@usine/agents 0.4.0 → 0.5.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/LICENSE +661 -21
- package/README.md +16 -8
- package/dist/child-host/child-host.d.ts +31 -1
- package/dist/child-host/child-host.d.ts.map +1 -1
- package/dist/child-host/child-host.js +52 -17
- package/dist/child-host/child-host.js.map +1 -1
- package/dist/child-host/command.d.ts +12 -1
- package/dist/child-host/command.d.ts.map +1 -1
- package/dist/child-host/command.js +18 -1
- package/dist/child-host/command.js.map +1 -1
- package/dist/openai-prices.d.ts +8 -0
- package/dist/openai-prices.d.ts.map +1 -0
- package/dist/openai-prices.js +28 -0
- package/dist/openai-prices.js.map +1 -0
- package/dist/pi/claude/claude.d.ts +10 -0
- package/dist/pi/claude/claude.d.ts.map +1 -0
- package/dist/pi/{claude.js → claude/claude.js} +244 -252
- package/dist/pi/claude/claude.js.map +1 -0
- package/dist/pi/claude/codec.d.ts +67 -0
- package/dist/pi/claude/codec.d.ts.map +1 -0
- package/dist/pi/claude/codec.js +140 -0
- package/dist/pi/claude/codec.js.map +1 -0
- package/dist/pi/{claude.d.ts → claude/sdk.d.ts} +9 -7
- package/dist/pi/claude/sdk.d.ts.map +1 -0
- package/dist/pi/claude/sdk.js +63 -0
- package/dist/pi/claude/sdk.js.map +1 -0
- package/dist/pi/codex/account.d.ts +8 -2
- package/dist/pi/codex/account.d.ts.map +1 -1
- package/dist/pi/codex/account.js +18 -1
- package/dist/pi/codex/account.js.map +1 -1
- package/dist/pi/codex/app-server.d.ts +1 -1
- package/dist/pi/codex/app-server.d.ts.map +1 -1
- package/dist/pi/codex/app-server.js +1 -1
- package/dist/pi/codex/app-server.js.map +1 -1
- package/dist/pi/codex/codec.d.ts +1 -97
- package/dist/pi/codex/codec.d.ts.map +1 -1
- package/dist/pi/codex/codec.js +2 -91
- package/dist/pi/codex/codec.js.map +1 -1
- package/dist/pi/codex/codex.d.ts.map +1 -1
- package/dist/pi/codex/codex.js +17 -7
- package/dist/pi/codex/codex.js.map +1 -1
- package/dist/pi/conversation.d.ts +4 -0
- package/dist/pi/conversation.d.ts.map +1 -1
- package/dist/pi/conversation.js +4 -0
- package/dist/pi/conversation.js.map +1 -1
- package/dist/pi/pi.d.ts.map +1 -1
- package/dist/pi/pi.js +5 -0
- package/dist/pi/pi.js.map +1 -1
- package/dist/pi/sdk.d.ts +8 -1
- package/dist/pi/sdk.d.ts.map +1 -1
- package/dist/pi/sdk.js +21 -13
- package/dist/pi/sdk.js.map +1 -1
- package/dist/pi/usage.d.ts +13 -13
- package/dist/pi/usage.d.ts.map +1 -1
- package/dist/pi/usage.js +40 -18
- package/dist/pi/usage.js.map +1 -1
- package/dist/preflight/command.d.ts +4 -5
- package/dist/preflight/command.d.ts.map +1 -1
- package/dist/preflight/command.js +11 -22
- package/dist/preflight/command.js.map +1 -1
- package/dist/preflight/preflight.d.ts +11 -4
- package/dist/preflight/preflight.d.ts.map +1 -1
- package/dist/preflight/preflight.js +24 -10
- package/dist/preflight/preflight.js.map +1 -1
- package/dist/protocol/codex.d.ts +122 -4
- package/dist/protocol/codex.d.ts.map +1 -1
- package/dist/protocol/codex.js +108 -0
- package/dist/protocol/codex.js.map +1 -1
- package/dist/protocol/count.d.ts +4 -0
- package/dist/protocol/count.d.ts.map +1 -0
- package/dist/protocol/count.js +4 -0
- package/dist/protocol/count.js.map +1 -0
- package/dist/runtime.d.ts +18 -8
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +12 -6
- package/dist/runtime.js.map +1 -1
- package/package.json +23 -19
- package/dist/pi/claude.d.ts.map +0 -1
- package/dist/pi/claude.js.map +0 -1
package/dist/pi/sdk.js
CHANGED
|
@@ -8,6 +8,23 @@ export const environmentBashTool = (cwd, environment) => {
|
|
|
8
8
|
const exact = (context) => ({ ...context, env: { ...environment } });
|
|
9
9
|
return defineTool(createBashToolDefinition(cwd, { exposeSessionEnvironment: false, spawnHook: exact }));
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Pi's default tools, named so that the global `defaultTools` setting can't add a tool whose
|
|
13
|
+
* processes inherit this process's environment, such as `grep` or `find`.
|
|
14
|
+
*/
|
|
15
|
+
const piChildToolNames = ["read", "bash", "edit", "write"];
|
|
16
|
+
/**
|
|
17
|
+
* Returns the session options that give a Pi child exactly Pi's default tools. With `environment`,
|
|
18
|
+
* the bash tool runs its commands with exactly that environment.
|
|
19
|
+
*/
|
|
20
|
+
export const piChildTools = (cwd, environment) => ({
|
|
21
|
+
tools: [...piChildToolNames],
|
|
22
|
+
// A custom tool replaces the built-in tool of the same name.
|
|
23
|
+
customTools: Option.match(environment, {
|
|
24
|
+
onNone: () => [],
|
|
25
|
+
onSome: (exact) => [environmentBashTool(cwd, exact)],
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
11
28
|
/** The service that starts a Pi session with the selected model and its repository tools. */
|
|
12
29
|
export class PiSdk extends Context.Service()("@usine/agents/pi/PiSdk") {
|
|
13
30
|
}
|
|
@@ -37,25 +54,15 @@ export const piSdkLive = Layer.succeed(PiSdk)({
|
|
|
37
54
|
noThemes: true,
|
|
38
55
|
});
|
|
39
56
|
await resourceLoader.reload();
|
|
40
|
-
const
|
|
57
|
+
const { session } = await createAgentSession({
|
|
58
|
+
...piChildTools(options.cwd, options.environment),
|
|
41
59
|
cwd: options.cwd,
|
|
60
|
+
model: selected,
|
|
42
61
|
modelRuntime,
|
|
43
62
|
resourceLoader,
|
|
44
63
|
sessionManager: SessionManager.inMemory(options.cwd),
|
|
45
64
|
settingsManager,
|
|
46
65
|
thinkingLevel: options.thinkingLevel,
|
|
47
|
-
};
|
|
48
|
-
// A custom tool replaces the built-in tool of the same name.
|
|
49
|
-
const environmentScopedSessionOptions = Option.match(options.environment, {
|
|
50
|
-
onNone: () => sessionOptions,
|
|
51
|
-
onSome: (environment) => ({
|
|
52
|
-
...sessionOptions,
|
|
53
|
-
customTools: [environmentBashTool(options.cwd, environment)],
|
|
54
|
-
}),
|
|
55
|
-
});
|
|
56
|
-
const { session } = await createAgentSession({
|
|
57
|
-
...environmentScopedSessionOptions,
|
|
58
|
-
model: selected,
|
|
59
66
|
});
|
|
60
67
|
let ownershipTransferred = false;
|
|
61
68
|
try {
|
|
@@ -84,6 +91,7 @@ export const piSdkLive = Layer.succeed(PiSdk)({
|
|
|
84
91
|
model,
|
|
85
92
|
pool,
|
|
86
93
|
session,
|
|
94
|
+
tools: session.getActiveToolNames(),
|
|
87
95
|
};
|
|
88
96
|
}
|
|
89
97
|
finally {
|
package/dist/pi/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/pi/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAEL,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,
|
|
1
|
+
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../src/pi/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAEL,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACrB,UAAU,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,GAKhB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAGL,gBAAgB,EAChB,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAC;AAqD7B,8GAA8G;AAC9G,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,GAAW,EACX,WAA6C,EAC7B,EAAE;IA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nB,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE;QACrB,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;YAAE,OAAO,MAAM,CAAC,IAAI,CAAC;QAC7C,SAAS,GAAG,IAAI,CAAC;QACjB,IAAI,QAAQ,EAAE,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,MAAM,CAAC,UAAU,CAAC,iDAAiD,EAAE;gBAC1E,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,KAAK;gBAC5B,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI;aAC3B,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC;QACD,OAAO,OAAO;YACZ,CAAC,CAAC,MAAM,CAAC,UAAU,CACf,+EAA+E,CAChF;YACH,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;IAClB,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/dist/pi/usage.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TokenCount, UsdAmount } from "@usine/core/agent/session";
|
|
1
|
+
import { TokenBreakdown, TokenCount, UsdAmount } from "@usine/core/agent/session";
|
|
2
2
|
import { Option, Schema } from "effect";
|
|
3
|
+
import type { CodexTokenUsage } from "../protocol/codex.ts";
|
|
3
4
|
/** A session's token count and, if the harness reports one, its cost in dollars. */
|
|
4
5
|
export interface SessionUsage {
|
|
5
6
|
readonly totalTokens: TokenCount;
|
|
@@ -19,21 +20,20 @@ export declare const addUsage: (total: SessionUsage, message: SessionUsage) => S
|
|
|
19
20
|
* their added tokens. The cost is the SDK's `costUSD` estimate and changes only at a result.
|
|
20
21
|
*/
|
|
21
22
|
export declare const claudeTokenMeter: () => (message: Schema.Json) => Option.Option<SessionUsage>;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}>;
|
|
32
|
-
}>;
|
|
33
|
-
export type CodexTokenUsage = typeof CodexTokenUsage.Type;
|
|
23
|
+
/**
|
|
24
|
+
* Returns a Claude token meter for a session that another process can resume. `read` returns the
|
|
25
|
+
* session's usage: the current process's, as `claudeTokenMeter` reads it, plus the earlier
|
|
26
|
+
* processes'. `restart` starts on a new process, which Claude counts from zero.
|
|
27
|
+
*/
|
|
28
|
+
export declare const claudeSessionMeter: () => {
|
|
29
|
+
read: (message: Schema.Json) => Option.Option<SessionUsage>;
|
|
30
|
+
restart: () => void;
|
|
31
|
+
};
|
|
34
32
|
/**
|
|
35
33
|
* Returns a Codex thread's consumption: output plus uncached input. The thread's `totalTokens` counts
|
|
36
34
|
* the whole context on every turn, so it is not used.
|
|
37
35
|
*/
|
|
38
36
|
export declare const codexThreadTokens: (total: CodexTokenUsage["tokenUsage"]["total"]) => TokenCount;
|
|
37
|
+
/** Returns a Codex thread's tokens per billing rate. */
|
|
38
|
+
export declare const codexTokenBreakdown: (total: CodexTokenUsage["tokenUsage"]["total"]) => TokenBreakdown;
|
|
39
39
|
//# sourceMappingURL=usage.d.ts.map
|
package/dist/pi/usage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/pi/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"usage.d.ts","sourceRoot":"","sources":["../../src/pi/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAClF,OAAO,EAAQ,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAc5D,oFAAoF;AACpF,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;CAC5C;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,gHAM1B,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,QAAQ,UAAW,YAAY,WAAW,YAAY,KAAG,YAKpE,CAAC;AA0BH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,kBAIV,MAAM,CAAC,IAAI,KAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAwB1D,CAAC;AAIF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;IAK3B,IAAI,YAAY,MAAM,CAAC,IAAI,KAAG,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;IAKzD,OAAO;CAMV,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,UAAW,eAAe,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,KAAG,UACc,CAAC;AAEjG,wDAAwD;AACxD,eAAO,MAAM,mBAAmB,UAAW,eAAe,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,mBAM7E,CAAC"}
|
package/dist/pi/usage.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { TokenCount, UsdAmount } from "@usine/core/agent/session";
|
|
1
|
+
import { TokenBreakdown, TokenCount, UsdAmount } from "@usine/core/agent/session";
|
|
2
2
|
import { flow, Option, Schema } from "effect";
|
|
3
|
-
|
|
3
|
+
import { UsageCount } from "../protocol/count.js";
|
|
4
4
|
const Dollars = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
|
|
5
5
|
const PiUsage = Schema.Struct({
|
|
6
6
|
role: Schema.Literal("assistant"),
|
|
7
7
|
usage: Schema.Struct({
|
|
8
|
-
input:
|
|
9
|
-
output:
|
|
10
|
-
cacheWrite:
|
|
8
|
+
input: UsageCount,
|
|
9
|
+
output: UsageCount,
|
|
10
|
+
cacheWrite: UsageCount,
|
|
11
11
|
cost: Schema.optionalKey(Schema.Struct({ total: Dollars })),
|
|
12
12
|
}),
|
|
13
13
|
});
|
|
@@ -31,16 +31,16 @@ const ClaudeAssistantUsage = Schema.Struct({
|
|
|
31
31
|
message: Schema.Struct({
|
|
32
32
|
id: Schema.NonEmptyString,
|
|
33
33
|
usage: Schema.Struct({
|
|
34
|
-
input_tokens:
|
|
35
|
-
output_tokens:
|
|
36
|
-
cache_creation_input_tokens: Schema.optionalKey(Schema.NullOr(
|
|
34
|
+
input_tokens: UsageCount,
|
|
35
|
+
output_tokens: UsageCount,
|
|
36
|
+
cache_creation_input_tokens: Schema.optionalKey(Schema.NullOr(UsageCount)),
|
|
37
37
|
}),
|
|
38
38
|
}),
|
|
39
39
|
});
|
|
40
40
|
const ClaudeModelUsage = Schema.Struct({
|
|
41
|
-
inputTokens:
|
|
42
|
-
outputTokens:
|
|
43
|
-
cacheCreationInputTokens:
|
|
41
|
+
inputTokens: UsageCount,
|
|
42
|
+
outputTokens: UsageCount,
|
|
43
|
+
cacheCreationInputTokens: UsageCount,
|
|
44
44
|
costUSD: Schema.optionalKey(Dollars),
|
|
45
45
|
});
|
|
46
46
|
const ClaudeResultUsage = Schema.Struct({
|
|
@@ -81,16 +81,38 @@ export const claudeTokenMeter = () => {
|
|
|
81
81
|
return Option.some({ totalTokens: TokenCount.make(total), costUsd: cost });
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
const NO_USAGE = { totalTokens: TokenCount.make(0), costUsd: Option.none() };
|
|
85
|
+
/**
|
|
86
|
+
* Returns a Claude token meter for a session that another process can resume. `read` returns the
|
|
87
|
+
* session's usage: the current process's, as `claudeTokenMeter` reads it, plus the earlier
|
|
88
|
+
* processes'. `restart` starts on a new process, which Claude counts from zero.
|
|
89
|
+
*/
|
|
90
|
+
export const claudeSessionMeter = () => {
|
|
91
|
+
let earlier = NO_USAGE;
|
|
92
|
+
let current = NO_USAGE;
|
|
93
|
+
let meter = claudeTokenMeter();
|
|
94
|
+
return {
|
|
95
|
+
read: (message) => Option.map(meter(message), (usage) => {
|
|
96
|
+
current = usage;
|
|
97
|
+
return addUsage(earlier, usage);
|
|
98
|
+
}),
|
|
99
|
+
restart: () => {
|
|
100
|
+
earlier = addUsage(earlier, current);
|
|
101
|
+
current = NO_USAGE;
|
|
102
|
+
meter = claudeTokenMeter();
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
};
|
|
91
106
|
/**
|
|
92
107
|
* Returns a Codex thread's consumption: output plus uncached input. The thread's `totalTokens` counts
|
|
93
108
|
* the whole context on every turn, so it is not used.
|
|
94
109
|
*/
|
|
95
110
|
export const codexThreadTokens = (total) => TokenCount.make(total.outputTokens + Math.max(0, total.inputTokens - total.cachedInputTokens));
|
|
111
|
+
/** Returns a Codex thread's tokens per billing rate. */
|
|
112
|
+
export const codexTokenBreakdown = (total) => new TokenBreakdown({
|
|
113
|
+
input: Math.max(0, total.inputTokens - total.cachedInputTokens - total.cacheWriteInputTokens),
|
|
114
|
+
cachedInput: total.cachedInputTokens,
|
|
115
|
+
cacheWrite: total.cacheWriteInputTokens,
|
|
116
|
+
output: total.outputTokens,
|
|
117
|
+
});
|
|
96
118
|
//# sourceMappingURL=usage.js.map
|
package/dist/pi/usage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/pi/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/pi/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EA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@usine/core/agent/capability";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
|
-
import {
|
|
5
|
-
import type { ChildHost } from "../child-host/child-host.ts";
|
|
4
|
+
import { type ChildHost } from "../child-host/child-host.ts";
|
|
6
5
|
import { SessionOperationError } from "../runtime.ts";
|
|
7
6
|
/** Returns the error for a readiness command that exited non-zero; the message includes the command but not its output. */
|
|
8
7
|
export declare const probeFailed: (harness: Harness, capability: HarnessCapability, command: string, args: ReadonlyArray<string>) => HarnessUnavailableError;
|
|
@@ -13,8 +12,8 @@ export declare const probeFailed: (harness: Harness, capability: HarnessCapabili
|
|
|
13
12
|
*/
|
|
14
13
|
export declare const probeOutput: (host: import("../child-host/child-host.ts").LocalProcess | import("../child-host/child-host.ts").RemoteShell, environment: Readonly<Record<string, string>>, harness: "claude" | "codex" | "pi", capability: "binary" | "login" | "version", command: string, args: readonly string[]) => Effect.Effect<{
|
|
15
14
|
stdout: string;
|
|
16
|
-
exitCode: ChildProcessSpawner.ExitCode;
|
|
17
|
-
}, HarnessUnavailableError | SessionOperationError, ChildProcessSpawner.ChildProcessSpawner>;
|
|
15
|
+
exitCode: import("effect/process/ChildProcessSpawner").ExitCode;
|
|
16
|
+
}, HarnessUnavailableError | SessionOperationError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
18
17
|
/** Runs a readiness command and returns its trimmed stdout. Fails with `HarnessUnavailableError` if the command exits non-zero. */
|
|
19
|
-
export declare const probeCommand: (host: ChildHost, environment: Readonly<Record<string, string>>, harness: Harness, capability: HarnessCapability, command: string, args: ReadonlyArray<string>) => Effect.Effect<string, HarnessUnavailableError | SessionOperationError, ChildProcessSpawner.ChildProcessSpawner>;
|
|
18
|
+
export declare const probeCommand: (host: ChildHost, environment: Readonly<Record<string, string>>, harness: Harness, capability: HarnessCapability, command: string, args: ReadonlyArray<string>) => Effect.Effect<string, HarnessUnavailableError | SessionOperationError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
20
19
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,KAAK,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAE,KAAK,SAAS,EAAe,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,2HAA2H;AAC3H,eAAO,MAAM,WAAW,YACb,OAAO,cACJ,iBAAiB,WACpB,MAAM,QACT,aAAa,CAAC,MAAM,CAAC,4BAMzB,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;qHAuCtB,CAAC;AAEH,mIAAmI;AACnI,eAAO,MAAM,YAAY,SACjB,SAAS,eACF,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,WACpC,OAAO,cACJ,iBAAiB,WACpB,MAAM,QACT,aAAa,CAAC,MAAM,CAAC,6IAQ1B,CAAC"}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
2
|
-
import { Effect, Option
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { Effect, Option } from "effect";
|
|
3
|
+
import { SSH_FAILURE } from "../child-host/child-host.js";
|
|
4
|
+
import { hostOutput } from "../child-host/command.js";
|
|
5
5
|
import { SessionOperationError } from "../runtime.js";
|
|
6
|
-
/** The exit code OpenSSH returns if it cannot connect or run the remote command. */
|
|
7
|
-
const SSH_FAILURE = 255;
|
|
8
6
|
/** Returns the error for a readiness command that exited non-zero; the message includes the command but not its output. */
|
|
9
7
|
export const probeFailed = (harness, capability, command, args) => new HarnessUnavailableError({
|
|
10
8
|
harness,
|
|
@@ -18,23 +16,14 @@ export const probeFailed = (harness, capability, command, args) => new HarnessUn
|
|
|
18
16
|
*/
|
|
19
17
|
export const probeOutput = Effect.fn("HarnessPreflight.command")(function* (host, environment, harness, capability, command, args) {
|
|
20
18
|
yield* Effect.annotateCurrentSpan({ harness, capability, host: host._tag });
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (host._tag === "RemoteShell" && exitCode === SSH_FAILURE)
|
|
30
|
-
return yield* new SessionOperationError({
|
|
31
|
-
operation: "launch",
|
|
32
|
-
sessionId: Option.none(),
|
|
33
|
-
message: `Can't reach ${host.destination} to run ${command}`,
|
|
34
|
-
cause: new Error(`${host.ssh.command} exited with code ${SSH_FAILURE}`),
|
|
35
|
-
});
|
|
36
|
-
return { stdout: stdout.trim(), exitCode };
|
|
37
|
-
})).pipe(Effect.timeout("30 seconds"), Effect.catchTags({
|
|
19
|
+
return yield* hostOutput(host, { environment, command, args }).pipe(Effect.flatMap((output) => host._tag === "RemoteShell" && output.exitCode === SSH_FAILURE
|
|
20
|
+
? Effect.fail(new SessionOperationError({
|
|
21
|
+
operation: "launch",
|
|
22
|
+
sessionId: Option.none(),
|
|
23
|
+
message: `Can't reach ${host.destination} to run ${command}`,
|
|
24
|
+
cause: new Error(`${host.ssh.command} exited with code ${SSH_FAILURE}`),
|
|
25
|
+
}))
|
|
26
|
+
: Effect.succeed(output)), Effect.timeout("30 seconds"), Effect.catchTags({
|
|
38
27
|
PlatformError: () => new HarnessUnavailableError({
|
|
39
28
|
harness,
|
|
40
29
|
capability,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAA0B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAA0B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,EAAkB,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,2HAA2H;AAC3H,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,OAAgB,EAChB,UAA6B,EAC7B,OAAe,EACf,IAA2B,EAC3B,EAAE,CACF,IAAI,uBAAuB,CAAC;IAC1B,OAAO;IACP,UAAU;IACV,OAAO,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,OAAO,wCAAwC;CAC3G,CAAC,CAAC;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,EAAE,CAAC,0BAA0B,CAAC,CAAC,QAAQ,CAAC,EACxE,IAAe,EACf,WAA6C,EAC7C,OAAgB,EAChB,UAA6B,EAC7B,OAAe,EACf,IAA2B;IAE3B,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAC5E,OAAO,KAAK,CAAC,CAAC,UAAU,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EAAE,IAAI,CAAC,CAAC,IAAI,CACrE,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,CACtC,QAAQ,KAAK,CAAC;IACZ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IACxB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC,CACjE,CACF,CAAC"}
|
|
@@ -1,18 +1,25 @@
|
|
|
1
1
|
import type { BrainSpec } from "@usine/core/agent/brain";
|
|
2
2
|
import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
3
|
-
import { Effect } from "effect";
|
|
3
|
+
import { Effect, Option } from "effect";
|
|
4
4
|
import type { ChildHost } from "../child-host/child-host.ts";
|
|
5
5
|
import { SessionOperationError } from "../runtime.ts";
|
|
6
6
|
import { CodexAppServer } from "../pi/codex/app-server.ts";
|
|
7
7
|
import { PiSdk } from "../pi/sdk.ts";
|
|
8
8
|
/** The Codex CLI version of the pinned app-server protocol package used by the conformance check. */
|
|
9
|
-
export declare const CODEX_CLI_VERSION = "0.
|
|
9
|
+
export declare const CODEX_CLI_VERSION = "0.159.2";
|
|
10
|
+
/**
|
|
11
|
+
* The Codex CLI versions that preflight accepts, the conformance baseline first. Adding a version
|
|
12
|
+
* needs a review of its generated protocol types and a run of the live contracts.
|
|
13
|
+
*/
|
|
14
|
+
export declare const supportedCodexVersions: ReadonlyArray<string>;
|
|
15
|
+
/** Returns the error for `codex --version` output that names no supported Codex CLI version. */
|
|
16
|
+
export declare const unsupportedCodexVersion: (version: string) => Option.Option<HarnessUnavailableError>;
|
|
10
17
|
/**
|
|
11
18
|
* Checks `brain` on `host` without starting a prompt; each check process gets `environment` as its
|
|
12
19
|
* complete local environment, or on top of the remote host's environment (ADR 0011). Fails with
|
|
13
20
|
* `HarnessUnavailableError` for Pi on a remote host.
|
|
14
21
|
*/
|
|
15
|
-
export declare const verifyHarness: (brain: BrainSpec, host: import("../child-host/child-host.ts").LocalProcess | import("../child-host/child-host.ts").RemoteShell, environment: Readonly<Record<string, string>>) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/
|
|
22
|
+
export declare const verifyHarness: (brain: BrainSpec, host: import("../child-host/child-host.ts").LocalProcess | import("../child-host/child-host.ts").RemoteShell, environment: Readonly<Record<string, string>>) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner | CodexAppServer | PiSdk>;
|
|
16
23
|
/** Checks only `brain` on `host`, with `environment` and the Worker user's configuration; does not run a prompt or log in. */
|
|
17
|
-
export declare const preflight: (brain: BrainSpec, host: ChildHost, environment: Readonly<Record<string, string>>) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/
|
|
24
|
+
export declare const preflight: (brain: BrainSpec, host: ChildHost, environment: Readonly<Record<string, string>>) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
18
25
|
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAEL,YAAY,EACZ,uBAAuB,EACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"preflight.d.ts","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAEL,YAAY,EACZ,uBAAuB,EACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAEhD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAoB,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAsB,MAAM,2BAA2B,CAAC;AAE/E,OAAO,EAAE,KAAK,EAAyB,MAAM,cAAc,CAAC;AAG5D,qGAAqG;AACrG,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,aAAa,CAAC,MAAM,CAMxD,CAAC;AAEF,gGAAgG;AAChG,eAAO,MAAM,uBAAuB,YAAa,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,uBAAuB,CASxF,CAAC;AAYR;;;;GAIG;AACH,eAAO,MAAM,aAAa,4VAsIzB,CAAC;AAEF,8HAA8H;AAC9H,eAAO,MAAM,SAAS,UACb,SAAS,QACV,SAAS,eACF,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,mJAK5C,CAAC"}
|
|
@@ -7,9 +7,26 @@ import { initializeCodex, verifyCodexAccount } from "../pi/codex/account.js";
|
|
|
7
7
|
import { PiSdk, piSdkLive, usePiStart } from "../pi/sdk.js";
|
|
8
8
|
import { probeCommand, probeFailed, probeOutput } from "./command.js";
|
|
9
9
|
/** The Codex CLI version of the pinned app-server protocol package used by the conformance check. */
|
|
10
|
-
export const CODEX_CLI_VERSION = "0.
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export const CODEX_CLI_VERSION = "0.159.2";
|
|
11
|
+
/**
|
|
12
|
+
* The Codex CLI versions that preflight accepts, the conformance baseline first. Adding a version
|
|
13
|
+
* needs a review of its generated protocol types and a run of the live contracts.
|
|
14
|
+
*/
|
|
15
|
+
export const supportedCodexVersions = [
|
|
16
|
+
CODEX_CLI_VERSION,
|
|
17
|
+
"0.159.0",
|
|
18
|
+
"0.159.1",
|
|
19
|
+
"0.159.3",
|
|
20
|
+
"0.153.4",
|
|
21
|
+
];
|
|
22
|
+
/** Returns the error for `codex --version` output that names no supported Codex CLI version. */
|
|
23
|
+
export const unsupportedCodexVersion = (version) => supportedCodexVersions.some((supported) => version === `codex-cli ${supported}`)
|
|
24
|
+
? Option.none()
|
|
25
|
+
: Option.some(new HarnessUnavailableError({
|
|
26
|
+
harness: "codex",
|
|
27
|
+
capability: "version",
|
|
28
|
+
message: `The worker has ${/^codex-cli [0-9]+\.[0-9]+\.[0-9]+$/u.test(version) ? version : "an unrecognized Codex version"}. Install a supported Codex CLI version: ${supportedCodexVersions.join(", ")}.`,
|
|
29
|
+
}));
|
|
13
30
|
const ClaudeAuthentication = Schema.Struct({
|
|
14
31
|
loggedIn: Schema.Boolean,
|
|
15
32
|
authMethod: Schema.String,
|
|
@@ -37,12 +54,9 @@ export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (bra
|
|
|
37
54
|
switch (brain.harness) {
|
|
38
55
|
case "codex": {
|
|
39
56
|
const version = yield* probe("binary", "codex", ["--version"]);
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
capability: "version",
|
|
44
|
-
message: `The worker has ${/^codex-cli [0-9]+\.[0-9]+\.[0-9]+$/u.test(version) ? version : "an unrecognized Codex version"}. Install a supported Codex CLI version: ${supportedCodexVersions.join(", ")}.`,
|
|
45
|
-
});
|
|
57
|
+
const unsupported = unsupportedCodexVersion(version);
|
|
58
|
+
if (Option.isSome(unsupported))
|
|
59
|
+
return yield* unsupported.value;
|
|
46
60
|
yield* Effect.scoped(Effect.gen(function* () {
|
|
47
61
|
const server = yield* CodexAppServer;
|
|
48
62
|
const connection = yield* server.open({
|
|
@@ -86,7 +100,7 @@ export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (bra
|
|
|
86
100
|
const sdk = yield* PiSdk;
|
|
87
101
|
yield* usePiStart((signal) => sdk.start({
|
|
88
102
|
cwd: homedir(),
|
|
89
|
-
environment: Option.
|
|
103
|
+
environment: Option.some(environment),
|
|
90
104
|
extensions: [],
|
|
91
105
|
model: brain.model,
|
|
92
106
|
signal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEtE,qGAAqG;AACrG,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAE3C
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,YAAY,EACZ,uBAAuB,GACxB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,C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f,WAA6C,EAC7C,EAAE,CACF,aAAa,CAAC,KAAK,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,IAAI,CAC1C,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,EAClC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAC1B,CAAC"}
|
package/dist/protocol/codex.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* `@pwrdrvr/codex-app-server-protocol@0.
|
|
5
|
-
* only under bundler module resolution
|
|
6
|
-
*
|
|
3
|
+
* The Codex app-server wire types: the request types that usine sends, copied from
|
|
4
|
+
* `@pwrdrvr/codex-app-server-protocol@0.159.2` (codex-cli 0.159.2) because that package resolves
|
|
5
|
+
* only under bundler module resolution, and the decoders for the responses and notifications that
|
|
6
|
+
* usine reads. `protocol-conformance/check.ts` fails `pnpm check` if either drifts from the
|
|
7
|
+
* package; it compiles this module without Node types, so nothing here imports a Node module.
|
|
7
8
|
*/
|
|
8
9
|
export interface InitializeParams {
|
|
9
10
|
readonly clientInfo: {
|
|
@@ -63,5 +64,122 @@ export declare const AccountResponse: Schema.Struct<{
|
|
|
63
64
|
export declare const AccountUpdated: Schema.Struct<{
|
|
64
65
|
readonly authMode: Schema.NullOr<Schema.String>;
|
|
65
66
|
}>;
|
|
67
|
+
/** The model catalog page, used to validate the requested model and reasoning effort. */
|
|
68
|
+
export declare const ModelListResponse: Schema.Struct<{
|
|
69
|
+
readonly data: Schema.$Array<Schema.Struct<{
|
|
70
|
+
readonly id: Schema.String;
|
|
71
|
+
readonly model: Schema.String;
|
|
72
|
+
readonly supportedReasoningEfforts: Schema.optionalKey<Schema.$Array<Schema.Struct<{
|
|
73
|
+
readonly reasoningEffort: Schema.String;
|
|
74
|
+
}>>>;
|
|
75
|
+
}>>;
|
|
76
|
+
readonly nextCursor: Schema.NullOr<Schema.String>;
|
|
77
|
+
}>;
|
|
78
|
+
/** The thread ID and effective model returned when a child thread starts. */
|
|
79
|
+
export declare const ThreadStartResponse: Schema.Struct<{
|
|
80
|
+
readonly thread: Schema.Struct<{
|
|
81
|
+
readonly id: Schema.brand<Schema.NonEmptyString, "HarnessSessionId">;
|
|
82
|
+
}>;
|
|
83
|
+
readonly model: Schema.NonEmptyString;
|
|
84
|
+
readonly instructionSources: Schema.$Array<Schema.String>;
|
|
85
|
+
}>;
|
|
86
|
+
/** The turn ID, needed to steer or interrupt the turn. */
|
|
87
|
+
export declare const TurnStartResponse: Schema.Struct<{
|
|
88
|
+
readonly turn: Schema.Struct<{
|
|
89
|
+
readonly id: Schema.NonEmptyString;
|
|
90
|
+
}>;
|
|
91
|
+
}>;
|
|
92
|
+
/** An item notification with its thread and turn IDs; `item` is kept as JSON. */
|
|
93
|
+
export declare const ItemNotification: Schema.Struct<{
|
|
94
|
+
readonly item: Schema.Codec<Schema.Json, Schema.Json, never, never>;
|
|
95
|
+
readonly threadId: Schema.String;
|
|
96
|
+
readonly turnId: Schema.String;
|
|
97
|
+
}>;
|
|
98
|
+
/** A user message recorded in the thread: a turn's input, or steered input once the running turn reads it. */
|
|
99
|
+
export declare const UserMessageItem: Schema.Struct<{
|
|
100
|
+
readonly type: Schema.Literal<"userMessage">;
|
|
101
|
+
readonly content: Schema.$Array<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
102
|
+
}>;
|
|
103
|
+
/** The text part of a user message. */
|
|
104
|
+
export declare const UserTextInput: Schema.Struct<{
|
|
105
|
+
readonly type: Schema.Literal<"text">;
|
|
106
|
+
readonly text: Schema.String;
|
|
107
|
+
}>;
|
|
108
|
+
/** A completed assistant message; `phase` distinguishes a final answer from commentary. */
|
|
109
|
+
export declare const AgentMessageItem: Schema.Struct<{
|
|
110
|
+
readonly type: Schema.Literal<"agentMessage">;
|
|
111
|
+
readonly id: Schema.NonEmptyString;
|
|
112
|
+
readonly text: Schema.String;
|
|
113
|
+
readonly phase: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
114
|
+
}>;
|
|
115
|
+
/** A recognized tool item, with the fields needed to match starts and results. */
|
|
116
|
+
export declare const ToolItem: Schema.Struct<{
|
|
117
|
+
readonly type: Schema.Literals<readonly ["commandExecution", "fileChange", "mcpToolCall", "dynamicToolCall", "webSearch", "imageView", "imageGeneration"]>;
|
|
118
|
+
readonly id: Schema.NonEmptyString;
|
|
119
|
+
readonly status: Schema.optionalKey<Schema.String>;
|
|
120
|
+
readonly success: Schema.optionalKey<Schema.NullOr<Schema.Boolean>>;
|
|
121
|
+
}>;
|
|
122
|
+
/** The outcome of a turn, used to resume a conversation on Hold or report a session failure. */
|
|
123
|
+
export declare const TurnCompleted: Schema.Struct<{
|
|
124
|
+
readonly turn: Schema.Struct<{
|
|
125
|
+
readonly id: Schema.String;
|
|
126
|
+
readonly status: Schema.Literals<readonly ["completed", "interrupted", "failed", "inProgress"]>;
|
|
127
|
+
readonly error: Schema.NullOr<Schema.Struct<{
|
|
128
|
+
readonly message: Schema.String;
|
|
129
|
+
readonly additionalDetails: Schema.NullOr<Schema.String>;
|
|
130
|
+
}>>;
|
|
131
|
+
}>;
|
|
132
|
+
}>;
|
|
133
|
+
/** A turn error from the app server; if `willRetry` is set, the model provider request is retried, for example `Reconnecting... 2/5`. */
|
|
134
|
+
export declare const ErrorNotification: Schema.Struct<{
|
|
135
|
+
readonly error: Schema.Struct<{
|
|
136
|
+
readonly message: Schema.String;
|
|
137
|
+
readonly additionalDetails: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
138
|
+
}>;
|
|
139
|
+
readonly willRetry: Schema.Boolean;
|
|
140
|
+
readonly turnId: Schema.String;
|
|
141
|
+
}>;
|
|
142
|
+
/** Any notification for one turn, for example an item or a streaming delta. */
|
|
143
|
+
export declare const TurnActivity: Schema.Struct<{
|
|
144
|
+
readonly turnId: Schema.String;
|
|
145
|
+
}>;
|
|
146
|
+
export declare const RateLimitWindow: Schema.Struct<{
|
|
147
|
+
readonly usedPercent: Schema.Number;
|
|
148
|
+
readonly windowDurationMins: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
149
|
+
readonly resetsAt: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
150
|
+
}>;
|
|
151
|
+
/** A partial account usage update; omitted windows are also absent in the normalized snapshot. */
|
|
152
|
+
export declare const RateLimitsUpdated: Schema.Struct<{
|
|
153
|
+
readonly rateLimits: Schema.Struct<{
|
|
154
|
+
readonly limitId: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
155
|
+
readonly limitName: Schema.optionalKey<Schema.NullOr<Schema.String>>;
|
|
156
|
+
readonly primary: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
|
|
157
|
+
readonly usedPercent: Schema.Number;
|
|
158
|
+
readonly windowDurationMins: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
159
|
+
readonly resetsAt: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
160
|
+
}>>>;
|
|
161
|
+
readonly secondary: Schema.optionalKey<Schema.NullOr<Schema.Struct<{
|
|
162
|
+
readonly usedPercent: Schema.Number;
|
|
163
|
+
readonly windowDurationMins: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
164
|
+
readonly resetsAt: Schema.optionalKey<Schema.NullOr<Schema.Number>>;
|
|
165
|
+
}>>>;
|
|
166
|
+
}>;
|
|
167
|
+
}>;
|
|
168
|
+
/**
|
|
169
|
+
* The Codex thread token usage, cumulative across turns; `inputTokens` includes cache reads and
|
|
170
|
+
* cache writes.
|
|
171
|
+
*/
|
|
172
|
+
export declare const CodexTokenUsage: Schema.Struct<{
|
|
173
|
+
readonly threadId: Schema.NonEmptyString;
|
|
174
|
+
readonly tokenUsage: Schema.Struct<{
|
|
175
|
+
readonly total: Schema.Struct<{
|
|
176
|
+
readonly inputTokens: Schema.Int;
|
|
177
|
+
readonly cachedInputTokens: Schema.Int;
|
|
178
|
+
readonly cacheWriteInputTokens: Schema.Int;
|
|
179
|
+
readonly outputTokens: Schema.Int;
|
|
180
|
+
}>;
|
|
181
|
+
}>;
|
|
182
|
+
}>;
|
|
183
|
+
export type CodexTokenUsage = typeof CodexTokenUsage.Type;
|
|
66
184
|
export {};
|
|
67
185
|
//# sourceMappingURL=codex.d.ts.map
|