@davidorex/pi-jit-agents 0.14.6
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 +1 -0
- package/README.md +45 -0
- package/dist/agent-spec.d.ts +24 -0
- package/dist/agent-spec.d.ts.map +1 -0
- package/dist/agent-spec.js +126 -0
- package/dist/agent-spec.js.map +1 -0
- package/dist/agent-trace-sdk.d.ts +42 -0
- package/dist/agent-trace-sdk.d.ts.map +1 -0
- package/dist/agent-trace-sdk.js +177 -0
- package/dist/agent-trace-sdk.js.map +1 -0
- package/dist/compile.d.ts +17 -0
- package/dist/compile.d.ts.map +1 -0
- package/dist/compile.js +118 -0
- package/dist/compile.js.map +1 -0
- package/dist/errors.d.ts +36 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +56 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/introspect.d.ts +17 -0
- package/dist/introspect.d.ts.map +1 -0
- package/dist/introspect.js +22 -0
- package/dist/introspect.js.map +1 -0
- package/dist/jit-runtime.d.ts +106 -0
- package/dist/jit-runtime.d.ts.map +1 -0
- package/dist/jit-runtime.js +583 -0
- package/dist/jit-runtime.js.map +1 -0
- package/dist/template.d.ts +36 -0
- package/dist/template.d.ts.map +1 -0
- package/dist/template.js +78 -0
- package/dist/template.js.map +1 -0
- package/dist/trace-redactor.d.ts +43 -0
- package/dist/trace-redactor.d.ts.map +1 -0
- package/dist/trace-redactor.js +173 -0
- package/dist/trace-redactor.js.map +1 -0
- package/dist/trace-writer.d.ts +13 -0
- package/dist/trace-writer.d.ts.map +1 -0
- package/dist/trace-writer.js +112 -0
- package/dist/trace-writer.js.map +1 -0
- package/dist/types.d.ts +185 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +71 -0
- package/schemas/agent-trace.schema.json +191 -0
- package/schemas/trace-config.schema.json +58 -0
- package/schemas/verdict.schema.json +14 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed errors for pi-jit-agents.
|
|
3
|
+
*
|
|
4
|
+
* Each error carries enough context for consumer error messages without
|
|
5
|
+
* requiring the consumer to know anything about internal paths or state.
|
|
6
|
+
*/
|
|
7
|
+
/** Thrown when an agent spec file is not found in any discovery tier. */
|
|
8
|
+
export class AgentNotFoundError extends Error {
|
|
9
|
+
agentName;
|
|
10
|
+
searchPaths;
|
|
11
|
+
constructor(agentName, searchPaths) {
|
|
12
|
+
const pathList = searchPaths.map((p) => ` - ${p}`).join("\n");
|
|
13
|
+
super(`Agent '${agentName}' not found. Searched:\n${pathList}`);
|
|
14
|
+
this.name = "AgentNotFoundError";
|
|
15
|
+
this.agentName = agentName;
|
|
16
|
+
this.searchPaths = searchPaths;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Thrown when an agent spec file exists but cannot be read or parsed. */
|
|
20
|
+
export class AgentParseError extends Error {
|
|
21
|
+
agentName;
|
|
22
|
+
filePath;
|
|
23
|
+
cause;
|
|
24
|
+
constructor(agentName, filePath, cause) {
|
|
25
|
+
super(`Agent '${agentName}' at ${filePath}: ${cause.message}`);
|
|
26
|
+
this.name = "AgentParseError";
|
|
27
|
+
this.agentName = agentName;
|
|
28
|
+
this.filePath = filePath;
|
|
29
|
+
this.cause = cause;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** Thrown when compileAgent cannot produce any prompt content. */
|
|
33
|
+
export class AgentCompileError extends Error {
|
|
34
|
+
agentName;
|
|
35
|
+
cause;
|
|
36
|
+
constructor(agentName, message, cause) {
|
|
37
|
+
super(`Agent '${agentName}' compile failed: ${message}`);
|
|
38
|
+
this.name = "AgentCompileError";
|
|
39
|
+
this.agentName = agentName;
|
|
40
|
+
this.cause = cause;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/** Thrown when executeAgent fails or is cancelled. */
|
|
44
|
+
export class AgentDispatchError extends Error {
|
|
45
|
+
agentName;
|
|
46
|
+
stopReason;
|
|
47
|
+
cause;
|
|
48
|
+
constructor(agentName, message, opts) {
|
|
49
|
+
super(`Agent '${agentName}' dispatch failed: ${message}`);
|
|
50
|
+
this.name = "AgentDispatchError";
|
|
51
|
+
this.agentName = agentName;
|
|
52
|
+
this.stopReason = opts?.stopReason;
|
|
53
|
+
this.cause = opts?.cause;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,yEAAyE;AACzE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC5B,SAAS,CAAS;IAClB,WAAW,CAAW;IAEtC,YAAY,SAAiB,EAAE,WAAqB;QACnD,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,KAAK,CAAC,UAAU,SAAS,2BAA2B,QAAQ,EAAE,CAAC,CAAC;QAChE,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IAChC,CAAC;CACD;AAED,0EAA0E;AAC1E,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACzB,SAAS,CAAS;IAClB,QAAQ,CAAS;IACjB,KAAK,CAAQ;IAE7B,YAAY,SAAiB,EAAE,QAAgB,EAAE,KAAY;QAC5D,KAAK,CAAC,UAAU,SAAS,QAAQ,QAAQ,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;CACD;AAED,kEAAkE;AAClE,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC3B,SAAS,CAAS;IAClB,KAAK,CAAS;IAE9B,YAAY,SAAiB,EAAE,OAAe,EAAE,KAAa;QAC5D,KAAK,CAAC,UAAU,SAAS,qBAAqB,OAAO,EAAE,CAAC,CAAC;QACzD,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;CACD;AAED,sDAAsD;AACtD,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC5B,SAAS,CAAS;IAClB,UAAU,CAAU;IACpB,KAAK,CAAS;IAE9B,YAAY,SAAiB,EAAE,OAAe,EAAE,IAA6C;QAC5F,KAAK,CAAC,UAAU,SAAS,sBAAsB,OAAO,EAAE,CAAC,CAAC;QAC1D,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,IAAI,EAAE,UAAU,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,IAAI,EAAE,KAAK,CAAC;IAC1B,CAAC;CACD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @davidorex/pi-jit-agents — Agent spec compilation and in-process dispatch runtime.
|
|
3
|
+
*
|
|
4
|
+
* Owns everything between "I have a spec" and "I have a typed result."
|
|
5
|
+
* See docs/planning/jit-agents-spec.md for the boundary contract and principles.
|
|
6
|
+
*/
|
|
7
|
+
export { createAgentLoader, parseAgentYaml } from "./agent-spec.js";
|
|
8
|
+
export type { AgentTraceQuery } from "./agent-trace-sdk.js";
|
|
9
|
+
export { agentTrace, agentTraceChildren, agentTraceEntry } from "./agent-trace-sdk.js";
|
|
10
|
+
export { compileAgent } from "./compile.js";
|
|
11
|
+
export * from "./errors.js";
|
|
12
|
+
export { agentContract } from "./introspect.js";
|
|
13
|
+
export type { CompleteFn, NormalizedToolChoice } from "./jit-runtime.js";
|
|
14
|
+
export { buildPhantomTool, executeAgent, normalizeToolChoice } from "./jit-runtime.js";
|
|
15
|
+
export type { TemplateEnvContext } from "./template.js";
|
|
16
|
+
export { createTemplateEnv, renderTemplate, renderTemplateFile } from "./template.js";
|
|
17
|
+
export type { RedactionConfig, RedactionPattern } from "./trace-redactor.js";
|
|
18
|
+
export { BUILTIN_PATTERNS, loadProjectRedactionConfig, redactLlmResponse, redactSensitiveData, } from "./trace-redactor.js";
|
|
19
|
+
export type { WriteTraceOptions } from "./trace-writer.js";
|
|
20
|
+
export { dateRotatedPath, writeAgentTrace } from "./trace-writer.js";
|
|
21
|
+
export * from "./types.js";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvF,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACtF,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,EACN,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,cAAc,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @davidorex/pi-jit-agents — Agent spec compilation and in-process dispatch runtime.
|
|
3
|
+
*
|
|
4
|
+
* Owns everything between "I have a spec" and "I have a typed result."
|
|
5
|
+
* See docs/planning/jit-agents-spec.md for the boundary contract and principles.
|
|
6
|
+
*/
|
|
7
|
+
export { createAgentLoader, parseAgentYaml } from "./agent-spec.js";
|
|
8
|
+
export { agentTrace, agentTraceChildren, agentTraceEntry } from "./agent-trace-sdk.js";
|
|
9
|
+
export { compileAgent } from "./compile.js";
|
|
10
|
+
export * from "./errors.js";
|
|
11
|
+
export { agentContract } from "./introspect.js";
|
|
12
|
+
export { buildPhantomTool, executeAgent, normalizeToolChoice } from "./jit-runtime.js";
|
|
13
|
+
export { createTemplateEnv, renderTemplate, renderTemplateFile } from "./template.js";
|
|
14
|
+
// Trace subsystem (issue-023)
|
|
15
|
+
export { BUILTIN_PATTERNS, loadProjectRedactionConfig, redactLlmResponse, redactSensitiveData, } from "./trace-redactor.js";
|
|
16
|
+
export { dateRotatedPath, writeAgentTrace } from "./trace-writer.js";
|
|
17
|
+
export * from "./types.js";
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvF,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAEvF,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEtF,8BAA8B;AAC9B,OAAO,EACN,gBAAgB,EAChB,0BAA0B,EAC1B,iBAAiB,EACjB,mBAAmB,GACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACrE,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent contract introspection — projection of an AgentSpec for SDK queries.
|
|
3
|
+
*
|
|
4
|
+
* Implements the introspection surface of the jit-agents boundary contract
|
|
5
|
+
* (jit-agents-spec.md §2). Consumers ask "what does this agent accept and
|
|
6
|
+
* produce" without dispatching it.
|
|
7
|
+
*/
|
|
8
|
+
import type { AgentContract, AgentSpec } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Project an AgentSpec into an AgentContract.
|
|
11
|
+
*
|
|
12
|
+
* Internal fields (loadedFrom, inline prompt text, template paths) are not
|
|
13
|
+
* exposed. Only the contract-relevant fields: name, role, input schema,
|
|
14
|
+
* context block declarations, output format and schema.
|
|
15
|
+
*/
|
|
16
|
+
export declare function agentContract(spec: AgentSpec): AgentContract;
|
|
17
|
+
//# sourceMappingURL=introspect.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect.d.ts","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE3D;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,aAAa,CAQ5D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project an AgentSpec into an AgentContract.
|
|
3
|
+
*
|
|
4
|
+
* Internal fields (loadedFrom, inline prompt text, template paths) are not
|
|
5
|
+
* exposed. Only the contract-relevant fields: name, role, input schema,
|
|
6
|
+
* context block declarations, output format and schema.
|
|
7
|
+
*/
|
|
8
|
+
export function agentContract(spec) {
|
|
9
|
+
const contract = { name: spec.name };
|
|
10
|
+
if (spec.role !== undefined)
|
|
11
|
+
contract.role = spec.role;
|
|
12
|
+
if (spec.inputSchema !== undefined)
|
|
13
|
+
contract.inputSchema = spec.inputSchema;
|
|
14
|
+
if (spec.contextBlocks !== undefined)
|
|
15
|
+
contract.contextBlocks = spec.contextBlocks;
|
|
16
|
+
if (spec.outputFormat !== undefined)
|
|
17
|
+
contract.outputFormat = spec.outputFormat;
|
|
18
|
+
if (spec.outputSchema !== undefined)
|
|
19
|
+
contract.outputSchema = spec.outputSchema;
|
|
20
|
+
return contract;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=introspect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect.js","sourceRoot":"","sources":["../src/introspect.ts"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,IAAe;IAC5C,MAAM,QAAQ,GAAkB,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC;IACpD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;QAAE,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvD,IAAI,IAAI,CAAC,WAAW,KAAK,SAAS;QAAE,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC;IAC5E,IAAI,IAAI,CAAC,aAAa,KAAK,SAAS;QAAE,QAAQ,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;IAClF,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;QAAE,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IAC/E,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;QAAE,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;IAC/E,OAAO,QAAQ,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Api, Tool } from "@mariozechner/pi-ai";
|
|
2
|
+
import { complete as piAiComplete } from "@mariozechner/pi-ai";
|
|
3
|
+
import type { CompiledAgent, DispatchContext, JitAgentResult } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Injection point for the pi-ai `complete` function. Defaults to the real
|
|
6
|
+
* implementation. Tests override via the optional `completeFn` parameter on
|
|
7
|
+
* `executeAgent`.
|
|
8
|
+
*/
|
|
9
|
+
export type CompleteFn = typeof piAiComplete;
|
|
10
|
+
/**
|
|
11
|
+
* Build a phantom Tool from a JSON Schema file for forced structured output.
|
|
12
|
+
*
|
|
13
|
+
* For the common shape (top-level `type: object` with `required` and
|
|
14
|
+
* `properties` where each property has a primitive `type` and optional
|
|
15
|
+
* `enum`), produces a TypeBox Type.Object matching the schema. Complex shapes
|
|
16
|
+
* (allOf, anyOf, conditional) fall back to a relaxed Type.Object that accepts
|
|
17
|
+
* any object — post-hoc validation via `validateFromFile` catches violations.
|
|
18
|
+
*
|
|
19
|
+
* The tool is never executed — it exists only as a schema constraint that
|
|
20
|
+
* pi-ai enforces via forced toolChoice.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildPhantomTool(schemaPath: string, toolName?: string, description?: string): Tool;
|
|
23
|
+
/**
|
|
24
|
+
* Provider-aware shape returned by `normalizeToolChoice`. The type union
|
|
25
|
+
* covers every shape that any pi-ai 0.70.2 driver currently honors for
|
|
26
|
+
* forced structured output:
|
|
27
|
+
*
|
|
28
|
+
* - Anthropic-native object form (anthropic-messages, bedrock-converse-stream)
|
|
29
|
+
* - OpenAI-compatible function form (openai-completions, mistral-conversations,
|
|
30
|
+
* and the canonical shape for openai-responses / openai-codex-responses /
|
|
31
|
+
* azure-openai-responses if/when those drivers begin honoring toolChoice)
|
|
32
|
+
* - Google string-mode form (google-generative-ai, google-gemini-cli,
|
|
33
|
+
* google-vertex) — only `"any"` is emitted; specific-tool pinning is
|
|
34
|
+
* not exposed by the Google providers in pi-ai 0.70.2
|
|
35
|
+
*
|
|
36
|
+
* pi-ai itself accepts any `unknown` here (toolChoice rides on the
|
|
37
|
+
* `Record<string, unknown>` half of `ProviderStreamOptions`); the explicit
|
|
38
|
+
* union exists for callers that want compile-time discrimination of the
|
|
39
|
+
* normalization output.
|
|
40
|
+
*/
|
|
41
|
+
export type NormalizedToolChoice = {
|
|
42
|
+
type: "tool";
|
|
43
|
+
name: string;
|
|
44
|
+
} | {
|
|
45
|
+
type: "function";
|
|
46
|
+
function: {
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
} | "any";
|
|
50
|
+
/**
|
|
51
|
+
* Map a pi-ai `Api` kind plus a phantom tool name to the `toolChoice` shape
|
|
52
|
+
* the corresponding driver expects.
|
|
53
|
+
*
|
|
54
|
+
* This is the architectural normalization point referenced by ADR-0003: the
|
|
55
|
+
* forced-toolChoice protocol divergence across Anthropic / OpenAI-compatible
|
|
56
|
+
* / Google providers is collapsed here, not at each consumer call site.
|
|
57
|
+
*
|
|
58
|
+
* Coverage map (pi-ai 0.70.2 — verified against
|
|
59
|
+
* `node_modules/@mariozechner/pi-ai/dist/providers/*`):
|
|
60
|
+
*
|
|
61
|
+
* - `anthropic-messages` — passes object through unchanged. Anthropic
|
|
62
|
+
* Messages API expects `{type:"tool", name}`.
|
|
63
|
+
* - `bedrock-converse-stream` — accepts `{type:"tool", name}` and translates
|
|
64
|
+
* internally to Bedrock Converse's `{tool:{name}}` shape (driver line
|
|
65
|
+
* 611-612 of amazon-bedrock.js).
|
|
66
|
+
* - `openai-completions` — passthrough. OpenAI / OpenRouter / OpenAI-
|
|
67
|
+
* compatible gateways expect `{type:"function", function:{name}}` or
|
|
68
|
+
* string `"required"`. Mismatch here is the proximate cause of the
|
|
69
|
+
* "Tool '' not found in provided tools" 400 surfaced post-7edf3a2.
|
|
70
|
+
* - `mistral-conversations` — driver passes the object through its own
|
|
71
|
+
* `mapToolChoice` which reads `choice.function.name`, so the OpenAI-
|
|
72
|
+
* compatible function form is required.
|
|
73
|
+
* - `openai-responses`, `openai-codex-responses`, `azure-openai-responses`
|
|
74
|
+
* — pi-ai 0.70.2 drivers do NOT honor `options.toolChoice` (codex hard-
|
|
75
|
+
* codes `tool_choice: "auto"`; the other two drop it entirely). The
|
|
76
|
+
* OpenAI-compatible function form is emitted here as the canonical
|
|
77
|
+
* shape for the day pi-ai begins forwarding it; today the value is
|
|
78
|
+
* ignored and forced toolChoice is unenforceable on these drivers.
|
|
79
|
+
* Tracked as a pi-ai upstream gap; do not paper over here.
|
|
80
|
+
* - `google-generative-ai`, `google-gemini-cli`, `google-vertex` — drivers
|
|
81
|
+
* accept only string `"any" | "auto" | "none"` (mapped to FunctionCalling-
|
|
82
|
+
* ConfigMode). Specific-tool pinning is not exposed. `"any"` forces
|
|
83
|
+
* tool use; adequate for the phantom-tool single-tool pattern (the model
|
|
84
|
+
* has only one tool to call) but fails to pin a specific tool when
|
|
85
|
+
* multiple tools are present.
|
|
86
|
+
* - Unknown / custom api strings — Anthropic-format default. Matches the
|
|
87
|
+
* pre-fix behavior that worked end-to-end for `anthropic-messages` and
|
|
88
|
+
* preserves backward compatibility for any consumer that registered a
|
|
89
|
+
* custom api provider expecting that shape.
|
|
90
|
+
*/
|
|
91
|
+
export declare function normalizeToolChoice(api: Api, toolName: string): NormalizedToolChoice;
|
|
92
|
+
/**
|
|
93
|
+
* Execute a compiled agent in-process.
|
|
94
|
+
*
|
|
95
|
+
* When `compiled.outputSchema` is set: build a phantom tool from the schema,
|
|
96
|
+
* call pi-ai's `complete` with forced toolChoice, extract ToolCall.arguments,
|
|
97
|
+
* and validate post-hoc against the schema file.
|
|
98
|
+
*
|
|
99
|
+
* When `compiled.outputSchema` is absent: call `complete` without tools and
|
|
100
|
+
* return the extracted text as `output`.
|
|
101
|
+
*
|
|
102
|
+
* Test hook: `completeFn` overrides the pi-ai `complete` import for unit
|
|
103
|
+
* tests that do not make real LLM calls.
|
|
104
|
+
*/
|
|
105
|
+
export declare function executeAgent(compiled: CompiledAgent, dispatch: DispatchContext, completeFn?: CompleteFn): Promise<JitAgentResult>;
|
|
106
|
+
//# sourceMappingURL=jit-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jit-runtime.d.ts","sourceRoot":"","sources":["../src/jit-runtime.ts"],"names":[],"mappings":"AAoBA,OAAO,KAAK,EAAE,GAAG,EAAkD,IAAI,EAAY,MAAM,qBAAqB,CAAC;AAC/G,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAQ,MAAM,qBAAqB,CAAC;AAUrE,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAwJjF;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,YAAY,CAAC;AAE7C;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC/B,UAAU,EAAE,MAAM,EAClB,QAAQ,SAAe,EACvB,WAAW,SAA4B,GACrC,IAAI,CASN;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,oBAAoB,GAC7B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAChD,KAAK,CAAC;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,oBAAoB,CAkBpF;AAyFD;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CACjC,QAAQ,EAAE,aAAa,EACvB,QAAQ,EAAE,eAAe,EACzB,UAAU,GAAE,UAAyB,GACnC,OAAO,CAAC,cAAc,CAAC,CAoSzB"}
|