@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
package/dist/pi/usage.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { TokenCount, UsdAmount } from "@usine/core/agent/session";
|
|
2
|
+
import { flow, Option, Schema } from "effect";
|
|
3
|
+
const Count = Schema.Int.check(Schema.isGreaterThanOrEqualTo(0));
|
|
4
|
+
const Dollars = Schema.Finite.check(Schema.isGreaterThanOrEqualTo(0));
|
|
5
|
+
const PiUsage = Schema.Struct({
|
|
6
|
+
role: Schema.Literal("assistant"),
|
|
7
|
+
usage: Schema.Struct({
|
|
8
|
+
input: Count,
|
|
9
|
+
output: Count,
|
|
10
|
+
cacheWrite: Count,
|
|
11
|
+
cost: Schema.optionalKey(Schema.Struct({ total: Dollars })),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Returns the usage of one completed Pi assistant message: output plus uncached input, where cache
|
|
16
|
+
* writes count and cache reads do not, and the dollar cost if Pi reports one.
|
|
17
|
+
*/
|
|
18
|
+
export const piMessageUsage = flow(Schema.decodeUnknownOption(PiUsage), Option.map(({ usage }) => ({
|
|
19
|
+
totalTokens: TokenCount.make(usage.output + usage.input + usage.cacheWrite),
|
|
20
|
+
costUsd: Option.map(Option.fromNullishOr(usage.cost), ({ total }) => UsdAmount.make(total)),
|
|
21
|
+
})));
|
|
22
|
+
/** Adds a message's usage to a session total; the cost is `Some` once any message has a cost. */
|
|
23
|
+
export const addUsage = (total, message) => ({
|
|
24
|
+
totalTokens: TokenCount.make(total.totalTokens + message.totalTokens),
|
|
25
|
+
costUsd: Option.isNone(message.costUsd)
|
|
26
|
+
? total.costUsd
|
|
27
|
+
: Option.some(UsdAmount.make(Option.getOrElse(total.costUsd, () => 0) + message.costUsd.value)),
|
|
28
|
+
});
|
|
29
|
+
const ClaudeAssistantUsage = Schema.Struct({
|
|
30
|
+
type: Schema.Literal("assistant"),
|
|
31
|
+
message: Schema.Struct({
|
|
32
|
+
id: Schema.NonEmptyString,
|
|
33
|
+
usage: Schema.Struct({
|
|
34
|
+
input_tokens: Count,
|
|
35
|
+
output_tokens: Count,
|
|
36
|
+
cache_creation_input_tokens: Schema.optionalKey(Schema.NullOr(Count)),
|
|
37
|
+
}),
|
|
38
|
+
}),
|
|
39
|
+
});
|
|
40
|
+
const ClaudeModelUsage = Schema.Struct({
|
|
41
|
+
inputTokens: Count,
|
|
42
|
+
outputTokens: Count,
|
|
43
|
+
cacheCreationInputTokens: Count,
|
|
44
|
+
costUSD: Schema.optionalKey(Dollars),
|
|
45
|
+
});
|
|
46
|
+
const ClaudeResultUsage = Schema.Struct({
|
|
47
|
+
type: Schema.Literal("result"),
|
|
48
|
+
modelUsage: Schema.Record(Schema.String, ClaudeModelUsage),
|
|
49
|
+
});
|
|
50
|
+
const decodeAssistant = Schema.decodeUnknownOption(ClaudeAssistantUsage);
|
|
51
|
+
const decodeResult = Schema.decodeUnknownOption(ClaudeResultUsage);
|
|
52
|
+
/**
|
|
53
|
+
* Returns a Claude token meter: live message usage between results, reconciled with the cumulative
|
|
54
|
+
* `modelUsage` at each result. Consumption is output plus input plus cache creation, because the
|
|
55
|
+
* SDK's input counts exclude cache reads and writes; repeated blocks with one message ID count only
|
|
56
|
+
* their added tokens. The cost is the SDK's `costUSD` estimate and changes only at a result.
|
|
57
|
+
*/
|
|
58
|
+
export const claudeTokenMeter = () => {
|
|
59
|
+
let total = 0;
|
|
60
|
+
let cost = Option.none();
|
|
61
|
+
const messages = new Map();
|
|
62
|
+
return (message) => {
|
|
63
|
+
const assistant = decodeAssistant(message);
|
|
64
|
+
if (Option.isSome(assistant)) {
|
|
65
|
+
const { id, usage } = assistant.value.message;
|
|
66
|
+
const consumed = usage.output_tokens + usage.input_tokens + (usage.cache_creation_input_tokens ?? 0);
|
|
67
|
+
const previous = messages.get(id) ?? 0;
|
|
68
|
+
total += Math.max(0, consumed - previous);
|
|
69
|
+
messages.set(id, Math.max(previous, consumed));
|
|
70
|
+
return Option.some({ totalTokens: TokenCount.make(total), costUsd: cost });
|
|
71
|
+
}
|
|
72
|
+
const result = decodeResult(message);
|
|
73
|
+
if (Option.isNone(result))
|
|
74
|
+
return Option.none();
|
|
75
|
+
const models = Object.values(result.value.modelUsage);
|
|
76
|
+
const consumed = models.reduce((sum, usage) => sum + usage.outputTokens + usage.inputTokens + usage.cacheCreationInputTokens, 0);
|
|
77
|
+
total = Math.max(total, consumed);
|
|
78
|
+
const priced = models.flatMap(({ costUSD }) => (costUSD === undefined ? [] : [costUSD]));
|
|
79
|
+
if (priced.length > 0)
|
|
80
|
+
cost = Option.some(UsdAmount.make(priced.reduce((sum, value) => sum + value, 0)));
|
|
81
|
+
return Option.some({ totalTokens: TokenCount.make(total), costUsd: cost });
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
/** The Codex thread token usage, cumulative across turns; `inputTokens` includes cached input. */
|
|
85
|
+
export const CodexTokenUsage = Schema.Struct({
|
|
86
|
+
threadId: Schema.NonEmptyString,
|
|
87
|
+
tokenUsage: Schema.Struct({
|
|
88
|
+
total: Schema.Struct({ inputTokens: Count, cachedInputTokens: Count, outputTokens: Count }),
|
|
89
|
+
}),
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* Returns a Codex thread's consumption: output plus uncached input. The thread's `totalTokens` counts
|
|
93
|
+
* the whole context on every turn, so it is not used.
|
|
94
|
+
*/
|
|
95
|
+
export const codexThreadTokens = (total) => TokenCount.make(total.outputTokens + Math.max(0, total.inputTokens - total.cachedInputTokens));
|
|
96
|
+
//# sourceMappingURL=usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/pi/usage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAClE,OA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,KAAK,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;KAC5F,CAAC;CACH,CAAC,CAAC;AAGH;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAA6C,EAAc,EAAE,CAC7F,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Harness } from "@usine/core/agent/brain";
|
|
2
|
+
import { HarnessUnavailableError, type HarnessCapability } from "@usine/core/agent/capability";
|
|
2
3
|
import { Effect } from "effect";
|
|
3
4
|
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
5
|
+
import type { ChildHost } from "../child-host/child-host.ts";
|
|
4
6
|
import { SessionOperationError } from "../runtime.ts";
|
|
5
|
-
/**
|
|
6
|
-
export declare const
|
|
7
|
+
/** Returns the error for a readiness command that exited non-zero; the message includes the command but not its output. */
|
|
8
|
+
export declare const probeFailed: (harness: Harness, capability: HarnessCapability, command: string, args: ReadonlyArray<string>) => HarnessUnavailableError;
|
|
9
|
+
/**
|
|
10
|
+
* Runs a readiness command on `host` with a 30-second timeout and returns its trimmed stdout and
|
|
11
|
+
* exit code; stderr is discarded. If the remote host is unreachable or the command times out, fails
|
|
12
|
+
* with `SessionOperationError`.
|
|
13
|
+
*/
|
|
14
|
+
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
|
+
stdout: string;
|
|
16
|
+
exitCode: ChildProcessSpawner.ExitCode;
|
|
17
|
+
}, HarnessUnavailableError | SessionOperationError, ChildProcessSpawner.ChildProcessSpawner>;
|
|
18
|
+
/** 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>;
|
|
7
20
|
//# sourceMappingURL=command.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"
|
|
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,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAWtD,2HAA2H;AAC3H,eAAO,MAAM,WAAW,YACb,OAAO,cACJ,iBAAiB,WACpB,MAAM,QACT,aAAa,CAAC,MAAM,CAAC,4BAMzB,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,WAAW;;;4FAsDtB,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,oHAQ1B,CAAC"}
|
|
@@ -1,35 +1,44 @@
|
|
|
1
1
|
import { HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
2
2
|
import { Effect, Option, Stream } from "effect";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
4
|
+
import { hostCommand } from "../child-host/command.js";
|
|
5
5
|
import { SessionOperationError } from "../runtime.js";
|
|
6
|
-
/**
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/** The exit code OpenSSH returns if it cannot connect or run the remote command. */
|
|
7
|
+
const SSH_FAILURE = 255;
|
|
8
|
+
/** Returns the error for a readiness command that exited non-zero; the message includes the command but not its output. */
|
|
9
|
+
export const probeFailed = (harness, capability, command, args) => new HarnessUnavailableError({
|
|
10
|
+
harness,
|
|
11
|
+
capability,
|
|
12
|
+
message: `${command} ${args.join(" ")} failed. Check the ${harness} installation and login on the worker.`,
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Runs a readiness command on `host` with a 30-second timeout and returns its trimmed stdout and
|
|
16
|
+
* exit code; stderr is discarded. If the remote host is unreachable or the command times out, fails
|
|
17
|
+
* with `SessionOperationError`.
|
|
18
|
+
*/
|
|
19
|
+
export const probeOutput = Effect.fn("HarnessPreflight.command")(function* (host, environment, harness, capability, command, args) {
|
|
20
|
+
yield* Effect.annotateCurrentSpan({ harness, capability, host: host._tag });
|
|
9
21
|
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
10
22
|
return yield* Effect.scoped(Effect.gen(function* () {
|
|
11
|
-
const handle = yield* spawner.spawn(
|
|
12
|
-
cwd: homedir(),
|
|
13
|
-
detached: false,
|
|
14
|
-
forceKillAfter: "2 seconds",
|
|
15
|
-
}));
|
|
23
|
+
const handle = yield* spawner.spawn(hostCommand(host, { environment, command, args }, { detached: false, forceKillAfter: "2 seconds" }));
|
|
16
24
|
const [stdout, , exitCode] = yield* Effect.all([
|
|
17
25
|
handle.stdout.pipe(Stream.decodeText(), Stream.mkString),
|
|
18
26
|
handle.stderr.pipe(Stream.runDrain),
|
|
19
27
|
handle.exitCode,
|
|
20
28
|
], { concurrency: "unbounded" });
|
|
21
|
-
if (exitCode
|
|
22
|
-
return yield* new
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
message:
|
|
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}`),
|
|
26
35
|
});
|
|
27
|
-
return stdout.trim();
|
|
36
|
+
return { stdout: stdout.trim(), exitCode };
|
|
28
37
|
})).pipe(Effect.timeout("30 seconds"), Effect.catchTags({
|
|
29
38
|
PlatformError: () => new HarnessUnavailableError({
|
|
30
39
|
harness,
|
|
31
40
|
capability,
|
|
32
|
-
message: `
|
|
41
|
+
message: `The worker can't run ${command}`,
|
|
33
42
|
}),
|
|
34
43
|
TimeoutError: (cause) => new SessionOperationError({
|
|
35
44
|
operation: "launch",
|
|
@@ -39,4 +48,8 @@ export const probeCommand = Effect.fn("HarnessPreflight.command")(function* (har
|
|
|
39
48
|
}),
|
|
40
49
|
}));
|
|
41
50
|
});
|
|
51
|
+
/** Runs a readiness command and returns its trimmed stdout. Fails with `HarnessUnavailableError` if the command exits non-zero. */
|
|
52
|
+
export const probeCommand = (host, environment, harness, capability, command, args) => probeOutput(host, environment, harness, capability, command, args).pipe(Effect.flatMap(({ stdout, exitCode }) => exitCode === 0
|
|
53
|
+
? Effect.succeed(stdout)
|
|
54
|
+
: Effect.fail(probeFailed(harness, capability, command, args))));
|
|
42
55
|
//# sourceMappingURL=command.js.map
|
|
@@ -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,EA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;QACJ,YAAY,EAAE,CAAC,KAAK,EAAE,EAAE,CACtB,IAAI,qBAAqB,CAAC;YACxB,SAAS,EAAE,QAAQ;YACnB,SAAS,EAAE,MAAM,CAAC,IAAI,EAAE;YACxB,OAAO,EAAE,GAAG,OAAO,4BAA4B;YAC/C,KAAK;SACN,CAAC;KACL,CAAC,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,mIAAmI;AACnI,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAe,EACf,WAA6C,EAC7C,OAAgB,EAChB,UAA6B,EAC7B,OAAe,EACf,IAA2B,EAC3B,EAAE,CACF,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,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,13 +1,18 @@
|
|
|
1
1
|
import type { BrainSpec } from "@usine/core/agent/brain";
|
|
2
2
|
import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
|
+
import type { ChildHost } from "../child-host/child-host.ts";
|
|
4
5
|
import { SessionOperationError } from "../runtime.ts";
|
|
5
6
|
import { CodexAppServer } from "../pi/codex/app-server.ts";
|
|
6
7
|
import { PiSdk } from "../pi/sdk.ts";
|
|
7
|
-
/**
|
|
8
|
+
/** The Codex CLI version of the pinned app-server protocol package used by the conformance check. */
|
|
8
9
|
export declare const CODEX_CLI_VERSION = "0.144.0";
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Checks `brain` on `host` without starting a prompt; each check process gets `environment` as its
|
|
12
|
+
* complete local environment, or on top of the remote host's environment (ADR 0011). Fails with
|
|
13
|
+
* `HarnessUnavailableError` for Pi on a remote host.
|
|
14
|
+
*/
|
|
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/unstable/process/ChildProcessSpawner").ChildProcessSpawner | CodexAppServer | PiSdk>;
|
|
16
|
+
/** 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/unstable/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
13
18
|
//# 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,
|
|
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,EAAkB,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;;;;GAIG;AACH,eAAO,MAAM,aAAa,qWA0IzB,CAAC;AAEF,8HAA8H;AAC9H,eAAO,MAAM,SAAS,UACb,SAAS,QACV,SAAS,eACF,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,4JAK5C,CAAC"}
|
|
@@ -1,42 +1,55 @@
|
|
|
1
|
-
import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
1
|
+
import { HarnessReady, HarnessUnavailableError, } from "@usine/core/agent/capability";
|
|
2
2
|
import { Effect, Option, Schema } from "effect";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { SessionOperationError, WorkingDirectory } from "../runtime.js";
|
|
5
5
|
import { CodexAppServer, codexAppServerLive } from "../pi/codex/app-server.js";
|
|
6
6
|
import { initializeCodex, verifyCodexAccount } from "../pi/codex/account.js";
|
|
7
7
|
import { PiSdk, piSdkLive, usePiStart } from "../pi/sdk.js";
|
|
8
|
-
import { probeCommand } from "./command.js";
|
|
9
|
-
/**
|
|
8
|
+
import { probeCommand, probeFailed, probeOutput } from "./command.js";
|
|
9
|
+
/** The Codex CLI version of the pinned app-server protocol package used by the conformance check. */
|
|
10
10
|
export const CODEX_CLI_VERSION = "0.144.0";
|
|
11
|
-
//
|
|
11
|
+
// Each additional version needs a review of its generated types and a run of the live contracts.
|
|
12
12
|
const supportedCodexVersions = [CODEX_CLI_VERSION, "0.153.4"];
|
|
13
13
|
const ClaudeAuthentication = Schema.Struct({
|
|
14
14
|
loggedIn: Schema.Boolean,
|
|
15
15
|
authMethod: Schema.String,
|
|
16
16
|
apiProvider: Schema.String,
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
const decodeClaudeAuthentication = Schema.decodeUnknownOption(Schema.fromJsonString(ClaudeAuthentication));
|
|
19
|
+
const CLAUDE_AUTH_STATUS = ["auth", "status", "--json"];
|
|
20
|
+
/**
|
|
21
|
+
* Checks `brain` on `host` without starting a prompt; each check process gets `environment` as its
|
|
22
|
+
* complete local environment, or on top of the remote host's environment (ADR 0011). Fails with
|
|
23
|
+
* `HarnessUnavailableError` for Pi on a remote host.
|
|
24
|
+
*/
|
|
25
|
+
export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (brain, host, environment) {
|
|
26
|
+
yield* Effect.annotateCurrentSpan({
|
|
27
|
+
harness: brain.harness,
|
|
28
|
+
model: brain.model,
|
|
29
|
+
host: host._tag,
|
|
30
|
+
});
|
|
21
31
|
const loginError = (message) => new HarnessUnavailableError({
|
|
22
32
|
harness: brain.harness,
|
|
23
33
|
capability: "login",
|
|
24
34
|
message,
|
|
25
35
|
});
|
|
36
|
+
const probe = (capability, command, args) => probeCommand(host, environment, brain.harness, capability, command, args);
|
|
26
37
|
switch (brain.harness) {
|
|
27
38
|
case "codex": {
|
|
28
|
-
const version = yield*
|
|
39
|
+
const version = yield* probe("binary", "codex", ["--version"]);
|
|
29
40
|
if (!supportedCodexVersions.some((supported) => version === `codex-cli ${supported}`))
|
|
30
41
|
return yield* new HarnessUnavailableError({
|
|
31
42
|
harness: "codex",
|
|
32
43
|
capability: "version",
|
|
33
|
-
message: `
|
|
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(", ")}.`,
|
|
34
45
|
});
|
|
35
46
|
yield* Effect.scoped(Effect.gen(function* () {
|
|
36
47
|
const server = yield* CodexAppServer;
|
|
37
48
|
const connection = yield* server.open({
|
|
38
49
|
cwd: WorkingDirectory.make(homedir()),
|
|
39
50
|
sessionId: Option.none(),
|
|
51
|
+
environment,
|
|
52
|
+
host,
|
|
40
53
|
});
|
|
41
54
|
yield* initializeCodex(connection);
|
|
42
55
|
yield* verifyCodexAccount(connection, brain.model);
|
|
@@ -44,37 +57,50 @@ export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (bra
|
|
|
44
57
|
break;
|
|
45
58
|
}
|
|
46
59
|
case "claude": {
|
|
47
|
-
yield*
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
yield* probe("binary", "claude", ["--version"]);
|
|
61
|
+
const status = yield* probeOutput(host, environment, "claude", "login", "claude", CLAUDE_AUTH_STATUS);
|
|
62
|
+
// Claude prints the same status and exits 1 when not logged in.
|
|
63
|
+
const auth = status.exitCode === 0 || status.exitCode === 1
|
|
64
|
+
? decodeClaudeAuthentication(status.stdout)
|
|
65
|
+
: Option.none();
|
|
66
|
+
if (Option.isNone(auth))
|
|
67
|
+
return yield* status.exitCode === 0
|
|
68
|
+
? loginError("Claude returned an unrecognized login status")
|
|
69
|
+
: probeFailed("claude", "login", "claude", CLAUDE_AUTH_STATUS);
|
|
70
|
+
const { loggedIn, authMethod, apiProvider } = auth.value;
|
|
71
|
+
if (status.exitCode !== 0 ||
|
|
72
|
+
!loggedIn ||
|
|
73
|
+
authMethod !== "claude.ai" ||
|
|
74
|
+
apiProvider !== "firstParty")
|
|
75
|
+
return yield* loginError("Claude Code needs a subscription login. Run claude auth login on the worker.");
|
|
56
76
|
break;
|
|
57
77
|
}
|
|
58
78
|
case "pi": {
|
|
59
|
-
|
|
79
|
+
if (host._tag === "RemoteShell")
|
|
80
|
+
return yield* new HarnessUnavailableError({
|
|
81
|
+
harness: "pi",
|
|
82
|
+
capability: "binary",
|
|
83
|
+
message: "Pi children run only on local workers",
|
|
84
|
+
});
|
|
85
|
+
// Pi runs from the SDK installed with this process, not from a CLI binary.
|
|
60
86
|
const sdk = yield* PiSdk;
|
|
61
87
|
yield* usePiStart((signal) => sdk.start({
|
|
62
88
|
cwd: homedir(),
|
|
89
|
+
environment: Option.none(),
|
|
63
90
|
extensions: [],
|
|
64
|
-
model:
|
|
91
|
+
model: brain.model,
|
|
65
92
|
signal,
|
|
66
93
|
thinkingLevel: brain.effort,
|
|
67
|
-
toolMode: "repository",
|
|
68
94
|
}), (cause) => new SessionOperationError({
|
|
69
95
|
operation: "launch",
|
|
70
96
|
sessionId: Option.none(),
|
|
71
|
-
message: `
|
|
97
|
+
message: `Can't check Pi authentication for "${brain.model}"`,
|
|
72
98
|
cause,
|
|
73
99
|
}), (acquired) => Effect.gen(function* () {
|
|
74
100
|
const result = acquired.result;
|
|
75
101
|
yield* Effect.sync(acquired.dispose);
|
|
76
102
|
if (result._tag !== "Started" || result.pool !== "apiKeys")
|
|
77
|
-
return yield* loginError(`Pi child model ${brain.model}
|
|
103
|
+
return yield* loginError(`Pi child model "${brain.model}" is unavailable, doesn't support effort ${brain.effort}, or doesn't use an API key`);
|
|
78
104
|
}));
|
|
79
105
|
break;
|
|
80
106
|
}
|
|
@@ -82,6 +108,7 @@ export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (bra
|
|
|
82
108
|
yield* Effect.logInfo("Worker harness verified", {
|
|
83
109
|
harness: brain.harness,
|
|
84
110
|
model: brain.model,
|
|
111
|
+
host: host._tag,
|
|
85
112
|
});
|
|
86
113
|
return new HarnessReady({ harness: brain.harness });
|
|
87
114
|
}, (effect, brain) => effect.pipe(Effect.timeout("60 seconds"), Effect.catchTag("TimeoutError", (cause) => new SessionOperationError({
|
|
@@ -95,6 +122,6 @@ export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (bra
|
|
|
95
122
|
errorTag: error._tag,
|
|
96
123
|
message: error.message,
|
|
97
124
|
}))));
|
|
98
|
-
/** Checks only
|
|
99
|
-
export const preflight = (brain) => verifyHarness(brain).pipe(Effect.provide(codexAppServerLive), Effect.provide(piSdkLive));
|
|
125
|
+
/** Checks only `brain` on `host`, with `environment` and the Worker user's configuration; does not run a prompt or log in. */
|
|
126
|
+
export const preflight = (brain, host, environment) => verifyHarness(brain, host, environment).pipe(Effect.provide(codexAppServerLive), Effect.provide(piSdkLive));
|
|
100
127
|
//# sourceMappingURL=preflight.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
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,iGAAiG;AACjG,MAAM,sBAAsB,GAAG,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC;AAE9D,MAAM,oBAAoB,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,QAAQ,EAAE,MAAM,CAAC,OAAO;IACxB,UAAU,EAAE,MAAM,CAAC,MAAM;IACzB,WAAW,EAAE,MAAM,CAAC,MAAM;CAC3B,CAAC,CAAC;AACH,MAAM,0BAA0B,GAAG,MAAM,CAAC,mBAAmB,CAC3D,MAAM,CAAC,cAAc,CAAC,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,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CACxB,MAAM,CAAC,QAAQ,CAAC,iCAAiC,EAAE;IACjD,OAAO,EAAE,KAAK,CAAC,OAAO;IACtB,KAAK,EAAE,KAAK,CAAC,KAAK;IAClB,QAAQ,EAAE,KAAK,CAAC,IAAI;IACpB,OAAO,EAAE,KAAK,CAAC,OAAO;CACvB,CAAC,CACH,CACF,CACJ,CAAC;AAEF,8HAA8H;AAC9H,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,KAAgB,EAChB,IAAe,EACf,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/prompt.d.ts
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentPersona, type AgentName } from "@usine/core/agent";
|
|
2
2
|
import type { AttemptTask } from "@usine/core/attempt";
|
|
3
|
+
import type { SalvagePushed } from "@usine/core/attempt/salvage";
|
|
3
4
|
import type { RepositoryName } from "@usine/core/repository";
|
|
4
|
-
import type
|
|
5
|
-
/** The
|
|
5
|
+
import { Option, type Schema } from "effect";
|
|
6
|
+
/** The trigger context, Agent instructions, and task for the parent prompt. */
|
|
6
7
|
export interface PromptParts {
|
|
7
8
|
readonly repository: RepositoryName;
|
|
8
9
|
readonly payload: Schema.Json;
|
|
9
10
|
readonly agent: AgentName;
|
|
10
11
|
readonly persona: AgentPersona;
|
|
11
12
|
readonly task: AttemptTask;
|
|
13
|
+
/** The previous Attempt's salvage checked out in the workspace, if the Run is retrying. */
|
|
14
|
+
readonly resume: Option.Option<SalvagePushed>;
|
|
15
|
+
/** The previous Attempt's salvage that conflicts with the current revision and is not in the workspace. */
|
|
16
|
+
readonly conflictingSalvage: Option.Option<SalvagePushed>;
|
|
12
17
|
}
|
|
13
|
-
/** The Agent
|
|
18
|
+
/** The Agent instructions and delegated task for a child prompt. */
|
|
14
19
|
export interface ChildPromptParts {
|
|
15
20
|
readonly agent: AgentName;
|
|
16
21
|
readonly persona: AgentPersona;
|
|
17
|
-
/** Free text
|
|
22
|
+
/** Free text written by the parent model, not the rendered Loop task. */
|
|
18
23
|
readonly task: string;
|
|
19
24
|
}
|
|
20
|
-
/**
|
|
21
|
-
export declare const githubSignature: (agent: AgentName) => string;
|
|
22
|
-
/** Builds the parent's instructions from the saved payload, effective task, and Agent persona, including GitHub attribution. */
|
|
25
|
+
/** Returns the parent's instructions, including GitHub attribution. */
|
|
23
26
|
export declare const assemblePrompt: (parts: PromptParts) => string;
|
|
24
|
-
/**
|
|
27
|
+
/** Returns a child's instructions, including GitHub attribution. */
|
|
25
28
|
export declare const assembleChildPrompt: (parts: ChildPromptParts) => string;
|
|
26
29
|
//# sourceMappingURL=prompt.d.ts.map
|
package/dist/prompt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG7C,+EAA+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,cAAc,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,2FAA2F;IAC3F,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC9C,2GAA2G;IAC3G,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;CAC3D;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,yEAAyE;IACzE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAqCD,uEAAuE;AACvE,eAAO,MAAM,cAAc,UAAW,WAAW,KAAG,MAuBtC,CAAC;AAEf,oEAAoE;AACpE,eAAO,MAAM,mBAAmB,UAAW,gBAAgB,KAAG,MAahD,CAAC"}
|
package/dist/prompt.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { githubSignature } from "@usine/core/agent";
|
|
2
|
+
import { Option } from "effect";
|
|
3
|
+
import { BLOCKED_MARKER, QUESTION_MARKER } from "./runtime.js";
|
|
4
|
+
const completionInstructions = [
|
|
5
|
+
"# Task completion",
|
|
6
|
+
"",
|
|
7
|
+
"Run gates, tests, and CI watches in the foreground. If a tool starts background work, wait for its result and finish every dependent step before returning your final answer.",
|
|
8
|
+
"Do not end a turn promising to resume after a background notification. Your final answer returns control to the caller and may end the Attempt and remove its worktree. Push all commits that must survive before returning.",
|
|
9
|
+
"A running command or pending CI check is unfinished work, not a blocker. Keep waiting and complete the task. For a genuine blocker, record the exact blocker on the issue or pull request and report which work remains incomplete.",
|
|
10
|
+
`For an unresolved blocker, start your final answer with exactly ${BLOCKED_MARKER} on its own line, followed by the exact blocker and incomplete work. This reserved marker reports a failed Attempt. A child's report that starts with the marker fails the Attempt: return it verbatim as your own final answer. Use an ordinary final answer only after completing the task.`,
|
|
11
|
+
`When the work needs a decision that only the operator can make, post the question on the task's issue or pull request when it has one, then start your final answer with exactly ${QUESTION_MARKER} on its own line, followed by the question and the options you see. This reserved marker ends the Attempt and asks the operator; usine does not run this task again on the same Item until the operator answers or the Item changes. Return a child's report that starts with this marker verbatim as your own final answer.`,
|
|
12
|
+
];
|
|
3
13
|
const githubInstructions = (agent) => [
|
|
4
14
|
"# GitHub identity",
|
|
5
15
|
"",
|
|
@@ -9,11 +19,26 @@ const githubInstructions = (agent) => [
|
|
|
9
19
|
"Append this signature to every GitHub comment, issue, pull request, or review you publish:",
|
|
10
20
|
githubSignature(agent),
|
|
11
21
|
];
|
|
12
|
-
|
|
22
|
+
const resumeLines = (parts) => [
|
|
23
|
+
...Option.match(parts.resume, {
|
|
24
|
+
onNone: () => [],
|
|
25
|
+
onSome: ({ ref, commit }) => [
|
|
26
|
+
`Resumes from: ${ref} at ${commit}, the previous Attempt's unfinished work, checked out at HEAD. Its last commit is an automatic work-in-progress snapshot. Continue from this state instead of starting over.`,
|
|
27
|
+
],
|
|
28
|
+
}),
|
|
29
|
+
...Option.match(parts.conflictingSalvage, {
|
|
30
|
+
onNone: () => [],
|
|
31
|
+
onSome: ({ ref, commit }) => [
|
|
32
|
+
`Previous work: ${ref} at ${commit}, the previous Attempt's unfinished work, conflicts with the current revision, so the checkout starts without it. Fetch that branch to reuse parts of it.`,
|
|
33
|
+
],
|
|
34
|
+
}),
|
|
35
|
+
];
|
|
36
|
+
/** Returns the parent's instructions, including GitHub attribution. */
|
|
13
37
|
export const assemblePrompt = (parts) => [
|
|
14
38
|
"# Run context",
|
|
15
39
|
"",
|
|
16
40
|
`Repository: ${parts.repository}`,
|
|
41
|
+
...resumeLines(parts),
|
|
17
42
|
"",
|
|
18
43
|
"Payload snapshot:",
|
|
19
44
|
"```json",
|
|
@@ -28,9 +53,11 @@ export const assemblePrompt = (parts) => [
|
|
|
28
53
|
"",
|
|
29
54
|
parts.task,
|
|
30
55
|
"",
|
|
56
|
+
...completionInstructions,
|
|
57
|
+
"",
|
|
31
58
|
...githubInstructions(parts.agent),
|
|
32
59
|
].join("\n");
|
|
33
|
-
/**
|
|
60
|
+
/** Returns a child's instructions, including GitHub attribution. */
|
|
34
61
|
export const assembleChildPrompt = (parts) => [
|
|
35
62
|
"# Agent persona",
|
|
36
63
|
"",
|
|
@@ -40,6 +67,8 @@ export const assembleChildPrompt = (parts) => [
|
|
|
40
67
|
"",
|
|
41
68
|
parts.task,
|
|
42
69
|
"",
|
|
70
|
+
...completionInstructions,
|
|
71
|
+
"",
|
|
43
72
|
...githubInstructions(parts.agent),
|
|
44
73
|
].join("\n");
|
|
45
74
|
//# sourceMappingURL=prompt.js.map
|
package/dist/prompt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAqC,MAAM,mBAAmB,CAAC;AAIvF,OAAO,EAAE,MAAM,EAAe,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAuB/D,MAAM,sBAAsB,GAA0B;IACpD,mBAAmB;IACnB,EAAE;IACF,+KAA+K;IAC/K,8NAA8N;IAC9N,qOAAqO;IACrO,mEAAmE,cAAc,+RAA+R;IAChX,oLAAoL,eAAe,8TAA8T;CAClgB,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,KAAgB,EAAyB,EAAE,CAAC;IACtE,mBAAmB;IACnB,EAAE;IACF,sGAAsG;IACtG,iKAAiK;IACjK,mOAAmO;I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ACE,iBAAiB;IACjB,EAAE;IACF,KAAK,CAAC,OAAO;IACb,EAAE;IACF,kBAAkB;IAClB,EAAE;IACF,KAAK,CAAC,IAAI;IACV,EAAE;IACF,GAAG,sBAAsB;IACzB,EAAE;IACF,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;CACnC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/protocol/codex.d.ts
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* `@pwrdrvr/codex-app-server-protocol@0.144.0` (codex-cli 0.144.0) because
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* against their generated types and the live steering/interruption contracts.
|
|
8
|
-
* `protocol-conformance/check.ts` compiles against the baseline package and fails
|
|
9
|
-
* `pnpm check` when these shapes drift.
|
|
3
|
+
* Request types sent to the Codex app server, copied from
|
|
4
|
+
* `@pwrdrvr/codex-app-server-protocol@0.144.0` (codex-cli 0.144.0) because that package resolves
|
|
5
|
+
* only under bundler module resolution. `protocol-conformance/check.ts` fails `pnpm check` if these
|
|
6
|
+
* types drift from the package.
|
|
10
7
|
*/
|
|
11
8
|
export interface InitializeParams {
|
|
12
9
|
readonly clientInfo: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/protocol/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC
|
|
1
|
+
{"version":3,"file":"codex.d.ts","sourceRoot":"","sources":["../../src/protocol/codex.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,UAAU,EAAE;QACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QACtB,QAAQ,CA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AAC,SAAS,CAAC,CAAC;IACzC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,YAAY,GAAG,WAAW,GAAG,IAAI,CAAC;IACtE,QAAQ,CAAC,aAAa,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,kBAAkB,CAAA;KAAE,GAAG,IAAI,CAAC;IACtE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAGD,eAAO,MAAM,eAAe;;;;;EAG1B,CAAC;AACH,eAAO,MAAM,cAAc;;EAA4D,CAAC"}
|
package/dist/protocol/codex.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
|
-
//
|
|
2
|
+
// Decodes only the authentication type, so account identity is never logged.
|
|
3
3
|
export const AccountResponse = Schema.Struct({
|
|
4
4
|
account: Schema.NullOr(Schema.Struct({ type: Schema.String })),
|
|
5
5
|
requiresOpenaiAuth: Schema.Boolean,
|