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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ FROM core AS browser

# Browser automation over MCP. T3 Code's own preview tools are hosted by the
# web/desktop client, so a phone-only setup has no eyes without this.
ARG CHROME_DEVTOOLS_MCP_VERSION=1.13.0
ARG CHROME_DEVTOOLS_MCP_VERSION=1.14.0
ARG PLAYWRIGHT_MCP_VERSION=0.0.86

RUN set -eux; \
Expand Down
8 changes: 4 additions & 4 deletions docker/browser-mcp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docker/browser-mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"description": "Pinned browser automation MCP servers for the browser image stage. Versions mirror the Dockerfile ARGs; refresh both with scripts/bump-versions.sh.",
"dependencies": {
"@playwright/mcp": "0.0.86",
"chrome-devtools-mcp": "1.13.0"
"chrome-devtools-mcp": "1.14.0"
}
}
99 changes: 85 additions & 14 deletions docker/runtime/patches/opencode-skills.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,43 @@ const shapes = [
client.provider.list({ location }).pipe(Effect.timeout("10 seconds"), Effect.ignore),
processEnv,`,
},
// Reviewed against v0.1.12-nightly.20261124.5209 (84e4264bb347e36e97f6c3bd95d666eecfa12e07).
{
directory: "directory",
environment: true,
tracksScans: true,
comment: "/**\n * Until its scan ends a location lists only built-ins, even once the server lists it as loaded,\n * and nothing but the scan's end tells the two apart. Unless the caller saw that scan end, read to\n * boot the location, wait for its scan (`scanned` must listen before `read`), and read again.\n */\n",
loader: ` function* <E>(
read: Effect.Effect<OpenCode2Workspace, E>,
scanned: Effect.Effect<void>,
sawScan: boolean,
environment?: NodeJS.ProcessEnv,
) {
const first = yield* read;
if (sawScan) return first;
yield* scanned.pipe(
Effect.timeoutOption(resolveProviderProbeTimeoutMs("opencode", 10_000, environment)),
);
return yield* read;
},`,
argument: ` Deferred.await(scanned),
// Without events no scan can be awaited, so trust the first read as before.
stream._tag === "None" || seen.has(directory),
processEnv,`,
},
];

const nativeReadiness = ` const scanned = client.plugin.list({ location }).pipe(
Effect.repeat({
until: (plugins) => ["opencode.config.skill", "opencode.config.command"].every(
(id) => plugins.data.some((plugin) => plugin.id === id && plugin.state?.status === "active"),
),
schedule: Schedule.spaced("100 millis"),
}),
Effect.asVoid,
);
`;

function mismatch(file) {
return new Error(`The opencode-skills patch no longer matches ${file}. Review the upstream source before publishing this runtime.`);
}
Expand All @@ -127,10 +162,54 @@ export function patchOpenCodeSkills(source) {
change(files[0], normalized, normalized);
}
change(files[0], 'import * as Deferred from "effect/Deferred";', 'import * as Schedule from "effect/Schedule";');
change(files[0], 'import * as Stream from "effect/Stream";\n', "");
change(files[0], "openCode2Server.withConnection(({ client, events }) =>", "openCode2Server.withConnection(({ client }) =>");
change(files[0],
` const scanned = yield* Deferred.make<void>();
if (shape.tracksScans) {
change(files[0], " followOpenCode2Scans,\n", "");
change(files[0], "openCode2Server.withConnection(({ client, events, url }) =>", "openCode2Server.withConnection(({ client }) =>");
change(files[0],
` // Locations whose scan T3 saw end on the current server; a scan is announced only once.
let scans = { url: "", scanned: new Set<string>() };
const followScans = (connection: OpenCode2Server.OpenCode2Connection) =>
Effect.suspend(() => {
const scanned = new Set<string>();
scans = { url: connection.url, scanned };
return connection.events.pipe(
Effect.flatMap((events) =>
followOpenCode2Scans(events, (directory) => Effect.sync(() => scanned.add(directory))),
),
Effect.scoped,
Effect.ignore,
Effect.forkScoped,
);
});
// A session or text generation can start the server too, and reads no catalog when it does.
yield* Stream.runForEach(openCode2Server.connections, (connection) =>
followScans(connection).pipe(Effect.andThen(followMachineCatalog(connection))),
).pipe(Effect.forkScoped);
`, ` // A session or text generation can start the server too, and reads no catalog when it does.
yield* Stream.runForEach(openCode2Server.connections, followMachineCatalog).pipe(Effect.forkScoped);
`);
change(files[0],
` if (scans.url !== url) scans = { url, scanned: new Set() };
const { scanned: seen } = scans;
const scanned = yield* Deferred.make<void>();
const stream = yield* events.pipe(Effect.option);
if (stream._tag === "Some") {
yield* followOpenCode2Scans(stream.value, (scannedDirectory) =>
scannedDirectory === directory
? Deferred.succeed(scanned, undefined).pipe(Effect.asVoid)
: Effect.void,
).pipe(Effect.forkScoped);
}
`, nativeReadiness);
change(files[0],
` // A location loaded before T3 watched never announces its scan; wait for it only once.
seen.add(directory);
`, "");
} else {
change(files[0], 'import * as Stream from "effect/Stream";\n', "");
change(files[0], "openCode2Server.withConnection(({ client, events }) =>", "openCode2Server.withConnection(({ client }) =>");
change(files[0],
` const scanned = yield* Deferred.make<void>();
const pending = new Set(["command.updated", "skill.updated"]);
const stream = yield* events.pipe(Effect.option);
if (stream._tag === "Some") {
Expand All @@ -148,16 +227,8 @@ export function patchOpenCodeSkills(source) {
);
}
`,
` const scanned = client.plugin.list({ location }).pipe(
Effect.repeat({
until: (plugins) => ["opencode.config.skill", "opencode.config.command"].every(
(id) => plugins.data.some((plugin) => plugin.id === id && plugin.state?.status === "active"),
),
schedule: Schedule.spaced("100 millis"),
}),
Effect.asVoid,
);
`);
nativeReadiness);
}
const callEnd = shape.directory === "directory" ? "\n );" : "";
change(files[0], shape.argument + callEnd,
" scanned," + (shape.environment ? "\n processEnv," : "") + callEnd);
Expand Down
10 changes: 8 additions & 2 deletions docker/setup/antigravity.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
// short cache, so a status poll never waits on T3.
export const INSTANCE = "antigravity";

export function antigravityCodePrompt(interaction) {
if (interaction?.type !== "credentials" || !interaction.id || !Array.isArray(interaction.fields)) return null;
const field = ["code", "authorizationCode"].find((name) => interaction.fields.some((entry) => entry?.name === name));
return field ? { id: interaction.id, field } : null;
}

// T3 names a release `agy_acp_server_1.1.1`; the page says 1.1.1.
const shortVersion = (value) => (value ? String(value).replace(/^agy_acp_server_/, "") : null);
const BUSY = new Set(["downloading", "extracting", "verifying"]);
Expand Down Expand Up @@ -232,8 +238,8 @@ export function createAntigravity({ api, now = Date.now, maxAgeMs = 15_000 }) {
}
};
const completeSignIn = (flowId, callbackUrl) => api.call("provider.auth.complete", { instanceId: INSTANCE, flowId, callbackUrl });
const submitSignInCode = (flowId, interactionId, code) => api.call("provider.auth.respond", {
instanceId: INSTANCE, flowId, interactionId, response: { type: "credentials", values: { authorizationCode: code } },
const submitSignInCode = (flowId, prompt, code) => api.call("provider.auth.respond", {
instanceId: INSTANCE, flowId, interactionId: prompt.id, response: { type: "credentials", values: { [prompt.field]: code } },
});
const cancelSignIn = (flowId) => api.call("provider.auth.cancel", { instanceId: INSTANCE, flowId });
/** After a sign-in: have T3 check access again, then read it. */
Expand Down
21 changes: 10 additions & 11 deletions docker/setup/server.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { createFilesService, FILES_ROUTES, FILES_POST_ROUTES, filesFailure } fro
import { createHoldControl } from './files/hold.mjs';
import { createLatestCache } from "./latest.mjs";
import { createT3Api } from "./t3-api.mjs";
import { createAntigravity } from "./antigravity.mjs";
import { antigravityCodePrompt, createAntigravity } from "./antigravity.mjs";
import { createT3Sessions } from "./t3-session.mjs";
import { createDeviceLabels } from "./device-labels.mjs";
import * as Context from "./context.mjs";
Expand Down Expand Up @@ -1691,15 +1691,15 @@ const startAntigravitySignin = async () => {
const session = {
id, agentId: "antigravity", state: "starting", url: null, code: null,
needsCode: true, output: "", error: null, child: null, t3: true,
flow: null, flowId: null, codeInteractionId: null, expiresAt: null, startedAt: Date.now(),
flow: null, flowId: null, codePrompt: null, expiresAt: null, startedAt: Date.now(),
};
sessions.set(id, session);
const end = (state, error = null) => {
if (TERMINAL_STATES.has(session.state)) return;
session.state = state;
session.error = error;
session.url = null;
session.codeInteractionId = null;
session.codePrompt = null;
session.flow?.close();
sessionStore.settle(session);
};
Expand All @@ -1710,8 +1710,7 @@ const startAntigravitySignin = async () => {
if (Number.isFinite(expires)) session.expiresAt = expires;
if (state.phase === "waiting" && state.authorizationUrl) {
session.url = state.authorizationUrl;
session.codeInteractionId = state.interaction?.type === "credentials" &&
state.interaction.fields?.some((field) => field.name === "authorizationCode") ? state.interaction.id : null;
session.codePrompt = antigravityCodePrompt(state.interaction);
if (session.state === "starting") session.state = "awaiting-code";
} else if (state.phase === "verifying") {
session.state = "submitted";
Expand Down Expand Up @@ -1742,7 +1741,7 @@ const startAntigravitySignin = async () => {
const publicSession = (s) => ({
id: s.id, agent: s.agentId, state: s.state, url: s.url, code: s.code, qr: s.qr ?? null,
needsCode: s.needsCode, error: s.error, identity: s.identity ?? null, warning: s.warning ?? null,
googleAuthorizationCode: Boolean(s.codeInteractionId),
googleAuthorizationCode: Boolean(s.codePrompt),
// When the wait for the browser step gives up, for the device code's countdown.
startedAt: s.startedAt, expiresAt: s.expiresAt ?? s.startedAt + SESSION_TTL_MS,
tail: s.output.trim().split("\n").slice(-4).join("\n"),
Expand Down Expand Up @@ -3283,15 +3282,15 @@ const server = createServer(async (req, res) => {
if (session.t3) {
if (session.state !== "awaiting-code") return sendJson(res, 409, { error: "This sign-in is no longer waiting for a response." });
const code = String(input.code ?? "").trim();
const expectsCode = Boolean(session.codeInteractionId);
if (expectsCode && (!/^[!-~]{1,4096}$/u.test(code) || /^https?:\/\//i.test(code))) {
const prompt = session.codePrompt;
if (prompt && (!/^[!-~]{1,4096}$/u.test(code) || /^https?:\/\//i.test(code))) {
return sendJson(res, 400, { error: "Paste the authorization code shown by Google." });
}
if (!expectsCode && (!/^https?:\/\//i.test(code) || code.length > 16384)) {
if (!prompt && (!/^https?:\/\//i.test(code) || code.length > 16384)) {
return sendJson(res, 400, { error: "Paste the whole address from the browser's address bar, starting with http://127.0.0.1." });
}
try {
if (session.codeInteractionId) await antigravity.submitSignInCode(session.flowId, session.codeInteractionId, code);
if (prompt) await antigravity.submitSignInCode(session.flowId, prompt, code);
else await antigravity.completeSignIn(session.flowId, code);
if (!TERMINAL_STATES.has(session.state)) session.state = "submitted";
session.submittedAt = Date.now();
Expand Down Expand Up @@ -3332,7 +3331,7 @@ const server = createServer(async (req, res) => {
if (session.flowId && !TERMINAL_STATES.has(session.state)) void antigravity.cancelSignIn(session.flowId).catch(() => {});
session.state = "cancelled";
session.url = null;
session.codeInteractionId = null;
session.codePrompt = null;
session.flow?.close();
} else if (session) {
session.state = "cancelled";
Expand Down
101 changes: 101 additions & 0 deletions tests/fixtures/opencode-workspace-scans-source.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// Excerpts from upstream Nightly 5209 at 84e4264bb347e36e97f6c3bd95d666eecfa12e07.
export const scansSource = {
"packages/provider-opencode/src/server/driver.ts": `import * as Deferred from "effect/Deferred";
import * as Stream from "effect/Stream";
followOpenCode2Scans,
const catalogWatch = yield* makeOpenCode2CatalogWatch(processEnv);
// An external server may not have the host's cwd; without a location it uses its own default.
const machineDirectory = (connection: OpenCode2Server.OpenCode2Connection) =>
connection.external ? undefined : host.paths.cwd;
const followMachineCatalog = (connection: OpenCode2Server.OpenCode2Connection) =>
catalogWatch.follow(
connection.url,
connection.events,
loadOpenCode2DirectoryCatalog(connection.client, machineDirectory(connection)),
);
// Locations whose scan T3 saw end on the current server; a scan is announced only once.
let scans = { url: "", scanned: new Set<string>() };
const followScans = (connection: OpenCode2Server.OpenCode2Connection) =>
Effect.suspend(() => {
const scanned = new Set<string>();
scans = { url: connection.url, scanned };
return connection.events.pipe(
Effect.flatMap((events) =>
followOpenCode2Scans(events, (directory) => Effect.sync(() => scanned.add(directory))),
),
Effect.scoped,
Effect.ignore,
Effect.forkScoped,
);
});
// A session or text generation can start the server too, and reads no catalog when it does.
yield* Stream.runForEach(openCode2Server.connections, (connection) =>
followScans(connection).pipe(Effect.andThen(followMachineCatalog(connection))),
).pipe(Effect.forkScoped);
const loadOpenCode2Models = yield* makeOpenCode2ModelLoader(
openCode2Server.withConnection((connection) =>
followMachineCatalog(connection).pipe(
Effect.andThen(loadOpenCode2Catalog(connection.client, machineDirectory(connection))),
),
),
processEnv,
);
const listOpenCode2Workspace = (cwd: string) =>
openCode2Server.withConnection(({ client, events, url }) =>
Effect.gen(function* () {
// OpenCode names a location by its resolved path (no trailing slash or \`..\`).
const directory = pathService.resolve(cwd);
const location = { directory };
if (scans.url !== url) scans = { url, scanned: new Set() };
const { scanned: seen } = scans;
const scanned = yield* Deferred.make<void>();
const stream = yield* events.pipe(Effect.option);
if (stream._tag === "Some") {
yield* followOpenCode2Scans(stream.value, (scannedDirectory) =>
scannedDirectory === directory
? Deferred.succeed(scanned, undefined).pipe(Effect.asVoid)
: Effect.void,
).pipe(Effect.forkScoped);
}
const workspace = yield* loadOpenCode2Workspace(
Effect.all(
{
skills: client.skill.list({ location }).pipe(Effect.map((list) => list.data)),
commands: client.command.list({ location }).pipe(Effect.map((list) => list.data)),
},
{ concurrency: "unbounded" },
),
Deferred.await(scanned),
// Without events no scan can be awaited, so trust the first read as before.
stream._tag === "None" || seen.has(directory),
processEnv,
);
// A location loaded before T3 watched never announces its scan; wait for it only once.
seen.add(directory);
return workspace;
}).pipe(Effect.scoped),
);
`,
"packages/provider-opencode/src/server/status.ts": `/**
* Until its scan ends a location lists only built-ins, even once the server lists it as loaded,
* and nothing but the scan's end tells the two apart. Unless the caller saw that scan end, read to
* boot the location, wait for its scan (\`scanned\` must listen before \`read\`), and read again.
*/
export const loadOpenCode2Workspace = Effect.fn("OpencodeProviderStatus.loadOpenCode2Workspace")(
function* <E>(
read: Effect.Effect<OpenCode2Workspace, E>,
scanned: Effect.Effect<void>,
sawScan: boolean,
environment?: NodeJS.ProcessEnv,
) {
const first = yield* read;
if (sawScan) return first;
yield* scanned.pipe(
Effect.timeoutOption(resolveProviderProbeTimeoutMs("opencode", 10_000, environment)),
);
return yield* read;
},
);

`,
};
21 changes: 21 additions & 0 deletions tests/opencode-workspace-patch.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import test from "node:test";
import { source } from "./fixtures/opencode-workspace-source.mjs";
import { normalizedSource } from "./fixtures/opencode-workspace-normalized-source.mjs";
import { settledSource } from "./fixtures/opencode-workspace-settled-source.mjs";
import { scansSource } from "./fixtures/opencode-workspace-scans-source.mjs";
import { files, patchOpenCodeSkills } from "../docker/runtime/patches/opencode-skills.mjs";
import { patches } from "../docker/runtime/patches/index.mjs";

Expand Down Expand Up @@ -75,3 +76,23 @@ test("settled Nightly replaces the upstream catalog barrier with native plugin r
assert.throws(() => patchOpenCodeSkills(changed), /no longer matches/, "unreviewed settlement changes fail closed");
}
});

test("Nightly 5209 waits for config plugins and keeps watching the model catalog", () => {
const before = structuredClone(scansSource);
const [driver, status] = files;
const result = patchOpenCodeSkills(scansSource);
assert.deepEqual(scansSource, before);
assert.match(result[driver], /Stream\.runForEach\(openCode2Server\.connections, followMachineCatalog\)/);
assert.match(result[driver], /const directory = pathService\.resolve\(cwd\);/);
assert.match(result[driver], /client\.plugin\.list\(\{ location \}\)/);
assert.match(result[driver], /opencode\.config\.skill/);
assert.match(result[driver], /opencode\.config\.command/);
assert.match(result[driver], /scanned,\s+processEnv,/);
assert.doesNotMatch(result[driver], /followScans|followOpenCode2Scans|seen\.|Deferred/);
assert.match(result[status], /yield\* read;\s+yield\* scanned\.pipe\(Effect\.timeout\(resolveProviderProbeTimeoutMs\("opencode", 10_000, environment\)\)\);\s+return yield\* read;/);
assert.doesNotMatch(result[status], /sawScan|timeoutOption/);
for (const [file, anchor] of [[driver, 'seen.has(directory)'], [status, 'if (sawScan) return first;']]) {
const changed = { ...scansSource, [file]: scansSource[file].replace(anchor, '') };
assert.throws(() => patchOpenCodeSkills(changed), /no longer matches/);
}
});
Loading
Loading