@jini-ai/daemon 0.6.7 → 0.6.9
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 +8 -0
- package/dist/agent-executor/antigravity-permissions.d.ts +11 -0
- package/dist/agent-executor/antigravity-permissions.js +64 -0
- package/dist/agent-executor/contracts.d.ts +31 -6
- package/dist/agent-executor/event-translation.d.ts +6 -1
- package/dist/agent-executor/event-translation.js +1 -1
- package/dist/agent-executor/events.d.ts +1 -0
- package/dist/agent-executor/events.js +85 -74
- package/dist/agent-executor/launch.d.ts +4 -2
- package/dist/agent-executor/launch.js +306 -217
- package/dist/agent-executor/mcp-bridge-probe.js +51 -35
- package/dist/agent-executor/mcp-bridge.d.ts +18 -8
- package/dist/agent-executor/mcp-bridge.js +105 -65
- package/dist/agent-executor/run-output.d.ts +20 -0
- package/dist/agent-executor/run-output.js +80 -0
- package/dist/attachment-content.js +18 -15
- package/dist/core/read-only-tools.d.ts +26 -3
- package/dist/core/read-only-tools.js +38 -5
- package/dist/core/tool-audit.d.ts +3 -1
- package/dist/core/tool-audit.js +35 -22
- package/dist/core/tool-candidates.d.ts +8 -0
- package/dist/core/tool-candidates.js +6 -0
- package/dist/core/tool-gaps.d.ts +60 -0
- package/dist/core/tool-gaps.js +199 -0
- package/dist/delegated-tool-bridge.d.ts +1 -1
- package/dist/delegated-tool-bridge.js +161 -122
- package/dist/event-log.d.ts +45 -2
- package/dist/event-log.js +83 -4
- package/dist/http/attachments.d.ts +26 -1
- package/dist/http/attachments.js +129 -65
- package/dist/http/connectors.d.ts +1 -32
- package/dist/http/connectors.js +13 -68
- package/dist/http/delegated-tools.d.ts +5 -1
- package/dist/http/delegated-tools.js +29 -29
- package/dist/http/host-tools.d.ts +1 -0
- package/dist/http/host-tools.js +64 -59
- package/dist/http/index.d.ts +2 -2
- package/dist/http/index.js +1 -1
- package/dist/http/media.js +48 -69
- package/dist/http/memory.js +45 -36
- package/dist/http/model-proxy-fields.d.ts +23 -0
- package/dist/http/model-proxy-fields.js +29 -0
- package/dist/http/model-proxy.js +193 -395
- package/dist/http/research-tavily.adapter.js +72 -49
- package/dist/http/research.js +33 -23
- package/dist/http/resource-request.d.ts +37 -0
- package/dist/http/resource-request.js +59 -0
- package/dist/http/routines.js +49 -90
- package/dist/http/runs.d.ts +7 -5
- package/dist/http/runs.js +21 -7
- package/dist/http/terminals.js +23 -48
- package/dist/http/tool-catalog.d.ts +5 -0
- package/dist/http/xai.d.ts +11 -1
- package/dist/http/xai.js +125 -124
- package/dist/legacy-data-migration.js +41 -24
- package/dist/run/core/retry.js +51 -35
- package/dist/run/diagnostics/diagnostics.js +5 -17
- package/dist/run-credentials.js +49 -27
- package/dist/run-lifecycle.d.ts +12 -2
- package/dist/run-lifecycle.js +47 -26
- package/dist/store/agent-sessions/sqlite.d.ts +6 -0
- package/dist/store/agent-sessions/sqlite.js +6 -4
- package/dist/surface-exchanges.js +2 -1
- package/dist/terminal-session.d.ts +1 -1
- package/dist/terminal-session.js +26 -33
- package/dist/tool-audit.d.ts +1 -0
- package/dist/tool-audit.js +1 -0
- package/dist/tool-executor.d.ts +24 -3
- package/dist/tool-executor.js +277 -139
- package/dist/tool-recovery/recovery.js +64 -35
- package/dist/tool-recovery/stack.d.ts +2 -1
- package/dist/tool-recovery/stack.js +1 -1
- package/package.json +10 -10
package/dist/terminal-session.js
CHANGED
|
@@ -115,6 +115,10 @@ function toSessionInfo(session, resourceRef) {
|
|
|
115
115
|
signal: session.signal,
|
|
116
116
|
};
|
|
117
117
|
}
|
|
118
|
+
/** Drop undefined-valued keys so an omitted option never overrides the engine's own default. */
|
|
119
|
+
function definedOnly(value) {
|
|
120
|
+
return Object.fromEntries(Object.entries(value).filter(([, entry]) => entry !== undefined));
|
|
121
|
+
}
|
|
118
122
|
/**
|
|
119
123
|
* Serializes calls made for the same `id` through a per-id promise chain
|
|
120
124
|
* (matching this codebase's `oauth-tokens.ts` `withLock` precedent), so a
|
|
@@ -141,18 +145,19 @@ async function runExclusive(locks, id, fn) {
|
|
|
141
145
|
* the kill/write/resize lock, and (via {@link createTerminalToolRegistrations})
|
|
142
146
|
* `ToolExecutor` gating for creation. See module doc for the full design.
|
|
143
147
|
*/
|
|
144
|
-
export function createTerminalSessionManager(
|
|
145
|
-
const options = { ...requiredArgs, ...optionalArgs };
|
|
148
|
+
export function createTerminalSessionManager(_requiredArgs, options = {}) {
|
|
146
149
|
const terminalService = options.terminalService ??
|
|
147
150
|
createTerminalService({
|
|
148
151
|
loadSpawnPty: options.loadSpawnPty ?? (() => loadRealSpawnPty({})),
|
|
149
|
-
...(
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
152
|
+
...definedOnly({
|
|
153
|
+
maxEvents: options.maxEvents,
|
|
154
|
+
maxBufferBytes: options.maxBufferBytes,
|
|
155
|
+
exitTailBytes: options.exitTailBytes,
|
|
156
|
+
flushIntervalMs: options.flushIntervalMs,
|
|
157
|
+
flushThresholdBytes: options.flushThresholdBytes,
|
|
158
|
+
ttlMs: options.ttlMs,
|
|
159
|
+
shutdownGraceMs: options.shutdownGraceMs,
|
|
160
|
+
}),
|
|
156
161
|
});
|
|
157
162
|
const metadata = new Map();
|
|
158
163
|
const locks = new Map();
|
|
@@ -181,9 +186,7 @@ export function createTerminalSessionManager(requiredArgs, optionalArgs = {}) {
|
|
|
181
186
|
async function create({ principal, options: createOptions }) {
|
|
182
187
|
const session = await terminalService.create({
|
|
183
188
|
cwd: createOptions.cwd,
|
|
184
|
-
...(
|
|
185
|
-
...(createOptions.rows !== undefined ? { rows: createOptions.rows } : {}),
|
|
186
|
-
...(createOptions.shell !== undefined ? { shell: createOptions.shell } : {}),
|
|
189
|
+
...definedOnly({ cols: createOptions.cols, rows: createOptions.rows, shell: createOptions.shell }),
|
|
187
190
|
});
|
|
188
191
|
const resourceRef = createOptions.resourceRef ?? null;
|
|
189
192
|
metadata.set(session.id, { principalId: principal.id, resourceRef, killed: false });
|
|
@@ -210,7 +213,8 @@ export function createTerminalSessionManager(requiredArgs, optionalArgs = {}) {
|
|
|
210
213
|
const session = terminalService.get(id);
|
|
211
214
|
return session ? toSessionInfo(session, resourceRef) : null;
|
|
212
215
|
}
|
|
213
|
-
|
|
216
|
+
/** Shared write/resize path: ownership check, then the per-session lock, then the killed flag. */
|
|
217
|
+
async function unlessKilled(principal, id, act) {
|
|
214
218
|
const found = checkOwnership(principal, id);
|
|
215
219
|
if (!found)
|
|
216
220
|
return { status: 'not-found' };
|
|
@@ -221,22 +225,15 @@ export function createTerminalSessionManager(requiredArgs, optionalArgs = {}) {
|
|
|
221
225
|
if (!meta || meta.killed) {
|
|
222
226
|
return { status: 'ok', ok: false, session: currentSnapshot(id, meta?.resourceRef ?? null) };
|
|
223
227
|
}
|
|
224
|
-
const ok =
|
|
228
|
+
const ok = act();
|
|
225
229
|
return { status: 'ok', ok, session: currentSnapshot(id, meta.resourceRef) };
|
|
226
230
|
});
|
|
227
231
|
}
|
|
232
|
+
async function write({ principal, id, input }) {
|
|
233
|
+
return unlessKilled(principal, id, () => terminalService.write(id, input));
|
|
234
|
+
}
|
|
228
235
|
async function resize({ principal, id, cols, rows }) {
|
|
229
|
-
|
|
230
|
-
if (!found)
|
|
231
|
-
return { status: 'not-found' };
|
|
232
|
-
return runExclusive(locks, id, () => {
|
|
233
|
-
const meta = metadata.get(id);
|
|
234
|
-
if (!meta || meta.killed) {
|
|
235
|
-
return { status: 'ok', ok: false, session: currentSnapshot(id, meta?.resourceRef ?? null) };
|
|
236
|
-
}
|
|
237
|
-
const ok = terminalService.resize(id, cols, rows);
|
|
238
|
-
return { status: 'ok', ok, session: currentSnapshot(id, meta.resourceRef) };
|
|
239
|
-
});
|
|
236
|
+
return unlessKilled(principal, id, () => terminalService.resize(id, cols, rows));
|
|
240
237
|
}
|
|
241
238
|
async function kill({ principal, id }, { signal } = {}) {
|
|
242
239
|
const found = checkOwnership(principal, id);
|
|
@@ -280,12 +277,9 @@ function isRecord(value) {
|
|
|
280
277
|
* precedent).
|
|
281
278
|
*/
|
|
282
279
|
export function createTerminalToolRegistrations(requiredArgs, optionalArgs = {}) {
|
|
283
|
-
const
|
|
284
|
-
const {
|
|
285
|
-
const descriptorExtras = {
|
|
286
|
-
...(requiresConfirmation !== undefined ? { requiresConfirmation } : {}),
|
|
287
|
-
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
288
|
-
};
|
|
280
|
+
const { manager } = requiredArgs;
|
|
281
|
+
const { policy = denyAllTerminalCreatePolicy, requiresConfirmation, timeoutMs } = optionalArgs;
|
|
282
|
+
const descriptorExtras = definedOnly({ requiresConfirmation, timeoutMs });
|
|
289
283
|
return {
|
|
290
284
|
create: {
|
|
291
285
|
descriptor: {
|
|
@@ -307,8 +301,7 @@ export function createTerminalToolRegistrations(requiredArgs, optionalArgs = {})
|
|
|
307
301
|
return manager.create({ principal: ctx.principal, options: {
|
|
308
302
|
resourceRef,
|
|
309
303
|
cwd,
|
|
310
|
-
...(
|
|
311
|
-
...(rows !== undefined ? { rows } : {}),
|
|
304
|
+
...definedOnly({ cols, rows }),
|
|
312
305
|
shell,
|
|
313
306
|
} });
|
|
314
307
|
},
|
package/dist/tool-audit.d.ts
CHANGED
package/dist/tool-audit.js
CHANGED
package/dist/tool-executor.d.ts
CHANGED
|
@@ -70,6 +70,8 @@ export type ToolExecutionStatus = 'completed' | 'denied' | 'confirmation-denied'
|
|
|
70
70
|
*/
|
|
71
71
|
export type ToolExecutionErrorKind = 'validation' | 'internal';
|
|
72
72
|
export interface ToolExecutionResult {
|
|
73
|
+
/** Value-free rewrites, retained even when output text is truncated. */
|
|
74
|
+
readonly normalizationNotes?: readonly string[];
|
|
73
75
|
readonly executionId: string;
|
|
74
76
|
readonly status: ToolExecutionStatus;
|
|
75
77
|
readonly output?: unknown;
|
|
@@ -99,7 +101,7 @@ export interface ToolExecutor {
|
|
|
99
101
|
readonly executionId: string;
|
|
100
102
|
readonly decision: ConfirmationDecision;
|
|
101
103
|
}): void;
|
|
102
|
-
/**
|
|
104
|
+
/** Cancels an in-flight execution, unblocking a still-pending confirmation. No-op if `executionId` is already terminal or unknown. */
|
|
103
105
|
cancel(args: {
|
|
104
106
|
readonly executionId: string;
|
|
105
107
|
}): void;
|
|
@@ -107,12 +109,30 @@ export interface ToolExecutor {
|
|
|
107
109
|
readonly executionId: string;
|
|
108
110
|
}): ToolExecutionAuditRecord | null;
|
|
109
111
|
}
|
|
112
|
+
/** Advisory preparation after authorization/confirmation, before the handler. A failure is fail-open. */
|
|
113
|
+
export type PrepareToolGuidance = (required: {
|
|
114
|
+
principal: Principal;
|
|
115
|
+
run: RunRef;
|
|
116
|
+
tool: ToolDescriptor;
|
|
117
|
+
signal: AbortSignal;
|
|
118
|
+
emitSurface?: SurfaceEmitter;
|
|
119
|
+
}, optional?: Record<string, never>) => Promise<string>;
|
|
110
120
|
export interface CreateToolExecutorOptions {
|
|
121
|
+
readonly prepareGuidance?: PrepareToolGuidance;
|
|
111
122
|
readonly registry: ToolRegistry;
|
|
112
123
|
readonly delegate?: ExecutionDelegate;
|
|
113
124
|
/** Injectable clock for audit timestamps — defaults to `Date.now`. Test-only hook. */
|
|
114
125
|
readonly now?: () => number;
|
|
126
|
+
/** Cap on retained finished audit records, oldest evicted first. See {@link DEFAULT_MAX_AUDIT_RECORDS}. */
|
|
127
|
+
readonly maxAuditRecords?: number;
|
|
115
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Default cap on finished audit records kept for `getAuditRecord`. One record is added per tool
|
|
131
|
+
* execution and nothing else ever removed one, so a long-lived daemon grew the map for its whole
|
|
132
|
+
* uptime (memory investigation 2026-10-21). An in-flight execution's record is never evicted: its
|
|
133
|
+
* later transitions still have to land on it.
|
|
134
|
+
*/
|
|
135
|
+
export declare const DEFAULT_MAX_AUDIT_RECORDS = 1000;
|
|
116
136
|
/**
|
|
117
137
|
* Creates the `ToolExecutor` reference implementation: an in-process,
|
|
118
138
|
* in-memory gate over a `ToolRegistry`. No persistence — a real host that
|
|
@@ -125,8 +145,9 @@ export interface CreateToolExecutorOptions {
|
|
|
125
145
|
* — the one and only caller of that internal export.
|
|
126
146
|
* @param options.delegate - Transport-supplied authorize/confirm UI seam;
|
|
127
147
|
* omit for a headless caller whose tools never need interactive gating.
|
|
128
|
-
* @
|
|
148
|
+
* @param options.maxAuditRecords - Finished audit records kept, see {@link DEFAULT_MAX_AUDIT_RECORDS}.
|
|
149
|
+
* @complexity Known-id `execute` adds schema-guided normalization to the handler's cost; unknown ids scan O(n) descriptors for hints. `resumeConfirmation`/`cancel`/`getAuditRecord` are O(1) map lookups.
|
|
129
150
|
* @overallScore 100/100
|
|
130
151
|
*/
|
|
131
|
-
export declare function createToolExecutor(requiredArgs: Pick<CreateToolExecutorOptions, "registry">, optionalArgs?: Pick<CreateToolExecutorOptions, "delegate" | "now">): ToolExecutor;
|
|
152
|
+
export declare function createToolExecutor(requiredArgs: Pick<CreateToolExecutorOptions, "registry">, optionalArgs?: Pick<CreateToolExecutorOptions, "delegate" | "now" | "prepareGuidance" | "maxAuditRecords">): ToolExecutor;
|
|
132
153
|
//# sourceMappingURL=tool-executor.d.ts.map
|