@jini-ai/agent-runtime 0.7.3-next.2 → 0.7.4

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.
Files changed (177) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +38 -0
  3. package/dist/agent-protocol/acp/models.d.ts +0 -10
  4. package/dist/agent-protocol/acp/models.js +0 -10
  5. package/dist/agent-protocol/acp/rpc.d.ts +5 -1
  6. package/dist/agent-protocol/acp/rpc.js +2 -1
  7. package/dist/agent-protocol/acp/session-permission.js +4 -3
  8. package/dist/agent-protocol/acp/session-results.d.ts +4 -4
  9. package/dist/agent-protocol/acp/session-results.js +30 -21
  10. package/dist/agent-protocol/acp/session-run.js +0 -8
  11. package/dist/agent-protocol/acp/session-types.d.ts +0 -1
  12. package/dist/agent-protocol/acp/session-usage.d.ts +12 -0
  13. package/dist/agent-protocol/acp/session-usage.js +29 -0
  14. package/dist/agent-protocol/acp/session.d.ts +1 -1
  15. package/dist/agent-protocol/acp/session.js +10 -4
  16. package/dist/agent-protocol/acp/text-suppression.js +75 -71
  17. package/dist/agent-protocol/pi-rpc/events.d.ts +21 -4
  18. package/dist/agent-protocol/pi-rpc/events.js +9 -9
  19. package/dist/agent-protocol/pi-rpc/internal.d.ts +6 -2
  20. package/dist/agent-protocol/pi-rpc/internal.js +6 -4
  21. package/dist/agent-protocol/pi-rpc/session.js +4 -3
  22. package/dist/anthropic-live-models.js +0 -0
  23. package/dist/claude-code-models.d.ts +3 -1
  24. package/dist/claude-code-models.js +4 -4
  25. package/dist/claude-stream-frames.js +1 -1
  26. package/dist/cli-probe-cache.d.ts +33 -0
  27. package/dist/cli-probe-cache.js +59 -0
  28. package/dist/custom-instructions.d.ts +107 -0
  29. package/dist/custom-instructions.js +80 -0
  30. package/dist/defs/{aider.d.ts → aider/index.d.ts} +2 -1
  31. package/dist/defs/{aider.js → aider/index.js} +6 -3
  32. package/dist/defs/amr/executable-env.d.ts +2 -0
  33. package/dist/defs/amr/executable-env.js +2 -0
  34. package/dist/defs/amr/executable-resolution.d.ts +5 -1
  35. package/dist/defs/amr/executable-resolution.js +1 -1
  36. package/dist/defs/antigravity/index.d.ts +1 -0
  37. package/dist/defs/antigravity/index.js +3 -0
  38. package/dist/defs/antigravity/permissions.d.ts +26 -0
  39. package/dist/defs/antigravity/permissions.js +66 -0
  40. package/dist/defs/{auggie.d.ts → auggie/index.d.ts} +1 -1
  41. package/dist/defs/{auggie.js → auggie/index.js} +3 -3
  42. package/dist/defs/claude/config-dir.d.ts +62 -0
  43. package/dist/defs/claude/config-dir.js +133 -0
  44. package/dist/defs/claude/filesystem.d.ts +33 -0
  45. package/dist/defs/claude/filesystem.js +30 -0
  46. package/dist/defs/{claude.d.ts → claude/index.d.ts} +1 -1
  47. package/dist/defs/{claude.js → claude/index.js} +9 -9
  48. package/dist/defs/claude/mcp-config.d.ts +22 -0
  49. package/dist/defs/claude/mcp-config.js +29 -0
  50. package/dist/defs/claude/mcp-delivery.d.ts +57 -0
  51. package/dist/defs/claude/mcp-delivery.js +75 -0
  52. package/dist/defs/claude/mcp-json.d.ts +34 -0
  53. package/dist/defs/claude/mcp-json.js +38 -0
  54. package/dist/defs/claude/subagent-start.d.ts +12 -0
  55. package/dist/defs/claude/subagent-start.js +35 -0
  56. package/dist/defs/{cline.d.ts → cline/index.d.ts} +1 -1
  57. package/dist/defs/{cline.js → cline/index.js} +3 -3
  58. package/dist/defs/codex/contracts.d.ts +47 -0
  59. package/dist/defs/codex/contracts.js +6 -0
  60. package/dist/defs/codex/event-stream.d.ts +5 -1
  61. package/dist/defs/codex/event-stream.js +29 -24
  62. package/dist/defs/codex/home-config.d.ts +55 -0
  63. package/dist/defs/codex/home-config.js +224 -0
  64. package/dist/defs/codex/home-staging.d.ts +57 -0
  65. package/dist/defs/codex/home-staging.js +184 -0
  66. package/dist/defs/{codex.d.ts → codex/index.d.ts} +2 -2
  67. package/dist/defs/{codex.js → codex/index.js} +3 -3
  68. package/dist/defs/codex/isolation.d.ts +29 -0
  69. package/dist/defs/codex/isolation.js +69 -0
  70. package/dist/defs/codex/launch.d.ts +4 -1
  71. package/dist/defs/codex/launch.js +1 -1
  72. package/dist/defs/codex/mcp-delivery.d.ts +8 -0
  73. package/dist/defs/codex/mcp-delivery.js +5 -0
  74. package/dist/defs/{crush.d.ts → crush/index.d.ts} +1 -1
  75. package/dist/defs/{crush.js → crush/index.js} +3 -3
  76. package/dist/defs/cursor-agent/event-stream.d.ts +5 -1
  77. package/dist/defs/cursor-agent/event-stream.js +14 -7
  78. package/dist/defs/{cursor-agent.d.ts → cursor-agent/index.d.ts} +1 -1
  79. package/dist/defs/{cursor-agent.js → cursor-agent/index.js} +4 -4
  80. package/dist/defs/{deepseek.d.ts → deepseek/index.d.ts} +2 -1
  81. package/dist/defs/{deepseek.js → deepseek/index.js} +6 -3
  82. package/dist/defs/{devin.d.ts → devin/index.d.ts} +1 -1
  83. package/dist/defs/{devin.js → devin/index.js} +3 -3
  84. package/dist/defs/{droid.d.ts → droid/index.d.ts} +1 -1
  85. package/dist/defs/{droid.js → droid/index.js} +3 -3
  86. package/dist/defs/gemini/event-stream.d.ts +5 -1
  87. package/dist/defs/gemini/event-stream.js +15 -12
  88. package/dist/defs/gemini/tool-calls.d.ts +7 -0
  89. package/dist/defs/gemini/tool-calls.js +9 -0
  90. package/dist/defs/{goose.d.ts → goose/index.d.ts} +1 -1
  91. package/dist/defs/{goose.js → goose/index.js} +3 -3
  92. package/dist/defs/{grok-build.d.ts → grok-build/index.d.ts} +1 -1
  93. package/dist/defs/{grok-build.js → grok-build/index.js} +3 -3
  94. package/dist/defs/index.d.ts +28 -28
  95. package/dist/defs/index.js +28 -28
  96. package/dist/defs/{kilo.d.ts → kilo/index.d.ts} +1 -1
  97. package/dist/defs/{kilo.js → kilo/index.js} +3 -3
  98. package/dist/defs/kimi/event-stream.d.ts +4 -1
  99. package/dist/defs/kimi/event-stream.js +6 -5
  100. package/dist/defs/{kimi.d.ts → kimi/index.d.ts} +1 -1
  101. package/dist/defs/{kimi.js → kimi/index.js} +3 -3
  102. package/dist/defs/{kiro.d.ts → kiro/index.d.ts} +1 -1
  103. package/dist/defs/{kiro.js → kiro/index.js} +3 -3
  104. package/dist/defs/mimo/constants.d.ts +2 -0
  105. package/dist/defs/mimo/constants.js +2 -0
  106. package/dist/defs/{mimo.d.ts → mimo/index.d.ts} +1 -1
  107. package/dist/defs/{mimo.js → mimo/index.js} +3 -3
  108. package/dist/defs/opencode/constants.d.ts +2 -0
  109. package/dist/defs/opencode/constants.js +2 -0
  110. package/dist/defs/opencode/event-stream.d.ts +5 -1
  111. package/dist/defs/opencode/event-stream.js +13 -11
  112. package/dist/defs/{opencode.d.ts → opencode/index.d.ts} +2 -2
  113. package/dist/defs/{opencode.js → opencode/index.js} +5 -5
  114. package/dist/defs/opencode/mcp-config.d.ts +108 -0
  115. package/dist/defs/opencode/mcp-config.js +119 -0
  116. package/dist/defs/opencode/model-discovery.d.ts +3 -1
  117. package/dist/defs/opencode/model-discovery.js +1 -1
  118. package/dist/defs/opencode/tool-calls.d.ts +7 -0
  119. package/dist/defs/opencode/tool-calls.js +12 -0
  120. package/dist/defs/{opencode-acp.d.ts → opencode-acp/index.d.ts} +2 -2
  121. package/dist/defs/{opencode-acp.js → opencode-acp/index.js} +4 -4
  122. package/dist/defs/{pi.d.ts → pi/index.d.ts} +1 -1
  123. package/dist/defs/{pi.js → pi/index.js} +3 -3
  124. package/dist/defs/pi/model-discovery.d.ts +4 -1
  125. package/dist/defs/pi/model-discovery.js +1 -1
  126. package/dist/defs/{qoder.d.ts → qoder/index.d.ts} +1 -1
  127. package/dist/defs/{qoder.js → qoder/index.js} +3 -3
  128. package/dist/defs/{qwen.d.ts → qwen/index.d.ts} +1 -1
  129. package/dist/defs/{qwen.js → qwen/index.js} +3 -3
  130. package/dist/defs/{reasonix.d.ts → reasonix/index.d.ts} +1 -1
  131. package/dist/defs/{reasonix.js → reasonix/index.js} +3 -3
  132. package/dist/defs/{trae-cli.d.ts → trae-cli/index.d.ts} +1 -1
  133. package/dist/defs/{trae-cli.js → trae-cli/index.js} +3 -3
  134. package/dist/defs/{vibe.d.ts → vibe/index.d.ts} +1 -1
  135. package/dist/defs/{vibe.js → vibe/index.js} +3 -3
  136. package/dist/executables.js +1 -1
  137. package/dist/inventory/index.d.ts +61 -0
  138. package/dist/inventory/index.js +45 -0
  139. package/dist/json-event-stream-shared.d.ts +10 -2
  140. package/dist/json-event-stream-shared.js +21 -13
  141. package/dist/json-event-stream.js +6 -5
  142. package/dist/launch.js +1 -1
  143. package/dist/model-catalog-live-discovery.d.ts +103 -0
  144. package/dist/model-catalog-live-discovery.js +111 -0
  145. package/dist/model-discovery-adapters.d.ts +6 -1
  146. package/dist/model-discovery-adapters.js +4 -3
  147. package/dist/model-discovery-config.js +1 -1
  148. package/dist/native-permissions.d.ts +19 -0
  149. package/dist/native-permissions.js +22 -0
  150. package/dist/providers/anthropic-messages.js +3 -2
  151. package/dist/providers/connection-guard.js +99 -84
  152. package/dist/providers/connection-test.js +0 -5
  153. package/dist/providers/google-messages.js +1 -1
  154. package/dist/providers/oauth-provider.d.ts +1 -23
  155. package/dist/providers/oauth-provider.js +1 -35
  156. package/dist/providers/openai-chat-request.js +1 -1
  157. package/dist/providers/tool-loop-verdict.d.ts +1 -0
  158. package/dist/providers/tool-loop-verdict.js +4 -1
  159. package/dist/providers/tool-turn-types.d.ts +12 -9
  160. package/dist/providers/tool-turn.d.ts +63 -1
  161. package/dist/providers/tool-turn.js +67 -1
  162. package/dist/qoder-stream.js +66 -66
  163. package/dist/role-marker-guard.js +49 -30
  164. package/dist/runtime-def-binding.js +1 -1
  165. package/dist/runtime-port-bindings.d.ts +82 -0
  166. package/dist/runtime-port-bindings.js +4 -1
  167. package/dist/runtime-strategies.d.ts +100 -0
  168. package/dist/runtime-strategies.js +129 -0
  169. package/package.json +44 -10
  170. package/dist/defs/amp.d.ts +0 -2
  171. package/dist/defs/amp.js +0 -2
  172. package/dist/defs/amr.d.ts +0 -2
  173. package/dist/defs/amr.js +0 -2
  174. package/dist/defs/codebuddy.d.ts +0 -2
  175. package/dist/defs/codebuddy.js +0 -2
  176. package/dist/defs/hermes.d.ts +0 -2
  177. package/dist/defs/hermes.js +0 -2
@@ -62,7 +62,7 @@ export function emitTurnEndErrorIfPresent({ message, raw, send }, _optional = {}
62
62
  : 'Pi agent error';
63
63
  send({ event: 'agent', payload: { type: 'error', message: messageText, raw } });
64
64
  }
65
- export function handleTurnEnd(raw, send, ctx) {
65
+ export function handleTurnEnd({ raw, send, ctx }, _optional = {}) {
66
66
  const message = getRecord({ value: raw.message });
67
67
  const messageUsage = getRecord({ value: message?.usage });
68
68
  if (messageUsage)
@@ -70,7 +70,7 @@ export function handleTurnEnd(raw, send, ctx) {
70
70
  emitTurnEndErrorIfPresent({ message, raw, send });
71
71
  return null;
72
72
  }
73
- export function handleAssistantTextDelta(ev, send, ctx) {
73
+ export function handleAssistantTextDelta({ ev, send, ctx }, _optional = {}) {
74
74
  if (typeof ev.delta !== 'string')
75
75
  return;
76
76
  if (!ctx.sentFirstToken.value) {
@@ -98,18 +98,18 @@ export function handleAssistantThinkingEnd(_ev, send) {
98
98
  // the model returns an error (e.g. aborted, context overflow).
99
99
  // Surface it so sendAgentEvent's error-handling path sets
100
100
  // agentStreamError and the run flips to `failed` on close.
101
- export function handleAssistantError(ev, send, _ctx, raw) {
101
+ export function handleAssistantError({ ev, send, _ctx, raw }, _optional = {}) {
102
102
  const message = nonEmptyString(ev.reason) ?? nonEmptyString(ev.delta) ?? 'Agent error';
103
103
  send({ event: 'agent', payload: { type: 'error', message, raw } });
104
104
  }
105
105
  const ASSISTANT_MESSAGE_EVENT_HANDLERS = {
106
- text_delta: handleAssistantTextDelta,
106
+ text_delta: (ev, send, ctx) => handleAssistantTextDelta({ ev, send, ctx }),
107
107
  thinking_delta: handleAssistantThinkingDelta,
108
108
  thinking_start: handleAssistantThinkingStart,
109
109
  thinking_end: handleAssistantThinkingEnd,
110
- error: handleAssistantError,
110
+ error: (ev, send, ctx, raw) => handleAssistantError({ ev, send, _ctx: ctx, raw }),
111
111
  };
112
- export function handleMessageUpdate(raw, send, ctx) {
112
+ export function handleMessageUpdate({ raw, send, ctx }, _optional = {}) {
113
113
  const ev = getRecord({ value: raw.assistantMessageEvent });
114
114
  const handler = typeof ev?.type === 'string' ? ASSISTANT_MESSAGE_EVENT_HANDLERS[ev.type] : undefined;
115
115
  if (ev && handler)
@@ -176,8 +176,8 @@ const PI_RPC_EVENT_HANDLERS = {
176
176
  agent_start: handleAgentStart,
177
177
  agent_end: handleAgentEnd,
178
178
  turn_start: handleTurnStart,
179
- turn_end: handleTurnEnd,
180
- message_update: handleMessageUpdate,
179
+ turn_end: (raw, send, ctx) => handleTurnEnd({ raw, send, ctx }),
180
+ message_update: (raw, send, ctx) => handleMessageUpdate({ raw, send, ctx }),
181
181
  message_end: handleMessageEnd,
182
182
  tool_execution_start: handleToolExecutionStart,
183
183
  tool_execution_end: handleToolExecutionEnd,
@@ -201,7 +201,7 @@ export function mapPiRpcEvent({ raw, send, ctx }, _optional = {}) {
201
201
  if (message?.role === 'assistant' && typeof message.model === 'string' && typeof message.provider === 'string') {
202
202
  send({ event: 'agent', payload: { type: 'status', label: 'model', model: `${message.provider}/${message.model}` } });
203
203
  }
204
- const handler = typeof raw.type === 'string' ? PI_RPC_EVENT_HANDLERS[raw.type] : undefined;
204
+ const handler = typeof raw.type === 'string' && Object.hasOwn(PI_RPC_EVENT_HANDLERS, raw.type) ? PI_RPC_EVENT_HANDLERS[raw.type] : undefined;
205
205
  return handler ? handler(raw, send, ctx) : null;
206
206
  }
207
207
  //# sourceMappingURL=events.js.map
@@ -22,7 +22,11 @@ export type TokenUsage = {
22
22
  * Returns `true` when `value` is a non-null object, narrowing it to
23
23
  * `JsonRecord` for safe property access on RPC message payloads.
24
24
  */
25
- export declare function isRecord(value: unknown): value is JsonRecord;
25
+ export declare function isRecord(required: {
26
+ value: unknown;
27
+ }, _optional?: Record<string, never>): required is {
28
+ value: JsonRecord;
29
+ };
26
30
  /**
27
31
  * Extracts a human-readable message string from an unknown thrown value;
28
32
  * falls back to `String(err)` for non-Error objects.
@@ -48,7 +52,7 @@ export declare function errorCode({ err }: {
48
52
  *
49
53
  * @param value - An arbitrary value from a parsed JSON payload.
50
54
  */
51
- export declare function getRecord({ value }: {
55
+ export declare function getRecord(required: {
52
56
  value: unknown;
53
57
  }, _optional?: Record<string, never>): JsonRecord | undefined;
54
58
  //# sourceMappingURL=internal.d.ts.map
@@ -7,7 +7,8 @@
7
7
  * Returns `true` when `value` is a non-null object, narrowing it to
8
8
  * `JsonRecord` for safe property access on RPC message payloads.
9
9
  */
10
- export function isRecord(value) {
10
+ export function isRecord(required, _optional = {}) {
11
+ const { value } = required;
11
12
  return typeof value === 'object' && value !== null;
12
13
  }
13
14
  /**
@@ -27,7 +28,8 @@ export function errorMessage({ err }, _optional = {}) {
27
28
  * @param err - Any caught value from a try/catch or error callback.
28
29
  */
29
30
  export function errorCode({ err }, _optional = {}) {
30
- return isRecord(err) && typeof err.code === 'string' ? err.code : undefined;
31
+ const record = getRecord({ value: err });
32
+ return typeof record?.code === 'string' ? record.code : undefined;
31
33
  }
32
34
  /**
33
35
  * Returns `value` cast to `JsonRecord` when it is a non-null object, or
@@ -35,7 +37,7 @@ export function errorCode({ err }, _optional = {}) {
35
37
  *
36
38
  * @param value - An arbitrary value from a parsed JSON payload.
37
39
  */
38
- export function getRecord({ value }, _optional = {}) {
39
- return isRecord(value) ? value : undefined;
40
+ export function getRecord(required, _optional = {}) {
41
+ return isRecord(required) ? required.value : undefined;
40
42
  }
41
43
  //# sourceMappingURL=internal.js.map
@@ -8,7 +8,7 @@ import fs from 'node:fs';
8
8
  import path from 'node:path';
9
9
  import { createJsonLineStream } from '../core/index.js';
10
10
  import { mapPiRpcEvent } from './events.js';
11
- import { isRecord, errorMessage, errorCode, getRecord } from './internal.js';
11
+ import { errorMessage, errorCode, getRecord } from './internal.js';
12
12
  // Image forwarding budgets to prevent large synchronous base64 work.
13
13
  /** Maximum number of images forwarded per prompt turn. */
14
14
  export const MAX_IMAGE_COUNT = 10;
@@ -352,8 +352,9 @@ function handlePiAgentEnd(run) {
352
352
  child.kill('SIGTERM');
353
353
  }, gracefulShutdownMs);
354
354
  }
355
- function handlePiMessage({ run, raw }) {
356
- if (!isRecord(raw))
355
+ function handlePiMessage({ run, raw: value }) {
356
+ const raw = getRecord({ value });
357
+ if (!raw)
357
358
  return;
358
359
  // Once finished (agent_end or abort), stop processing — the run is
359
360
  // over, so no more agent events should be emitted. We still drain
Binary file
@@ -13,7 +13,9 @@ export declare const CLAUDE_CODE_INITIALIZE_REQUEST = "{\"type\":\"control_reque
13
13
  export declare const CLAUDE_CODE_INITIALIZE_ARGS: readonly string[];
14
14
  /** Strips the bracketed context-window variant marker (`claude-fable-5-1[1m]`) —
15
15
  * `models.ts#sanitizeCustomModel` rejects brackets, and `--model` accepts the bare name. */
16
- export declare function normalizeClaudePickerModelId(raw: string): string;
16
+ export declare function normalizeClaudePickerModelId({ raw }: {
17
+ raw: string;
18
+ }, _optional?: Record<string, never>): string;
17
19
  /** Outcome of parsing `~/.claude.json`. The failure reasons are distinct so the freshness guard can
18
20
  * say WHY it skipped; the runtime treats every failure as "nothing to add". */
19
21
  export type ClaudeCodePickerCacheParse = {
@@ -6,7 +6,7 @@ import { defaultRuntimeState } from './runtime-state.js';
6
6
  * `codex debug models`.
7
7
  *
8
8
  * **Why this exists.** `claude` has no list-models subcommand, so without an `ANTHROPIC_API_KEY` the
9
- * picker used to render `defs/claude.ts`'s hand-written `CLAUDE_FALLBACK_MODELS` and nothing else. A
9
+ * picker used to render `defs/claude/index.ts`'s hand-written `CLAUDE_FALLBACK_MODELS` and nothing else. A
10
10
  * subscription-only install therefore never saw a new model (e.g. `claude-opus-5-5`) until someone
11
11
  * edited that array and republished.
12
12
  *
@@ -69,7 +69,7 @@ export const CLAUDE_CODE_INITIALIZE_ARGS = [
69
69
  ];
70
70
  /** Strips the bracketed context-window variant marker (`claude-fable-5-1[1m]`) —
71
71
  * `models.ts#sanitizeCustomModel` rejects brackets, and `--model` accepts the bare name. */
72
- export function normalizeClaudePickerModelId(raw) {
72
+ export function normalizeClaudePickerModelId({ raw }, _optional = {}) {
73
73
  return stripTrailingBracketGroup(raw).trim();
74
74
  }
75
75
  /** `x[1m]` -> `x`: drops a final `[...]` group (one containing no `]`); leaves `raw` alone otherwise.
@@ -103,7 +103,7 @@ export function parseClaudeCodePickerCache({ raw }, _optional = {}) {
103
103
  const ids = cached
104
104
  .map((entry) => (entry && typeof entry === 'object' ? entry.value : null))
105
105
  .filter((value) => typeof value === 'string')
106
- .map(normalizeClaudePickerModelId)
106
+ .map(raw => normalizeClaudePickerModelId({ raw }))
107
107
  .filter((id) => id.length > 0);
108
108
  return ids.length > 0 ? { ok: true, ids } : { ok: false, reason: 'no-usable-values' };
109
109
  }
@@ -137,7 +137,7 @@ function initializeEntryRows(entry) {
137
137
  const rows = [];
138
138
  const displayName = typeof entry.displayName === 'string' ? entry.displayName : '';
139
139
  for (const raw of [entry.value, entry.resolvedModel]) {
140
- const id = typeof raw === 'string' ? normalizeClaudePickerModelId(raw) : 'default';
140
+ const id = typeof raw === 'string' ? normalizeClaudePickerModelId({ raw }) : 'default';
141
141
  // A non-string value contributes nothing, same as the `default` sentinel.
142
142
  if (id === 'default' || sanitizeCustomModel({ id: id }) !== id)
143
143
  continue;
@@ -37,7 +37,7 @@ const TASK_STATUS_ALIASES = {
37
37
  export function normalizeTaskStatus({ value }, _optional = {}) {
38
38
  if (typeof value !== 'string')
39
39
  return 'pending';
40
- return TASK_STATUS_ALIASES[value] ?? 'pending';
40
+ return Object.hasOwn(TASK_STATUS_ALIASES, value) ? TASK_STATUS_ALIASES[value] : 'pending';
41
41
  }
42
42
  function nextGeneratedRuntimeTaskId(counter) {
43
43
  // Coverage-driven refactor (2026-07-18, no behavior change): the
@@ -0,0 +1,33 @@
1
+ /** Background inventory caching for detected CLIs; the host injects the probe (its inventory port).
2
+ * Discovery stays behind the existing runtime port; requests only read settled snapshots. */
3
+ /** The shared probe tail: caches given the same queue never launch overlapping CLI sweeps.
4
+ * Host-owned (one per process is typical) so this module keeps no state of its own. */
5
+ export interface CliProbeQueue {
6
+ tail: Promise<void>;
7
+ }
8
+ /** A fresh, idle probe queue for {@link createCliProbeCache}'s `probeQueue`. */
9
+ export declare function createCliProbeQueue(_required?: Record<string, never>, _optional?: Record<string, never>): CliProbeQueue;
10
+ /** One inventory per host port. Catalog expiry schedules a lazy background refresh.
11
+ * Failed scans keep the snapshot until the optional retry cooldown; explicit Rescan always retries.
12
+ * A rescan during a scan coalesces into one forced follow-up, never a second concurrent sweep.
13
+ * @complexity O(1) bookkeeping; snapshot/probe cost belongs to the injected inventory port. */
14
+ export declare function createCliProbeCache<T>({ initial, probe, probeQueue }: {
15
+ initial: () => T;
16
+ probe: (input: {
17
+ force: boolean;
18
+ }, options: Record<string, never>) => Promise<T>;
19
+ probeQueue: CliProbeQueue;
20
+ }, { expiresAt, retryAfterMs }?: {
21
+ expiresAt?: (input: {
22
+ snapshot: T;
23
+ }, options: Record<string, never>) => number;
24
+ retryAfterMs?: number;
25
+ }): {
26
+ isPending(_input: Record<string, never>, _options?: Record<string, never>): boolean;
27
+ read({ force }: {
28
+ force?: boolean;
29
+ }, _options?: Record<string, never>): Promise<T>;
30
+ /** Explicit completion port for diagnostics/tests; HTTP readers never call it. */
31
+ settled(_input: Record<string, never>, _options?: Record<string, never>): Promise<void>;
32
+ };
33
+ //# sourceMappingURL=cli-probe-cache.d.ts.map
@@ -0,0 +1,59 @@
1
+ /** Background inventory caching for detected CLIs; the host injects the probe (its inventory port).
2
+ * Discovery stays behind the existing runtime port; requests only read settled snapshots. */
3
+ /** A fresh, idle probe queue for {@link createCliProbeCache}'s `probeQueue`. */
4
+ export function createCliProbeQueue(_required = {}, _optional = {}) {
5
+ return { tail: Promise.resolve() };
6
+ }
7
+ /** One inventory per host port. Catalog expiry schedules a lazy background refresh.
8
+ * Failed scans keep the snapshot until the optional retry cooldown; explicit Rescan always retries.
9
+ * A rescan during a scan coalesces into one forced follow-up, never a second concurrent sweep.
10
+ * @complexity O(1) bookkeeping; snapshot/probe cost belongs to the injected inventory port. */
11
+ export function createCliProbeCache({ initial, probe, probeQueue }, { expiresAt, retryAfterMs } = {}) {
12
+ let snapshot;
13
+ let pending;
14
+ let started = false;
15
+ let rescanQueued = false;
16
+ let snapshotExpiresAt = Infinity;
17
+ function refresh({ force }, _options = {}) {
18
+ if (pending) {
19
+ rescanQueued ||= force;
20
+ return;
21
+ }
22
+ started = true;
23
+ // Let the request serialize its cached response before even launching the first CLI.
24
+ const turn = new Promise(resolve => { setImmediate(resolve); });
25
+ pending = probeQueue.tail.then(() => turn).then(async () => {
26
+ try {
27
+ const result = await probe({ force }, {});
28
+ snapshotExpiresAt = expiresAt?.({ snapshot: result }, {}) ?? Infinity;
29
+ snapshot = Promise.resolve(result);
30
+ }
31
+ catch {
32
+ // Keep last-good data without hammering a failing host or caching an initial failure forever.
33
+ snapshotExpiresAt = retryAfterMs === undefined ? Infinity : Date.now() + retryAfterMs;
34
+ }
35
+ }).finally(() => {
36
+ pending = undefined;
37
+ if (rescanQueued) {
38
+ rescanQueued = false;
39
+ refresh({ force: true });
40
+ }
41
+ });
42
+ probeQueue.tail = pending;
43
+ }
44
+ return {
45
+ isPending(_input, _options = {}) { return pending !== undefined; },
46
+ read({ force = false }, _options = {}) {
47
+ snapshot ??= Promise.resolve(initial());
48
+ if (!started || force || snapshotExpiresAt <= Date.now())
49
+ refresh({ force });
50
+ return snapshot;
51
+ },
52
+ /** Explicit completion port for diagnostics/tests; HTTP readers never call it. */
53
+ async settled(_input, _options = {}) {
54
+ while (pending)
55
+ await pending;
56
+ },
57
+ };
58
+ }
59
+ //# sourceMappingURL=cli-probe-cache.js.map
@@ -0,0 +1,107 @@
1
+ import type { UUID } from "@jini-ai/core/primitives";
2
+ import type { SettingsRepoPort } from "@jini-ai/core/settings";
3
+ /**
4
+ * Structural signature matching `@jini-ai/core/settings`'s real `getEffective` export (a host may
5
+ * re-export it from its own settings feature). Redeclared locally rather than imported as a value:
6
+ * importing the FUNCTION here is the edge that would close an `[assistant, settings]` module cycle in
7
+ * a host whose settings feature registers assistant tool contributors; see `ResolveCustomInstructionsDeps.getEffective`'s own doc for
8
+ * how the real function still reaches this file despite the type living here instead of being
9
+ * imported. `.value` is typed `unknown` (not `JsonValue`) because this file only ever narrows it with
10
+ * `typeof ... === "string"` below — no caller here needs the full settings-value union.
11
+ */
12
+ type GetEffective = (required: {
13
+ deps: {
14
+ repo: SettingsRepoPort;
15
+ };
16
+ namespace: string;
17
+ key: string;
18
+ scopeContext: {
19
+ workspaceId: UUID;
20
+ };
21
+ }) => Promise<{
22
+ value: unknown;
23
+ } | null>;
24
+ export interface ResolveCustomInstructionsDeps {
25
+ settingsRepo: SettingsRepoPort;
26
+ /**
27
+ * Resolves once boot-time definition registration for `core.instructions.*`
28
+ * (the host's settings-tabs-ready promise) completes. Awaited before every read so a read that races
29
+ * boot reads as "not yet registered" (falls through to `""`) rather than being misinterpreted —
30
+ * the same discipline the host's settings-ready promise requires of every settings consumer.
31
+ * Optional so a test that registers definitions itself before calling in doesn't need to thread a
32
+ * dummy resolved promise through.
33
+ * @default Promise.resolve()
34
+ */
35
+ settingsReady?: Promise<void>;
36
+ /** The real `@jini-ai/core/settings` `getEffective` — injected rather than statically imported;
37
+ * see the `GetEffective` type's own doc. Wired to the real implementation at the host's
38
+ * composition root. */
39
+ getEffective: GetEffective;
40
+ /** The host settings feature's `INSTRUCTIONS_NAMESPACE` constant (e.g. `"core.instructions"`) —
41
+ * injected for uniformity with `getEffective` above rather than relocated to a new shared module,
42
+ * so this module never takes a runtime edge on the host's settings barrel. */
43
+ instructionsNamespace: string;
44
+ /**
45
+ * Receives the fail-open read's message and error (see `resolveCustomInstructions`). Injected so
46
+ * the host owns its log sink and any log-line prefix; the engine never writes to the console.
47
+ */
48
+ warn: (message: string, error: unknown) => void;
49
+ }
50
+ export interface ResolveCustomInstructionsInput {
51
+ workspaceId: UUID;
52
+ }
53
+ /** The single object argument both entry points take: the injected deps plus the per-call input. */
54
+ export type ResolveCustomInstructionsArgs = ResolveCustomInstructionsDeps & ResolveCustomInstructionsInput;
55
+ /**
56
+ * Reads `core.instructions.custom` fresh from the ledger for one workspace. getEffective owns
57
+ * fresh reads; see the header for why independent processes cannot rely on cache invalidation.
58
+ *
59
+ * FAILS OPEN: any error (a repo I/O failure, `settingsReady` rejecting, a malformed stored value) is
60
+ * logged and reads as `""` — a broken settings read must degrade the assistant to "no custom
61
+ * instructions", never block a run from starting at all. This restates, at the one call site here
62
+ * that cannot assume it, `getEffective`'s own documented "total, never throws" contract — the
63
+ * evaluator logic above the repo is exempt from throwing; the repo's actual I/O underneath it is not.
64
+ *
65
+ * @complexity O(1) — one `getEffective` resolution.
66
+ * @overallScore 100
67
+ */
68
+ export declare function resolveCustomInstructions(args: ResolveCustomInstructionsArgs, _optional?: {}): Promise<string>;
69
+ /**
70
+ * Formats a raw `core.instructions.custom` value as a `PromptAugmenter.systemOverlay()` block, or
71
+ * `null` for empty/whitespace-only text — matching that seam's own "if non-null" contract
72
+ * (`@jini-ai/agent-runtime`'s `prompt-augmenter.ts`) so an operator who has never set instructions
73
+ * (or has cleared them back to the tab's empty-textarea default) gets byte-identical behavior to
74
+ * before this file existed.
75
+ *
76
+ * @complexity O(n) in the length of `customInstructions` — one trim, one length check.
77
+ * @overallScore 100
78
+ */
79
+ export declare function formatCustomInstructionsOverlay({ customInstructions }: {
80
+ customInstructions: string;
81
+ }, _optional?: {}): string | null;
82
+ export interface CustomInstructionsCache {
83
+ /**
84
+ * Re-resolves `core.instructions.custom` and updates what `readOverlay()` returns next. Never
85
+ * rejects — inherits `resolveCustomInstructions`'s fail-open contract.
86
+ */
87
+ refresh(): Promise<void>;
88
+ /**
89
+ * Synchronous read of the last successfully refreshed value, formatted per
90
+ * `formatCustomInstructionsOverlay`. `null` before the first `refresh()` ever resolves, which is
91
+ * indistinguishable from "no custom instructions set" — the only value `systemOverlay()`'s
92
+ * synchronous contract allows before any async read has had a chance to complete.
93
+ */
94
+ readOverlay(): string | null;
95
+ }
96
+ /**
97
+ * The synchronous-read bridge this file's header describes. The host daemon constructs one
98
+ * instance for its single workspace, calls `refresh()` once per run start (before starting the
99
+ * agent, so the read is never older than "as of this conversation turn"), and wires `readOverlay`
100
+ * into `PromptAugmenter.systemOverlay()`.
101
+ *
102
+ * @complexity O(1) to construct; `refresh()` is `resolveCustomInstructions`'s O(1).
103
+ * @overallScore 100
104
+ */
105
+ export declare function createCustomInstructionsCache(args: ResolveCustomInstructionsArgs, _optional?: {}): CustomInstructionsCache;
106
+ export {};
107
+ //# sourceMappingURL=custom-instructions.d.ts.map
@@ -0,0 +1,80 @@
1
+ /**
2
+ * @file The read half of the admin Instructions tab's system-prompt seam: turns the stored
3
+ * `core.instructions.custom` value into text the host daemon's `PromptAugmenter.
4
+ * systemOverlay()` hands the spawned agent CLI. Prompt assembly belongs to the daemon process.
5
+ *
6
+ * `getEffective` must read fresh values: main-server writes cannot invalidate a cache keyed by
7
+ * this daemon's independent repository instance. An indexed local row read is cheaper than
8
+ * cross-process cache incoherence; see the owning settings module's cache rationale.
9
+ *
10
+ * `PromptAugmenter.systemOverlay()` returns synchronously, while the settings read is async.
11
+ * `createCustomInstructionsCache` holds the last successfully resolved value; the caller refreshes
12
+ * it before each run so the synchronous overlay can read it without I/O.
13
+ */
14
+ const CUSTOM_INSTRUCTIONS_KEY = "custom";
15
+ /**
16
+ * Reads `core.instructions.custom` fresh from the ledger for one workspace. getEffective owns
17
+ * fresh reads; see the header for why independent processes cannot rely on cache invalidation.
18
+ *
19
+ * FAILS OPEN: any error (a repo I/O failure, `settingsReady` rejecting, a malformed stored value) is
20
+ * logged and reads as `""` — a broken settings read must degrade the assistant to "no custom
21
+ * instructions", never block a run from starting at all. This restates, at the one call site here
22
+ * that cannot assume it, `getEffective`'s own documented "total, never throws" contract — the
23
+ * evaluator logic above the repo is exempt from throwing; the repo's actual I/O underneath it is not.
24
+ *
25
+ * @complexity O(1) — one `getEffective` resolution.
26
+ * @overallScore 100
27
+ */
28
+ export async function resolveCustomInstructions(args, _optional = {}) {
29
+ try {
30
+ await (args.settingsReady ?? Promise.resolve());
31
+ const resolved = await args.getEffective({
32
+ deps: { repo: args.settingsRepo },
33
+ namespace: args.instructionsNamespace,
34
+ key: CUSTOM_INSTRUCTIONS_KEY,
35
+ scopeContext: { workspaceId: args.workspaceId },
36
+ });
37
+ return typeof resolved?.value === "string" ? resolved.value : "";
38
+ }
39
+ catch (error) {
40
+ args.warn("resolveCustomInstructions failed; treating as unset", error);
41
+ return "";
42
+ }
43
+ }
44
+ const CUSTOM_INSTRUCTIONS_OVERLAY_HEADER = "The site operator has configured the following custom instructions for this assistant. Follow " +
45
+ "them in addition to your default behavior, and defer to them if they conflict with it:";
46
+ /**
47
+ * Formats a raw `core.instructions.custom` value as a `PromptAugmenter.systemOverlay()` block, or
48
+ * `null` for empty/whitespace-only text — matching that seam's own "if non-null" contract
49
+ * (`@jini-ai/agent-runtime`'s `prompt-augmenter.ts`) so an operator who has never set instructions
50
+ * (or has cleared them back to the tab's empty-textarea default) gets byte-identical behavior to
51
+ * before this file existed.
52
+ *
53
+ * @complexity O(n) in the length of `customInstructions` — one trim, one length check.
54
+ * @overallScore 100
55
+ */
56
+ export function formatCustomInstructionsOverlay({ customInstructions }, _optional = {}) {
57
+ const trimmed = customInstructions.trim();
58
+ return trimmed.length === 0 ? null : `${CUSTOM_INSTRUCTIONS_OVERLAY_HEADER}\n\n${trimmed}`;
59
+ }
60
+ /**
61
+ * The synchronous-read bridge this file's header describes. The host daemon constructs one
62
+ * instance for its single workspace, calls `refresh()` once per run start (before starting the
63
+ * agent, so the read is never older than "as of this conversation turn"), and wires `readOverlay`
64
+ * into `PromptAugmenter.systemOverlay()`.
65
+ *
66
+ * @complexity O(1) to construct; `refresh()` is `resolveCustomInstructions`'s O(1).
67
+ * @overallScore 100
68
+ */
69
+ export function createCustomInstructionsCache(args, _optional = {}) {
70
+ let latest = "";
71
+ return {
72
+ async refresh() {
73
+ latest = await resolveCustomInstructions(args);
74
+ },
75
+ readOverlay() {
76
+ return formatCustomInstructionsOverlay({ customInstructions: latest });
77
+ },
78
+ };
79
+ }
80
+ //# sourceMappingURL=custom-instructions.js.map
@@ -15,6 +15,7 @@ export declare const aiderAgentDef: {
15
15
  runtimeContext?: import("@jini-ai/core/contracts/agents").RuntimeContext;
16
16
  } | undefined) => string[];
17
17
  maxPromptArgBytes: number;
18
+ argvPromptPosition: "last";
18
19
  streamFormat: string;
19
20
  installUrl: string;
20
21
  docsUrl: string;
@@ -34,4 +35,4 @@ export declare const aiderAgentDef: {
34
35
  deps?: import("@jini-ai/core/contracts/agents").ModelDiscoveryDeps;
35
36
  }): Promise<import("@jini-ai/core/contracts/agents").DefaultModelResolution>;
36
37
  };
37
- //# sourceMappingURL=aider.d.ts.map
38
+ //# sourceMappingURL=index.d.ts.map
@@ -1,5 +1,5 @@
1
- import { createAgentModelDiscovery } from '../model-discovery-native.js';
2
- import { DEFAULT_MODEL_OPTION } from './shared.js';
1
+ import { createAgentModelDiscovery } from '../../model-discovery-native.js';
2
+ import { DEFAULT_MODEL_OPTION } from '../shared.js';
3
3
  export const aiderAgentDef = {
4
4
  // UNVERIFIED live integration locally; source/category and limits are documented in model-discovery-adapters.ts.
5
5
  ...createAgentModelDiscovery('aider', { fallbackModels: () => aiderAgentDef.fallbackModels }),
@@ -72,6 +72,9 @@ export const aiderAgentDef = {
72
72
  return args;
73
73
  },
74
74
  maxPromptArgBytes: 30_000,
75
+ // `buildArgs` pushes the prompt verbatim as the final argv element (pinned by
76
+ // `defs/__tests__/argv-prompt-position.test.ts`), so prompt variants may fit that slot.
77
+ argvPromptPosition: 'last',
75
78
  streamFormat: 'plain',
76
79
  installUrl: 'https://aider.chat/docs/install.html',
77
80
  docsUrl: 'https://aider.chat',
@@ -83,4 +86,4 @@ export const aiderAgentDef = {
83
86
  // is nowhere for a bridged tool call to land. Revisit if upstream ships a
84
87
  // client.
85
88
  };
86
- //# sourceMappingURL=aider.js.map
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export declare const AMR_OPENCODE_BIN_ENV = "VELA_OPENCODE_BIN";
2
+ //# sourceMappingURL=executable-env.d.ts.map
@@ -0,0 +1,2 @@
1
+ export const AMR_OPENCODE_BIN_ENV = 'VELA_OPENCODE_BIN';
2
+ //# sourceMappingURL=executable-env.js.map
@@ -3,5 +3,9 @@ export declare function resolveAmrCompanion({ options, services }: {
3
3
  options: ResolvedExecutableOptions;
4
4
  services: ExecutableResolutionHelpers;
5
5
  }, _optional?: Record<string, never>): string | null;
6
- export declare function packagedAmrExecutable(configuredEnv: Record<string, string>, options: ResolvedExecutableOptions, services: ExecutableResolutionHelpers): string | null;
6
+ export declare function packagedAmrExecutable({ configuredEnv, options, services }: {
7
+ configuredEnv: Record<string, string>;
8
+ options: ResolvedExecutableOptions;
9
+ services: ExecutableResolutionHelpers;
10
+ }, _optional?: Record<string, never>): string | null;
7
11
  //# sourceMappingURL=executable-resolution.d.ts.map
@@ -36,7 +36,7 @@ function packagedVelaOpenCodeCompanionTree(resourceRoot, options, services) {
36
36
  }
37
37
  return services.isRunnableFile(path.join(candidate, services.platformExecutableName({ name: 'opencode' })), options) ? candidate : null;
38
38
  }
39
- export function packagedAmrExecutable(configuredEnv, options, services) {
39
+ export function packagedAmrExecutable({ configuredEnv, options, services }, _optional = {}) {
40
40
  const resourceRoot = services.resourceRootOf(options);
41
41
  if (!resourceRoot)
42
42
  return null;
@@ -75,6 +75,7 @@ export declare const antigravityAgentDef: {
75
75
  runtimeContext?: RuntimeContext;
76
76
  } | undefined) => string[];
77
77
  maxPromptArgBytes: number;
78
+ argvPromptPosition: "last";
78
79
  fullCliAccessOnly: true;
79
80
  fullCliAccessNote: string;
80
81
  streamFormat: string;
@@ -258,6 +258,9 @@ export const antigravityAgentDef = {
258
258
  // deepseek) rather than `promptViaStdin`. Without one of these three
259
259
  // fields `assessAgentExecutorCompatibility` rejects the def outright.
260
260
  maxPromptArgBytes: 30_000,
261
+ // `buildArgs` pushes the prompt verbatim as the final argv element (pinned by
262
+ // `defs/__tests__/argv-prompt-position.test.ts`), so prompt variants may fit that slot.
263
+ argvPromptPosition: 'last',
261
264
  // Structured receipts enable native-tool auditing; they do not enforce an OFF switch.
262
265
  // agy's CLI reference exposes no run-scoped settings/permission/MCP override. Global settings
263
266
  // writes race other runs, and relocating HOME breaks auth, so audited output alone cannot grant this.
@@ -0,0 +1,26 @@
1
+ import type { AtomicFileWriterPort, FileLockPort } from '@jini-ai/core/contracts/runtime';
2
+ /**
3
+ * Persist one server's MCP grant for agy, which has no run-scoped settings override.
4
+ * Holds the host's lock and writes through the host's atomic writer, which also keeps the first
5
+ * existing file as a backup (lock, then backup, then write; the lock is released on every path).
6
+ * Invalid settings and I/O failures reject before spawn rather than widening permissions.
7
+ * @complexity O(settings bytes), including the allow-list scan; bounded by the settings file.
8
+ */
9
+ export declare function ensureAntigravityMcpPermission({ settingsPath, serverName, fileLock, writer }: {
10
+ settingsPath: string;
11
+ serverName: string;
12
+ fileLock: FileLockPort;
13
+ writer: AtomicFileWriterPort;
14
+ }, _options?: Record<string, never>): Promise<void>;
15
+ /** Prepare this CLI's persistent MCP permission before an env-passthrough launch. */
16
+ export declare function prepareAntigravityBridge({ delivery, serverName, fileLock, writer }: {
17
+ delivery: {
18
+ readonly kind: string;
19
+ } | null;
20
+ serverName: string;
21
+ fileLock: FileLockPort;
22
+ writer: AtomicFileWriterPort;
23
+ }, { ensurePermission }: {
24
+ ensurePermission: typeof ensureAntigravityMcpPermission;
25
+ }): Promise<void>;
26
+ //# sourceMappingURL=permissions.d.ts.map