toolsplice-core 0.0.1 → 0.0.2
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/README.md +26 -17
- package/dist/abortable.d.ts +6 -0
- package/dist/abortable.js +50 -0
- package/dist/adaptive-read.d.ts +50 -0
- package/dist/adaptive-read.js +780 -0
- package/dist/answer-wait.d.ts +7 -0
- package/dist/answer-wait.js +45 -0
- package/dist/cache-reads.d.ts +18 -0
- package/dist/cache-reads.js +89 -0
- package/dist/calibration-ledger.d.ts +37 -0
- package/dist/calibration-ledger.js +148 -0
- package/dist/calibration-marker.d.ts +4 -0
- package/dist/calibration-marker.js +77 -0
- package/dist/catalog-setup.d.ts +33 -0
- package/dist/catalog-setup.js +89 -0
- package/dist/catalog.d.ts +10 -0
- package/dist/catalog.js +42 -0
- package/dist/checkpoint-files.d.ts +15 -0
- package/dist/checkpoint-files.js +99 -0
- package/dist/coalesce-reads.d.ts +6 -0
- package/dist/coalesce-reads.js +33 -0
- package/dist/contract-caller.d.ts +2 -1
- package/dist/contract-caller.js +35 -16
- package/dist/contract-schema.d.ts +3 -1
- package/dist/contract-schema.js +34 -4
- package/dist/contracts.d.ts +1 -0
- package/dist/contracts.js +5 -1
- package/dist/core.d.ts +31 -1
- package/dist/core.js +27 -0
- package/dist/db-final-answer.d.ts +9 -0
- package/dist/db-final-answer.js +62 -0
- package/dist/define.d.ts +78 -0
- package/dist/define.js +14 -0
- package/dist/final-answer-stores.d.ts +71 -0
- package/dist/final-answer-stores.js +72 -0
- package/dist/final-answer.d.ts +32 -0
- package/dist/final-answer.js +104 -0
- package/dist/impact.d.ts +48 -0
- package/dist/impact.js +71 -0
- package/dist/local-tool.d.ts +18 -0
- package/dist/local-tool.js +32 -0
- package/dist/mcp-apps.d.ts +53 -0
- package/dist/mcp-apps.js +32 -0
- package/dist/mcp-event-delivery.d.ts +98 -0
- package/dist/mcp-event-delivery.js +211 -0
- package/dist/mcp-extensions.d.ts +46 -0
- package/dist/mcp-extensions.js +200 -0
- package/dist/mcp-peer.d.ts +45 -0
- package/dist/mcp-peer.js +207 -0
- package/dist/mcp-server-card.d.ts +21 -0
- package/dist/mcp-server-card.js +54 -0
- package/dist/page-checkpoint.d.ts +71 -0
- package/dist/page-checkpoint.js +286 -0
- package/dist/page-read-gate.d.ts +15 -0
- package/dist/page-read-gate.js +48 -0
- package/dist/pattern.d.ts +1 -0
- package/dist/pattern.js +27 -5
- package/dist/read-pages.d.ts +25 -0
- package/dist/read-pages.js +85 -0
- package/dist/read-policy.d.ts +6 -0
- package/dist/read-policy.js +16 -0
- package/dist/read-steps.d.ts +12 -0
- package/dist/read-steps.js +36 -0
- package/dist/result-session.d.ts +109 -0
- package/dist/result-session.js +620 -0
- package/dist/route-checkpoint.d.ts +3 -0
- package/dist/route-checkpoint.js +80 -0
- package/dist/route-evaluation.d.ts +141 -0
- package/dist/route-evaluation.js +329 -0
- package/dist/row-groups.d.ts +17 -0
- package/dist/row-groups.js +79 -0
- package/dist/row-query.d.ts +62 -0
- package/dist/row-query.js +172 -0
- package/dist/rules.d.ts +30 -0
- package/dist/rules.js +72 -0
- package/dist/run-diagnostics.d.ts +75 -0
- package/dist/run-diagnostics.js +212 -0
- package/dist/search-fetch.d.ts +50 -0
- package/dist/search-fetch.js +264 -0
- package/dist/skill-files.d.ts +9 -0
- package/dist/skill-files.js +49 -0
- package/dist/splice-diagnostics.d.ts +4 -0
- package/dist/splice-diagnostics.js +24 -16
- package/dist/splice-recording.d.ts +29 -2
- package/dist/splice-recording.js +22 -5
- package/dist/splice.d.ts +98 -1
- package/dist/splice.js +225 -27
- package/dist/sqlite-checkpoint-store.d.ts +5 -0
- package/dist/sqlite-checkpoint-store.js +91 -0
- package/dist/sqlite-checkpoint-worker.js +115 -0
- package/dist/test-difference.d.ts +13 -0
- package/dist/test-difference.js +42 -0
- package/dist/testing.d.ts +122 -0
- package/dist/testing.js +261 -0
- package/dist/text-pages.d.ts +24 -0
- package/dist/text-pages.js +36 -0
- package/dist/tool-discovery.d.ts +59 -0
- package/dist/tool-discovery.js +136 -0
- package/dist/unevaluated.d.ts +7 -0
- package/dist/unevaluated.js +156 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/workflow-json.js +1 -1
- package/integrations/ai.d.mts +36 -0
- package/integrations/ai.mjs +178 -0
- package/integrations/call-options.mjs +9 -0
- package/integrations/langchain.d.mts +31 -0
- package/integrations/langchain.mjs +114 -0
- package/integrations/managed.mjs +154 -0
- package/integrations/types.d.mts +13 -0
- package/package.json +30 -1
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { setTimeout as wait } from "node:timers/promises";
|
|
2
|
+
import { abortable } from "./abortable.js";
|
|
3
|
+
import { RetryablePageError } from "./read-pages.js";
|
|
4
|
+
/** One in-process upstream queue. Share the instance across idempotent readers. */
|
|
5
|
+
export class PageReadGate {
|
|
6
|
+
tail = Promise.resolve();
|
|
7
|
+
nextStart = 0;
|
|
8
|
+
minIntervalMs;
|
|
9
|
+
maxCooldownMs;
|
|
10
|
+
constructor({ minIntervalMs, maxCooldownMs = 60000 }) {
|
|
11
|
+
for (const n of [minIntervalMs, maxCooldownMs]) {
|
|
12
|
+
if (!Number.isSafeInteger(n) || n < 0 || n > 60000)
|
|
13
|
+
throw new RangeError("Page read gate durations must be integers from 0 through 60000 ms.");
|
|
14
|
+
}
|
|
15
|
+
this.minIntervalMs = minIntervalMs;
|
|
16
|
+
this.maxCooldownMs = maxCooldownMs;
|
|
17
|
+
}
|
|
18
|
+
async read(read, signal) {
|
|
19
|
+
signal?.throwIfAborted();
|
|
20
|
+
if (typeof read !== "function")
|
|
21
|
+
throw new TypeError("Expected a page read callback.");
|
|
22
|
+
// Every queued turn waits on its predecessor even if its caller has cancelled.
|
|
23
|
+
const work = this.tail.then(async () => {
|
|
24
|
+
signal?.throwIfAborted();
|
|
25
|
+
const now = performance.now();
|
|
26
|
+
const delay = Math.max(0, Math.ceil(this.nextStart - now));
|
|
27
|
+
if (delay > this.maxCooldownMs)
|
|
28
|
+
throw new RetryablePageError("Page read cooldown exceeds the configured limit.", Math.min(Number.MAX_SAFE_INTEGER, delay));
|
|
29
|
+
if (delay)
|
|
30
|
+
await wait(delay, undefined, { signal });
|
|
31
|
+
signal?.throwIfAborted();
|
|
32
|
+
this.nextStart = performance.now() + this.minIntervalMs;
|
|
33
|
+
try {
|
|
34
|
+
return await read();
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
if (error instanceof RetryablePageError &&
|
|
38
|
+
error.retryAfterMs !== undefined) {
|
|
39
|
+
this.nextStart = Math.max(this.nextStart, performance.now() + error.retryAfterMs);
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.tail = work.then(() => undefined, () => undefined);
|
|
45
|
+
// Cancelling a caller stops waiting immediately. An in-flight callback still owns the slot.
|
|
46
|
+
return abortable(() => work, signal);
|
|
47
|
+
}
|
|
48
|
+
}
|
package/dist/pattern.d.ts
CHANGED
package/dist/pattern.js
CHANGED
|
@@ -1,7 +1,27 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
// semantics (dot, negated/Unicode classes, shorthand whitespace, lookaround, backrefs).
|
|
1
|
+
// The portable subset is checked when a provider schema is loaded. The same
|
|
2
|
+
// engine also compiles Ajv's own meta-schema patterns, which use a wider grammar.
|
|
4
3
|
import { RE2JS } from "re2js";
|
|
4
|
+
// ECMA-262 WhiteSpace and LineTerminator code points. RE2's native \s is ASCII.
|
|
5
|
+
const whitespace = String.raw `[\x09-\x0D\x20\xA0\x{1680}\x{2000}-\x{200A}\x{2028}\x{2029}\x{202F}\x{205F}\x{3000}\x{FEFF}]`;
|
|
6
|
+
export function compileEnginePattern(pattern) {
|
|
7
|
+
let translated = "";
|
|
8
|
+
let inClass = false;
|
|
9
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
10
|
+
const c = pattern[i];
|
|
11
|
+
if (c === "\\" && i + 1 < pattern.length) {
|
|
12
|
+
const escaped = pattern[++i];
|
|
13
|
+
translated += escaped === "s" && !inClass ? whitespace : c + escaped;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (c === "[")
|
|
17
|
+
inClass = true;
|
|
18
|
+
if (c === "]")
|
|
19
|
+
inClass = false;
|
|
20
|
+
translated += c;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return RE2JS.compile(translated);
|
|
24
|
+
}
|
|
5
25
|
export function compilePattern(pattern) {
|
|
6
26
|
if (pattern.length > 1024)
|
|
7
27
|
throw new Error("pattern limit");
|
|
@@ -12,6 +32,8 @@ export function compilePattern(pattern) {
|
|
|
12
32
|
throw new Error("non-ASCII pattern");
|
|
13
33
|
if (c === "\\") {
|
|
14
34
|
const n = pattern[++i];
|
|
35
|
+
if (n === "s" && !inClass)
|
|
36
|
+
continue;
|
|
15
37
|
if (!n || !"dwnrtf\\^$.*+?()[]{}|/-".includes(n))
|
|
16
38
|
throw new Error("unsupported escape");
|
|
17
39
|
continue;
|
|
@@ -26,7 +48,7 @@ export function compilePattern(pattern) {
|
|
|
26
48
|
else if (c === "." && !inClass)
|
|
27
49
|
throw new Error("unsupported wildcard");
|
|
28
50
|
}
|
|
29
|
-
// Syntax only
|
|
51
|
+
// Syntax only. Native regexes never execute against contract values.
|
|
30
52
|
new RegExp(pattern, "u");
|
|
31
|
-
return
|
|
53
|
+
return compileEnginePattern(pattern);
|
|
32
54
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/** Mark a transient error only when repeating the same read is safe. */
|
|
2
|
+
export declare class RetryablePageError extends Error {
|
|
3
|
+
readonly retryAfterMs?: number | undefined;
|
|
4
|
+
constructor(message: string, retryAfterMs?: number | undefined);
|
|
5
|
+
}
|
|
6
|
+
export interface PageReadOptions {
|
|
7
|
+
/** Attempts per cursor, including the first. Defaults to 1 for ordinary reads and 3 with a checkpoint. Maximum 5. */
|
|
8
|
+
maxReadAttempts?: number;
|
|
9
|
+
/** Cumulative retry delay in milliseconds. Defaults to 5,000 for ordinary reads and 60,000 with a checkpoint. */
|
|
10
|
+
maxRetryWaitMs?: number;
|
|
11
|
+
/** Maximum number of logical pages, including the first. Default 32. */
|
|
12
|
+
maxPages?: number;
|
|
13
|
+
/** Maximum total UTF-8 bytes across all pages. Default 5 MiB. */
|
|
14
|
+
maxBytes?: number;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
}
|
|
17
|
+
export declare function pageLimits(options: PageReadOptions): {
|
|
18
|
+
maxPages: number;
|
|
19
|
+
maxBytes: number;
|
|
20
|
+
};
|
|
21
|
+
export declare function utf8Bytes(text: string): number;
|
|
22
|
+
/** The consumer validates the page body before the next cursor is followed. */
|
|
23
|
+
export declare function readPages<Page extends {
|
|
24
|
+
nextCursor?: string | null;
|
|
25
|
+
}>(read: (cursor: string | undefined, signal?: AbortSignal) => Page | PromiseLike<Page>, maxPages: number, { signal, maxReadAttempts, maxRetryWaitMs }: PageReadOptions): AsyncGenerator<Page, void, unknown>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { setTimeout as wait } from "node:timers/promises";
|
|
2
|
+
import { abortable } from "./abortable.js";
|
|
3
|
+
import { JSON_LIMIT } from "./workflow-json.js";
|
|
4
|
+
/** Mark a transient error only when repeating the same read is safe. */
|
|
5
|
+
export class RetryablePageError extends Error {
|
|
6
|
+
retryAfterMs;
|
|
7
|
+
constructor(message, retryAfterMs) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.retryAfterMs = retryAfterMs;
|
|
10
|
+
this.name = "RetryablePageError";
|
|
11
|
+
if (retryAfterMs !== undefined &&
|
|
12
|
+
(!Number.isSafeInteger(retryAfterMs) || retryAfterMs < 0))
|
|
13
|
+
throw new RangeError("retryAfterMs must be a nonnegative integer.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export function pageLimits(options) {
|
|
17
|
+
const maxPages = options.maxPages ?? 32, maxBytes = options.maxBytes ?? JSON_LIMIT;
|
|
18
|
+
for (const [n, max, label] of [
|
|
19
|
+
[maxPages, 1000, "maxPages"],
|
|
20
|
+
[maxBytes, 64 * 1024 * 1024, "maxBytes"],
|
|
21
|
+
]) {
|
|
22
|
+
if (!Number.isSafeInteger(n) || n < 1 || n > max)
|
|
23
|
+
throw new RangeError(`${label} must be an integer from 1 through ${max}.`);
|
|
24
|
+
}
|
|
25
|
+
return { maxPages, maxBytes };
|
|
26
|
+
}
|
|
27
|
+
export function utf8Bytes(text) {
|
|
28
|
+
if (/[\uD800-\uDFFF]/u.test(text))
|
|
29
|
+
throw new Error("Invalid UTF-8 page or cursor.");
|
|
30
|
+
return Buffer.byteLength(text);
|
|
31
|
+
}
|
|
32
|
+
/** The consumer validates the page body before the next cursor is followed. */
|
|
33
|
+
export async function* readPages(read, maxPages, { signal, maxReadAttempts = 1, maxRetryWaitMs = 5000 }) {
|
|
34
|
+
if (!Number.isSafeInteger(maxReadAttempts) ||
|
|
35
|
+
maxReadAttempts < 1 ||
|
|
36
|
+
maxReadAttempts > 5)
|
|
37
|
+
throw new RangeError("maxReadAttempts must be an integer from 1 through 5.");
|
|
38
|
+
if (!Number.isSafeInteger(maxRetryWaitMs) ||
|
|
39
|
+
maxRetryWaitMs < 0 ||
|
|
40
|
+
maxRetryWaitMs > 60000)
|
|
41
|
+
throw new RangeError("maxRetryWaitMs must be an integer from 0 through 60000.");
|
|
42
|
+
let remainingWait = maxRetryWaitMs;
|
|
43
|
+
async function readCursor(cursor) {
|
|
44
|
+
for (let attempt = 1;; attempt++) {
|
|
45
|
+
try {
|
|
46
|
+
return await abortable(() => read(cursor, signal), signal);
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
signal?.throwIfAborted();
|
|
50
|
+
if (!(error instanceof RetryablePageError) ||
|
|
51
|
+
attempt >= maxReadAttempts)
|
|
52
|
+
throw error;
|
|
53
|
+
const backoff = 100 * 2 ** (attempt - 1);
|
|
54
|
+
const delay = Math.max(error.retryAfterMs ?? 0, Math.floor(backoff * (1 + Math.random())));
|
|
55
|
+
if (delay > remainingWait)
|
|
56
|
+
throw error;
|
|
57
|
+
remainingWait -= delay;
|
|
58
|
+
try {
|
|
59
|
+
await wait(delay, undefined, { signal });
|
|
60
|
+
}
|
|
61
|
+
catch (reason) {
|
|
62
|
+
signal?.throwIfAborted();
|
|
63
|
+
throw reason;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const seen = new Set();
|
|
69
|
+
let cursor;
|
|
70
|
+
for (let i = 0; i < maxPages; i++) {
|
|
71
|
+
const page = await readCursor(cursor);
|
|
72
|
+
signal?.throwIfAborted();
|
|
73
|
+
yield page;
|
|
74
|
+
const next = page.nextCursor;
|
|
75
|
+
if (next === null || next === undefined)
|
|
76
|
+
return;
|
|
77
|
+
if (typeof next !== "string" || utf8Bytes(next) > 4096)
|
|
78
|
+
throw new Error("Invalid page cursor.");
|
|
79
|
+
if (seen.has(next))
|
|
80
|
+
throw new Error("Upstream repeated a page cursor.");
|
|
81
|
+
seen.add(next);
|
|
82
|
+
cursor = next;
|
|
83
|
+
}
|
|
84
|
+
throw new RangeError("Read exceeded the page limit.");
|
|
85
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Portable execution settings for independent, ordered read waves. */
|
|
2
|
+
export function parseReadPolicy(value) {
|
|
3
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
4
|
+
throw new Error("Invalid recorded read policy.");
|
|
5
|
+
const policy = value;
|
|
6
|
+
if (Object.keys(policy).length !== 2 ||
|
|
7
|
+
!Number.isInteger(policy.concurrency) ||
|
|
8
|
+
Number(policy.concurrency) < 1 ||
|
|
9
|
+
Number(policy.concurrency) > 16 ||
|
|
10
|
+
typeof policy.assumeReadOnly !== "boolean")
|
|
11
|
+
throw new Error("Invalid recorded read policy.");
|
|
12
|
+
return {
|
|
13
|
+
concurrency: Number(policy.concurrency),
|
|
14
|
+
assumeReadOnly: policy.assumeReadOnly,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type FinalAnswerOptions, type DatabaseFinalAnswerOptions } from "./final-answer.js";
|
|
2
|
+
type Storage = {
|
|
3
|
+
directory: string;
|
|
4
|
+
store?: never;
|
|
5
|
+
} | Pick<DatabaseFinalAnswerOptions, "store" | "directory">;
|
|
6
|
+
/** Re-enter an application workflow after a crash. Only successful named reads are reused. */
|
|
7
|
+
export declare function readSteps(options: Storage & Pick<FinalAnswerOptions, "jobId" | "context">): {
|
|
8
|
+
read<I, T>(name: string, input: I, schema: Record<string, unknown>, work: (input: I) => T | PromiseLike<T>, wait?: {
|
|
9
|
+
waitMs?: number;
|
|
10
|
+
}): Promise<T>;
|
|
11
|
+
};
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { finalAnswerCheckpoint, } from "./final-answer.js";
|
|
2
|
+
import { copyJson, jsonFingerprint } from "./workflow-json.js";
|
|
3
|
+
/** Re-enter an application workflow after a crash. Only successful named reads are reused. */
|
|
4
|
+
export function readSteps(options) {
|
|
5
|
+
const { jobId } = options;
|
|
6
|
+
const context = copyJson(options.context);
|
|
7
|
+
if (typeof jobId !== "string" ||
|
|
8
|
+
!jobId ||
|
|
9
|
+
!context ||
|
|
10
|
+
typeof context !== "object" ||
|
|
11
|
+
Array.isArray(context))
|
|
12
|
+
throw new TypeError("Expected a nonempty job ID and workflow context.");
|
|
13
|
+
if ((options.directory !== undefined) === (options.store !== undefined))
|
|
14
|
+
throw new Error("Choose one checkpoint directory or store.");
|
|
15
|
+
const directory = options.directory, store = options.store;
|
|
16
|
+
return {
|
|
17
|
+
async read(name, input, schema, work, wait) {
|
|
18
|
+
if (typeof name !== "string" ||
|
|
19
|
+
!name.trim() ||
|
|
20
|
+
typeof work !== "function")
|
|
21
|
+
throw new TypeError("Expected a named read and callback.");
|
|
22
|
+
const args = copyJson(input);
|
|
23
|
+
const identity = {
|
|
24
|
+
jobId: "toolsplice:read-step:v1:" + jsonFingerprint([jobId, name]),
|
|
25
|
+
context: { workflow: context, step: name, input: args },
|
|
26
|
+
schema,
|
|
27
|
+
};
|
|
28
|
+
if (store)
|
|
29
|
+
return finalAnswerCheckpoint({ ...identity, store }).run(async (save) => save(await work(args)), wait);
|
|
30
|
+
return finalAnswerCheckpoint({
|
|
31
|
+
...identity,
|
|
32
|
+
directory: directory,
|
|
33
|
+
}).run(async (save) => save(await work(args)), wait);
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { SpliceRunOptions } from "./splice.js";
|
|
2
|
+
import { type LocalToolDefinition } from "./local-tool.js";
|
|
3
|
+
import { type ToolCaller } from "./execution.js";
|
|
4
|
+
export interface ResultTool {
|
|
5
|
+
definition: LocalToolDefinition;
|
|
6
|
+
execute(args: Record<string, unknown>, options?: SpliceRunOptions): Promise<unknown>;
|
|
7
|
+
}
|
|
8
|
+
/** Adapt already-authorized MCP definitions and their connected caller once. */
|
|
9
|
+
export declare function resultToolsFromMcp(catalog: {
|
|
10
|
+
tools: readonly LocalToolDefinition[];
|
|
11
|
+
}, caller: ToolCaller): ResultTool[];
|
|
12
|
+
/** Present a successful tool read using application-defined fields and its actual arguments. */
|
|
13
|
+
export declare function projectTool<Value, Output>(source: {
|
|
14
|
+
definition: LocalToolDefinition;
|
|
15
|
+
execute(args: Record<string, unknown>, options?: SpliceRunOptions): Promise<Value>;
|
|
16
|
+
}, project: (value: Value, args: Readonly<Record<string, unknown>>) => Output | PromiseLike<Output>, options?: {
|
|
17
|
+
description?: string;
|
|
18
|
+
outputSchema?: Record<string, unknown>;
|
|
19
|
+
}): {
|
|
20
|
+
definition: LocalToolDefinition;
|
|
21
|
+
execute(args: Record<string, unknown>, runOptions?: SpliceRunOptions): Promise<Output>;
|
|
22
|
+
};
|
|
23
|
+
export interface ResultSelection {
|
|
24
|
+
ref: string;
|
|
25
|
+
path?: string;
|
|
26
|
+
offset?: number;
|
|
27
|
+
limit?: number;
|
|
28
|
+
fields?: string[];
|
|
29
|
+
keys?: boolean;
|
|
30
|
+
contains?: string;
|
|
31
|
+
countMatches?: string;
|
|
32
|
+
where?: {
|
|
33
|
+
field: string;
|
|
34
|
+
equals: string | number | boolean | null;
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export interface ResultForwardRequest {
|
|
38
|
+
sourceTool: string | null;
|
|
39
|
+
tool: string;
|
|
40
|
+
argument: string;
|
|
41
|
+
path: string;
|
|
42
|
+
arguments: Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
export interface ResultToolOptions {
|
|
45
|
+
/** Route by actual result size, using this run’s question to select a bounded view. */
|
|
46
|
+
adaptiveRead?: string;
|
|
47
|
+
/** Add an optional local select argument to these read tools. */
|
|
48
|
+
selectOnRead?: readonly string[];
|
|
49
|
+
forwardTo?: Readonly<Record<string, readonly string[]>>;
|
|
50
|
+
authorizeForward?: (request: ResultForwardRequest) => boolean | Promise<boolean>;
|
|
51
|
+
}
|
|
52
|
+
export interface ResultSessionOptions {
|
|
53
|
+
inlineBytes?: number;
|
|
54
|
+
/** Maximum native result size when an adaptive view has no question-specific evidence. */
|
|
55
|
+
adaptiveFallbackBytes?: number;
|
|
56
|
+
/** Return the native value when an adaptive view would exceed run retention limits. */
|
|
57
|
+
nativeOnCapacity?: boolean;
|
|
58
|
+
maxBytes?: number;
|
|
59
|
+
maxEntries?: number;
|
|
60
|
+
}
|
|
61
|
+
/** One instance per agent run. Retain large captures and values requested by first-read selection. */
|
|
62
|
+
export declare class ResultSession {
|
|
63
|
+
#private;
|
|
64
|
+
constructor(options?: ResultSessionOptions);
|
|
65
|
+
get hasRetainedResults(): boolean;
|
|
66
|
+
capture(input: unknown): {
|
|
67
|
+
value: unknown;
|
|
68
|
+
ref?: undefined;
|
|
69
|
+
bytes?: undefined;
|
|
70
|
+
type?: undefined;
|
|
71
|
+
preview?: undefined;
|
|
72
|
+
} | {
|
|
73
|
+
readonly value?: undefined;
|
|
74
|
+
ref: string;
|
|
75
|
+
partial: boolean;
|
|
76
|
+
selection: unknown;
|
|
77
|
+
headingEvidence?: string | undefined;
|
|
78
|
+
bytes?: undefined;
|
|
79
|
+
type?: undefined;
|
|
80
|
+
preview?: undefined;
|
|
81
|
+
} | {
|
|
82
|
+
readonly value?: undefined;
|
|
83
|
+
ref: string;
|
|
84
|
+
bytes?: undefined;
|
|
85
|
+
type?: undefined;
|
|
86
|
+
preview?: undefined;
|
|
87
|
+
} | {
|
|
88
|
+
readonly value?: undefined;
|
|
89
|
+
ref: string;
|
|
90
|
+
bytes: number;
|
|
91
|
+
type: string;
|
|
92
|
+
preview: unknown;
|
|
93
|
+
};
|
|
94
|
+
/** Capture the model-visible output of a native framework tool in this run. */
|
|
95
|
+
adaptivePresenter(question: string): (name: string, args: Record<string, unknown>) => (value: unknown) => unknown;
|
|
96
|
+
/** Read once, retain the original and return only the requested view. */
|
|
97
|
+
readAndSelect(tool: ResultTool, args: Record<string, unknown>, selection: Omit<ResultSelection, "ref">, options?: SpliceRunOptions): Promise<{
|
|
98
|
+
ref: string;
|
|
99
|
+
} & Record<string, unknown>>;
|
|
100
|
+
resolve(ref: string, path?: string): unknown;
|
|
101
|
+
close(): void;
|
|
102
|
+
inspect(selection: ResultSelection): Record<string, unknown>;
|
|
103
|
+
/** Select the tools to advertise on the next model turn in hosts with dynamic catalogs. */
|
|
104
|
+
availableTools<T extends ResultTool>(tools: readonly T[], { remainingTurns }?: {
|
|
105
|
+
remainingTurns?: number;
|
|
106
|
+
}): T[];
|
|
107
|
+
/** Register input tools for capture. Only forwardTo destinations accept reference handoffs. */
|
|
108
|
+
tools(input: readonly ResultTool[], { forwardTo, authorizeForward, selectOnRead, adaptiveRead, }?: ResultToolOptions): ResultTool[];
|
|
109
|
+
}
|