Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/mcp/McpHttpServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ export const layerPullRequestsToolkit = toolkitRegistration(
PullRequestsHandlers.layer,
).pipe(Layer.provide(PullRequestWatchService.layer));

export const layerEventsToolkit = toolkitRegistration(EventsToolkit, EventsHandlers.layer).pipe(
const layerEventsToolkit = toolkitRegistration(EventsToolkit, EventsHandlers.layer).pipe(
Layer.provide(PullRequestWatchService.layer),
);

Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/orchestration-v2/contextBoundary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { OrchestrationV2Run, OrchestrationV2ThreadProjection } from "@t3too
import { cancelledBeforeStart } from "./RestartBackgroundNote.ts";

/** A fresh-session schedule run starts a side conversation; the thread's own one continues past it. */
export function isScheduledFreshRun(
function isScheduledFreshRun(
run: Pick<OrchestrationV2Run, "freshContext" | "userMessageId">,
turnItems: OrchestrationV2ThreadProjection["turnItems"],
): boolean {
Expand Down
13 changes: 5 additions & 8 deletions apps/server/src/orchestration-v2/eventSubscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,20 @@ export const emptyCursor = (): SubscriptionCursor => ({
deliveredSignatures: {},
});

export function canonicalAuthor(login: string): string {
function canonicalAuthor(login: string): string {
return login
.trim()
.toLowerCase()
.replace(/\[bot\]$/i, "");
}

export function authorIgnored(
login: string | null | undefined,
ignore: readonly string[],
): boolean {
function authorIgnored(login: string | null | undefined, ignore: readonly string[]): boolean {
if (login == null || login.trim() === "") return false;
const key = canonicalAuthor(login);
return ignore.some((entry) => canonicalAuthor(entry) === key);
}

export function normalizePullRequestUrl(raw: string): string {
function normalizePullRequestUrl(raw: string): string {
const url = new URL(raw);
url.hash = "";
url.search = "";
Expand Down Expand Up @@ -95,7 +92,7 @@ export interface DeliveryInput {
readonly maxWakesPerHour?: number | null | undefined;
}

export function normalizeDelivery(
function normalizeDelivery(
input: DeliveryInput | undefined,
):
| { readonly ok: true; readonly delivery: EventDeliveryPolicy }
Expand Down Expand Up @@ -159,7 +156,7 @@ function validateQuietHours(hours: QuietHours): string | null {
}

/** Minutes from midnight in the zone. Throws when the zone is invalid. */
export function minutesInZone(nowMs: number, timeZone: string): number {
function minutesInZone(nowMs: number, timeZone: string): number {
const parts = new Intl.DateTimeFormat("en-US", {
timeZone,
hour: "2-digit",
Expand Down
2 changes: 1 addition & 1 deletion apps/server/src/provider/agentContextBudget.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"claudeSystemAppendBytes": 5930,
"codexAdditionalContextBytes": 7324,
"mcpToolListJsonBytes": 61564
"mcpToolListJsonBytes": 61917
}
16 changes: 0 additions & 16 deletions packages/client-runtime/src/operations/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,22 +630,6 @@ export const setThreadStanding = Effect.fn("EnvironmentCommands.setThreadStandin
});
});

export interface SetThreadDelegationNudgeInput extends ThreadCommandInput {
readonly enabled: boolean;
readonly thresholds?: ReadonlyArray<number>;
}
export const setThreadDelegationNudge = Effect.fn("EnvironmentCommands.setThreadDelegationNudge")(
function* (input: SetThreadDelegationNudgeInput) {
return yield* dispatch({
type: "thread.delegation-nudge.set",
commandId: yield* allocateCommandId(input),
threadId: input.threadId,
enabled: input.enabled,
...(input.thresholds === undefined ? {} : { thresholds: [...input.thresholds] }),
});
},
);

export interface SetThreadAutoSettleInput extends ThreadCommandInput {
readonly enabled: boolean;
}
Expand Down
13 changes: 12 additions & 1 deletion packages/provider-testing/src/replayWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class ReplayFixtureGitCommandError extends Schema.TaggedError<ReplayFixtureGitCo
}
}

const INHERITED_REPOSITORY_ENV = {
GIT_DIR: undefined,
GIT_WORK_TREE: undefined,
GIT_COMMON_DIR: undefined,
GIT_INDEX_FILE: undefined,
GIT_OBJECT_DIRECTORY: undefined,
GIT_ALTERNATE_OBJECT_DIRECTORIES: undefined,
};

function runGit(
cwd: string,
args: ReadonlyArray<string>,
Expand All @@ -29,7 +38,9 @@ function runGit(
> {
return Effect.gen(function* () {
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const exitCode = yield* spawner.exitCode(ChildProcess.make("git", args, { cwd }));
const exitCode = yield* spawner.exitCode(
ChildProcess.make("git", args, { cwd, env: INHERITED_REPOSITORY_ENV, extendEnv: true }),
);
if (Number(exitCode) !== 0) {
return yield* new ReplayFixtureGitCommandError({
command: `git ${args.join(" ")}`,
Expand Down
41 changes: 2 additions & 39 deletions scripts/scenarios/mention-finds-older-linked-thread.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,54 +1,17 @@
import * as NodeCrypto from "@effect/platform-node/NodeCrypto";
import * as NodeWS from "@effect/platform-node/NodeWS";
import {
CommandId,
ORCHESTRATION_PROTOCOL_VERSION,
ThreadId,
WsRpcGroup,
} from "@t3tools/contracts";
import { CommandId, ThreadId } from "@t3tools/contracts";
import { expect } from "e2e";
import * as SecureRandom from "effect/crypto/SecureRandom";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import * as Schema from "effect/Schema";
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
import { RpcClient, RpcSerialization } from "effect/rpc";
import { Socket } from "effect/socket";

import { T3_HOME } from "../e2e.config.ts";
import { SECOND_HOME, startSecondServer } from "./second-server.ts";
import { makeState, runPromise, test, WEB } from "./t3.ts";
import { makeState, rpcClient, runPromise, test, WEB } from "./t3.ts";

// A shell keeps an environment's 25 newest settled threads; older ones come from search.
const NEWER_SETTLED = 25;

/** The typed RPC client of the server on `home` at `origin`, signed in through its own CLI. */
const rpcClient = Effect.fn("scenario.rpcClient")(function* (home: string, origin: string) {
const issued = yield* makeState(home).cli(["auth", "session", "issue", "--token-only"]);
const { ticket } = yield* HttpClient.execute(
HttpClientRequest.post(`${origin}/api/auth/websocket-ticket`).pipe(
HttpClientRequest.bearerToken(issued.stdout.trim()),
),
).pipe(
Effect.flatMap(HttpClientResponse.filterStatusOk),
Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Struct({ ticket: Schema.String }))),
Effect.provide(FetchHttpClient.layer),
);
// Built into the caller's scope: `Effect.provide` would close the socket once `make` returns.
const protocol = yield* Layer.build(
RpcClient.layerProtocolSocket().pipe(
Layer.provide(
Socket.layerWebSocket(
`${origin.replace(/^http/, "ws")}/ws?orchestrationProtocol=${ORCHESTRATION_PROTOCOL_VERSION}&wsTicket=${encodeURIComponent(ticket)}`,
),
),
Layer.provide(RpcSerialization.layerJson),
Layer.provide(NodeWS.layerWebSocketConstructor),
),
);
return yield* RpcClient.make(WsRpcGroup).pipe(Effect.provideContext(protocol));
});

const uuid = Effect.flatMap(SecureRandom.SecureRandom, (random) => random.uuidV4());
const decodePairing = Schema.decodeEffect(
Schema.fromJsonString(Schema.Struct({ credential: Schema.String })),
Expand Down
34 changes: 33 additions & 1 deletion scripts/scenarios/t3.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
// `test` for web scenarios: e2e's web test plus `t3`, which seeds state and opens the signed-in
// app. `t3-mobile.ts` is the same for the iOS app.
import * as NodeServices from "@effect/platform-node/NodeServices";
import * as NodeWS from "@effect/platform-node/NodeWS";
import { test as base } from "@e2e-dev/web";
import { ORCHESTRATION_PROTOCOL_VERSION, WsRpcGroup } from "@t3tools/contracts";
import { expect } from "e2e";
import * as HostProcess from "@t3tools/shared/HostProcess";
import * as Effect from "effect/Effect";
import * as FileSystem from "effect/FileSystem";
import * as Layer from "effect/Layer";
import * as Path from "effect/Path";
import * as Schema from "effect/Schema";
import { FetchHttpClient, HttpClient, HttpClientResponse } from "effect/http";
import { FetchHttpClient, HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
import { RpcClient, RpcSerialization } from "effect/rpc";
import { Socket } from "effect/socket";

import { APP_DIR, T3_HOME } from "../e2e.config.ts";
import { run } from "./shell.ts";
Expand Down Expand Up @@ -149,6 +154,33 @@ const environmentId = (baseUrl: string) =>
Effect.provide(FetchHttpClient.layer),
);

/** The typed RPC client of the server on `home` at `origin`, signed in through its own CLI. */
export const rpcClient = Effect.fn("scenario.rpcClient")(function* (home: string, origin: string) {
const issued = yield* makeState(home).cli(["auth", "session", "issue", "--token-only"]);
const { ticket } = yield* HttpClient.execute(
HttpClientRequest.post(`${origin}/api/auth/websocket-ticket`).pipe(
HttpClientRequest.bearerToken(issued.stdout.trim()),
),
).pipe(
Effect.flatMap(HttpClientResponse.filterStatusOk),
Effect.flatMap(HttpClientResponse.schemaBodyJson(Schema.Struct({ ticket: Schema.String }))),
Effect.provide(FetchHttpClient.layer),
);
// Built into the caller's scope: `Effect.provide` would close the socket once `make` returns.
const protocol = yield* Layer.build(
RpcClient.layerProtocolSocket().pipe(
Layer.provide(
Socket.layerWebSocket(
`${origin.replace(/^http/, "ws")}/ws?orchestrationProtocol=${ORCHESTRATION_PROTOCOL_VERSION}&wsTicket=${encodeURIComponent(ticket)}`,
),
),
Layer.provide(RpcSerialization.layerJson),
Layer.provide(NodeWS.layerWebSocketConstructor),
),
);
return yield* RpcClient.make(WsRpcGroup).pipe(Effect.provideContext(protocol));
});

export const test = base.extend<{ t3: T3 }>({
t3: async ({ app, browser }, use) => {
const { state, cleanup } = makeState(T3_HOME);
Expand Down
Loading