@usine/agents 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/README.md +35 -6
  2. package/dist/pi/authentication.d.ts +4 -4
  3. package/dist/pi/authentication.d.ts.map +1 -1
  4. package/dist/pi/authentication.js +2 -2
  5. package/dist/pi/authentication.js.map +1 -1
  6. package/dist/pi/children.d.ts +4 -1
  7. package/dist/pi/children.d.ts.map +1 -1
  8. package/dist/pi/children.js +4 -1
  9. package/dist/pi/children.js.map +1 -1
  10. package/dist/pi/claude.d.ts +6 -2
  11. package/dist/pi/claude.d.ts.map +1 -1
  12. package/dist/pi/claude.js +80 -15
  13. package/dist/pi/claude.js.map +1 -1
  14. package/dist/pi/codex/account.d.ts +11 -0
  15. package/dist/pi/codex/account.d.ts.map +1 -0
  16. package/dist/pi/codex/account.js +43 -0
  17. package/dist/pi/codex/account.js.map +1 -0
  18. package/dist/pi/codex/app-server.d.ts +15 -6
  19. package/dist/pi/codex/app-server.d.ts.map +1 -1
  20. package/dist/pi/codex/app-server.js +61 -22
  21. package/dist/pi/codex/app-server.js.map +1 -1
  22. package/dist/pi/codex/codec.d.ts +96 -0
  23. package/dist/pi/codex/codec.d.ts.map +1 -0
  24. package/dist/pi/codex/codec.js +110 -0
  25. package/dist/pi/codex/codec.js.map +1 -0
  26. package/dist/pi/codex/codex.d.ts +2 -0
  27. package/dist/pi/codex/codex.d.ts.map +1 -1
  28. package/dist/pi/codex/codex.js +143 -148
  29. package/dist/pi/codex/codex.js.map +1 -1
  30. package/dist/pi/conversation.d.ts +26 -0
  31. package/dist/pi/conversation.d.ts.map +1 -0
  32. package/dist/pi/conversation.js +93 -0
  33. package/dist/pi/conversation.js.map +1 -0
  34. package/dist/pi/live.d.ts +4 -0
  35. package/dist/pi/live.d.ts.map +1 -0
  36. package/dist/pi/{index.js → live.js} +2 -9
  37. package/dist/pi/live.js.map +1 -0
  38. package/dist/pi/pi.d.ts +3 -1
  39. package/dist/pi/pi.d.ts.map +1 -1
  40. package/dist/pi/pi.js +90 -64
  41. package/dist/pi/pi.js.map +1 -1
  42. package/dist/pi/sdk.d.ts +18 -13
  43. package/dist/pi/sdk.d.ts.map +1 -1
  44. package/dist/pi/sdk.js +15 -10
  45. package/dist/pi/sdk.js.map +1 -1
  46. package/dist/pi/session.d.ts +20 -21
  47. package/dist/pi/session.d.ts.map +1 -1
  48. package/dist/pi/session.js +23 -11
  49. package/dist/pi/session.js.map +1 -1
  50. package/dist/pi/subagents.d.ts +17 -11
  51. package/dist/pi/subagents.d.ts.map +1 -1
  52. package/dist/pi/subagents.js +81 -44
  53. package/dist/pi/subagents.js.map +1 -1
  54. package/dist/pi/thinking.d.ts +8 -0
  55. package/dist/pi/thinking.d.ts.map +1 -0
  56. package/dist/pi/thinking.js +15 -0
  57. package/dist/pi/thinking.js.map +1 -0
  58. package/dist/pi/turns.d.ts +28 -0
  59. package/dist/pi/turns.d.ts.map +1 -0
  60. package/dist/pi/turns.js +54 -0
  61. package/dist/pi/turns.js.map +1 -0
  62. package/dist/pi/usage.d.ts +25 -0
  63. package/dist/pi/usage.d.ts.map +1 -0
  64. package/dist/pi/usage.js +72 -0
  65. package/dist/pi/usage.js.map +1 -0
  66. package/dist/preflight/command.d.ts +7 -0
  67. package/dist/preflight/command.d.ts.map +1 -0
  68. package/dist/preflight/command.js +42 -0
  69. package/dist/preflight/command.js.map +1 -0
  70. package/dist/preflight/preflight.d.ts +13 -0
  71. package/dist/preflight/preflight.d.ts.map +1 -0
  72. package/dist/preflight/preflight.js +100 -0
  73. package/dist/preflight/preflight.js.map +1 -0
  74. package/dist/prompt.d.ts +15 -11
  75. package/dist/prompt.d.ts.map +1 -1
  76. package/dist/prompt.js +14 -11
  77. package/dist/prompt.js.map +1 -1
  78. package/dist/protocol/codex.d.ts +20 -6
  79. package/dist/protocol/codex.d.ts.map +1 -1
  80. package/dist/protocol/codex.js +7 -1
  81. package/dist/protocol/codex.js.map +1 -1
  82. package/dist/runtime.d.ts +59 -25
  83. package/dist/runtime.d.ts.map +1 -1
  84. package/dist/runtime.js +47 -34
  85. package/dist/runtime.js.map +1 -1
  86. package/package.json +34 -10
  87. package/dist/index.d.ts +0 -4
  88. package/dist/index.d.ts.map +0 -1
  89. package/dist/index.js +0 -4
  90. package/dist/index.js.map +0 -1
  91. package/dist/pi/index.d.ts +0 -11
  92. package/dist/pi/index.d.ts.map +0 -1
  93. package/dist/pi/index.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ import { TokenCount } from "@usine/core/agent/session";
2
+ import { Option, Schema } from "effect";
3
+ const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
4
+ const PiUsage = Schema.Struct({
5
+ role: Schema.Literal("assistant"),
6
+ usage: Schema.Struct({ totalTokens: Count }),
7
+ });
8
+ /** Pi assistant usage is per completed message, including cache tokens. */
9
+ export const piMessageTokens = Schema.decodeUnknownOption(PiUsage);
10
+ const ClaudeAssistantUsage = Schema.Struct({
11
+ type: Schema.Literal("assistant"),
12
+ message: Schema.Struct({
13
+ id: Schema.NonEmptyString,
14
+ usage: Schema.Struct({
15
+ input_tokens: Count,
16
+ output_tokens: Count,
17
+ cache_read_input_tokens: Schema.optionalKey(Schema.NullOr(Count)),
18
+ cache_creation_input_tokens: Schema.optionalKey(Schema.NullOr(Count)),
19
+ }),
20
+ }),
21
+ });
22
+ const ClaudeModelUsage = Schema.Struct({
23
+ inputTokens: Count,
24
+ outputTokens: Count,
25
+ cacheReadInputTokens: Count,
26
+ cacheCreationInputTokens: Count,
27
+ });
28
+ const ClaudeResultUsage = Schema.Struct({
29
+ type: Schema.Literal("result"),
30
+ modelUsage: Schema.Record(Schema.String, ClaudeModelUsage),
31
+ });
32
+ const decodeAssistant = Schema.decodeUnknownOption(ClaudeAssistantUsage);
33
+ const decodeResult = Schema.decodeUnknownOption(ClaudeResultUsage);
34
+ /** Tracks Claude's live message usage and reconciles its cumulative query meter at each result.
35
+ * Repeated blocks with the same message id count only their additional tokens.
36
+ * The SDK's result.usage is per-turn and excludes auxiliary work; modelUsage
37
+ * includes that work and stays cumulative across streaming-input turns.
38
+ */
39
+ export const claudeTokenMeter = () => {
40
+ let total = 0;
41
+ const messages = new Map();
42
+ return (message) => {
43
+ const assistant = decodeAssistant(message);
44
+ if (Option.isSome(assistant)) {
45
+ const { id, usage } = assistant.value.message;
46
+ const consumed = usage.input_tokens +
47
+ usage.output_tokens +
48
+ (usage.cache_read_input_tokens ?? 0) +
49
+ (usage.cache_creation_input_tokens ?? 0);
50
+ const previous = messages.get(id) ?? 0;
51
+ total += Math.max(0, consumed - previous);
52
+ messages.set(id, Math.max(previous, consumed));
53
+ return Option.some(TokenCount.make(total));
54
+ }
55
+ const result = decodeResult(message);
56
+ if (Option.isNone(result))
57
+ return Option.none();
58
+ const consumed = Object.values(result.value.modelUsage).reduce((sum, usage) => sum +
59
+ usage.inputTokens +
60
+ usage.outputTokens +
61
+ usage.cacheReadInputTokens +
62
+ usage.cacheCreationInputTokens, 0);
63
+ total = Math.max(total, consumed);
64
+ return Option.some(TokenCount.make(total));
65
+ };
66
+ };
67
+ /** Codex's thread meter is cumulative across turns on the same thread. */
68
+ export const CodexTokenUsage = Schema.Struct({
69
+ threadId: Schema.NonEmptyString,
70
+ tokenUsage: Schema.Struct({ total: Schema.Struct({ totalTokens: TokenCount }) }),
71
+ });
72
+ //# sourceMappingURL=usage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/pi/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,MAAM,OAAO,GAAG,MAAM,CAAC,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GAAG,EAAE,KAAK,EAAE,EAAE,CACb,GAAG;YACH,KAAK,CAAC,WAAW;YACjB,KAAK,CAAC,YAAY;YAClB,KAAK,CAAC,oBAAoB;YAC1B,KAAK,CAAC,wBAAwB,EAChC,CAAC,CACF,CAAC;QACF,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,0EAA0E;AAC1E,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,MAAM,CAAC,cAAc;IAC/B,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC;CACjF,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { HarnessUnavailableError } from "@usine/core/agent/capability";
2
+ import { Effect } from "effect";
3
+ import { ChildProcessSpawner } from "effect/unstable/process";
4
+ import { SessionOperationError } from "../runtime.ts";
5
+ /** Runs a bounded readiness command without retaining its potentially sensitive diagnostics. */
6
+ export declare const probeCommand: (harness: "claude" | "codex" | "pi", capability: "binary" | "login" | "version", command: string, args: readonly string[]) => Effect.Effect<string, HarnessUnavailableError | SessionOperationError, ChildProcessSpawner.ChildProcessSpawner>;
7
+ //# sourceMappingURL=command.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAA0B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,gGAAgG;AAChG,eAAO,MAAM,YAAY,+OAmDvB,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { HarnessUnavailableError } from "@usine/core/agent/capability";
2
+ import { Effect, Option, Stream } from "effect";
3
+ import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
4
+ import { homedir } from "node:os";
5
+ import { SessionOperationError } from "../runtime.js";
6
+ /** Runs a bounded readiness command without retaining its potentially sensitive diagnostics. */
7
+ export const probeCommand = Effect.fn("HarnessPreflight.command")(function* (harness, capability, command, args) {
8
+ yield* Effect.annotateCurrentSpan({ harness, capability });
9
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
10
+ return yield* Effect.scoped(Effect.gen(function* () {
11
+ const handle = yield* spawner.spawn(ChildProcess.make(command, args, {
12
+ cwd: homedir(),
13
+ detached: false,
14
+ forceKillAfter: "2 seconds",
15
+ }));
16
+ const [stdout, , exitCode] = yield* Effect.all([
17
+ handle.stdout.pipe(Stream.decodeText(), Stream.mkString),
18
+ handle.stderr.pipe(Stream.runDrain),
19
+ handle.exitCode,
20
+ ], { concurrency: "unbounded" });
21
+ if (exitCode !== 0)
22
+ return yield* new HarnessUnavailableError({
23
+ harness,
24
+ capability,
25
+ message: `${command} ${args.join(" ")} failed; check the Worker's ${harness} installation and login`,
26
+ });
27
+ return stdout.trim();
28
+ })).pipe(Effect.timeout("30 seconds"), Effect.catchTags({
29
+ PlatformError: () => new HarnessUnavailableError({
30
+ harness,
31
+ capability,
32
+ message: `Worker cannot execute ${command}`,
33
+ }),
34
+ TimeoutError: (cause) => new SessionOperationError({
35
+ operation: "launch",
36
+ sessionId: Option.none(),
37
+ message: `${command} readiness check timed out`,
38
+ cause,
39
+ }),
40
+ }));
41
+ });
42
+ //# sourceMappingURL=command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":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,EAAE,WAAW,EAAE,WAAW,EAAE,CAC7B,CAAC;QACF,IAAI,QAAQ,KAAK,CAAC;YAChB,OAAO,KAAK,CAAC,CAAC,IAAI,uBAAuB,CAAC;gBACxC,OAAO;gBACP,UAAU;gBACV,OAAO,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,+BAA+B,OAAO,yBAAyB;aACrG,CAAC,CAAC;QACL,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC,CAAC,CACH,CAAC,IAAI,CACJ,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAC5B,MAAM,CAAC,SAAS,CAAC;QACf,aAAa,EAAE,GAAG,EAAE,CAClB,IAAI,uBAAuB,CAAC;YAC1B,OAAO;YACP,UAAU;YACV,OAAO,EAAE,yBAAyB,OAAO,EAAE;SAC5C,CAAC;QACJ,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CACtB,IAAI,qBAAqB,CAAC;YACxB,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE;YACxB,OAAO,EAAE,GAAG,OAAO,4BAA4B;YAC/C,KAAK;SACN,CAAC;KACL,CAAC,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { BrainSpec } from "@usine/core/agent/brain";
2
+ import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
3
+ import { Effect } from "effect";
4
+ import { SessionOperationError } from "../runtime.ts";
5
+ import { CodexAppServer } from "../pi/codex/app-server.ts";
6
+ import { PiSdk } from "../pi/sdk.ts";
7
+ /** Baseline Codex CLI version used by the pinned app-server protocol conformance gate. */
8
+ export declare const CODEX_CLI_VERSION = "0.144.0";
9
+ /** Verifies a rostered brain through supplied process and SDK services; starts no prompt. */
10
+ export declare const verifyHarness: (brain: BrainSpec) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner | CodexAppServer | PiSdk>;
11
+ /** Checks only the requested brain using the worker user's configuration, without running a prompt or logging in. */
12
+ export declare const preflight: (brain: BrainSpec) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner>;
13
+ //# sourceMappingURL=preflight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAoB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAsB,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAAE,KAAK,EAAyB,MAAM,cAAc,CAAC;AAG5D,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAW3C,6FAA6F;AAC7F,eAAO,MAAM,aAAa,wMA4GzB,CAAC;AAEF,qHAAqH;AACrH,eAAO,MAAM,SAAS,UAAW,SAAS,4JACgD,CAAC"}
@@ -0,0 +1,100 @@
1
+ import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
2
+ import { Effect, Option, Schema } from "effect";
3
+ import { homedir } from "node:os";
4
+ import { SessionOperationError, WorkingDirectory } from "../runtime.js";
5
+ import { CodexAppServer, codexAppServerLive } from "../pi/codex/app-server.js";
6
+ import { initializeCodex, verifyCodexAccount } from "../pi/codex/account.js";
7
+ import { PiSdk, piSdkLive, usePiStart } from "../pi/sdk.js";
8
+ import { probeCommand } from "./command.js";
9
+ /** Baseline Codex CLI version used by the pinned app-server protocol conformance gate. */
10
+ export const CODEX_CLI_VERSION = "0.144.0";
11
+ // Additional exact builds require generated-type review and the live contracts.
12
+ const supportedCodexVersions = [CODEX_CLI_VERSION, "0.153.4"];
13
+ const ClaudeAuthentication = Schema.Struct({
14
+ loggedIn: Schema.Boolean,
15
+ authMethod: Schema.String,
16
+ apiProvider: Schema.String,
17
+ });
18
+ /** Verifies a rostered brain through supplied process and SDK services; starts no prompt. */
19
+ export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (brain) {
20
+ yield* Effect.annotateCurrentSpan({ harness: brain.harness, model: brain.model });
21
+ const loginError = (message) => new HarnessUnavailableError({
22
+ harness: brain.harness,
23
+ capability: "login",
24
+ message,
25
+ });
26
+ switch (brain.harness) {
27
+ case "codex": {
28
+ const version = yield* probeCommand("codex", "binary", "codex", ["--version"]);
29
+ if (!supportedCodexVersions.some((supported) => version === `codex-cli ${supported}`))
30
+ return yield* new HarnessUnavailableError({
31
+ harness: "codex",
32
+ capability: "version",
33
+ message: `Worker has ${/^codex-cli [0-9]+\.[0-9]+\.[0-9]+$/u.test(version) ? version : "an unrecognized Codex version"}; supported Codex CLI versions: ${supportedCodexVersions.join(", ")}`,
34
+ });
35
+ yield* Effect.scoped(Effect.gen(function* () {
36
+ const server = yield* CodexAppServer;
37
+ const connection = yield* server.open({
38
+ cwd: WorkingDirectory.make(homedir()),
39
+ sessionId: Option.none(),
40
+ });
41
+ yield* initializeCodex(connection);
42
+ yield* verifyCodexAccount(connection, brain.model);
43
+ })).pipe(Effect.catchTag("PoolUnavailableError", (error) => loginError(error.message)));
44
+ break;
45
+ }
46
+ case "claude": {
47
+ yield* probeCommand("claude", "binary", "claude", ["--version"]);
48
+ const response = yield* probeCommand("claude", "login", "claude", [
49
+ "auth",
50
+ "status",
51
+ "--json",
52
+ ]);
53
+ const auth = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(ClaudeAuthentication))(response).pipe(Effect.mapError(() => loginError("Claude returned an unrecognized login status")));
54
+ if (!auth.loggedIn || auth.authMethod !== "claude.ai" || auth.apiProvider !== "firstParty")
55
+ return yield* loginError("Claude requires a subscription login; run claude auth login on the Worker");
56
+ break;
57
+ }
58
+ case "pi": {
59
+ // Pi is the SDK installed with this run host, not a separate CLI binary.
60
+ const sdk = yield* PiSdk;
61
+ yield* usePiStart((signal) => sdk.start({
62
+ cwd: homedir(),
63
+ extensions: [],
64
+ model: Option.some(brain.model),
65
+ signal,
66
+ thinkingLevel: brain.effort,
67
+ toolMode: "repository",
68
+ }), (cause) => new SessionOperationError({
69
+ operation: "launch",
70
+ sessionId: Option.none(),
71
+ message: `Pi could not check authentication for ${brain.model}`,
72
+ cause,
73
+ }), (acquired) => Effect.gen(function* () {
74
+ const result = acquired.result;
75
+ yield* Effect.sync(acquired.dispose);
76
+ if (result._tag !== "Started" || result.pool !== "apiKeys")
77
+ return yield* loginError(`Pi child model ${brain.model} requires an available model, supported effort, and API-key authentication`);
78
+ }));
79
+ break;
80
+ }
81
+ }
82
+ yield* Effect.logInfo("Worker harness verified", {
83
+ harness: brain.harness,
84
+ model: brain.model,
85
+ });
86
+ return new HarnessReady({ harness: brain.harness });
87
+ }, (effect, brain) => effect.pipe(Effect.timeout("60 seconds"), Effect.catchTag("TimeoutError", (cause) => new SessionOperationError({
88
+ operation: "launch",
89
+ sessionId: Option.none(),
90
+ message: `${brain.harness} readiness check timed out`,
91
+ cause,
92
+ })), Effect.tapError((error) => Effect.logError("Worker harness preflight failed", {
93
+ harness: brain.harness,
94
+ model: brain.model,
95
+ errorTag: error._tag,
96
+ message: error.message,
97
+ }))));
98
+ /** Checks only the requested brain using the worker user's configuration, without running a prompt or logging in. */
99
+ export const preflight = (brain) => verifyHarness(brain).pipe(Effect.provide(codexAppServerLive), Effect.provide(piSdkLive));
100
+ //# sourceMappingURL=preflight.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,M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KAAK,CAAC,KAAK;IAClB,QAAQ,EAAE,KAAK,CAAC,IAAI;IACpB,OAAO,EAAE,KAAK,CAAC,OAAO;CACvB,CAAC,CACH,CACF,CACJ,CAAC;AAEF,qHAAqH;AACrH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAgB,EAAE,EAAE,CAC5C,aAAa,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC"}
package/dist/prompt.d.ts CHANGED
@@ -1,22 +1,26 @@
1
- import type { Agent, AttemptChannel, Repository } from "@usine/core";
1
+ import type { AgentPersona, AgentName } from "@usine/core/agent";
2
+ import type { AttemptTask } from "@usine/core/attempt";
3
+ import type { RepositoryName } from "@usine/core/repository";
2
4
  import type { Schema } from "effect";
5
+ /** The recorded trigger context, Agent instructions, and effective task presented to the parent. */
3
6
  export interface PromptParts {
4
- readonly repository: Repository.Name;
7
+ readonly repository: RepositoryName;
5
8
  readonly payload: Schema.Json;
6
- readonly agent: Agent.Name;
7
- readonly persona: Agent.Persona;
8
- readonly task: AttemptChannel.Task;
9
+ readonly agent: AgentName;
10
+ readonly persona: AgentPersona;
11
+ readonly task: AttemptTask;
9
12
  }
13
+ /** The Agent's standing instructions and the focused task the parent delegates to a child. */
10
14
  export interface ChildPromptParts {
11
- readonly agent: Agent.Name;
12
- readonly persona: Agent.Persona;
15
+ readonly agent: AgentName;
16
+ readonly persona: AgentPersona;
13
17
  /** Free text authored by the parent model, not the rendered loop task. */
14
18
  readonly task: string;
15
19
  }
16
- /** Human-visible attribution required on GitHub content authored by an Agent. */
17
- export declare const githubSignature: (agent: Agent.Name) => string;
18
- /** Builds the complete parent prompt from immutable run context. */
20
+ /** The attribution line every GitHub comment or review written by an Agent ends with. */
21
+ export declare const githubSignature: (agent: AgentName) => string;
22
+ /** Builds the parent's instructions from the saved payload, effective task, and Agent persona, including GitHub attribution. */
19
23
  export declare const assemblePrompt: (parts: PromptParts) => string;
20
- /** Builds the isolated prompt given to a first-level child session. */
24
+ /** Builds a child's instructions from the delegated task and Agent persona, including GitHub attribution. */
21
25
  export declare const assembleChildPrompt: (parts: ChildPromptParts) => string;
22
26
  //# sourceMappingURL=prompt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,IAAI,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC,IAAI,CAAC;CACpC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC;IAChC,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,iFAAiF;AACjF,eAAO,MAAM,eAAe,UAAW,KAAK,CAAC,IAAI,KAAG,MAAmC,CAAC;AAExF,oEAAoE;AACpE,eAAO,MAAM,cAAc,UAAW,WAAW,KAAG,MAuBtC,CAAC;AAEf,uEAAuE;AACvE,eAAO,MAAM,mBAAmB,UAAW,gBAAgB,KAAG,MAchD,CAAC"}
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,oGAAoG;AACpG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC5B;AAED,8FAA8F;AAC9F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,yFAAyF;AACzF,eAAO,MAAM,eAAe,UAAW,SAAS,KAAG,MAAmC,CAAC;AAYvF,gIAAgI;AAChI,eAAO,MAAM,cAAc,UAAW,WAAW,KAAG,MAoBtC,CAAC;AAEf,6GAA6G;AAC7G,eAAO,MAAM,mBAAmB,UAAW,gBAAgB,KAAG,MAWhD,CAAC"}
package/dist/prompt.js CHANGED
@@ -1,6 +1,15 @@
1
- /** Human-visible attribution required on GitHub content authored by an Agent. */
1
+ /** The attribution line every GitHub comment or review written by an Agent ends with. */
2
2
  export const githubSignature = (agent) => `— usine agent: ${agent}`;
3
- /** Builds the complete parent prompt from immutable run context. */
3
+ const githubInstructions = (agent) => [
4
+ "# GitHub identity",
5
+ "",
6
+ "All factory Agents use the same GitHub App identity, including the Agent that opened a pull request.",
7
+ "Submit pull request reviews with event COMMENT (gh pr review --comment), never APPROVE or REQUEST_CHANGES. Attach each review to the exact commit you reviewed.",
8
+ "Use the Loop's outcome labels to report findings or a passed review, and remove the opposite outcome label. A passed label does not satisfy GitHub required approvals; the operator provides any independent approval and merges.",
9
+ "Append this signature to every GitHub comment, issue, pull request, or review you publish:",
10
+ githubSignature(agent),
11
+ ];
12
+ /** Builds the parent's instructions from the saved payload, effective task, and Agent persona, including GitHub attribution. */
4
13
  export const assemblePrompt = (parts) => [
5
14
  "# Run context",
6
15
  "",
@@ -19,12 +28,9 @@ export const assemblePrompt = (parts) => [
19
28
  "",
20
29
  parts.task,
21
30
  "",
22
- "# GitHub identity",
23
- "",
24
- "Append this signature to every GitHub comment, issue, or pull request you publish:",
25
- githubSignature(parts.agent),
31
+ ...githubInstructions(parts.agent),
26
32
  ].join("\n");
27
- /** Builds the isolated prompt given to a first-level child session. */
33
+ /** Builds a child's instructions from the delegated task and Agent persona, including GitHub attribution. */
28
34
  export const assembleChildPrompt = (parts) => [
29
35
  "# Agent persona",
30
36
  "",
@@ -34,9 +40,6 @@ export const assembleChildPrompt = (parts) => [
34
40
  "",
35
41
  parts.task,
36
42
  "",
37
- "# GitHub identity",
38
- "",
39
- "Append this signature to every GitHub comment, issue, or pull request you publish:",
40
- githubSignature(parts.agent),
43
+ ...githubInstructions(parts.agent),
41
44
  ].join("\n");
42
45
  //# sourceMappingURL=prompt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAkBA,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAiB,EAAU,EAAE,CAAC,kBAAkB,KAAK,EAAE,CAAC;AAExF,oEAAoE;AACpE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAkB,EAAU,EAAE,CAC3D;IACE,eAAe;IACf,EAAE;IACF,eAAe,KAAK,CAAC,UAAU,EAAE;IACjC,EAAE;IACF,mBAAmB;IACnB,SAAS;IACT,IAA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K,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IAC3C,KAAK;IACL,EAAE;IACF,iBAAiB;IACjB,EAAE;IACF,KAAK,CAAC,OAAO;IACb,EAAE;IACF,QAAQ;IACR,EAAE;IACF,KAAK,CAAC,IAAI;IACV,EAAE;IACF,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;CACnC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEf,6GAA6G;AAC7G,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAuB,EAAU,EAAE,CACrE;IACE,iBAAiB;IACjB,EAAE;IACF,KAAK,CAAC,OAAO;IACb,EAAE;IACF,kBAAkB;IAClB,EAAE;IACF,KAAK,CAAC,IAAI;IACV,EAAE;IACF,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;CACnC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
@@ -1,10 +1,12 @@
1
+ import { Schema } from "effect";
1
2
  /**
2
- * NodeNext-compatible view of the exact-pinned generated app-server protocol
3
- * (`@pwrdrvr/codex-app-server-protocol@0.144.0`, mirroring codex-cli 0.144.0).
4
- * The upstream package omits extensions in its generated source, so it only
5
- * resolves under bundler-style resolution; these are the request shapes usine
6
- * sends on that pinned wire version. `protocol-conformance/check.ts` compiles
7
- * against the real package and fails `pnpm check` when this view drifts.
3
+ * The request shapes usine sends to the Codex app server, restated from
4
+ * `@pwrdrvr/codex-app-server-protocol@0.144.0` (codex-cli 0.144.0) because
5
+ * that package resolves only under bundler-style resolution.
6
+ * This is the baseline protocol. Additional supported CLI builds are verified
7
+ * against their generated types and the live steering/interruption contracts.
8
+ * `protocol-conformance/check.ts` compiles against the baseline package and fails
9
+ * `pnpm check` when these shapes drift.
8
10
  */
9
11
  export interface InitializeParams {
10
12
  readonly clientInfo: {
@@ -19,6 +21,9 @@ export interface ModelListParams {
19
21
  readonly limit?: number | null;
20
22
  readonly includeHidden?: boolean | null;
21
23
  }
24
+ export interface GetAccountParams {
25
+ readonly refreshToken?: boolean;
26
+ }
22
27
  export interface ThreadStartParams {
23
28
  readonly model?: string | null;
24
29
  readonly allowProviderModelFallback?: boolean;
@@ -52,5 +57,14 @@ export interface TurnInterruptParams {
52
57
  readonly threadId: string;
53
58
  readonly turnId: string;
54
59
  }
60
+ export declare const AccountResponse: Schema.Struct<{
61
+ readonly account: Schema.NullOr<Schema.Struct<{
62
+ readonly type: Schema.String;
63
+ }>>;
64
+ readonly requiresOpenaiAuth: Schema.Boolean;
65
+ }>;
66
+ export declare const AccountUpdated: Schema.Struct<{
67
+ readonly authMode: Schema.NullOr<Schema.String>;
68
+ }>;
55
69
  export {};
56
70
  //# sourceMappingURL=codex.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/protocol/codex.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,QAAQ,CAAC,YAAY,EAAE,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,CAAC,0BAA0B,CAAC,EAAE,OAAO,CAAC;IAC9C,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,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,SAAS;IACjB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;CAC9C;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,WAAW,GAAG,IAAI,CAAC;IACtE,QAAQ,CAAC,aAAa,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;KAAE,GAAG,IAAI,CAAC;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAGD,eAAO,MAAM,eAAe;;;;;EAG1B,CAAC;AACH,eAAO,MAAM,cAAc;;EAA4D,CAAC"}
@@ -1,2 +1,8 @@
1
- export {};
1
+ import { Schema } from "effect";
2
+ // Only authentication mode crosses this boundary; account identity is never logged.
3
+ export const AccountResponse = Schema.Struct({
4
+ account: Schema.NullOr(Schema.Struct({ type: Schema.String })),
5
+ requiresOpenaiAuth: Schema.Boolean,
6
+ });
7
+ export const AccountUpdated = Schema.Struct({ authMode: Schema.NullOr(Schema.String) });
2
8
  //# sourceMappingURL=codex.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/protocol/codex.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/protocol/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAkEhC,oFAAoF;AACpF,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9D,kBAAkB,EAAE,MAAM,CAAC,OAAO;CACnC,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
package/dist/runtime.d.ts CHANGED
@@ -1,27 +1,29 @@
1
- import { Agent, AttemptChannel, AttemptFailure } from "@usine/core";
1
+ import { AgentSession, AgentSessionEvent, ChildSession } from "@usine/core/agent/session";
2
+ import * as AttemptChannel from "@usine/core/attempt/channel";
3
+ import { AttemptFailure } from "@usine/core/attempt/failure";
2
4
  import { Context, Effect, Schema, Scope, Stream } from "effect";
3
- /** Value object: process-local working directory for one isolated Attempt. */
5
+ /** The checkout directory one Attempt runs in. */
4
6
  export declare const WorkingDirectory: Schema.brand<Schema.NonEmptyString, "AgentWorkingDirectory">;
5
7
  export type WorkingDirectory = typeof WorkingDirectory.Type;
6
8
  declare const LaunchRequest_base: Schema.Class<LaunchRequest, Schema.Struct<{
7
9
  readonly spec: typeof AttemptChannel.RunSpec;
8
10
  readonly cwd: Schema.brand<Schema.NonEmptyString, "AgentWorkingDirectory">;
9
11
  }>, {}>;
10
- /** Complete input required to start the Pi parent inside one Attempt checkout. */
12
+ /** The Attempt's task and Agent choices, together with the prepared checkout where its parent starts. */
11
13
  export declare class LaunchRequest extends LaunchRequest_base {
12
14
  }
13
15
  declare const ChildRequest_base: Schema.Class<ChildRequest, Schema.Struct<{
14
- readonly session: typeof Agent.ChildSession;
16
+ readonly session: typeof ChildSession;
15
17
  readonly cwd: Schema.brand<Schema.NonEmptyString, "AgentWorkingDirectory">;
16
18
  readonly prompt: Schema.NonEmptyString;
17
19
  }>, {}>;
18
- /** Complete input for exactly one first-level child session. */
20
+ /** Work delegated to one child, with its assigned identity and the checkout it shares with the parent. */
19
21
  export declare class ChildRequest extends ChildRequest_base {
20
22
  }
21
23
  declare const SessionResult_base: Schema.Class<SessionResult, Schema.Struct<{
22
24
  readonly message: Schema.NonEmptyString;
23
25
  }>, {}>;
24
- /** Terminal semantic output from a parent or child SDK session. */
26
+ /** The final message a parent or child session returns. */
25
27
  export declare class SessionResult extends SessionResult_base {
26
28
  }
27
29
  declare const UnknownModelError_base: Schema.Class<UnknownModelError, Schema.TaggedStruct<"UnknownModelError", {
@@ -29,7 +31,7 @@ declare const UnknownModelError_base: Schema.Class<UnknownModelError, Schema.Tag
29
31
  readonly model: Schema.brand<Schema.String, "ModelId">;
30
32
  readonly message: Schema.NonEmptyString;
31
33
  }>, import("effect/Cause").YieldableError>;
32
- /** The configured vendor model id is well-formed but absent from the selected SDK registry. */
34
+ /** The rostered model id is well-formed but the SDK's registry does not list it. */
33
35
  export declare class UnknownModelError extends UnknownModelError_base {
34
36
  }
35
37
  declare const PoolUnavailableError_base: Schema.Class<PoolUnavailableError, Schema.TaggedStruct<"PoolUnavailableError", {
@@ -38,7 +40,7 @@ declare const PoolUnavailableError_base: Schema.Class<PoolUnavailableError, Sche
38
40
  readonly pool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
39
41
  readonly message: Schema.NonEmptyString;
40
42
  }>, import("effect/Cause").YieldableError>;
41
- /** The selected credential cannot draw from the billing pool required by this session. */
43
+ /** The credential cannot spend from the billing pool this session needs. */
42
44
  export declare class PoolUnavailableError extends PoolUnavailableError_base {
43
45
  }
44
46
  declare const UnsupportedEffortError_base: Schema.Class<UnsupportedEffortError, Schema.TaggedStruct<"UnsupportedEffortError", {
@@ -47,16 +49,24 @@ declare const UnsupportedEffortError_base: Schema.Class<UnsupportedEffortError,
47
49
  readonly effort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
48
50
  readonly message: Schema.NonEmptyString;
49
51
  }>, import("effect/Cause").YieldableError>;
50
- /** The selected model exists but does not support the rostered reasoning effort. */
52
+ /** The model exists but does not support the rostered reasoning effort. */
51
53
  export declare class UnsupportedEffortError extends UnsupportedEffortError_base {
52
54
  }
53
55
  declare const AgentResultError_base: Schema.Class<AgentResultError, Schema.TaggedStruct<"AgentResultError", {
54
56
  readonly sessionId: Schema.OptionFromNullOr<Schema.brand<Schema.NonEmptyString, "AgentSessionId">>;
55
57
  readonly message: Schema.NonEmptyString;
56
58
  }>, import("effect/Cause").YieldableError>;
57
- /** The session ran to a terminal state and reported that the work itself failed. */
59
+ /** The session finished and reported that the work itself failed. */
58
60
  export declare class AgentResultError extends AgentResultError_base {
59
61
  }
62
+ declare const ChildSessionBudgetExceededError_base: Schema.Class<ChildSessionBudgetExceededError, Schema.TaggedStruct<"ChildSessionBudgetExceededError", {
63
+ readonly maxChildren: Schema.brand<Schema.Int, "ChildSessionBudget">;
64
+ readonly attemptedChildren: Schema.brand<Schema.Int, "ChildSessionCount">;
65
+ readonly message: Schema.NonEmptyString;
66
+ }>, import("effect/Cause").YieldableError>;
67
+ /** The Pi parent asked for one more child than this Attempt's budget allows. */
68
+ export declare class ChildSessionBudgetExceededError extends ChildSessionBudgetExceededError_base {
69
+ }
60
70
  export declare const SESSION_OPERATIONS: readonly ["launch", "stream", "steer", "interrupt"];
61
71
  export declare const SessionOperation: Schema.Literals<readonly ["launch", "stream", "steer", "interrupt"]>;
62
72
  export type SessionOperation = typeof SessionOperation.Type;
@@ -66,48 +76,72 @@ declare const SessionOperationError_base: Schema.Class<SessionOperationError, Sc
66
76
  readonly message: Schema.NonEmptyString;
67
77
  readonly cause: Schema.Defect;
68
78
  }>, import("effect/Cause").YieldableError>;
69
- /** SDK/process failure after model and harness validation. */
79
+ /** The SDK or its process failed after the model and harness were validated. */
70
80
  export declare class SessionOperationError extends SessionOperationError_base {
71
81
  }
72
- export declare const AgentSessionError: Schema.Union<readonly [typeof UnknownModelError, typeof PoolUnavailableError, typeof UnsupportedEffortError, typeof AgentResultError, typeof SessionOperationError]>;
82
+ /** A session could not start, continue, or finish its work; the failure determines whether retry needs an operator. */
83
+ export declare const AgentSessionError: Schema.Union<readonly [typeof UnknownModelError, typeof PoolUnavailableError, typeof UnsupportedEffortError, typeof AgentResultError, typeof ChildSessionBudgetExceededError, typeof SessionOperationError]>;
73
84
  export type AgentSessionError = typeof AgentSessionError.Type;
74
85
  /**
75
- * The one place the session error union meets the ADR 0002 retry taxonomy:
76
- * SDK/process trouble is retryable infrastructure; a bad roster spec or the
77
- * agent failing its own work always waits for the operator.
86
+ * Maps session errors onto the retry taxonomy: an SDK or process failure is
87
+ * retryable infrastructure, while a bad roster spec or the agent failing its
88
+ * own work waits for the operator (ADR 0002).
78
89
  */
79
- export declare const toAttemptFailure: (error: AgentSessionError) => AttemptFailure.AttemptFailure;
80
- /** Live SDK session. Its event stream and controls are backend-independent. */
90
+ export declare const toAttemptFailure: (error: AgentSessionError) => AttemptFailure;
91
+ /** A live parent or child session whose activity can be observed while its work continues. */
81
92
  export interface RunningSession {
82
- readonly session: Agent.Session;
83
- readonly events: Stream.Stream<Agent.SessionEvent, AgentSessionError>;
93
+ readonly session: AgentSession;
94
+ /** Activity to record in the Attempt transcript while waiting for the result. */
95
+ readonly events: Stream.Stream<AgentSessionEvent, AgentSessionError>;
96
+ /** Waits for the final message or the failure that ends this session's work. */
84
97
  readonly result: Effect.Effect<SessionResult, AgentSessionError>;
98
+ /** Adds operator guidance to the running session without creating a new Attempt. */
85
99
  readonly steer: (message: string) => Effect.Effect<void, AgentSessionError>;
100
+ /** Requests that this session stop its current work. */
86
101
  readonly interrupt: Effect.Effect<void, AgentSessionError>;
102
+ /** Applies a nonterminal operator action; child messages hold completion until release. */
103
+ readonly intervene: (action: AttemptChannel.OperatorAction) => Effect.Effect<AttemptChannel.InterventionState, AgentSessionError>;
104
+ }
105
+ /**
106
+ * Records each live child session so the run host can route operator input
107
+ * (steer, interrupt, or a takeover message) to one by the id it reports in the
108
+ * normalized event stream. The parent registers no child; it is addressed
109
+ * directly. Registration is scoped: the entry is removed when the child's scope
110
+ * closes, so a returned child is no longer addressable (ADR 0018).
111
+ */
112
+ export interface ChildSessions {
113
+ readonly register: (session: RunningSession) => Effect.Effect<void, never, Scope.Scope>;
87
114
  }
115
+ /** Launches coding sessions for tasks delegated by an Attempt's parent. */
88
116
  export interface ChildBackendService {
117
+ /** Starts the assigned child and returns its controls; its result is awaited separately. */
89
118
  readonly launch: (request: ChildRequest) => Effect.Effect<RunningSession, AgentSessionError, Scope.Scope>;
90
119
  }
91
120
  declare const ChildBackend_base: Context.ServiceClass<ChildBackend, "@usine/agents/ChildBackend", ChildBackendService>;
92
- /** Stable first-level child seam selected by the authored BrainSpec harness. */
121
+ /** Runs the coding work delegated by an Attempt's parent. */
93
122
  export declare class ChildBackend extends ChildBackend_base {
94
123
  }
95
124
  declare const ClaudeChildBackend_base: Context.ServiceClass<ClaudeChildBackend, "@usine/agents/ClaudeChildBackend", ChildBackendService>;
96
- /** Concrete Claude child implementation consumed by the harness dispatcher. */
125
+ /** Runs delegated coding work with Claude Code. */
97
126
  export declare class ClaudeChildBackend extends ClaudeChildBackend_base {
98
127
  }
99
128
  declare const CodexChildBackend_base: Context.ServiceClass<CodexChildBackend, "@usine/agents/CodexChildBackend", ChildBackendService>;
100
- /** Concrete Codex child implementation consumed by the harness dispatcher. */
129
+ /** Runs delegated coding work with Codex. */
101
130
  export declare class CodexChildBackend extends CodexChildBackend_base {
102
131
  }
103
132
  declare const PiChildBackend_base: Context.ServiceClass<PiChildBackend, "@usine/agents/PiChildBackend", ChildBackendService>;
104
- /** Concrete Pi child implementation consumed by the harness dispatcher. */
133
+ /** Runs delegated coding work with Pi. */
105
134
  export declare class PiChildBackend extends PiChildBackend_base {
106
135
  }
107
136
  declare const AgentRuntime_base: Context.ServiceClass<AgentRuntime, "@usine/agents/AgentRuntime", {
108
- readonly launch: (request: LaunchRequest) => Effect.Effect<RunningSession, AgentSessionError, Scope.Scope>;
137
+ /**
138
+ * Starts work in the prepared checkout and returns controls for observing and
139
+ * guiding the parent. Each child it spawns registers with `children` so the
140
+ * run host can address a takeover to it by id.
141
+ */
142
+ readonly launch: (request: LaunchRequest, children: ChildSessions) => Effect.Effect<RunningSession, AgentSessionError, Scope.Scope>;
109
143
  }>;
110
- /** Stable parent seam consumed by the run host. */
144
+ /** Starts the parent that coordinates one Attempt's task and delegates coding work to children. */
111
145
  export declare class AgentRuntime extends AgentRuntime_base {
112
146
  }
113
147
  export {};