@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.
- package/README.md +43 -16
- package/dist/agent/agent.d.ts +12 -8
- package/dist/agent/agent.d.ts.map +1 -1
- package/dist/agent/agent.js +14 -10
- package/dist/agent/agent.js.map +1 -1
- package/dist/agent/brain.d.ts +2 -6
- package/dist/agent/brain.d.ts.map +1 -1
- package/dist/agent/brain.js +3 -7
- package/dist/agent/brain.js.map +1 -1
- package/dist/agent/capability.d.ts +4 -4
- package/dist/agent/capability.d.ts.map +1 -1
- package/dist/agent/capability.js +4 -4
- package/dist/agent/capability.js.map +1 -1
- package/dist/agent/session.d.ts +95 -21
- package/dist/agent/session.d.ts.map +1 -1
- package/dist/agent/session.js +100 -21
- package/dist/agent/session.js.map +1 -1
- package/dist/attempt/attempt.d.ts +63 -11
- package/dist/attempt/attempt.d.ts.map +1 -1
- package/dist/attempt/attempt.js +81 -11
- package/dist/attempt/attempt.js.map +1 -1
- package/dist/attempt/channel.d.ts +142 -44
- package/dist/attempt/channel.d.ts.map +1 -1
- package/dist/attempt/channel.js +124 -36
- package/dist/attempt/channel.js.map +1 -1
- package/dist/attempt/failure.d.ts +27 -14
- package/dist/attempt/failure.d.ts.map +1 -1
- package/dist/attempt/failure.js +27 -14
- package/dist/attempt/failure.js.map +1 -1
- package/dist/attempt/outcome.d.ts +3 -5
- package/dist/attempt/outcome.d.ts.map +1 -1
- package/dist/attempt/outcome.js +2 -4
- package/dist/attempt/outcome.js.map +1 -1
- package/dist/attempt/salvage.d.ts +50 -0
- package/dist/attempt/salvage.d.ts.map +1 -0
- package/dist/attempt/salvage.js +21 -0
- package/dist/attempt/salvage.js.map +1 -0
- package/dist/attempt/start.d.ts +35 -0
- package/dist/attempt/start.d.ts.map +1 -0
- package/dist/attempt/start.js +30 -0
- package/dist/attempt/start.js.map +1 -0
- package/dist/cycle-budget.d.ts +7 -8
- package/dist/cycle-budget.d.ts.map +1 -1
- package/dist/cycle-budget.js +9 -10
- package/dist/cycle-budget.js.map +1 -1
- package/dist/event.d.ts +4 -8
- package/dist/event.d.ts.map +1 -1
- package/dist/event.js +4 -8
- package/dist/event.js.map +1 -1
- package/dist/instance.d.ts +1 -1
- package/dist/instance.d.ts.map +1 -1
- package/dist/instance.js +1 -1
- package/dist/instance.js.map +1 -1
- package/dist/item.d.ts +1 -2
- package/dist/item.d.ts.map +1 -1
- package/dist/item.js +1 -2
- package/dist/item.js.map +1 -1
- package/dist/loop.d.ts +10 -2
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +9 -2
- package/dist/loop.js.map +1 -1
- package/dist/operator.d.ts +8 -0
- package/dist/operator.d.ts.map +1 -0
- package/dist/operator.js +9 -0
- package/dist/operator.js.map +1 -0
- package/dist/repository.d.ts +6 -8
- package/dist/repository.d.ts.map +1 -1
- package/dist/repository.js +8 -10
- package/dist/repository.js.map +1 -1
- package/dist/run/again.d.ts +13 -0
- package/dist/run/again.d.ts.map +1 -0
- package/dist/run/again.js +13 -0
- package/dist/run/again.js.map +1 -0
- package/dist/run/approval.d.ts +27 -0
- package/dist/run/approval.d.ts.map +1 -0
- package/dist/run/approval.js +26 -0
- package/dist/run/approval.js.map +1 -0
- package/dist/run/run.d.ts +2 -2
- package/dist/run/run.d.ts.map +1 -1
- package/dist/run/run.js +2 -2
- package/dist/run/run.js.map +1 -1
- package/dist/run/state.d.ts +22 -31
- package/dist/run/state.d.ts.map +1 -1
- package/dist/run/state.js +23 -36
- package/dist/run/state.js.map +1 -1
- package/dist/step/harvest.d.ts +44 -0
- package/dist/step/harvest.d.ts.map +1 -0
- package/dist/step/harvest.js +368 -0
- package/dist/step/harvest.js.map +1 -0
- package/dist/step/result.d.ts +15 -4
- package/dist/step/result.d.ts.map +1 -1
- package/dist/step/result.js +14 -4
- package/dist/step/result.js.map +1 -1
- package/dist/step/step.d.ts +2 -8
- package/dist/step/step.d.ts.map +1 -1
- package/dist/step/step.js +2 -8
- package/dist/step/step.js.map +1 -1
- package/dist/worker.d.ts +48 -4
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +47 -4
- package/dist/worker.js.map +1 -1
- 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)
|
|
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
|
-
|
|
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/
|
|
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/
|
|
16
|
-
| `@usine/core/
|
|
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`,
|
|
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
|
-
|
|
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
|
-
`
|
|
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
|
-
|
|
52
|
+
## Sessions and usage
|
|
26
53
|
|
|
27
|
-
`
|
|
54
|
+
Outbound `SessionEvent` envelopes keep parent and first-level child session identity.
|
|
28
55
|
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
`
|
|
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.
|
package/dist/agent/agent.d.ts
CHANGED
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { Schema, Option } from "effect";
|
|
2
2
|
import { BrainSpec, Effort, ModelId } from "./brain.ts";
|
|
3
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
16
|
+
/** The harness, model, and effort of the Agent's child sessions. */
|
|
12
17
|
readonly brain: typeof BrainSpec;
|
|
13
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAExD,
|
|
1
|
+
{"version":3,"file":"agent.d.ts","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,gEAAgE;AAChE,eAAO,MAAM,SAAS,0CAIW,CAAC;AAElC,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAE9C;;;GAGG;AACH,eAAO,MAAM,eAAe,UAAW,SAAS,KAAG,MAAmC,CAAC;AAEvF,kDAAkD;AAClD,eAAO,MAAM,YAAY,6CAEW,CAAC;AACrC,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;;;IAIlD,oEAAoE;;IAEpE,8EAA8E;;IAG9E,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"}
|
package/dist/agent/agent.js
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { Schema, Option } from "effect";
|
|
2
2
|
import { BrainSpec, Effort, ModelId } from "./brain.js";
|
|
3
|
-
/**
|
|
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
|
|
5
|
+
message: "Expected a kebab-case agent name",
|
|
6
6
|
})).pipe(Schema.brand("AgentName"));
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
/**
|
|
16
|
+
/** The harness, model, and effort of the Agent's child sessions. */
|
|
13
17
|
brain: BrainSpec,
|
|
14
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
package/dist/agent/agent.js.map
CHANGED
|
@@ -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,
|
|
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,gEAAgE;AAChE,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;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAgB,EAAU,EAAE,CAAC,kBAAkB,KAAK,EAAE,CAAC;AAEvF,kDAAkD;AAClD,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAC7C,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC,CAC3E,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;AAGrC,MAAM,OAAO,KAAM,SAAQ,MAAM,CAAC,KAAK,CAAQ,OAAO,CAAC,CAAC;IACtD,IAAI,EAAE,SAAS;IACf,oEAAoE;IACpE,KAAK,EAAE,SAAS;IAChB,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC;IAC7C,2EAA2E;IAC3E,sGAAsG;IACtG,YAAY,EAAE,MAAM,CAAC,qBAAqB,CAAC,MAAM,CAAC;IAClD,OAAO,EAAE,YAAY;CACtB,CAAC;CAAG;AAEL,+HAA+H;AAC/H,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,KAAY,EACZ,eAAuC,EACf,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC,CAAC;AAEtF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAY,EAAE,eAAsC,EAAU,EAAE,CAClG,MAAM,CAAC,SAAS,CACd,MAAM,CAAC,WAAW,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,EACzD,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CACzB,CAAC"}
|
package/dist/agent/brain.d.ts
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
/** A provider
|
|
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
|
-
/**
|
|
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
|
|
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"}
|
package/dist/agent/brain.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
/** A provider
|
|
3
|
-
export const ModelId = Schema.String.check(Schema.isPattern(/\S/u, { message: "Expected a non-blank model
|
|
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
|
-
/**
|
|
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,
|
package/dist/agent/brain.js.map
CHANGED
|
@@ -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
|
|
1
|
+
{"version":3,"file":"brain.js","sourceRoot":"","sources":["../../src/agent/brain.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,+EAA+E;AAC/E,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,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAU,CAAC;AAC5D,MAAM,CAAC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AAGlD,sEAAsE;AACtE,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAU,CAAC;AAC5F,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AAG/C,MAAM,OAAO,SAAU,SAAQ,MAAM,CAAC,KAAK,CAAY,iBAAiB,CAAC,CAAC;IACxE,OAAO,EAAE,OAAO;IAChB,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
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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"}
|
package/dist/agent/capability.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
import { Harness } from "./brain.js";
|
|
3
|
-
/** A harness prerequisite that
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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"}
|
package/dist/agent/session.d.ts
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
-
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
149
|
+
/** The latest rate-limit windows observed for `pool` during the session. */
|
|
99
150
|
export declare class PoolRateLimitsUpdated extends PoolRateLimitsUpdated_base {
|
|
100
151
|
}
|
|
101
|
-
/**
|
|
102
|
-
export declare const
|
|
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;
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/agent/session.ts"],"names":[],"mappings":"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"}
|