@automatalabs/acp-agents 0.5.0 → 0.5.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/dist/backend.d.ts
CHANGED
|
@@ -26,6 +26,12 @@ export interface SessionMetaInputs {
|
|
|
26
26
|
}
|
|
27
27
|
export interface Backend {
|
|
28
28
|
readonly id: BackendId;
|
|
29
|
+
/** When true, the runner EMBEDS the JSON Schema in the prompt text on schema runs. For the
|
|
30
|
+
* built-ins the native constraint channel is authoritative and this stays unset; a CUSTOM
|
|
31
|
+
* backend sets it because its agent may ignore the `_meta.outputSchema` forward entirely —
|
|
32
|
+
* without the schema in the prompt, such an agent returns well-formed JSON with the WRONG
|
|
33
|
+
* KEYS and the repair ladder can never converge (it can fix prose, not unseen contracts). */
|
|
34
|
+
readonly embedSchemaInPrompt?: boolean;
|
|
29
35
|
/** How to launch this backend's ACP server over stdio. */
|
|
30
36
|
spawnConfig(): SpawnConfig;
|
|
31
37
|
/** OPTIONAL backend-level `_meta` DEFAULTS for session/new (e.g. a custom registry entry's
|
package/dist/backend.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../src/backend.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,4FAA4F;AAC5F,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,OAAO,CAAC;AAClD;sFACsF;AACtF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC;AAE/B,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC,UAAU,CAAC;CACxB;AAED,8FAA8F;AAC9F,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,eAAe,IAAI,MAAM,CAAC;IAC1B,uGAAuG;IACvG,mBAAmB,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AU,CAAC;CACxB;AAED,8FAA8F;AAC9F,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,eAAe,IAAI,MAAM,CAAC;IAC1B,uGAAuG;IACvG,mBAAmB,IAAI,OAAO,CAAC;CAChC;AAED;+EAC+E;AAC/E,MAAM,WAAW,iBAAiB;IAChC,yFAAyF;IACzF,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sFAAsF;IACtF,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC;AAED,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB;;;;kGAI8F;IAC9F,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,0DAA0D;IAC1D,WAAW,IAAI,WAAW,CAAC;IAC3B;;sEAEkE;IAClE,mBAAmB,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5D;;;mGAG+F;IAC/F,WAAW,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,CAAC,EAAE,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC1G,kGAAkG;IAClG,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC7E,oGAAoG;IACpG,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC;CACrD;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAE7D"}
|
|
@@ -4,6 +4,10 @@ import type { RegisteredBackend } from "../registry.js";
|
|
|
4
4
|
export declare class CustomAcpBackend implements Backend {
|
|
5
5
|
private readonly config;
|
|
6
6
|
readonly id: string;
|
|
7
|
+
/** The agent may ignore the `_meta.outputSchema` forward, so the runner must also state the
|
|
8
|
+
* schema in the prompt — otherwise the model returns JSON with keys it invented and the
|
|
9
|
+
* repair ladder can never converge on a contract the model was never shown. */
|
|
10
|
+
readonly embedSchemaInPrompt = true;
|
|
7
11
|
constructor(config: RegisteredBackend);
|
|
8
12
|
spawnConfig(): SpawnConfig;
|
|
9
13
|
sessionMetaDefaults(): Record<string, unknown> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/backends/custom.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,qBAAa,gBAAiB,YAAW,OAAO;
|
|
1
|
+
{"version":3,"file":"custom.d.ts","sourceRoot":"","sources":["../../src/backends/custom.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAIxD,qBAAa,gBAAiB,YAAW,OAAO;IAOlC,OAAO,CAAC,QAAQ,CAAC,MAAM;IANnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB;;oFAEgF;IAChF,QAAQ,CAAC,mBAAmB,QAAQ;gBAEP,MAAM,EAAE,iBAAiB;IAItD,WAAW,IAAI,WAAW;IAS1B,mBAAmB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAQ1D,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAM9E,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS;IAQ5E,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO;CAGpD"}
|
package/dist/backends/custom.js
CHANGED
|
@@ -4,6 +4,10 @@ import { parseFinalJson } from "../structured-output.js";
|
|
|
4
4
|
export class CustomAcpBackend {
|
|
5
5
|
config;
|
|
6
6
|
id;
|
|
7
|
+
/** The agent may ignore the `_meta.outputSchema` forward, so the runner must also state the
|
|
8
|
+
* schema in the prompt — otherwise the model returns JSON with keys it invented and the
|
|
9
|
+
* repair ladder can never converge on a contract the model was never shown. */
|
|
10
|
+
embedSchemaInPrompt = true;
|
|
7
11
|
constructor(config) {
|
|
8
12
|
this.config = config;
|
|
9
13
|
this.id = config.name;
|
package/dist/runner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAkBA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EAGlB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAI5C,OAAO,EAA0B,KAAK,eAAe,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../src/runner.ts"],"names":[],"mappings":"AAkBA,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,4BA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AE,YAAY,GAAG,MAAM;IAInC,GAAG,CAAC,CAAC,SAAS,OAAO,GAAG,SAAS,GAAG,SAAS,EACjD,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,UAAU,CAAC,CAAC,CAAM,GAC1B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IA+F1B;qGACiG;IAC3F,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAI/B;AAED;;;qDAGqD;AACrD,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,gBAAgB,GAAG,cAAc,CAE1E;AAmFD;;;;oCAIoC;AACpC,wBAAgB,aAAa,CAAC,IAAI,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,OAAO,CAM1G"}
|
package/dist/runner.js
CHANGED
|
@@ -24,6 +24,7 @@ import { CodexBackend } from "./backends/codex.js";
|
|
|
24
24
|
import { CustomAcpBackend } from "./backends/custom.js";
|
|
25
25
|
import { resolveBackendRegistry } from "./registry.js";
|
|
26
26
|
import { mapThrownError } from "./errors-map.js";
|
|
27
|
+
import { toJsonSchema } from "./schema-strict.js";
|
|
27
28
|
import { resolveStructuredOutput } from "./structured-output.js";
|
|
28
29
|
export class AcpAgentRunner {
|
|
29
30
|
pool;
|
|
@@ -92,7 +93,7 @@ export class AcpAgentRunner {
|
|
|
92
93
|
// model id: "browser" selects nothing; "browser/foo" selects "foo". Built-ins get the
|
|
93
94
|
// full spec unchanged (their catalogs match provider-prefixed and bare ids).
|
|
94
95
|
await applyModelSelection(session, innerModelSpec(opts.model ?? opts.tier, backend), opts);
|
|
95
|
-
const text = buildPrompt(prompt, opts,
|
|
96
|
+
const text = buildPrompt(prompt, opts, schema, backend);
|
|
96
97
|
// Generic turn-scoped _meta passthrough merged UNDER the backend-computed keys (e.g. the
|
|
97
98
|
// outputSchema forward when a schema is set) — user meta never clobbers the schema channel.
|
|
98
99
|
const promptMeta = mergeTurnMeta(opts.promptMeta, backend.promptMeta(schema));
|
|
@@ -218,20 +219,28 @@ async function applyModelSelection(session, spec, opts) {
|
|
|
218
219
|
for (const fallback of modifierFallbacks ?? [])
|
|
219
220
|
opts.onModelFallback?.(fallback);
|
|
220
221
|
}
|
|
221
|
-
function buildPrompt(prompt, opts,
|
|
222
|
+
function buildPrompt(prompt, opts, schema, backend) {
|
|
222
223
|
const parts = [];
|
|
223
224
|
if (opts.instructions)
|
|
224
225
|
parts.push(opts.instructions);
|
|
225
226
|
if (opts.label)
|
|
226
227
|
parts.push(`Task label: ${opts.label}`);
|
|
227
228
|
parts.push(prompt);
|
|
228
|
-
if (
|
|
229
|
-
|
|
229
|
+
if (schema) {
|
|
230
|
+
const contract = [
|
|
230
231
|
"Final output contract:",
|
|
231
232
|
"- Your FINAL message MUST be a single JSON object that conforms to the required output schema.",
|
|
232
233
|
"- Output ONLY that JSON object — no prose, no explanation, and no markdown code fences.",
|
|
233
234
|
"- If you need to inspect files or run commands first, do so, then emit the JSON object as your final message.",
|
|
234
|
-
]
|
|
235
|
+
];
|
|
236
|
+
if (backend.embedSchemaInPrompt) {
|
|
237
|
+
// The agent behind a custom backend may ignore the `_meta.outputSchema` forward, so the
|
|
238
|
+
// schema must be STATED, not just wired — otherwise the model invents its own keys and
|
|
239
|
+
// the repair ladder can never converge. Built-ins skip this: their native constraint
|
|
240
|
+
// channel is authoritative.
|
|
241
|
+
contract.push(`- The required output schema (JSON Schema):\n${JSON.stringify(toJsonSchema(schema))}`);
|
|
242
|
+
}
|
|
243
|
+
parts.push(contract.join("\n"));
|
|
235
244
|
}
|
|
236
245
|
return parts.join("\n\n");
|
|
237
246
|
}
|