Skip to content
Merged
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
3 changes: 2 additions & 1 deletion apps/server/src/auth/EnvironmentAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
type DpopFailureReason as DpopFailureReasonType,
mcpClientScopes,
} from "@t3tools/contracts";
import * as HostProcess from "@t3tools/shared/HostProcess";
import { isLocalLoopbackHost } from "@t3tools/shared/hostClassification";
import { encodeOAuthScope } from "@t3tools/shared/oauthScope";
import * as Context from "effect/Context";
Expand Down Expand Up @@ -730,7 +731,7 @@ export const make = Effect.gen(function* () {
const config = yield* ServerConfig.ServerConfig;
const managedPolicy = yield* ManagedPolicy.ManagedPolicy;
const devAuth = resolveReusableDevAuth(config);
const unsafeNoAuth = process.env.T3CODE_UNSAFE_NO_AUTH === "1";
const unsafeNoAuth = (yield* HostProcess.Environment).T3CODE_UNSAFE_NO_AUTH === "1";

const authenticateToken = (
token: string,
Expand Down
4 changes: 4 additions & 0 deletions apps/server/src/fork/claudeSteerQueue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ const startSteeredTurn = Effect.gen(function* () {
applyFlagSettings: () => Effect.void,
setPermissionMode: () => Effect.void,
backgroundTasks: () => Effect.succeed(false),
mcpServerStatus: Effect.succeed([]),
readMcpResource: () => Effect.die("unexpected MCP resource read"),
callMcpTool: () => Effect.die("unexpected MCP tool call"),
listPermissionRules: Effect.die("unexpected permission rules read"),
stopTask: () => Effect.void,
interrupt: Effect.die("a steer must not interrupt"),
close: Effect.void,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as NodeServices from "@effect/platform-node/NodeServices";
import { describe, expect, it } from "@effect/vitest";
import * as HostProcess from "@t3tools/shared/HostProcess";
import * as Effect from "effect/Effect";
import * as Queue from "effect/Queue";
import * as TestClock from "effect/testing/TestClock";
Expand Down Expand Up @@ -108,7 +109,7 @@ describe("claude usage event export", () => {
it.live("keeps the URL and key for the export and out of processes the server starts", () =>
Effect.gen(function* () {
const environment: NodeJS.ProcessEnv = {
PATH: process.env.PATH,
PATH: (yield* HostProcess.Environment).PATH,
T3CODE_CLAUDE_USAGE_EXPORT_URL: URL_,
T3CODE_CLAUDE_USAGE_EXPORT_KEY: KEY,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const layerTest = ProviderOrchestrationAdapterInfrastructure.layer.pipe(
Layer.provideMerge(
Layer.mock(SecretResolver.SecretResolver)({
read: (references) => Effect.succeed(references.map(() => undefined)),
label: (provider) => Effect.succeed(provider),
}),
),
Layer.provideMerge(
Expand Down
8 changes: 7 additions & 1 deletion apps/server/src/fork/generalRoleParity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { HttpBody, HttpClient, HttpRouter, HttpServer } from "effect/http";
import * as NetAddress from "effect/net/NetAddress";
import type { SDKUserMessage } from "@anthropic-ai/claude-agent-sdk";

import { AssetSigner } from "../assets/AssetSigner.ts";
import { ServerSecretStore } from "../auth/ServerSecretStore.ts";
import * as ServerConfig from "../config.ts";
import { DeviceService } from "../device/DeviceService.ts";
Expand Down Expand Up @@ -118,7 +119,7 @@ interface ProviderFixture {
readonly adapter: Effect.Effect<
ProviderAdapter.ProviderAdapterV2["Service"],
never,
McpProviderSessions.McpProviderSessions
McpProviderSessions.McpProviderSessions | Scope.Scope
>;
readonly firstRequest: (threadId: ThreadId) => Effect.Effect<ObservedRequest>;
},
Expand Down Expand Up @@ -225,6 +226,10 @@ const claude: ProviderFixture = {
applyFlagSettings: () => Effect.void,
setPermissionMode: () => Effect.void,
backgroundTasks: () => Effect.succeed(false),
mcpServerStatus: Effect.succeed([]),
readMcpResource: () => Effect.die("unexpected MCP resource read"),
callMcpTool: () => Effect.die("unexpected MCP tool call"),
listPermissionRules: Effect.die("unexpected permission rules read"),
stopTask: () => Effect.void,
interrupt: Effect.void,
close: Effect.void,
Expand Down Expand Up @@ -633,6 +638,7 @@ it.effect.each(

// Serving tools/list only reads registrations, so the handlers' services are never called.
const toolHandlerServices = Layer.mergeAll(
Layer.mock(AssetSigner)({}),
Layer.mock(DeviceService)({}),
Layer.mock(DocumentText)({}),
Layer.mock(GitVcsDriver.GitVcsDriver)({}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const idleCompactions = (options: {
}),
Layer.mock(ProjectionStore.ProjectionStoreV2)({
getThread: () => Effect.succeed(data.thread),
getThreadRecords: () => Effect.sync(() => data),
getThreadRecords: () => Effect.succeed(data),
}),
Layer.mock(LastUserInput.LastUserInput)({
atMs: () =>
Expand Down
13 changes: 7 additions & 6 deletions apps/server/src/fork/previewDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as Exit from "effect/Exit";
import * as FileSystem from "effect/FileSystem";
import * as Option from "effect/Option";
import * as Path from "effect/Path";
import * as Schema from "effect/Schema";
import * as Scope from "effect/Scope";
import * as Semaphore from "effect/Semaphore";
import * as Stream from "effect/Stream";
Expand Down Expand Up @@ -53,9 +54,9 @@ export const keepStartPage = (context: BrowserContext) => {
};
export const isStartPage = (page: Page) => startPages.has(page);

class PreviewDisplayError extends Error {
override readonly name = "PreviewDisplayError";
}
class PreviewDisplayError extends Schema.TaggedError<PreviewDisplayError>()("PreviewDisplayError", {
message: Schema.String,
}) {}

/**
* On Linux, each `env` call reads `enabled`. If true, it starts Xvfb when none is running and gives
Expand Down Expand Up @@ -127,9 +128,9 @@ export const make = Effect.fn("previewDisplay.make")(function* (
);
if (!/^\d+$/.test(display.trim())) {
yield* Scope.close(child, Exit.void);
return yield* Effect.fail(
new PreviewDisplayError(`T3's browser display did not start.\n${output}`.trim()),
);
return yield* new PreviewDisplayError({
message: `T3's browser display did not start.\n${output}`.trim(),
});
}
return {
env: { DISPLAY: `:${display.trim()}`, XAUTHORITY: authority },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,9 @@ const flavorOptions = {
selfInvocation: undefined as never,
makeRuntime: () => Effect.die("not spawned in this test"),
withProcess: (_stop, task) => task,
<<<<<<< origin/main
// @effect-diagnostics-next-line effectSucceedWithVoid:off - This optional result requires undefined, not the wider void type.
defaultModel: Effect.succeed(undefined),
defaultModel: Effect.undefined,
} satisfies Parameters<typeof makeAntigravityAcpAdapterFlavor>[0];
const flavor = makeAntigravityAcpAdapterFlavor(flavorOptions);
=======
defaultModel: Effect.undefined,
});
>>>>>>> upstream/main

function permissionRequest(
toolCallId: string,
Expand Down
4 changes: 0 additions & 4 deletions apps/server/src/orchestration-v2/Orchestrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -716,16 +716,12 @@ function mayStartSubagentFollowup(
if (command.scheduledTaskId !== undefined || command.restartContinuationOfRunId !== undefined)
return false;
if (command.notification !== undefined) return command.notification.source.kind !== "monitor";
<<<<<<< origin/main
if (command.delegatedCompletion !== undefined) return true;
return command.createdBy === "user" || command.creationSource === "mcp";
=======
return (
command.createdBy === "user" ||
command.creationSource === "mcp" ||
command.usageLimitContinuationOfRunId !== undefined
);
>>>>>>> upstream/main
}

/** Waiting runs only drain post-terminal output; their agent turn is over and still needs a wake. */
Expand Down
17 changes: 2 additions & 15 deletions apps/server/src/ws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3622,11 +3622,10 @@ export const layer = Layer.unwrap(
return yield* Effect.acquireUseRelease(
sessions.markConnected(session.sessionId),
() =>
<<<<<<< origin/main
EnvironmentAuth.isUnsafeNoAuthSession(session.sessionId)
? rpcWebSocketHttpEffect
? framedRpcWebSocketHttpEffect
: Effect.raceFirst(
rpcWebSocketHttpEffect,
framedRpcWebSocketHttpEffect,
sessions.awaitInvalidation(session.sessionId, session.proofKeyThumbprint).pipe(
Effect.as(HttpServerResponse.empty()),
Effect.catchTags({
Expand All @@ -3635,18 +3634,6 @@ export const layer = Layer.unwrap(
}),
),
),
=======
Effect.raceFirst(
framedRpcWebSocketHttpEffect,
sessions.awaitInvalidation(session.sessionId, session.proofKeyThumbprint).pipe(
Effect.as(HttpServerResponse.empty()),
Effect.catchTags({
SessionCredentialVerificationError: (error) =>
failEnvironmentInternal("internal_error", error),
}),
),
),
>>>>>>> upstream/main
() => sessions.markDisconnected(session.sessionId),
);
}).pipe(
Expand Down
21 changes: 10 additions & 11 deletions apps/web/src/fork/pdfWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@ export function getDocumentOnSharedWorker(params: Parameters<typeof getDocument>
worker ??= new PDFWorker();
open++;
const task = getDocument({ ...params, worker });
const destroy = task.destroy.bind(task);
let closed = false;
return {
promise: task.promise,
destroy() {
if (!closed && --open === 0)
idle = setTimeout(() => {
worker?.destroy();
worker = null;
}, IDLE_MS);
closed = true;
return task.destroy();
},
task.destroy = () => {
if (!closed && --open === 0)
idle = setTimeout(() => {
worker?.destroy();
worker = null;
}, IDLE_MS);
closed = true;
return destroy();
};
return task;
}
7 changes: 1 addition & 6 deletions packages/contracts/src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1256,15 +1256,14 @@ export const ServerSettings = Schema.Struct({
),

enableAgentBrowserAccess: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
<<<<<<< origin/main
/**
* Fork: "native" runs chrome-headless-shell. On Linux and Windows, "xvfb" runs full Chrome for
* Testing. On Linux with Xvfb, Chrome opens a window on a private Xvfb display. On macOS "xvfb"
* runs chrome-headless-shell, the same browser as "native".
*/
previewBrowserMode: PreviewBrowserMode.pipe(
Schema.withDecodingDefault(Effect.succeed("native" as const)),
=======
),
speechModelId: Schema.String.pipe(
Schema.withDecodingDefault(Effect.succeed("handy-computer/parakeet-unified-en-0.6b-gguf")),
),
Expand All @@ -1277,7 +1276,6 @@ export const ServerSettings = Schema.Struct({
// Null follows textGenerationModelSelection; a selection pins transcript cleanup to its own model.
speechPostProcessingModelSelection: Schema.NullOr(ModelSelection).pipe(
Schema.withDecodingDefault(Effect.succeed(null)),
>>>>>>> upstream/main
),
projectAgentBrowserAccessOverrides: Schema.Record(ProjectId, Schema.Boolean).pipe(
Schema.withDecodingDefault(Effect.succeed({})),
Expand Down Expand Up @@ -1686,15 +1684,12 @@ export const ServerSettingsPatch = Schema.Struct({
enableProviderUpdateChecks: Schema.optionalKey(Schema.Boolean),
continueThreadsAfterServerUpdate: Schema.optionalKey(Schema.Boolean),
enableAgentBrowserAccess: Schema.optionalKey(Schema.Boolean),
<<<<<<< origin/main
previewBrowserMode: Schema.optionalKey(PreviewBrowserMode),
=======
speechModelId: Schema.optionalKey(Schema.String),
speechAcceleration: Schema.optionalKey(SpeechAcceleration),
speechModelUnloadTimeout: Schema.optionalKey(SpeechModelUnloadTimeout),
speechProjectCustomWords: Schema.optionalKey(SpeechCustomWords),
speechPostProcessingModelSelection: Schema.optionalKey(Schema.NullOr(ModelSelection)),
>>>>>>> upstream/main
projectAgentBrowserAccessOverrides: Schema.optionalKey(
Schema.Record(ProjectId, Schema.NullOr(Schema.Boolean)),
),
Expand Down
6 changes: 0 additions & 6 deletions packages/provider-acp/src/server/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6856,11 +6856,8 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
const mcpContext = yield* readMcpContext(threadId);
runtimeMcpBridge = yield* makeRuntimeMcpBridge(mcpContext, runtimeScope);
const runtimeGeneration = yield* Ref.get(runtimeCallbackGeneration);
<<<<<<< origin/main
runtimeAccount = yield* readAccount;
=======
openAgentRequests = new Set();
>>>>>>> upstream/main
runtime = yield* flavor
.makeRuntime(
makeRuntimeInput(runtimeGeneration, openAgentRequests, mcpContext, resumeSessionId),
Expand Down Expand Up @@ -7005,11 +7002,8 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
runtime = replacementExit.value.replacementRuntime;
runtimeScope = replacementScope;
runtimeMcpBridge = replacementMcpBridge;
<<<<<<< origin/main
runtimeAccount = replacementExit.value.replacementAccount;
=======
openAgentRequests = replacementAgentRequests;
>>>>>>> upstream/main
yield* Ref.set(runtimeCallbackGeneration, replacementGeneration);
prepareTerminalEnvironment(
yield* readMcpContext(threadId),
Expand Down
Loading