@usine/agents 0.1.0 → 0.2.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 +33 -6
- package/dist/pi/authentication.d.ts +4 -4
- package/dist/pi/authentication.d.ts.map +1 -1
- package/dist/pi/authentication.js +2 -2
- package/dist/pi/authentication.js.map +1 -1
- package/dist/pi/children.d.ts +4 -1
- package/dist/pi/children.d.ts.map +1 -1
- package/dist/pi/children.js +4 -1
- package/dist/pi/children.js.map +1 -1
- package/dist/pi/claude.d.ts +6 -2
- package/dist/pi/claude.d.ts.map +1 -1
- package/dist/pi/claude.js +18 -11
- package/dist/pi/claude.js.map +1 -1
- package/dist/pi/codex/account.d.ts +11 -0
- package/dist/pi/codex/account.d.ts.map +1 -0
- package/dist/pi/codex/account.js +43 -0
- package/dist/pi/codex/account.js.map +1 -0
- package/dist/pi/codex/app-server.d.ts +15 -6
- package/dist/pi/codex/app-server.d.ts.map +1 -1
- package/dist/pi/codex/app-server.js +61 -22
- package/dist/pi/codex/app-server.js.map +1 -1
- package/dist/pi/codex/codex.d.ts +2 -0
- package/dist/pi/codex/codex.d.ts.map +1 -1
- package/dist/pi/codex/codex.js +54 -34
- package/dist/pi/codex/codex.js.map +1 -1
- package/dist/pi/live.d.ts +4 -0
- package/dist/pi/live.d.ts.map +1 -0
- package/dist/pi/{index.js → live.js} +2 -9
- package/dist/pi/live.js.map +1 -0
- package/dist/pi/pi.d.ts +3 -1
- package/dist/pi/pi.d.ts.map +1 -1
- package/dist/pi/pi.js +64 -26
- package/dist/pi/pi.js.map +1 -1
- package/dist/pi/sdk.d.ts +18 -13
- package/dist/pi/sdk.d.ts.map +1 -1
- package/dist/pi/sdk.js +15 -10
- package/dist/pi/sdk.js.map +1 -1
- package/dist/pi/session.d.ts +20 -21
- package/dist/pi/session.d.ts.map +1 -1
- package/dist/pi/session.js +9 -10
- package/dist/pi/session.js.map +1 -1
- package/dist/pi/subagents.d.ts +15 -11
- package/dist/pi/subagents.d.ts.map +1 -1
- package/dist/pi/subagents.js +73 -43
- package/dist/pi/subagents.js.map +1 -1
- package/dist/pi/thinking.d.ts +8 -0
- package/dist/pi/thinking.d.ts.map +1 -0
- package/dist/pi/thinking.js +15 -0
- package/dist/pi/thinking.js.map +1 -0
- package/dist/preflight/command.d.ts +7 -0
- package/dist/preflight/command.d.ts.map +1 -0
- package/dist/preflight/command.js +42 -0
- package/dist/preflight/command.js.map +1 -0
- package/dist/preflight/preflight.d.ts +13 -0
- package/dist/preflight/preflight.d.ts.map +1 -0
- package/dist/preflight/preflight.js +100 -0
- package/dist/preflight/preflight.js.map +1 -0
- package/dist/prompt.d.ts +15 -11
- package/dist/prompt.d.ts.map +1 -1
- package/dist/prompt.js +14 -11
- package/dist/prompt.js.map +1 -1
- package/dist/protocol/codex.d.ts +20 -6
- package/dist/protocol/codex.d.ts.map +1 -1
- package/dist/protocol/codex.js +7 -1
- package/dist/protocol/codex.js.map +1 -1
- package/dist/runtime.d.ts +42 -24
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +47 -34
- package/dist/runtime.js.map +1 -1
- package/package.json +34 -10
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/index.js.map +0 -1
- package/dist/pi/index.d.ts +0 -11
- package/dist/pi/index.d.ts.map +0 -1
- package/dist/pi/index.js.map +0 -1
package/dist/pi/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/pi/session.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/pi/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACV,YAAY,EACZ,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,QA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CAAC,IAAI;gBACxB,SAAS,EAAE,OAAO,CAAC,EAAE;aACtB,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IACH,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAChC,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,WAAW,EAAE,CAAC;AACnD,CAAC,CAAC,CAAC"}
|
package/dist/pi/subagents.d.ts
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
import { type ExtensionFactory, type InlineExtension } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Agent } from "@usine/core";
|
|
2
|
+
import { Agent } from "@usine/core/agent";
|
|
3
|
+
import { AgentSessionEvent, AgentSessionId, ChildSessionBudget } from "@usine/core/agent/session";
|
|
3
4
|
import { Effect } from "effect";
|
|
4
|
-
import { type AgentSessionError, type ChildBackend, type WorkingDirectory } from "../runtime.ts";
|
|
5
|
+
import { type AgentSessionError, type ChildBackend, ChildSessionBudgetExceededError, type WorkingDirectory } from "../runtime.ts";
|
|
5
6
|
export interface SubagentsExtensionOptions {
|
|
6
|
-
readonly agent: Agent
|
|
7
|
+
readonly agent: Agent;
|
|
7
8
|
readonly backend: ChildBackend["Service"];
|
|
8
9
|
readonly cwd: WorkingDirectory;
|
|
9
|
-
readonly emit: (event:
|
|
10
|
-
readonly
|
|
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;
|
|
11
15
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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.
|
|
16
20
|
*/
|
|
17
21
|
readonly run: <A>(program: Effect.Effect<A, AgentSessionError>) => Promise<A>;
|
|
18
22
|
}
|
|
19
|
-
/**
|
|
23
|
+
/** Builds the subagents extension; its single tool creates first-level child sessions only. */
|
|
20
24
|
export declare const createSubagentsExtension: (options: SubagentsExtensionOptions) => ExtensionFactory;
|
|
21
|
-
/**
|
|
25
|
+
/** Names the extension so Pi startup diagnostics can identify it. */
|
|
22
26
|
export declare const subagentsExtension: (options: SubagentsExtensionOptions) => InlineExtension;
|
|
23
27
|
//# sourceMappingURL=subagents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagents.d.ts","sourceRoot":"","sources":["../../src/pi/subagents.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"subagents.d.ts","sourceRoot":"","sources":["../../src/pi/subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,cAAc,EAEd,kBAAkB,EAEnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAiB,MAAM,QAAQ,CAAC;AAG/C,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAEjB,+BAA+B,EAC/B,KAAK,gBAAgB,EACtB,MAAM,eAAe,CAAC;AAEvB,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IAC1C,QAAQ,CAAC,GAAG,EAAE,gBAAgB,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACjE,QAAQ,CAAC,WAAW,EAAE,kBAAkB,CAAC;IACzC,8EAA8E;IAC9E,QAAQ,CAAC,gBAAgB,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3F,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,iBAAiB,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CAC/E;AA8BD,+FAA+F;AAC/F,eAAO,MAAM,wBAAwB,YAAa,yBAAyB,KAAG,gBAkG7E,CAAC;AAEF,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,YAAa,yBAAyB,KAAG,eAGtE,CAAC"}
|
package/dist/pi/subagents.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { defineTool, } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import { Agent } from "@usine/core";
|
|
2
|
+
import { Agent } from "@usine/core/agent";
|
|
3
|
+
import { AgentSessionEvent, AgentSessionId, ChildSession, ChildSessionBudget, ChildSessionCount, } from "@usine/core/agent/session";
|
|
3
4
|
import { Effect, Fiber, Stream } from "effect";
|
|
4
5
|
import { Type } from "typebox";
|
|
5
6
|
import { assembleChildPrompt } from "../prompt.js";
|
|
6
|
-
import { ChildRequest, } from "../runtime.js";
|
|
7
|
+
import { ChildRequest, ChildSessionBudgetExceededError, } from "../runtime.js";
|
|
8
|
+
const TASK_EXCERPT_CHARACTERS = 160;
|
|
9
|
+
const taskExcerpt = (task) => {
|
|
10
|
+
const collapsed = task.replace(/\s+/gu, " ").trim();
|
|
11
|
+
return collapsed.length > TASK_EXCERPT_CHARACTERS
|
|
12
|
+
? `${collapsed.slice(0, TASK_EXCERPT_CHARACTERS)}…`
|
|
13
|
+
: collapsed;
|
|
14
|
+
};
|
|
7
15
|
const interrupted = (signal, sessionId) => signal === undefined
|
|
8
16
|
? Effect.logWarning("Pi supplied no abort signal; the child outlives only its scope", {
|
|
9
17
|
sessionId,
|
|
@@ -16,9 +24,69 @@ const interrupted = (signal, sessionId) => signal === undefined
|
|
|
16
24
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
17
25
|
return Effect.sync(() => signal.removeEventListener("abort", onAbort));
|
|
18
26
|
});
|
|
19
|
-
/**
|
|
27
|
+
/** Builds the subagents extension; its single tool creates first-level child sessions only. */
|
|
20
28
|
export const createSubagentsExtension = (options) => {
|
|
21
29
|
let childNumber = 0;
|
|
30
|
+
const spawn = Effect.fn("Subagents.spawn")(function* (attemptedChildren, task, signal, onUpdate) {
|
|
31
|
+
const excerpt = taskExcerpt(task);
|
|
32
|
+
yield* Effect.annotateCurrentSpan({
|
|
33
|
+
attemptedChildren,
|
|
34
|
+
maxChildren: options.maxChildren,
|
|
35
|
+
parentSessionId: options.parentId,
|
|
36
|
+
});
|
|
37
|
+
if (attemptedChildren > options.maxChildren) {
|
|
38
|
+
const error = new ChildSessionBudgetExceededError({
|
|
39
|
+
attemptedChildren,
|
|
40
|
+
maxChildren: options.maxChildren,
|
|
41
|
+
message: `Attempt tried to spawn child ${attemptedChildren} after reaching its ${options.maxChildren}-child budget`,
|
|
42
|
+
});
|
|
43
|
+
yield* Effect.logWarning("Child session budget exceeded", {
|
|
44
|
+
attemptedChildren,
|
|
45
|
+
maxChildren: options.maxChildren,
|
|
46
|
+
parentSessionId: options.parentId,
|
|
47
|
+
taskExcerpt: excerpt,
|
|
48
|
+
});
|
|
49
|
+
yield* options.onBudgetExceeded(error);
|
|
50
|
+
return yield* error;
|
|
51
|
+
}
|
|
52
|
+
const session = new ChildSession({
|
|
53
|
+
id: AgentSessionId.make(`${options.parentId}:child:${attemptedChildren}`),
|
|
54
|
+
parentId: options.parentId,
|
|
55
|
+
agent: options.agent.name,
|
|
56
|
+
brain: options.agent.brain,
|
|
57
|
+
});
|
|
58
|
+
const request = new ChildRequest({
|
|
59
|
+
session,
|
|
60
|
+
cwd: options.cwd,
|
|
61
|
+
prompt: assembleChildPrompt({
|
|
62
|
+
agent: options.agent.name,
|
|
63
|
+
persona: options.agent.persona,
|
|
64
|
+
task,
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
yield* Effect.annotateCurrentSpan({
|
|
68
|
+
agent: request.session.agent,
|
|
69
|
+
sessionId: request.session.id,
|
|
70
|
+
});
|
|
71
|
+
yield* Effect.logInfo("Spawning child session", {
|
|
72
|
+
attemptedChildren,
|
|
73
|
+
maxChildren: options.maxChildren,
|
|
74
|
+
taskExcerpt: excerpt,
|
|
75
|
+
});
|
|
76
|
+
const child = yield* options.backend.launch(request);
|
|
77
|
+
const forward = yield* child.events.pipe(Stream.runForEach(options.emit), Effect.forkScoped);
|
|
78
|
+
const result = yield* Effect.raceFirst(child.result, interrupted(signal, request.session.id).pipe(Effect.andThen(child.interrupt), Effect.andThen(Effect.interrupt)));
|
|
79
|
+
yield* Fiber.join(forward);
|
|
80
|
+
yield* Effect.logInfo("Child session returned to Pi parent", {
|
|
81
|
+
sessionId: request.session.id,
|
|
82
|
+
});
|
|
83
|
+
const report = {
|
|
84
|
+
content: [{ type: "text", text: result.message }],
|
|
85
|
+
details: { childSessionId: request.session.id },
|
|
86
|
+
};
|
|
87
|
+
onUpdate?.(report);
|
|
88
|
+
return report;
|
|
89
|
+
}, Effect.scoped);
|
|
22
90
|
return (pi) => {
|
|
23
91
|
pi.registerTool(defineTool({
|
|
24
92
|
name: "subagent",
|
|
@@ -32,50 +100,12 @@ export const createSubagentsExtension = (options) => {
|
|
|
32
100
|
executionMode: "parallel",
|
|
33
101
|
execute: (_toolCallId, params, signal, onUpdate) => {
|
|
34
102
|
childNumber += 1;
|
|
35
|
-
|
|
36
|
-
id: Agent.SessionId.make(`${options.parentId}:child:${childNumber}`),
|
|
37
|
-
parentId: options.parentId,
|
|
38
|
-
agent: options.agent.name,
|
|
39
|
-
brain: options.agent.brain,
|
|
40
|
-
});
|
|
41
|
-
const request = new ChildRequest({
|
|
42
|
-
session,
|
|
43
|
-
cwd: options.cwd,
|
|
44
|
-
prompt: assembleChildPrompt({
|
|
45
|
-
agent: options.agent.name,
|
|
46
|
-
persona: options.agent.persona,
|
|
47
|
-
task: params.task,
|
|
48
|
-
}),
|
|
49
|
-
});
|
|
50
|
-
const program = Effect.scoped(Effect.gen(function* () {
|
|
51
|
-
yield* Effect.annotateCurrentSpan({
|
|
52
|
-
agent: request.session.agent,
|
|
53
|
-
parentSessionId: request.session.parentId,
|
|
54
|
-
sessionId: request.session.id,
|
|
55
|
-
});
|
|
56
|
-
yield* Effect.logInfo("Delegating task to child session");
|
|
57
|
-
const child = yield* options.backend.launch(request);
|
|
58
|
-
const forward = yield* child.events.pipe(Stream.runForEach(options.emit), Effect.forkScoped);
|
|
59
|
-
const result = yield* Effect.raceFirst(child.result, interrupted(signal, request.session.id).pipe(Effect.andThen(child.interrupt), Effect.andThen(Effect.interrupt)));
|
|
60
|
-
yield* Fiber.join(forward);
|
|
61
|
-
yield* Effect.logInfo("Child session returned to Pi parent", {
|
|
62
|
-
sessionId: request.session.id,
|
|
63
|
-
});
|
|
64
|
-
onUpdate?.({
|
|
65
|
-
content: [{ type: "text", text: result.message }],
|
|
66
|
-
details: { childSessionId: session.id },
|
|
67
|
-
});
|
|
68
|
-
return {
|
|
69
|
-
content: [{ type: "text", text: result.message }],
|
|
70
|
-
details: { childSessionId: session.id },
|
|
71
|
-
};
|
|
72
|
-
}));
|
|
73
|
-
return options.run(program);
|
|
103
|
+
return options.run(spawn(ChildSessionCount.make(childNumber), params.task, signal, onUpdate));
|
|
74
104
|
},
|
|
75
105
|
}));
|
|
76
106
|
};
|
|
77
107
|
};
|
|
78
|
-
/**
|
|
108
|
+
/** Names the extension so Pi startup diagnostics can identify it. */
|
|
79
109
|
export const subagentsExtension = (options) => ({
|
|
80
110
|
name: "usine-subagents",
|
|
81
111
|
factory: createSubagentsExtension(options),
|
package/dist/pi/subagents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subagents.js","sourceRoot":"","sources":["../../src/pi/subagents.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"subagents.js","sourceRoot":"","sources":["../../src/pi/subagents.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,GAGX,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAGL,YAAY,EACZ,+BAA+B,GAEhC,MAAM,eAAe,CAAC;AAoBvB,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE;IAC3C,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,OAAO,SAAS,CAAC,MAAM,GAAG,uBAAuB;QAC/C,CAAC,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE,uBAAuB,CAAC,GAAG;QACnD,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,WAAW,GAAG,CAClB,MAA+B,EAC/B,SAAyB,EACJ,EAAE,CACvB,MAAM,KAAK,SAAS;IAClB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,gEA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D;YACpE,gBAAgB,EAAE;gBAChB,iFAAiF;aAClF;YACD,UAAU,EAAE,IAAI,CAAC,MAAM,CACrB,EAAE,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,EAAE,EACvC,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAChC;YACD,aAAa,EAAE,UAAU;YACzB,OAAO,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;gBACjD,WAAW,IAAI,CAAC,CAAC;gBACjB,OAAO,OAAO,CAAC,GAAG,CAChB,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,CAC1E,CAAC;YACJ,CAAC;SACF,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,OAAkC,EAAmB,EAAE,CAAC,CAAC;IAC1F,IAAI,EAAE,iBAAiB;IACvB,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC;CAC3C,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Effort } from "@usine/core/agent/brain";
|
|
2
|
+
export interface ThinkingCapableModel {
|
|
3
|
+
readonly reasoning: boolean;
|
|
4
|
+
readonly thinkingLevelMap?: Partial<Record<Effort, string | null>> | undefined;
|
|
5
|
+
}
|
|
6
|
+
/** The thinking levels a model supports; the SDK clamps to this set without exposing it. */
|
|
7
|
+
export declare const supportedThinkingLevels: (model: ThinkingCapableModel) => ReadonlyArray<Effort>;
|
|
8
|
+
//# sourceMappingURL=thinking.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking.d.ts","sourceRoot":"","sources":["../../src/pi/thinking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAW,MAAM,yBAAyB,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CAChF;AAED,4FAA4F;AAC5F,eAAO,MAAM,uBAAuB,UAAW,oBAAoB,KAAG,aAAa,CAAC,MAAM,CAQzF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effort, EFFORTS } from "@usine/core/agent/brain";
|
|
2
|
+
/** The thinking levels a model supports; the SDK clamps to this set without exposing it. */
|
|
3
|
+
export const supportedThinkingLevels = (model) => {
|
|
4
|
+
if (!model.reasoning)
|
|
5
|
+
return ["off"];
|
|
6
|
+
return EFFORTS.filter((level) => {
|
|
7
|
+
const mapped = model.thinkingLevelMap?.[level];
|
|
8
|
+
if (mapped === null)
|
|
9
|
+
return false;
|
|
10
|
+
if (level === "xhigh" || level === "max")
|
|
11
|
+
return mapped !== undefined;
|
|
12
|
+
return true;
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=thinking.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thinking.js","sourceRoot":"","sources":["../../src/pi/thinking.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAO1D,4FAA4F;AAC5F,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAA2B,EAAyB,EAAE;IAC5F,IAAI,CAAC,KAAK,CAAC,SAAS;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IACrC,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE;QAC9B,MAAM,MAAM,GAAG,KAAK,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;QAC/C,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QAClC,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,KAAK;YAAE,OAAO,MAAM,KAAK,SAAS,CAAC;QACtE,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { ChildProcessSpawner } from "effect/unstable/process";
|
|
4
|
+
import { SessionOperationError } from "../runtime.ts";
|
|
5
|
+
/** Runs a bounded readiness command without retaining its potentially sensitive diagnostics. */
|
|
6
|
+
export declare const probeCommand: (harness: "claude" | "codex" | "pi", capability: "binary" | "login" | "version", command: string, args: readonly string[]) => Effect.Effect<string, HarnessUnavailableError | SessionOperationError, ChildProcessSpawner.ChildProcessSpawner>;
|
|
7
|
+
//# sourceMappingURL=command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.d.ts","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAA0B,MAAM,8BAA8B,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAgB,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD,gGAAgG;AAChG,eAAO,MAAM,YAAY,+OAmDvB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
2
|
+
import { Effect, Option, Stream } from "effect";
|
|
3
|
+
import { ChildProcess, ChildProcessSpawner } from "effect/unstable/process";
|
|
4
|
+
import { homedir } from "node:os";
|
|
5
|
+
import { SessionOperationError } from "../runtime.js";
|
|
6
|
+
/** Runs a bounded readiness command without retaining its potentially sensitive diagnostics. */
|
|
7
|
+
export const probeCommand = Effect.fn("HarnessPreflight.command")(function* (harness, capability, command, args) {
|
|
8
|
+
yield* Effect.annotateCurrentSpan({ harness, capability });
|
|
9
|
+
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
|
|
10
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
11
|
+
const handle = yield* spawner.spawn(ChildProcess.make(command, args, {
|
|
12
|
+
cwd: homedir(),
|
|
13
|
+
detached: false,
|
|
14
|
+
forceKillAfter: "2 seconds",
|
|
15
|
+
}));
|
|
16
|
+
const [stdout, , exitCode] = yield* Effect.all([
|
|
17
|
+
handle.stdout.pipe(Stream.decodeText(), Stream.mkString),
|
|
18
|
+
handle.stderr.pipe(Stream.runDrain),
|
|
19
|
+
handle.exitCode,
|
|
20
|
+
], { concurrency: "unbounded" });
|
|
21
|
+
if (exitCode !== 0)
|
|
22
|
+
return yield* new HarnessUnavailableError({
|
|
23
|
+
harness,
|
|
24
|
+
capability,
|
|
25
|
+
message: `${command} ${args.join(" ")} failed; check the Worker's ${harness} installation and login`,
|
|
26
|
+
});
|
|
27
|
+
return stdout.trim();
|
|
28
|
+
})).pipe(Effect.timeout("30 seconds"), Effect.catchTags({
|
|
29
|
+
PlatformError: () => new HarnessUnavailableError({
|
|
30
|
+
harness,
|
|
31
|
+
capability,
|
|
32
|
+
message: `Worker cannot execute ${command}`,
|
|
33
|
+
}),
|
|
34
|
+
TimeoutError: (cause) => new SessionOperationError({
|
|
35
|
+
operation: "launch",
|
|
36
|
+
sessionId: Option.none(),
|
|
37
|
+
message: `${command} readiness check timed out`,
|
|
38
|
+
cause,
|
|
39
|
+
}),
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../src/preflight/command.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,u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WAAW,EAAE,CAC7B,CAAC;QACF,IAAI,QAAQ,KAAK,CAAC;YAChB,OAAO,KAAK,CAAC,CAAC,IAAI,uBAAuB,CAAC;gBACxC,OAAO;gBACP,UAAU;gBACV,OAAO,EAAE,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,+BAA+B,OAAO,yBAAyB;aACrG,CAAC,CAAC;QACL,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;IACvB,CAAC,CAAC,CACH,CAAC,IAAI,CACJ,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,EAC5B,MAAM,CAAC,SAAS,CAAC;QACf,aAAa,EAAE,GAAG,EAAE,CAClB,IAAI,uBAAuB,CAAC;YAC1B,OAAO;YACP,UAAU;YACV,OAAO,EAAE,yBAAyB,OAAO,EAAE;SAC5C,CAAC;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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BrainSpec } from "@usine/core/agent/brain";
|
|
2
|
+
import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
3
|
+
import { Effect } from "effect";
|
|
4
|
+
import { SessionOperationError } from "../runtime.ts";
|
|
5
|
+
import { CodexAppServer } from "../pi/codex/app-server.ts";
|
|
6
|
+
import { PiSdk } from "../pi/sdk.ts";
|
|
7
|
+
/** Baseline Codex CLI version used by the pinned app-server protocol conformance gate. */
|
|
8
|
+
export declare const CODEX_CLI_VERSION = "0.144.0";
|
|
9
|
+
/** Verifies a rostered brain through supplied process and SDK services; starts no prompt. */
|
|
10
|
+
export declare const verifyHarness: (brain: BrainSpec) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner | CodexAppServer | PiSdk>;
|
|
11
|
+
/** Checks only the requested brain using the worker user's configuration, without running a prompt or logging in. */
|
|
12
|
+
export declare const preflight: (brain: BrainSpec) => Effect.Effect<HarnessReady, HarnessUnavailableError | SessionOperationError, import("effect/unstable/process/ChildProcessSpawner").ChildProcessSpawner>;
|
|
13
|
+
//# sourceMappingURL=preflight.d.ts.map
|
|
@@ -0,0 +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,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,MAAM,EAAkB,MAAM,QAAQ,CAAC;AAEhD,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,0FAA0F;AAC1F,eAAO,MAAM,iBAAiB,YAAY,CAAC;AAW3C,6FAA6F;AAC7F,eAAO,MAAM,aAAa,wMA4GzB,CAAC;AAEF,qHAAqH;AACrH,eAAO,MAAM,SAAS,UAAW,SAAS,4JACgD,CAAC"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { HarnessReady, HarnessUnavailableError } from "@usine/core/agent/capability";
|
|
2
|
+
import { Effect, Option, Schema } from "effect";
|
|
3
|
+
import { homedir } from "node:os";
|
|
4
|
+
import { SessionOperationError, WorkingDirectory } from "../runtime.js";
|
|
5
|
+
import { CodexAppServer, codexAppServerLive } from "../pi/codex/app-server.js";
|
|
6
|
+
import { initializeCodex, verifyCodexAccount } from "../pi/codex/account.js";
|
|
7
|
+
import { PiSdk, piSdkLive, usePiStart } from "../pi/sdk.js";
|
|
8
|
+
import { probeCommand } from "./command.js";
|
|
9
|
+
/** Baseline Codex CLI version used by the pinned app-server protocol conformance gate. */
|
|
10
|
+
export const CODEX_CLI_VERSION = "0.144.0";
|
|
11
|
+
// Additional exact builds require generated-type review and the live contracts.
|
|
12
|
+
const supportedCodexVersions = [CODEX_CLI_VERSION, "0.153.4"];
|
|
13
|
+
const ClaudeAuthentication = Schema.Struct({
|
|
14
|
+
loggedIn: Schema.Boolean,
|
|
15
|
+
authMethod: Schema.String,
|
|
16
|
+
apiProvider: Schema.String,
|
|
17
|
+
});
|
|
18
|
+
/** Verifies a rostered brain through supplied process and SDK services; starts no prompt. */
|
|
19
|
+
export const verifyHarness = Effect.fn("HarnessPreflight.verify")(function* (brain) {
|
|
20
|
+
yield* Effect.annotateCurrentSpan({ harness: brain.harness, model: brain.model });
|
|
21
|
+
const loginError = (message) => new HarnessUnavailableError({
|
|
22
|
+
harness: brain.harness,
|
|
23
|
+
capability: "login",
|
|
24
|
+
message,
|
|
25
|
+
});
|
|
26
|
+
switch (brain.harness) {
|
|
27
|
+
case "codex": {
|
|
28
|
+
const version = yield* probeCommand("codex", "binary", "codex", ["--version"]);
|
|
29
|
+
if (!supportedCodexVersions.some((supported) => version === `codex-cli ${supported}`))
|
|
30
|
+
return yield* new HarnessUnavailableError({
|
|
31
|
+
harness: "codex",
|
|
32
|
+
capability: "version",
|
|
33
|
+
message: `Worker has ${/^codex-cli [0-9]+\.[0-9]+\.[0-9]+$/u.test(version) ? version : "an unrecognized Codex version"}; supported Codex CLI versions: ${supportedCodexVersions.join(", ")}`,
|
|
34
|
+
});
|
|
35
|
+
yield* Effect.scoped(Effect.gen(function* () {
|
|
36
|
+
const server = yield* CodexAppServer;
|
|
37
|
+
const connection = yield* server.open({
|
|
38
|
+
cwd: WorkingDirectory.make(homedir()),
|
|
39
|
+
sessionId: Option.none(),
|
|
40
|
+
});
|
|
41
|
+
yield* initializeCodex(connection);
|
|
42
|
+
yield* verifyCodexAccount(connection, brain.model);
|
|
43
|
+
})).pipe(Effect.catchTag("PoolUnavailableError", (error) => loginError(error.message)));
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case "claude": {
|
|
47
|
+
yield* probeCommand("claude", "binary", "claude", ["--version"]);
|
|
48
|
+
const response = yield* probeCommand("claude", "login", "claude", [
|
|
49
|
+
"auth",
|
|
50
|
+
"status",
|
|
51
|
+
"--json",
|
|
52
|
+
]);
|
|
53
|
+
const auth = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(ClaudeAuthentication))(response).pipe(Effect.mapError(() => loginError("Claude returned an unrecognized login status")));
|
|
54
|
+
if (!auth.loggedIn || auth.authMethod !== "claude.ai" || auth.apiProvider !== "firstParty")
|
|
55
|
+
return yield* loginError("Claude requires a subscription login; run claude auth login on the Worker");
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
case "pi": {
|
|
59
|
+
// Pi is the SDK installed with this run host, not a separate CLI binary.
|
|
60
|
+
const sdk = yield* PiSdk;
|
|
61
|
+
yield* usePiStart((signal) => sdk.start({
|
|
62
|
+
cwd: homedir(),
|
|
63
|
+
extensions: [],
|
|
64
|
+
model: Option.some(brain.model),
|
|
65
|
+
signal,
|
|
66
|
+
thinkingLevel: brain.effort,
|
|
67
|
+
toolMode: "repository",
|
|
68
|
+
}), (cause) => new SessionOperationError({
|
|
69
|
+
operation: "launch",
|
|
70
|
+
sessionId: Option.none(),
|
|
71
|
+
message: `Pi could not check authentication for ${brain.model}`,
|
|
72
|
+
cause,
|
|
73
|
+
}), (acquired) => Effect.gen(function* () {
|
|
74
|
+
const result = acquired.result;
|
|
75
|
+
yield* Effect.sync(acquired.dispose);
|
|
76
|
+
if (result._tag !== "Started" || result.pool !== "apiKeys")
|
|
77
|
+
return yield* loginError(`Pi child model ${brain.model} requires an available model, supported effort, and API-key authentication`);
|
|
78
|
+
}));
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
yield* Effect.logInfo("Worker harness verified", {
|
|
83
|
+
harness: brain.harness,
|
|
84
|
+
model: brain.model,
|
|
85
|
+
});
|
|
86
|
+
return new HarnessReady({ harness: brain.harness });
|
|
87
|
+
}, (effect, brain) => effect.pipe(Effect.timeout("60 seconds"), Effect.catchTag("TimeoutError", (cause) => new SessionOperationError({
|
|
88
|
+
operation: "launch",
|
|
89
|
+
sessionId: Option.none(),
|
|
90
|
+
message: `${brain.harness} readiness check timed out`,
|
|
91
|
+
cause,
|
|
92
|
+
})), Effect.tapError((error) => Effect.logError("Worker harness preflight failed", {
|
|
93
|
+
harness: brain.harness,
|
|
94
|
+
model: brain.model,
|
|
95
|
+
errorTag: error._tag,
|
|
96
|
+
message: error.message,
|
|
97
|
+
}))));
|
|
98
|
+
/** Checks only the requested brain using the worker user's configuration, without running a prompt or logging in. */
|
|
99
|
+
export const preflight = (brain) => verifyHarness(brain).pipe(Effect.provide(codexAppServerLive), Effect.provide(piSdkLive));
|
|
100
|
+
//# sourceMappingURL=preflight.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preflight.js","sourceRoot":"","sources":["../../src/preflight/preflight.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,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,YA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|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentPersona, AgentName } from "@usine/core/agent";
|
|
2
|
+
import type { AttemptTask } from "@usine/core/attempt";
|
|
3
|
+
import type { RepositoryName } from "@usine/core/repository";
|
|
2
4
|
import type { Schema } from "effect";
|
|
5
|
+
/** The recorded trigger context, Agent instructions, and effective task presented to the parent. */
|
|
3
6
|
export interface PromptParts {
|
|
4
|
-
readonly repository:
|
|
7
|
+
readonly repository: RepositoryName;
|
|
5
8
|
readonly payload: Schema.Json;
|
|
6
|
-
readonly agent:
|
|
7
|
-
readonly persona:
|
|
8
|
-
readonly task:
|
|
9
|
+
readonly agent: AgentName;
|
|
10
|
+
readonly persona: AgentPersona;
|
|
11
|
+
readonly task: AttemptTask;
|
|
9
12
|
}
|
|
13
|
+
/** The Agent's standing instructions and the focused task the parent delegates to a child. */
|
|
10
14
|
export interface ChildPromptParts {
|
|
11
|
-
readonly agent:
|
|
12
|
-
readonly persona:
|
|
15
|
+
readonly agent: AgentName;
|
|
16
|
+
readonly persona: AgentPersona;
|
|
13
17
|
/** Free text authored by the parent model, not the rendered loop task. */
|
|
14
18
|
readonly task: string;
|
|
15
19
|
}
|
|
16
|
-
/**
|
|
17
|
-
export declare const githubSignature: (agent:
|
|
18
|
-
/** Builds the
|
|
20
|
+
/** The attribution line every GitHub comment or review written by an Agent ends with. */
|
|
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. */
|
|
19
23
|
export declare const assemblePrompt: (parts: PromptParts) => string;
|
|
20
|
-
/** Builds the
|
|
24
|
+
/** Builds a child's instructions from the delegated task and Agent persona, including GitHub attribution. */
|
|
21
25
|
export declare const assembleChildPrompt: (parts: ChildPromptParts) => string;
|
|
22
26
|
//# 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,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../src/prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC,oGAAoG;AACpG,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;CAC5B;AAED,8FAA8F;AAC9F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,YAAY,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,yFAAyF;AACzF,eAAO,MAAM,eAAe,UAAW,SAAS,KAAG,MAAmC,CAAC;AAYvF,gIAAgI;AAChI,eAAO,MAAM,cAAc,UAAW,WAAW,KAAG,MAoBtC,CAAC;AAEf,6GAA6G;AAC7G,eAAO,MAAM,mBAAmB,UAAW,gBAAgB,KAAG,MAWhD,CAAC"}
|
package/dist/prompt.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/** The attribution line every GitHub comment or review written by an Agent ends with. */
|
|
2
2
|
export const githubSignature = (agent) => `— usine agent: ${agent}`;
|
|
3
|
-
|
|
3
|
+
const githubInstructions = (agent) => [
|
|
4
|
+
"# GitHub identity",
|
|
5
|
+
"",
|
|
6
|
+
"All factory Agents use the same GitHub App identity, including the Agent that opened a pull request.",
|
|
7
|
+
"Submit pull request reviews with event COMMENT (gh pr review --comment), never APPROVE or REQUEST_CHANGES. Attach each review to the exact commit you reviewed.",
|
|
8
|
+
"Use the Loop's outcome labels to report findings or a passed review, and remove the opposite outcome label. A passed label does not satisfy GitHub required approvals; the operator provides any independent approval and merges.",
|
|
9
|
+
"Append this signature to every GitHub comment, issue, pull request, or review you publish:",
|
|
10
|
+
githubSignature(agent),
|
|
11
|
+
];
|
|
12
|
+
/** Builds the parent's instructions from the saved payload, effective task, and Agent persona, including GitHub attribution. */
|
|
4
13
|
export const assemblePrompt = (parts) => [
|
|
5
14
|
"# Run context",
|
|
6
15
|
"",
|
|
@@ -19,12 +28,9 @@ export const assemblePrompt = (parts) => [
|
|
|
19
28
|
"",
|
|
20
29
|
parts.task,
|
|
21
30
|
"",
|
|
22
|
-
|
|
23
|
-
"",
|
|
24
|
-
"Append this signature to every GitHub comment, issue, or pull request you publish:",
|
|
25
|
-
githubSignature(parts.agent),
|
|
31
|
+
...githubInstructions(parts.agent),
|
|
26
32
|
].join("\n");
|
|
27
|
-
/** Builds the
|
|
33
|
+
/** Builds a child's instructions from the delegated task and Agent persona, including GitHub attribution. */
|
|
28
34
|
export const assembleChildPrompt = (parts) => [
|
|
29
35
|
"# Agent persona",
|
|
30
36
|
"",
|
|
@@ -34,9 +40,6 @@ export const assembleChildPrompt = (parts) => [
|
|
|
34
40
|
"",
|
|
35
41
|
parts.task,
|
|
36
42
|
"",
|
|
37
|
-
|
|
38
|
-
"",
|
|
39
|
-
"Append this signature to every GitHub comment, issue, or pull request you publish:",
|
|
40
|
-
githubSignature(parts.agent),
|
|
43
|
+
...githubInstructions(parts.agent),
|
|
41
44
|
].join("\n");
|
|
42
45
|
//# 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":"AAsBA,yFAAyF;AACzF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAgB,EAAU,EAAE,CAAC,kBAAkB,KAAK,EAAE,CAAC;AAEvF,MAAM,kBAAkB,GAAG,CAAC,KAAgB,EAAyB,EAAE,CAAC;IACtE,mBAAmB;IACnB,EAAE;IACF,sGAAsG;IACtG,iKAAiK;IACjK,mOAAmO;IACnO,4FAA4F;IAC5F,eAAe,CAAC,KAAK,CAAC;CACvB,CAAC;AAEF,gIAAgI;AAChI,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAkB,EAAU,EAAE,CAC3D;IACE,eAAe;IACf,EAAE;IACF,eAAe,KAAK,CAAC,UAAU,EAAE;IACjC,EAAE;IACF,mBAAmB;IACnB,SAAS;IACT,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IAC3C,KAAK;IACL,EAAE;IACF,iBAAiB;IACjB,EAAE;IACF,KAAK,CAAC,OAAO;IACb,EAAE;IACF,QAAQ;IACR,EAAE;IACF,KAAK,CAAC,IAAI;IACV,EAAE;IACF,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;CACnC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEf,6GAA6G;AAC7G,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAuB,EAAU,EAAE,CACrE;IACE,iBAAiB;IACjB,EAAE;IACF,KAAK,CAAC,OAAO;IACb,EAAE;IACF,kBAAkB;IAClB,EAAE;IACF,KAAK,CAAC,IAAI;IACV,EAAE;IACF,GAAG,kBAAkB,CAAC,KAAK,CAAC,KAAK,CAAC;CACnC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC"}
|