@usine/agents 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 +93 -29
- package/dist/child-host/child-host.d.ts +60 -0
- package/dist/child-host/child-host.d.ts.map +1 -0
- package/dist/child-host/child-host.js +84 -0
- package/dist/child-host/child-host.js.map +1 -0
- package/dist/child-host/command.d.ts +11 -0
- package/dist/child-host/command.d.ts.map +1 -0
- package/dist/child-host/command.js +26 -0
- package/dist/child-host/command.js.map +1 -0
- package/dist/pi/authentication.d.ts +11 -2
- package/dist/pi/authentication.d.ts.map +1 -1
- package/dist/pi/authentication.js +15 -2
- package/dist/pi/authentication.js.map +1 -1
- package/dist/pi/children.d.ts +1 -4
- package/dist/pi/children.d.ts.map +1 -1
- package/dist/pi/children.js +1 -4
- package/dist/pi/children.js.map +1 -1
- package/dist/pi/claude.d.ts +8 -9
- package/dist/pi/claude.d.ts.map +1 -1
- package/dist/pi/claude.js +413 -39
- package/dist/pi/claude.js.map +1 -1
- package/dist/pi/codex/account.d.ts +3 -3
- package/dist/pi/codex/account.d.ts.map +1 -1
- package/dist/pi/codex/account.js +5 -5
- package/dist/pi/codex/account.js.map +1 -1
- package/dist/pi/codex/app-server.d.ts +19 -7
- package/dist/pi/codex/app-server.d.ts.map +1 -1
- package/dist/pi/codex/app-server.js +41 -36
- package/dist/pi/codex/app-server.js.map +1 -1
- package/dist/pi/codex/codec.d.ts +118 -0
- package/dist/pi/codex/codec.d.ts.map +1 -0
- package/dist/pi/codex/codec.js +137 -0
- package/dist/pi/codex/codec.js.map +1 -0
- package/dist/pi/codex/codex.d.ts +0 -1
- package/dist/pi/codex/codex.d.ts.map +1 -1
- package/dist/pi/codex/codex.js +169 -133
- package/dist/pi/codex/codex.js.map +1 -1
- package/dist/pi/conversation.d.ts +43 -0
- package/dist/pi/conversation.d.ts.map +1 -0
- package/dist/pi/conversation.js +129 -0
- package/dist/pi/conversation.js.map +1 -0
- package/dist/pi/pi.d.ts +1 -4
- package/dist/pi/pi.d.ts.map +1 -1
- package/dist/pi/pi.js +38 -201
- package/dist/pi/pi.js.map +1 -1
- package/dist/pi/sdk.d.ts +11 -15
- package/dist/pi/sdk.d.ts.map +1 -1
- package/dist/pi/sdk.js +35 -53
- package/dist/pi/sdk.js.map +1 -1
- package/dist/pi/session.d.ts +13 -14
- package/dist/pi/session.d.ts.map +1 -1
- package/dist/pi/session.js +68 -16
- package/dist/pi/session.js.map +1 -1
- package/dist/pi/turns.d.ts +28 -0
- package/dist/pi/turns.d.ts.map +1 -0
- package/dist/pi/turns.js +67 -0
- package/dist/pi/turns.js.map +1 -0
- package/dist/pi/usage.d.ts +39 -0
- package/dist/pi/usage.d.ts.map +1 -0
- package/dist/pi/usage.js +96 -0
- package/dist/pi/usage.js.map +1 -0
- package/dist/preflight/command.d.ts +16 -3
- package/dist/preflight/command.d.ts.map +1 -1
- package/dist/preflight/command.js +30 -17
- package/dist/preflight/command.js.map +1 -1
- package/dist/preflight/preflight.d.ts +10 -5
- package/dist/preflight/preflight.d.ts.map +1 -1
- package/dist/preflight/preflight.js +52 -25
- package/dist/preflight/preflight.js.map +1 -1
- package/dist/prompt.d.ts +12 -9
- package/dist/prompt.d.ts.map +1 -1
- package/dist/prompt.js +33 -4
- package/dist/prompt.js.map +1 -1
- package/dist/protocol/codex.d.ts +4 -7
- package/dist/protocol/codex.d.ts.map +1 -1
- package/dist/protocol/codex.js +1 -1
- package/dist/protocol/codex.js.map +1 -1
- package/dist/runtime.d.ts +101 -40
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +108 -27
- package/dist/runtime.js.map +1 -1
- package/package.json +22 -10
- package/dist/pi/live.d.ts +0 -4
- package/dist/pi/live.d.ts.map +0 -1
- package/dist/pi/live.js +0 -11
- package/dist/pi/live.js.map +0 -1
- package/dist/pi/subagents.d.ts +0 -27
- package/dist/pi/subagents.d.ts.map +0 -1
- package/dist/pi/subagents.js +0 -113
- package/dist/pi/subagents.js.map +0 -1
- package/dist/pi/thinking.d.ts +0 -8
- package/dist/pi/thinking.d.ts.map +0 -1
- package/dist/pi/thinking.js +0 -15
- package/dist/pi/thinking.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/protocol/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"codex.js","sourceRoot":"","sources":["../../src/protocol/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AA+DhC,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC9D,kBAAkB,EAAE,MAAM,CAAC,OAAO;CACnC,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import { AgentSession, AgentSessionEvent, ChildSession } from "@usine/core/agent/session";
|
|
1
|
+
import { AgentSession, AgentSessionEvent, AgentSessionId, ChildSession } from "@usine/core/agent/session";
|
|
2
2
|
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
3
|
+
import { WorkerName } from "@usine/core/worker";
|
|
3
4
|
import { AttemptFailure } from "@usine/core/attempt/failure";
|
|
4
|
-
import { Context, Effect, Schema, Scope, Stream } from "effect";
|
|
5
|
-
/** The checkout directory
|
|
5
|
+
import { Context, Effect, Option, Schema, Scope, Stream } from "effect";
|
|
6
|
+
/** The checkout directory of an Attempt. */
|
|
6
7
|
export declare const WorkingDirectory: Schema.brand<Schema.NonEmptyString, "AgentWorkingDirectory">;
|
|
7
8
|
export type WorkingDirectory = typeof WorkingDirectory.Type;
|
|
8
|
-
declare const LaunchRequest_base: Schema.Class<LaunchRequest, Schema.Struct<{
|
|
9
|
-
readonly spec: typeof AttemptChannel.RunSpec;
|
|
10
|
-
readonly cwd: Schema.brand<Schema.NonEmptyString, "AgentWorkingDirectory">;
|
|
11
|
-
}>, {}>;
|
|
12
|
-
/** The Attempt's task and Agent choices, together with the prepared checkout where its parent starts. */
|
|
13
|
-
export declare class LaunchRequest extends LaunchRequest_base {
|
|
14
|
-
}
|
|
15
9
|
declare const ChildRequest_base: Schema.Class<ChildRequest, Schema.Struct<{
|
|
16
10
|
readonly session: typeof ChildSession;
|
|
11
|
+
/** The checkout directory on `host`. */
|
|
17
12
|
readonly cwd: Schema.brand<Schema.NonEmptyString, "AgentWorkingDirectory">;
|
|
18
13
|
readonly prompt: Schema.NonEmptyString;
|
|
14
|
+
/**
|
|
15
|
+
* The complete environment of the child process and its commands: the Worker's allowlisted
|
|
16
|
+
* variables plus the Attempt's credential configuration, with nothing inherited from the launching
|
|
17
|
+
* process (ADR 0011). On a `RemoteShell` host, the variables are exported on top of the remote
|
|
18
|
+
* environment, which contains no orchestrator secret.
|
|
19
|
+
*/
|
|
20
|
+
readonly environment: Schema.$Record<Schema.String, Schema.String>;
|
|
21
|
+
readonly host: Schema.Union<readonly [typeof import("./child-host/child-host.ts").LocalProcess, typeof import("./child-host/child-host.ts").RemoteShell]>;
|
|
22
|
+
/** The Worker that `host` runs on; Claude children on one Worker share its Claude login. */
|
|
23
|
+
readonly worker: Schema.brand<Schema.String, "WorkerName">;
|
|
19
24
|
}>, {}>;
|
|
20
|
-
/**
|
|
25
|
+
/** A task delegated to one child, with its session and the checkout it shares with the parent. */
|
|
21
26
|
export declare class ChildRequest extends ChildRequest_base {
|
|
22
27
|
}
|
|
23
28
|
declare const SessionResult_base: Schema.Class<SessionResult, Schema.Struct<{
|
|
@@ -31,7 +36,7 @@ declare const UnknownModelError_base: Schema.Class<UnknownModelError, Schema.Tag
|
|
|
31
36
|
readonly model: Schema.brand<Schema.String, "ModelId">;
|
|
32
37
|
readonly message: Schema.NonEmptyString;
|
|
33
38
|
}>, import("effect/Cause").YieldableError>;
|
|
34
|
-
/**
|
|
39
|
+
/** An error for a well-formed rostered model ID that the SDK's registry does not list. */
|
|
35
40
|
export declare class UnknownModelError extends UnknownModelError_base {
|
|
36
41
|
}
|
|
37
42
|
declare const PoolUnavailableError_base: Schema.Class<PoolUnavailableError, Schema.TaggedStruct<"PoolUnavailableError", {
|
|
@@ -40,7 +45,7 @@ declare const PoolUnavailableError_base: Schema.Class<PoolUnavailableError, Sche
|
|
|
40
45
|
readonly pool: Schema.Literals<readonly ["apiKeys", "claudePlan", "chatgptPlan"]>;
|
|
41
46
|
readonly message: Schema.NonEmptyString;
|
|
42
47
|
}>, import("effect/Cause").YieldableError>;
|
|
43
|
-
/**
|
|
48
|
+
/** An error for a credential that cannot use the billing pool the session needs. */
|
|
44
49
|
export declare class PoolUnavailableError extends PoolUnavailableError_base {
|
|
45
50
|
}
|
|
46
51
|
declare const UnsupportedEffortError_base: Schema.Class<UnsupportedEffortError, Schema.TaggedStruct<"UnsupportedEffortError", {
|
|
@@ -49,22 +54,52 @@ declare const UnsupportedEffortError_base: Schema.Class<UnsupportedEffortError,
|
|
|
49
54
|
readonly effort: Schema.Literals<readonly ["off", "minimal", "low", "medium", "high", "xhigh", "max"]>;
|
|
50
55
|
readonly message: Schema.NonEmptyString;
|
|
51
56
|
}>, import("effect/Cause").YieldableError>;
|
|
52
|
-
/**
|
|
57
|
+
/** An error for a model that does not support the rostered reasoning effort. */
|
|
53
58
|
export declare class UnsupportedEffortError extends UnsupportedEffortError_base {
|
|
54
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* The reserved prefix of a final answer that reports an unresolved blocker. The session fails with
|
|
62
|
+
* `AgentBlockedError`, whose message is the text after the marker.
|
|
63
|
+
*/
|
|
64
|
+
export declare const BLOCKED_MARKER = "[usine:blocked]";
|
|
65
|
+
/**
|
|
66
|
+
* The reserved prefix of a final answer that asks the operator for a decision. The session fails
|
|
67
|
+
* with `AgentQuestionError`, whose message is the text after the marker.
|
|
68
|
+
*/
|
|
69
|
+
export declare const QUESTION_MARKER = "[usine:question]";
|
|
70
|
+
/**
|
|
71
|
+
* The reserved prefix of a report that relays a harness failure, such as a child's failed Codex
|
|
72
|
+
* turn, to the parent. The session fails with `AgentResultError`, which ends the Attempt with
|
|
73
|
+
* `AgentFailure`.
|
|
74
|
+
*/
|
|
75
|
+
export declare const FAILED_MARKER = "[usine:failed]";
|
|
55
76
|
declare const AgentResultError_base: Schema.Class<AgentResultError, Schema.TaggedStruct<"AgentResultError", {
|
|
56
77
|
readonly sessionId: Schema.OptionFromNullOr<Schema.brand<Schema.NonEmptyString, "AgentSessionId">>;
|
|
57
78
|
readonly message: Schema.NonEmptyString;
|
|
58
79
|
}>, import("effect/Cause").YieldableError>;
|
|
59
|
-
/**
|
|
80
|
+
/** An error for a session that finished and reported that the work failed. */
|
|
60
81
|
export declare class AgentResultError extends AgentResultError_base {
|
|
61
82
|
}
|
|
83
|
+
declare const AgentBlockedError_base: Schema.Class<AgentBlockedError, Schema.TaggedStruct<"AgentBlockedError", {
|
|
84
|
+
readonly sessionId: Schema.OptionFromNullOr<Schema.brand<Schema.NonEmptyString, "AgentSessionId">>;
|
|
85
|
+
readonly message: Schema.NonEmptyString;
|
|
86
|
+
}>, import("effect/Cause").YieldableError>;
|
|
87
|
+
/** An error for a session that finished with the blocker marker; `message` is the blocker text. */
|
|
88
|
+
export declare class AgentBlockedError extends AgentBlockedError_base {
|
|
89
|
+
}
|
|
90
|
+
declare const AgentQuestionError_base: Schema.Class<AgentQuestionError, Schema.TaggedStruct<"AgentQuestionError", {
|
|
91
|
+
readonly sessionId: Schema.OptionFromNullOr<Schema.brand<Schema.NonEmptyString, "AgentSessionId">>;
|
|
92
|
+
readonly message: Schema.NonEmptyString;
|
|
93
|
+
}>, import("effect/Cause").YieldableError>;
|
|
94
|
+
/** An error for a session that finished with a question for the operator; `message` is the question. */
|
|
95
|
+
export declare class AgentQuestionError extends AgentQuestionError_base {
|
|
96
|
+
}
|
|
62
97
|
declare const ChildSessionBudgetExceededError_base: Schema.Class<ChildSessionBudgetExceededError, Schema.TaggedStruct<"ChildSessionBudgetExceededError", {
|
|
63
98
|
readonly maxChildren: Schema.brand<Schema.Int, "ChildSessionBudget">;
|
|
64
99
|
readonly attemptedChildren: Schema.brand<Schema.Int, "ChildSessionCount">;
|
|
65
100
|
readonly message: Schema.NonEmptyString;
|
|
66
101
|
}>, import("effect/Cause").YieldableError>;
|
|
67
|
-
/**
|
|
102
|
+
/** An error for a Pi parent that requested more children than the Attempt's budget allows. */
|
|
68
103
|
export declare class ChildSessionBudgetExceededError extends ChildSessionBudgetExceededError_base {
|
|
69
104
|
}
|
|
70
105
|
export declare const SESSION_OPERATIONS: readonly ["launch", "stream", "steer", "interrupt"];
|
|
@@ -76,57 +111,83 @@ declare const SessionOperationError_base: Schema.Class<SessionOperationError, Sc
|
|
|
76
111
|
readonly message: Schema.NonEmptyString;
|
|
77
112
|
readonly cause: Schema.Defect;
|
|
78
113
|
}>, import("effect/Cause").YieldableError>;
|
|
79
|
-
/**
|
|
114
|
+
/** An error for an SDK or process failure after the model and harness were validated. */
|
|
80
115
|
export declare class SessionOperationError extends SessionOperationError_base {
|
|
81
116
|
}
|
|
82
|
-
/**
|
|
83
|
-
export declare const AgentSessionError: Schema.Union<readonly [typeof UnknownModelError, typeof PoolUnavailableError, typeof UnsupportedEffortError, typeof AgentResultError, typeof ChildSessionBudgetExceededError, typeof SessionOperationError]>;
|
|
117
|
+
/** Any error that stops a session from starting, continuing, or finishing; the error type determines whether a retry needs the operator. */
|
|
118
|
+
export declare const AgentSessionError: Schema.Union<readonly [typeof UnknownModelError, typeof PoolUnavailableError, typeof UnsupportedEffortError, typeof AgentResultError, typeof AgentBlockedError, typeof AgentQuestionError, typeof ChildSessionBudgetExceededError, typeof SessionOperationError]>;
|
|
84
119
|
export type AgentSessionError = typeof AgentSessionError.Type;
|
|
85
120
|
/**
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
|
|
121
|
+
* A report that a session ends with: a blocker or question marked in its final answer, or a failure
|
|
122
|
+
* reported by its harness. A child relays each report to the parent with the same marker.
|
|
123
|
+
*/
|
|
124
|
+
export type AgentReport = AgentResultError | AgentBlockedError | AgentQuestionError;
|
|
125
|
+
/**
|
|
126
|
+
* Returns the report of a final answer that starts with `[usine:blocked]`, `[usine:question]`, or
|
|
127
|
+
* `[usine:failed]`; the details can follow on the same line or the next. Returns `None` if the answer
|
|
128
|
+
* does not start with a marker.
|
|
129
|
+
*/
|
|
130
|
+
export declare const reportedOutcome: (sessionId: Option.Option<AgentSessionId>, answer: string) => Option.Option<AgentReport>;
|
|
131
|
+
/** Returns the final answer that relays `report`, starting with its marker. */
|
|
132
|
+
export declare const reportText: (report: AgentReport) => string;
|
|
133
|
+
/**
|
|
134
|
+
* Maps a session error to an Attempt failure: SDK and process failures are retryable infrastructure
|
|
135
|
+
* failures; roster errors and Agent-reported failures wait for the operator (ADR 0002).
|
|
89
136
|
*/
|
|
90
137
|
export declare const toAttemptFailure: (error: AgentSessionError) => AttemptFailure;
|
|
91
|
-
/** A
|
|
138
|
+
/** A running parent or child session. */
|
|
92
139
|
export interface RunningSession {
|
|
93
140
|
readonly session: AgentSession;
|
|
94
|
-
/**
|
|
141
|
+
/** The session activity to record in the Attempt transcript. */
|
|
95
142
|
readonly events: Stream.Stream<AgentSessionEvent, AgentSessionError>;
|
|
96
|
-
/** Waits for the final message or the
|
|
143
|
+
/** Waits for the session's final message, or fails with the error that ended it. */
|
|
97
144
|
readonly result: Effect.Effect<SessionResult, AgentSessionError>;
|
|
98
145
|
/** Adds operator guidance to the running session without creating a new Attempt. */
|
|
99
146
|
readonly steer: (message: string) => Effect.Effect<void, AgentSessionError>;
|
|
100
|
-
/** Requests that
|
|
147
|
+
/** Requests that the session stop its current work. */
|
|
101
148
|
readonly interrupt: Effect.Effect<void, AgentSessionError>;
|
|
102
|
-
|
|
103
|
-
|
|
149
|
+
/**
|
|
150
|
+
* Applies a nonterminal operator action; after a child message, the session does not complete
|
|
151
|
+
* until release. If the harness reads the message only at its next boundary, returns `queued` and
|
|
152
|
+
* calls `onDelivery` once: with the session state when it is read, or `None` if the session stops
|
|
153
|
+
* first.
|
|
154
|
+
*/
|
|
155
|
+
readonly intervene: (action: AttemptChannel.OperatorAction, onDelivery: OnDelivery) => Effect.Effect<AttemptChannel.InterventionState, AgentSessionError>;
|
|
156
|
+
}
|
|
157
|
+
/** A callback, called once for a queued operator message with the session state when it was read, or `None` if the session stopped first. */
|
|
158
|
+
export type OnDelivery = (delivered: Option.Option<AttemptChannel.InterventionState>) => Effect.Effect<void>;
|
|
159
|
+
/** A backend that launches child sessions for tasks delegated by an Attempt's parent. */
|
|
104
160
|
export interface ChildBackendService {
|
|
105
|
-
/** Starts the
|
|
161
|
+
/** Starts the child and returns its controls; `result` is awaited separately. */
|
|
106
162
|
readonly launch: (request: ChildRequest) => Effect.Effect<RunningSession, AgentSessionError, Scope.Scope>;
|
|
107
163
|
}
|
|
108
164
|
declare const ChildBackend_base: Context.ServiceClass<ChildBackend, "@usine/agents/ChildBackend", ChildBackendService>;
|
|
109
|
-
/**
|
|
165
|
+
/** The service that runs tasks delegated by an Attempt's parent. */
|
|
110
166
|
export declare class ChildBackend extends ChildBackend_base {
|
|
111
167
|
}
|
|
168
|
+
declare const ClaudeLoginLock_base: Context.ServiceClass<ClaudeLoginLock, "@usine/agents/ClaudeLoginLock", {
|
|
169
|
+
/** Runs `effect` with `worker`'s lock, after waiting for any other effect that has the lock. */
|
|
170
|
+
readonly withLock: (worker: WorkerName) => <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
|
|
171
|
+
}>;
|
|
172
|
+
/**
|
|
173
|
+
* A per-Worker lock for Claude commands that can refresh the Worker's shared Claude login: the
|
|
174
|
+
* preflight login check and the start of a Claude child. Claude Code ends a process that finds
|
|
175
|
+
* another process refreshing the login (#453). Provide one instance to both the executor and the
|
|
176
|
+
* Attempt runtime.
|
|
177
|
+
*/
|
|
178
|
+
export declare class ClaudeLoginLock extends ClaudeLoginLock_base {
|
|
179
|
+
}
|
|
112
180
|
declare const ClaudeChildBackend_base: Context.ServiceClass<ClaudeChildBackend, "@usine/agents/ClaudeChildBackend", ChildBackendService>;
|
|
113
|
-
/**
|
|
181
|
+
/** The child backend for Claude Code. */
|
|
114
182
|
export declare class ClaudeChildBackend extends ClaudeChildBackend_base {
|
|
115
183
|
}
|
|
116
184
|
declare const CodexChildBackend_base: Context.ServiceClass<CodexChildBackend, "@usine/agents/CodexChildBackend", ChildBackendService>;
|
|
117
|
-
/**
|
|
185
|
+
/** The child backend for Codex. */
|
|
118
186
|
export declare class CodexChildBackend extends CodexChildBackend_base {
|
|
119
187
|
}
|
|
120
188
|
declare const PiChildBackend_base: Context.ServiceClass<PiChildBackend, "@usine/agents/PiChildBackend", ChildBackendService>;
|
|
121
|
-
/**
|
|
189
|
+
/** The child backend for Pi. */
|
|
122
190
|
export declare class PiChildBackend extends PiChildBackend_base {
|
|
123
191
|
}
|
|
124
|
-
declare const AgentRuntime_base: Context.ServiceClass<AgentRuntime, "@usine/agents/AgentRuntime", {
|
|
125
|
-
/** Starts work in the prepared checkout and returns controls for observing and guiding the parent. */
|
|
126
|
-
readonly launch: (request: LaunchRequest) => Effect.Effect<RunningSession, AgentSessionError, Scope.Scope>;
|
|
127
|
-
}>;
|
|
128
|
-
/** Starts the parent that coordinates one Attempt's task and delegates coding work to children. */
|
|
129
|
-
export declare class AgentRuntime extends AgentRuntime_base {
|
|
130
|
-
}
|
|
131
192
|
export {};
|
|
132
193
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EAEd,YAAY,EAGb,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAEL,cAAc,EAKf,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAS,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG/E,4CAA4C;AAC5C,eAAO,MAAM,gBAAgB,8DAAoE,CAAC;AAClG,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;;;IAK1D,wCAAwC;;;IAGxC;;;;;OAKG;;;IAGH,4FAA4F;;;AAd9F,kGAAkG;AAClG,qBAAa,YAAa,SAAQ,iBAehC;CAAG;;;;AAEL,2DAA2D;AAC3D,qBAAa,aAAc,SAAQ,kBAEjC;CAAG;;;;;;AAEL,0FAA0F;AAC1F,qBAAa,iBAAkB,SAAQ,sBAMrC;CAAG;;;;;;;AAEL,oFAAoF;AACpF,qBAAa,oBAAqB,SAAQ,yBAOxC;CAAG;;;;;;;AAEL,gFAAgF;AAChF,qBAAa,sBAAuB,SAAQ,2BAO1C;CAAG;AAEL;;;GAGG;AACH,eAAO,MAAM,cAAc,oBAAoB,CAAC;AAEhD;;;GAGG;AACH,eAAO,MAAM,eAAe,qBAAqB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,aAAa,mBAAmB,CAAC;;;;;AAE9C,8EAA8E;AAC9E,qBAAa,gBA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;AAEJ,mCAAmC;AACnC,qBAAa,iBAAkB,SAAQ,sBAEtC;CAAG;;AAEJ,gCAAgC;AAChC,qBAAa,cAAe,SAAQ,mBAEnC;CAAG"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,21 +1,28 @@
|
|
|
1
1
|
import { Effort, Harness, ModelId } from "@usine/core/agent/brain";
|
|
2
2
|
import { AgentSession, AgentSessionEvent, AgentSessionId, BillingPool, ChildSession, ChildSessionBudget, ChildSessionCount, } from "@usine/core/agent/session";
|
|
3
3
|
import * as AttemptChannel from "@usine/core/attempt/channel";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { WorkerName } from "@usine/core/worker";
|
|
5
|
+
import { AgentFailure, AttemptFailure, BlockedFailure, ChildSessionBudgetFailure, InfraFailure, QuestionFailure, } from "@usine/core/attempt/failure";
|
|
6
|
+
import { Context, Effect, Match, Option, Schema, Scope, Stream } from "effect";
|
|
7
|
+
import { ChildHost } from "./child-host/child-host.js";
|
|
8
|
+
/** The checkout directory of an Attempt. */
|
|
7
9
|
export const WorkingDirectory = Schema.NonEmptyString.pipe(Schema.brand("AgentWorkingDirectory"));
|
|
8
|
-
/**
|
|
9
|
-
export class LaunchRequest extends Schema.Class("@usine/agents/LaunchRequest")({
|
|
10
|
-
spec: AttemptChannel.RunSpec,
|
|
11
|
-
cwd: WorkingDirectory,
|
|
12
|
-
}) {
|
|
13
|
-
}
|
|
14
|
-
/** Work delegated to one child, with its assigned identity and the checkout it shares with the parent. */
|
|
10
|
+
/** A task delegated to one child, with its session and the checkout it shares with the parent. */
|
|
15
11
|
export class ChildRequest extends Schema.Class("@usine/agents/ChildRequest")({
|
|
16
12
|
session: ChildSession,
|
|
13
|
+
/** The checkout directory on `host`. */
|
|
17
14
|
cwd: WorkingDirectory,
|
|
18
15
|
prompt: Schema.NonEmptyString,
|
|
16
|
+
/**
|
|
17
|
+
* The complete environment of the child process and its commands: the Worker's allowlisted
|
|
18
|
+
* variables plus the Attempt's credential configuration, with nothing inherited from the launching
|
|
19
|
+
* process (ADR 0011). On a `RemoteShell` host, the variables are exported on top of the remote
|
|
20
|
+
* environment, which contains no orchestrator secret.
|
|
21
|
+
*/
|
|
22
|
+
environment: Schema.Record(Schema.String, Schema.String),
|
|
23
|
+
host: ChildHost,
|
|
24
|
+
/** The Worker that `host` runs on; Claude children on one Worker share its Claude login. */
|
|
25
|
+
worker: WorkerName,
|
|
19
26
|
}) {
|
|
20
27
|
}
|
|
21
28
|
/** The final message a parent or child session returns. */
|
|
@@ -23,14 +30,14 @@ export class SessionResult extends Schema.Class("@usine/agents/SessionResult")({
|
|
|
23
30
|
message: Schema.NonEmptyString,
|
|
24
31
|
}) {
|
|
25
32
|
}
|
|
26
|
-
/**
|
|
33
|
+
/** An error for a well-formed rostered model ID that the SDK's registry does not list. */
|
|
27
34
|
export class UnknownModelError extends Schema.TaggedError("@usine/agents/UnknownModelError")("UnknownModelError", {
|
|
28
35
|
harness: Harness,
|
|
29
36
|
model: ModelId,
|
|
30
37
|
message: Schema.NonEmptyString,
|
|
31
38
|
}) {
|
|
32
39
|
}
|
|
33
|
-
/**
|
|
40
|
+
/** An error for a credential that cannot use the billing pool the session needs. */
|
|
34
41
|
export class PoolUnavailableError extends Schema.TaggedError("@usine/agents/PoolUnavailableError")("PoolUnavailableError", {
|
|
35
42
|
harness: Harness,
|
|
36
43
|
model: ModelId,
|
|
@@ -38,7 +45,7 @@ export class PoolUnavailableError extends Schema.TaggedError("@usine/agents/Pool
|
|
|
38
45
|
message: Schema.NonEmptyString,
|
|
39
46
|
}) {
|
|
40
47
|
}
|
|
41
|
-
/**
|
|
48
|
+
/** An error for a model that does not support the rostered reasoning effort. */
|
|
42
49
|
export class UnsupportedEffortError extends Schema.TaggedError("@usine/agents/UnsupportedEffortError")("UnsupportedEffortError", {
|
|
43
50
|
harness: Harness,
|
|
44
51
|
model: ModelId,
|
|
@@ -46,13 +53,41 @@ export class UnsupportedEffortError extends Schema.TaggedError("@usine/agents/Un
|
|
|
46
53
|
message: Schema.NonEmptyString,
|
|
47
54
|
}) {
|
|
48
55
|
}
|
|
49
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* The reserved prefix of a final answer that reports an unresolved blocker. The session fails with
|
|
58
|
+
* `AgentBlockedError`, whose message is the text after the marker.
|
|
59
|
+
*/
|
|
60
|
+
export const BLOCKED_MARKER = "[usine:blocked]";
|
|
61
|
+
/**
|
|
62
|
+
* The reserved prefix of a final answer that asks the operator for a decision. The session fails
|
|
63
|
+
* with `AgentQuestionError`, whose message is the text after the marker.
|
|
64
|
+
*/
|
|
65
|
+
export const QUESTION_MARKER = "[usine:question]";
|
|
66
|
+
/**
|
|
67
|
+
* The reserved prefix of a report that relays a harness failure, such as a child's failed Codex
|
|
68
|
+
* turn, to the parent. The session fails with `AgentResultError`, which ends the Attempt with
|
|
69
|
+
* `AgentFailure`.
|
|
70
|
+
*/
|
|
71
|
+
export const FAILED_MARKER = "[usine:failed]";
|
|
72
|
+
/** An error for a session that finished and reported that the work failed. */
|
|
50
73
|
export class AgentResultError extends Schema.TaggedError("@usine/agents/AgentResultError")("AgentResultError", {
|
|
51
74
|
sessionId: Schema.OptionFromNullOr(AgentSessionId),
|
|
52
75
|
message: Schema.NonEmptyString,
|
|
53
76
|
}) {
|
|
54
77
|
}
|
|
55
|
-
/**
|
|
78
|
+
/** An error for a session that finished with the blocker marker; `message` is the blocker text. */
|
|
79
|
+
export class AgentBlockedError extends Schema.TaggedError("@usine/agents/AgentBlockedError")("AgentBlockedError", {
|
|
80
|
+
sessionId: Schema.OptionFromNullOr(AgentSessionId),
|
|
81
|
+
message: Schema.NonEmptyString,
|
|
82
|
+
}) {
|
|
83
|
+
}
|
|
84
|
+
/** An error for a session that finished with a question for the operator; `message` is the question. */
|
|
85
|
+
export class AgentQuestionError extends Schema.TaggedError("@usine/agents/AgentQuestionError")("AgentQuestionError", {
|
|
86
|
+
sessionId: Schema.OptionFromNullOr(AgentSessionId),
|
|
87
|
+
message: Schema.NonEmptyString,
|
|
88
|
+
}) {
|
|
89
|
+
}
|
|
90
|
+
/** An error for a Pi parent that requested more children than the Attempt's budget allows. */
|
|
56
91
|
export class ChildSessionBudgetExceededError extends Schema.TaggedError("@usine/agents/ChildSessionBudgetExceededError")("ChildSessionBudgetExceededError", {
|
|
57
92
|
maxChildren: ChildSessionBudget,
|
|
58
93
|
attemptedChildren: ChildSessionCount,
|
|
@@ -61,7 +96,7 @@ export class ChildSessionBudgetExceededError extends Schema.TaggedError("@usine/
|
|
|
61
96
|
}
|
|
62
97
|
export const SESSION_OPERATIONS = ["launch", "stream", "steer", "interrupt"];
|
|
63
98
|
export const SessionOperation = Schema.Literals(SESSION_OPERATIONS);
|
|
64
|
-
/**
|
|
99
|
+
/** An error for an SDK or process failure after the model and harness were validated. */
|
|
65
100
|
export class SessionOperationError extends Schema.TaggedError("@usine/agents/SessionOperationError")("SessionOperationError", {
|
|
66
101
|
operation: SessionOperation,
|
|
67
102
|
sessionId: Schema.OptionFromNullOr(AgentSessionId),
|
|
@@ -69,19 +104,58 @@ export class SessionOperationError extends Schema.TaggedError("@usine/agents/Ses
|
|
|
69
104
|
cause: Schema.Defect(),
|
|
70
105
|
}) {
|
|
71
106
|
}
|
|
72
|
-
/**
|
|
107
|
+
/** Any error that stops a session from starting, continuing, or finishing; the error type determines whether a retry needs the operator. */
|
|
73
108
|
export const AgentSessionError = Schema.Union([
|
|
74
109
|
UnknownModelError,
|
|
75
110
|
PoolUnavailableError,
|
|
76
111
|
UnsupportedEffortError,
|
|
77
112
|
AgentResultError,
|
|
113
|
+
AgentBlockedError,
|
|
114
|
+
AgentQuestionError,
|
|
78
115
|
ChildSessionBudgetExceededError,
|
|
79
116
|
SessionOperationError,
|
|
80
117
|
]);
|
|
81
118
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
119
|
+
* Returns the report of a final answer that starts with `[usine:blocked]`, `[usine:question]`, or
|
|
120
|
+
* `[usine:failed]`; the details can follow on the same line or the next. Returns `None` if the answer
|
|
121
|
+
* does not start with a marker.
|
|
122
|
+
*/
|
|
123
|
+
export const reportedOutcome = (sessionId, answer) => {
|
|
124
|
+
const trimmed = answer.trim();
|
|
125
|
+
if (trimmed.startsWith(QUESTION_MARKER)) {
|
|
126
|
+
return Option.some(new AgentQuestionError({
|
|
127
|
+
sessionId,
|
|
128
|
+
message: trimmed.slice(QUESTION_MARKER.length).trim() ||
|
|
129
|
+
"Agent asked the operator a question without writing it.",
|
|
130
|
+
}));
|
|
131
|
+
}
|
|
132
|
+
if (trimmed.startsWith(BLOCKED_MARKER)) {
|
|
133
|
+
return Option.some(new AgentBlockedError({
|
|
134
|
+
sessionId,
|
|
135
|
+
message: trimmed.slice(BLOCKED_MARKER.length).trim() ||
|
|
136
|
+
"Agent reported an unresolved blocker without details.",
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
if (trimmed.startsWith(FAILED_MARKER)) {
|
|
140
|
+
return Option.some(new AgentResultError({
|
|
141
|
+
sessionId,
|
|
142
|
+
message: trimmed.slice(FAILED_MARKER.length).trim() || "Agent reported a failure without details.",
|
|
143
|
+
}));
|
|
144
|
+
}
|
|
145
|
+
return Option.none();
|
|
146
|
+
};
|
|
147
|
+
/** Returns the final answer that relays `report`, starting with its marker. */
|
|
148
|
+
export const reportText = (report) => {
|
|
149
|
+
const marker = Match.valueTags(report, {
|
|
150
|
+
AgentResultError: () => FAILED_MARKER,
|
|
151
|
+
AgentBlockedError: () => BLOCKED_MARKER,
|
|
152
|
+
AgentQuestionError: () => QUESTION_MARKER,
|
|
153
|
+
});
|
|
154
|
+
return `${marker}\n${report.message}`;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Maps a session error to an Attempt failure: SDK and process failures are retryable infrastructure
|
|
158
|
+
* failures; roster errors and Agent-reported failures wait for the operator (ADR 0002).
|
|
85
159
|
*/
|
|
86
160
|
export const toAttemptFailure = (error) => Match.valueTags(error, {
|
|
87
161
|
SessionOperationError: (operation) => new InfraFailure({ message: operation.message, cause: operation.cause }),
|
|
@@ -89,21 +163,28 @@ export const toAttemptFailure = (error) => Match.valueTags(error, {
|
|
|
89
163
|
PoolUnavailableError: ({ message }) => new AgentFailure({ message }),
|
|
90
164
|
UnsupportedEffortError: ({ message }) => new AgentFailure({ message }),
|
|
91
165
|
AgentResultError: ({ message }) => new AgentFailure({ message }),
|
|
166
|
+
AgentBlockedError: ({ message }) => new BlockedFailure({ message }),
|
|
167
|
+
AgentQuestionError: ({ message }) => new QuestionFailure({ question: message }),
|
|
92
168
|
ChildSessionBudgetExceededError: ({ attemptedChildren, maxChildren }) => new ChildSessionBudgetFailure({ attemptedChildren, maxChildren }),
|
|
93
169
|
});
|
|
94
|
-
/**
|
|
170
|
+
/** The service that runs tasks delegated by an Attempt's parent. */
|
|
95
171
|
export class ChildBackend extends Context.Service()("@usine/agents/ChildBackend") {
|
|
96
172
|
}
|
|
97
|
-
/**
|
|
173
|
+
/**
|
|
174
|
+
* A per-Worker lock for Claude commands that can refresh the Worker's shared Claude login: the
|
|
175
|
+
* preflight login check and the start of a Claude child. Claude Code ends a process that finds
|
|
176
|
+
* another process refreshing the login (#453). Provide one instance to both the executor and the
|
|
177
|
+
* Attempt runtime.
|
|
178
|
+
*/
|
|
179
|
+
export class ClaudeLoginLock extends Context.Service()("@usine/agents/ClaudeLoginLock") {
|
|
180
|
+
}
|
|
181
|
+
/** The child backend for Claude Code. */
|
|
98
182
|
export class ClaudeChildBackend extends Context.Service()("@usine/agents/ClaudeChildBackend") {
|
|
99
183
|
}
|
|
100
|
-
/**
|
|
184
|
+
/** The child backend for Codex. */
|
|
101
185
|
export class CodexChildBackend extends Context.Service()("@usine/agents/CodexChildBackend") {
|
|
102
186
|
}
|
|
103
|
-
/**
|
|
187
|
+
/** The child backend for Pi. */
|
|
104
188
|
export class PiChildBackend extends Context.Service()("@usine/agents/PiChildBackend") {
|
|
105
189
|
}
|
|
106
|
-
/** Starts the parent that coordinates one Attempt's task and delegates coding work to children. */
|
|
107
|
-
export class AgentRuntime extends Context.Service()("@usine/agents/AgentRuntime") {
|
|
108
|
-
}
|
|
109
190
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACL,YAAY,EACZ,cAAc,EACd,yBAAyB,EACzB,YAAY,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,cAAc,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,YAAY,EACZ,eAAe,GAChB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAEvD,4CAA4C;AAC5C,MAAM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+
"version": "0.4.0",
|
|
4
|
+
"description": "The usine agent layer: Claude Code, Codex, and Pi child backends, Attempt prompts, and harness preflight.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"directory": "packages/agents"
|
|
10
10
|
},
|
|
11
11
|
"files": [
|
|
12
|
-
"dist"
|
|
12
|
+
"dist",
|
|
13
|
+
"!dist/tsconfig.tsbuildinfo"
|
|
13
14
|
],
|
|
14
15
|
"type": "module",
|
|
15
16
|
"sideEffects": false,
|
|
@@ -18,6 +19,10 @@
|
|
|
18
19
|
"types": "./dist/pi/pi.d.ts",
|
|
19
20
|
"default": "./dist/pi/pi.js"
|
|
20
21
|
},
|
|
22
|
+
"./child-host": {
|
|
23
|
+
"types": "./dist/child-host/child-host.d.ts",
|
|
24
|
+
"default": "./dist/child-host/child-host.js"
|
|
25
|
+
},
|
|
21
26
|
"./children": {
|
|
22
27
|
"types": "./dist/pi/children.d.ts",
|
|
23
28
|
"default": "./dist/pi/children.js"
|
|
@@ -30,9 +35,9 @@
|
|
|
30
35
|
"types": "./dist/pi/codex/codex.d.ts",
|
|
31
36
|
"default": "./dist/pi/codex/codex.js"
|
|
32
37
|
},
|
|
33
|
-
"./pi/
|
|
34
|
-
"types": "./dist/pi/
|
|
35
|
-
"default": "./dist/pi/
|
|
38
|
+
"./pi/authentication": {
|
|
39
|
+
"types": "./dist/pi/authentication.d.ts",
|
|
40
|
+
"default": "./dist/pi/authentication.js"
|
|
36
41
|
},
|
|
37
42
|
"./prompt": {
|
|
38
43
|
"types": "./dist/prompt.d.ts",
|
|
@@ -51,10 +56,16 @@
|
|
|
51
56
|
"access": "public"
|
|
52
57
|
},
|
|
53
58
|
"dependencies": {
|
|
54
|
-
"@anthropic-ai/claude-agent-sdk": "0.3.
|
|
55
|
-
"@earendil-works/
|
|
56
|
-
"
|
|
57
|
-
"@
|
|
59
|
+
"@anthropic-ai/claude-agent-sdk": "0.3.308",
|
|
60
|
+
"@earendil-works/chord": "1.1.0",
|
|
61
|
+
"@earendil-works/pi-agent-core": "1.1.0",
|
|
62
|
+
"@earendil-works/pi-ai": "1.1.0",
|
|
63
|
+
"@earendil-works/pi-codemode": "1.1.0",
|
|
64
|
+
"@earendil-works/pi-coding-agent": "1.1.0",
|
|
65
|
+
"@earendil-works/pi-mcp": "1.1.0",
|
|
66
|
+
"@earendil-works/pi-telemetry": "1.1.0",
|
|
67
|
+
"@earendil-works/pi-tui": "1.1.0",
|
|
68
|
+
"@usine/core": "0.4.0"
|
|
58
69
|
},
|
|
59
70
|
"devDependencies": {
|
|
60
71
|
"@effect/platform-node": "4.0.0-rc.111",
|
|
@@ -75,6 +86,7 @@
|
|
|
75
86
|
"build": "tsc -b",
|
|
76
87
|
"check": "tsc -p tsconfig.check.json && tsc -p tsconfig.conformance.json",
|
|
77
88
|
"test": "vitest run --exclude 'test/integration/**'",
|
|
89
|
+
"test:integration:claude": "vitest run test/integration/claude.test.ts",
|
|
78
90
|
"test:integration:codex": "vitest run test/integration/codex.test.ts",
|
|
79
91
|
"test:integration:pi": "vitest run test/integration/pi.test.ts"
|
|
80
92
|
}
|
package/dist/pi/live.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Layer } from "effect";
|
|
2
|
-
/** The Node agent runtime: the Pi parent with the Claude, Codex, and Pi child backends. */
|
|
3
|
-
export declare const layer: Layer.Layer<import("../runtime.ts").AgentRuntime, never, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
4
|
-
//# sourceMappingURL=live.d.ts.map
|
package/dist/pi/live.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../src/pi/live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAgB/B,2FAA2F;AAC3F,eAAO,MAAM,KAAK,qIAAuE,CAAC"}
|
package/dist/pi/live.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Layer } from "effect";
|
|
2
|
-
import { claudeChildBackendLayer, claudeSdkLive } from "./claude.js";
|
|
3
|
-
import { childDispatcherLayer } from "./children.js";
|
|
4
|
-
import { codexAppServerLive } from "./codex/app-server.js";
|
|
5
|
-
import { codexChildBackendLayer } from "./codex/codex.js";
|
|
6
|
-
import { piChildBackendLayer, piParentLayer, piSdkLive } from "./pi.js";
|
|
7
|
-
const childImplementations = Layer.merge(claudeChildBackendLayer.pipe(Layer.provide(claudeSdkLive)), Layer.merge(codexChildBackendLayer.pipe(Layer.provide(codexAppServerLive)), piChildBackendLayer.pipe(Layer.provide(piSdkLive))));
|
|
8
|
-
const childLive = childDispatcherLayer.pipe(Layer.provide(childImplementations));
|
|
9
|
-
/** The Node agent runtime: the Pi parent with the Claude, Codex, and Pi child backends. */
|
|
10
|
-
export const layer = piParentLayer.pipe(Layer.provide(Layer.merge(piSdkLive, childLive)));
|
|
11
|
-
//# sourceMappingURL=live.js.map
|
package/dist/pi/live.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"live.js","sourceRoot":"","sources":["../../src/pi/live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,QAAQ,CAAC;AAC/B,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAExE,MAAM,oBAAoB,GAAG,KAAK,CAAC,KAAK,CACtC,uBAAuB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,EAC1D,KAAK,CAAC,KAAK,CACT,sBAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,EAC9D,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CACnD,CACF,CAAC;AACF,MAAM,SAAS,GAAG,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC,CAAC;AAEjF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/pi/subagents.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type ExtensionFactory, type InlineExtension } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Agent } from "@usine/core/agent";
|
|
3
|
-
import { AgentSessionEvent, AgentSessionId, ChildSessionBudget } from "@usine/core/agent/session";
|
|
4
|
-
import { Effect } from "effect";
|
|
5
|
-
import { type AgentSessionError, type ChildBackend, ChildSessionBudgetExceededError, type WorkingDirectory } from "../runtime.ts";
|
|
6
|
-
export interface SubagentsExtensionOptions {
|
|
7
|
-
readonly agent: Agent;
|
|
8
|
-
readonly backend: ChildBackend["Service"];
|
|
9
|
-
readonly cwd: WorkingDirectory;
|
|
10
|
-
readonly emit: (event: AgentSessionEvent) => Effect.Effect<void>;
|
|
11
|
-
readonly maxChildren: ChildSessionBudget;
|
|
12
|
-
/** Called on every rejected spawn; the parent decides what a repeat means. */
|
|
13
|
-
readonly onBudgetExceeded: (error: ChildSessionBudgetExceededError) => Effect.Effect<void>;
|
|
14
|
-
readonly parentId: AgentSessionId;
|
|
15
|
-
/**
|
|
16
|
-
* Runs one child program on the parent launch's services and scope. Pi
|
|
17
|
-
* calls the tool outside any usine fiber, so the default runtime would lose
|
|
18
|
-
* the stderr log redirect (corrupting the protocol stdout) and detach the
|
|
19
|
-
* child from the Attempt's lifetime.
|
|
20
|
-
*/
|
|
21
|
-
readonly run: <A>(program: Effect.Effect<A, AgentSessionError>) => Promise<A>;
|
|
22
|
-
}
|
|
23
|
-
/** Builds the subagents extension; its single tool creates first-level child sessions only. */
|
|
24
|
-
export declare const createSubagentsExtension: (options: SubagentsExtensionOptions) => ExtensionFactory;
|
|
25
|
-
/** Names the extension so Pi startup diagnostics can identify it. */
|
|
26
|
-
export declare const subagentsExtension: (options: SubagentsExtensionOptions) => InlineExtension;
|
|
27
|
-
//# sourceMappingURL=subagents.d.ts.map
|