@adonis-agora/agent 0.31.0 → 0.33.1
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/CHANGELOG.md +795 -0
- package/dist/assets/spa/assets/index-DjIMQOxi.js +9 -0
- package/dist/assets/spa/index.html +1 -1
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +140 -2
- package/dist/providers/agent_provider.js.map +1 -1
- package/dist/src/agent-deps-factory.d.ts +16 -2
- package/dist/src/agent-deps-factory.d.ts.map +1 -1
- package/dist/src/agent-deps-factory.js +8 -0
- package/dist/src/agent-deps-factory.js.map +1 -1
- package/dist/src/agent-deps.d.ts +21 -1
- package/dist/src/agent-deps.d.ts.map +1 -1
- package/dist/src/agent-deps.js.map +1 -1
- package/dist/src/agent-loop.d.ts +228 -9
- package/dist/src/agent-loop.d.ts.map +1 -1
- package/dist/src/agent-loop.js +1360 -209
- package/dist/src/agent-loop.js.map +1 -1
- package/dist/src/agent-service.d.ts +27 -0
- package/dist/src/agent-service.d.ts.map +1 -1
- package/dist/src/agent-service.js +29 -0
- package/dist/src/agent-service.js.map +1 -1
- package/dist/src/ai-sdk/ai-sdk-model.d.ts.map +1 -1
- package/dist/src/ai-sdk/ai-sdk-model.js +21 -1
- package/dist/src/ai-sdk/ai-sdk-model.js.map +1 -1
- package/dist/src/client/sse.d.ts +32 -2
- package/dist/src/client/sse.d.ts.map +1 -1
- package/dist/src/client/sse.js +45 -2
- package/dist/src/client/sse.js.map +1 -1
- package/dist/src/define_config.d.ts +41 -7
- package/dist/src/define_config.d.ts.map +1 -1
- package/dist/src/define_config.js.map +1 -1
- package/dist/src/durable/agent-run-workflow.d.ts +10 -11
- package/dist/src/durable/agent-run-workflow.d.ts.map +1 -1
- package/dist/src/durable/agent-run-workflow.js +49 -21
- package/dist/src/durable/agent-run-workflow.js.map +1 -1
- package/dist/src/durable/durable-agent-runner.d.ts +3 -2
- package/dist/src/durable/durable-agent-runner.d.ts.map +1 -1
- package/dist/src/durable/durable-agent-runner.js +2 -2
- package/dist/src/durable/durable-agent-runner.js.map +1 -1
- package/dist/src/elicitation.d.ts +207 -0
- package/dist/src/elicitation.d.ts.map +1 -0
- package/dist/src/elicitation.js +315 -0
- package/dist/src/elicitation.js.map +1 -0
- package/dist/src/evals/approval-prior.d.ts +58 -0
- package/dist/src/evals/approval-prior.d.ts.map +1 -0
- package/dist/src/evals/approval-prior.js +82 -0
- package/dist/src/evals/approval-prior.js.map +1 -0
- package/dist/src/evals/evaluate.d.ts +51 -0
- package/dist/src/evals/evaluate.d.ts.map +1 -0
- package/dist/src/evals/evaluate.js +76 -0
- package/dist/src/evals/evaluate.js.map +1 -0
- package/dist/src/evals/governance-sample-source.d.ts +23 -0
- package/dist/src/evals/governance-sample-source.d.ts.map +1 -0
- package/dist/src/evals/governance-sample-source.js +93 -0
- package/dist/src/evals/governance-sample-source.js.map +1 -0
- package/dist/src/evals/in-memory-score-store.d.ts +16 -0
- package/dist/src/evals/in-memory-score-store.d.ts.map +1 -0
- package/dist/src/evals/in-memory-score-store.js +57 -0
- package/dist/src/evals/in-memory-score-store.js.map +1 -0
- package/dist/src/evals/index.d.ts +15 -0
- package/dist/src/evals/index.d.ts.map +1 -0
- package/dist/src/evals/index.js +14 -0
- package/dist/src/evals/index.js.map +1 -0
- package/dist/src/evals/judge.d.ts +30 -0
- package/dist/src/evals/judge.d.ts.map +1 -0
- package/dist/src/evals/judge.js +53 -0
- package/dist/src/evals/judge.js.map +1 -0
- package/dist/src/evals/live-scoring.d.ts +42 -0
- package/dist/src/evals/live-scoring.d.ts.map +1 -0
- package/dist/src/evals/live-scoring.js +103 -0
- package/dist/src/evals/live-scoring.js.map +1 -0
- package/dist/src/evals/sample-source.d.ts +40 -0
- package/dist/src/evals/sample-source.d.ts.map +1 -0
- package/dist/src/evals/sample-source.js +33 -0
- package/dist/src/evals/sample-source.js.map +1 -0
- package/dist/src/evals/score-store.d.ts +54 -0
- package/dist/src/evals/score-store.d.ts.map +1 -0
- package/dist/src/evals/score-store.js +2 -0
- package/dist/src/evals/score-store.js.map +1 -0
- package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts +28 -0
- package/dist/src/evals/scorers/answer-relevancy.scorer.d.ts.map +1 -0
- package/dist/src/evals/scorers/answer-relevancy.scorer.js +42 -0
- package/dist/src/evals/scorers/answer-relevancy.scorer.js.map +1 -0
- package/dist/src/evals/scorers/approval-outcome.scorer.d.ts +22 -0
- package/dist/src/evals/scorers/approval-outcome.scorer.d.ts.map +1 -0
- package/dist/src/evals/scorers/approval-outcome.scorer.js +60 -0
- package/dist/src/evals/scorers/approval-outcome.scorer.js.map +1 -0
- package/dist/src/evals/scorers/approval-risk.scorer.d.ts +28 -0
- package/dist/src/evals/scorers/approval-risk.scorer.d.ts.map +1 -0
- package/dist/src/evals/scorers/approval-risk.scorer.js +54 -0
- package/dist/src/evals/scorers/approval-risk.scorer.js.map +1 -0
- package/dist/src/evals/scorers/run-completion.scorer.d.ts +18 -0
- package/dist/src/evals/scorers/run-completion.scorer.d.ts.map +1 -0
- package/dist/src/evals/scorers/run-completion.scorer.js +55 -0
- package/dist/src/evals/scorers/run-completion.scorer.js.map +1 -0
- package/dist/src/evals/summarize.d.ts +44 -0
- package/dist/src/evals/summarize.d.ts.map +1 -0
- package/dist/src/evals/summarize.js +87 -0
- package/dist/src/evals/summarize.js.map +1 -0
- package/dist/src/evals/types.d.ts +81 -0
- package/dist/src/evals/types.d.ts.map +1 -0
- package/dist/src/evals/types.js +15 -0
- package/dist/src/evals/types.js.map +1 -0
- package/dist/src/history-window.d.ts +50 -11
- package/dist/src/history-window.d.ts.map +1 -1
- package/dist/src/history-window.js +84 -12
- package/dist/src/history-window.js.map +1 -1
- package/dist/src/index.d.ts +9 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +9 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/mcp/server.d.ts +8 -0
- package/dist/src/mcp/server.d.ts.map +1 -1
- package/dist/src/mcp/server.js +27 -1
- package/dist/src/mcp/server.js.map +1 -1
- package/dist/src/mcp-client/importer.d.ts +75 -0
- package/dist/src/mcp-client/importer.d.ts.map +1 -0
- package/dist/src/mcp-client/importer.js +161 -0
- package/dist/src/mcp-client/importer.js.map +1 -0
- package/dist/src/mcp-client/index.d.ts +9 -0
- package/dist/src/mcp-client/index.d.ts.map +1 -0
- package/dist/src/mcp-client/index.js +8 -0
- package/dist/src/mcp-client/index.js.map +1 -0
- package/dist/src/mcp-client/options.d.ts +99 -0
- package/dist/src/mcp-client/options.d.ts.map +1 -0
- package/dist/src/mcp-client/options.js +2 -0
- package/dist/src/mcp-client/options.js.map +1 -0
- package/dist/src/mcp-client/tool-input.d.ts +39 -0
- package/dist/src/mcp-client/tool-input.d.ts.map +1 -0
- package/dist/src/mcp-client/tool-input.js +61 -0
- package/dist/src/mcp-client/tool-input.js.map +1 -0
- package/dist/src/mcp-client/tool-kind.d.ts +37 -0
- package/dist/src/mcp-client/tool-kind.d.ts.map +1 -0
- package/dist/src/mcp-client/tool-kind.js +20 -0
- package/dist/src/mcp-client/tool-kind.js.map +1 -0
- package/dist/src/mcp-client/tool-name.d.ts +22 -0
- package/dist/src/mcp-client/tool-name.d.ts.map +1 -0
- package/dist/src/mcp-client/tool-name.js +35 -0
- package/dist/src/mcp-client/tool-name.js.map +1 -0
- package/dist/src/mcp-client/tool-source.d.ts +75 -0
- package/dist/src/mcp-client/tool-source.d.ts.map +1 -0
- package/dist/src/mcp-client/tool-source.js +244 -0
- package/dist/src/mcp-client/tool-source.js.map +1 -0
- package/dist/src/mcp-client/transient.d.ts +28 -0
- package/dist/src/mcp-client/transient.d.ts.map +1 -0
- package/dist/src/mcp-client/transient.js +126 -0
- package/dist/src/mcp-client/transient.js.map +1 -0
- package/dist/src/mcp-client/unsafe-regex.d.ts +23 -0
- package/dist/src/mcp-client/unsafe-regex.d.ts.map +1 -0
- package/dist/src/mcp-client/unsafe-regex.js +194 -0
- package/dist/src/mcp-client/unsafe-regex.js.map +1 -0
- package/dist/src/memory.d.ts +448 -0
- package/dist/src/memory.d.ts.map +1 -0
- package/dist/src/memory.js +338 -0
- package/dist/src/memory.js.map +1 -0
- package/dist/src/processors.d.ts +134 -0
- package/dist/src/processors.d.ts.map +1 -0
- package/dist/src/processors.js +215 -0
- package/dist/src/processors.js.map +1 -0
- package/dist/src/rag/index.d.ts +1 -1
- package/dist/src/rag/index.d.ts.map +1 -1
- package/dist/src/rag/index.js +1 -1
- package/dist/src/rag/index.js.map +1 -1
- package/dist/src/rag/pg-vector-store.d.ts +41 -0
- package/dist/src/rag/pg-vector-store.d.ts.map +1 -1
- package/dist/src/rag/pg-vector-store.js +93 -15
- package/dist/src/rag/pg-vector-store.js.map +1 -1
- package/dist/src/replay-integrity.d.ts +17 -0
- package/dist/src/replay-integrity.d.ts.map +1 -0
- package/dist/src/replay-integrity.js +19 -0
- package/dist/src/replay-integrity.js.map +1 -0
- package/dist/src/runners/inline-agent-runner.d.ts +33 -7
- package/dist/src/runners/inline-agent-runner.d.ts.map +1 -1
- package/dist/src/runners/inline-agent-runner.js +113 -27
- package/dist/src/runners/inline-agent-runner.js.map +1 -1
- package/dist/src/skills.d.ts +291 -0
- package/dist/src/skills.d.ts.map +1 -0
- package/dist/src/skills.js +0 -0
- package/dist/src/skills.js.map +1 -0
- package/dist/src/spi/agent-runner.d.ts +20 -6
- package/dist/src/spi/agent-runner.d.ts.map +1 -1
- package/dist/src/spi/agent-store.d.ts +53 -0
- package/dist/src/spi/agent-store.d.ts.map +1 -1
- package/dist/src/spi/governance-queries.d.ts +5 -0
- package/dist/src/spi/governance-queries.d.ts.map +1 -1
- package/dist/src/spi/history-window.d.ts +64 -10
- package/dist/src/spi/history-window.d.ts.map +1 -1
- package/dist/src/spi/model-provider.d.ts +18 -0
- package/dist/src/spi/model-provider.d.ts.map +1 -1
- package/dist/src/spi/processors.d.ts +161 -0
- package/dist/src/spi/processors.d.ts.map +1 -0
- package/dist/src/spi/processors.js +57 -0
- package/dist/src/spi/processors.js.map +1 -0
- package/dist/src/spi/token-stream-sink.d.ts +43 -0
- package/dist/src/spi/token-stream-sink.d.ts.map +1 -1
- package/dist/src/spi/token-stream-sink.js +17 -1
- package/dist/src/spi/token-stream-sink.js.map +1 -1
- package/dist/src/sse.d.ts +5 -2
- package/dist/src/sse.d.ts.map +1 -1
- package/dist/src/sse.js +11 -2
- package/dist/src/sse.js.map +1 -1
- package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -1
- package/dist/src/stores/lucid-governance-queries.js +3 -0
- package/dist/src/stores/lucid-governance-queries.js.map +1 -1
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +15 -0
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +11 -3
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +65 -0
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/structured-output.d.ts +57 -0
- package/dist/src/structured-output.d.ts.map +1 -0
- package/dist/src/structured-output.js +80 -0
- package/dist/src/structured-output.js.map +1 -0
- package/dist/src/testing/fake-model-provider.d.ts +8 -4
- package/dist/src/testing/fake-model-provider.d.ts.map +1 -1
- package/dist/src/testing/fake-model-provider.js +6 -9
- package/dist/src/testing/fake-model-provider.js.map +1 -1
- package/dist/src/testing/in-memory-governance-queries.d.ts.map +1 -1
- package/dist/src/testing/in-memory-governance-queries.js +1 -0
- package/dist/src/testing/in-memory-governance-queries.js.map +1 -1
- package/dist/src/testing/in-memory-store.d.ts +4 -3
- package/dist/src/testing/in-memory-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-store.js +13 -7
- package/dist/src/testing/in-memory-store.js.map +1 -1
- package/dist/src/testing/index.d.ts +1 -1
- package/dist/src/testing/index.d.ts.map +1 -1
- package/dist/src/testing/index.js.map +1 -1
- package/dist/src/tool-registry.d.ts +9 -0
- package/dist/src/tool-registry.d.ts.map +1 -1
- package/dist/src/tool-registry.js +11 -0
- package/dist/src/tool-registry.js.map +1 -1
- package/dist/src/types.d.ts +70 -2
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +38 -24
- package/skills/agent-personas-agents/SKILL.md +16 -12
- package/dist/assets/spa/assets/index-3Q2m5_Ax.js +0 -9
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { AgentDepsFactory } from '../agent-deps-factory.js';
|
|
2
|
+
import { type HumanReply } from '../elicitation.js';
|
|
2
3
|
import type { AgentRunner } from '../spi/agent-runner.js';
|
|
3
4
|
import type { AgentStore } from '../spi/agent-store.js';
|
|
4
|
-
import type { AgentRunInput
|
|
5
|
+
import type { AgentRunInput } from '../types.js';
|
|
5
6
|
/**
|
|
6
|
-
* Runs the agent turn in-process — the default runner (`durable: false`). HITL
|
|
7
|
-
* pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's
|
|
8
|
-
* satisfy another's pending action.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Runs the agent turn in-process — the default runner (`durable: false`). A HITL wait resolves a
|
|
8
|
+
* pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's reply can never
|
|
9
|
+
* satisfy another's pending action.
|
|
10
|
+
*
|
|
11
|
+
* Sub-agent delegation runs a nested loop on a transient sub-thread, and that nested run parks on a
|
|
12
|
+
* human exactly as a top-level one does — under its OWN runId, which is what makes it answerable:
|
|
13
|
+
* the pending row it writes carries that runId, and its frames are forwarded into the top-level
|
|
14
|
+
* ancestor's stream (the only stream anyone subscribed to) carrying it too. The mirror of the
|
|
15
|
+
* durable runner's `sinkRunId`.
|
|
16
|
+
*
|
|
17
|
+
* Single-replica only — durable is the scaled path (deferred).
|
|
11
18
|
*/
|
|
12
19
|
export declare class InlineAgentRunner implements AgentRunner {
|
|
13
20
|
private readonly factory;
|
|
@@ -17,9 +24,28 @@ export declare class InlineAgentRunner implements AgentRunner {
|
|
|
17
24
|
start(input: AgentRunInput): Promise<{
|
|
18
25
|
runId: string;
|
|
19
26
|
}>;
|
|
20
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Deliver a human's reply to whichever wait this run is parked on.
|
|
29
|
+
*
|
|
30
|
+
* An approval wait takes a {@link Decision} only. Answers addressed there are refused rather than
|
|
31
|
+
* delivered: `approved` is absent on them, and the tool-call row would record a rejection the
|
|
32
|
+
* person never made. The refusal leaves the wait intact, so the approval is still there to make.
|
|
33
|
+
*
|
|
34
|
+
* The other direction IS delivered — a question set parks as a `pending_approval` action, so an
|
|
35
|
+
* operator pressing Approve on it is expected, and the loop reads that as "confirmed the
|
|
36
|
+
* pre-picked answers".
|
|
37
|
+
*/
|
|
38
|
+
signal(runId: string, toolCallId: string, reply: HumanReply): Promise<void>;
|
|
21
39
|
cancel(runId: string): Promise<void>;
|
|
22
40
|
private topLevelHooks;
|
|
41
|
+
/**
|
|
42
|
+
* The two waits a run parks on, keyed by the run that is parked. Identical for a top-level run and
|
|
43
|
+
* for a delegated one: `signal(runId, …)` finds either, because the pending map belongs to the
|
|
44
|
+
* runner rather than to a run.
|
|
45
|
+
*/
|
|
46
|
+
private humanHooks;
|
|
47
|
+
/** Hold a run at `key` until a human's reply arrives through {@link InlineAgentRunner.signal}. */
|
|
48
|
+
private park;
|
|
23
49
|
/** Delegate to another agent as a nested in-process run (a transient sub-thread). */
|
|
24
50
|
private runNested;
|
|
25
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-agent-runner.d.ts","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"inline-agent-runner.d.ts","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGjE,OAAO,EAEL,KAAK,UAAU,EAGhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,KAAK,EAAS,aAAa,EAAY,MAAM,aAAa,CAAC;AAYlE;;;;;;;;;;;;GAYG;AACH,qBAAa,iBAAkB,YAAW,WAAW;IAIjD,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,KAAK;IAJxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiC;IAEzD,YACmB,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,UAAU,EAChC;IAEE,KAAK,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAyC5D;IAED;;;;;;;;;;OAUG;IACG,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhF;IAEK,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAOzC;IAED,OAAO,CAAC,aAAa;IAkCrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;IAWlB,kGAAkG;IAClG,OAAO,CAAC,IAAI;IAMZ,qFAAqF;YACvE,SAAS;CAgExB"}
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { utcDay } from '../agent-deps.js';
|
|
2
|
-
import { runAgentLoop } from '../agent-loop.js';
|
|
2
|
+
import { runAgentLoop, settleAll } from '../agent-loop.js';
|
|
3
3
|
import { spannedAgent } from '../diagnostics.js';
|
|
4
|
+
import { HumanReplyMismatchError, isHumanDecision, } from '../elicitation.js';
|
|
5
|
+
import { childSinkWriter } from '../spi/token-stream-sink.js';
|
|
4
6
|
/**
|
|
5
|
-
* Runs the agent turn in-process — the default runner (`durable: false`). HITL
|
|
6
|
-
* pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's
|
|
7
|
-
* satisfy another's pending action.
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Runs the agent turn in-process — the default runner (`durable: false`). A HITL wait resolves a
|
|
8
|
+
* pending promise keyed run-namespaced by `${runId}:${toolCallId}`, so one run's reply can never
|
|
9
|
+
* satisfy another's pending action.
|
|
10
|
+
*
|
|
11
|
+
* Sub-agent delegation runs a nested loop on a transient sub-thread, and that nested run parks on a
|
|
12
|
+
* human exactly as a top-level one does — under its OWN runId, which is what makes it answerable:
|
|
13
|
+
* the pending row it writes carries that runId, and its frames are forwarded into the top-level
|
|
14
|
+
* ancestor's stream (the only stream anyone subscribed to) carrying it too. The mirror of the
|
|
15
|
+
* durable runner's `sinkRunId`.
|
|
16
|
+
*
|
|
17
|
+
* Single-replica only — durable is the scaled path (deferred).
|
|
10
18
|
*/
|
|
11
19
|
export class InlineAgentRunner {
|
|
12
20
|
factory;
|
|
@@ -20,7 +28,19 @@ export class InlineAgentRunner {
|
|
|
20
28
|
const runId = crypto.randomUUID();
|
|
21
29
|
const day = input.day ?? utcDay();
|
|
22
30
|
const deps = this.factory.forAgent(input.agentName);
|
|
23
|
-
const hooks = this.topLevelHooks(
|
|
31
|
+
const hooks = this.topLevelHooks({
|
|
32
|
+
runId,
|
|
33
|
+
deps,
|
|
34
|
+
actor: input.actor,
|
|
35
|
+
day,
|
|
36
|
+
// The chain this run sits on with its OWN agent appended — what lets a child recognise a
|
|
37
|
+
// delegation back to an agent the chain has already passed through.
|
|
38
|
+
chainBelow: [
|
|
39
|
+
...(input.delegationPath ?? []),
|
|
40
|
+
...(input.agentName !== undefined ? [input.agentName] : []),
|
|
41
|
+
],
|
|
42
|
+
depth: input.delegationDepth ?? 0,
|
|
43
|
+
});
|
|
24
44
|
// The root turn span — the trace's root, correlated to every child step span by traceId = runId.
|
|
25
45
|
// Emitted by the runner (not the shared loop) because the inline runner executes the loop exactly
|
|
26
46
|
// once; the durable runner's body replays, so it roots its trace by traceId instead. Zero-cost
|
|
@@ -38,13 +58,28 @@ export class InlineAgentRunner {
|
|
|
38
58
|
});
|
|
39
59
|
return { runId };
|
|
40
60
|
}
|
|
41
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Deliver a human's reply to whichever wait this run is parked on.
|
|
63
|
+
*
|
|
64
|
+
* An approval wait takes a {@link Decision} only. Answers addressed there are refused rather than
|
|
65
|
+
* delivered: `approved` is absent on them, and the tool-call row would record a rejection the
|
|
66
|
+
* person never made. The refusal leaves the wait intact, so the approval is still there to make.
|
|
67
|
+
*
|
|
68
|
+
* The other direction IS delivered — a question set parks as a `pending_approval` action, so an
|
|
69
|
+
* operator pressing Approve on it is expected, and the loop reads that as "confirmed the
|
|
70
|
+
* pre-picked answers".
|
|
71
|
+
*/
|
|
72
|
+
async signal(runId, toolCallId, reply) {
|
|
42
73
|
const key = `${runId}:${toolCallId}`;
|
|
43
|
-
const
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
resolve(decision);
|
|
74
|
+
const parked = this.pending.get(key);
|
|
75
|
+
if (parked === undefined) {
|
|
76
|
+
return;
|
|
47
77
|
}
|
|
78
|
+
if (parked.on === 'approval' && !isHumanDecision(reply)) {
|
|
79
|
+
throw new HumanReplyMismatchError(runId, toolCallId);
|
|
80
|
+
}
|
|
81
|
+
this.pending.delete(key);
|
|
82
|
+
parked.resolve(reply);
|
|
48
83
|
}
|
|
49
84
|
async cancel(runId) {
|
|
50
85
|
// Best-effort: settle the run `cancelled` (first-terminal, so a completed run stays completed),
|
|
@@ -54,38 +89,89 @@ export class InlineAgentRunner {
|
|
|
54
89
|
const writer = await deps.sink.open(runId);
|
|
55
90
|
await writer.end();
|
|
56
91
|
}
|
|
57
|
-
topLevelHooks(
|
|
92
|
+
topLevelHooks(args) {
|
|
93
|
+
const { runId, deps, actor, day, chainBelow, depth } = args;
|
|
58
94
|
return {
|
|
59
95
|
runId,
|
|
60
96
|
durable: false,
|
|
61
97
|
openSink: () => deps.sink.open(runId),
|
|
62
|
-
|
|
63
|
-
// Run-namespaced key: `${runId}:${toolCallId}` — one run can't approve another's tool call.
|
|
64
|
-
this.pending.set(`${runId}:${call.id}`, resolve);
|
|
65
|
-
}),
|
|
98
|
+
...this.humanHooks(runId),
|
|
66
99
|
step: (_name, fn) => fn(),
|
|
67
|
-
|
|
100
|
+
// Nothing here records a position, so a turn's read tools can simply overlap.
|
|
101
|
+
parallel: settleAll,
|
|
102
|
+
runAgent: (agentName, task) => this.runNested({
|
|
103
|
+
agentName,
|
|
104
|
+
task,
|
|
105
|
+
actor,
|
|
106
|
+
day,
|
|
107
|
+
depth: depth + 1,
|
|
108
|
+
path: chainBelow,
|
|
109
|
+
parentRunId: runId,
|
|
110
|
+
// This run owns the stream a human subscribed to, so every delegation below it writes here.
|
|
111
|
+
sinkRunId: runId,
|
|
112
|
+
}),
|
|
68
113
|
};
|
|
69
114
|
}
|
|
115
|
+
/**
|
|
116
|
+
* The two waits a run parks on, keyed by the run that is parked. Identical for a top-level run and
|
|
117
|
+
* for a delegated one: `signal(runId, …)` finds either, because the pending map belongs to the
|
|
118
|
+
* runner rather than to a run.
|
|
119
|
+
*/
|
|
120
|
+
humanHooks(runId) {
|
|
121
|
+
return {
|
|
122
|
+
awaitApproval: (call) =>
|
|
123
|
+
// Run-namespaced key: `${runId}:${toolCallId}` — one run can't approve another's tool call.
|
|
124
|
+
this.park(`${runId}:${call.id}`, 'approval'),
|
|
125
|
+
// An answer and an approval reach a parked run by the same channel, because a question set is
|
|
126
|
+
// itself a `pending_approval` row: `POST /agent/tool-call/answer` and `/approve` both land here.
|
|
127
|
+
awaitAnswers: (request) => this.park(`${runId}:${request.id}`, 'answers'),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Hold a run at `key` until a human's reply arrives through {@link InlineAgentRunner.signal}. */
|
|
131
|
+
park(key, on) {
|
|
132
|
+
return new Promise((resolve) => {
|
|
133
|
+
this.pending.set(key, { on, resolve });
|
|
134
|
+
});
|
|
135
|
+
}
|
|
70
136
|
/** Delegate to another agent as a nested in-process run (a transient sub-thread). */
|
|
71
|
-
async runNested(
|
|
137
|
+
async runNested(args) {
|
|
138
|
+
const { agentName, task, actor, day, depth, path, parentRunId, sinkRunId } = args;
|
|
72
139
|
const subThread = await this.store.createThread({ actor, persona: 'default', transient: true });
|
|
73
140
|
const runId = crypto.randomUUID();
|
|
74
141
|
const deps = this.factory.forAgent(agentName);
|
|
75
142
|
const hooks = {
|
|
76
143
|
runId,
|
|
77
144
|
durable: false,
|
|
78
|
-
|
|
79
|
-
//
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
145
|
+
// Forward into the ancestor's stream but never end it: the top-level run owns that lifecycle
|
|
146
|
+
// across however many delegations it spans.
|
|
147
|
+
openSink: async () => childSinkWriter(await deps.sink.open(sinkRunId)),
|
|
148
|
+
// A delegated run parks on a human like any other, keyed by ITS OWN runId — which is the id
|
|
149
|
+
// its pending row and its forwarded frames both carry, so the wait can be answered.
|
|
150
|
+
...this.humanHooks(runId),
|
|
84
151
|
step: (_name, fn) => fn(),
|
|
85
|
-
|
|
152
|
+
parallel: settleAll,
|
|
153
|
+
runAgent: (childName, childTask) => this.runNested({
|
|
154
|
+
agentName: childName,
|
|
155
|
+
task: childTask,
|
|
156
|
+
actor,
|
|
157
|
+
day,
|
|
158
|
+
depth: depth + 1,
|
|
159
|
+
path: [...path, agentName],
|
|
160
|
+
parentRunId: runId,
|
|
161
|
+
sinkRunId,
|
|
162
|
+
}),
|
|
86
163
|
};
|
|
87
164
|
// A nested sub-agent run is its own trace (its own runId), rooted by the same turn span.
|
|
88
|
-
return spannedAgent('turn', runId, { runId }, () => runAgentLoop({ ...deps, day }, {
|
|
165
|
+
return spannedAgent('turn', runId, { runId }, () => runAgentLoop({ ...deps, day }, {
|
|
166
|
+
threadId: subThread.id,
|
|
167
|
+
actor,
|
|
168
|
+
userText: task,
|
|
169
|
+
agentName,
|
|
170
|
+
day,
|
|
171
|
+
parentRunId,
|
|
172
|
+
delegationDepth: depth,
|
|
173
|
+
delegationPath: path,
|
|
174
|
+
}, hooks), (result) => ({ textLength: result.text.length }));
|
|
89
175
|
}
|
|
90
176
|
}
|
|
91
177
|
//# sourceMappingURL=inline-agent-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-agent-runner.js","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAuB,YAAY,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"inline-agent-runner.js","sourceRoot":"","sources":["../../../src/runners/inline-agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAuB,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAGL,uBAAuB,EACvB,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAa9D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,iBAAiB;IAIT,OAAO;IACP,KAAK;IAJP,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEzD,YACmB,OAAyB,EACzB,KAAiB;uBADjB,OAAO;qBACP,KAAK;IACrB,CAAC;IAEJ,KAAK,CAAC,KAAK,CAAC,KAAoB;QAC9B,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC;QAClC,MAAM,GAAG,GAAG,KAAK,CA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,KAAK,GAAG,CAAC;gBAChB,IAAI,EAAE,CAAC,GAAG,IAAI,EAAE,SAAS,CAAC;gBAC1B,WAAW,EAAE,KAAK;gBAClB,SAAS;aACV,CAAC;SACL,CAAC;QACF,yFAAyF;QACzF,OAAO,YAAY,CACjB,MAAM,EACN,KAAK,EACL,EAAE,KAAK,EAAE,EACT,GAAG,EAAE,CACH,YAAY,CACV,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAChB;YACE,QAAQ,EAAE,SAAS,CAAC,EAAE;YACtB,KAAK;YACL,QAAQ,EAAE,IAAI;YACd,SAAS;YACT,GAAG;YACH,WAAW;YACX,eAAe,EAAE,KAAK;YACtB,cAAc,EAAE,IAAI;SACrB,EACD,KAAK,CACN,EACH,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CACjD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skills: an authored procedure the model pulls in when a task calls for it, instead of every
|
|
3
|
+
* instruction living in the system prompt.
|
|
4
|
+
*
|
|
5
|
+
* WHAT A SKILL IS NOT: an agent. An agent is WHO is answering — its persona, its tools, its history
|
|
6
|
+
* window, its output schema. A skill is HOW one particular task is done, and any agent may pull one
|
|
7
|
+
* in. That is why a skill carries no model, no tool list and no schema: the moment it did, the two
|
|
8
|
+
* would be the same thing wearing different names, and a consumer would have to choose between them
|
|
9
|
+
* for reasons nobody could state.
|
|
10
|
+
*
|
|
11
|
+
* WHAT IT COSTS THE PROMPT: one line per skill. The catalog block below carries names, scopes and
|
|
12
|
+
* descriptions only; a BODY reaches the model as a tool result, on the transcript, where the
|
|
13
|
+
* `HistoryWindow` ceiling already governs it. So skills are not a fourth thing competing for the
|
|
14
|
+
* system block with the agent's own prompt, its persona and injected retrieval — see
|
|
15
|
+
* `AgentLoopDeps.skills` for how they compose.
|
|
16
|
+
*/
|
|
17
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
18
|
+
import type { Actor, PageContext, ToolDefinition } from './types.js';
|
|
19
|
+
/** How a skill is identified in the catalog, to the model and to a `/`-autocomplete alike. */
|
|
20
|
+
export interface SkillSummary {
|
|
21
|
+
/** Unique within a scope. The handle the model passes to the `skill` tool. */
|
|
22
|
+
name: string;
|
|
23
|
+
/** One line: what task this covers, and therefore when to load it. Read by the MODEL to choose. */
|
|
24
|
+
description: string;
|
|
25
|
+
/** The opaque scope token this skill is published at — see {@link ScopeResolver}. */
|
|
26
|
+
scope: string;
|
|
27
|
+
}
|
|
28
|
+
/** A skill with the instructions themselves. Only ever materialized when something loads it. */
|
|
29
|
+
export interface Skill extends SkillSummary {
|
|
30
|
+
body: string;
|
|
31
|
+
}
|
|
32
|
+
/** Whose turn is asking, and therefore which scopes apply. */
|
|
33
|
+
export interface ScopeContext {
|
|
34
|
+
actor: Actor;
|
|
35
|
+
threadId: string;
|
|
36
|
+
/** The agent running this turn. Undefined → the default agent. */
|
|
37
|
+
agentName?: string;
|
|
38
|
+
pageContext?: PageContext;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The skills-facing name for {@link ScopeContext}, so a `SkillProvider`'s signature reads in its own
|
|
42
|
+
* vocabulary. Deliberately the SAME type rather than a parallel one: skills and memory resolve
|
|
43
|
+
* scopes through one {@link ScopeResolver}, and a deployment that could answer "which scopes does
|
|
44
|
+
* this actor have" twice would eventually answer it differently.
|
|
45
|
+
*/
|
|
46
|
+
export type SkillContext = ScopeContext;
|
|
47
|
+
/** The scope token every deployment has: skills nobody narrowed. */
|
|
48
|
+
export declare const GLOBAL_SCOPE = "global";
|
|
49
|
+
/** The token for one actor's own skills. */
|
|
50
|
+
export declare function actorScope(actor: Actor): string;
|
|
51
|
+
/** The token for a tenant's skills — `Actor.tenantRef` is the only tenant key this library knows. */
|
|
52
|
+
export declare function tenantScope(tenantRef: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Which scopes a turn may draw from, MOST SPECIFIC FIRST. Precedence is the order: an entry from an
|
|
55
|
+
* earlier token outranks a same-named one from a later token, and the model is shown which won.
|
|
56
|
+
*
|
|
57
|
+
* A HOST-SUPPLIED FUNCTION rather than an enum this library owns, because the axes a deployment
|
|
58
|
+
* scopes by are the deployment's own. `Actor` gives an id and a tenant; it does not give a sector, a
|
|
59
|
+
* squadron, a base, a shift — and every one of those is a real axis in some consumer. An enum here
|
|
60
|
+
* would make each of them a schema change in a library that has no business knowing they exist,
|
|
61
|
+
* while a token is a string a host mints for itself. Return `['sector:logistics', 'tenant:base-7',
|
|
62
|
+
* 'global']` and precedence follows, with nothing in this package edited.
|
|
63
|
+
*
|
|
64
|
+
* MUST be a pure function of its context. It runs inside the `skills:catalog` / `memory:digest`
|
|
65
|
+
* checkpoint and its result is journaled, so a resumed run reads back the scopes the first attempt
|
|
66
|
+
* resolved rather than asking a membership table that may have changed since — which would let a
|
|
67
|
+
* run's prompt differ from the one its journal records. Read a database here at your peril; read it
|
|
68
|
+
* in the provider, whose answer is journaled at the same position.
|
|
69
|
+
*/
|
|
70
|
+
export interface ScopeResolver {
|
|
71
|
+
resolve(ctx: ScopeContext): string[] | Promise<string[]>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The scopes derivable from an {@link Actor} alone — the common case, so a consumer wiring skills
|
|
75
|
+
* for the first time supplies no resolver at all: the actor's own, their tenant's (when they have
|
|
76
|
+
* one), and the deployment's. A host adding an axis of its own replaces this rather than extending
|
|
77
|
+
* it, since the ORDER is the precedence and only the host knows where its axis belongs.
|
|
78
|
+
*/
|
|
79
|
+
export declare const defaultScopeResolver: ScopeResolver;
|
|
80
|
+
/** Arguments to {@link SkillProvider.list}. */
|
|
81
|
+
export interface ListSkillsInput {
|
|
82
|
+
scopes: readonly string[];
|
|
83
|
+
ctx: SkillContext;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Arguments to {@link SkillProvider.load}. An object rather than positional arguments because `name`
|
|
87
|
+
* and `scope` are both strings: transposed, a positional call compiles clean, returns `null`, and
|
|
88
|
+
* the skill silently fails to load.
|
|
89
|
+
*/
|
|
90
|
+
export interface LoadSkillInput {
|
|
91
|
+
name: string;
|
|
92
|
+
scope: string;
|
|
93
|
+
ctx: SkillContext;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Where skills come from. Deliberately two calls rather than one: `list` is asked on EVERY turn and
|
|
97
|
+
* must stay cheap, while a body is read only when the model decides it needs that procedure — the
|
|
98
|
+
* whole point of the surface. A provider over a table selects name/description/scope for the first
|
|
99
|
+
* and one row for the second.
|
|
100
|
+
*
|
|
101
|
+
* This library owns no skill table. A skill's real scoping axes, its authoring UI and its audit
|
|
102
|
+
* trail are all the host's, and a host that related its own entity into a table this package created
|
|
103
|
+
* at boot would be writing migrations against a schema the boot-time heal also edits. Tokens split
|
|
104
|
+
* it the other way round: the library owns the contract (what a scope means, how precedence works,
|
|
105
|
+
* what is journaled), the host owns the rows.
|
|
106
|
+
*/
|
|
107
|
+
export interface SkillProvider {
|
|
108
|
+
/**
|
|
109
|
+
* Every skill visible at `scopes`, in any order — this library sorts and resolves precedence. A
|
|
110
|
+
* provider MAY return skills outside `scopes`; they are dropped rather than trusted, so a filter
|
|
111
|
+
* bug in a host cannot widen what an actor is offered.
|
|
112
|
+
*/
|
|
113
|
+
list(input: ListSkillsInput): SkillSummary[] | Promise<SkillSummary[]>;
|
|
114
|
+
/**
|
|
115
|
+
* The instructions for one skill, or `null` when it is gone. Called only from inside the loading
|
|
116
|
+
* checkpoint, so the body it returns is journaled and every replay reads THAT text back — an
|
|
117
|
+
* edited skill never rewrites the prompt of a run already in flight.
|
|
118
|
+
*/
|
|
119
|
+
load(input: LoadSkillInput): string | null | Promise<string | null>;
|
|
120
|
+
}
|
|
121
|
+
/** A source of skills that is a fixed list — module config, or a host's own constant. */
|
|
122
|
+
export declare function staticSkillProvider(skills: readonly Skill[]): SkillProvider;
|
|
123
|
+
/**
|
|
124
|
+
* Read several sources as one. The order is the tie-break and nothing else: precedence between
|
|
125
|
+
* skills is by SCOPE, so two sources only ever compete when they publish the same name at the same
|
|
126
|
+
* scope, and then the earlier source wins. Wire the host's own provider first — a row it can edit is
|
|
127
|
+
* a better answer than a body that needs a deploy to change.
|
|
128
|
+
*/
|
|
129
|
+
export declare function compositeSkillProvider(providers: readonly SkillProvider[]): SkillProvider;
|
|
130
|
+
/**
|
|
131
|
+
* One skill as it is offered — to the model in the catalog block, and to a client listing what a
|
|
132
|
+
* user may type after a `/`. Both read the same list, built by the same call, so what a user can
|
|
133
|
+
* reach and what the model can reach cannot drift apart.
|
|
134
|
+
*/
|
|
135
|
+
export interface SkillCatalogEntry {
|
|
136
|
+
name: string;
|
|
137
|
+
description: string;
|
|
138
|
+
/** The scope token it resolved from — the provenance a user is entitled to see. */
|
|
139
|
+
scope: string;
|
|
140
|
+
/**
|
|
141
|
+
* Scope tokens of same-named skills this one outranks, widest last. Present ONLY when something
|
|
142
|
+
* was shadowed, so a reader can tell "there is no org default" from "there is one and yours wins".
|
|
143
|
+
* The model is shown it for the same reason: a silent override is indistinguishable from an
|
|
144
|
+
* instruction nobody wrote, and the user can only be told "your setting differs from the org
|
|
145
|
+
* default" by something that knows both existed.
|
|
146
|
+
*/
|
|
147
|
+
shadows?: string[];
|
|
148
|
+
}
|
|
149
|
+
/** What a turn resolved — journaled whole, so the prompt is reconstructible from the journal alone. */
|
|
150
|
+
export interface SkillOffer {
|
|
151
|
+
/** The scope tokens this turn drew from, most specific first. */
|
|
152
|
+
scopes: string[];
|
|
153
|
+
/** The skills offered, most specific first then by name. */
|
|
154
|
+
entries: SkillCatalogEntry[];
|
|
155
|
+
/** Applicable skills `maxSkills` left out. Non-zero means the catalog is not the whole truth. */
|
|
156
|
+
omitted: number;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* How many skills a catalog offers before it starts leaving some out. A ceiling on the SYSTEM
|
|
160
|
+
* PROMPT's share, not on how many a deployment may have: the block costs one line each, and a
|
|
161
|
+
* hundred lines of "here is something you could load" crowds out the agent's own instructions while
|
|
162
|
+
* making the choice harder rather than easier.
|
|
163
|
+
*/
|
|
164
|
+
export declare const DEFAULT_MAX_SKILLS = 20;
|
|
165
|
+
/** How a turn reaches its skills. See `AgentLoopDeps.skills`. */
|
|
166
|
+
export interface SkillsConfig {
|
|
167
|
+
provider: SkillProvider;
|
|
168
|
+
/** Undefined → {@link defaultScopeResolver}: the actor's own, their tenant's, the deployment's. */
|
|
169
|
+
scopes?: ScopeResolver;
|
|
170
|
+
/** Undefined → {@link DEFAULT_MAX_SKILLS}. */
|
|
171
|
+
maxSkills?: number;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Resolve a provider's skills against an ordered scope list: most specific wins, and the loser's
|
|
175
|
+
* scope is recorded rather than discarded.
|
|
176
|
+
*
|
|
177
|
+
* Pure, and separately exported, because two callers must reach the identical answer — the loop, so
|
|
178
|
+
* the model is offered it, and the listing endpoint, so a user is. A second implementation of "which
|
|
179
|
+
* skills apply" is a second answer, and the two diverge the first time either is edited.
|
|
180
|
+
*/
|
|
181
|
+
export declare function resolveSkillCatalog(summaries: readonly SkillSummary[], scopes: readonly string[], maxSkills?: number): Omit<SkillOffer, 'scopes'>;
|
|
182
|
+
/** Resolve the scopes and the catalog for one turn. Called INSIDE the loop's `skills:catalog` step. */
|
|
183
|
+
export declare function offerSkills(config: SkillsConfig, ctx: SkillContext): Promise<SkillOffer>;
|
|
184
|
+
/** The reserved name of the built-in skill-loading tool. */
|
|
185
|
+
export declare const SKILL_TOOL_NAME = "skill";
|
|
186
|
+
/**
|
|
187
|
+
* The catalog as the model reads it. One line per skill — name, scope, description, and what it
|
|
188
|
+
* overrides — because the entire claim of progressive disclosure is that choosing what to read costs
|
|
189
|
+
* far less than reading everything.
|
|
190
|
+
*/
|
|
191
|
+
export declare function buildSkillsBlock(entries: readonly SkillCatalogEntry[]): string;
|
|
192
|
+
/** What the model passes to the `skill` tool. */
|
|
193
|
+
export interface SkillToolInput {
|
|
194
|
+
name: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* The `skill` tool's input schema. Hand-written for the same reason `askInputSchema` is: this
|
|
198
|
+
* package depends on no validator, and the schema has to publish a JSON Schema a provider can
|
|
199
|
+
* constrain generation against.
|
|
200
|
+
*
|
|
201
|
+
* The available names are deliberately NOT an enum here. A per-turn enum would make the tool's
|
|
202
|
+
* definition depend on the catalog, and a tool list re-derived by whichever process serves a turn is
|
|
203
|
+
* exactly the process-local lookup this design keeps off a turn's decisions. The names live in the
|
|
204
|
+
* prompt, where the journal holds them; a name that is not in the catalog comes back as an ordinary
|
|
205
|
+
* tool failure listing the ones that are.
|
|
206
|
+
*/
|
|
207
|
+
export declare const skillInputSchema: StandardSchemaV1<unknown, SkillToolInput>;
|
|
208
|
+
export declare const SKILL_TOOL_DESCRIPTION = "Read one of the procedures listed in <skills>. Call it before doing a task a listed skill covers, and follow what it returns. It performs nothing and changes nothing \u2014 it only gives you instructions you do not yet have.";
|
|
209
|
+
/**
|
|
210
|
+
* The `skill` tool as the model sees it. NOT a `ToolSpec` and never registered, exactly like `ask`:
|
|
211
|
+
* it has no handler, because the loop serves it from the catalog the journal holds. Keeping it out
|
|
212
|
+
* of the `ToolRegistry` is also what keeps its kind off a process-local lookup — see
|
|
213
|
+
* `claimToolCall`.
|
|
214
|
+
*/
|
|
215
|
+
export declare function skillToolDefinition(): ToolDefinition;
|
|
216
|
+
/** What a `skill` call resolved to — the body, or why it did not. */
|
|
217
|
+
export type SkillLoadOutcome = {
|
|
218
|
+
ok: true;
|
|
219
|
+
skill: Skill;
|
|
220
|
+
shadows?: string[];
|
|
221
|
+
} | {
|
|
222
|
+
ok: false;
|
|
223
|
+
error: string;
|
|
224
|
+
};
|
|
225
|
+
/**
|
|
226
|
+
* Serve one `skill` call against the catalog THIS TURN was offered.
|
|
227
|
+
*
|
|
228
|
+
* The catalog is the authorization boundary, not just a menu: a name the turn was never offered is
|
|
229
|
+
* refused here, so a model that invents one (or repeats one it saw in another actor's thread) cannot
|
|
230
|
+
* reach a body through a provider that would happily serve it. Because the catalog came out of the
|
|
231
|
+
* `skills:catalog` checkpoint, that boundary is the one the journal records rather than the one this
|
|
232
|
+
* process's provider currently believes in.
|
|
233
|
+
*/
|
|
234
|
+
export declare function loadSkill(args: {
|
|
235
|
+
config: SkillsConfig;
|
|
236
|
+
offer: SkillOffer;
|
|
237
|
+
name: string;
|
|
238
|
+
ctx: SkillContext;
|
|
239
|
+
}): Promise<SkillLoadOutcome>;
|
|
240
|
+
/** Who is trying to write a skill. */
|
|
241
|
+
export interface SkillAuthor {
|
|
242
|
+
/**
|
|
243
|
+
* `'human'` is a person acting through a UI; `'agent'` is anything else — a tool, a turn, a batch
|
|
244
|
+
* job. The distinction is the whole of the rule below, so it is not inferable and has to be stated
|
|
245
|
+
* by the caller.
|
|
246
|
+
*/
|
|
247
|
+
kind: 'human' | 'agent';
|
|
248
|
+
actorRef?: string;
|
|
249
|
+
}
|
|
250
|
+
/** A request to author a skill at a scope. */
|
|
251
|
+
export interface SkillWriteRequest {
|
|
252
|
+
/** The scope token the skill would be published at. */
|
|
253
|
+
scope: string;
|
|
254
|
+
actor: Actor;
|
|
255
|
+
/** The actor's resolved scopes, most specific first — the same list a turn draws from. */
|
|
256
|
+
scopes: readonly string[];
|
|
257
|
+
author: SkillAuthor;
|
|
258
|
+
/**
|
|
259
|
+
* The host's own answer to "may this person administer that scope" — a sector lead editing their
|
|
260
|
+
* sector's skills, an operator editing the deployment's. This library cannot know it: it has no
|
|
261
|
+
* notion of who administers `sector:logistics`, and inventing one would be a second, weaker
|
|
262
|
+
* authorization model next to the host's real one. Undefined/false → a wider scope is refused.
|
|
263
|
+
*/
|
|
264
|
+
elevated?: boolean;
|
|
265
|
+
}
|
|
266
|
+
export type SkillWriteVerdict = {
|
|
267
|
+
allowed: true;
|
|
268
|
+
} | {
|
|
269
|
+
allowed: false;
|
|
270
|
+
reason: string;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* May this author publish a skill at this scope?
|
|
274
|
+
*
|
|
275
|
+
* A skill's body is instructions the model follows, which makes writing one at a scope an edit to
|
|
276
|
+
* everyone in that scope's system prompt. The rules follow from that, and only the third is
|
|
277
|
+
* interesting:
|
|
278
|
+
*
|
|
279
|
+
* 1. You may only write into a scope you are yourself in. Writing into a scope you are not in is
|
|
280
|
+
* authoring for people you have no relationship with.
|
|
281
|
+
* 2. Your OWN scope is yours. A per-actor skill affects exactly one prompt — the author's.
|
|
282
|
+
* 3. NOTHING BUT A HUMAN MAY WRITE ABOVE ITS OWN SCOPE, whatever `elevated` says. An agent that can
|
|
283
|
+
* write a `tenant:` skill is an agent whose prompt anyone in the tenant can edit by talking to
|
|
284
|
+
* it: the user asks for something, the turn writes the instruction, and every later turn for
|
|
285
|
+
* every other user follows it. That is prompt injection with persistence, and no elevation a host
|
|
286
|
+
* could grant makes it a different shape. An agent that has genuinely learned something worth
|
|
287
|
+
* sharing proposes it; a person publishes it.
|
|
288
|
+
* 4. A human writing above their own scope needs the host to say so (`elevated`).
|
|
289
|
+
*/
|
|
290
|
+
export declare function skillWriteVerdict(request: SkillWriteRequest): SkillWriteVerdict;
|
|
291
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../../src/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAErE,8FAA8F;AAC9F,MAAM,WAAW,YAAY;IAC3B,8EAA8E;IAC9E,IAAI,EAAE,MAAM,CAAC;IACb,mGAAmG;IACnG,WAAW,EAAE,MAAM,CAAC;IACpB,qFAAqF;IACrF,KA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|
|
2
|
+
import type { AgentRunInput } from '../types.js';
|
|
2
3
|
/**
|
|
3
4
|
* Runs an agent turn. Two impls exist:
|
|
4
5
|
* - InlineAgentRunner (default): the loop runs in-process — no extra dependencies. This is what
|
|
5
|
-
*
|
|
6
|
-
* - DurableAgentRunner (opt-in via `durable: true`): the turn is
|
|
7
|
-
*
|
|
6
|
+
* the provider builds unless `durable: true` is set.
|
|
7
|
+
* - DurableAgentRunner (opt-in via `durable: true`): the turn is an `@adonis-agora/durable`
|
|
8
|
+
* {@link import('../durable/agent-run-workflow.js').AgentRunWorkflow}, so each model/tool call is
|
|
9
|
+
* a checkpointed step and HITL is `ctx.waitForSignal`.
|
|
8
10
|
*
|
|
9
11
|
* `start` ENQUEUES and returns immediately with the runId — the live tokens flow on the
|
|
10
12
|
* TokenStreamSink, not through this call.
|
|
@@ -13,8 +15,20 @@ export interface AgentRunner {
|
|
|
13
15
|
start(input: AgentRunInput): Promise<{
|
|
14
16
|
runId: string;
|
|
15
17
|
}>;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Deliver a human's reply to a parked tool call — an approve/reject {@link import('../types.js').Decision}
|
|
20
|
+
* for an `action`, or an {@link import('../elicitation.js').ElicitationReply} for a question set.
|
|
21
|
+
* One channel for both, because a question set parks as a `pending_approval` action and therefore
|
|
22
|
+
* reaches a run through the inbox a deployment already has.
|
|
23
|
+
*
|
|
24
|
+
* A `Decision` reaching a question set is the documented reduction ("confirmed the pre-picked
|
|
25
|
+
* answers"). The reverse is not: answers carry no `approved`, so an implementation that can tell
|
|
26
|
+
* which wait it is settling MUST refuse them with
|
|
27
|
+
* {@link import('../elicitation.js').HumanReplyMismatchError} rather than deliver them. An
|
|
28
|
+
* implementation that cannot tell delivers, and the loop discards the reply and stays parked —
|
|
29
|
+
* either way, no rejection is recorded against a human who only submitted a form.
|
|
30
|
+
*/
|
|
31
|
+
signal(runId: string, toolCallId: string, reply: HumanReply): Promise<void>;
|
|
18
32
|
cancel(runId: string): Promise<void>;
|
|
19
33
|
}
|
|
20
34
|
//# sourceMappingURL=agent-runner.d.ts.map
|