@alpacakit/agents 0.1.0-beta.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +224 -0
- package/dist/agents/builtin.d.ts +19 -0
- package/dist/agents/builtin.d.ts.map +1 -0
- package/dist/agents/builtin.js +14 -0
- package/dist/agents/claude.d.ts +20 -0
- package/dist/agents/claude.d.ts.map +1 -0
- package/dist/agents/claude.js +480 -0
- package/dist/agents/codex.d.ts +19 -0
- package/dist/agents/codex.d.ts.map +1 -0
- package/dist/agents/codex.js +355 -0
- package/dist/agents/openai-compatible/config.d.ts +16 -0
- package/dist/agents/openai-compatible/config.d.ts.map +1 -0
- package/dist/agents/openai-compatible/config.js +160 -0
- package/dist/agents/openai-compatible/engine.d.ts +18 -0
- package/dist/agents/openai-compatible/engine.d.ts.map +1 -0
- package/dist/agents/openai-compatible/engine.js +10 -0
- package/dist/agents/openai-compatible/fetch-engine.d.ts +38 -0
- package/dist/agents/openai-compatible/fetch-engine.d.ts.map +1 -0
- package/dist/agents/openai-compatible/fetch-engine.js +216 -0
- package/dist/agents/openai-compatible/pi/engine.d.ts +32 -0
- package/dist/agents/openai-compatible/pi/engine.d.ts.map +1 -0
- package/dist/agents/openai-compatible/pi/engine.js +98 -0
- package/dist/agents/openai-compatible/pi/module.d.ts +87 -0
- package/dist/agents/openai-compatible/pi/module.d.ts.map +1 -0
- package/dist/agents/openai-compatible/pi/module.js +43 -0
- package/dist/agents/openai-compatible/pi/sandbox.d.ts +25 -0
- package/dist/agents/openai-compatible/pi/sandbox.d.ts.map +1 -0
- package/dist/agents/openai-compatible/pi/sandbox.js +69 -0
- package/dist/agents/openai-compatible/pi/session.d.ts +17 -0
- package/dist/agents/openai-compatible/pi/session.d.ts.map +1 -0
- package/dist/agents/openai-compatible/pi/session.js +354 -0
- package/dist/agents/openai-compatible/response.d.ts +19 -0
- package/dist/agents/openai-compatible/response.d.ts.map +1 -0
- package/dist/agents/openai-compatible/response.js +203 -0
- package/dist/agents/openai-compatible/types.d.ts +34 -0
- package/dist/agents/openai-compatible/types.d.ts.map +1 -0
- package/dist/agents/openai-compatible/types.js +1 -0
- package/dist/agents/openai-compatible.d.ts +12 -0
- package/dist/agents/openai-compatible.d.ts.map +1 -0
- package/dist/agents/openai-compatible.js +45 -0
- package/dist/auth/login-probe.d.ts +21 -0
- package/dist/auth/login-probe.d.ts.map +1 -0
- package/dist/auth/login-probe.js +47 -0
- package/dist/auth/login.d.ts +79 -0
- package/dist/auth/login.d.ts.map +1 -0
- package/dist/auth/login.js +9 -0
- package/dist/auth/material.d.ts +87 -0
- package/dist/auth/material.d.ts.map +1 -0
- package/dist/auth/material.js +59 -0
- package/dist/auth/profile-store.d.ts +14 -0
- package/dist/auth/profile-store.d.ts.map +1 -0
- package/dist/auth/profile-store.js +101 -0
- package/dist/auth/secrets.d.ts +14 -0
- package/dist/auth/secrets.d.ts.map +1 -0
- package/dist/auth/secrets.js +40 -0
- package/dist/codex/app-server.d.ts +30 -0
- package/dist/codex/app-server.d.ts.map +1 -0
- package/dist/codex/app-server.js +322 -0
- package/dist/codex/index.d.ts +3 -0
- package/dist/codex/index.d.ts.map +1 -0
- package/dist/codex/index.js +1 -0
- package/dist/codex/protocol.d.ts +124 -0
- package/dist/codex/protocol.d.ts.map +1 -0
- package/dist/codex/protocol.js +283 -0
- package/dist/config/agent-config-validation.d.ts +22 -0
- package/dist/config/agent-config-validation.d.ts.map +1 -0
- package/dist/config/agent-config-validation.js +31 -0
- package/dist/config/agent-configs.d.ts +37 -0
- package/dist/config/agent-configs.d.ts.map +1 -0
- package/dist/config/agent-configs.js +214 -0
- package/dist/config/compose.d.ts +10 -0
- package/dist/config/compose.d.ts.map +1 -0
- package/dist/config/compose.js +89 -0
- package/dist/config/config.d.ts +21 -0
- package/dist/config/config.d.ts.map +1 -0
- package/dist/config/config.js +33 -0
- package/dist/config/errors.d.ts +45 -0
- package/dist/config/errors.d.ts.map +1 -0
- package/dist/config/errors.js +37 -0
- package/dist/config/extension.d.ts +3 -0
- package/dist/config/extension.d.ts.map +1 -0
- package/dist/config/extension.js +1 -0
- package/dist/config/ids.d.ts +8 -0
- package/dist/config/ids.d.ts.map +1 -0
- package/dist/config/ids.js +4 -0
- package/dist/config/index.d.ts +12 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +6 -0
- package/dist/config/model.d.ts +105 -0
- package/dist/config/model.d.ts.map +1 -0
- package/dist/config/model.js +1 -0
- package/dist/config/paths.d.ts +7 -0
- package/dist/config/paths.d.ts.map +1 -0
- package/dist/config/paths.js +10 -0
- package/dist/config/schema.d.ts +59 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +83 -0
- package/dist/config/store.d.ts +34 -0
- package/dist/config/store.d.ts.map +1 -0
- package/dist/config/store.js +420 -0
- package/dist/config/support.d.ts +14 -0
- package/dist/config/support.d.ts.map +1 -0
- package/dist/config/support.js +32 -0
- package/dist/config/values.d.ts +21 -0
- package/dist/config/values.d.ts.map +1 -0
- package/dist/config/values.js +22 -0
- package/dist/config/xdg.d.ts +20 -0
- package/dist/config/xdg.d.ts.map +1 -0
- package/dist/config/xdg.js +23 -0
- package/dist/core/async-queue.d.ts +14 -0
- package/dist/core/async-queue.d.ts.map +1 -0
- package/dist/core/async-queue.js +46 -0
- package/dist/core/env.d.ts +19 -0
- package/dist/core/env.d.ts.map +1 -0
- package/dist/core/env.js +39 -0
- package/dist/core/error.d.ts +121 -0
- package/dist/core/error.d.ts.map +1 -0
- package/dist/core/error.js +88 -0
- package/dist/core/fs.d.ts +16 -0
- package/dist/core/fs.d.ts.map +1 -0
- package/dist/core/fs.js +30 -0
- package/dist/core/json.d.ts +20 -0
- package/dist/core/json.d.ts.map +1 -0
- package/dist/core/json.js +42 -0
- package/dist/core/node-ports.d.ts +9 -0
- package/dist/core/node-ports.d.ts.map +1 -0
- package/dist/core/node-ports.js +135 -0
- package/dist/core/ports.d.ts +71 -0
- package/dist/core/ports.d.ts.map +1 -0
- package/dist/core/ports.js +19 -0
- package/dist/core/redact.d.ts +8 -0
- package/dist/core/redact.d.ts.map +1 -0
- package/dist/core/redact.js +66 -0
- package/dist/core/run.d.ts +125 -0
- package/dist/core/run.d.ts.map +1 -0
- package/dist/core/run.js +27 -0
- package/dist/core/values.d.ts +12 -0
- package/dist/core/values.d.ts.map +1 -0
- package/dist/core/values.js +9 -0
- package/dist/corpus/failure-corpus.d.ts +21 -0
- package/dist/corpus/failure-corpus.d.ts.map +1 -0
- package/dist/corpus/failure-corpus.js +89 -0
- package/dist/fleet/fleet.d.ts +120 -0
- package/dist/fleet/fleet.d.ts.map +1 -0
- package/dist/fleet/fleet.js +409 -0
- package/dist/fleet/policy.d.ts +45 -0
- package/dist/fleet/policy.d.ts.map +1 -0
- package/dist/fleet/policy.js +50 -0
- package/dist/fleet/store.d.ts +28 -0
- package/dist/fleet/store.d.ts.map +1 -0
- package/dist/fleet/store.js +225 -0
- package/dist/host/capabilities.d.ts +146 -0
- package/dist/host/capabilities.d.ts.map +1 -0
- package/dist/host/capabilities.js +59 -0
- package/dist/host/context.d.ts +29 -0
- package/dist/host/context.d.ts.map +1 -0
- package/dist/host/context.js +11 -0
- package/dist/host/github-dir.d.ts +16 -0
- package/dist/host/github-dir.d.ts.map +1 -0
- package/dist/host/github-dir.js +164 -0
- package/dist/host/mcp-list.d.ts +12 -0
- package/dist/host/mcp-list.d.ts.map +1 -0
- package/dist/host/mcp-list.js +122 -0
- package/dist/host/requirement-ref.d.ts +12 -0
- package/dist/host/requirement-ref.d.ts.map +1 -0
- package/dist/host/requirement-ref.js +40 -0
- package/dist/host/run-command.d.ts +27 -0
- package/dist/host/run-command.d.ts.map +1 -0
- package/dist/host/run-command.js +66 -0
- package/dist/host/validate-spec.d.ts +10 -0
- package/dist/host/validate-spec.d.ts.map +1 -0
- package/dist/host/validate-spec.js +69 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/kernel/classify.d.ts +44 -0
- package/dist/kernel/classify.d.ts.map +1 -0
- package/dist/kernel/classify.js +136 -0
- package/dist/kernel/cli-agent.d.ts +62 -0
- package/dist/kernel/cli-agent.d.ts.map +1 -0
- package/dist/kernel/cli-agent.js +281 -0
- package/dist/kernel/cli-login.d.ts +13 -0
- package/dist/kernel/cli-login.d.ts.map +1 -0
- package/dist/kernel/cli-login.js +199 -0
- package/dist/kernel/definition.d.ts +41 -0
- package/dist/kernel/definition.d.ts.map +1 -0
- package/dist/kernel/definition.js +13 -0
- package/dist/kernel/env-template.d.ts +17 -0
- package/dist/kernel/env-template.d.ts.map +1 -0
- package/dist/kernel/env-template.js +78 -0
- package/dist/kernel/facets.d.ts +58 -0
- package/dist/kernel/facets.d.ts.map +1 -0
- package/dist/kernel/facets.js +102 -0
- package/dist/kernel/guard.d.ts +24 -0
- package/dist/kernel/guard.d.ts.map +1 -0
- package/dist/kernel/guard.js +69 -0
- package/dist/kernel/handle.d.ts +29 -0
- package/dist/kernel/handle.d.ts.map +1 -0
- package/dist/kernel/handle.js +97 -0
- package/dist/kernel/keyed.d.ts +19 -0
- package/dist/kernel/keyed.d.ts.map +1 -0
- package/dist/kernel/keyed.js +35 -0
- package/dist/kernel/login.d.ts +20 -0
- package/dist/kernel/login.d.ts.map +1 -0
- package/dist/kernel/login.js +74 -0
- package/dist/kernel/options.d.ts +73 -0
- package/dist/kernel/options.d.ts.map +1 -0
- package/dist/kernel/options.js +41 -0
- package/dist/kernel/run.d.ts +20 -0
- package/dist/kernel/run.d.ts.map +1 -0
- package/dist/kernel/run.js +245 -0
- package/dist/kernel/runtime.d.ts +48 -0
- package/dist/kernel/runtime.d.ts.map +1 -0
- package/dist/kernel/runtime.js +108 -0
- package/dist/keyring/index.d.ts +2 -0
- package/dist/keyring/index.d.ts.map +1 -0
- package/dist/keyring/index.js +1 -0
- package/dist/keyring/resolver.d.ts +9 -0
- package/dist/keyring/resolver.d.ts.map +1 -0
- package/dist/keyring/resolver.js +62 -0
- package/dist/run-agent.d.ts +19 -0
- package/dist/run-agent.d.ts.map +1 -0
- package/dist/run-agent.js +25 -0
- package/dist/structured/extract.d.ts +27 -0
- package/dist/structured/extract.d.ts.map +1 -0
- package/dist/structured/extract.js +188 -0
- package/dist/structured/run-structured.d.ts +83 -0
- package/dist/structured/run-structured.d.ts.map +1 -0
- package/dist/structured/run-structured.js +202 -0
- package/dist/structured/standard-schema.d.ts +34 -0
- package/dist/structured/standard-schema.d.ts.map +1 -0
- package/dist/structured/standard-schema.js +6 -0
- package/dist/testing/fake-agent.d.ts +32 -0
- package/dist/testing/fake-agent.d.ts.map +1 -0
- package/dist/testing/fake-agent.js +43 -0
- package/dist/testing/fake-clock.d.ts +8 -0
- package/dist/testing/fake-clock.d.ts.map +1 -0
- package/dist/testing/fake-clock.js +44 -0
- package/dist/testing/fake-exec.d.ts +26 -0
- package/dist/testing/fake-exec.d.ts.map +1 -0
- package/dist/testing/fake-exec.js +69 -0
- package/dist/testing/fake-secrets.d.ts +3 -0
- package/dist/testing/fake-secrets.d.ts.map +1 -0
- package/dist/testing/fake-secrets.js +5 -0
- package/dist/testing/index.d.ts +10 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +9 -0
- package/package.json +75 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured output (design "Structured output"): a decorator over
|
|
3
|
+
* kernel runs. Repair happens WITHIN one candidate — it composes below
|
|
4
|
+
* the fleet, never inside it. Exhausted repairs fail with
|
|
5
|
+
* `output_rejected` carrying the issue list.
|
|
6
|
+
*/
|
|
7
|
+
import { AGENT_ERROR_CODE, AgentError, } from "../core/error.js";
|
|
8
|
+
import { EventBroadcast } from "../kernel/handle.js";
|
|
9
|
+
import { DEFAULT_MARKERS, defaultExtractionStrategies, extractBlock, parseJsonResilient, } from "./extract.js";
|
|
10
|
+
const DEFAULT_MAX_REPAIRS = 2;
|
|
11
|
+
const PREVIOUS_BLOCK_TRUNCATE_CHARS = 12_000;
|
|
12
|
+
const STRUCTURED_RUN_OPTION_KEY = "contract";
|
|
13
|
+
export const CONTRACT_PROMPT_PLACEMENT = {
|
|
14
|
+
append: "append",
|
|
15
|
+
embedded: "embedded",
|
|
16
|
+
};
|
|
17
|
+
export function isStructuredRunOptions(options) {
|
|
18
|
+
return STRUCTURED_RUN_OPTION_KEY in options;
|
|
19
|
+
}
|
|
20
|
+
export function resolveStructuredRunOptions(options) {
|
|
21
|
+
const { contract, ...runOptions } = options;
|
|
22
|
+
return { runOptions, contract };
|
|
23
|
+
}
|
|
24
|
+
function defaultContractInstruction(markers) {
|
|
25
|
+
return [
|
|
26
|
+
"Reply with a single JSON value that satisfies the requested contract.",
|
|
27
|
+
`Wrap it between the exact markers ${markers.start} and ${markers.end}.`,
|
|
28
|
+
"Do not put anything else between the markers.",
|
|
29
|
+
].join("\n");
|
|
30
|
+
}
|
|
31
|
+
function defaultRepairPrompt(ctx) {
|
|
32
|
+
const issueLines = ctx.issues.map((issue) => `- ${issue.path.join(".") || "(root)"}: ${issue.message}`);
|
|
33
|
+
const previous = ctx.previousBlock === null
|
|
34
|
+
? "(no output block was found)"
|
|
35
|
+
: ctx.previousBlock.slice(0, PREVIOUS_BLOCK_TRUNCATE_CHARS);
|
|
36
|
+
return [
|
|
37
|
+
ctx.basePrompt,
|
|
38
|
+
"",
|
|
39
|
+
ctx.contractInstruction,
|
|
40
|
+
"",
|
|
41
|
+
"Your previous reply did not satisfy the contract.",
|
|
42
|
+
"Previous block:",
|
|
43
|
+
previous,
|
|
44
|
+
"Problems:",
|
|
45
|
+
...issueLines,
|
|
46
|
+
"Reply again with only the corrected JSON between the markers.",
|
|
47
|
+
].join("\n");
|
|
48
|
+
}
|
|
49
|
+
function toIssuePath(path) {
|
|
50
|
+
if (path === undefined) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
return path.map((segment) => {
|
|
54
|
+
const key = typeof segment === "object" && segment !== null && "key" in segment
|
|
55
|
+
? segment.key
|
|
56
|
+
: segment;
|
|
57
|
+
return typeof key === "number" ? key : String(key);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function toIssues(issues) {
|
|
61
|
+
return issues.map((issue) => ({
|
|
62
|
+
path: toIssuePath(issue.path),
|
|
63
|
+
code: "schema",
|
|
64
|
+
message: issue.message,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
function resolveParse(schema) {
|
|
68
|
+
if (typeof schema === "function") {
|
|
69
|
+
return async (block) => schema(block);
|
|
70
|
+
}
|
|
71
|
+
return async (block) => {
|
|
72
|
+
const parsed = parseJsonResilient(block);
|
|
73
|
+
if (!parsed.ok) {
|
|
74
|
+
return {
|
|
75
|
+
ok: false,
|
|
76
|
+
issues: [{ path: [], code: "invalid_json", message: parsed.error }],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
const validated = await schema["~standard"].validate(parsed.value);
|
|
80
|
+
if (validated.issues !== undefined) {
|
|
81
|
+
return { ok: false, issues: toIssues(validated.issues) };
|
|
82
|
+
}
|
|
83
|
+
return { ok: true, value: validated.value };
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function resolveContract(contract) {
|
|
87
|
+
const markers = contract.markers ?? DEFAULT_MARKERS;
|
|
88
|
+
const validate = contract.validate?.bind(contract);
|
|
89
|
+
const instruction = contract.renderContract?.(markers) ?? defaultContractInstruction(markers);
|
|
90
|
+
return {
|
|
91
|
+
parse: resolveParse(contract.schema),
|
|
92
|
+
markers,
|
|
93
|
+
strategies: contract.extractionStrategies ?? defaultExtractionStrategies,
|
|
94
|
+
instruction,
|
|
95
|
+
initialPrompt: contract.promptPlacement === CONTRACT_PROMPT_PLACEMENT.append
|
|
96
|
+
? (basePrompt) => `${basePrompt}\n\n${instruction}`
|
|
97
|
+
: (basePrompt) => basePrompt,
|
|
98
|
+
maxRepairs: contract.repair?.maxAttempts ?? DEFAULT_MAX_REPAIRS,
|
|
99
|
+
shouldRetry: contract.repair?.shouldRetry ?? (() => true),
|
|
100
|
+
renderRepairPrompt: contract.repair?.renderRepairPrompt ?? defaultRepairPrompt,
|
|
101
|
+
validate: validate === undefined
|
|
102
|
+
? async () => []
|
|
103
|
+
: async (value) => validate(value),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async function evaluateRun(contract, text) {
|
|
107
|
+
const block = extractBlock(text, contract.markers, contract.strategies);
|
|
108
|
+
if (block === null) {
|
|
109
|
+
return {
|
|
110
|
+
block,
|
|
111
|
+
outcome: {
|
|
112
|
+
ok: false,
|
|
113
|
+
issues: [
|
|
114
|
+
{
|
|
115
|
+
path: [],
|
|
116
|
+
code: "no_output_block",
|
|
117
|
+
message: "No output block was found in the agent's reply",
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
const outcome = await contract.parse(block);
|
|
124
|
+
if (!outcome.ok) {
|
|
125
|
+
return { block, outcome };
|
|
126
|
+
}
|
|
127
|
+
const semanticIssues = await contract.validate(outcome.value);
|
|
128
|
+
if (semanticIssues.length > 0) {
|
|
129
|
+
return { block, outcome: { ok: false, issues: semanticIssues } };
|
|
130
|
+
}
|
|
131
|
+
return { block, outcome };
|
|
132
|
+
}
|
|
133
|
+
export function startStructuredRun(input) {
|
|
134
|
+
const broadcast = new EventBroadcast();
|
|
135
|
+
const result = driveStructured(input, broadcast);
|
|
136
|
+
// A caller may only iterate events; keep the result rejection observed.
|
|
137
|
+
result.catch(() => { });
|
|
138
|
+
return Object.assign(result, { events: broadcast.events, result });
|
|
139
|
+
}
|
|
140
|
+
async function driveStructured(input, broadcast) {
|
|
141
|
+
const resolved = resolveContract(input.contract);
|
|
142
|
+
const attempts = [];
|
|
143
|
+
let prompt = resolved.initialPrompt(input.options.prompt);
|
|
144
|
+
let lastIssues = [];
|
|
145
|
+
let lastRun = null;
|
|
146
|
+
try {
|
|
147
|
+
for (let attempt = 0; attempt <= resolved.maxRepairs; attempt += 1) {
|
|
148
|
+
const result = await forwardRun(input.runAttempt({ ...input.options, prompt }), broadcast);
|
|
149
|
+
lastRun = result;
|
|
150
|
+
const { block, outcome } = await evaluateRun(resolved, result.text);
|
|
151
|
+
if (outcome.ok) {
|
|
152
|
+
return { output: outcome.value, result, attempts };
|
|
153
|
+
}
|
|
154
|
+
lastIssues = outcome.issues;
|
|
155
|
+
attempts.push({ runId: result.runId, issues: outcome.issues, block });
|
|
156
|
+
if (attempt >= resolved.maxRepairs ||
|
|
157
|
+
!resolved.shouldRetry(outcome.issues, attempt + 1)) {
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
prompt = resolved.renderRepairPrompt({
|
|
161
|
+
basePrompt: input.options.prompt,
|
|
162
|
+
contractInstruction: resolved.instruction,
|
|
163
|
+
attempt: attempt + 1,
|
|
164
|
+
issues: outcome.issues,
|
|
165
|
+
previousBlock: block,
|
|
166
|
+
markers: resolved.markers,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
const errorOptions = {
|
|
170
|
+
code: AGENT_ERROR_CODE.outputRejected,
|
|
171
|
+
message: "Structured output contract was not satisfied within the repair budget",
|
|
172
|
+
data: { issues: lastIssues, attempts: attempts.length },
|
|
173
|
+
agentId: input.agentId,
|
|
174
|
+
started: true,
|
|
175
|
+
};
|
|
176
|
+
if (lastRun !== null) {
|
|
177
|
+
errorOptions.runId = lastRun.runId;
|
|
178
|
+
}
|
|
179
|
+
throw new AgentError(errorOptions);
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
broadcast.end();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Forward one run's events into the structured broadcast, then return its
|
|
187
|
+
* result. The pump is awaited even on failure so no attempt's events leak
|
|
188
|
+
* past the structured stream into the next attempt.
|
|
189
|
+
*/
|
|
190
|
+
async function forwardRun(handle, broadcast) {
|
|
191
|
+
const pumping = (async () => {
|
|
192
|
+
for await (const event of handle.events) {
|
|
193
|
+
broadcast.push(event);
|
|
194
|
+
}
|
|
195
|
+
})();
|
|
196
|
+
try {
|
|
197
|
+
return await handle.result;
|
|
198
|
+
}
|
|
199
|
+
finally {
|
|
200
|
+
await pumping;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standard Schema v1 interface, vendored per the spec's guidance
|
|
3
|
+
* (https://standardschema.dev) so no validator library types cross the
|
|
4
|
+
* package boundary. zod v4, valibot, and arktype all implement this.
|
|
5
|
+
*/
|
|
6
|
+
export type StandardSchemaV1<Input = unknown, Output = Input> = {
|
|
7
|
+
readonly "~standard": StandardSchemaProps<Input, Output>;
|
|
8
|
+
};
|
|
9
|
+
export type StandardSchemaProps<Input, Output> = {
|
|
10
|
+
readonly version: 1;
|
|
11
|
+
readonly vendor: string;
|
|
12
|
+
readonly validate: (value: unknown) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;
|
|
13
|
+
readonly types?: StandardSchemaTypes<Input, Output> | undefined;
|
|
14
|
+
};
|
|
15
|
+
export type StandardSchemaResult<Output> = StandardSchemaSuccessResult<Output> | StandardSchemaFailureResult;
|
|
16
|
+
export type StandardSchemaSuccessResult<Output> = {
|
|
17
|
+
readonly value: Output;
|
|
18
|
+
readonly issues?: undefined;
|
|
19
|
+
};
|
|
20
|
+
export type StandardSchemaFailureResult = {
|
|
21
|
+
readonly issues: ReadonlyArray<StandardSchemaIssue>;
|
|
22
|
+
};
|
|
23
|
+
export type StandardSchemaIssue = {
|
|
24
|
+
readonly message: string;
|
|
25
|
+
readonly path?: ReadonlyArray<PropertyKey | StandardSchemaPathSegment> | undefined;
|
|
26
|
+
};
|
|
27
|
+
export type StandardSchemaPathSegment = {
|
|
28
|
+
readonly key: PropertyKey;
|
|
29
|
+
};
|
|
30
|
+
export type StandardSchemaTypes<Input, Output> = {
|
|
31
|
+
readonly input: Input;
|
|
32
|
+
readonly output: Output;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=standard-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard-schema.d.ts","sourceRoot":"","sources":["../../src/structured/standard-schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,MAAM,gBAAgB,CAAC,KAAK,GAAG,OAAO,EAAE,MAAM,GAAG,KAAK,IAAI;IAC9D,QAAQ,CAAC,WAAW,EAAE,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,KAAK,EAAE,MAAM,IAAI;IAC/C,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,OAAO,KACX,oBAAoB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC,CAAC;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,mBAAmB,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;CACjE,CAAC;AAEF,MAAM,MAAM,oBAAoB,CAAC,MAAM,IACnC,2BAA2B,CAAC,MAAM,CAAC,GACnC,2BAA2B,CAAC;AAEhC,MAAM,MAAM,2BAA2B,CAAC,MAAM,IAAI;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;CACrD,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,IAAI,CAAC,EACV,aAAa,CAAC,WAAW,GAAG,yBAAyB,CAAC,GACtD,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,CAAC,GAAG,EAAE,WAAW,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,KAAK,EAAE,MAAM,IAAI;IAC/C,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { AgentError } from "../core/error.js";
|
|
2
|
+
import type { AgentEvent } from "../core/run.js";
|
|
3
|
+
import type { AgentDefinition } from "../kernel/definition.js";
|
|
4
|
+
import type { ResolvedRunOptions } from "../kernel/options.js";
|
|
5
|
+
export declare const FAKE_AGENT_BEHAVIOR_KIND: {
|
|
6
|
+
readonly succeed: "succeed";
|
|
7
|
+
readonly fail: "fail";
|
|
8
|
+
readonly waitForAbort: "wait-for-abort";
|
|
9
|
+
};
|
|
10
|
+
export type FakeAgentBehavior = {
|
|
11
|
+
kind: typeof FAKE_AGENT_BEHAVIOR_KIND.succeed;
|
|
12
|
+
text: string;
|
|
13
|
+
events?: AgentEvent[];
|
|
14
|
+
} | {
|
|
15
|
+
kind: typeof FAKE_AGENT_BEHAVIOR_KIND.fail;
|
|
16
|
+
error: AgentError;
|
|
17
|
+
} | {
|
|
18
|
+
kind: typeof FAKE_AGENT_BEHAVIOR_KIND.waitForAbort;
|
|
19
|
+
};
|
|
20
|
+
export type FakeAgentCall = {
|
|
21
|
+
options: ResolvedRunOptions;
|
|
22
|
+
env: Record<string, string>;
|
|
23
|
+
};
|
|
24
|
+
export type FakeAgentDefinition<Id extends string> = AgentDefinition<Id> & {
|
|
25
|
+
readonly calls: FakeAgentCall[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* In-process fake for composition-layer tests. Behaviors are consumed in
|
|
29
|
+
* order; the last one repeats.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fakeAgent<const Id extends string>(id: Id, behavior: FakeAgentBehavior | FakeAgentBehavior[]): FakeAgentDefinition<Id>;
|
|
32
|
+
//# sourceMappingURL=fake-agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-agent.d.ts","sourceRoot":"","sources":["../../src/testing/fake-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAc,MAAM,yBAAyB,CAAC;AAC3E,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,eAAO,MAAM,wBAAwB;;;;CAI3B,CAAC;AAEX,MAAM,MAAM,iBAAiB,GACzB;IACE,IAAI,EAAE,OAAO,wBAAwB,CAAC,OAAO,CAAC;IAC9C,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;CACvB,GACD;IAAE,IAAI,EAAE,OAAO,wBAAwB,CAAC,IAAI,CAAC;IAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GACjE;IAAE,IAAI,EAAE,OAAO,wBAAwB,CAAC,YAAY,CAAA;CAAE,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAC1B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,EAAE,SAAS,MAAM,IAAI,eAAe,CAAC,EAAE,CAAC,GAAG;IACzE,QAAQ,CAAC,KAAK,EAAE,aAAa,EAAE,CAAC;CACjC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,SAAS,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAC/C,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,iBAAiB,GAAG,iBAAiB,EAAE,GAChD,mBAAmB,CAAC,EAAE,CAAC,CAoCzB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export const FAKE_AGENT_BEHAVIOR_KIND = {
|
|
2
|
+
succeed: "succeed",
|
|
3
|
+
fail: "fail",
|
|
4
|
+
waitForAbort: "wait-for-abort",
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* In-process fake for composition-layer tests. Behaviors are consumed in
|
|
8
|
+
* order; the last one repeats.
|
|
9
|
+
*/
|
|
10
|
+
export function fakeAgent(id, behavior) {
|
|
11
|
+
const behaviors = Array.isArray(behavior) ? behavior : [behavior];
|
|
12
|
+
const calls = [];
|
|
13
|
+
let callIndex = 0;
|
|
14
|
+
async function* run(options, ctx) {
|
|
15
|
+
calls.push({ options, env: ctx.env });
|
|
16
|
+
const current = behaviors[Math.min(callIndex, behaviors.length - 1)] ??
|
|
17
|
+
{
|
|
18
|
+
kind: FAKE_AGENT_BEHAVIOR_KIND.succeed,
|
|
19
|
+
text: "",
|
|
20
|
+
};
|
|
21
|
+
callIndex += 1;
|
|
22
|
+
if (current.kind === FAKE_AGENT_BEHAVIOR_KIND.fail) {
|
|
23
|
+
throw current.error;
|
|
24
|
+
}
|
|
25
|
+
if (current.kind === FAKE_AGENT_BEHAVIOR_KIND.waitForAbort) {
|
|
26
|
+
await new Promise((resolve) => {
|
|
27
|
+
ctx.signal.addEventListener("abort", () => resolve(), { once: true });
|
|
28
|
+
});
|
|
29
|
+
throw new Error("aborted");
|
|
30
|
+
}
|
|
31
|
+
for (const event of current.events ?? []) {
|
|
32
|
+
yield event;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
text: current.text,
|
|
36
|
+
model: null,
|
|
37
|
+
exit: null,
|
|
38
|
+
raw: null,
|
|
39
|
+
usage: null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return { id, run, calls };
|
|
43
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Clock } from "../core/ports.js";
|
|
2
|
+
export type FakeClock = Clock & {
|
|
3
|
+
/** Advance time, firing due timers in order. */
|
|
4
|
+
advance(ms: number): void;
|
|
5
|
+
pendingTimerCount(): number;
|
|
6
|
+
};
|
|
7
|
+
export declare function fakeClock(startMs?: number): FakeClock;
|
|
8
|
+
//# sourceMappingURL=fake-clock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-clock.d.ts","sourceRoot":"","sources":["../../src/testing/fake-clock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG;IAC9B,gDAAgD;IAChD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,iBAAiB,IAAI,MAAM,CAAC;CAC7B,CAAC;AAQF,wBAAgB,SAAS,CAAC,OAAO,SAAI,GAAG,SAAS,CA+ChD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export function fakeClock(startMs = 0) {
|
|
2
|
+
let nowMs = startMs;
|
|
3
|
+
let nextOrder = 0;
|
|
4
|
+
const timers = new Set();
|
|
5
|
+
const dueTimer = (until) => {
|
|
6
|
+
let earliest = null;
|
|
7
|
+
for (const timer of timers) {
|
|
8
|
+
if (timer.at > until) {
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
if (earliest === null ||
|
|
12
|
+
timer.at < earliest.at ||
|
|
13
|
+
(timer.at === earliest.at && timer.order < earliest.order)) {
|
|
14
|
+
earliest = timer;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return earliest;
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
now: () => nowMs,
|
|
21
|
+
setTimeout: (callback, delayMs) => {
|
|
22
|
+
const timer = {
|
|
23
|
+
at: nowMs + delayMs,
|
|
24
|
+
order: nextOrder,
|
|
25
|
+
callback,
|
|
26
|
+
};
|
|
27
|
+
nextOrder += 1;
|
|
28
|
+
timers.add(timer);
|
|
29
|
+
return () => timers.delete(timer);
|
|
30
|
+
},
|
|
31
|
+
advance: (ms) => {
|
|
32
|
+
const target = nowMs + ms;
|
|
33
|
+
let timer = dueTimer(target);
|
|
34
|
+
while (timer !== null) {
|
|
35
|
+
nowMs = Math.max(nowMs, timer.at);
|
|
36
|
+
timers.delete(timer);
|
|
37
|
+
timer.callback();
|
|
38
|
+
timer = dueTimer(target);
|
|
39
|
+
}
|
|
40
|
+
nowMs = target;
|
|
41
|
+
},
|
|
42
|
+
pendingTimerCount: () => timers.size,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Exec, ExecChunk, ExecExit, ExecSpawnOptions, InteractiveExecSpawnOptions } from "../core/ports.js";
|
|
2
|
+
export type FakeExecScript = {
|
|
3
|
+
chunks?: ExecChunk[];
|
|
4
|
+
exitCode?: number;
|
|
5
|
+
/** Absent = exited without a signal. */
|
|
6
|
+
exitSignal?: string;
|
|
7
|
+
/** Keep the stream open until killed (timeout / early-completion tests). */
|
|
8
|
+
hang?: boolean;
|
|
9
|
+
/** Survive SIGTERM so SIGKILL escalation can be observed. */
|
|
10
|
+
ignoreSigterm?: boolean;
|
|
11
|
+
onWrite?: (text: string, controls: {
|
|
12
|
+
stdout(text: string): void;
|
|
13
|
+
stderr(text: string): void;
|
|
14
|
+
exit(exit: ExecExit): void;
|
|
15
|
+
}) => void;
|
|
16
|
+
};
|
|
17
|
+
export type FakeExec = Exec & {
|
|
18
|
+
readonly spawns: (ExecSpawnOptions | InteractiveExecSpawnOptions)[];
|
|
19
|
+
readonly stdinWrites: string[][];
|
|
20
|
+
/** Kill signals recorded per spawn, in order. */
|
|
21
|
+
readonly kills: string[][];
|
|
22
|
+
/** Commands `which` should report as missing. */
|
|
23
|
+
readonly missingCommands: Set<string>;
|
|
24
|
+
};
|
|
25
|
+
export declare function fakeExec(scripts?: FakeExecScript[]): FakeExec;
|
|
26
|
+
//# sourceMappingURL=fake-exec.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-exec.d.ts","sourceRoot":"","sources":["../../src/testing/fake-exec.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,gBAAgB,EAEhB,2BAA2B,EAC5B,MAAM,kBAAkB,CAAC;AAG1B,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,CAAC,EAAE,SAAS,EAAE,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4EAA4E;IAC5E,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,6DAA6D;IAC7D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,OAAO,CAAC,EAAE,CACR,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE;QACR,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;KAC5B,KACE,IAAI,CAAC;CACX,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG;IAC5B,QAAQ,CAAC,MAAM,EAAE,CAAC,gBAAgB,GAAG,2BAA2B,CAAC,EAAE,CAAC;IACpE,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,CAAC;IACjC,iDAAiD;IACjD,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACvC,CAAC;AAEF,wBAAgB,QAAQ,CAAC,OAAO,GAAE,cAAc,EAAO,GAAG,QAAQ,CA4EjE"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { AsyncQueue } from "../core/async-queue.js";
|
|
2
|
+
import { OUTPUT_CHANNEL, PROCESS_SIGNAL } from "../core/values.js";
|
|
3
|
+
export function fakeExec(scripts = []) {
|
|
4
|
+
const remaining = [...scripts];
|
|
5
|
+
const spawns = [];
|
|
6
|
+
const stdinWrites = [];
|
|
7
|
+
const kills = [];
|
|
8
|
+
const missingCommands = new Set();
|
|
9
|
+
return {
|
|
10
|
+
spawns,
|
|
11
|
+
stdinWrites,
|
|
12
|
+
kills,
|
|
13
|
+
missingCommands,
|
|
14
|
+
which: (command) => Promise.resolve(missingCommands.has(command) ? null : `/fake/bin/${command}`),
|
|
15
|
+
spawn: (options) => {
|
|
16
|
+
spawns.push(options);
|
|
17
|
+
const script = remaining.shift() ?? {};
|
|
18
|
+
const killSignals = [];
|
|
19
|
+
const writes = [];
|
|
20
|
+
kills.push(killSignals);
|
|
21
|
+
stdinWrites.push(writes);
|
|
22
|
+
const chunks = new AsyncQueue();
|
|
23
|
+
for (const chunk of script.chunks ?? []) {
|
|
24
|
+
chunks.push(chunk);
|
|
25
|
+
}
|
|
26
|
+
let settleExit = () => { };
|
|
27
|
+
const exit = new Promise((resolve) => {
|
|
28
|
+
settleExit = resolve;
|
|
29
|
+
});
|
|
30
|
+
let finished = false;
|
|
31
|
+
const finish = (value) => {
|
|
32
|
+
if (finished) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
finished = true;
|
|
36
|
+
chunks.end();
|
|
37
|
+
settleExit(value);
|
|
38
|
+
};
|
|
39
|
+
const controls = {
|
|
40
|
+
stdout: (text) => chunks.push({ channel: OUTPUT_CHANNEL.stdout, text }),
|
|
41
|
+
stderr: (text) => chunks.push({ channel: OUTPUT_CHANNEL.stderr, text }),
|
|
42
|
+
exit: finish,
|
|
43
|
+
};
|
|
44
|
+
if (script.hang !== true) {
|
|
45
|
+
finish({
|
|
46
|
+
code: script.exitCode ?? 0,
|
|
47
|
+
signal: script.exitSignal ?? null,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
chunks,
|
|
52
|
+
exit,
|
|
53
|
+
writeStdin: (text) => {
|
|
54
|
+
writes.push(text);
|
|
55
|
+
script.onWrite?.(text, controls);
|
|
56
|
+
},
|
|
57
|
+
endStdin: () => { },
|
|
58
|
+
kill: (signal) => {
|
|
59
|
+
killSignals.push(signal);
|
|
60
|
+
if (signal === PROCESS_SIGNAL.sigterm &&
|
|
61
|
+
script.ignoreSigterm === true) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
finish({ code: null, signal });
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fake-secrets.d.ts","sourceRoot":"","sources":["../../src/testing/fake-secrets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAEvD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,cAAc,CAIhB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@alpacakit/agents/testing` — fakes for every port. Dev-only; the
|
|
3
|
+
* kernel and fleet are fully testable without spawning anything.
|
|
4
|
+
* In-memory stores are NOT here: they are real adapters in the root.
|
|
5
|
+
*/
|
|
6
|
+
export { FAKE_AGENT_BEHAVIOR_KIND, type FakeAgentBehavior, type FakeAgentCall, type FakeAgentDefinition, fakeAgent, } from "./fake-agent.js";
|
|
7
|
+
export { type FakeClock, fakeClock } from "./fake-clock.js";
|
|
8
|
+
export { type FakeExec, type FakeExecScript, fakeExec } from "./fake-exec.js";
|
|
9
|
+
export { fakeSecretResolver } from "./fake-secrets.js";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,wBAAwB,EACxB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@alpacakit/agents/testing` — fakes for every port. Dev-only; the
|
|
3
|
+
* kernel and fleet are fully testable without spawning anything.
|
|
4
|
+
* In-memory stores are NOT here: they are real adapters in the root.
|
|
5
|
+
*/
|
|
6
|
+
export { FAKE_AGENT_BEHAVIOR_KIND, fakeAgent, } from "./fake-agent.js";
|
|
7
|
+
export { fakeClock } from "./fake-clock.js";
|
|
8
|
+
export { fakeExec } from "./fake-exec.js";
|
|
9
|
+
export { fakeSecretResolver } from "./fake-secrets.js";
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@alpacakit/agents",
|
|
3
|
+
"version": "0.1.0-beta.19",
|
|
4
|
+
"description": "Run AI coding agents programmatically: execute, stream, classify failures, fail over.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./config": {
|
|
13
|
+
"types": "./dist/config/index.d.ts",
|
|
14
|
+
"import": "./dist/config/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./config/extension": {
|
|
17
|
+
"types": "./dist/config/extension.d.ts",
|
|
18
|
+
"import": "./dist/config/extension.js"
|
|
19
|
+
},
|
|
20
|
+
"./config/xdg": {
|
|
21
|
+
"types": "./dist/config/xdg.d.ts",
|
|
22
|
+
"import": "./dist/config/xdg.js"
|
|
23
|
+
},
|
|
24
|
+
"./codex": {
|
|
25
|
+
"types": "./dist/codex/index.d.ts",
|
|
26
|
+
"import": "./dist/codex/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./keyring": {
|
|
29
|
+
"types": "./dist/keyring/index.d.ts",
|
|
30
|
+
"import": "./dist/keyring/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./testing": {
|
|
33
|
+
"types": "./dist/testing/index.d.ts",
|
|
34
|
+
"import": "./dist/testing/index.js"
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"README*.md",
|
|
41
|
+
"LICENSE"
|
|
42
|
+
],
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"registry": "https://registry.npmjs.org/"
|
|
46
|
+
},
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22.19.0"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"zod": "^4.3.6",
|
|
52
|
+
"@alpacakit/core": "0.1.0-beta.19"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"typescript": "^5.9.3",
|
|
56
|
+
"vitest": "^4.0.18"
|
|
57
|
+
},
|
|
58
|
+
"peerDependencies": {
|
|
59
|
+
"@earendil-works/pi-coding-agent": "0.75.5",
|
|
60
|
+
"@napi-rs/keyring": "^1.3.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependenciesMeta": {
|
|
63
|
+
"@earendil-works/pi-coding-agent": {
|
|
64
|
+
"optional": true
|
|
65
|
+
},
|
|
66
|
+
"@napi-rs/keyring": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "tsc -p tsconfig.build.json",
|
|
72
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
73
|
+
"test": "vitest run"
|
|
74
|
+
}
|
|
75
|
+
}
|