@duetso/agent 0.3.8 → 0.3.10
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 +6 -2
- package/dist/package.json +3 -3
- package/dist/src/memory/embedding.d.ts.map +1 -1
- package/dist/src/memory/embedding.js +4 -6
- package/dist/src/memory/embedding.js.map +1 -1
- package/dist/src/model-resolution/duet-gateway.d.ts +10 -0
- package/dist/src/model-resolution/duet-gateway.d.ts.map +1 -1
- package/dist/src/model-resolution/duet-gateway.js +19 -6
- package/dist/src/model-resolution/duet-gateway.js.map +1 -1
- package/dist/src/model-resolution/model-gateway.d.ts.map +1 -1
- package/dist/src/model-resolution/model-gateway.js +12 -2
- package/dist/src/model-resolution/model-gateway.js.map +1 -1
- package/dist/src/turn-runner/built-in-skills.d.ts.map +1 -1
- package/dist/src/turn-runner/built-in-skills.js +141 -2
- package/dist/src/turn-runner/built-in-skills.js.map +1 -1
- package/dist/src/turn-runner/prompts.d.ts +10 -0
- package/dist/src/turn-runner/prompts.d.ts.map +1 -1
- package/dist/src/turn-runner/prompts.js +23 -2
- package/dist/src/turn-runner/prompts.js.map +1 -1
- package/dist/src/turn-runner/turn-runner.d.ts +30 -0
- package/dist/src/turn-runner/turn-runner.d.ts.map +1 -1
- package/dist/src/turn-runner/turn-runner.js +82 -22
- package/dist/src/turn-runner/turn-runner.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -69,17 +69,19 @@ Memory and compaction are the same primitive: observational memory _is_ how cont
|
|
|
69
69
|
|
|
70
70
|
### Relays: keep the agent working until the job is done
|
|
71
71
|
|
|
72
|
-
A relay is how duet-agent stays on task across hours, days, or months. Under the hood it's a state machine — but the runner agent, not a config file, picks the next transition every turn. Enough structure to route long work; not so much that the agent is locked into a path. Each state is one of
|
|
72
|
+
A relay is how duet-agent stays on task across hours, days, or months. Under the hood it's a state machine — but the runner agent, not a config file, picks the next transition every turn. Enough structure to route long work; not so much that the agent is locked into a path. Each state is one of six kinds:
|
|
73
73
|
|
|
74
74
|
- **agent** — a sub-agent with a prompt, optional system prompt, and optional skill allowlist.
|
|
75
75
|
- **script** — shell out to `bash`, `curl`, a CLI. Anything with an API is a script state.
|
|
76
76
|
- **poll** — recurring check on an external signal (inbox, build status, webhook).
|
|
77
77
|
- **timer** — a pure delay until a wall-clock time, no script attached.
|
|
78
|
+
- **park** — the machine runs nothing while the main agent owns the next move: a human gate, or work it does itself. A park schedules no wake, so the runner spends one reminder pass before a turn would end parked — waiting for a human is legitimate, forgetting to transition is not.
|
|
78
79
|
- **terminal** — record a business outcome: `completed`, `cancelled`, `failed`.
|
|
79
80
|
|
|
80
81
|
```mermaid
|
|
81
82
|
flowchart LR
|
|
82
83
|
A([agent]) --> S([script]) --> P([poll]) --> Tm([timer]) --> T([terminal])
|
|
84
|
+
A --> Pk([park]) --> A
|
|
83
85
|
```
|
|
84
86
|
|
|
85
87
|
That's the whole vocabulary. Email, GitHub, Calendly, CRM — none of them need first-class engine concepts; they're shell scripts. Relays can start in the middle ("I already emailed them, just wait for a reply") because the runner agent reads context, not a workflow ID.
|
|
@@ -604,7 +606,9 @@ As a final safety net for on-disk state, `TurnRunner` also caps the size of ever
|
|
|
604
606
|
|
|
605
607
|
## Skills
|
|
606
608
|
|
|
607
|
-
Skills are loaded from `<cwd>/.duet/skills`, `<cwd>/.agents/skills`, `~/.duet/skills`, and `~/.agents/skills` by default, using `@earendil-works/pi-coding-agent`'s skill loader. The
|
|
609
|
+
Skills are loaded from `<cwd>/.duet/skills`, `<cwd>/.agents/skills`, `~/.duet/skills`, and `~/.agents/skills` by default, using `@earendil-works/pi-coding-agent`'s skill loader. The system prompt advertises metadata only — name, path, description — so the prompt cost of installing a skill stays flat no matter how long its SKILL.md is. Full instructions load on demand: typing `/name` expands the whole body inline for that turn, and the model can otherwise read the SKILL.md at the advertised path. A skill with `disableModelInvocation` is not advertised at all, so it activates only when something names it explicitly.
|
|
610
|
+
|
|
611
|
+
A few skills ship with the package (`/relay`, `/goal`; `duet skills` lists them alongside your own). They are merged into discovery like any on-disk skill, and a same-named skill in any discovery root shadows them — a built-in is a starting point you can replace, not fixed behavior.
|
|
608
612
|
|
|
609
613
|
After `start`, the runner exposes what it discovered:
|
|
610
614
|
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duetso/agent",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "An opinionated full-stack agent turn runner with native memories, interrupts, and multi-agent orchestration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -43,10 +43,10 @@
|
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"setup": "bash scripts/setup-docker.sh",
|
|
46
|
-
"build": "tsc && bun build src/memory/store/index.ts --target node --format esm --outfile dist/src/memory-store.js",
|
|
46
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.json && bun build src/memory/store/index.ts --target node --format esm --outfile dist/src/memory-store.js",
|
|
47
47
|
"check-types": "tsc --noEmit",
|
|
48
48
|
"cli": "bun src/cli.ts",
|
|
49
|
-
"dev": "tsc --watch",
|
|
49
|
+
"dev": "tsc -p tsconfig.build.json --watch",
|
|
50
50
|
"eval": "docker run --rm -v \"$PWD:/src:ro\" -w /work -e HOME=/tmp/home -e DUET_TEST_IN_DOCKER=1 -e DUET_API_KEY -e ANTHROPIC_API_KEY -e OPENAI_API_KEY -e EVAL_MODEL -e EVAL_ADVISOR_THINKING -e JUDGE_MODEL -e COVERAGE_THRESHOLD oven/bun:1.3.11 sh -lc 'cp -R /src/. /work && bun install --frozen-lockfile && bun test ./evals/*.eval.ts'",
|
|
51
51
|
"format": "oxfmt --write --no-error-on-unmatched-pattern",
|
|
52
52
|
"format:check": "oxfmt --check --no-error-on-unmatched-pattern",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../../src/memory/embedding.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"embedding.d.ts","sourceRoot":"","sources":["../../../src/memory/embedding.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,4DAA4D;AAC5D,eAAO,MAAM,oBAAoB,OAAO,CAAC;AACzC,gEAAgE;AAChE,eAAO,MAAM,qBAAqB,MAAM,CAAC;AACzC,2EAA2E;AAC3E,eAAO,MAAM,4BAA4B,8BAA8B,CAAC;AACxE,eAAO,MAAM,wBAAwB,yBAAyB,CAAC;AAM/D;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,EAAE,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC;AAEjE,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,GAAG,SAAS,CAAC,CAAC;IAC7C;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,4BAAiC,GAAG,OAAO,CAyCzF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { DUET_TIER_HEADER, getDuetGatewayBaseUrl } from "../model-resolution/duet-gateway.js";
|
|
1
|
+
import { duetTierHeaders, getDuetGatewayBaseUrl } from "../model-resolution/duet-gateway.js";
|
|
3
2
|
/**
|
|
4
3
|
* Client for Duet gateway embeddings.
|
|
5
4
|
*
|
|
@@ -86,15 +85,14 @@ async function postBatch(options) {
|
|
|
86
85
|
let lastError;
|
|
87
86
|
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
88
87
|
try {
|
|
89
|
-
// Embeddings bypass the model layer with their own fetch, so the tier
|
|
90
|
-
// has to be stamped here too or memory traffic arrives unattributed.
|
|
91
|
-
const tier = activeDuetTier();
|
|
92
88
|
const response = await options.fetchImpl(options.url, {
|
|
93
89
|
method: "POST",
|
|
94
90
|
headers: {
|
|
95
91
|
authorization: `Bearer ${options.apiKey}`,
|
|
96
92
|
"content-type": "application/json",
|
|
97
|
-
|
|
93
|
+
// Embeddings bypass the model layer with their own fetch, so the
|
|
94
|
+
// tier claim is stamped here too.
|
|
95
|
+
...duetTierHeaders(),
|
|
98
96
|
},
|
|
99
97
|
body: JSON.stringify({ model: options.model, input: options.inputs }),
|
|
100
98
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding.js","sourceRoot":"","sources":["../../../src/memory/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"embedding.js","sourceRoot":"","sources":["../../../src/memory/embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAE7F;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,4DAA4D;AAC5D,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AACzC,gEAAgE;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AACzC,2EAA2E;AAC3E,MAAM,CAAC,MAAM,4BAA4B,GAAG,2BAA2B,CAAC;AACxE,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAE/D,MAAM,aAAa,GAAG,gBAAgB,CAAC;AACvC,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,eAAe,G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,CAAC;AAED,SAAS,qBAAqB;IAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,EAAE,IAAI,EAAE,IAAI,4BAA4B,CAAC;AACvF,CAAC;AAED,KAAK,UAAU,YAAY,CAAC,QAAkB;IAC5C,IAAI,CAAC;QACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IAC/B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,4BAA4B,CAAC;IACtC,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { type Model } from "@earendil-works/pi-ai";
|
|
2
2
|
/** Request header the product reads to attribute a gateway call to a tier. */
|
|
3
3
|
export declare const DUET_TIER_HEADER = "x-duet-tier";
|
|
4
|
+
/**
|
|
5
|
+
* The active routing tier as request headers, or undefined for a concrete pin.
|
|
6
|
+
*
|
|
7
|
+
* The Duet proxy 403s unclaimed generations for non-internal models
|
|
8
|
+
* (`tier_not_allowed`), so every transport that bills through the gateway —
|
|
9
|
+
* pi-resolved models, the AI SDK client, the embeddings fetch — spreads this
|
|
10
|
+
* claim into its request headers. Undefined rather than `{}` so call sites can
|
|
11
|
+
* keep the header key entirely absent on pinned traffic.
|
|
12
|
+
*/
|
|
13
|
+
export declare function duetTierHeaders(): Record<string, string> | undefined;
|
|
4
14
|
/**
|
|
5
15
|
* The Duet gateway proxies Vercel's AI Gateway path layout and authenticates
|
|
6
16
|
* with a `DUET_API_KEY` token scoped to a single org. Rather than ship a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duet-gateway.d.ts","sourceRoot":"","sources":["../../../src/model-resolution/duet-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQ3E,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"duet-gateway.d.ts","sourceRoot":"","sources":["../../../src/model-resolution/duet-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,KAAK,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAQ3E,8EAA8E;AAC9E,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAGpE;AAkED;;;;;;;;;;;;;GAaG;AAEH,eAAO,MAAM,wBAAwB,iBAAiB,CAAC;AACvD,eAAO,MAAM,yBAAyB,0BAA0B,CAAC;AAEjE,wBAAgB,qBAAqB,IAAI,MAAM,CAI9C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,CAenE;AAuBD,+EAA+E;AAC/E,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAY/F;AA+GD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAY7F;AA4CD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAU1E"}
|
|
@@ -4,6 +4,19 @@ import { activeDuetTier } from "../model-routing/active-tier.js";
|
|
|
4
4
|
import { connectedProviderApiKey, refreshConnectedTokenInBackground, } from "../connected-providers/tokens.js";
|
|
5
5
|
/** Request header the product reads to attribute a gateway call to a tier. */
|
|
6
6
|
export const DUET_TIER_HEADER = "x-duet-tier";
|
|
7
|
+
/**
|
|
8
|
+
* The active routing tier as request headers, or undefined for a concrete pin.
|
|
9
|
+
*
|
|
10
|
+
* The Duet proxy 403s unclaimed generations for non-internal models
|
|
11
|
+
* (`tier_not_allowed`), so every transport that bills through the gateway —
|
|
12
|
+
* pi-resolved models, the AI SDK client, the embeddings fetch — spreads this
|
|
13
|
+
* claim into its request headers. Undefined rather than `{}` so call sites can
|
|
14
|
+
* keep the header key entirely absent on pinned traffic.
|
|
15
|
+
*/
|
|
16
|
+
export function duetTierHeaders() {
|
|
17
|
+
const tier = activeDuetTier();
|
|
18
|
+
return tier === undefined ? undefined : { [DUET_TIER_HEADER]: tier };
|
|
19
|
+
}
|
|
7
20
|
const DEFAULT_DUET_GATEWAY_BASE_URL = "https://gateway.duet.so";
|
|
8
21
|
const OPENAI_MODEL_PREFIX = "openai/";
|
|
9
22
|
const VERCEL_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
|
|
@@ -96,17 +109,17 @@ export function getDuetGatewayBaseUrl() {
|
|
|
96
109
|
*/
|
|
97
110
|
export function resolveDuetGatewayModel(modelId) {
|
|
98
111
|
const upstream = resolveDuetGatewayUpstream(modelId);
|
|
99
|
-
// Every duet-gateway model is built here — parent step, classifier,
|
|
100
|
-
//
|
|
101
|
-
//
|
|
102
|
-
//
|
|
103
|
-
const
|
|
112
|
+
// Every duet-gateway model is built here — parent step, classifier, vision
|
|
113
|
+
// fallback, subagents and memory alike — so stamping the routing tier once
|
|
114
|
+
// at this seam attributes all of them without per-call-site plumbing. Never
|
|
115
|
+
// added to other transports.
|
|
116
|
+
const tierHeaders = duetTierHeaders();
|
|
104
117
|
return {
|
|
105
118
|
...upstream,
|
|
106
119
|
provider: "duet-gateway",
|
|
107
120
|
id: modelId,
|
|
108
121
|
baseUrl: getDuetGatewayBaseUrlForModel(upstream),
|
|
109
|
-
...(
|
|
122
|
+
...(tierHeaders && { headers: { ...upstream.headers, ...tierHeaders } }),
|
|
110
123
|
};
|
|
111
124
|
}
|
|
112
125
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"duet-gateway.js","sourceRoot":"","sources":["../../../src/model-resolution/duet-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAc,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EACL,uBAAuB,EACvB,iCAAiC,GAClC,MAAM,kCAAkC,CAAC;AAE1C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAC;AAE9C,MAAM,6BAA6B,GAAG,yBAAyB,CAAC;AAChE,MAAM,mBAAmB,GAAG,SAAS,CAAC;AACtC,MAAM,uBAAuB,GAAG,8BAA8B,CAAC;AAC/D,MAAM,eAAe,GAAG,2BAA2B,CAAC;AAMpD,oFAAoF;AACpF,2EAA2E;AAC3E,+EAA+E;AAC/E,4EAA4E;AAC5E,qEAAqE;AACrE,MAAM,4BAA4B,GAAG;IACnC,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;IACxB,aAAa,EAAE,SAAS;IACxB,SAAS,EAAE,OAAO;CACW,CAAC;AAEhC,MAAM,8BAA8B,GAAwC;IAC1E,oBAAoB,EAAE;QACpB,GAAG,4BAA4B;QAC/B,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE;KACjE;IACD,sBAAsB,EAAE;QACtB,GAAG,4BAA4B;QAC/B,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE;KACrE;IACD,qBAAqB,EAAE;QACrB,GAAG,4BAA4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BAAqB,CAAC,QAAgB;IACpD,IAAI,QAAQ,KAAK,cAAc,EAAE,CAAC;QAChC,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAC/C,CAAC;IACD,IAAI,qBAAqB,CAAC,QAAQ,CAAC,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,uBAAuB,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK;YAAE,iCAAiC,CAAC,QAAQ,CAAC,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,YAAY,CAAC,QAA8C,CAAC,CAAC;AACtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-gateway.d.ts","sourceRoot":"","sources":["../../../src/model-resolution/model-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAGnC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAM/C,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GACjB,UAAU,GACV,OAAO,GACP,OAAO,GACP,WAAW,GACX,UAAU,GACV,WAAW,GACX,QAAQ,GACR,eAAe,CAAC;AAEpB;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,UAAU,CAAC,OAAO,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"model-gateway.d.ts","sourceRoot":"","sources":["../../../src/model-resolution/model-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAGnC;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,iBAAiB,CAAC;AAM/C,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GACjB,UAAU,GACV,OAAO,GACP,OAAO,GACP,WAAW,GACX,UAAU,GACV,WAAW,GACX,QAAQ,GACR,eAAe,CAAC;AAEpB;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,UAAU,CAAC,OAAO,aAAa,CAAC,CA4BzE;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAazE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createGateway } from "ai";
|
|
2
|
-
import { getDuetGatewayBaseUrl } from "./duet-gateway.js";
|
|
2
|
+
import { duetTierHeaders, getDuetGatewayBaseUrl } from "./duet-gateway.js";
|
|
3
3
|
/**
|
|
4
4
|
* The `duet model` subcommand talks to models directly through the Vercel AI
|
|
5
5
|
* SDK (`ai@^7`), pointed at the Duet gateway instead of the pi harness. The
|
|
@@ -30,7 +30,17 @@ export function createDuetModelGateway() {
|
|
|
30
30
|
const upstream = duetKey || !vercelKey
|
|
31
31
|
? { baseURL: `${getDuetGatewayBaseUrl()}/v4/ai`, apiKey: process.env[DUET_API_KEY_ENV] }
|
|
32
32
|
: { baseURL: "https://ai-gateway.vercel.sh/v4/ai", apiKey: vercelKey };
|
|
33
|
-
|
|
33
|
+
// An AI SDK caller inside a routed turn — the advisor today — bills through
|
|
34
|
+
// this client rather than the pi transport, so it must carry the tier claim
|
|
35
|
+
// itself. Constructors run per call site, so the claim reads the tier
|
|
36
|
+
// current at that moment; Vercel's own gateway ignores the extra header when
|
|
37
|
+
// the fallback credential path is in use.
|
|
38
|
+
const tierHeaders = duetTierHeaders();
|
|
39
|
+
return createGateway({
|
|
40
|
+
...upstream,
|
|
41
|
+
...(tierHeaders && { headers: tierHeaders }),
|
|
42
|
+
fetch: longTimeoutFetch,
|
|
43
|
+
});
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
36
46
|
* Fetch the gateway model catalog and return a map of model id -> capability
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-gateway.js","sourceRoot":"","sources":["../../../src/model-resolution/model-gateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACnC,OAAO,EAAE,qB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AAE,KAAK,CAAC;IACb,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"built-in-skills.d.ts","sourceRoot":"","sources":["../../../src/turn-runner/built-in-skills.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAc7D,MAAM,WAAW,YAAY;IAC3B,iEAAiE;IACjE,KAAK,EAAE,KAAK,CAAC;IACb,iEAAiE;IACjE,YAAY,EAAE,MAAM,CAAC;CACtB;AAyPD;;;;GAIG;AACH,eAAO,MAAM,eAAe,EAAE,SAAS,YAAY,EAMlD,CAAC;AAMF;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAEhF;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAEpD;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,IAAI,KAAK,EAAE,CAE3C"}
|
|
@@ -27,6 +27,24 @@ const RELAY_INSTRUCTIONS = dedent `
|
|
|
27
27
|
- Only fall back to a plain answer when the request is genuinely a
|
|
28
28
|
one-shot question that cannot be expressed as a state.
|
|
29
29
|
|
|
30
|
+
## When the request is a goal, not a process
|
|
31
|
+
|
|
32
|
+
Some requests have no process to model — just an outcome that must hold
|
|
33
|
+
("get the suite green", "make this page load under a second"). Those want
|
|
34
|
+
a loop, not a pipeline: a \`park\` state where you do the work yourself,
|
|
35
|
+
an \`agent\` state holding an evaluator sub-agent that judges the result
|
|
36
|
+
against written criteria and answers \`VERDICT: complete\` or
|
|
37
|
+
\`VERDICT: incomplete\` plus the specific gaps, and a terminal you select
|
|
38
|
+
only after a pass you spot-checked. Incomplete sends the machine back to
|
|
39
|
+
the park for another round. Give the evaluator fresh context and the
|
|
40
|
+
criteria — never a summary of what you did, which only teaches it to
|
|
41
|
+
accept your account.
|
|
42
|
+
|
|
43
|
+
The built-in \`/goal\` skill is the full write-up of that loop: how to fix
|
|
44
|
+
criteria before you start, how to prompt the judge, and how to stop a loop
|
|
45
|
+
that will not converge. Suggest \`/goal\` when the user's request is
|
|
46
|
+
shaped that way.
|
|
47
|
+
|
|
30
48
|
## Running multiple scheduled tasks (cron-style) in ONE state machine
|
|
31
49
|
|
|
32
50
|
Only one state machine can be active per session, so when the user wants
|
|
@@ -91,7 +109,124 @@ const RELAY_INSTRUCTIONS = dedent `
|
|
|
91
109
|
state).
|
|
92
110
|
`;
|
|
93
111
|
const RELAY_DESCRIPTION = "Run durable, multi-step, or recurring work as a state machine of sub-agent, script, poll, and timer states so the work survives session boundaries and progress stays visible to the user.";
|
|
94
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Body of the built-in `/goal` skill. A reference pattern, not a prebuilt
|
|
114
|
+
* machine: it teaches the agent to build its own work/evaluate loop so
|
|
115
|
+
* the definition, criteria, and state names fit the goal at hand.
|
|
116
|
+
*/
|
|
117
|
+
const GOAL_INSTRUCTIONS = dedent `
|
|
118
|
+
The user gave you a goal to drive to completion, not a task to perform
|
|
119
|
+
once. Build a state machine whose loop is: you do the work, an
|
|
120
|
+
independent sub-agent judges whether the goal is actually met, and the
|
|
121
|
+
machine terminates only when that judge says yes.
|
|
122
|
+
|
|
123
|
+
This is a pattern to instantiate with
|
|
124
|
+
\`create_state_machine_definition\`, not a fixed machine to invoke.
|
|
125
|
+
Name the states, write the criteria, and size the loop to this goal.
|
|
126
|
+
|
|
127
|
+
## The two states (plus a terminal)
|
|
128
|
+
|
|
129
|
+
1. **work** — a \`park\` state. Park runs nothing itself; it records that
|
|
130
|
+
you, the main agent, own the next move, so the work happens in your own
|
|
131
|
+
turn with your own tools and full context. Start here, take a complete
|
|
132
|
+
pass at the goal, then select \`evaluate\`. This is also where the
|
|
133
|
+
machine sits whenever a turn ends mid-goal — out of rounds, or waiting
|
|
134
|
+
on the user — so the next turn resumes into the work phase. (If the
|
|
135
|
+
work is better delegated — heavy, isolated, or parallelizable — make
|
|
136
|
+
this an \`agent\` state instead; the loop is identical.)
|
|
137
|
+
2. **evaluate** — an \`agent\` state. A sub-agent that judges, and only
|
|
138
|
+
judges. It never does the work, and it never fixes what it finds.
|
|
139
|
+
3. **goal_met** — a \`terminal\` with status \`"completed"\`, selected
|
|
140
|
+
only on a verified pass.
|
|
141
|
+
|
|
142
|
+
\`\`\`json
|
|
143
|
+
{
|
|
144
|
+
"name": "<goal in a few words>",
|
|
145
|
+
"prompt": "Drive <the goal> to completion: work, then evaluate, until the evaluator passes.",
|
|
146
|
+
"states": [
|
|
147
|
+
{ "name": "work", "kind": "park",
|
|
148
|
+
"when": "Start here, and return here after every incomplete verdict, to do or fix the work." },
|
|
149
|
+
{ "name": "evaluate", "kind": "agent",
|
|
150
|
+
"when": "After each work pass, to judge the goal against its criteria.",
|
|
151
|
+
"prompt": "<the goal verbatim + criteria + verdict format>" },
|
|
152
|
+
{ "name": "goal_met", "kind": "terminal", "status": "completed" }
|
|
153
|
+
]
|
|
154
|
+
}
|
|
155
|
+
\`\`\`
|
|
156
|
+
|
|
157
|
+
## Criteria come first
|
|
158
|
+
|
|
159
|
+
Before creating the definition, decide what "done" means, as checks
|
|
160
|
+
someone else could run: the command that must exit 0, the file that must
|
|
161
|
+
contain X, the behavior the user must be able to observe. Subjective
|
|
162
|
+
goals ("make it feel faster", "clean this up") still need observable
|
|
163
|
+
proxies — pick them now, because an unfalsifiable criterion makes the
|
|
164
|
+
loop unterminable. If you cannot state a check for a criterion that
|
|
165
|
+
matters, ask the user before you start.
|
|
166
|
+
|
|
167
|
+
## Writing the evaluator
|
|
168
|
+
|
|
169
|
+
- **Fresh context, not forked.** Leave \`forkContext\` off. The judge
|
|
170
|
+
must grade the artifact that exists, not your account of it — your
|
|
171
|
+
narration of your own work is exactly the thing most likely to be
|
|
172
|
+
wrong.
|
|
173
|
+
- **Carry criteria, not history.** Its prompt restates the goal verbatim
|
|
174
|
+
and lists the criteria. It gets no summary of what you tried; that
|
|
175
|
+
only teaches it to accept your framing.
|
|
176
|
+
- **Make it verify.** Instruct it to read the files, run the
|
|
177
|
+
build/tests/command, and reproduce the user's scenario. A verdict
|
|
178
|
+
reached by reading a diff is a guess.
|
|
179
|
+
- **Fix the verdict shape** so the loop can branch on it:
|
|
180
|
+
- \`VERDICT: complete\` — nothing left against the criteria.
|
|
181
|
+
- \`VERDICT: incomplete\` — followed by a numbered list of gaps, each
|
|
182
|
+
naming what is wrong, where, and what would satisfy it. "Needs
|
|
183
|
+
polish" is not a gap; "src/cli/run.ts:88 still ignores --json" is.
|
|
184
|
+
- **Bias it toward finding gaps.** Tell it to look for what a skeptical
|
|
185
|
+
reviewer would reject, and to report a gap when unsure rather than
|
|
186
|
+
passing on the benefit of the doubt.
|
|
187
|
+
|
|
188
|
+
## The loop
|
|
189
|
+
|
|
190
|
+
Create the definition with \`firstState: "work"\`, then do a full work
|
|
191
|
+
pass in that same turn and select \`evaluate\` when the pass is done —
|
|
192
|
+
parking is not a reason to stop. From there:
|
|
193
|
+
|
|
194
|
+
- **incomplete** → fix every gap, then select \`evaluate\` again. A state
|
|
195
|
+
that completes hands you a pass that must end in a transition, so do the
|
|
196
|
+
fixing in that pass rather than parking first for it — you already hold
|
|
197
|
+
the gaps in your context, and nothing needs threading through state
|
|
198
|
+
input.
|
|
199
|
+
- **complete** → check one or two criteria yourself before you
|
|
200
|
+
terminate. A pass verdict is a claim like any other sub-agent output;
|
|
201
|
+
a judge can hallucinate a pass the same way a worker hallucinates a
|
|
202
|
+
finish. Then select \`goal_met\`.
|
|
203
|
+
- **blocked on the user** → this is what \`work\` is for. Select it, ask
|
|
204
|
+
your question, and end the turn; the machine holds at \`work\` and the
|
|
205
|
+
user's reply resumes the loop.
|
|
206
|
+
|
|
207
|
+
## Don't let the loop spin
|
|
208
|
+
|
|
209
|
+
- Keep the criteria fixed across rounds. Re-scoping mid-loop is how a
|
|
210
|
+
loop "passes" without the goal being met; change criteria only with
|
|
211
|
+
the user.
|
|
212
|
+
- If the same gap survives two rounds, your approach is the problem, not
|
|
213
|
+
the effort. Change approach rather than retrying harder.
|
|
214
|
+
- After a few rounds with no pass, or if the verdicts flip-flop, park at
|
|
215
|
+
\`work\` and ask the user with \`ask_user_question\` — the criteria are
|
|
216
|
+
wrong, the goal is underspecified, or the work is blocked.
|
|
217
|
+
- A goal that turns out to be unachievable ends at a \`failed\` terminal
|
|
218
|
+
with the reason recorded. That is a real outcome; an endless loop is
|
|
219
|
+
not.
|
|
220
|
+
`;
|
|
221
|
+
const GOAL_DESCRIPTION = "Drive a goal to completion with a state machine that loops your own work against an independent sub-agent evaluator, terminating only when the evaluator verifies the goal's success criteria are met.";
|
|
222
|
+
function buildBuiltIn(name, description, instructions,
|
|
223
|
+
/**
|
|
224
|
+
* Hides the skill from the advertised skill list, so it activates only when
|
|
225
|
+
* the user types `/name` or a state prompt names it. Use it for a skill whose
|
|
226
|
+
* pattern is already reachable through another skill's body: advertising both
|
|
227
|
+
* makes the model choose between two overlapping menu entries every turn.
|
|
228
|
+
*/
|
|
229
|
+
disableModelInvocation = false) {
|
|
95
230
|
const baseDir = `${BUILTIN_PATH_PREFIX}/${name}`;
|
|
96
231
|
const filePath = `${baseDir}/SKILL.md`;
|
|
97
232
|
return {
|
|
@@ -106,7 +241,7 @@ function buildBuiltIn(name, description, instructions) {
|
|
|
106
241
|
origin: "top-level",
|
|
107
242
|
baseDir,
|
|
108
243
|
}),
|
|
109
|
-
disableModelInvocation
|
|
244
|
+
disableModelInvocation,
|
|
110
245
|
},
|
|
111
246
|
instructions,
|
|
112
247
|
};
|
|
@@ -118,6 +253,10 @@ function buildBuiltIn(name, description, instructions) {
|
|
|
118
253
|
*/
|
|
119
254
|
export const BUILT_IN_SKILLS = [
|
|
120
255
|
buildBuiltIn("relay", RELAY_DESCRIPTION, RELAY_INSTRUCTIONS),
|
|
256
|
+
// User-invoked only: `/relay` carries the goal loop's shape, so the model
|
|
257
|
+
// reaches this pattern through relay rather than picking between two
|
|
258
|
+
// state-machine skills on its own.
|
|
259
|
+
buildBuiltIn("goal", GOAL_DESCRIPTION, GOAL_INSTRUCTIONS, true),
|
|
121
260
|
];
|
|
122
261
|
const BUILT_IN_BY_PATH = new Map(BUILT_IN_SKILLS.map(({ skill, instructions }) => [skill.filePath, instructions]));
|
|
123
262
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"built-in-skills.js","sourceRoot":"","sources":["../../../src/turn-runner/built-in-skills.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAS7C;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAA
|
|
1
|
+
{"version":3,"file":"built-in-skills.js","sourceRoot":"","sources":["../../../src/turn-runner/built-in-skills.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAE5E;;;;;;;;GAQG;AACH,MAAM,mBAAmB,GAAG,gBAAgB,CAAC;AAS7C;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4FhC,CAAC;AAEF,MAAM,iBAAiB,GACrB,4LAA4L,CAAC;AAE/L;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuG/B,CAAC;AAEF,MAAM,gBAAgB,GACpB,wMAAwM,CAAC;AAE3M,SAAS,YAAY,CACnB,IAAY,EACZ,WA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KAAK,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -50,6 +50,16 @@ export declare function createStateAgentSystemPromptLayer(context?: {
|
|
|
50
50
|
export declare function createForkContextReminder(): string;
|
|
51
51
|
/** Keep an ask from becoming a terminal while process-bound work is still live. */
|
|
52
52
|
export declare function withheldAskReminder(questions: readonly TurnQuestion[]): string;
|
|
53
|
+
/**
|
|
54
|
+
* Gentle last-chance reminder spent on one extra parent pass when a turn is
|
|
55
|
+
* about to end completed while the machine is still parked. A park that ends
|
|
56
|
+
* the turn is legitimate when the parent is genuinely waiting on the user, but
|
|
57
|
+
* it is also what "I forgot to select the next state" looks like — and the
|
|
58
|
+
* parent is the only one who can tell the two apart. The pass is delivered
|
|
59
|
+
* alongside the standard {@link parkNudge}, which names the parked state, so
|
|
60
|
+
* this text only has to supply the "your turn is ending" framing.
|
|
61
|
+
*/
|
|
62
|
+
export declare const PARK_END_OF_TURN_NUDGE: string;
|
|
53
63
|
/** Binding reminder attached wherever a parent turn enters or remains in a park. */
|
|
54
64
|
export declare function parkNudge(stateName: string): string;
|
|
55
65
|
export declare function createStateMachineSystemPromptLayer(input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/turn-runner/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AAI7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AAiCxE,wBAAgB,oCAAoC,CAAC,KAAK,EAAE;IAC1D,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IA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AgB,CAAC;IACzB,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IACzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;IAG5B,OAAO,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAEpC,MAAM,EAAE,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CACnC,GAAG,MAAM,CAaT;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,iCAAiC,CAAC,OAAO,CAAC,EAAE;IAC1D,UAAU,EAAE,sBAAsB,CAAC;IACnC,YAAY,EAAE,MAAM,CAAC;CACtB,GAAG,MAAM,CAaT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAMlD;AAED,mFAAmF;AACnF,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAY9E;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAMjC,CAAC;AAEH,oFAAoF;AACpF,wBAAgB,SAAS,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAQnD;AA2CD,wBAAgB,mCAAmC,CAAC,KAAK,EAAE;IACzD,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,GAAG,MAAM,CA0CT;AAED;;;;;;;;;GASG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAW5D;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oCAAoC,IAAI,MAAM,CAS7D"}
|
|
@@ -111,6 +111,22 @@ export function withheldAskReminder(questions) {
|
|
|
111
111
|
without asking.
|
|
112
112
|
`);
|
|
113
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Gentle last-chance reminder spent on one extra parent pass when a turn is
|
|
116
|
+
* about to end completed while the machine is still parked. A park that ends
|
|
117
|
+
* the turn is legitimate when the parent is genuinely waiting on the user, but
|
|
118
|
+
* it is also what "I forgot to select the next state" looks like — and the
|
|
119
|
+
* parent is the only one who can tell the two apart. The pass is delivered
|
|
120
|
+
* alongside the standard {@link parkNudge}, which names the parked state, so
|
|
121
|
+
* this text only has to supply the "your turn is ending" framing.
|
|
122
|
+
*/
|
|
123
|
+
export const PARK_END_OF_TURN_NUDGE = systemReminder(dedent `
|
|
124
|
+
<system-reminder>
|
|
125
|
+
Your turn is about to end with the state machine still parked. If you were
|
|
126
|
+
waiting on the user, that is correct — just reply and end the turn. If you
|
|
127
|
+
meant to keep going and have not selected the next state yet, select it now.
|
|
128
|
+
</system-reminder>
|
|
129
|
+
`);
|
|
114
130
|
/** Binding reminder attached wherever a parent turn enters or remains in a park. */
|
|
115
131
|
export function parkNudge(stateName) {
|
|
116
132
|
return systemReminder(dedent `
|
|
@@ -247,13 +263,18 @@ export function createSourceOfTruthSystemPromptLayer() {
|
|
|
247
263
|
].join("\n\n");
|
|
248
264
|
}
|
|
249
265
|
function createSkillsSystemPrompt(skills) {
|
|
250
|
-
|
|
266
|
+
// `disableModelInvocation` means "the model may not reach for this on its
|
|
267
|
+
// own", so such a skill is never advertised here. It stays fully usable
|
|
268
|
+
// through the paths that name it explicitly — the user typing `/name`, or a
|
|
269
|
+
// state prompt containing it — because those are invocations, not choices.
|
|
270
|
+
const advertised = skills.filter((skill) => !skill.disableModelInvocation);
|
|
271
|
+
if (advertised.length === 0) {
|
|
251
272
|
return undefined;
|
|
252
273
|
}
|
|
253
274
|
return dedent `
|
|
254
275
|
Available skills (metadata only — \`read\` the SKILL.md at the listed \`path\` to load full instructions when a skill's description matches the task at hand, or to edit the skill itself):
|
|
255
276
|
${toXML({
|
|
256
|
-
skills:
|
|
277
|
+
skills: advertised.map((skill) => ({
|
|
257
278
|
skill: {
|
|
258
279
|
_attrs: { name: skill.name, path: skill.filePath },
|
|
259
280
|
description: skill.description,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../src/turn-runner/prompts.ts"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,CAAC,CAAC;YACjC,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE;gBAClD,WAAW,EAAE,KAAK,CAAC,WAAW;aAC/B;SACF,CAAC,CAAC;KACJ,CAAC;GACH,CAAC;AACJ,CAAC"}
|
|
@@ -161,6 +161,8 @@ export declare class TurnRunner {
|
|
|
161
161
|
private readonly taskSettlementDelivery;
|
|
162
162
|
/** Coalesces same-tick settlements into one FIFO drain and one B3 notice. */
|
|
163
163
|
private settlementDeliveryQueued;
|
|
164
|
+
/** End-of-turn park nudge already spent; refreshed whenever a state runs. */
|
|
165
|
+
private parkNudged;
|
|
164
166
|
/** Monotonic root-scope suffix; each public turn owns one root scope. */
|
|
165
167
|
private nextRootScope;
|
|
166
168
|
/** Scope currently accepting state tasks. */
|
|
@@ -323,6 +325,34 @@ export declare class TurnRunner {
|
|
|
323
325
|
private runParentPass;
|
|
324
326
|
private runWakeInput;
|
|
325
327
|
private runTerminalAcknowledgmentPass;
|
|
328
|
+
/**
|
|
329
|
+
* Fold a finished continuation pass into a loop outcome: an interrupt, an ask,
|
|
330
|
+
* whatever control action the parent emitted, or the turn's completion. Every
|
|
331
|
+
* runner-owned continuation settles the same way, so they share this instead
|
|
332
|
+
* of each re-deriving the precedence between those four.
|
|
333
|
+
*/
|
|
334
|
+
private settleContinuationPass;
|
|
335
|
+
/**
|
|
336
|
+
* Spend one extra parent pass before a completed turn ends while the machine
|
|
337
|
+
* is still parked. `runParentPass` appends {@link parkNudge} on its own, so
|
|
338
|
+
* this only supplies the "your turn is ending" framing. Ending the turn again
|
|
339
|
+
* is a legitimate outcome — the pass is a nudge, not an obligation — so
|
|
340
|
+
* whatever the parent does next settles the turn normally.
|
|
341
|
+
*/
|
|
342
|
+
private runParkNudgePass;
|
|
343
|
+
/**
|
|
344
|
+
* Queue that nudge pass when a turn that succeeded is about to end with the
|
|
345
|
+
* machine parked. A park holds without scheduling any wake, so nothing else
|
|
346
|
+
* would ever resume the machine: if the parent parked and then simply forgot
|
|
347
|
+
* to transition, this is the last moment anyone can catch it. Spending the
|
|
348
|
+
* nudge once per executed state keeps a parent that legitimately waits for
|
|
349
|
+
* the user from being nagged into transitioning, while a loop that parks
|
|
350
|
+
* between real work rounds still gets a nudge each round (see
|
|
351
|
+
* {@link executePlannedWork}). Anything still pending — running work, or a
|
|
352
|
+
* scheduled wake that will resume the machine on its own — means the turn is
|
|
353
|
+
* not ending on a stalled park, so there is nothing to remind anyone about.
|
|
354
|
+
*/
|
|
355
|
+
private queueParkNudgeIfDue;
|
|
326
356
|
private runAdvisorCompletionReviewPass;
|
|
327
357
|
/**
|
|
328
358
|
* Queue a fresh parent continuation only when a completed agent-mode turn did enough work to
|