@usine/core 0.2.0 → 0.4.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 (102) hide show
  1. package/README.md +43 -16
  2. package/dist/agent/agent.d.ts +12 -8
  3. package/dist/agent/agent.d.ts.map +1 -1
  4. package/dist/agent/agent.js +14 -10
  5. package/dist/agent/agent.js.map +1 -1
  6. package/dist/agent/brain.d.ts +2 -6
  7. package/dist/agent/brain.d.ts.map +1 -1
  8. package/dist/agent/brain.js +3 -7
  9. package/dist/agent/brain.js.map +1 -1
  10. package/dist/agent/capability.d.ts +4 -4
  11. package/dist/agent/capability.d.ts.map +1 -1
  12. package/dist/agent/capability.js +4 -4
  13. package/dist/agent/capability.js.map +1 -1
  14. package/dist/agent/session.d.ts +95 -21
  15. package/dist/agent/session.d.ts.map +1 -1
  16. package/dist/agent/session.js +100 -21
  17. package/dist/agent/session.js.map +1 -1
  18. package/dist/attempt/attempt.d.ts +63 -11
  19. package/dist/attempt/attempt.d.ts.map +1 -1
  20. package/dist/attempt/attempt.js +81 -11
  21. package/dist/attempt/attempt.js.map +1 -1
  22. package/dist/attempt/channel.d.ts +142 -44
  23. package/dist/attempt/channel.d.ts.map +1 -1
  24. package/dist/attempt/channel.js +124 -36
  25. package/dist/attempt/channel.js.map +1 -1
  26. package/dist/attempt/failure.d.ts +27 -14
  27. package/dist/attempt/failure.d.ts.map +1 -1
  28. package/dist/attempt/failure.js +27 -14
  29. package/dist/attempt/failure.js.map +1 -1
  30. package/dist/attempt/outcome.d.ts +3 -5
  31. package/dist/attempt/outcome.d.ts.map +1 -1
  32. package/dist/attempt/outcome.js +2 -4
  33. package/dist/attempt/outcome.js.map +1 -1
  34. package/dist/attempt/salvage.d.ts +50 -0
  35. package/dist/attempt/salvage.d.ts.map +1 -0
  36. package/dist/attempt/salvage.js +21 -0
  37. package/dist/attempt/salvage.js.map +1 -0
  38. package/dist/attempt/start.d.ts +35 -0
  39. package/dist/attempt/start.d.ts.map +1 -0
  40. package/dist/attempt/start.js +30 -0
  41. package/dist/attempt/start.js.map +1 -0
  42. package/dist/cycle-budget.d.ts +7 -8
  43. package/dist/cycle-budget.d.ts.map +1 -1
  44. package/dist/cycle-budget.js +9 -10
  45. package/dist/cycle-budget.js.map +1 -1
  46. package/dist/event.d.ts +4 -8
  47. package/dist/event.d.ts.map +1 -1
  48. package/dist/event.js +4 -8
  49. package/dist/event.js.map +1 -1
  50. package/dist/instance.d.ts +1 -1
  51. package/dist/instance.d.ts.map +1 -1
  52. package/dist/instance.js +1 -1
  53. package/dist/instance.js.map +1 -1
  54. package/dist/item.d.ts +1 -2
  55. package/dist/item.d.ts.map +1 -1
  56. package/dist/item.js +1 -2
  57. package/dist/item.js.map +1 -1
  58. package/dist/loop.d.ts +10 -2
  59. package/dist/loop.d.ts.map +1 -1
  60. package/dist/loop.js +9 -2
  61. package/dist/loop.js.map +1 -1
  62. package/dist/operator.d.ts +8 -0
  63. package/dist/operator.d.ts.map +1 -0
  64. package/dist/operator.js +9 -0
  65. package/dist/operator.js.map +1 -0
  66. package/dist/repository.d.ts +6 -8
  67. package/dist/repository.d.ts.map +1 -1
  68. package/dist/repository.js +8 -10
  69. package/dist/repository.js.map +1 -1
  70. package/dist/run/again.d.ts +13 -0
  71. package/dist/run/again.d.ts.map +1 -0
  72. package/dist/run/again.js +13 -0
  73. package/dist/run/again.js.map +1 -0
  74. package/dist/run/approval.d.ts +27 -0
  75. package/dist/run/approval.d.ts.map +1 -0
  76. package/dist/run/approval.js +26 -0
  77. package/dist/run/approval.js.map +1 -0
  78. package/dist/run/run.d.ts +2 -2
  79. package/dist/run/run.d.ts.map +1 -1
  80. package/dist/run/run.js +2 -2
  81. package/dist/run/run.js.map +1 -1
  82. package/dist/run/state.d.ts +22 -31
  83. package/dist/run/state.d.ts.map +1 -1
  84. package/dist/run/state.js +23 -36
  85. package/dist/run/state.js.map +1 -1
  86. package/dist/step/harvest.d.ts +44 -0
  87. package/dist/step/harvest.d.ts.map +1 -0
  88. package/dist/step/harvest.js +368 -0
  89. package/dist/step/harvest.js.map +1 -0
  90. package/dist/step/result.d.ts +15 -4
  91. package/dist/step/result.d.ts.map +1 -1
  92. package/dist/step/result.js +14 -4
  93. package/dist/step/result.js.map +1 -1
  94. package/dist/step/step.d.ts +2 -8
  95. package/dist/step/step.d.ts.map +1 -1
  96. package/dist/step/step.js +2 -8
  97. package/dist/step/step.js.map +1 -1
  98. package/dist/worker.d.ts +48 -4
  99. package/dist/worker.d.ts.map +1 -1
  100. package/dist/worker.js +47 -4
  101. package/dist/worker.js.map +1 -1
  102. package/package.json +27 -2
package/README.md CHANGED
@@ -1,35 +1,62 @@
1
1
  # @usine/core
2
2
 
3
- Domain model for [usine](https://github.com/basaltbytes/usine), an agent-agnostic software factory: the Event → Run → Step → Attempt vocabulary every other block types against, plus the shared instance, repository, worker, and agent values.
3
+ Domain model for [usine](https://github.com/basaltbytes/usine): event, run, step, and attempt types for every other block, plus shared instance, repo, worker, and agent values.
4
4
 
5
- Import each domain concept from its owning subpath. Identities, records, and operations share that domain module.
5
+ 0.x APIs change without notice. Supply the peer dependency `effect` at the pinned version.
6
+
7
+ ## Subpaths
6
8
 
7
9
  | Subpath | Exports |
8
10
  | --- | --- |
9
11
  | `@usine/core/event` | `Event`, `EventId`, `DedupKey` |
10
- | `@usine/core/run`, `@usine/core/run/state` | `Run`, `RunId`; the run state machine as a tagged union with typestate transitions (`RunState.start`, `RunState.supersede`, ...) |
12
+ | `@usine/core/run`, `@usine/core/run/state` | `Run`, `RunId`; the run state machine as a tagged union with typestate transitions (`RunState.start`, `RunState.supersede`, and others) |
11
13
  | `@usine/core/step`, `@usine/core/step/result` | `Step`, `StepName`; `StepResult` and its facts (`Commit`, `PullRequest`, `Comment`) |
12
- | `@usine/core/attempt` | `Attempt`, `AttemptId`, `AttemptNumber`, `AttemptTask`, `shouldAutoRetry` |
14
+ | `@usine/core/step/harvest` | `harvestFacts`, `harvestPostedComments`, `HarvestError`, `HarvestSpec`, `AttemptWindowsRead`: the commits and pull requests in an attempt's finished checkout, and the comments and reviews it posted on its item, read with the caller's `git`/`gh` runner |
15
+ | `@usine/core/attempt` | `Attempt`, `AttemptId`, `AttemptNumber`, `AttemptTask`, `shouldAutoRetry`, and `AttemptWindow`, `windowOf`, `windowHolds`, `windowsOverlap`, `AttemptWindows` |
13
16
  | `@usine/core/attempt/outcome` | `AttemptSucceeded`, `AttemptFailed`, `AttemptCanceled`, `AttemptOutcome` |
14
17
  | `@usine/core/attempt/failure` | `InfraFailure`, `DefectFailure`, `AgentFailure`, `RunawayFailure`, `ChildSessionBudgetFailure`, `AttemptFailure`, `isAutoRetryableFailure` |
15
- | `@usine/core/attempt/channel` | The protocol-v4 attempt channel: `RunSpec`, `Start`, the envelopes, and the `admit` reducer. Import it as a namespace (`AttemptChannel.Started`) |
16
- | `@usine/core/agent`, `@usine/core/agent/brain`, `@usine/core/agent/session` | `Agent`, `AgentName`, `AgentPersona`, parent-model resolution; `BrainSpec`, `ModelId`, `Harness`, `Effort`; `AgentSessionId`, session descriptors, `AgentSessionEvent`, `ChildSessionBudget`, `ChildSessionCount` |
18
+ | `@usine/core/attempt/salvage` | `SalvageRef`, `salvageRefFor`, `SalvagePushed`, `SalvageRetained`, `AttemptSalvage`, `AttemptRecovery`, `RecoverySink` (its `windows` reads the windows a recovered attempt's harvest needs) |
19
+ | `@usine/core/attempt/start` | Why an attempt started: `StartedByEvent`, `StartedByRetry`, `StartedByEditAndRetry` (with the operator login), `StartedByInfraRetry`, `StartedAfterRestart`, `AttemptStart`, `OperatorRetryStart` |
20
+ | `@usine/core/attempt/channel` | `RunSpec`, versioned envelopes, the `Sink` (stores envelopes, reads the `transcript` and the harvest's `windows`), and the `admit` reducer. Import as a namespace (`AttemptChannel.Started`). |
21
+ | `@usine/core/agent`, `/agent/brain`, `/agent/session` | `Agent`, `AgentName`, `AgentPersona`, parent model resolution, `githubSignature` (the last line of an agent's GitHub comments); `BrainSpec`, `ModelId`, `Harness`, `Effort`; `AgentSessionId`, session descriptors, `AgentSessionEvent`, `ChildSessionBudget`, `ChildSessionCount` |
17
22
  | `@usine/core/agent/capability` | `HarnessCapability`, `HarnessReady`, `HarnessUnavailableError`, and the credential-free `HarnessReadiness` preflight response |
18
- | `@usine/core/repository` | `RepositoryName`, `RepositoryRevision`, `CommitSha`, `splitRepositoryName`, `canonicalRepositoryName` |
19
- | `@usine/core/worker`, `@usine/core/item`, `@usine/core/loop`, `@usine/core/instance` | `WorkerName`, `WorkerKind`; `ItemKey`, `ItemNumber`; `LoopName`, `ApprovalRequirement`; `InstanceDirectory` |
23
+ | `@usine/core/repository` | `RepositoryName`, `RepositoryRevision`, `CommitSha`, `safeSegment`, `splitRepositoryName`, `canonicalRepositoryName` |
24
+ | `@usine/core/worker`, `/item`, `/loop`, `/instance` | `WorkerName`, `WorkerKind`, `GatewayCredentialKind`; `ItemKey`, `ItemNumber`; `LoopName`, `ApprovalRequirement`; `InstanceDirectory` |
25
+ | `@usine/core/cycle-budget` | `CycleLimit`, `CycleGeneration`, `CycleCount`, `LoopCycleCount`, `CycleBudgetAsk` |
26
+
27
+ Branded schemas are exported under their brand name, as a value and a type. `PullRequest` and `Comment` facts use `URL` values in memory and strings in JSON, so step results round-trip through the channel and durable storage.
28
+
29
+ ## Runs
30
+
31
+ The run state machine is `pending → waiting → queued → running → succeeded / failed / canceled`, plus `failed → running` on operator retry. `RunState.operatorActions(state)` returns which of approval, retry, failure resolution, cancel, and run again apply. Command handlers share these typed transitions.
32
+
33
+ - Run again opens a new run for the item state of a succeeded or canceled run. `RunAgain` (`/run/again`) records the original run and who asked.
34
+ - Failure resolution applies only in the failed state; operator views also hide it once the latest failed attempt is resolved.
35
+
36
+ An item-level `CycleBudgetAsk`, which can exist before another run opens, records the exhausted loop, its limit, and the participating loops' admitted and completed runs.
37
+
38
+ ## Attempts
39
+
40
+ Each attempt records its child `BrainSpec`, its effective Pi parent model, why it started (`start`, none for attempts from before usine recorded it), and when a restart last reattached it (`reattachedAt`). `RunSpec` is the immutable repo, payload, task, agent context, and child-session budget that the parent starts from.
41
+
42
+ Only infra failures retry automatically, up to a cap. Agent failures wait for the operator. Runaway guard failures, exhausted child-session budgets, and `DefectFailure` never retry automatically; `DefectFailure` records a defect caught at a boundary that needs a serializable outcome, with its original cause.
43
+
44
+ ## Attempt windows
45
+
46
+ `AttemptWindow` is when an attempt worked on its run's item: `startedAt` to `endedAt` from its record, with no end while open. `windowOf(attempt)` returns none for an attempt that ended before usine recorded end times. `windowHolds(window, at)` opens a window at its start second, since GitHub records times to the second. `windowsOverlap` says whether GitHub can record a time inside both windows.
20
47
 
21
- Branded schemas are exported under their brand name, and each has an `export type` twin of the same name so the name works in type positions too.
48
+ Attempts on local and SSH workers all write as the same GitHub App, so a write inside two attempts' windows belongs to neither, in the run reader and in the harvest. The harvest keeps a comment only if the bot login wrote it with the agent's signature, after the worker prepared the checkout (creation, or a review's submission), inside the attempt's own window, and in no window of the agent's other overlapping attempts.
22
49
 
23
- `PullRequest` and `Comment` facts use `URL` values in memory and URL strings in JSON, so Step results round-trip through the Attempt channel and durable storage.
50
+ The harvest reads `AttemptWindows` (`own`, `overlapping`) through `AttemptWindowsRead` after GitHub lists the comments, so they include attempts started during the harvest and any end the orchestrator recorded first, as a cancel does before the executor stops. Comments after that end, and attempts started after it, don't count.
24
51
 
25
- The run state machine is `pending → waiting → queued → running → succeeded / failed / canceled`, with `failed → running` on operator retry. The failure taxonomy separates infra failures (the only auto-retryable class, capped), agent failures (always wait for the operator), runaway guard failures, and exhausted child-session budgets. Guard failures never auto-retry.
52
+ ## Sessions and usage
26
53
 
27
- `RunState.operatorActions(state)` returns approval, retry, and cancel availability for operator views. The command handlers enforce the same lifecycle through the typed transitions.
54
+ Outbound `SessionEvent` envelopes keep parent and first-level child session identity.
28
55
 
29
- Each Attempt records the child `BrainSpec` and effective Pi parent model used for that try. The attempt channel includes immutable repository, payload, task, agent context, and child-session budget in its `Start` frame; outbound `SessionEvent` envelopes retain parent and first-level child session identity.
56
+ `SessionTokensUpdated` has a session's cumulative `TokenCount` and, as `costUsd`, the `UsdAmount` its harness priced it at: Pi from its model catalog, Claude Code from the Agent SDK. Codex sets no price. Older transcripts decode it to `Option.none()`.
30
57
 
31
- Everything is 0.x: APIs change without notice while the engine grows. `effect` is a peer dependency — supply it yourself at the pinned version.
58
+ `ChildSession.gatewayCredential` is the `GatewayCredentialKind` the gateway in front of the child's worker used for its model requests: none if the child used its harness's login, and in older transcripts. `brainPool(brain, gatewayCredential)` returns a started session's billing pool; `sessionPool(session)` reads a recorded one's. A Claude Code child is in `apiKeys` if its gateway used an API key, otherwise in `claudePlan` (ADR 0013, ADR 0021).
32
59
 
33
- Import `CycleLimit`, `CycleGeneration`, `CycleCount`, `LoopCycleCount`, and `CycleBudgetAsk` from `@usine/core/cycle-budget`. An Item-level Ask records the exhausted Loop, its limit, and participating Loops’ admitted and completed Runs; it can exist before another Run is opened.
60
+ The optional `SessionStarted.harnessSession` (`HarnessSession`) records the harness's `HarnessSessionId` and the worker `cwd`, apart from usine's session identity. Older transcripts decode it to `Option.none()`.
34
61
 
35
- `DefectFailure` records a programmer defect captured at a boundary that needs a serializable Attempt outcome. It retains the original cause and never qualifies for automatic retry.
62
+ Envelopes include `PROTOCOL_VERSION` (7), which the transcript store uses to read older envelopes. Version 7 added the previous attempt's pushed salvage to `RunSpec` (`resume`); version 6 added harness session metadata.
@@ -1,27 +1,31 @@
1
1
  import { Schema, Option } from "effect";
2
2
  import { BrainSpec, Effort, ModelId } from "./brain.ts";
3
- /** Kebab-case name of a rostered Agent, taken from its filename. */
3
+ /** The kebab-case name of an Agent, taken from its filename. */
4
4
  export declare const AgentName: Schema.brand<Schema.String, "AgentName">;
5
5
  export type AgentName = typeof AgentName.Type;
6
- /** Standing Markdown instructions for one Agent. */
6
+ /**
7
+ * Returns the signature line that ends every GitHub comment, issue, pull request, or review the
8
+ * Agent writes. Harvesting uses it to separate Agents that post as the same bot login.
9
+ */
10
+ export declare const githubSignature: (agent: AgentName) => string;
11
+ /** The Agent's standing Markdown instructions. */
7
12
  export declare const AgentPersona: Schema.brand<Schema.String, "AgentPersona">;
8
13
  export type AgentPersona = typeof AgentPersona.Type;
9
14
  declare const Agent_base: Schema.Class<Agent, Schema.Struct<{
10
15
  readonly name: Schema.brand<Schema.String, "AgentName">;
11
- /** Coding harness and settings used for this Agent's delegated child sessions. */
16
+ /** The harness, model, and effort of the Agent's child sessions. */
12
17
  readonly brain: typeof BrainSpec;
13
- /** Preferred model for the coordinating Pi parent; an absent override uses the instance default. */
18
+ /** The model of the Pi parent session, or `None` for the instance default. */
14
19
  readonly parentModel: Schema.OptionFromNullOr<Schema.brand<Schema.String, "ModelId">>;
15
- /** Parent reasoning effort; an absent override uses the instance default, then the child brain's effort. */
20
+ /** The parent session's reasoning effort, or `None` for the instance default, then `brain.effort`. */
16
21
  readonly parentEffort: Schema.OptionFromOptionalKey<Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>>;
17
22
  readonly persona: Schema.brand<Schema.String, "AgentPersona">;
18
23
  }>, {}>;
19
- /** One named member of the instance's team roster. */
20
24
  export declare class Agent extends Agent_base {
21
25
  }
22
- /** Selects the Agent's parent-model override, then the instance default; `None` leaves selection to Pi. */
26
+ /** Returns the Agent's `parentModel`, else the instance default. Returns `None` if neither is set, so Pi selects the model. */
23
27
  export declare const resolveParentModel: (agent: Agent, instanceDefault: Option.Option<ModelId>) => Option.Option<ModelId>;
24
- /** The agent's parent-effort override, else the instance default, else the child brain's effort. */
28
+ /** Returns the Agent's `parentEffort`, else the instance default, else `brain.effort`. */
25
29
  export declare const resolveParentEffort: (agent: Agent, instanceDefault: Option.Option<Effort>) => Effort;
26
30
  export {};
27
31
  //# sourceMappingURL=agent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAA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AG9E,sGAAsG;;;;AAPxG,qBAAa,KAAM,SAAQ,UAUzB;CAAG;AAEL,+HAA+H;AAC/H,eAAO,MAAM,kBAAkB,UACtB,KAAK,mBACK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KACtC,MAAM,CAAC,MAAM,CAAC,OAAO,CAA6D,CAAC;AAEtF,0FAA0F;AAC1F,eAAO,MAAM,mBAAmB,UAAW,KAAK,mBAAmB,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,KAAG,MAIxF,CAAC"}
@@ -1,26 +1,30 @@
1
1
  import { Schema, Option } from "effect";
2
2
  import { BrainSpec, Effort, ModelId } from "./brain.js";
3
- /** Kebab-case name of a rostered Agent, taken from its filename. */
3
+ /** The kebab-case name of an Agent, taken from its filename. */
4
4
  export const AgentName = Schema.String.check(Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u, {
5
- message: "Expected a kebab-case Agent name",
5
+ message: "Expected a kebab-case agent name",
6
6
  })).pipe(Schema.brand("AgentName"));
7
- /** Standing Markdown instructions for one Agent. */
8
- export const AgentPersona = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank Agent persona" })).pipe(Schema.brand("AgentPersona"));
9
- /** One named member of the instance's team roster. */
7
+ /**
8
+ * Returns the signature line that ends every GitHub comment, issue, pull request, or review the
9
+ * Agent writes. Harvesting uses it to separate Agents that post as the same bot login.
10
+ */
11
+ export const githubSignature = (agent) => `— usine agent: ${agent}`;
12
+ /** The Agent's standing Markdown instructions. */
13
+ export const AgentPersona = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank agent persona" })).pipe(Schema.brand("AgentPersona"));
10
14
  export class Agent extends Schema.Class("Agent")({
11
15
  name: AgentName,
12
- /** Coding harness and settings used for this Agent's delegated child sessions. */
16
+ /** The harness, model, and effort of the Agent's child sessions. */
13
17
  brain: BrainSpec,
14
- /** Preferred model for the coordinating Pi parent; an absent override uses the instance default. */
18
+ /** The model of the Pi parent session, or `None` for the instance default. */
15
19
  parentModel: Schema.OptionFromNullOr(ModelId),
16
20
  // Optional key rather than null: older stored agent rows have no such key.
17
- /** Parent reasoning effort; an absent override uses the instance default, then the child brain's effort. */
21
+ /** The parent session's reasoning effort, or `None` for the instance default, then `brain.effort`. */
18
22
  parentEffort: Schema.OptionFromOptionalKey(Effort),
19
23
  persona: AgentPersona,
20
24
  }) {
21
25
  }
22
- /** Selects the Agent's parent-model override, then the instance default; `None` leaves selection to Pi. */
26
+ /** Returns the Agent's `parentModel`, else the instance default. Returns `None` if neither is set, so Pi selects the model. */
23
27
  export const resolveParentModel = (agent, instanceDefault) => Option.firstSomeOf([agent.parentModel, instanceDefault]);
24
- /** The agent's parent-effort override, else the instance default, else the child brain's effort. */
28
+ /** Returns the Agent's `parentEffort`, else the instance default, else `brain.effort`. */
25
29
  export const resolveParentEffort = (agent, instanceDefault) => Option.getOrElse(Option.firstSomeOf([agent.parentEffort, instanceDefault]), () => agent.brain.effort);
26
30
  //# sourceMappingURL=agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/agent/agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAExD,oEAAoE;AACpE,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC1C,MAAM,CAAC,SAAS,CAAC,6BAA6B,EAAE;IAC9C,OAAO,EAAE,kCAAkC;CAC5C,CAAC,CACH,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;AAIlC,oDAAoD;AACpD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,oCAAoC,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Schema } from "effect";
2
- /** A provider's model name; the selected harness checks its availability when the session starts. */
2
+ /** A provider model name, which the harness checks when the session starts. */
3
3
  export declare const ModelId: Schema.brand<Schema.String, "ModelId">;
4
4
  export type ModelId = typeof ModelId.Type;
5
- /** Coding runtimes an Agent can select for delegated work. */
6
5
  export declare const HARNESSES: readonly ["claude", "codex", "pi"];
7
- /** The coding runtime that executes an Agent session. */
8
6
  export declare const Harness: Schema.Literals<readonly ["claude", "codex", "pi"]>;
9
7
  export type Harness = typeof Harness.Type;
10
- /** Reasoning levels accepted in Agent files; support depends on the chosen harness and model. */
8
+ /** The reasoning levels; support depends on the harness and model. */
11
9
  export declare const EFFORTS: readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
12
- /** The requested amount of reasoning for a session; available levels depend on its harness and model. */
13
10
  export declare const Effort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
14
11
  export type Effort = typeof Effort.Type;
15
12
  declare const BrainSpec_base: Schema.Class<BrainSpec, Schema.Struct<{
@@ -17,7 +14,6 @@ declare const BrainSpec_base: Schema.Class<BrainSpec, Schema.Struct<{
17
14
  readonly model: Schema.brand<Schema.String, "ModelId">;
18
15
  readonly effort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
19
16
  }>, {}>;
20
- /** How an Agent session runs: its coding harness, model, and reasoning effort. */
21
17
  export declare class BrainSpec extends BrainSpec_base {
22
18
  }
23
19
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../src/agent/brain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qGAAqG;AACrG,eAAO,MAAM,OAAO,wCAEW,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,8DAA8D;AAC9D,eAAO,MAAM,SAAS,YAAI,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAU,CAAC;AAC5D,yDAAyD;AACzD,eAAO,MAAM,OAAO,qDAA6B,CAAC;AAClD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,iGAAiG;AACjG,eAAO,MAAM,OAAO,YAAI,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAC5F,yGAAyG;AACzG,eAAO,MAAM,MAAM,uFAA2B,CAAC;AAC/C,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;;;;;;AAExC,kFAAkF;AAClF,qBAAa,SAAU,SAAQ,cAI7B;CAAG"}
1
+ {"version":3,"file":"brain.d.ts","sourceRoot":"","sources":["../../src/agent/brain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+EAA+E;AAC/E,eAAO,MAAM,OAAO,wCAEW,CAAC;AAChC,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,eAAO,MAAM,SAAS,YAAI,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAU,CAAC;AAC5D,eAAO,MAAM,OAAO,qDAA6B,CAAC;AAClD,MAAM,MAAM,OAAO,GAAG,OAAO,OAAO,CAAC,IAAI,CAAC;AAE1C,sEAAsE;AACtE,eAAO,MAAM,OAAO,YAAI,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAC5F,eAAO,MAAM,MAAM,uFAA2B,CAAC;AAC/C,MAAM,MAAM,MAAM,GAAG,OAAO,MAAM,CAAC,IAAI,CAAC;;;;;;AAExC,qBAAa,SAAU,SAAQ,cAI7B;CAAG"}
@@ -1,15 +1,11 @@
1
1
  import { Schema } from "effect";
2
- /** A provider's model name; the selected harness checks its availability when the session starts. */
3
- export const ModelId = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank model id" })).pipe(Schema.brand("ModelId"));
4
- /** Coding runtimes an Agent can select for delegated work. */
2
+ /** A provider model name, which the harness checks when the session starts. */
3
+ export const ModelId = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank model ID" })).pipe(Schema.brand("ModelId"));
5
4
  export const HARNESSES = ["claude", "codex", "pi"];
6
- /** The coding runtime that executes an Agent session. */
7
5
  export const Harness = Schema.Literals(HARNESSES);
8
- /** Reasoning levels accepted in Agent files; support depends on the chosen harness and model. */
6
+ /** The reasoning levels; support depends on the harness and model. */
9
7
  export const EFFORTS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"];
10
- /** The requested amount of reasoning for a session; available levels depend on its harness and model. */
11
8
  export const Effort = Schema.Literals(EFFORTS);
12
- /** How an Agent session runs: its coding harness, model, and reasoning effort. */
13
9
  export class BrainSpec extends Schema.Class("Agent/BrainSpec")({
14
10
  harness: Harness,
15
11
  model: ModelId,
@@ -1 +1 @@
1
- {"version":3,"file":"brain.js","sourceRoot":"","sources":["../../src/agent/brain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,qGAAqG;AACrG,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CACxC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,+BAA+B,EAAE,CAAC,CACtE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;AAGhC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAU,CAAC;AAC5D,yDAAyD;AACzD,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAGlD,iGAAiG;AACjG,MAAM,CAAC,MAAM,OAAO,G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AChB,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,MAAM;CACf,CAAC;CAAG"}
@@ -1,5 +1,5 @@
1
1
  import { Schema } from "effect";
2
- /** A harness prerequisite that requires operator provisioning, never an automatic retry. */
2
+ /** A harness prerequisite that the operator must provision; a missing one is never retried. */
3
3
  export declare const HarnessCapability: Schema.Literals<readonly ["binary", "version", "login"]>;
4
4
  export type HarnessCapability = typeof HarnessCapability.Type;
5
5
  declare const HarnessUnavailableError_base: Schema.Class<HarnessUnavailableError, Schema.TaggedStruct<"HarnessUnavailableError", {
@@ -7,16 +7,16 @@ declare const HarnessUnavailableError_base: Schema.Class<HarnessUnavailableError
7
7
  readonly capability: Schema.Literals<readonly ["binary", "version", "login"]>;
8
8
  readonly message: Schema.NonEmptyString;
9
9
  }>, import("effect/Cause").YieldableError>;
10
- /** The Worker cannot run the requested harness until the operator fixes its provisioning. */
10
+ /** An error for a Worker that is missing `capability` for `harness`. */
11
11
  export declare class HarnessUnavailableError extends HarnessUnavailableError_base {
12
12
  }
13
13
  declare const HarnessReady_base: Schema.Class<HarnessReady, Schema.TaggedStruct<"HarnessReady", {
14
14
  readonly harness: Schema.Literals<readonly ["claude", "codex", "pi"]>;
15
15
  }>, {}>;
16
- /** A verify-only probe found the requested harness available in the Worker's environment. */
16
+ /** The result of a verify-only probe that found the harness available on the Worker. */
17
17
  export declare class HarnessReady extends HarnessReady_base {
18
18
  }
19
- /** The run host's preflight response; contains no credentials or account identity. */
19
+ /** The result of a harness preflight, without credentials or account identity. */
20
20
  export declare const HarnessReadiness: Schema.Union<readonly [typeof HarnessReady, typeof HarnessUnavailableError]>;
21
21
  export type HarnessReadiness = typeof HarnessReadiness.Type;
22
22
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/agent/capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB,0DAAkD,CAAC;AACjF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;;;;;;AAE9D,6FAA6F;AAC7F,qBAAa,uBAAwB,SAAQ,4BAM3C;CAAG;;;;AAEL,6FAA6F;AAC7F,qBAAa,YAAa,SAAQ,iBAEhC;CAAG;AAEL,sFAAsF;AACtF,eAAO,MAAM,gBAAgB,8EAAwD,CAAC;AACtF,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC"}
1
+ {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../../src/agent/capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,+FAA+F;AAC/F,eAAO,MAAM,iBAAiB,0DAAkD,CAAC;AACjF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,CAAC;;;;;;AAE9D,wEAAwE;AACxE,qBAAa,uBAAwB,SAAQ,4BAM3C;CAAG;;;;AAEL,wFAAwF;AACxF,qBAAa,YAAa,SAAQ,iBAEhC;CAAG;AAEL,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,8EAAwD,CAAC;AACtF,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC"}
@@ -1,19 +1,19 @@
1
1
  import { Schema } from "effect";
2
2
  import { Harness } from "./brain.js";
3
- /** A harness prerequisite that requires operator provisioning, never an automatic retry. */
3
+ /** A harness prerequisite that the operator must provision; a missing one is never retried. */
4
4
  export const HarnessCapability = Schema.Literals(["binary", "version", "login"]);
5
- /** The Worker cannot run the requested harness until the operator fixes its provisioning. */
5
+ /** An error for a Worker that is missing `capability` for `harness`. */
6
6
  export class HarnessUnavailableError extends Schema.TaggedError("HarnessUnavailableError")("HarnessUnavailableError", {
7
7
  harness: Harness,
8
8
  capability: HarnessCapability,
9
9
  message: Schema.NonEmptyString,
10
10
  }) {
11
11
  }
12
- /** A verify-only probe found the requested harness available in the Worker's environment. */
12
+ /** The result of a verify-only probe that found the harness available on the Worker. */
13
13
  export class HarnessReady extends Schema.TaggedClass("HarnessReady")("HarnessReady", {
14
14
  harness: Harness,
15
15
  }) {
16
16
  }
17
- /** The run host's preflight response; contains no credentials or account identity. */
17
+ /** The result of a harness preflight, without credentials or account identity. */
18
18
  export const HarnessReadiness = Schema.Union([HarnessReady, HarnessUnavailableError]);
19
19
  //# sourceMappingURL=capability.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"capability.js","sourceRoot":"","sources":["../../src/agent/capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAGjF,6FAA6F;AAC7F,MAAM,OAAO,uBAAwB,SAAQ,MAAM,CAAC,WAAW,CAC7D,yBAAyB,CAC1B,CAAC,yBAAyB,EAAE;IAC3B,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,iBAAiB;IAC7B,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC;CAAG;AAEL,6FAA6F;AAC7F,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,CAAe,cAAc,CAAC,CAAC,cAAc,EAAE;IACjG,OAAO,EAAE,OAAO;CACjB,CAAC;CAAG;AAEL,sFAAsF;AACtF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"capability.js","sourceRoot":"","sources":["../../src/agent/capability.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,+FAA+F;AAC/F,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC;AAGjF,wEAAwE;AACxE,MAAM,OAAO,uBAAwB,SAAQ,MAAM,CAAC,WAAW,CAC7D,yBAAyB,CAC1B,CAAC,yBAAyB,EAAE;IAC3B,OAAO,EAAE,OAAO;IAChB,UAAU,EAAE,iBAAiB;IAC7B,OAAO,EAAE,MAAM,CAAC,cAAc;CAC/B,CAAC;CAAG;AAEL,wFAAwF;AACxF,MAAM,OAAO,YAAa,SAAQ,MAAM,CAAC,WAAW,CAAe,cAAc,CAAC,CAAC,cAAc,EAAE;IACjG,OAAO,EAAE,OAAO;CACjB,CAAC;CAAG;AAEL,kFAAkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,YAAY,EAAE,uBAAuB,CAAC,CAAC,CAAC"}
@@ -1,12 +1,16 @@
1
- import { Schema } from "effect";
1
+ import { Option, Schema } from "effect";
2
+ import { GatewayCredentialKind } from "../worker.ts";
2
3
  import { BrainSpec } from "./brain.ts";
3
- /** Identity usine assigns to a parent or child session within an Attempt. */
4
+ /** The usine ID of a parent or child session, distinct from `HarnessSessionId`. */
4
5
  export declare const AgentSessionId: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
5
6
  export type AgentSessionId = typeof AgentSessionId.Type;
6
- /** Maximum child sessions one Attempt may spawn over its lifetime, including sequential spawns. */
7
+ /** The sum of output tokens and uncached input tokens (new prompt text and cache writes), excluding cache reads. */
8
+ export declare const TokenCount: Schema.brand<Schema.Int, "TokenCount">;
9
+ export type TokenCount = typeof TokenCount.Type;
10
+ /** The maximum number of child sessions per Attempt, counting sequential spawns. */
7
11
  export declare const ChildSessionBudget: Schema.brand<Schema.Int, "ChildSessionBudget">;
8
12
  export type ChildSessionBudget = typeof ChildSessionBudget.Type;
9
- /** The 1-based child spawn request number within an Attempt, including requests rejected by the budget. */
13
+ /** The 1-based number of a child spawn request in an Attempt, counting requests the budget rejected. */
10
14
  export declare const ChildSessionCount: Schema.brand<Schema.Int, "ChildSessionCount">;
11
15
  export type ChildSessionCount = typeof ChildSessionCount.Type;
12
16
  declare const ParentSession_base: Schema.Class<ParentSession, Schema.TaggedStruct<"ParentSession", {
@@ -14,7 +18,6 @@ declare const ParentSession_base: Schema.Class<ParentSession, Schema.TaggedStruc
14
18
  readonly agent: Schema.brand<Schema.String, "AgentName">;
15
19
  readonly brain: typeof BrainSpec;
16
20
  }>, {}>;
17
- /** The session coordinating an Attempt and delegating work to its coding children. */
18
21
  export declare class ParentSession extends ParentSession_base {
19
22
  }
20
23
  declare const ChildSession_base: Schema.Class<ChildSession, Schema.TaggedStruct<"ChildSession", {
@@ -22,24 +25,40 @@ declare const ChildSession_base: Schema.Class<ChildSession, Schema.TaggedStruct<
22
25
  readonly parentId: Schema.brand<Schema.NonEmptyString, "AgentSessionId">;
23
26
  readonly agent: Schema.brand<Schema.String, "AgentName">;
24
27
  readonly brain: typeof BrainSpec;
28
+ /**
29
+ * The credential kind the Gateway used for the child's model requests (ADR 0027), or `None`
30
+ * if the child used its harness's own login or the record is older.
31
+ */
32
+ readonly gatewayCredential: Schema.withConstructorDefault<Schema.OptionFromOptionalKey<Schema.Literals<readonly ["api-key", "subscription"]>>>;
25
33
  }>, {}>;
26
- /** A coding session delegated by the Attempt's parent; children cannot delegate to further children. */
34
+ /** A session spawned by the parent session; a child can't spawn children. */
27
35
  export declare class ChildSession extends ChildSession_base {
28
36
  }
29
- /** A participant in an Attempt, with its role, Agent, and effective brain recorded. */
30
37
  export declare const AgentSession: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
31
38
  export type AgentSession = typeof AgentSession.Type;
39
+ /** The harness's ID for its saved conversation, distinct from `AgentSessionId`. */
40
+ export declare const HarnessSessionId: Schema.brand<Schema.NonEmptyString, "HarnessSessionId">;
41
+ export type HarnessSessionId = typeof HarnessSessionId.Type;
42
+ declare const HarnessSession_base: Schema.Class<HarnessSession, Schema.Struct<{
43
+ readonly id: Schema.brand<Schema.NonEmptyString, "HarnessSessionId">;
44
+ readonly cwd: Schema.NonEmptyString;
45
+ }>, {}>;
46
+ /** A saved harness conversation; `cwd` is the Worker checkout to resume it from. */
47
+ export declare class HarnessSession extends HarnessSession_base {
48
+ }
32
49
  declare const SessionStarted_base: Schema.Class<SessionStarted, Schema.TaggedStruct<"SessionStarted", {
33
50
  readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
51
+ /** `None` for older transcripts and for harnesses without a saved conversation. */
52
+ readonly harnessSession: Schema.withConstructorDefault<Schema.OptionFromOptionalKey<typeof HarnessSession>>;
34
53
  }>, {}>;
35
- /** Records the session identity and brain actually selected at launch. */
54
+ /** The session identity and the brain selected at launch. */
36
55
  export declare class SessionStarted extends SessionStarted_base {
37
56
  }
38
57
  declare const TextOutput_base: Schema.Class<TextOutput, Schema.TaggedStruct<"TextOutput", {
39
58
  readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
40
59
  readonly text: Schema.NonEmptyString;
41
60
  }>, {}>;
42
- /** Completed assistant text emitted during the session, which may precede its final result. */
61
+ /** Completed assistant text, which can come before the final result. */
43
62
  export declare class TextOutput extends TextOutput_base {
44
63
  }
45
64
  declare const ToolStarted_base: Schema.Class<ToolStarted, Schema.TaggedStruct<"ToolStarted", {
@@ -48,7 +67,7 @@ declare const ToolStarted_base: Schema.Class<ToolStarted, Schema.TaggedStruct<"T
48
67
  readonly tool: Schema.NonEmptyString;
49
68
  readonly input: Schema.Codec<Schema.Json, Schema.Json, never, never>;
50
69
  }>, {}>;
51
- /** A session began a tool call; `callId` pairs it with the corresponding result. */
70
+ /** The start of a tool call; `callId` matches the corresponding `ToolFinished`. */
52
71
  export declare class ToolStarted extends ToolStarted_base {
53
72
  }
54
73
  declare const ToolFinished_base: Schema.Class<ToolFinished, Schema.TaggedStruct<"ToolFinished", {
@@ -58,27 +77,59 @@ declare const ToolFinished_base: Schema.Class<ToolFinished, Schema.TaggedStruct<
58
77
  readonly output: Schema.Codec<Schema.Json, Schema.Json, never, never>;
59
78
  readonly isError: Schema.Boolean;
60
79
  }>, {}>;
61
- /** A tool call returned its output; a tool error does not by itself close the session. */
80
+ /** The result of a tool call; `isError` doesn't end the session. */
62
81
  export declare class ToolFinished extends ToolFinished_base {
63
82
  }
64
83
  declare const SessionFinished_base: Schema.Class<SessionFinished, Schema.TaggedStruct<"SessionFinished", {
65
84
  readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
66
85
  }>, {}>;
67
- /** Marks the end of a session's activity in the transcript; the Attempt's outcome is recorded separately. */
86
+ /** The end of a session's activity; the Attempt's outcome is recorded separately. */
68
87
  export declare class SessionFinished extends SessionFinished_base {
69
88
  }
70
- /** The billing source whose meter produced a usage or rate-limit observation. */
89
+ declare const SessionIdle_base: Schema.Class<SessionIdle, Schema.TaggedStruct<"SessionIdle", {
90
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
91
+ }>, {}>;
92
+ /** A supervised session that finished a turn and accepts more operator messages. */
93
+ export declare class SessionIdle extends SessionIdle_base {
94
+ }
95
+ declare const SessionResumed_base: Schema.Class<SessionResumed, Schema.TaggedStruct<"SessionResumed", {
96
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
97
+ }>, {}>;
98
+ /** A live session that started another user turn in the same conversation. */
99
+ export declare class SessionResumed extends SessionResumed_base {
100
+ }
101
+ /** An estimated amount in US dollars from the harness's own rate table, not a bill (ADR 0013). */
102
+ export declare const UsdAmount: Schema.brand<Schema.Finite, "UsdAmount">;
103
+ export type UsdAmount = typeof UsdAmount.Type;
104
+ declare const SessionTokensUpdated_base: Schema.Class<SessionTokensUpdated, Schema.TaggedStruct<"SessionTokensUpdated", {
105
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
106
+ readonly totalTokens: Schema.brand<Schema.Int, "TokenCount">;
107
+ readonly costUsd: Schema.withConstructorDefault<Schema.OptionFromOptionalKey<Schema.brand<Schema.Finite, "UsdAmount">>>;
108
+ }>, {}>;
109
+ /**
110
+ * The session's cumulative token count and price, including later operator turns. `costUsd` is
111
+ * `None` for harnesses that don't price usage, such as Codex, and for older transcripts.
112
+ */
113
+ export declare class SessionTokensUpdated extends SessionTokensUpdated_base {
114
+ }
71
115
  export declare const BillingPool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
72
116
  export type BillingPool = typeof BillingPool.Type;
117
+ /**
118
+ * Returns the billing pool of a session with `brain` and the Gateway credential kind, if any.
119
+ *
120
+ * - Claude Code: `apiKeys` if the Gateway injects an API key, otherwise `claudePlan` (ADR 0013).
121
+ * - Codex: `chatgptPlan`.
122
+ * - Pi: `chatgptPlan` for `openai-codex/` models, otherwise `apiKeys` (ADR 0021).
123
+ */
124
+ export declare const brainPool: (brain: BrainSpec, gatewayCredential: Option.Option<GatewayCredentialKind>) => BillingPool;
125
+ /** Returns the billing pool of a recorded session; the parent never uses a Gateway credential. */
126
+ export declare const sessionPool: (session: AgentSession) => BillingPool;
73
127
  declare const RateLimitWindow_base: Schema.Class<RateLimitWindow, Schema.Struct<{
74
- /** Percentage of the allowance already consumed, including usage outside this Attempt. */
128
+ /** The percentage of the allowance used, including usage outside this Attempt. */
75
129
  readonly usedPercent: Schema.Number;
76
- /** Length of the allowance window; absent when the provider omits it. */
77
130
  readonly windowDurationMinutes: Schema.OptionFromNullOr<Schema.Number>;
78
- /** When the allowance resets; absent when the provider omits it. */
79
131
  readonly resetsAt: Schema.OptionFromNullOr<Schema.DateTimeUtcFromString>;
80
132
  }>, {}>;
81
- /** A billing pool's observed usage for one allowance window. */
82
133
  export declare class RateLimitWindow extends RateLimitWindow_base {
83
134
  }
84
135
  declare const RateLimitsSnapshot_base: Schema.Class<RateLimitsSnapshot, Schema.Struct<{
@@ -87,7 +138,7 @@ declare const RateLimitsSnapshot_base: Schema.Class<RateLimitsSnapshot, Schema.S
87
138
  readonly primary: Schema.OptionFromNullOr<typeof RateLimitWindow>;
88
139
  readonly secondary: Schema.OptionFromNullOr<typeof RateLimitWindow>;
89
140
  }>, {}>;
90
- /** The allowance windows reported together by a provider; omitted windows remain unknown. */
141
+ /** The rate-limit windows from one provider report; a window is `None` if not reported. */
91
142
  export declare class RateLimitsSnapshot extends RateLimitsSnapshot_base {
92
143
  }
93
144
  declare const PoolRateLimitsUpdated_base: Schema.Class<PoolRateLimitsUpdated, Schema.TaggedStruct<"PoolRateLimitsUpdated", {
@@ -95,11 +146,34 @@ declare const PoolRateLimitsUpdated_base: Schema.Class<PoolRateLimitsUpdated, Sc
95
146
  readonly pool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
96
147
  readonly rateLimits: typeof RateLimitsSnapshot;
97
148
  }>, {}>;
98
- /** The latest rate windows observed for a billing pool during one session. */
149
+ /** The latest rate-limit windows observed for `pool` during the session. */
99
150
  export declare class PoolRateLimitsUpdated extends PoolRateLimitsUpdated_base {
100
151
  }
101
- /** Session activity and billing observations recorded in an Attempt's transcript. */
102
- export declare const AgentSessionEvent: Schema.Union<readonly [typeof SessionStarted, typeof TextOutput, typeof ToolStarted, typeof ToolFinished, typeof PoolRateLimitsUpdated, typeof SessionFinished]>;
152
+ /** The number of model provider retries in the current turn, starting at 1. */
153
+ export declare const ProviderRetries: Schema.brand<Schema.Int, "ProviderRetries">;
154
+ export type ProviderRetries = typeof ProviderRetries.Type;
155
+ declare const ProviderRetrying_base: Schema.Class<ProviderRetrying, Schema.TaggedStruct<"ProviderRetrying", {
156
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
157
+ /** The harness's failure message, verbatim if it provides one. */
158
+ readonly message: Schema.NonEmptyString;
159
+ /** The retries reported in the current turn, including this one. */
160
+ readonly retries: Schema.brand<Schema.Int, "ProviderRetries">;
161
+ }>, {}>;
162
+ /**
163
+ * A harness report of a failed model provider request that it retries, such as Codex's
164
+ * `Reconnecting...`. The session isn't stopped or failed (ADR 0013).
165
+ */
166
+ export declare class ProviderRetrying extends ProviderRetrying_base {
167
+ }
168
+ declare const ProviderRecovered_base: Schema.Class<ProviderRecovered, Schema.TaggedStruct<"ProviderRecovered", {
169
+ readonly session: Schema.Union<readonly [typeof ParentSession, typeof ChildSession]>;
170
+ /** The retries in the turn before the response. */
171
+ readonly retries: Schema.brand<Schema.Int, "ProviderRetries">;
172
+ }>, {}>;
173
+ /** A model provider response after a `ProviderRetrying` in the same turn. */
174
+ export declare class ProviderRecovered extends ProviderRecovered_base {
175
+ }
176
+ export declare const AgentSessionEvent: Schema.Union<readonly [typeof SessionStarted, typeof TextOutput, typeof ToolStarted, typeof ToolFinished, typeof PoolRateLimitsUpdated, typeof SessionFinished, typeof SessionIdle, typeof SessionResumed, typeof SessionTokensUpdated, typeof ProviderRetrying, typeof ProviderRecovered]>;
103
177
  export type AgentSessionEvent = typeof AgentSessionEvent.Type;
104
178
  export {};
105
179
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/agent/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,6EAA6E;AAC7E,eAAO,MAAM,cAAc,uDAA6D,CAAC;AACzF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAIxD,mGAAmG;AACnG,eAAO,MAAM,kBAAkB,gDAAuD,CAAC;AACvF,MAAM,MAAM,kBAAkB,GAAG,OAAO,kBAAkB,CAAC,IAAI,CAAC;AAEhE,2GAA2G;AAC3G,eAAO,MAAM,iBAAiB,+CAAsD,CAAC;AACrF,MAAM,MAAM,iBAAiB,GAAG,OAAO,iBAAiB,CAAC,IAAI,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