toolsplice 0.0.0-stage → 0.0.1
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/LICENSE +21 -0
- package/README.md +372 -2
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +923 -0
- package/dist/codegen.d.ts +44 -0
- package/dist/codegen.js +479 -0
- package/dist/contract-caller.d.ts +22 -0
- package/dist/contract-caller.js +307 -0
- package/dist/contract-corrections.d.ts +35 -0
- package/dist/contract-corrections.js +159 -0
- package/dist/contract-schema.d.ts +5 -0
- package/dist/contract-schema.js +126 -0
- package/dist/contracts.d.ts +71 -0
- package/dist/contracts.js +366 -0
- package/dist/core.d.ts +14 -0
- package/dist/core.js +16 -0
- package/dist/doctor.d.ts +22 -0
- package/dist/doctor.js +91 -0
- package/dist/drift.d.ts +23 -0
- package/dist/drift.js +111 -0
- package/dist/execution.d.ts +38 -0
- package/dist/execution.js +66 -0
- package/dist/extract.d.ts +34 -0
- package/dist/extract.js +73 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +19 -0
- package/dist/ordered-transport.d.ts +12 -0
- package/dist/ordered-transport.js +106 -0
- package/dist/pattern.d.ts +2 -0
- package/dist/pattern.js +32 -0
- package/dist/postgres.d.ts +41 -0
- package/dist/postgres.js +264 -0
- package/dist/probe.d.ts +29 -0
- package/dist/probe.js +134 -0
- package/dist/proxy.d.ts +40 -0
- package/dist/proxy.js +436 -0
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.js +26 -0
- package/dist/schema.d.ts +17 -0
- package/dist/schema.js +299 -0
- package/dist/shape.d.ts +91 -0
- package/dist/shape.js +499 -0
- package/dist/splice-diagnostics.d.ts +40 -0
- package/dist/splice-diagnostics.js +80 -0
- package/dist/splice-project.d.ts +119 -0
- package/dist/splice-project.js +296 -0
- package/dist/splice-recording.d.ts +105 -0
- package/dist/splice-recording.js +464 -0
- package/dist/splice.d.ts +84 -0
- package/dist/splice.js +1065 -0
- package/dist/storage.d.ts +17 -0
- package/dist/storage.js +1 -0
- package/dist/store.d.ts +151 -0
- package/dist/store.js +735 -0
- package/dist/v2.d.ts +49 -0
- package/dist/v2.js +396 -0
- package/dist/validate-output.d.ts +3 -0
- package/dist/validate-output.js +73 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/dist/workflow-json.d.ts +8 -0
- package/dist/workflow-json.js +74 -0
- package/docs/PROJECTS-AND-UPGRADES.md +115 -0
- package/docs/RECORDING-AND-CORRECTIONS.md +176 -0
- package/package.json +95 -4
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ServerRecord, ShapeStoreDiagnostic } from "./store.js";
|
|
2
|
+
export type Awaitable<T> = T | Promise<T>;
|
|
3
|
+
/** Backends must serialize mutations against the latest committed record.
|
|
4
|
+
* Mutators are synchronous and must not perform external effects. Never retry a
|
|
5
|
+
* mutator after entry: a failed commit can have an unknown outcome. */
|
|
6
|
+
export interface LearningStore {
|
|
7
|
+
load(name: string, version?: string): Awaitable<ServerRecord>;
|
|
8
|
+
refresh(name: string): Awaitable<ServerRecord | undefined>;
|
|
9
|
+
has(name: string): Awaitable<boolean>;
|
|
10
|
+
list(): Awaitable<string[]>;
|
|
11
|
+
transact<T>(name: string, mutate: (record: ServerRecord) => T): Awaitable<T>;
|
|
12
|
+
remove(name: string): Awaitable<void>;
|
|
13
|
+
diagnostics?(): Awaitable<ShapeStoreDiagnostic[]>;
|
|
14
|
+
watch?(name: string, onChange: () => void, onError?: () => void): () => void;
|
|
15
|
+
/** The application owns backend lifetime; closing one proxy must not close a shared store. */
|
|
16
|
+
close?(): Awaitable<void>;
|
|
17
|
+
}
|
package/dist/storage.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/store.d.ts
ADDED
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import type { Extracted, OutputKind } from "./extract.js";
|
|
2
|
+
import { type JsonSchema } from "./schema.js";
|
|
3
|
+
import { type ObserveOptions, type Shape } from "./shape.js";
|
|
4
|
+
export interface ToolAnnotations {
|
|
5
|
+
title?: string;
|
|
6
|
+
readOnlyHint?: boolean;
|
|
7
|
+
destructiveHint?: boolean;
|
|
8
|
+
idempotentHint?: boolean;
|
|
9
|
+
openWorldHint?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ToolRecord {
|
|
12
|
+
name: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
inputSchema?: JsonSchema;
|
|
15
|
+
/** outputSchema the server itself declares, if any. */
|
|
16
|
+
outputSchema?: JsonSchema;
|
|
17
|
+
annotations?: ToolAnnotations;
|
|
18
|
+
drift?: import("./drift.js").DriftState;
|
|
19
|
+
schemaValidation?: {
|
|
20
|
+
checked: number;
|
|
21
|
+
mismatches: number;
|
|
22
|
+
latest: "valid" | "mismatch" | "unverified";
|
|
23
|
+
paths: string[];
|
|
24
|
+
};
|
|
25
|
+
calls: number;
|
|
26
|
+
kinds: Record<OutputKind, number>;
|
|
27
|
+
/** Learned from structuredContent and JSON text results. */
|
|
28
|
+
shape: Shape;
|
|
29
|
+
textSamples: string[];
|
|
30
|
+
errorSamples: string[];
|
|
31
|
+
prefixes: string[];
|
|
32
|
+
updatedAt?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface ServerRecord {
|
|
35
|
+
exportedAt?: string;
|
|
36
|
+
exportedFingerprint?: string;
|
|
37
|
+
name: string;
|
|
38
|
+
version?: string;
|
|
39
|
+
tools: Record<string, ToolRecord>;
|
|
40
|
+
updatedAt?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface ToolListEntry {
|
|
43
|
+
name: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
inputSchema?: unknown;
|
|
46
|
+
outputSchema?: unknown;
|
|
47
|
+
annotations?: ToolAnnotations;
|
|
48
|
+
}
|
|
49
|
+
export declare function newServer(name: string, version?: string): ServerRecord;
|
|
50
|
+
export declare function newTool(name: string): ToolRecord;
|
|
51
|
+
export declare function recordToolList(server: ServerRecord, tools: ToolListEntry[]): void;
|
|
52
|
+
/**
|
|
53
|
+
* Reapply privacy to retained learning across every tool, including tools absent from a new list.
|
|
54
|
+
* Mutates learned shapes and text/error/prefix samples only. Server-declared schemas (including
|
|
55
|
+
* their examples/defaults), descriptions, annotations, and other metadata are outside this scope.
|
|
56
|
+
* Call inside transact on load/list to persist a policy change before any tool calls occur.
|
|
57
|
+
*/
|
|
58
|
+
export declare function applyExamplePolicy(server: ServerRecord, options?: ObserveOptions): void;
|
|
59
|
+
export declare function recordCall(server: ServerRecord, toolName: string, result: Extracted, options?: ObserveOptions): ToolRecord;
|
|
60
|
+
/** Masks things that look like paths, emails, ids and tokens in a short message. */
|
|
61
|
+
export declare function scrub(text: string): string;
|
|
62
|
+
export interface ToolOutput {
|
|
63
|
+
/** Undefined when the tool has only ever returned plain text. */
|
|
64
|
+
schema?: JsonSchema;
|
|
65
|
+
source: "declared" | "learned";
|
|
66
|
+
encoding: "structured" | "json-text" | "text";
|
|
67
|
+
samples: number;
|
|
68
|
+
/** The tool returned JSON most of the time but sometimes plain text (often "no results"). */
|
|
69
|
+
alsoText: boolean;
|
|
70
|
+
/** A successful response without text/structured data decodes to null. */
|
|
71
|
+
alsoEmpty?: boolean;
|
|
72
|
+
textSample?: string;
|
|
73
|
+
prefix?: string;
|
|
74
|
+
warning?: string;
|
|
75
|
+
}
|
|
76
|
+
/** The best available description of what a tool returns. */
|
|
77
|
+
export declare function toolOutput(tool: ToolRecord): ToolOutput | undefined;
|
|
78
|
+
/**
|
|
79
|
+
* Copies learned examples and observed values onto the matching properties of a declared schema.
|
|
80
|
+
* A declared `{ content: string }` says nothing about what the string looks like; an example does.
|
|
81
|
+
*/
|
|
82
|
+
export declare function withLearnedExamples(declared: JsonSchema, learned: JsonSchema): JsonSchema;
|
|
83
|
+
export interface ShapeStoreOptions {
|
|
84
|
+
/** Diagnostics from list(), which skips unreadable/corrupt entries. Never includes file contents. */
|
|
85
|
+
onWarning?: (message: string) => void;
|
|
86
|
+
}
|
|
87
|
+
export interface ShapeStoreDiagnostic {
|
|
88
|
+
file: string;
|
|
89
|
+
kind: "locked" | "orphan-temp";
|
|
90
|
+
pid?: number;
|
|
91
|
+
owner: "running" | "not-running" | "unknown";
|
|
92
|
+
}
|
|
93
|
+
export declare class ShapeStoreError extends Error {
|
|
94
|
+
readonly code: "CORRUPT" | "IDENTITY" | "CONFLICT" | "LOCKED" | "IO";
|
|
95
|
+
constructor(code: "CORRUPT" | "IDENTITY" | "CONFLICT" | "LOCKED" | "IO", message: string, cause?: unknown);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Explicit reads and writes throw on failure; a proxy should catch recording failures.
|
|
99
|
+
* Saves are atomic and reject stale snapshots instead of silently losing another writer's data.
|
|
100
|
+
* Locks are nonblocking: after a crashed writer, inspect/remove its .lock file before retrying.
|
|
101
|
+
* PID/inode checks cannot make stale-lock unlink atomic, so locks are never auto-reclaimed.
|
|
102
|
+
* SIGKILL can leave one private .tmp per in-flight write; repeated manual recovery/crashes can
|
|
103
|
+
* accumulate orphans. Inspect/clean these only after stopping writers.
|
|
104
|
+
*/
|
|
105
|
+
export declare class ShapeStore {
|
|
106
|
+
readonly dir: string;
|
|
107
|
+
private readonly options;
|
|
108
|
+
private cache;
|
|
109
|
+
private snapshots;
|
|
110
|
+
constructor(dir: string, options?: ShapeStoreOptions);
|
|
111
|
+
/** Read disk without consulting an old session's cache, including external forget. */
|
|
112
|
+
refresh(name: string): ServerRecord | undefined;
|
|
113
|
+
watch(_name: string, onChange: () => void, onError?: () => void): () => void;
|
|
114
|
+
load(name: string, version?: string): ServerRecord;
|
|
115
|
+
has(name: string): boolean;
|
|
116
|
+
save(name: string): void;
|
|
117
|
+
/**
|
|
118
|
+
* Apply one synchronous mutation to the latest persisted record while holding its writer lock.
|
|
119
|
+
* If no file exists, reuse only a never-persisted cache as a detached copy. A previously
|
|
120
|
+
* persisted record that disappeared starts fresh, respecting another process's forget.
|
|
121
|
+
* A successful return means the write committed and the cache/save baseline were refreshed.
|
|
122
|
+
*
|
|
123
|
+
* A throw has NO return value and does NOT imply the mutator was never called: read/lock
|
|
124
|
+
* failures precede it, while serialization/write failures follow it. The mutator is never
|
|
125
|
+
* retried internally. For fail-open recording, capture its record and mark callback entry;
|
|
126
|
+
* if it ran, use that in-memory record without applying the mutation again. The cache is
|
|
127
|
+
* replaced only on success; failed callback records remain available only to their caller.
|
|
128
|
+
* Unsaved local changes are superseded whenever a persisted record exists. Callbacks must
|
|
129
|
+
* not perform upstream calls or other irreversible effects. Existing locks fail with LOCKED.
|
|
130
|
+
*/
|
|
131
|
+
transact<T>(name: string, mutate: (record: ServerRecord) => T): T;
|
|
132
|
+
/** Forget only files whose validated identity matches name. Never contacts the server. */
|
|
133
|
+
remove(name: string): void;
|
|
134
|
+
list(): string[];
|
|
135
|
+
/**
|
|
136
|
+
* Read-only, best-effort snapshot of lock/temp artifacts; never reclaims or reads result data.
|
|
137
|
+
* Each lock read is bounded to 64 bytes. Symlinks/nonregular/unreadable locks report unknown.
|
|
138
|
+
* Temp PIDs come only from recognized filenames; their contents are never opened.
|
|
139
|
+
* A temp may belong to an active write. Liveness is advisory, not permission to delete: PID
|
|
140
|
+
* reuse, concurrent file replacement, and process namespaces prevent reliable ownership proof.
|
|
141
|
+
*/
|
|
142
|
+
diagnostics(): ShapeStoreDiagnostic[];
|
|
143
|
+
private locate;
|
|
144
|
+
private fileFor;
|
|
145
|
+
private legacyFileFor;
|
|
146
|
+
private serialize;
|
|
147
|
+
private cleanup;
|
|
148
|
+
private warn;
|
|
149
|
+
}
|
|
150
|
+
/** Internal shared validation for persistent backends. The label must not contain credentials. */
|
|
151
|
+
export declare function decodeStoredRecord(raw: string, name: string): ServerRecord;
|