From a091f4db30c790aee2d32856d691923b866635cb Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 4 Nov 2026 16:29:50 +0000 Subject: [PATCH 1/9] test(server): reproduce Kiro secret storage not offered to the agent (#30948) These tests reproduce pingdotgg/t3code#30948. T3 does not advertise `clientCapabilities._meta.kiro.secretStorage`, so Kiro never asks for the OAuth tokens it stores for MCP servers. It also answers `_kiro/secret/*` requests with "Method not found" instead of reading and writing /secrets.json. When a client frame mismatches, the ACP replay agent now rejects every client request still pending, with the mismatch detail. Before, a mismatched response left `session/new` unanswered and the test hung until it timed out. Co-Authored-By: Claude Opus 5.5 --- apps/server/scripts/acp-replay-agent.ts | 16 +-- .../Adapters/KiroAdapterV2.test.ts | 100 +++++++++++++++++- 2 files changed, 109 insertions(+), 7 deletions(-) diff --git a/apps/server/scripts/acp-replay-agent.ts b/apps/server/scripts/acp-replay-agent.ts index c68366828e91e..2eba80dbcc1c9 100644 --- a/apps/server/scripts/acp-replay-agent.ts +++ b/apps/server/scripts/acp-replay-agent.ts @@ -158,6 +158,14 @@ function stopWithFailure(detail: string, actual?: unknown): void { }; writeStatus(failure); process.stderr.write(`ACP replay mismatch: ${JSON.stringify(failure)}\n`); + // Reject what the client still awaits, so a test fails with the mismatch instead of hanging. + const message = `ACP replay mismatch at ${entry?.label ?? "end of transcript"}: ${detail}${ + actual === undefined ? "" : ` ${JSON.stringify(actual)}` + }`; + for (const id of pendingClientRequestIds.values()) { + send({ jsonrpc: "2.0", id, error: { code: -32603, message } }); + } + pendingClientRequestIds.clear(); process.exitCode = 1; process.stdin.pause(); } @@ -284,14 +292,10 @@ function handleMessage(message: JsonRpcMessage): void { } const entry = transcript.entries[cursor]; if (entry?.type !== "expect_outbound" || !matchesExpected(entry.frame, actual)) { - stopWithFailure("Unexpected outbound ACP frame", actual); if (actual.kind === "request" && message.id !== undefined && message.id !== null) { - send({ - jsonrpc: "2.0", - id: message.id, - error: { code: -32603, message: "ACP replay frame mismatch" }, - }); + pendingClientRequestIds.set(actual.method, message.id); } + stopWithFailure("Unexpected outbound ACP frame", actual); return; } if (actual.kind === "request" && message.id !== undefined && message.id !== null) { diff --git a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts index 30304449c0f06..76fcad8309b5c 100644 --- a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts @@ -293,6 +293,38 @@ const openSessionFrames = (input: { }), ]; +/** Kiro keys an MCP server's OAuth tokens by a hash of the server; the value is a JSON string. */ +const MCP_TOKENS_KEY = "kiro.mcp.4f1c2a9e.tokens"; +const MCP_TOKENS = JSON.stringify({ access_token: "stored-token", token_type: "Bearer" }); + +const kiroSecretRequest = (method: string, params: unknown): Frame => ({ + type: "emit_inbound", + label: method, + frame: { kind: "request", method, params }, +}); +const kiroSecretResponse = (method: string, result: unknown): Frame => ({ + type: "expect_outbound", + label: `${method}.result`, + frame: { kind: "response", method, result }, +}); + +/** + * A temp KIRO_HOME whose `secrets.json` holds `secrets`, the flat map kiro-cli + * keeps there. HOME points elsewhere so only KIRO_HOME can find the file. + */ +const makeKiroHome = Effect.fn("makeKiroHome")(function* (secrets: Record) { + const fileSystem = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-kiro-home-" }); + const kiroHome = path.join(root, "kiro-home"); + const home = path.join(root, "home"); + yield* fileSystem.makeDirectory(kiroHome); + yield* fileSystem.makeDirectory(home); + const secretsPath = path.join(kiroHome, "secrets.json"); + yield* fileSystem.writeFileString(secretsPath, JSON.stringify(secrets, null, 2)); + return { secretsPath, environment: { HOME: home, KIRO_HOME: kiroHome } }; +}); + const runKiroScript = Effect.fn("runKiroScript")(function* (input: { readonly scenario: string; readonly frames: ReadonlyArray; @@ -300,6 +332,7 @@ const runKiroScript = Effect.fn("runKiroScript")(function* (input: { /** Option selections (e.g. reasoningEffort) for the session and `startTurn`. */ readonly options?: ModelSelection["options"]; readonly runtimeMode?: RuntimeMode; + readonly environment?: NodeJS.ProcessEnv; /** Holds the script's inbound frames at labels the test releases. */ readonly replayGate?: ProviderReplayGate; readonly testHooks?: Parameters[0]["testHooks"]; @@ -349,7 +382,7 @@ const runKiroScript = Effect.fn("runKiroScript")(function* (input: { const adapter = yield* makeKiroAdapterV2({ instanceId, settings: ENABLED_KIRO_SETTINGS, - environment: {}, + environment: input.environment ?? {}, selfInvocation: yield* resolveSelfInvocation(), makeRuntime: (runtimeInput) => makeAcpReplayRuntime({ @@ -780,6 +813,71 @@ describe("KiroAdapterV2", () => { }).pipe(Effect.provide(testLayer), Effect.scoped), ); + it.effect("advertises secret storage and answers Kiro's secret reads from its secrets file", () => + Effect.gen(function* () { + const kiroHome = yield* makeKiroHome({ [MCP_TOKENS_KEY]: MCP_TOKENS }); + yield* runKiroScript({ + scenario: "secret-get", + environment: kiroHome.environment, + frames: [ + // Kiro reads stored MCP OAuth tokens from the client only when it opts in. + outbound("initialize", { + protocolVersion: "", + info: "", + capabilities: "", + clientCapabilities: { + fs: "", + terminal: "", + session: "", + elicitation: "", + _meta: { kiro: { hooks: { enabled: true, v2: true }, secretStorage: true } }, + }, + clientInfo: "", + }), + answer("initialize", KIRO_V3_INITIALIZE), + outbound("session/new", { cwd: "", mcpServers: "" }), + kiroSecretRequest("_kiro/secret/get", { key: MCP_TOKENS_KEY }), + kiroSecretResponse("_kiro/secret/get", { value: MCP_TOKENS }), + kiroSecretRequest("_kiro/secret/get", { key: "kiro.mcp.missing.tokens" }), + kiroSecretResponse("_kiro/secret/get", { value: null }), + answer("session/new", sessionSetup([modeOption])), + ...closeSession, + ], + drive: () => Effect.void, + }); + }).pipe(Effect.provide(testLayer), Effect.scoped), + ); + + it.effect("stores and deletes Kiro's secrets in its secrets file", () => + Effect.gen(function* () { + const kiroHome = yield* makeKiroHome({ [MCP_TOKENS_KEY]: MCP_TOKENS }); + const refreshed = JSON.stringify({ access_token: "refreshed", token_type: "Bearer" }); + const otherKey = "kiro.mcp.other.tokens"; + yield* runKiroScript({ + scenario: "secret-store-delete", + environment: kiroHome.environment, + frames: [ + outbound("initialize"), + answer("initialize", KIRO_V3_INITIALIZE), + outbound("session/new", { cwd: "", mcpServers: "" }), + kiroSecretRequest("_kiro/secret/store", { key: otherKey, value: refreshed }), + kiroSecretResponse("_kiro/secret/store", { success: true }), + kiroSecretRequest("_kiro/secret/delete", { key: MCP_TOKENS_KEY }), + kiroSecretResponse("_kiro/secret/delete", { success: true }), + answer("session/new", sessionSetup([modeOption])), + ...closeSession, + ], + drive: () => Effect.void, + }); + const fileSystem = yield* FileSystem.FileSystem; + assert.deepStrictEqual( + JSON.parse(yield* fileSystem.readFileString(kiroHome.secretsPath)), + { [otherKey]: refreshed }, + "Kiro's stored and deleted secrets must land in /secrets.json", + ); + }).pipe(Effect.provide(testLayer), Effect.scoped), + ); + it.effect("sends a model Kiro does not list, and fails with Kiro's own message", () => runKiroScript({ scenario: "unlisted-model", From 3326af1363d9263e9e65354b14b44e540242d7bc Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 4 Nov 2026 16:40:28 +0000 Subject: [PATCH 2/9] fix(provider-kiro): Kiro threads can use OAuth MCP servers Kiro stores and reads MCP OAuth credentials only through the ACP client, and only when the client advertises `_meta.kiro.secretStorage`. T3 never did, so every OAuth MCP server failed with Unauthorized in T3-started Kiro sessions, even after kiro-cli had signed in. The Kiro flavor now advertises `secretStorage` and answers `_kiro/secret/get`, `_kiro/secret/store` and `_kiro/secret/delete` through `registerExtensions`, backed by kiro-cli's own `secrets.json` (`$KIRO_HOME`, else `$HOME/.kiro`), so kiro-cli sign-ins are reused. Writes are serialized across the server's Kiro sessions and keep the file at 0600. Fixes pingdotgg/t3code#30948 Co-Authored-By: Claude Opus 5.5 --- .../kiro_unknown_model/kiro_transcript.ndjson | 2 +- packages/provider-kiro/package.json | 1 + packages/provider-kiro/src/server/adapter.ts | 15 +++- .../src/server/secretStorage.test.ts | 34 +++++++ .../provider-kiro/src/server/secretStorage.ts | 88 +++++++++++++++++++ pnpm-lock.yaml | 3 + 6 files changed, 138 insertions(+), 5 deletions(-) create mode 100644 packages/provider-kiro/src/server/secretStorage.test.ts create mode 100644 packages/provider-kiro/src/server/secretStorage.ts diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_unknown_model/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_unknown_model/kiro_transcript.ndjson index 4f1a1de7cddbf..cb34100b76a7e 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_unknown_model/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_unknown_model/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_unknown_model","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.27.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":14}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/packages/provider-kiro/package.json b/packages/provider-kiro/package.json index b0cdc600f6072..283e1a568cbf7 100644 --- a/packages/provider-kiro/package.json +++ b/packages/provider-kiro/package.json @@ -32,6 +32,7 @@ "effect": "catalog:" }, "devDependencies": { + "@effect/platform-node": "catalog:", "@effect/vitest": "catalog:", "@types/node": "catalog:", "effect-acp": "workspace:*", diff --git a/packages/provider-kiro/src/server/adapter.ts b/packages/provider-kiro/src/server/adapter.ts index 6815b60e8f227..83a51992306a0 100644 --- a/packages/provider-kiro/src/server/adapter.ts +++ b/packages/provider-kiro/src/server/adapter.ts @@ -50,6 +50,7 @@ import { kiroPermissionDisposition, makeKiroAcpRuntime, } from "./acpSupport.ts"; +import { makeKiroSecretStorage } from "./secretStorage.ts"; export const KIRO_PROVIDER = ProviderDriverKind.make("kiro"); /** T3's slug for "Kiro default", and Kiro's documented default model id. */ @@ -523,7 +524,10 @@ function kiroPromptFailure(cause: unknown) { }); } -function makeKiroAcpAdapterFlavor(options: KiroAdapterV2Options): AcpAdapterV2Flavor { +function makeKiroAcpAdapterFlavor( + options: KiroAdapterV2Options, + registerExtensions: NonNullable, +): AcpAdapterV2Flavor { const makeRuntime = options.makeRuntime ?? ((input: AcpAdapterV2RuntimeInput) => { @@ -541,8 +545,10 @@ function makeKiroAcpAdapterFlavor(options: KiroAdapterV2Options): AcpAdapterV2Fl capabilities: KiroProviderCapabilitiesV2, // Kiro V3 loads the user's hooks only when the client opts in. `v2` makes // Kiro run them itself; `enabled` alone hands them to the client as - // `_kiro/hooks/*` requests, which T3 does not answer. - clientCapabilitiesMeta: { kiro: { hooks: { enabled: true, v2: true } } }, + // `_kiro/hooks/*` requests, which T3 does not answer. Kiro keeps MCP OAuth + // credentials only through `secretStorage` (see makeKiroSecretStorage). + clientCapabilitiesMeta: { kiro: { hooks: { enabled: true, v2: true }, secretStorage: true } }, + registerExtensions, makeRuntime, promptFailure: kiroPromptFailure, ignoreSessionUpdate: makeKiroCloudConfigFilter(), @@ -579,9 +585,10 @@ function makeKiroAcpAdapterFlavor(options: KiroAdapterV2Options): AcpAdapterV2Fl export const makeKiroAdapterV2 = Effect.fn("makeKiroAdapterV2")(function* ( options: KiroAdapterV2Options, ) { + const secretStorage = yield* makeKiroSecretStorage(options.environment); return yield* makeAcpAdapterV2({ instanceId: options.instanceId, - flavor: makeKiroAcpAdapterFlavor(options), + flavor: makeKiroAcpAdapterFlavor(options, secretStorage.registerExtensions), selfInvocation: options.selfInvocation, ...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }), ...(options.testHooks === undefined ? {} : { testHooks: options.testHooks }), diff --git a/packages/provider-kiro/src/server/secretStorage.test.ts b/packages/provider-kiro/src/server/secretStorage.test.ts new file mode 100644 index 0000000000000..4ac770f8a02ac --- /dev/null +++ b/packages/provider-kiro/src/server/secretStorage.test.ts @@ -0,0 +1,34 @@ +import * as NodeServices from "@effect/platform-node/NodeServices"; +import { assert, describe, it } from "@effect/vitest"; +import * as Effect from "effect/Effect"; +import * as FileSystem from "effect/FileSystem"; +import * as Path from "effect/Path"; + +import { makeKiroSecretStorage } from "./secretStorage.ts"; + +describe("makeKiroSecretStorage", () => { + it.effect("keeps every key when two sessions store at once, in a new 0600 file", () => + Effect.gen(function* () { + const fileSystem = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-kiro-secrets-" }); + const environment = { KIRO_HOME: ` ${path.join(root, "missing", "kiro")} ` }; + const sessions = [ + yield* makeKiroSecretStorage(environment), + yield* makeKiroSecretStorage(environment), + ]; + const keys = Array.from({ length: 20 }, (_, index) => `kiro.mcp.${index}.tokens`); + yield* Effect.forEach( + keys, + (key, index) => sessions[index % 2]!.store(key, `{"n":${index}}`), + { concurrency: "unbounded", discard: true }, + ); + + const secretsPath = path.join(root, "missing", "kiro", "secrets.json"); + const stored = JSON.parse(yield* fileSystem.readFileString(secretsPath)); + assert.deepStrictEqual(Object.keys(stored).toSorted(), keys.toSorted()); + assert.strictEqual((yield* fileSystem.stat(secretsPath)).mode & 0o777, 0o600); + assert.deepStrictEqual(yield* sessions[1]!.get(keys[3]!), { value: '{"n":3}' }); + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), + ); +}); diff --git a/packages/provider-kiro/src/server/secretStorage.ts b/packages/provider-kiro/src/server/secretStorage.ts new file mode 100644 index 0000000000000..a34f1e96c04dd --- /dev/null +++ b/packages/provider-kiro/src/server/secretStorage.ts @@ -0,0 +1,88 @@ +import * as HostProcess from "@t3tools/shared/HostProcess"; +import * as Effect from "effect/Effect"; +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 Semaphore from "effect/Semaphore"; +import * as EffectAcpErrors from "effect-acp/errors"; + +import type { AcpAdapterV2Flavor } from "@t3tools/provider-acp/server/adapter"; + +const SecretKey = Schema.Struct({ key: Schema.String }); +const SecretEntry = Schema.Struct({ key: Schema.String, value: Schema.String }); +const SecretsJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.String), { + space: 2, +}); +type Secrets = typeof SecretsJson.Type; +const decodeSecrets = Schema.decodeUnknownOption(SecretsJson); +const encodeSecrets = Schema.encodeSync(SecretsJson); + +// Read-modify-write is serialized across every Kiro session in this server. +const secretsFileLock = Semaphore.makeUnsafe(1); + +const secretStorageError = (cause: unknown) => + EffectAcpErrors.AcpRequestError.internalError("Kiro secret storage failed", undefined, { cause }); + +/** kiro-cli's own secrets file, so sessions reuse the MCP sign-ins it stored. */ +const kiroSecretsPath = ( + path: Path.Path, + environment: NodeJS.ProcessEnv, + homeDirectory: string, +) => { + const kiroHome = environment.KIRO_HOME?.trim(); + return kiroHome && path.isAbsolute(kiroHome) + ? path.join(kiroHome, "secrets.json") + : path.join(environment.HOME?.trim() || homeDirectory, ".kiro", "secrets.json"); +}; + +/** + * Answers `_kiro/secret/*`, which Kiro sends once the client advertises + * `secretStorage`. Like kiro-cli, an unreadable file reads as empty. + */ +export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function* ( + environment: NodeJS.ProcessEnv, +) { + const fileSystem = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const secretsPath = kiroSecretsPath(path, environment, yield* HostProcess.HomeDirectory); + + const readUnlocked = fileSystem.readFileString(secretsPath).pipe( + Effect.map((text) => Option.getOrElse(decodeSecrets(text), (): Secrets => ({}))), + Effect.orElseSucceed((): Secrets => ({})), + ); + + const get = Effect.fn("KiroSecretStorage.get")(function* (key: string) { + const secrets = yield* readUnlocked; + return { value: Object.hasOwn(secrets, key) ? (secrets[key] ?? null) : null }; + }, secretsFileLock.withPermits(1)); + + const update = Effect.fn("KiroSecretStorage.update")( + function* (change: (secrets: Secrets) => Secrets) { + const next = change(yield* readUnlocked); + yield* fileSystem.makeDirectory(path.dirname(secretsPath), { recursive: true }); + yield* fileSystem.writeFileString(secretsPath, encodeSecrets(next), { mode: 0o600 }); + yield* fileSystem.chmod(secretsPath, 0o600); + return { success: true } as const; + }, + secretsFileLock.withPermits(1), + Effect.mapError(secretStorageError), + ); + + const store = (key: string, value: string) => update((secrets) => ({ ...secrets, [key]: value })); + const remove = (key: string) => update(({ [key]: _removed, ...rest }) => rest); + + const registerExtensions: NonNullable = ({ runtime }) => + Effect.all( + [ + runtime.handleExtRequest("_kiro/secret/get", SecretKey, ({ key }) => get(key)), + runtime.handleExtRequest("_kiro/secret/store", SecretEntry, ({ key, value }) => + store(key, value), + ), + runtime.handleExtRequest("_kiro/secret/delete", SecretKey, ({ key }) => remove(key)), + ], + { discard: true }, + ); + + return { get, store, remove, registerExtensions }; +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6ddbc362245c9..6be4f6c3515b8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1848,6 +1848,9 @@ importers: specifier: 4.1.2 version: 4.1.2 devDependencies: + '@effect/platform-node': + specifier: 4.1.2 + version: 4.1.2(bufferutil@4.1.0)(effect@4.1.2)(redis@6.2.1)(utf-8-validate@6.0.6) '@effect/vitest': specifier: 4.1.2 version: 4.1.2(patch_hash=299510b71c36537a832a67e9d160a5f112a5f326a29e95c41cb45fc8234e47c7)(@astrojs/compiler-rs@0.5.1)(@tsc-rs/typescript@0.8.0)(@types/node@24.12.4)(@vitest/browser-playwright@5.0.5)(@vitest/ui@5.0.5)(@volar/typescript@2.4.28(@tsc-rs/typescript@0.8.0))(bufferutil@4.1.0)(effect@4.1.2)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(playwright@1.60.0)(terser@5.48.0)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0) From 8bd13a0849647cf8ae34274a1e262cb99a573377 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 4 Nov 2026 16:50:13 +0000 Subject: [PATCH 3/9] fix(provider-kiro): never rewrite a Kiro secrets file T3 cannot read Only a missing secrets.json reads as empty. A file T3 cannot read or decode makes get return null and store/delete fail, instead of replacing kiro-cli's other MCP sign-ins with a single key. The Kiro guide says to sign in to OAuth MCP servers once with kiro-cli. Co-Authored-By: Claude Opus 5.5 --- docs/user/providers-kiro.md | 6 ++++ .../src/server/secretStorage.test.ts | 18 ++++++++++++ .../provider-kiro/src/server/secretStorage.ts | 28 +++++++++++-------- 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/docs/user/providers-kiro.md b/docs/user/providers-kiro.md index 6b94ca14f2e5e..c3edfd38b0af5 100644 --- a/docs/user/providers-kiro.md +++ b/docs/user/providers-kiro.md @@ -38,6 +38,12 @@ not listed yet. Refresh the Kiro provider after adding or removing an agent. The thread's model still applies when an agent sets its own `model`. An agent that was removed leaves the thread on Kiro's current agent. +## MCP Servers + +Kiro threads load the MCP servers in your Kiro configuration. To use one that signs in with OAuth, +sign in to it once with `kiro-cli` on the machine running the T3 Code server (`/mcp`, then +re-authenticate). Kiro threads in T3 Code reuse that sign-in. + ## Permission Modes Kiro asks before tool calls such as writes and commands, and T3 Code answers by the permission mode: diff --git a/packages/provider-kiro/src/server/secretStorage.test.ts b/packages/provider-kiro/src/server/secretStorage.test.ts index 4ac770f8a02ac..fbe24a6875b36 100644 --- a/packages/provider-kiro/src/server/secretStorage.test.ts +++ b/packages/provider-kiro/src/server/secretStorage.test.ts @@ -1,6 +1,7 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { assert, describe, it } from "@effect/vitest"; import * as Effect from "effect/Effect"; +import * as Exit from "effect/Exit"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; @@ -31,4 +32,21 @@ describe("makeKiroSecretStorage", () => { assert.deepStrictEqual(yield* sessions[1]!.get(keys[3]!), { value: '{"n":3}' }); }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), ); + + it.effect("leaves a secrets file it cannot decode untouched", () => + Effect.gen(function* () { + const fileSystem = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-kiro-secrets-" }); + const secretsPath = path.join(root, "secrets.json"); + const original = '{"kiro.mcp.a.tokens":"A","kiro.other":{"nested":true}}'; + yield* fileSystem.writeFileString(secretsPath, original); + const storage = yield* makeKiroSecretStorage({ KIRO_HOME: root }); + + assert.deepStrictEqual(yield* storage.get("kiro.mcp.a.tokens"), { value: null }); + assert.isTrue(Exit.isFailure(yield* Effect.exit(storage.store("kiro.mcp.b.tokens", "B")))); + assert.isTrue(Exit.isFailure(yield* Effect.exit(storage.remove("kiro.mcp.a.tokens")))); + assert.strictEqual(yield* fileSystem.readFileString(secretsPath), original); + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), + ); }); diff --git a/packages/provider-kiro/src/server/secretStorage.ts b/packages/provider-kiro/src/server/secretStorage.ts index a34f1e96c04dd..b65235cc9fb02 100644 --- a/packages/provider-kiro/src/server/secretStorage.ts +++ b/packages/provider-kiro/src/server/secretStorage.ts @@ -1,7 +1,6 @@ import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Effect from "effect/Effect"; 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 Semaphore from "effect/Semaphore"; @@ -15,7 +14,7 @@ const SecretsJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.St space: 2, }); type Secrets = typeof SecretsJson.Type; -const decodeSecrets = Schema.decodeUnknownOption(SecretsJson); +const decodeSecrets = Schema.decodeUnknownEffect(SecretsJson); const encodeSecrets = Schema.encodeSync(SecretsJson); // Read-modify-write is serialized across every Kiro session in this server. @@ -36,10 +35,7 @@ const kiroSecretsPath = ( : path.join(environment.HOME?.trim() || homeDirectory, ".kiro", "secrets.json"); }; -/** - * Answers `_kiro/secret/*`, which Kiro sends once the client advertises - * `secretStorage`. Like kiro-cli, an unreadable file reads as empty. - */ +/** Answers `_kiro/secret/*`, which Kiro sends once the client advertises `secretStorage`. */ export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function* ( environment: NodeJS.ProcessEnv, ) { @@ -47,15 +43,23 @@ export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function const path = yield* Path.Path; const secretsPath = kiroSecretsPath(path, environment, yield* HostProcess.HomeDirectory); + // Only a missing file is empty: rewriting one we cannot read would drop kiro-cli's other sign-ins. const readUnlocked = fileSystem.readFileString(secretsPath).pipe( - Effect.map((text) => Option.getOrElse(decodeSecrets(text), (): Secrets => ({}))), - Effect.orElseSucceed((): Secrets => ({})), + Effect.catchTags({ + PlatformError: (error) => + error.reason._tag === "NotFound" ? Effect.succeed("{}") : Effect.fail(error), + }), + Effect.flatMap(decodeSecrets), ); - const get = Effect.fn("KiroSecretStorage.get")(function* (key: string) { - const secrets = yield* readUnlocked; - return { value: Object.hasOwn(secrets, key) ? (secrets[key] ?? null) : null }; - }, secretsFileLock.withPermits(1)); + const get = Effect.fn("KiroSecretStorage.get")( + function* (key: string) { + const secrets = yield* readUnlocked; + return { value: Object.hasOwn(secrets, key) ? (secrets[key] ?? null) : null }; + }, + secretsFileLock.withPermits(1), + Effect.orElseSucceed(() => ({ value: null })), + ); const update = Effect.fn("KiroSecretStorage.update")( function* (change: (secrets: Secrets) => Secrets) { From cedf6502463857498a233181625d3226b611149f Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 4 Nov 2026 16:58:39 +0000 Subject: [PATCH 4/9] fix(provider-kiro): answer Kiro secret reads on replacement runtimes A runtime that replaces the session (rollback, checkpoint restore, failed resume) runs `session/new` before the shared adapter calls `registerExtensions`, so Kiro's `_kiro/secret/get` during MCP startup got Method not found and OAuth MCP servers failed Unauthorized. The Kiro flavor now installs the secret handlers on every runtime its `makeRuntime` creates, before anything starts it. Co-Authored-By: Claude Opus 5.5 --- .../Adapters/KiroAdapterV2.test.ts | 99 +++++++++++++++---- packages/provider-kiro/src/server/adapter.ts | 10 +- .../provider-kiro/src/server/secretStorage.ts | 7 +- 3 files changed, 92 insertions(+), 24 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts index 76fcad8309b5c..a2cfc24dc8b0e 100644 --- a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts @@ -2,6 +2,7 @@ import * as NodeCrypto from "@effect/platform-node/NodeCrypto"; import * as NodeServices from "@effect/platform-node/NodeServices"; import { assert, describe, it } from "@effect/vitest"; import { + CheckpointId, MessageId, type ModelSelection, NodeId, @@ -328,6 +329,8 @@ const makeKiroHome = Effect.fn("makeKiroHome")(function* (secrets: Record; + /** Frames for the runtime a rollback starts, replayed by a second agent process. */ + readonly replacementFrames?: ReadonlyArray; readonly model?: string; /** Option selections (e.g. reasoningEffort) for the session and `startTurn`. */ readonly options?: ModelSelection["options"]; @@ -356,6 +359,7 @@ const runKiroScript = Effect.fn("runKiroScript")(function* (input: { requestId: RuntimeRequestId, decision: ProviderApprovalDecision, ) => Effect.Effect; + readonly rollbackToStart: Effect.Effect; }) => Effect.Effect; }) { const childProcessSpawner = yield* ChildProcessSpawner.ChildProcessSpawner; @@ -364,17 +368,26 @@ const runKiroScript = Effect.fn("runKiroScript")(function* (input: { const replayDir = yield* fileSystem.makeTempDirectoryScoped({ prefix: `t3-kiro-${input.scenario}-`, }); - const statusPath = path.join(replayDir, "status.json"); - const transcript = yield* decodeAcpReplayTranscript( - { - provider: KIRO_PROVIDER, - protocol: "acp.ndjson-jsonrpc", - version: "1", - scenario: input.scenario, - entries: input.frames as never, - }, - KIRO_PROVIDER, + const scripts = yield* Effect.forEach( + [input.frames, ...(input.replacementFrames === undefined ? [] : [input.replacementFrames])], + (frames, index) => + decodeAcpReplayTranscript( + { + provider: KIRO_PROVIDER, + protocol: "acp.ndjson-jsonrpc", + version: "1", + scenario: input.scenario, + entries: frames as never, + }, + KIRO_PROVIDER, + ).pipe( + Effect.map((transcript) => ({ + transcript, + statusPath: path.join(replayDir, `status-${index}.json`), + })), + ), ); + let runtimesMade = 0; const instanceId = ProviderInstanceId.make(`kiro-${input.scenario}`); const scriptPath = yield* path.fromFileUrl( new URL("../../../scripts/acp-replay-agent.ts", import.meta.url), @@ -384,10 +397,19 @@ const runKiroScript = Effect.fn("runKiroScript")(function* (input: { settings: ENABLED_KIRO_SETTINGS, environment: input.environment ?? {}, selfInvocation: yield* resolveSelfInvocation(), - makeRuntime: (runtimeInput) => - makeAcpReplayRuntime({ - transcript, - statusPath, + makeRuntime: (runtimeInput) => { + const script = scripts[runtimesMade++]; + if (script === undefined) { + // An unscripted runtime is a retry after the last one failed; report why it failed. + const last = scripts[scripts.length - 1]!; + return makeAcpReplayCompletenessAssertion( + fileSystem, + last.statusPath, + last.transcript, + ).pipe(Effect.andThen(Effect.die(`No replay script for Kiro runtime ${runtimesMade}`))); + } + return makeAcpReplayRuntime({ + ...script, scriptPath, childProcessSpawner, fileSystem, @@ -398,7 +420,8 @@ const runKiroScript = Effect.fn("runKiroScript")(function* (input: { ? runtime : { ...runtime, cancel: input.wrapCancel(runtime.cancel) }, ), - ), + ); + }, ...(input.testHooks === undefined ? {} : { testHooks: input.testHooks }), }); // Held frames must not outlive a failed drive and wedge teardown. @@ -474,10 +497,26 @@ const runKiroScript = Effect.fn("runKiroScript")(function* (input: { startTurnOn, interrupt: (providerTurnId) => session.interruptTurn({ providerThread, providerTurnId }), respond: (requestId, decision) => session.respondToRuntimeRequest({ requestId, decision }), + rollbackToStart: session + .rollbackThread({ + providerThread, + providerThreadTurns: [], + target: { + type: "thread_start", + checkpointId: CheckpointId.make(`checkpoint-kiro-${input.scenario}`), + appRunOrdinal: 0, + }, + }) + .pipe(Effect.asVoid), }); }).pipe(Effect.scoped); - // Closing the session stops the replay agent; every scripted frame must be used. - yield* makeAcpReplayCompletenessAssertion(fileSystem, statusPath, transcript); + // Closing the session stops the replay agents; every scripted frame must be used. + yield* Effect.forEach( + scripts, + ({ statusPath, transcript }) => + makeAcpReplayCompletenessAssertion(fileSystem, statusPath, transcript), + { discard: true }, + ); }); const collectTurn = (events: Stream.Stream) => @@ -848,6 +887,32 @@ describe("KiroAdapterV2", () => { }).pipe(Effect.provide(testLayer), Effect.scoped), ); + it.effect("answers Kiro's secret reads on the runtime a rollback starts", () => + Effect.gen(function* () { + const kiroHome = yield* makeKiroHome({ [MCP_TOKENS_KEY]: MCP_TOKENS }); + const openFrames = [ + outbound("initialize"), + answer("initialize", KIRO_V3_INITIALIZE), + outbound("session/new", { cwd: "", mcpServers: "" }), + ]; + yield* runKiroScript({ + scenario: "secret-get-after-rollback", + environment: kiroHome.environment, + // Rollback stops this runtime's process without `session/close`. + frames: [...openFrames, answer("session/new", sessionSetup([modeOption]))], + // The replacement `session/new` reconnects MCP servers, which reads their tokens. + replacementFrames: [ + ...openFrames, + kiroSecretRequest("_kiro/secret/get", { key: MCP_TOKENS_KEY }), + kiroSecretResponse("_kiro/secret/get", { value: MCP_TOKENS }), + answer("session/new", sessionSetup([modeOption])), + ...closeSession, + ], + drive: ({ rollbackToStart }) => rollbackToStart, + }); + }).pipe(Effect.provide(testLayer), Effect.scoped), + ); + it.effect("stores and deletes Kiro's secrets in its secrets file", () => Effect.gen(function* () { const kiroHome = yield* makeKiroHome({ [MCP_TOKENS_KEY]: MCP_TOKENS }); diff --git a/packages/provider-kiro/src/server/adapter.ts b/packages/provider-kiro/src/server/adapter.ts index 83a51992306a0..c2924e45ecf2d 100644 --- a/packages/provider-kiro/src/server/adapter.ts +++ b/packages/provider-kiro/src/server/adapter.ts @@ -526,9 +526,9 @@ function kiroPromptFailure(cause: unknown) { function makeKiroAcpAdapterFlavor( options: KiroAdapterV2Options, - registerExtensions: NonNullable, + secretStorage: Effect.Success>, ): AcpAdapterV2Flavor { - const makeRuntime = + const makeNativeRuntime = options.makeRuntime ?? ((input: AcpAdapterV2RuntimeInput) => { const { runtimePolicy: _runtimePolicy, processEnvironment, ...runtimeInput } = input; @@ -538,6 +538,9 @@ function makeKiroAcpAdapterFlavor( environment: { ...options.environment, ...processEnvironment }, }); }); + // Not `registerExtensions`: a replacement runtime (rollback, failed resume) wires that after `start()`. + const makeRuntime = (input: AcpAdapterV2RuntimeInput) => + makeNativeRuntime(input).pipe(Effect.tap(secretStorage.installHandlers)); const stripSteeringNote = makeKiroSteeringNoteFilter(); return { driver: KIRO_PROVIDER, @@ -548,7 +551,6 @@ function makeKiroAcpAdapterFlavor( // `_kiro/hooks/*` requests, which T3 does not answer. Kiro keeps MCP OAuth // credentials only through `secretStorage` (see makeKiroSecretStorage). clientCapabilitiesMeta: { kiro: { hooks: { enabled: true, v2: true }, secretStorage: true } }, - registerExtensions, makeRuntime, promptFailure: kiroPromptFailure, ignoreSessionUpdate: makeKiroCloudConfigFilter(), @@ -588,7 +590,7 @@ export const makeKiroAdapterV2 = Effect.fn("makeKiroAdapterV2")(function* ( const secretStorage = yield* makeKiroSecretStorage(options.environment); return yield* makeAcpAdapterV2({ instanceId: options.instanceId, - flavor: makeKiroAcpAdapterFlavor(options, secretStorage.registerExtensions), + flavor: makeKiroAcpAdapterFlavor(options, secretStorage), selfInvocation: options.selfInvocation, ...(options.nativeLogging === undefined ? {} : { nativeLogging: options.nativeLogging }), ...(options.testHooks === undefined ? {} : { testHooks: options.testHooks }), diff --git a/packages/provider-kiro/src/server/secretStorage.ts b/packages/provider-kiro/src/server/secretStorage.ts index b65235cc9fb02..70ac1af92e5ff 100644 --- a/packages/provider-kiro/src/server/secretStorage.ts +++ b/packages/provider-kiro/src/server/secretStorage.ts @@ -6,7 +6,7 @@ import * as Schema from "effect/Schema"; import * as Semaphore from "effect/Semaphore"; import * as EffectAcpErrors from "effect-acp/errors"; -import type { AcpAdapterV2Flavor } from "@t3tools/provider-acp/server/adapter"; +import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; const SecretKey = Schema.Struct({ key: Schema.String }); const SecretEntry = Schema.Struct({ key: Schema.String, value: Schema.String }); @@ -76,7 +76,8 @@ export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function const store = (key: string, value: string) => update((secrets) => ({ ...secrets, [key]: value })); const remove = (key: string) => update(({ [key]: _removed, ...rest }) => rest); - const registerExtensions: NonNullable = ({ runtime }) => + // Installed before the runtime starts: Kiro reads secrets while `session/new` connects MCP servers. + const installHandlers = (runtime: AcpSessionRuntime.AcpSessionRuntime["Service"]) => Effect.all( [ runtime.handleExtRequest("_kiro/secret/get", SecretKey, ({ key }) => get(key)), @@ -88,5 +89,5 @@ export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function { discard: true }, ); - return { get, store, remove, registerExtensions }; + return { get, store, remove, installHandlers }; }); From 60ac6066dc3656ce9f7d2649ffd61d536b85dd24 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 4 Nov 2026 17:09:13 +0000 Subject: [PATCH 5/9] fix(provider-kiro): write Kiro secrets atomically A write that failed partway (a full disk, a quota) truncated secrets.json and lost every kiro-cli MCP sign-in in it. Secrets now go through the shared writeFileStringAtomically, which keeps a symlinked file's link; it gains an optional mode so the temp file, and the file it becomes, are 0600. Co-Authored-By: Claude Opus 5.5 --- .../src/server/secretStorage.test.ts | 37 +++++++++++++++++++ .../provider-kiro/src/server/secretStorage.ts | 15 ++++++-- packages/shared/src/atomicWrite.ts | 8 +++- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/packages/provider-kiro/src/server/secretStorage.test.ts b/packages/provider-kiro/src/server/secretStorage.test.ts index fbe24a6875b36..dc471139a83a2 100644 --- a/packages/provider-kiro/src/server/secretStorage.test.ts +++ b/packages/provider-kiro/src/server/secretStorage.test.ts @@ -4,6 +4,7 @@ import * as Effect from "effect/Effect"; import * as Exit from "effect/Exit"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; +import * as PlatformError from "effect/PlatformError"; import { makeKiroSecretStorage } from "./secretStorage.ts"; @@ -33,6 +34,42 @@ describe("makeKiroSecretStorage", () => { }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), ); + it.effect("keeps the stored sign-ins when a write fails partway", () => + Effect.gen(function* () { + const fileSystem = yield* FileSystem.FileSystem; + const path = yield* Path.Path; + const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-kiro-secrets-" }); + const secretsPath = path.join(root, "secrets.json"); + const original = JSON.stringify({ "kiro.mcp.a.tokens": "A" }, null, 2); + yield* fileSystem.writeFileString(secretsPath, original); + // Writes half the text and then fails, like a full disk. + const failingWrites = FileSystem.FileSystem.of({ + ...fileSystem, + writeFileString: (target, text, options) => + fileSystem.writeFileString(target, text.slice(0, text.length / 2), options).pipe( + Effect.andThen( + Effect.fail( + PlatformError.systemError({ + _tag: "Unknown", + module: "FileSystem", + method: "writeFileString", + pathOrDescriptor: target, + }), + ), + ), + ), + }); + const storage = yield* makeKiroSecretStorage({ KIRO_HOME: root }).pipe( + Effect.provideService(FileSystem.FileSystem, failingWrites), + ); + + assert.isTrue(Exit.isFailure(yield* Effect.exit(storage.store("kiro.mcp.b.tokens", "B")))); + assert.strictEqual(yield* fileSystem.readFileString(secretsPath), original); + assert.deepStrictEqual(yield* fileSystem.readDirectory(root), ["secrets.json"]); + assert.deepStrictEqual(yield* storage.get("kiro.mcp.a.tokens"), { value: "A" }); + }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), + ); + it.effect("leaves a secrets file it cannot decode untouched", () => Effect.gen(function* () { const fileSystem = yield* FileSystem.FileSystem; diff --git a/packages/provider-kiro/src/server/secretStorage.ts b/packages/provider-kiro/src/server/secretStorage.ts index 70ac1af92e5ff..c43c2a00fb8eb 100644 --- a/packages/provider-kiro/src/server/secretStorage.ts +++ b/packages/provider-kiro/src/server/secretStorage.ts @@ -1,3 +1,4 @@ +import { writeFileStringAtomically } from "@t3tools/shared/atomicWrite"; import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; @@ -41,6 +42,7 @@ export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function ) { const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; + const platform = yield* HostProcess.Platform; const secretsPath = kiroSecretsPath(path, environment, yield* HostProcess.HomeDirectory); // Only a missing file is empty: rewriting one we cannot read would drop kiro-cli's other sign-ins. @@ -64,9 +66,16 @@ export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function const update = Effect.fn("KiroSecretStorage.update")( function* (change: (secrets: Secrets) => Secrets) { const next = change(yield* readUnlocked); - yield* fileSystem.makeDirectory(path.dirname(secretsPath), { recursive: true }); - yield* fileSystem.writeFileString(secretsPath, encodeSecrets(next), { mode: 0o600 }); - yield* fileSystem.chmod(secretsPath, 0o600); + // Atomic, so a failed write cannot truncate the sign-ins kiro-cli keeps in the same file. + yield* writeFileStringAtomically({ + filePath: secretsPath, + contents: encodeSecrets(next), + mode: 0o600, + }).pipe( + Effect.provideService(FileSystem.FileSystem, fileSystem), + Effect.provideService(Path.Path, path), + Effect.provideService(HostProcess.Platform, platform), + ); return { success: true } as const; }, secretsFileLock.withPermits(1), diff --git a/packages/shared/src/atomicWrite.ts b/packages/shared/src/atomicWrite.ts index e48755047398f..c9b6590f92f9e 100644 --- a/packages/shared/src/atomicWrite.ts +++ b/packages/shared/src/atomicWrite.ts @@ -21,6 +21,8 @@ const LOCKED_RENAME_RETRY_DELAY = "100 millis"; export const writeFileStringAtomically = (input: { readonly filePath: string; readonly contents: string; + /** Created with this mode, so the renamed file is never more open than it. */ + readonly mode?: number; }) => Effect.scoped( Effect.gen(function* () { @@ -41,7 +43,11 @@ export const writeFileStringAtomically = (input: { ); const tempPath = path.join(tempDirectory, "contents.tmp"); - yield* fs.writeFileString(tempPath, input.contents); + yield* fs.writeFileString( + tempPath, + input.contents, + input.mode === undefined ? undefined : { mode: input.mode }, + ); if (platform !== "win32") return yield* fs.rename(tempPath, targetPath); // Stop retrying if another save changes the target; read-only targets also return permanent EPERM. From e2ef9f6cf98c9699c59b3d6970a0c24e318870f2 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 4 Nov 2026 17:20:22 +0000 Subject: [PATCH 6/9] test(provider-kiro): skip the secrets file mode check on Windows Co-Authored-By: Claude Opus 5.5 --- packages/provider-kiro/src/server/secretStorage.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/provider-kiro/src/server/secretStorage.test.ts b/packages/provider-kiro/src/server/secretStorage.test.ts index dc471139a83a2..84d34e0c2ff82 100644 --- a/packages/provider-kiro/src/server/secretStorage.test.ts +++ b/packages/provider-kiro/src/server/secretStorage.test.ts @@ -1,5 +1,6 @@ import * as NodeServices from "@effect/platform-node/NodeServices"; import { assert, describe, it } from "@effect/vitest"; +import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Effect from "effect/Effect"; import * as Exit from "effect/Exit"; import * as FileSystem from "effect/FileSystem"; @@ -29,7 +30,10 @@ describe("makeKiroSecretStorage", () => { const secretsPath = path.join(root, "missing", "kiro", "secrets.json"); const stored = JSON.parse(yield* fileSystem.readFileString(secretsPath)); assert.deepStrictEqual(Object.keys(stored).toSorted(), keys.toSorted()); - assert.strictEqual((yield* fileSystem.stat(secretsPath)).mode & 0o777, 0o600); + // Windows reports every writable file as 0666. + if ((yield* HostProcess.Platform) !== "win32") { + assert.strictEqual((yield* fileSystem.stat(secretsPath)).mode & 0o777, 0o600); + } assert.deepStrictEqual(yield* sessions[1]!.get(keys[3]!), { value: '{"n":3}' }); }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), ); From 69b90b287057dd48dd523071e651fe23c2fc12fd Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Wed, 4 Nov 2026 18:02:07 +0000 Subject: [PATCH 7/9] test(server): Kiro replay fixtures expect the secret storage capability Every recorded Kiro initialize now advertises secretStorage, so the replay fixtures match the adapter. A replay mismatch also answers the mismatching request directly, so an earlier pending request with the same method still gets its error. Co-Authored-By: Claude Opus 5.5 --- apps/server/scripts/acp-replay-agent.ts | 19 +++++++++++++------ .../kiro_cloud_config/kiro_transcript.ndjson | 2 +- .../kiro_compaction/kiro_transcript.ndjson | 2 +- .../kiro_effort/kiro_transcript.ndjson | 2 +- .../kiro_transcript.ndjson | 4 ++-- .../kiro_transcript.ndjson | 2 +- .../kiro_model_switch/kiro_transcript.ndjson | 2 +- .../kiro_full_access_transcript.ndjson | 2 +- .../kiro_supervised_transcript.ndjson | 2 +- .../kiro_transcript.ndjson | 2 +- .../multi_turn/kiro_transcript.ndjson | 2 +- .../kiro_transcript.ndjson | 4 ++-- .../queued_turn/kiro_transcript.ndjson | 2 +- .../fixtures/simple/kiro_transcript.ndjson | 2 +- .../fixtures/subagent/kiro_transcript.ndjson | 2 +- .../kiro_transcript.ndjson | 2 +- .../turn_interrupt/kiro_transcript.ndjson | 2 +- .../kiro_transcript.ndjson | 2 +- 18 files changed, 32 insertions(+), 25 deletions(-) diff --git a/apps/server/scripts/acp-replay-agent.ts b/apps/server/scripts/acp-replay-agent.ts index 2eba80dbcc1c9..7ebb1467b411c 100644 --- a/apps/server/scripts/acp-replay-agent.ts +++ b/apps/server/scripts/acp-replay-agent.ts @@ -146,7 +146,11 @@ function matchesExpected(expected: unknown, actual: unknown): boolean { return Object.is(expected, actual); } -function stopWithFailure(detail: string, actual?: unknown): void { +function stopWithFailure( + detail: string, + actual?: unknown, + failedRequestId?: JsonRpcMessage["id"], +): void { if (stopped) return; stopped = true; const entry = transcript.entries[cursor]; @@ -162,7 +166,9 @@ function stopWithFailure(detail: string, actual?: unknown): void { const message = `ACP replay mismatch at ${entry?.label ?? "end of transcript"}: ${detail}${ actual === undefined ? "" : ` ${JSON.stringify(actual)}` }`; - for (const id of pendingClientRequestIds.values()) { + const ids = [...pendingClientRequestIds.values()]; + if (failedRequestId !== undefined && failedRequestId !== null) ids.push(failedRequestId); + for (const id of ids) { send({ jsonrpc: "2.0", id, error: { code: -32603, message } }); } pendingClientRequestIds.clear(); @@ -292,10 +298,11 @@ function handleMessage(message: JsonRpcMessage): void { } const entry = transcript.entries[cursor]; if (entry?.type !== "expect_outbound" || !matchesExpected(entry.frame, actual)) { - if (actual.kind === "request" && message.id !== undefined && message.id !== null) { - pendingClientRequestIds.set(actual.method, message.id); - } - stopWithFailure("Unexpected outbound ACP frame", actual); + stopWithFailure( + "Unexpected outbound ACP frame", + actual, + actual.kind === "request" ? message.id : undefined, + ); return; } if (actual.kind === "request" && message.id !== undefined && message.id !== null) { diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_cloud_config/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_cloud_config/kiro_transcript.ndjson index e4b6ab19b2f30..11826616da7cc 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_cloud_config/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_cloud_config/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_cloud_config","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13,"editedFrames":"Copied from turn_interrupt/kiro_transcript.ndjson. Added by hand: the background `fetch_cloud_config` tool call and its completion, as @hstern recorded them from kiro-cli 2.31.0 with an Identity Center login, in an order that failed there: the call before `session/prompt`, its completion after the `user_message_id_assigned` echo. The tool call id is invented; the reported frames omitted it."}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_compaction/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_compaction/kiro_transcript.ndjson index 6dce2f2ccb9f4..fc7e5e7858d39 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_compaction/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_compaction/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_compaction","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.33.1","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":15}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_effort/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_effort/kiro_transcript.ndjson index 2b613ee1100fc..eab15f7ca82fe 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_effort/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_effort/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_effort","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_fork_from_turn/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_fork_from_turn/kiro_transcript.ndjson index aac368e4d4838..3793b3e65a3a0 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_fork_from_turn/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_fork_from_turn/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_fork_from_turn","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.33.1","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":39}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} @@ -39,7 +39,7 @@ {"type":"emit_inbound","label":"response:session/prompt","frame":{"kind":"response","method":"session/prompt","result":{"stopReason":"end_turn"}}} {"type":"emit_inbound","label":"notification:session/update:session_info_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"session_info_update","_meta":{"kiro":{"contextUsage":{"usagePercentage":9.52649974822998},"breakdown":{"contextFiles":{"tokens":0,"percent":0,"items":[]},"tools":{"tokens":5481,"percent":0.5,"mcp":{"tokens":0,"percent":0},"builtin":{"tokens":5481,"percent":0.5}},"memory":{"tokens":0,"percent":0},"kiroResponses":{"tokens":10,"percent":0.1},"yourPrompts":{"tokens":778,"percent":8.9},"sessionFiles":{"tokens":0,"percent":0,"items":[]}},"kind":"context_usage","usagePercentage":9.52649974822998}}}}}} {"type":"runtime_exit","status":"success"} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000002","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_message_steering/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_message_steering/kiro_transcript.ndjson index 519feac99d2c4..a30aa3d58e9e7 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_message_steering/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_message_steering/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_message_steering","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.33.1","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_model_switch/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_model_switch/kiro_transcript.ndjson index 7e1ea7301c2c3..f059d6a4842d0 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_model_switch/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_model_switch/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_model_switch","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":15}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_full_access_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_full_access_transcript.ndjson index 05a5adb1f805d..cf53fb42bce0d 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_full_access_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_full_access_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_full_access_write","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_supervised_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_supervised_transcript.ndjson index fa569a6db3044..6d5766f89aeab 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_supervised_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_permission_modes/kiro_supervised_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_supervised_write","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_subagent_interrupt/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_subagent_interrupt/kiro_transcript.ndjson index 65151441473ef..7e30b034d68f1 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/kiro_subagent_interrupt/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/kiro_subagent_interrupt/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_subagent_interrupt","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.33.1","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/multi_turn/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/multi_turn/kiro_transcript.ndjson index 0ca4d283e87a7..1d23e580375ea 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/multi_turn/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/multi_turn/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"multi_turn","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":15}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/provider_thread_resume/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/provider_thread_resume/kiro_transcript.ndjson index 2f5d9833e73c7..10a3f17df88e5 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/provider_thread_resume/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/provider_thread_resume/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"provider_thread_resume","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":26}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} @@ -27,7 +27,7 @@ {"type":"expect_outbound","label":"request:session/close","frame":{"kind":"request","method":"session/close","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001"}}} {"type":"emit_inbound","label":"response:session/close","frame":{"kind":"response","method":"session/close","result":{}}} {"type":"runtime_exit","status":"success"} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/load","frame":{"kind":"request","method":"session/load","params":{"mcpServers":"","cwd":"","sessionId":"sess_00000000-0000-4000-8000-000000000001"}}} {"type":"emit_inbound","label":"notification:session/update:user_message_chunk","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"user_message_chunk","content":{"type":"text","text":"\n## T3 Code interaction mode: Default\n\nPrefer making reasonable assumptions and carrying out the user's request. Ask a concise question only when a missing user decision would materially change the result. Treat this mode as active until T3 Code supplies a different interaction-mode instruction.\n\n\n\nRespond with exactly: provider thread resume fixture first turn complete\n\nIn case you're asked: you are running in T3 Code through the Kiro harness, as claude-haiku-4.5. No need to mention this otherwise. You can embed images and videos in your response using Markdown with absolute file paths.\n\n\nWhen the t3-code MCP server exposes link_pull_request, you must use it to register every pull request you create or work on for this thread. Call link_pull_request with the full PR URL immediately after creating a PR or starting work on an existing PR. For a stack, call it for every layer, not just the current branch or the top PR. This applies when creating or updating PRs through gh, gh stack, another CLI, or the host API: those operations do not register the PRs with this thread. Linking an already-linked PR is safe. Before finishing PR work, call list_thread_pull_requests and link any PR from your work that is missing. Do not link unrelated PRs mentioned only as background. If a linking call fails, report that failure instead of claiming the PR is linked. When asked to monitor, watch, or babysit a PR and watch_pull_request is available, call it and end your turn: T3 Code wakes you when checks finish, someone else comments, or the branch conflicts, so do not poll or run your own watcher. When you hand the work back to the user, call unwatch_pull_request first so the thread returns to their inbox.\n"},"_meta":{"kiro":{"userMessageTag":"prompt_00000000-0000-4000-9000-000000000005","messageId":"00000000-0000-4000-9000-000000000001","timestamp":"2026-10-19T20:48:11.510Z","replay":true}}}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/queued_turn/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/queued_turn/kiro_transcript.ndjson index 73a21b301051e..ab733c7ae72aa 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/queued_turn/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/queued_turn/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"queued_turn","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":15}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/simple/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/simple/kiro_transcript.ndjson index 1e9a0c0412442..60a08c76243b3 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/simple/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/simple/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"simple","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/subagent/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/subagent/kiro_transcript.ndjson index 5f26257d395f9..16bd91306dc3d 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/subagent/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/subagent/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"subagent","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.33.1","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/tool_call_read_only_on_request/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/tool_call_read_only_on_request/kiro_transcript.ndjson index cd6d095d1a910..e57d0b71f766c 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/tool_call_read_only_on_request/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/tool_call_read_only_on_request/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_tool_call_read_only_on_request","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt/kiro_transcript.ndjson index 46a0f9ca5db4c..bb12247b828e7 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"turn_interrupt","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.32.0","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} diff --git a/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt_mid_tool/kiro_transcript.ndjson b/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt_mid_tool/kiro_transcript.ndjson index 14887375f1724..e427d07a0ef52 100644 --- a/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt_mid_tool/kiro_transcript.ndjson +++ b/apps/server/src/orchestration-v2/testkit/fixtures/turn_interrupt_mid_tool/kiro_transcript.ndjson @@ -1,5 +1,5 @@ {"type":"transcript_start","provider":"kiro","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"kiro_turn_interrupt_mid_tool","metadata":{"generatedBy":"live-kiro-recorder","kiroVersion":"2.33.1","normalization":"Session ids are fixed sess_ UUIDs and other UUIDs (message and request ids) are numbered in first-seen order, the workspace is , HOME is /home/kiro-replay and the recording user is kiro-replay. T3-owned prompt text, MCP servers and initialize params other than clientCapabilities and _meta are . Kiro's log directory, user-scoped commands and agents, and the _kiro/* broadcasts T3 ignores (governance, steering documents, powers, tools, hooks, MCP status, session roster) are removed. Timestamps are kept as recorded.","droppedFrames":13}} -{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true}}}},"clientInfo":""}}} +{"type":"expect_outbound","label":"request:initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"","capabilities":"","clientCapabilities":{"fs":{"readTextFile":false,"writeTextFile":false},"terminal":false,"session":{"notices":{}},"elicitation":{"form":{}},"_meta":{"kiro":{"hooks":{"enabled":true,"v2":true},"secretStorage":true}}},"clientInfo":""}}} {"type":"emit_inbound","label":"response:initialize","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":2,"agentCapabilities":{"loadSession":true,"promptCapabilities":{"image":true,"embeddedContext":true},"mcpCapabilities":{"http":true,"sse":true},"sessionCapabilities":{"list":{},"close":{},"delete":{},"fork":{"_meta":{"kiro":{"messageId":true}}}},"_meta":{"kiro":{"checkpoints":true,"sessionList":true,"policyNotifications":true,"extensionMethods":["_kiro/knowledge","_kiro/memory/list","_kiro/memory/get","_kiro/memory/create","_kiro/memory/update","_kiro/memory/delete","_kiro/codeIntelligence","_kiro/session/context","_kiro/session/compact","_kiro/session/export","_kiro/session/history","_kiro/config/template","_kiro/workflow/new","_kiro/workflow/invoke","_kiro/workflow/load","_kiro/workflow/inspect","_kiro/workflow/list","_kiro/workflow/pause","_kiro/workflow/cancel","_kiro/workflow/delete","_kiro/workflow/listRecipes","_kiro/workflow/listWatchHandlers","_kiro/workflow/resumeAll","_kiro/workflow/retry","_kiro/workflow/update","_kiro/workflow/resume","_kiro/sourceProviders/list","_kiro/sourceProviders/listResources"],"sessionSources":["local","remote"],"sessionListScopes":["workspace","user"],"executionTargets":["local","cloud-sandbox"],"sourceProviders":true,"replayMarking":true}}},"authMethods":[{"id":"aws-builder-id","name":"AWS Builder ID"},{"id":"aws-iam-identity-center","name":"AWS IAM Identity Center"}]}}} {"type":"expect_outbound","label":"request:session/new","frame":{"kind":"request","method":"session/new","params":{"cwd":"","mcpServers":""}}} {"type":"emit_inbound","label":"notification:session/update:available_commands_update","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"sess_00000000-0000-4000-8000-000000000001","update":{"sessionUpdate":"available_commands_update","availableCommands":[{"name":"architecture-selection","description":"Steering: architecture-selection","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:architecture-selection","commandId":"architecture-selection","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"architecture-selection"}}},{"name":"quick-spec","description":"Steering: quick-spec","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:quick-spec","commandId":"quick-spec","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"quick-spec"}}},{"name":"bug-fix","description":"Steering: bug-fix","input":{"hint":"optional context"},"_meta":{"kiro":{"type":"steering","contextQuery":"global:bug-fix","commandId":"bug-fix","resource":{"resourceType":"steering","source":{"origin":"bundled"}},"originalName":"bug-fix"}}},{"name":"general-task-execution","description":"General-purpose sub-agent with access to all tools for executing arbitrary tasks","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"general-task-execution","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"general-task-execution"}}},{"name":"context-gatherer","description":"Investigates the codebase to answer a specific question about it. Deeply analyzes existing code by tracing execution paths, mapping architecture and abstraction layers, understanding patterns, and documenting dependencies, returning a thorough, direct written analysis that explains how the relevant code works and points to the specific files and lines involved. Use it to understand code before you change it: before designing or implementing a change to code you don't already fully understand, start with context-gatherer so your edits are grounded in how the code actually works. When a task requires understanding code you don't already know, dispatch context-gatherer to do that exploration before running your own searches or reads. Rules: 1. Provide a clear, specific prompt that includes your intent: a detailed task description of the context you need and what you're trying to accomplish. 2. The subagent explores the codebase and returns an analysis of your query 3. Trust the returned results. You may still inspect additional code yourself when you need context beyond what was returned. 4. Reuse existing context-gatherer output for related follow-up questions; do not re-invoke on the same question with different phrasing. 5. For multiple distinct questions, dispatch several context-gatherers in parallel, each targeting a different aspect of the codebase.","input":{"hint":"task to delegate"},"_meta":{"kiro":{"type":"custom-agent","commandId":"context-gatherer","resource":{"resourceType":"agent","source":{"origin":"bundled"}},"originalName":"context-gatherer"}}}]}}}} From acab8758a8b0a567afd54776d1900916d0c49dec Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 10 Nov 2026 23:13:43 +0000 Subject: [PATCH 8/9] test(server): one Kiro script covers secret reads, stores and deletes AI-assisted; verified with the tests and tools listed above. --- .../Adapters/KiroAdapterV2.test.ts | 44 +++++-------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts index a2cfc24dc8b0e..7585eb5d58005 100644 --- a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts @@ -852,11 +852,13 @@ describe("KiroAdapterV2", () => { }).pipe(Effect.provide(testLayer), Effect.scoped), ); - it.effect("advertises secret storage and answers Kiro's secret reads from its secrets file", () => + it.effect("advertises secret storage and serves Kiro's secrets from its secrets file", () => Effect.gen(function* () { const kiroHome = yield* makeKiroHome({ [MCP_TOKENS_KEY]: MCP_TOKENS }); + const refreshed = JSON.stringify({ access_token: "refreshed", token_type: "Bearer" }); + const otherKey = "kiro.mcp.other.tokens"; yield* runKiroScript({ - scenario: "secret-get", + scenario: "secret-storage", environment: kiroHome.environment, frames: [ // Kiro reads stored MCP OAuth tokens from the client only when it opts in. @@ -879,11 +881,19 @@ describe("KiroAdapterV2", () => { kiroSecretResponse("_kiro/secret/get", { value: MCP_TOKENS }), kiroSecretRequest("_kiro/secret/get", { key: "kiro.mcp.missing.tokens" }), kiroSecretResponse("_kiro/secret/get", { value: null }), + kiroSecretRequest("_kiro/secret/store", { key: otherKey, value: refreshed }), + kiroSecretResponse("_kiro/secret/store", { success: true }), + kiroSecretRequest("_kiro/secret/delete", { key: MCP_TOKENS_KEY }), + kiroSecretResponse("_kiro/secret/delete", { success: true }), answer("session/new", sessionSetup([modeOption])), ...closeSession, ], drive: () => Effect.void, }); + const fileSystem = yield* FileSystem.FileSystem; + assert.deepStrictEqual(JSON.parse(yield* fileSystem.readFileString(kiroHome.secretsPath)), { + [otherKey]: refreshed, + }); }).pipe(Effect.provide(testLayer), Effect.scoped), ); @@ -913,36 +923,6 @@ describe("KiroAdapterV2", () => { }).pipe(Effect.provide(testLayer), Effect.scoped), ); - it.effect("stores and deletes Kiro's secrets in its secrets file", () => - Effect.gen(function* () { - const kiroHome = yield* makeKiroHome({ [MCP_TOKENS_KEY]: MCP_TOKENS }); - const refreshed = JSON.stringify({ access_token: "refreshed", token_type: "Bearer" }); - const otherKey = "kiro.mcp.other.tokens"; - yield* runKiroScript({ - scenario: "secret-store-delete", - environment: kiroHome.environment, - frames: [ - outbound("initialize"), - answer("initialize", KIRO_V3_INITIALIZE), - outbound("session/new", { cwd: "", mcpServers: "" }), - kiroSecretRequest("_kiro/secret/store", { key: otherKey, value: refreshed }), - kiroSecretResponse("_kiro/secret/store", { success: true }), - kiroSecretRequest("_kiro/secret/delete", { key: MCP_TOKENS_KEY }), - kiroSecretResponse("_kiro/secret/delete", { success: true }), - answer("session/new", sessionSetup([modeOption])), - ...closeSession, - ], - drive: () => Effect.void, - }); - const fileSystem = yield* FileSystem.FileSystem; - assert.deepStrictEqual( - JSON.parse(yield* fileSystem.readFileString(kiroHome.secretsPath)), - { [otherKey]: refreshed }, - "Kiro's stored and deleted secrets must land in /secrets.json", - ); - }).pipe(Effect.provide(testLayer), Effect.scoped), - ); - it.effect("sends a model Kiro does not list, and fails with Kiro's own message", () => runKiroScript({ scenario: "unlisted-model", From d16216dd8198c0832eecf93983f8f120e218f935 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Tue, 10 Nov 2026 23:32:55 +0000 Subject: [PATCH 9/9] fix(provider-kiro): never rewrite kiro-cli's secrets file kiro-cli rewrites secrets.json without a lock, so no T3-side lock can stop a read-modify-write from dropping a sign-in another process saved. T3 now only answers _kiro/secret/get; store and delete are left unhandled. AI-assisted; verified with the tests and tools listed above. --- .../Adapters/KiroAdapterV2.test.ts | 15 ++- docs/user/providers-kiro.md | 3 +- packages/provider-kiro/package.json | 1 - .../src/server/secretStorage.test.ts | 93 ------------------- .../provider-kiro/src/server/secretStorage.ts | 75 +++------------ packages/shared/src/atomicWrite.ts | 8 +- pnpm-lock.yaml | 3 - 7 files changed, 27 insertions(+), 171 deletions(-) delete mode 100644 packages/provider-kiro/src/server/secretStorage.test.ts diff --git a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts index 7585eb5d58005..ee3548d7f5355 100644 --- a/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts +++ b/apps/server/src/orchestration-v2/Adapters/KiroAdapterV2.test.ts @@ -309,6 +309,12 @@ const kiroSecretResponse = (method: string, result: unknown): Frame => ({ frame: { kind: "response", method, result }, }); +const kiroSecretRejection = (method: string): Frame => ({ + type: "expect_outbound", + label: `${method}.error`, + frame: { kind: "response", method, error: "" }, +}); + /** * A temp KIRO_HOME whose `secrets.json` holds `secrets`, the flat map kiro-cli * keeps there. HOME points elsewhere so only KIRO_HOME can find the file. @@ -852,7 +858,7 @@ describe("KiroAdapterV2", () => { }).pipe(Effect.provide(testLayer), Effect.scoped), ); - it.effect("advertises secret storage and serves Kiro's secrets from its secrets file", () => + it.effect("advertises secret storage, reads Kiro's secrets file and never writes it", () => Effect.gen(function* () { const kiroHome = yield* makeKiroHome({ [MCP_TOKENS_KEY]: MCP_TOKENS }); const refreshed = JSON.stringify({ access_token: "refreshed", token_type: "Bearer" }); @@ -881,10 +887,11 @@ describe("KiroAdapterV2", () => { kiroSecretResponse("_kiro/secret/get", { value: MCP_TOKENS }), kiroSecretRequest("_kiro/secret/get", { key: "kiro.mcp.missing.tokens" }), kiroSecretResponse("_kiro/secret/get", { value: null }), + // kiro-cli rewrites this file unlocked, so T3 never writes it. kiroSecretRequest("_kiro/secret/store", { key: otherKey, value: refreshed }), - kiroSecretResponse("_kiro/secret/store", { success: true }), + kiroSecretRejection("_kiro/secret/store"), kiroSecretRequest("_kiro/secret/delete", { key: MCP_TOKENS_KEY }), - kiroSecretResponse("_kiro/secret/delete", { success: true }), + kiroSecretRejection("_kiro/secret/delete"), answer("session/new", sessionSetup([modeOption])), ...closeSession, ], @@ -892,7 +899,7 @@ describe("KiroAdapterV2", () => { }); const fileSystem = yield* FileSystem.FileSystem; assert.deepStrictEqual(JSON.parse(yield* fileSystem.readFileString(kiroHome.secretsPath)), { - [otherKey]: refreshed, + [MCP_TOKENS_KEY]: MCP_TOKENS, }); }).pipe(Effect.provide(testLayer), Effect.scoped), ); diff --git a/docs/user/providers-kiro.md b/docs/user/providers-kiro.md index c3edfd38b0af5..26a140a803751 100644 --- a/docs/user/providers-kiro.md +++ b/docs/user/providers-kiro.md @@ -42,7 +42,8 @@ leaves the thread on Kiro's current agent. Kiro threads load the MCP servers in your Kiro configuration. To use one that signs in with OAuth, sign in to it once with `kiro-cli` on the machine running the T3 Code server (`/mcp`, then -re-authenticate). Kiro threads in T3 Code reuse that sign-in. +re-authenticate). Kiro threads in T3 Code reuse that sign-in but never change it, so when it +expires, sign in again with `kiro-cli`. ## Permission Modes diff --git a/packages/provider-kiro/package.json b/packages/provider-kiro/package.json index 3663db65891c2..81df0c51fb1f5 100644 --- a/packages/provider-kiro/package.json +++ b/packages/provider-kiro/package.json @@ -32,7 +32,6 @@ "effect": "catalog:" }, "devDependencies": { - "@effect/platform-node": "catalog:", "@effect/vitest": "catalog:", "@types/node": "catalog:", "effect-acp": "workspace:*", diff --git a/packages/provider-kiro/src/server/secretStorage.test.ts b/packages/provider-kiro/src/server/secretStorage.test.ts deleted file mode 100644 index 84d34e0c2ff82..0000000000000 --- a/packages/provider-kiro/src/server/secretStorage.test.ts +++ /dev/null @@ -1,93 +0,0 @@ -import * as NodeServices from "@effect/platform-node/NodeServices"; -import { assert, describe, it } from "@effect/vitest"; -import * as HostProcess from "@t3tools/shared/HostProcess"; -import * as Effect from "effect/Effect"; -import * as Exit from "effect/Exit"; -import * as FileSystem from "effect/FileSystem"; -import * as Path from "effect/Path"; -import * as PlatformError from "effect/PlatformError"; - -import { makeKiroSecretStorage } from "./secretStorage.ts"; - -describe("makeKiroSecretStorage", () => { - it.effect("keeps every key when two sessions store at once, in a new 0600 file", () => - Effect.gen(function* () { - const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-kiro-secrets-" }); - const environment = { KIRO_HOME: ` ${path.join(root, "missing", "kiro")} ` }; - const sessions = [ - yield* makeKiroSecretStorage(environment), - yield* makeKiroSecretStorage(environment), - ]; - const keys = Array.from({ length: 20 }, (_, index) => `kiro.mcp.${index}.tokens`); - yield* Effect.forEach( - keys, - (key, index) => sessions[index % 2]!.store(key, `{"n":${index}}`), - { concurrency: "unbounded", discard: true }, - ); - - const secretsPath = path.join(root, "missing", "kiro", "secrets.json"); - const stored = JSON.parse(yield* fileSystem.readFileString(secretsPath)); - assert.deepStrictEqual(Object.keys(stored).toSorted(), keys.toSorted()); - // Windows reports every writable file as 0666. - if ((yield* HostProcess.Platform) !== "win32") { - assert.strictEqual((yield* fileSystem.stat(secretsPath)).mode & 0o777, 0o600); - } - assert.deepStrictEqual(yield* sessions[1]!.get(keys[3]!), { value: '{"n":3}' }); - }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), - ); - - it.effect("keeps the stored sign-ins when a write fails partway", () => - Effect.gen(function* () { - const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-kiro-secrets-" }); - const secretsPath = path.join(root, "secrets.json"); - const original = JSON.stringify({ "kiro.mcp.a.tokens": "A" }, null, 2); - yield* fileSystem.writeFileString(secretsPath, original); - // Writes half the text and then fails, like a full disk. - const failingWrites = FileSystem.FileSystem.of({ - ...fileSystem, - writeFileString: (target, text, options) => - fileSystem.writeFileString(target, text.slice(0, text.length / 2), options).pipe( - Effect.andThen( - Effect.fail( - PlatformError.systemError({ - _tag: "Unknown", - module: "FileSystem", - method: "writeFileString", - pathOrDescriptor: target, - }), - ), - ), - ), - }); - const storage = yield* makeKiroSecretStorage({ KIRO_HOME: root }).pipe( - Effect.provideService(FileSystem.FileSystem, failingWrites), - ); - - assert.isTrue(Exit.isFailure(yield* Effect.exit(storage.store("kiro.mcp.b.tokens", "B")))); - assert.strictEqual(yield* fileSystem.readFileString(secretsPath), original); - assert.deepStrictEqual(yield* fileSystem.readDirectory(root), ["secrets.json"]); - assert.deepStrictEqual(yield* storage.get("kiro.mcp.a.tokens"), { value: "A" }); - }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), - ); - - it.effect("leaves a secrets file it cannot decode untouched", () => - Effect.gen(function* () { - const fileSystem = yield* FileSystem.FileSystem; - const path = yield* Path.Path; - const root = yield* fileSystem.makeTempDirectoryScoped({ prefix: "t3-kiro-secrets-" }); - const secretsPath = path.join(root, "secrets.json"); - const original = '{"kiro.mcp.a.tokens":"A","kiro.other":{"nested":true}}'; - yield* fileSystem.writeFileString(secretsPath, original); - const storage = yield* makeKiroSecretStorage({ KIRO_HOME: root }); - - assert.deepStrictEqual(yield* storage.get("kiro.mcp.a.tokens"), { value: null }); - assert.isTrue(Exit.isFailure(yield* Effect.exit(storage.store("kiro.mcp.b.tokens", "B")))); - assert.isTrue(Exit.isFailure(yield* Effect.exit(storage.remove("kiro.mcp.a.tokens")))); - assert.strictEqual(yield* fileSystem.readFileString(secretsPath), original); - }).pipe(Effect.provide(NodeServices.layer), Effect.scoped), - ); -}); diff --git a/packages/provider-kiro/src/server/secretStorage.ts b/packages/provider-kiro/src/server/secretStorage.ts index c43c2a00fb8eb..8295487aae2ec 100644 --- a/packages/provider-kiro/src/server/secretStorage.ts +++ b/packages/provider-kiro/src/server/secretStorage.ts @@ -1,28 +1,15 @@ -import { writeFileStringAtomically } from "@t3tools/shared/atomicWrite"; import * as HostProcess from "@t3tools/shared/HostProcess"; import * as Effect from "effect/Effect"; import * as FileSystem from "effect/FileSystem"; import * as Path from "effect/Path"; import * as Schema from "effect/Schema"; -import * as Semaphore from "effect/Semaphore"; -import * as EffectAcpErrors from "effect-acp/errors"; import type * as AcpSessionRuntime from "@t3tools/provider-acp/server/AcpSessionRuntime"; const SecretKey = Schema.Struct({ key: Schema.String }); -const SecretEntry = Schema.Struct({ key: Schema.String, value: Schema.String }); -const SecretsJson = Schema.fromJsonString(Schema.Record(Schema.String, Schema.String), { - space: 2, -}); -type Secrets = typeof SecretsJson.Type; -const decodeSecrets = Schema.decodeUnknownEffect(SecretsJson); -const encodeSecrets = Schema.encodeSync(SecretsJson); - -// Read-modify-write is serialized across every Kiro session in this server. -const secretsFileLock = Semaphore.makeUnsafe(1); - -const secretStorageError = (cause: unknown) => - EffectAcpErrors.AcpRequestError.internalError("Kiro secret storage failed", undefined, { cause }); +const decodeSecrets = Schema.decodeUnknownEffect( + Schema.fromJsonString(Schema.Record(Schema.String, Schema.String)), +); /** kiro-cli's own secrets file, so sessions reuse the MCP sign-ins it stored. */ const kiroSecretsPath = ( @@ -36,67 +23,31 @@ const kiroSecretsPath = ( : path.join(environment.HOME?.trim() || homeDirectory, ".kiro", "secrets.json"); }; -/** Answers `_kiro/secret/*`, which Kiro sends once the client advertises `secretStorage`. */ +/** + * Answers `_kiro/secret/get`, which Kiro sends once the client advertises `secretStorage`. + * Read-only: kiro-cli rewrites this file without a lock, so a T3 write could drop its sign-ins. + * `_kiro/secret/store` and `_kiro/secret/delete` stay unhandled (method not found). + */ export const makeKiroSecretStorage = Effect.fn("makeKiroSecretStorage")(function* ( environment: NodeJS.ProcessEnv, ) { const fileSystem = yield* FileSystem.FileSystem; const path = yield* Path.Path; - const platform = yield* HostProcess.Platform; const secretsPath = kiroSecretsPath(path, environment, yield* HostProcess.HomeDirectory); - // Only a missing file is empty: rewriting one we cannot read would drop kiro-cli's other sign-ins. - const readUnlocked = fileSystem.readFileString(secretsPath).pipe( - Effect.catchTags({ - PlatformError: (error) => - error.reason._tag === "NotFound" ? Effect.succeed("{}") : Effect.fail(error), - }), - Effect.flatMap(decodeSecrets), - ); - const get = Effect.fn("KiroSecretStorage.get")( function* (key: string) { - const secrets = yield* readUnlocked; + const secrets = yield* fileSystem + .readFileString(secretsPath) + .pipe(Effect.flatMap(decodeSecrets)); return { value: Object.hasOwn(secrets, key) ? (secrets[key] ?? null) : null }; }, - secretsFileLock.withPermits(1), Effect.orElseSucceed(() => ({ value: null })), ); - const update = Effect.fn("KiroSecretStorage.update")( - function* (change: (secrets: Secrets) => Secrets) { - const next = change(yield* readUnlocked); - // Atomic, so a failed write cannot truncate the sign-ins kiro-cli keeps in the same file. - yield* writeFileStringAtomically({ - filePath: secretsPath, - contents: encodeSecrets(next), - mode: 0o600, - }).pipe( - Effect.provideService(FileSystem.FileSystem, fileSystem), - Effect.provideService(Path.Path, path), - Effect.provideService(HostProcess.Platform, platform), - ); - return { success: true } as const; - }, - secretsFileLock.withPermits(1), - Effect.mapError(secretStorageError), - ); - - const store = (key: string, value: string) => update((secrets) => ({ ...secrets, [key]: value })); - const remove = (key: string) => update(({ [key]: _removed, ...rest }) => rest); - // Installed before the runtime starts: Kiro reads secrets while `session/new` connects MCP servers. const installHandlers = (runtime: AcpSessionRuntime.AcpSessionRuntime["Service"]) => - Effect.all( - [ - runtime.handleExtRequest("_kiro/secret/get", SecretKey, ({ key }) => get(key)), - runtime.handleExtRequest("_kiro/secret/store", SecretEntry, ({ key, value }) => - store(key, value), - ), - runtime.handleExtRequest("_kiro/secret/delete", SecretKey, ({ key }) => remove(key)), - ], - { discard: true }, - ); + runtime.handleExtRequest("_kiro/secret/get", SecretKey, ({ key }) => get(key)); - return { get, store, remove, installHandlers }; + return { get, installHandlers }; }); diff --git a/packages/shared/src/atomicWrite.ts b/packages/shared/src/atomicWrite.ts index c9b6590f92f9e..e48755047398f 100644 --- a/packages/shared/src/atomicWrite.ts +++ b/packages/shared/src/atomicWrite.ts @@ -21,8 +21,6 @@ const LOCKED_RENAME_RETRY_DELAY = "100 millis"; export const writeFileStringAtomically = (input: { readonly filePath: string; readonly contents: string; - /** Created with this mode, so the renamed file is never more open than it. */ - readonly mode?: number; }) => Effect.scoped( Effect.gen(function* () { @@ -43,11 +41,7 @@ export const writeFileStringAtomically = (input: { ); const tempPath = path.join(tempDirectory, "contents.tmp"); - yield* fs.writeFileString( - tempPath, - input.contents, - input.mode === undefined ? undefined : { mode: input.mode }, - ); + yield* fs.writeFileString(tempPath, input.contents); if (platform !== "win32") return yield* fs.rename(tempPath, targetPath); // Stop retrying if another save changes the target; read-only targets also return permanent EPERM. diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 19c16fd1034d1..ff6392397431e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1825,9 +1825,6 @@ importers: specifier: 4.1.2 version: 4.1.2 devDependencies: - '@effect/platform-node': - specifier: 4.1.2 - version: 4.1.2(bufferutil@4.1.0)(effect@4.1.2)(redis@6.2.1)(utf-8-validate@6.0.6) '@effect/vitest': specifier: 4.1.2 version: 4.1.2(patch_hash=299510b71c36537a832a67e9d160a5f112a5f326a29e95c41cb45fc8234e47c7)(@astrojs/compiler-rs@0.5.1)(@types/node@24.12.4)(@vitest/browser-playwright@5.0.5)(@vitest/ui@5.0.5)(@volar/typescript@2.4.28(typescript@6.0.3))(bufferutil@4.1.0)(effect@4.1.2)(esbuild@0.28.2)(jiti@2.7.0)(jsdom@30.1.0(@noble/hashes@1.8.0))(playwright@1.60.0)(terser@5.48.0)(typescript@6.0.3)(unrun@0.2.39)(utf-8-validate@6.0.6)(yaml@2.9.0)