@jini-ai/agent-runtime 0.7.3-next.1 → 0.7.3-next.3
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 +10 -0
- package/README.md +38 -0
- package/dist/agent-protocol/acp/constants.d.ts +3 -0
- package/dist/agent-protocol/acp/constants.js +5 -0
- package/dist/agent-protocol/acp/models.d.ts +0 -10
- package/dist/agent-protocol/acp/models.js +6 -11
- package/dist/agent-protocol/acp/rpc.d.ts +5 -1
- package/dist/agent-protocol/acp/rpc.js +2 -1
- package/dist/agent-protocol/acp/session-permission.js +4 -3
- package/dist/agent-protocol/acp/session-results.d.ts +3 -3
- package/dist/agent-protocol/acp/session-results.js +22 -17
- package/dist/agent-protocol/acp/session-run.js +0 -8
- package/dist/agent-protocol/acp/session-types.d.ts +0 -1
- package/dist/agent-protocol/acp/session.js +3 -2
- package/dist/agent-protocol/acp/text-suppression.js +75 -71
- package/dist/agent-protocol/pi-rpc/events.d.ts +21 -4
- package/dist/agent-protocol/pi-rpc/events.js +8 -8
- package/dist/agent-protocol/pi-rpc/internal.d.ts +6 -2
- package/dist/agent-protocol/pi-rpc/internal.js +6 -4
- package/dist/agent-protocol/pi-rpc/session.js +4 -3
- package/dist/anthropic-live-models.js +0 -0
- package/dist/claude-code-models.d.ts +3 -1
- package/dist/claude-code-models.js +4 -4
- package/dist/cli-probe-cache.d.ts +33 -0
- package/dist/cli-probe-cache.js +59 -0
- package/dist/custom-instructions.d.ts +107 -0
- package/dist/custom-instructions.js +80 -0
- package/dist/defs/{aider.d.ts → aider/index.d.ts} +2 -1
- package/dist/defs/{aider.js → aider/index.js} +6 -3
- package/dist/defs/amr/executable-env.d.ts +2 -0
- package/dist/defs/amr/executable-env.js +2 -0
- package/dist/defs/amr/executable-resolution.d.ts +5 -1
- package/dist/defs/amr/executable-resolution.js +1 -1
- package/dist/defs/antigravity/index.d.ts +1 -0
- package/dist/defs/antigravity/index.js +3 -0
- package/dist/defs/antigravity/permissions.d.ts +26 -0
- package/dist/defs/antigravity/permissions.js +66 -0
- package/dist/defs/{auggie.d.ts → auggie/index.d.ts} +1 -1
- package/dist/defs/{auggie.js → auggie/index.js} +3 -3
- package/dist/defs/claude/config-dir.d.ts +62 -0
- package/dist/defs/claude/config-dir.js +133 -0
- package/dist/defs/claude/filesystem.d.ts +33 -0
- package/dist/defs/claude/filesystem.js +30 -0
- package/dist/defs/{claude.d.ts → claude/index.d.ts} +1 -1
- package/dist/defs/{claude.js → claude/index.js} +9 -9
- package/dist/defs/claude/mcp-config.d.ts +22 -0
- package/dist/defs/claude/mcp-config.js +29 -0
- package/dist/defs/claude/mcp-delivery.d.ts +57 -0
- package/dist/defs/claude/mcp-delivery.js +75 -0
- package/dist/defs/claude/mcp-json.d.ts +34 -0
- package/dist/defs/claude/mcp-json.js +38 -0
- package/dist/defs/claude/subagent-start.d.ts +12 -0
- package/dist/defs/claude/subagent-start.js +35 -0
- package/dist/defs/{cline.d.ts → cline/index.d.ts} +1 -1
- package/dist/defs/{cline.js → cline/index.js} +3 -3
- package/dist/defs/codex/contracts.d.ts +47 -0
- package/dist/defs/codex/contracts.js +6 -0
- package/dist/defs/codex/event-stream.d.ts +5 -1
- package/dist/defs/codex/event-stream.js +29 -24
- package/dist/defs/codex/home-config.d.ts +55 -0
- package/dist/defs/codex/home-config.js +224 -0
- package/dist/defs/codex/home-staging.d.ts +57 -0
- package/dist/defs/codex/home-staging.js +184 -0
- package/dist/defs/{codex.d.ts → codex/index.d.ts} +2 -2
- package/dist/defs/{codex.js → codex/index.js} +3 -3
- package/dist/defs/codex/isolation.d.ts +29 -0
- package/dist/defs/codex/isolation.js +69 -0
- package/dist/defs/codex/launch.d.ts +4 -1
- package/dist/defs/codex/launch.js +1 -1
- package/dist/defs/codex/mcp-delivery.d.ts +8 -0
- package/dist/defs/codex/mcp-delivery.js +5 -0
- package/dist/defs/{crush.d.ts → crush/index.d.ts} +1 -1
- package/dist/defs/{crush.js → crush/index.js} +3 -3
- package/dist/defs/cursor-agent/event-stream.d.ts +5 -1
- package/dist/defs/cursor-agent/event-stream.js +14 -7
- package/dist/defs/{cursor-agent.d.ts → cursor-agent/index.d.ts} +1 -1
- package/dist/defs/{cursor-agent.js → cursor-agent/index.js} +4 -4
- package/dist/defs/{deepseek.d.ts → deepseek/index.d.ts} +2 -1
- package/dist/defs/{deepseek.js → deepseek/index.js} +6 -3
- package/dist/defs/{devin.d.ts → devin/index.d.ts} +1 -1
- package/dist/defs/{devin.js → devin/index.js} +3 -3
- package/dist/defs/{droid.d.ts → droid/index.d.ts} +1 -1
- package/dist/defs/{droid.js → droid/index.js} +3 -3
- package/dist/defs/gemini/event-stream.d.ts +5 -1
- package/dist/defs/gemini/event-stream.js +15 -12
- package/dist/defs/gemini/tool-calls.d.ts +7 -0
- package/dist/defs/gemini/tool-calls.js +9 -0
- package/dist/defs/{goose.d.ts → goose/index.d.ts} +1 -1
- package/dist/defs/{goose.js → goose/index.js} +3 -3
- package/dist/defs/{grok-build.d.ts → grok-build/index.d.ts} +1 -1
- package/dist/defs/{grok-build.js → grok-build/index.js} +3 -3
- package/dist/defs/index.d.ts +28 -28
- package/dist/defs/index.js +28 -28
- package/dist/defs/{kilo.d.ts → kilo/index.d.ts} +1 -1
- package/dist/defs/{kilo.js → kilo/index.js} +3 -3
- package/dist/defs/kimi/event-stream.d.ts +4 -1
- package/dist/defs/kimi/event-stream.js +6 -5
- package/dist/defs/{kimi.d.ts → kimi/index.d.ts} +1 -1
- package/dist/defs/{kimi.js → kimi/index.js} +3 -3
- package/dist/defs/{kiro.d.ts → kiro/index.d.ts} +1 -1
- package/dist/defs/{kiro.js → kiro/index.js} +3 -3
- package/dist/defs/mimo/constants.d.ts +2 -0
- package/dist/defs/mimo/constants.js +2 -0
- package/dist/defs/{mimo.d.ts → mimo/index.d.ts} +1 -1
- package/dist/defs/{mimo.js → mimo/index.js} +3 -3
- package/dist/defs/opencode/constants.d.ts +2 -0
- package/dist/defs/opencode/constants.js +2 -0
- package/dist/defs/opencode/event-stream.d.ts +5 -1
- package/dist/defs/opencode/event-stream.js +13 -11
- package/dist/defs/{opencode.d.ts → opencode/index.d.ts} +2 -2
- package/dist/defs/{opencode.js → opencode/index.js} +5 -5
- package/dist/defs/opencode/mcp-config.d.ts +108 -0
- package/dist/defs/opencode/mcp-config.js +119 -0
- package/dist/defs/opencode/model-discovery.d.ts +3 -1
- package/dist/defs/opencode/model-discovery.js +1 -1
- package/dist/defs/opencode/tool-calls.d.ts +7 -0
- package/dist/defs/opencode/tool-calls.js +12 -0
- package/dist/defs/{opencode-acp.d.ts → opencode-acp/index.d.ts} +2 -2
- package/dist/defs/{opencode-acp.js → opencode-acp/index.js} +4 -4
- package/dist/defs/{pi.d.ts → pi/index.d.ts} +1 -1
- package/dist/defs/{pi.js → pi/index.js} +3 -3
- package/dist/defs/pi/model-discovery.d.ts +4 -1
- package/dist/defs/pi/model-discovery.js +1 -1
- package/dist/defs/{qoder.d.ts → qoder/index.d.ts} +1 -1
- package/dist/defs/{qoder.js → qoder/index.js} +3 -3
- package/dist/defs/{qwen.d.ts → qwen/index.d.ts} +1 -1
- package/dist/defs/{qwen.js → qwen/index.js} +3 -3
- package/dist/defs/{reasonix.d.ts → reasonix/index.d.ts} +1 -1
- package/dist/defs/{reasonix.js → reasonix/index.js} +3 -3
- package/dist/defs/{trae-cli.d.ts → trae-cli/index.d.ts} +1 -1
- package/dist/defs/{trae-cli.js → trae-cli/index.js} +3 -3
- package/dist/defs/{vibe.d.ts → vibe/index.d.ts} +1 -1
- package/dist/defs/{vibe.js → vibe/index.js} +3 -3
- package/dist/executables.js +1 -1
- package/dist/inventory/index.d.ts +61 -0
- package/dist/inventory/index.js +45 -0
- package/dist/json-event-stream-shared.d.ts +10 -2
- package/dist/json-event-stream-shared.js +21 -13
- package/dist/json-event-stream.js +6 -5
- package/dist/launch.js +1 -1
- package/dist/model-catalog-live-discovery.d.ts +103 -0
- package/dist/model-catalog-live-discovery.js +111 -0
- package/dist/model-discovery-adapters.d.ts +6 -1
- package/dist/model-discovery-adapters.js +4 -3
- package/dist/model-discovery-config.js +1 -1
- package/dist/native-permissions.d.ts +19 -0
- package/dist/native-permissions.js +22 -0
- package/dist/providers/connection-guard.js +98 -83
- package/dist/providers/connection-test.js +0 -5
- package/dist/providers/oauth-provider.d.ts +1 -23
- package/dist/providers/oauth-provider.js +1 -35
- package/dist/providers/tool-turn-types.d.ts +12 -9
- package/dist/providers/tool-turn.d.ts +63 -1
- package/dist/providers/tool-turn.js +66 -0
- package/dist/qoder-stream.js +66 -66
- package/dist/role-marker-guard.js +49 -30
- package/dist/runtime-def-binding.js +1 -1
- package/dist/runtime-port-bindings.d.ts +82 -0
- package/dist/runtime-port-bindings.js +4 -1
- package/dist/runtime-strategies.d.ts +100 -0
- package/dist/runtime-strategies.js +129 -0
- package/package.json +45 -11
- package/dist/defs/amp.d.ts +0 -2
- package/dist/defs/amp.js +0 -2
- package/dist/defs/amr.d.ts +0 -2
- package/dist/defs/amr.js +0 -2
- package/dist/defs/codebuddy.d.ts +0 -2
- package/dist/defs/codebuddy.js +0 -2
- package/dist/defs/hermes.d.ts +0 -2
- package/dist/defs/hermes.js +0 -2
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ToolResultContentBlock } from '@jini-ai/core/contracts/tool-result-block';
|
|
1
2
|
import type { runAnthropicToolTurn, AnthropicToolDef } from './anthropic-messages.js';
|
|
2
3
|
import type { runOpenAiToolTurn } from './openai-chat.js';
|
|
3
4
|
import type { OpenAiFunctionToolDef } from './openai-chat-types.js';
|
|
@@ -69,18 +70,13 @@ export interface ProviderToolCall {
|
|
|
69
70
|
readonly name: string;
|
|
70
71
|
readonly input: unknown;
|
|
71
72
|
}
|
|
72
|
-
export type ProviderToolResultBlock = {
|
|
73
|
-
readonly type: "text";
|
|
74
|
-
readonly text: string;
|
|
75
|
-
} | {
|
|
76
|
-
readonly type: "image";
|
|
77
|
-
readonly mimeType: string;
|
|
78
|
-
readonly data: string;
|
|
79
|
-
};
|
|
80
73
|
export interface ProviderToolResult {
|
|
81
|
-
|
|
74
|
+
/** A string for an ordinary result; blocks only when the result carries an image. */
|
|
75
|
+
readonly content: string | readonly ToolResultContentBlock[];
|
|
82
76
|
readonly isError?: boolean;
|
|
83
77
|
}
|
|
78
|
+
/** Host-owned tool execution (e.g. bridged to a daemon `ToolExecutor` over the host's own tool
|
|
79
|
+
* surface); always supplied, the same convention every protocol adapter uses for its executor. */
|
|
84
80
|
export type ProviderToolExecutor = (call: ProviderToolCall) => Promise<ProviderToolResult>;
|
|
85
81
|
/** Raw provider call metadata: an unpublished wire name has no canonical tool ID or decoder. */
|
|
86
82
|
export interface ProviderUnexposedToolCall {
|
|
@@ -99,6 +95,7 @@ export interface ProviderToolTurnInput {
|
|
|
99
95
|
readonly protocol: ProviderProtocol;
|
|
100
96
|
readonly adapters: ProviderTurnAdapters;
|
|
101
97
|
readonly apiKey: string;
|
|
98
|
+
/** `anthropic`/`openai`/`google`: a model id. `azure`: the deployment name, not a raw model id — see `AzureTurnOptions.model`'s own doc. */
|
|
102
99
|
readonly model: string;
|
|
103
100
|
readonly system: string;
|
|
104
101
|
readonly messages: readonly ProviderChatMessage[];
|
|
@@ -124,8 +121,14 @@ export interface ProviderToolTurnOptions {
|
|
|
124
121
|
readonly getToolSnapshot?: () => readonly ProviderToolDescriptor[];
|
|
125
122
|
/** Value-free diagnostic only; execution must still validate through the host executor. */
|
|
126
123
|
readonly onSchemaFallback?: (event: ProviderSchemaFallback) => void;
|
|
124
|
+
/** Required for `azure` (no sane global default — every Azure OpenAI resource has its own
|
|
125
|
+
* endpoint); optional for the other three protocols, which fall back to each adapter's own
|
|
126
|
+
* public default endpoint. */
|
|
127
127
|
readonly baseUrl?: string;
|
|
128
128
|
readonly maxTokens?: number;
|
|
129
|
+
/** Overrides the provider's tool-turn limit. A meta-tool surface spends several calls (e.g.
|
|
130
|
+
* search/describe/execute) per action, so the provider default can truncate multi-step tasks;
|
|
131
|
+
* the host injects its own policy value. Omit to keep the provider default. */
|
|
129
132
|
readonly maxToolTurns?: number;
|
|
130
133
|
readonly signal?: AbortSignal;
|
|
131
134
|
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import type { ProviderTurnAdapters, ProviderToolTurnInput, ProviderToolTurnResult, ProviderToolTurnOptions } from './tool-turn-types.js';
|
|
1
|
+
import type { ProviderTurnAdapters, ProviderToolTurnInput, ProviderToolTurnResult, ProviderToolTurnOptions, ProviderProtocol } from './tool-turn-types.js';
|
|
2
2
|
export type * from './tool-turn-types.js';
|
|
3
3
|
export { compileOperationSchema } from './operation-schema.js';
|
|
4
4
|
export type { CompiledOperationSchema, OperationSchemaFallbackReason } from './operation-schema.js';
|
|
5
5
|
export { googleParametersOf, sanitizeGoogleSchema, findNumericEnumPaths, coerceNumericEnumStringsToNumbers } from './google-schema.js';
|
|
6
6
|
/** Existing provider loops, ready for host composition; callers may replace any adapter. */
|
|
7
7
|
export declare const providerTurnAdapters: ProviderTurnAdapters;
|
|
8
|
+
/** A stored, free-form provider string narrowed to a protocol the default adapters can dispatch, or
|
|
9
|
+
* null when it names something else. Case- and whitespace-insensitive because the stored column is
|
|
10
|
+
* free-form. The adapters themselves own the supported protocols; no second allowlist lives here.
|
|
11
|
+
* @complexity O(n) in provider length. */
|
|
12
|
+
export declare function resolveProviderProtocol({ provider }: {
|
|
13
|
+
provider: string;
|
|
14
|
+
}, _optional?: {}): ProviderProtocol | null;
|
|
8
15
|
/** Invalid snapshot names fail closed before an adapter can dispatch an ambiguous operation. */
|
|
9
16
|
export declare class ProviderToolProjectionError extends Error {
|
|
10
17
|
readonly code = "invalid-wire-name";
|
|
@@ -12,6 +19,61 @@ export declare class ProviderToolProjectionError extends Error {
|
|
|
12
19
|
}
|
|
13
20
|
/** Runs one provider-neutral turn through the supplied adapters. The adapter end event takes precedence over a raw provider stop code.
|
|
14
21
|
* Local mapping is proportional to the descriptors, expanded schemas and emitted result parts; request and loop cost belongs to the adapter ports.
|
|
22
|
+
*
|
|
23
|
+
* Provider mapping constraints (implemented here and in `google-schema.ts`):
|
|
24
|
+
*
|
|
25
|
+
* OpenAI/Azure have no host-tool-error flag on their wire. A shared fold marker carries failures
|
|
26
|
+
* into content and restores `isError` on outgoing events; adapter validation alone cannot detect a
|
|
27
|
+
* host denial in an otherwise valid string result. Azure uses the same content shape as OpenAI.
|
|
28
|
+
* Anthropic accepts JPEG/PNG/GIF/WebP image sources; its adapter guards unsupported media types.
|
|
29
|
+
* OpenAI/Azure move image parts into a follow-up user message because tool messages are text-only;
|
|
30
|
+
* Gemini places inline data beside function responses. Transcript events describe each image by
|
|
31
|
+
* MIME type instead of emitting base64 noise. Plain string results remain unchanged.
|
|
32
|
+
* Missing input schemas use an empty-object schema; schema dialect is a consumer concern.
|
|
33
|
+
*
|
|
34
|
+
* Gemini's restricted Schema cannot express full JSON Schema. Its supported-key allowlist follows
|
|
35
|
+
* the validator's Available Fields list (the Google AI Developer forum's "oneOf in response_schema"
|
|
36
|
+
* thread), which includes fields omitted by the prose API docs. Unsupported keys are dropped only
|
|
37
|
+
* from model guidance: tool handlers still validate inputs server-side. `const` becomes `enum`;
|
|
38
|
+
* `oneOf` becomes `anyOf`. That conversion is equivalent for disjoint tagged unions (e.g. navigation
|
|
39
|
+
* targets and TipTap nodes); overlapping future branches require an owner decision because the
|
|
40
|
+
* conversion would loosen the constraint.
|
|
41
|
+
*
|
|
42
|
+
* Local #/$defs references are resolved against the nearest enclosing, per-call definitions map,
|
|
43
|
+
* preventing concurrent turns from sharing definitions. Unknown references degrade to object
|
|
44
|
+
* guidance instead of failing an entire turn. References are inlined because Gemini has no $ref;
|
|
45
|
+
* ordinary object/array traversal does not consume the reference-depth budget.
|
|
46
|
+
* The reference cap is 4, a chosen bound rather than a product invariant: TipTap's recursive
|
|
47
|
+
* eight-branch block union grows combinatorially, and two reference hops represent one visible
|
|
48
|
+
* list/blockquote nesting level. Four hops cover two such levels while bounding request size.
|
|
49
|
+
* A navigation tree's separate depth limit does not determine this cap. Deeper content
|
|
50
|
+
* remains permissible but undescribed by a shallow type/description stub (union stubs use object);
|
|
51
|
+
* the stub must not recurse into properties, items or branches and recreate unbounded expansion.
|
|
52
|
+
*
|
|
53
|
+
* Gemini requires every array schema to declare items and every node to declare type unless it
|
|
54
|
+
* has anyOf. Unknown array items degrade to string, the narrowest valid approximation, rather than
|
|
55
|
+
* inviting arbitrary objects. Structural repair applies only at schema positions (properties.*, items,
|
|
56
|
+
* anyOf), never arbitrary default/example objects, which must not acquire invented type fields.
|
|
57
|
+
* Properties preserve author-chosen keys. Validation must use googleParametersOf, including shape
|
|
58
|
+
* repair, so it checks the actual wire schema rather than an incomplete lower-level conversion.
|
|
59
|
+
*
|
|
60
|
+
* Bare const literals infer boolean/integer/number/string; object/array const sites need an explicit
|
|
61
|
+
* type instead of broader inference. A type array collapses to one non-null type plus nullable;
|
|
62
|
+
* multiple non-null types lose precision and require an owner decision if used. Null enum members
|
|
63
|
+
* are removed because Gemini's enum accepts strings only and sibling nullable already conveys null.
|
|
64
|
+
* Numeric enums are stringified for Gemini and must be converted back at the tool-call boundary:
|
|
65
|
+
* a handler such as a redirect's statusCode still requires a number. Numeric paths come from the original
|
|
66
|
+
* unsanitized schema, once per tool, because sanitization overwrites the numeric type. The original
|
|
67
|
+
* type check prevents coercing numeric enum values on nonnumeric fields. Discovery traverses only
|
|
68
|
+
* properties, not arrays, unions or $refs; a numeric enum in those positions needs an extension.
|
|
69
|
+
* Coercion accepts only finite numeric-looking, nonblank strings and clones only the changed path;
|
|
70
|
+
* malformed paths/arguments remain untouched for the handler's validation rather than inventing data.
|
|
71
|
+
*
|
|
72
|
+
* The adapter's captured end-event reason takes precedence over the final response's raw stop code:
|
|
73
|
+
* a raw tool_use can mean the loop hit its cap while the model still wanted tools. Raw stop/finish
|
|
74
|
+
* fields are fallbacks only when no end event was observed; callers must explain the loop's actual
|
|
75
|
+
* stop. Anthropic alone requires a max-token default when omitted, so the shared mapping supplies it.
|
|
76
|
+
* Provider-internal fabricated-role-marker diagnostics are filtered because the client has no event case.
|
|
15
77
|
*/
|
|
16
78
|
export declare function runProviderToolTurn(required: ProviderToolTurnInput, optional?: ProviderToolTurnOptions): Promise<ProviderToolTurnResult>;
|
|
17
79
|
//# sourceMappingURL=tool-turn.d.ts.map
|
|
@@ -9,6 +9,14 @@ export { compileOperationSchema } from './operation-schema.js';
|
|
|
9
9
|
export { googleParametersOf, sanitizeGoogleSchema, findNumericEnumPaths, coerceNumericEnumStringsToNumbers } from './google-schema.js';
|
|
10
10
|
/** Existing provider loops, ready for host composition; callers may replace any adapter. */
|
|
11
11
|
export const providerTurnAdapters = Object.freeze({ anthropic: runAnthropicToolTurn, openai: runOpenAiToolTurn, azure: runAzureToolTurn, google: runGoogleToolTurn });
|
|
12
|
+
/** A stored, free-form provider string narrowed to a protocol the default adapters can dispatch, or
|
|
13
|
+
* null when it names something else. Case- and whitespace-insensitive because the stored column is
|
|
14
|
+
* free-form. The adapters themselves own the supported protocols; no second allowlist lives here.
|
|
15
|
+
* @complexity O(n) in provider length. */
|
|
16
|
+
export function resolveProviderProtocol({ provider }, _optional = {}) {
|
|
17
|
+
const normalized = provider.trim().toLowerCase();
|
|
18
|
+
return Object.hasOwn(providerTurnAdapters, normalized) ? normalized : null;
|
|
19
|
+
}
|
|
12
20
|
const TOOL_ERROR_PREFIX = "[tool error] ";
|
|
13
21
|
function toAnthropicToolContent(content) {
|
|
14
22
|
if (typeof content === "string")
|
|
@@ -101,6 +109,9 @@ function createToolProjection(input, _options = {}) {
|
|
|
101
109
|
const published = new Map();
|
|
102
110
|
const reported = new Set();
|
|
103
111
|
function getTools({ strict = false } = {}, { reportFallback = true } = {}) {
|
|
112
|
+
// Descriptors only, never handlers — the same public shape `ToolRegistry.list()` returns
|
|
113
|
+
// (`@jini-ai/core`'s own "handlers never publicly retrievable" invariant, see that package's
|
|
114
|
+
// `tool-registry.ts` module doc). Mapped into each protocol's own tool-def shape below.
|
|
104
115
|
const descriptors = input.getToolSnapshot?.() ?? input.tools;
|
|
105
116
|
pinWireNames(descriptors, names);
|
|
106
117
|
return descriptors.map(descriptor => {
|
|
@@ -278,6 +289,61 @@ async function runGoogleTurn(input) {
|
|
|
278
289
|
}
|
|
279
290
|
/** Runs one provider-neutral turn through the supplied adapters. The adapter end event takes precedence over a raw provider stop code.
|
|
280
291
|
* Local mapping is proportional to the descriptors, expanded schemas and emitted result parts; request and loop cost belongs to the adapter ports.
|
|
292
|
+
*
|
|
293
|
+
* Provider mapping constraints (implemented here and in `google-schema.ts`):
|
|
294
|
+
*
|
|
295
|
+
* OpenAI/Azure have no host-tool-error flag on their wire. A shared fold marker carries failures
|
|
296
|
+
* into content and restores `isError` on outgoing events; adapter validation alone cannot detect a
|
|
297
|
+
* host denial in an otherwise valid string result. Azure uses the same content shape as OpenAI.
|
|
298
|
+
* Anthropic accepts JPEG/PNG/GIF/WebP image sources; its adapter guards unsupported media types.
|
|
299
|
+
* OpenAI/Azure move image parts into a follow-up user message because tool messages are text-only;
|
|
300
|
+
* Gemini places inline data beside function responses. Transcript events describe each image by
|
|
301
|
+
* MIME type instead of emitting base64 noise. Plain string results remain unchanged.
|
|
302
|
+
* Missing input schemas use an empty-object schema; schema dialect is a consumer concern.
|
|
303
|
+
*
|
|
304
|
+
* Gemini's restricted Schema cannot express full JSON Schema. Its supported-key allowlist follows
|
|
305
|
+
* the validator's Available Fields list (the Google AI Developer forum's "oneOf in response_schema"
|
|
306
|
+
* thread), which includes fields omitted by the prose API docs. Unsupported keys are dropped only
|
|
307
|
+
* from model guidance: tool handlers still validate inputs server-side. `const` becomes `enum`;
|
|
308
|
+
* `oneOf` becomes `anyOf`. That conversion is equivalent for disjoint tagged unions (e.g. navigation
|
|
309
|
+
* targets and TipTap nodes); overlapping future branches require an owner decision because the
|
|
310
|
+
* conversion would loosen the constraint.
|
|
311
|
+
*
|
|
312
|
+
* Local #/$defs references are resolved against the nearest enclosing, per-call definitions map,
|
|
313
|
+
* preventing concurrent turns from sharing definitions. Unknown references degrade to object
|
|
314
|
+
* guidance instead of failing an entire turn. References are inlined because Gemini has no $ref;
|
|
315
|
+
* ordinary object/array traversal does not consume the reference-depth budget.
|
|
316
|
+
* The reference cap is 4, a chosen bound rather than a product invariant: TipTap's recursive
|
|
317
|
+
* eight-branch block union grows combinatorially, and two reference hops represent one visible
|
|
318
|
+
* list/blockquote nesting level. Four hops cover two such levels while bounding request size.
|
|
319
|
+
* A navigation tree's separate depth limit does not determine this cap. Deeper content
|
|
320
|
+
* remains permissible but undescribed by a shallow type/description stub (union stubs use object);
|
|
321
|
+
* the stub must not recurse into properties, items or branches and recreate unbounded expansion.
|
|
322
|
+
*
|
|
323
|
+
* Gemini requires every array schema to declare items and every node to declare type unless it
|
|
324
|
+
* has anyOf. Unknown array items degrade to string, the narrowest valid approximation, rather than
|
|
325
|
+
* inviting arbitrary objects. Structural repair applies only at schema positions (properties.*, items,
|
|
326
|
+
* anyOf), never arbitrary default/example objects, which must not acquire invented type fields.
|
|
327
|
+
* Properties preserve author-chosen keys. Validation must use googleParametersOf, including shape
|
|
328
|
+
* repair, so it checks the actual wire schema rather than an incomplete lower-level conversion.
|
|
329
|
+
*
|
|
330
|
+
* Bare const literals infer boolean/integer/number/string; object/array const sites need an explicit
|
|
331
|
+
* type instead of broader inference. A type array collapses to one non-null type plus nullable;
|
|
332
|
+
* multiple non-null types lose precision and require an owner decision if used. Null enum members
|
|
333
|
+
* are removed because Gemini's enum accepts strings only and sibling nullable already conveys null.
|
|
334
|
+
* Numeric enums are stringified for Gemini and must be converted back at the tool-call boundary:
|
|
335
|
+
* a handler such as a redirect's statusCode still requires a number. Numeric paths come from the original
|
|
336
|
+
* unsanitized schema, once per tool, because sanitization overwrites the numeric type. The original
|
|
337
|
+
* type check prevents coercing numeric enum values on nonnumeric fields. Discovery traverses only
|
|
338
|
+
* properties, not arrays, unions or $refs; a numeric enum in those positions needs an extension.
|
|
339
|
+
* Coercion accepts only finite numeric-looking, nonblank strings and clones only the changed path;
|
|
340
|
+
* malformed paths/arguments remain untouched for the handler's validation rather than inventing data.
|
|
341
|
+
*
|
|
342
|
+
* The adapter's captured end-event reason takes precedence over the final response's raw stop code:
|
|
343
|
+
* a raw tool_use can mean the loop hit its cap while the model still wanted tools. Raw stop/finish
|
|
344
|
+
* fields are fallbacks only when no end event was observed; callers must explain the loop's actual
|
|
345
|
+
* stop. Anthropic alone requires a max-token default when omitted, so the shared mapping supplies it.
|
|
346
|
+
* Provider-internal fabricated-role-marker diagnostics are filtered because the client has no event case.
|
|
281
347
|
*/
|
|
282
348
|
export async function runProviderToolTurn(required, optional = {}) {
|
|
283
349
|
const input = { ...optional, ...required };
|
package/dist/qoder-stream.js
CHANGED
|
@@ -80,80 +80,80 @@ function usageEvent(obj) {
|
|
|
80
80
|
isError: Boolean(obj.is_error),
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
function emitThinking({ thinking, state, onEvent }) {
|
|
84
|
+
if (!state.emittedThinkingStart) {
|
|
85
|
+
state.emittedThinkingStart = true;
|
|
86
|
+
onEvent({ type: 'thinking_start' });
|
|
87
|
+
}
|
|
88
|
+
onEvent({ type: 'thinking_delta', delta: thinking });
|
|
89
|
+
}
|
|
90
|
+
/** Emit one content block's text or thinking; returns whether text was emitted. */
|
|
91
|
+
function emitContentBlock({ block, state, onEvent }) {
|
|
92
|
+
const text = textFromContentBlock(block);
|
|
93
|
+
if (text.length > 0) {
|
|
94
|
+
onEvent({ type: 'text_delta', delta: text });
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
const thinking = thinkingFromContentBlock(block);
|
|
98
|
+
if (thinking.length > 0)
|
|
99
|
+
emitThinking({ thinking, state, onEvent });
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
function translateAssistant({ obj, message, rawLine, state, onEvent }) {
|
|
103
|
+
const content = Array.isArray(message.content) ? message.content : [];
|
|
104
|
+
let emittedText = false;
|
|
105
|
+
for (const block of content) {
|
|
106
|
+
if (emitContentBlock({ block, state, onEvent }))
|
|
107
|
+
emittedText = true;
|
|
108
|
+
}
|
|
109
|
+
if (!emittedText && typeof message.content === 'string') {
|
|
110
|
+
onEvent({ type: 'text_delta', delta: message.content });
|
|
111
|
+
emittedText = true;
|
|
112
|
+
}
|
|
113
|
+
if (obj.error && !emittedText) {
|
|
114
|
+
onEvent({
|
|
115
|
+
type: 'error',
|
|
116
|
+
message: messageFromError(obj.error),
|
|
117
|
+
raw: rawLine,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function translateResult({ obj, rawLine, onEvent }) {
|
|
122
|
+
onEvent(usageEvent(obj));
|
|
123
|
+
if (obj.is_error) {
|
|
124
|
+
onEvent({
|
|
125
|
+
type: 'error',
|
|
126
|
+
message: messageFromResult(obj),
|
|
127
|
+
raw: rawLine,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function translateObject({ obj, rawLine, state, onEvent }) {
|
|
132
|
+
if (!isRecord(obj))
|
|
133
|
+
return;
|
|
134
|
+
if (obj.type === 'system' && obj.subtype === 'init') {
|
|
135
|
+
onEvent(initStatusEvent(obj));
|
|
136
|
+
}
|
|
137
|
+
else if (obj.type === 'assistant' && isRecord(obj.message)) {
|
|
138
|
+
translateAssistant({ obj, message: obj.message, rawLine, state, onEvent });
|
|
139
|
+
}
|
|
140
|
+
else if (obj.type === 'result') {
|
|
141
|
+
translateResult({ obj, rawLine, onEvent });
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
onEvent({ type: 'raw', line: rawLine });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
83
147
|
export function createQoderStreamHandler({ onEvent }, _optional = {}) {
|
|
84
148
|
const lines = createBoundedLineStream({
|
|
85
149
|
onLine: line => { const trimmed = line.trim(); if (trimmed)
|
|
86
150
|
handleLine(trimmed); },
|
|
87
151
|
onOverflow: error => onEvent({ type: 'error', message: error.message, raw: '' }),
|
|
88
152
|
});
|
|
89
|
-
|
|
90
|
-
function emitThinking(thinking) {
|
|
91
|
-
if (!emittedThinkingStart) {
|
|
92
|
-
emittedThinkingStart = true;
|
|
93
|
-
onEvent({ type: 'thinking_start' });
|
|
94
|
-
}
|
|
95
|
-
onEvent({ type: 'thinking_delta', delta: thinking });
|
|
96
|
-
}
|
|
97
|
-
/** Emit one content block's text or thinking; returns whether text was emitted. */
|
|
98
|
-
function emitContentBlock(block) {
|
|
99
|
-
const text = textFromContentBlock(block);
|
|
100
|
-
if (text.length > 0) {
|
|
101
|
-
onEvent({ type: 'text_delta', delta: text });
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
const thinking = thinkingFromContentBlock(block);
|
|
105
|
-
if (thinking.length > 0)
|
|
106
|
-
emitThinking(thinking);
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
function handleAssistant(obj, message, rawLine) {
|
|
110
|
-
const content = Array.isArray(message.content) ? message.content : [];
|
|
111
|
-
let emittedText = false;
|
|
112
|
-
for (const block of content) {
|
|
113
|
-
if (emitContentBlock(block))
|
|
114
|
-
emittedText = true;
|
|
115
|
-
}
|
|
116
|
-
if (!emittedText && typeof message.content === 'string') {
|
|
117
|
-
onEvent({ type: 'text_delta', delta: message.content });
|
|
118
|
-
emittedText = true;
|
|
119
|
-
}
|
|
120
|
-
if (obj.error && !emittedText) {
|
|
121
|
-
onEvent({
|
|
122
|
-
type: 'error',
|
|
123
|
-
message: messageFromError(obj.error),
|
|
124
|
-
raw: rawLine,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
function handleResult(obj, rawLine) {
|
|
129
|
-
onEvent(usageEvent(obj));
|
|
130
|
-
if (obj.is_error) {
|
|
131
|
-
onEvent({
|
|
132
|
-
type: 'error',
|
|
133
|
-
message: messageFromResult(obj),
|
|
134
|
-
raw: rawLine,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function handleObject(obj, rawLine) {
|
|
139
|
-
if (!isRecord(obj))
|
|
140
|
-
return;
|
|
141
|
-
if (obj.type === 'system' && obj.subtype === 'init') {
|
|
142
|
-
onEvent(initStatusEvent(obj));
|
|
143
|
-
}
|
|
144
|
-
else if (obj.type === 'assistant' && isRecord(obj.message)) {
|
|
145
|
-
handleAssistant(obj, obj.message, rawLine);
|
|
146
|
-
}
|
|
147
|
-
else if (obj.type === 'result') {
|
|
148
|
-
handleResult(obj, rawLine);
|
|
149
|
-
}
|
|
150
|
-
else {
|
|
151
|
-
onEvent({ type: 'raw', line: rawLine });
|
|
152
|
-
}
|
|
153
|
-
}
|
|
153
|
+
const state = { emittedThinkingStart: false };
|
|
154
154
|
function handleLine(line) {
|
|
155
155
|
try {
|
|
156
|
-
|
|
156
|
+
translateObject({ obj: JSON.parse(line), rawLine: line, state, onEvent });
|
|
157
157
|
}
|
|
158
158
|
catch {
|
|
159
159
|
onEvent({ type: 'raw', line });
|
|
@@ -126,6 +126,47 @@ const NEWLINE_ANCHORED_PENDING_MARKER_TAIL_RE = /\n[ \t]*##[ \t]+(?:user|assista
|
|
|
126
126
|
// 1000 chunks of 50 bytes is otherwise O(n²) on string concatenation
|
|
127
127
|
// alone.
|
|
128
128
|
const TAIL_BUFFER_SIZE = 64;
|
|
129
|
+
/** Picks the confirmed-marker and pending-marker matchers for the current stream position. */
|
|
130
|
+
function markerRegexes({ firstChunk }) {
|
|
131
|
+
const matchRe = firstChunk
|
|
132
|
+
? FABRICATED_ROLE_MARKER_RE
|
|
133
|
+
: NEWLINE_ANCHORED_ROLE_MARKER_RE;
|
|
134
|
+
const pendingRe = firstChunk
|
|
135
|
+
? FIRST_CHUNK_PENDING_MARKER_TAIL_RE
|
|
136
|
+
: NEWLINE_ANCHORED_PENDING_MARKER_TAIL_RE;
|
|
137
|
+
return { matchRe, pendingRe };
|
|
138
|
+
}
|
|
139
|
+
/** Bytes between what was already emitted and a just-confirmed marker; `''` when the marker starts inside the emitted tail. */
|
|
140
|
+
function textBeforeMarker({ buffer, alreadyEmitted, markerStart }) {
|
|
141
|
+
if (markerStart <= alreadyEmitted)
|
|
142
|
+
return '';
|
|
143
|
+
return buffer.slice(alreadyEmitted, markerStart);
|
|
144
|
+
}
|
|
145
|
+
/** Splits the not-yet-emitted part of `buffer` into the safe prefix and a withheld complete-but-unconfirmed marker suffix. */
|
|
146
|
+
function withholdPendingMarker({ buffer, pendingRe, alreadyEmitted }) {
|
|
147
|
+
const pendingMatch = pendingRe.exec(buffer);
|
|
148
|
+
const pendingStart = pendingMatch
|
|
149
|
+
// Never withhold bytes we have already emitted in a prior
|
|
150
|
+
// feed — the suspicious suffix could in pathological cases
|
|
151
|
+
// start inside `tail` (we held back `pending` correctly on
|
|
152
|
+
// the prior call, but the suffix-start position is upstream
|
|
153
|
+
// of where we hold). Clamp to alreadyEmitted so safeToEmit
|
|
154
|
+
// never goes negative.
|
|
155
|
+
? Math.max(pendingMatch.index, alreadyEmitted)
|
|
156
|
+
: buffer.length;
|
|
157
|
+
return { safeToEmit: buffer.slice(alreadyEmitted, pendingStart), pending: buffer.slice(pendingStart) };
|
|
158
|
+
}
|
|
159
|
+
/** Appends the newly emitted bytes to `tail`, capped at TAIL_BUFFER_SIZE; reports whether the cap sliced it. */
|
|
160
|
+
function rollEmittedTail({ tail, safeToEmit }) {
|
|
161
|
+
const fullEmitted = tail + safeToEmit;
|
|
162
|
+
const willSlice = fullEmitted.length > TAIL_BUFFER_SIZE;
|
|
163
|
+
return {
|
|
164
|
+
tail: willSlice
|
|
165
|
+
? fullEmitted.slice(fullEmitted.length - TAIL_BUFFER_SIZE)
|
|
166
|
+
: fullEmitted,
|
|
167
|
+
willSlice,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
129
170
|
/**
|
|
130
171
|
* Create a stateful guard that detects fabricated role markers across
|
|
131
172
|
* chunk boundaries. Memory + per-call work is O(1): instead of
|
|
@@ -190,12 +231,7 @@ export function createRoleMarkerGuard({ messageId }, _optional = {}) {
|
|
|
190
231
|
// `pending` (deferred-from-prior-call suspicious suffix), and the
|
|
191
232
|
// new `text` into a single matching buffer.
|
|
192
233
|
const buffer = tail + pending + text;
|
|
193
|
-
const matchRe = firstChunk
|
|
194
|
-
? FABRICATED_ROLE_MARKER_RE
|
|
195
|
-
: NEWLINE_ANCHORED_ROLE_MARKER_RE;
|
|
196
|
-
const pendingRe = firstChunk
|
|
197
|
-
? FIRST_CHUNK_PENDING_MARKER_TAIL_RE
|
|
198
|
-
: NEWLINE_ANCHORED_PENDING_MARKER_TAIL_RE;
|
|
234
|
+
const { matchRe, pendingRe } = markerRegexes({ firstChunk });
|
|
199
235
|
// `firstChunk` transitions are tied to actual byte emission, not
|
|
200
236
|
// feed count — see comment above. Transitioned at the end of
|
|
201
237
|
// this function only when we emit at least one byte.
|
|
@@ -209,35 +245,18 @@ export function createRoleMarkerGuard({ messageId }, _optional = {}) {
|
|
|
209
245
|
_contaminated = true;
|
|
210
246
|
markerText = match[0].trim();
|
|
211
247
|
pending = '';
|
|
212
|
-
|
|
213
|
-
const markerStart = match.index;
|
|
214
|
-
if (markerStart <= alreadyEmitted)
|
|
215
|
-
return '';
|
|
216
|
-
return buffer.slice(alreadyEmitted, markerStart);
|
|
248
|
+
return textBeforeMarker({ buffer, alreadyEmitted: tail.length, markerStart: match.index });
|
|
217
249
|
}
|
|
218
250
|
// No confirmed marker. Check whether the buffer ends with a
|
|
219
251
|
// complete-but-unconfirmed marker prefix (role keyword present,
|
|
220
252
|
// lookahead char not yet arrived). If so, withhold that suffix
|
|
221
253
|
// until the next feed; emit the rest.
|
|
222
|
-
const
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
// Never withhold bytes we have already emitted in a prior
|
|
226
|
-
// feed — the suspicious suffix could in pathological cases
|
|
227
|
-
// start inside `tail` (we held back `pending` correctly on
|
|
228
|
-
// the prior call, but the suffix-start position is upstream
|
|
229
|
-
// of where we hold). Clamp to alreadyEmitted so safeToEmit
|
|
230
|
-
// never goes negative.
|
|
231
|
-
? Math.max(pendingMatch.index, alreadyEmitted)
|
|
232
|
-
: buffer.length;
|
|
233
|
-
const safeToEmit = buffer.slice(alreadyEmitted, pendingStart);
|
|
234
|
-
pending = buffer.slice(pendingStart);
|
|
254
|
+
const held = withholdPendingMarker({ buffer, pendingRe, alreadyEmitted: tail.length });
|
|
255
|
+
const safeToEmit = held.safeToEmit;
|
|
256
|
+
pending = held.pending;
|
|
235
257
|
// Roll the emitted-bytes tail forward.
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
tail = willSlice
|
|
239
|
-
? fullEmitted.slice(fullEmitted.length - TAIL_BUFFER_SIZE)
|
|
240
|
-
: fullEmitted;
|
|
258
|
+
const rolled = rollEmittedTail({ tail, safeToEmit });
|
|
259
|
+
tail = rolled.tail;
|
|
241
260
|
// `firstChunk` is true exactly while `tail` still represents the
|
|
242
261
|
// entire emission so far — i.e. no slice has occurred and `^` in
|
|
243
262
|
// the canonical regex genuinely anchors at byte 0 of the stream.
|
|
@@ -257,7 +276,7 @@ export function createRoleMarkerGuard({ messageId }, _optional = {}) {
|
|
|
257
276
|
// review r3324060995.
|
|
258
277
|
// Slice-based is the invariant that satisfies both: while we
|
|
259
278
|
// haven't sliced, `^` is correct; once we slice, it isn't.
|
|
260
|
-
if (willSlice)
|
|
279
|
+
if (rolled.willSlice)
|
|
261
280
|
firstChunk = false;
|
|
262
281
|
return safeToEmit;
|
|
263
282
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildCodexArgs, codexAgentDef } from './defs/codex.js';
|
|
1
|
+
import { buildCodexArgs, codexAgentDef } from './defs/codex/index.js';
|
|
2
2
|
/** Bind model probes and the argument builder to the host transport, capability state and plugin policy.
|
|
3
3
|
* The Codex config reaches only the Codex definition, through its own argument; nothing vendor-specific is
|
|
4
4
|
* added to the neutral build options. Returns a definition copy without mutating the registry. @complexity O(1). */
|
|
@@ -160,6 +160,88 @@ export declare function createAgentRuntimeBindings({ runtime }: {
|
|
|
160
160
|
realpath?: (path: string) => string;
|
|
161
161
|
}) => string;
|
|
162
162
|
};
|
|
163
|
+
strategies: {
|
|
164
|
+
for: (required: {
|
|
165
|
+
def: RuntimeAgentDef;
|
|
166
|
+
}) => {
|
|
167
|
+
httpMcpEnv?: typeof import("./defs/opencode/mcp-config.js").withOpenCodeHttpMcp;
|
|
168
|
+
mcpBridge?: {
|
|
169
|
+
prepare(required: {
|
|
170
|
+
delivery: {
|
|
171
|
+
readonly kind: string;
|
|
172
|
+
} | null;
|
|
173
|
+
serverName: string;
|
|
174
|
+
fileLock: import("@jini-ai/core/contracts/runtime").FileLockPort;
|
|
175
|
+
writer: import("@jini-ai/core/contracts/runtime").AtomicFileWriterPort;
|
|
176
|
+
}): Promise<void>;
|
|
177
|
+
};
|
|
178
|
+
filesystem: {
|
|
179
|
+
prepare?: ({ input, spawnEnv, runtimeTemps }: {
|
|
180
|
+
input: import("./defs/claude/filesystem.js").ClaudeFilesystemRunInput;
|
|
181
|
+
spawnEnv: NodeJS.ProcessEnv;
|
|
182
|
+
runtimeTemps: string[];
|
|
183
|
+
}) => Promise<void> | void;
|
|
184
|
+
unsupported?: ({ input }: {
|
|
185
|
+
input: import("./defs/claude/filesystem.js").ClaudeFilesystemRunInput;
|
|
186
|
+
}) => void;
|
|
187
|
+
supported: ({ input, launchPath, spawnEnv }: {
|
|
188
|
+
input: import("./defs/claude/filesystem.js").ClaudeFilesystemRunInput;
|
|
189
|
+
launchPath: string;
|
|
190
|
+
spawnEnv: NodeJS.ProcessEnv;
|
|
191
|
+
}, { filesystem }: {
|
|
192
|
+
filesystem: import("./defs/claude/filesystem.js").ClaudeFilesystemPolicy;
|
|
193
|
+
}) => void;
|
|
194
|
+
};
|
|
195
|
+
mcpConfigFile?: {
|
|
196
|
+
build: typeof import("./defs/claude/mcp-delivery.js").buildClaudeMcpDelivery;
|
|
197
|
+
write: typeof import("./defs/claude/mcp-delivery.js").writeMcpJsonForRun;
|
|
198
|
+
prepareHttp: typeof import("./defs/claude/mcp-config.js").prepareClaudeHttpMcpConfig;
|
|
199
|
+
};
|
|
200
|
+
subagentStart?: {
|
|
201
|
+
prepare: typeof import("./defs/claude/subagent-start.js").prepareClaudeSubagentStartSettings;
|
|
202
|
+
};
|
|
203
|
+
configDir?: {
|
|
204
|
+
readonly envKey: string;
|
|
205
|
+
stage: (required: {
|
|
206
|
+
runId: string;
|
|
207
|
+
hostEnv: NodeJS.ProcessEnv;
|
|
208
|
+
}, optional?: {
|
|
209
|
+
seams?: NonNullable<Parameters<typeof import("./defs/claude/config-dir.js").stageClaudeConfigDir>[1]>["seams"];
|
|
210
|
+
}) => ReturnType<typeof import("./defs/claude/config-dir.js").stageClaudeConfigDir>;
|
|
211
|
+
};
|
|
212
|
+
instructionsDocument?: {
|
|
213
|
+
merge: typeof import("./defs/opencode/mcp-config.js").mergeEnvContentInstructions;
|
|
214
|
+
};
|
|
215
|
+
mcpHome?: {
|
|
216
|
+
readonly envVar: string;
|
|
217
|
+
readonly deliveryKind: "codex-toml";
|
|
218
|
+
buildDelivery<E>(required: {
|
|
219
|
+
serverEntry: E;
|
|
220
|
+
}): {
|
|
221
|
+
readonly kind: "codex-toml";
|
|
222
|
+
readonly serverEntry: E;
|
|
223
|
+
};
|
|
224
|
+
withStagedHome(required: {
|
|
225
|
+
env: NodeJS.ProcessEnv;
|
|
226
|
+
homeDir: string;
|
|
227
|
+
}): NodeJS.ProcessEnv;
|
|
228
|
+
turnsOffPersonalConfig(required: {
|
|
229
|
+
nativeCapabilities?: Partial<import("@jini-ai/core/contracts/agents").NativeCapabilities>;
|
|
230
|
+
}): boolean;
|
|
231
|
+
stage: typeof import("./defs/codex/home-staging.js").stageCodexHome;
|
|
232
|
+
};
|
|
233
|
+
envContent?: {
|
|
234
|
+
mergeMcp: typeof import("./defs/opencode/mcp-config.js").mergeEnvContentMcpConfig;
|
|
235
|
+
};
|
|
236
|
+
mcpDelivery?: {
|
|
237
|
+
envContentVar: string;
|
|
238
|
+
};
|
|
239
|
+
mcpBridgeMechanism?: import("@jini-ai/core/contracts/agents").McpBridgeMechanism;
|
|
240
|
+
toolCallReceipt?: (required: {
|
|
241
|
+
event: Record<string, unknown>;
|
|
242
|
+
}) => Record<string, unknown>;
|
|
243
|
+
};
|
|
244
|
+
};
|
|
163
245
|
models: {
|
|
164
246
|
resolveForLaunch: (required: {
|
|
165
247
|
def: RuntimeAgentDef;
|
|
@@ -17,6 +17,7 @@ import { checkPromptArgvBudget, checkWindowsCmdShimCommandLineBudget, checkWindo
|
|
|
17
17
|
import { preparePromptFileForAgent } from './prompt-file.js';
|
|
18
18
|
import { createQoderStreamHandler } from './qoder-stream.js';
|
|
19
19
|
import { bindRuntimeAgentDef } from './runtime-def-binding.js';
|
|
20
|
+
import { RUNTIME_STRATEGY_HOST_ENV_NAMES, strategiesForDef } from './runtime-strategies.js';
|
|
20
21
|
function bindDefs({ runtime }, _optional = {}) {
|
|
21
22
|
const { state, codex } = runtime;
|
|
22
23
|
return {
|
|
@@ -33,7 +34,7 @@ function bindLaunch({ runtime }, _optional = {}) {
|
|
|
33
34
|
// The toolchain dirs come from this runtime's state and host env, never from the process defaults.
|
|
34
35
|
applyEnv: (required, optional = {}) => applyAgentLaunchEnv(required, { appendPathDirs: userToolchainBinDirs({}, { state, env: hostEnv }), ...optional }),
|
|
35
36
|
toolchainBinDirs: (_required, optional = {}) => userToolchainBinDirs({}, { env: hostEnv, ...optional, state }),
|
|
36
|
-
hostEnvNames: () => Object.values(state.executable.envNames),
|
|
37
|
+
hostEnvNames: () => [...Object.values(state.executable.envNames), ...RUNTIME_STRATEGY_HOST_ENV_NAMES],
|
|
37
38
|
planRun: (required) => planRun(required),
|
|
38
39
|
resolveNativeToolPolicy: (required) => resolveNativeToolPolicy(required),
|
|
39
40
|
promptArgvBudget: (required, optional = {}) => checkPromptArgvBudget(required, optional),
|
|
@@ -82,6 +83,8 @@ export function createAgentRuntimeBindings({ runtime }, _optional = {}) {
|
|
|
82
83
|
defs: bindDefs({ runtime }),
|
|
83
84
|
launch: bindLaunch({ runtime }),
|
|
84
85
|
filesystem: bindFilesystem({}),
|
|
86
|
+
// Vendor behaviour chosen by what the definition declares, never by its id (see runtime-strategies.ts).
|
|
87
|
+
strategies: { for: (required) => strategiesForDef(required) },
|
|
85
88
|
models: {
|
|
86
89
|
resolveForLaunch: (required, optional = {}) => resolveModelForLaunch(required, { ...optional, deps: getRuntimeModelDiscoveryDeps({ state }) }),
|
|
87
90
|
identityKind: ({ id }) => modelIdentityKind({ id }),
|