@obrier/plugboard 0.0.0-stage → 0.2.0
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 +364 -2
- package/dist/lib/THIRD-PARTY-LICENSES.txt +193 -0
- package/dist/lib/index.d.ts +164 -0
- package/dist/lib/index.js +13766 -0
- package/package.json +44 -4
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
declare const TRANSPORTS: readonly [
|
|
4
|
+
"auto",
|
|
5
|
+
"direct",
|
|
6
|
+
"claude-code"
|
|
7
|
+
];
|
|
8
|
+
export type Transport = (typeof TRANSPORTS)[number];
|
|
9
|
+
export type Via = Exclude<Transport, "auto">;
|
|
10
|
+
export declare const EXIT: {
|
|
11
|
+
readonly OK: 0;
|
|
12
|
+
readonly UPSTREAM_ERROR: 1;
|
|
13
|
+
readonly TIMEOUT: 1;
|
|
14
|
+
readonly UNKNOWN: 1;
|
|
15
|
+
readonly VALIDATION_ERROR: 2;
|
|
16
|
+
readonly NOT_FOUND: 2;
|
|
17
|
+
readonly POLICY_DENIED: 3;
|
|
18
|
+
readonly AUTH_REQUIRED: 4;
|
|
19
|
+
readonly RATE_LIMITED: 5;
|
|
20
|
+
readonly WRITE_OUTCOME_UNKNOWN: 6;
|
|
21
|
+
readonly PARTIAL: 7;
|
|
22
|
+
readonly UNREACHABLE: 10;
|
|
23
|
+
readonly COST_GUARD: 10;
|
|
24
|
+
};
|
|
25
|
+
export type Code = keyof typeof EXIT;
|
|
26
|
+
/** Every error Plugboard raises: a code (the CLI's exit codes name them), a message, and hints on what to do. */
|
|
27
|
+
export declare class PlugboardError extends Error {
|
|
28
|
+
readonly code: Code;
|
|
29
|
+
readonly hints: string[];
|
|
30
|
+
name: string;
|
|
31
|
+
constructor(message: string, code: Code, hints?: string[]);
|
|
32
|
+
get exitCode(): number;
|
|
33
|
+
}
|
|
34
|
+
export type Plan = {
|
|
35
|
+
connector: string;
|
|
36
|
+
tool: string;
|
|
37
|
+
class: string;
|
|
38
|
+
destructive: boolean;
|
|
39
|
+
profile: string;
|
|
40
|
+
decision: string;
|
|
41
|
+
hash: string;
|
|
42
|
+
/** What the hash names: the args as sent, but for a parameter the write key fills (`keyFills`). */
|
|
43
|
+
payload: Record<string, unknown>;
|
|
44
|
+
/** A parameter the write key fills when the write is sent, whichever key that is: outside the payload and the hash. */
|
|
45
|
+
keyFills?: "idempotency_key";
|
|
46
|
+
};
|
|
47
|
+
/** A call: the shape of a batch line, `{ connector, tool, args }`, with the call's options beside it. */
|
|
48
|
+
export type Call = {
|
|
49
|
+
/** A connector ID or a policy alias. */
|
|
50
|
+
connector: string;
|
|
51
|
+
/** The tool's name, the CLI's short name, or its kebab form. */
|
|
52
|
+
tool: string;
|
|
53
|
+
args?: Record<string, unknown>;
|
|
54
|
+
/** The policy profile that judges the call; the instance's by default. */
|
|
55
|
+
profile?: string;
|
|
56
|
+
/** The CLI's --deadline: 30 s by default. */
|
|
57
|
+
timeoutMs?: number;
|
|
58
|
+
/** Cancels the call: a read is dropped; a write cancelled after it was sent has an unknown outcome, as on a timeout. */
|
|
59
|
+
signal?: AbortSignal;
|
|
60
|
+
/** How the call reaches its connector; the narrowest setting wins: the call's, the instance's, PLUGBOARD_TRANSPORT, the policy's. */
|
|
61
|
+
transport?: Transport;
|
|
62
|
+
};
|
|
63
|
+
/** A read's result: the value as the CLI prints it, the MCP result as the connector sent it, and the path that served it. */
|
|
64
|
+
export type Read = {
|
|
65
|
+
value: unknown;
|
|
66
|
+
raw: Record<string, unknown>;
|
|
67
|
+
via: Via;
|
|
68
|
+
};
|
|
69
|
+
/** What a write would send and whether the profile allows it, with the request it was planned from: plain JSON. */
|
|
70
|
+
export type WritePlan = Plan & {
|
|
71
|
+
request: {
|
|
72
|
+
connector: string;
|
|
73
|
+
tool: string;
|
|
74
|
+
args: Record<string, unknown>;
|
|
75
|
+
profile: string;
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
export type WriteOptions = {
|
|
79
|
+
key: string;
|
|
80
|
+
/** The write profile it is sent under; the instance's by default. The plan's own profile is never trusted, as the
|
|
81
|
+
* CLI's --as is the sender's: no hash covers it. */
|
|
82
|
+
profile?: string;
|
|
83
|
+
timeoutMs?: number;
|
|
84
|
+
signal?: AbortSignal;
|
|
85
|
+
transport?: Transport;
|
|
86
|
+
};
|
|
87
|
+
/** Sent now, or already sent under this key before (nothing was called). */
|
|
88
|
+
export type Written = {
|
|
89
|
+
sent: true;
|
|
90
|
+
key: string;
|
|
91
|
+
ref: string | null;
|
|
92
|
+
value: unknown;
|
|
93
|
+
raw: Record<string, unknown>;
|
|
94
|
+
via: Via;
|
|
95
|
+
} | {
|
|
96
|
+
replayed: true;
|
|
97
|
+
key: string;
|
|
98
|
+
ref: string | null;
|
|
99
|
+
at?: string;
|
|
100
|
+
};
|
|
101
|
+
/** A batch line: a call, with an id to tell its result by (its input position by default). */
|
|
102
|
+
export type BatchCall = Call & {
|
|
103
|
+
id?: unknown;
|
|
104
|
+
};
|
|
105
|
+
export type BatchOptions = {
|
|
106
|
+
/** Lines running at once: the policy's limits.concurrency (4) by default. */
|
|
107
|
+
concurrency?: number;
|
|
108
|
+
/** Lines running at once on one connector: the policy's limits.per_connector (2) by default. */
|
|
109
|
+
perConnector?: number;
|
|
110
|
+
/** Results in input order; completion order by default. */
|
|
111
|
+
ordered?: boolean;
|
|
112
|
+
/** Once spent, the lines not yet started fail with TIMEOUT, unsent. None by default. */
|
|
113
|
+
budgetMs?: number;
|
|
114
|
+
};
|
|
115
|
+
/** A line's result: a failure is a result too, never an exception. */
|
|
116
|
+
export type BatchRead = {
|
|
117
|
+
id: unknown;
|
|
118
|
+
ok: true;
|
|
119
|
+
value: unknown;
|
|
120
|
+
raw: Record<string, unknown>;
|
|
121
|
+
via: Via;
|
|
122
|
+
} | {
|
|
123
|
+
id: unknown;
|
|
124
|
+
ok: false;
|
|
125
|
+
error: PlugboardError;
|
|
126
|
+
};
|
|
127
|
+
export type PlugboardOptions = {
|
|
128
|
+
/** A policy file; PLUGBOARD_POLICY's, or the default location, otherwise. Read once, on first use. */
|
|
129
|
+
policy?: string;
|
|
130
|
+
/** The profile calls use unless they name one; PLUGBOARD_PROFILE, or "default", otherwise. */
|
|
131
|
+
profile?: string;
|
|
132
|
+
transport?: Transport;
|
|
133
|
+
};
|
|
134
|
+
export type Plugboard = {
|
|
135
|
+
/** One read. A write tool is refused: plan it and send it with write(). */
|
|
136
|
+
call(request: Call): Promise<Read>;
|
|
137
|
+
/** A write (or a read) as it would be sent, with the hash its approval names. */
|
|
138
|
+
plan(request: Omit<Call, "signal" | "timeoutMs" | "transport">): WritePlan;
|
|
139
|
+
/** Sends an approved plan once under this key. Nothing in the plan is trusted: its request is planned again and
|
|
140
|
+
* sent only if the hash still matches. */
|
|
141
|
+
write(plan: WritePlan, options: WriteOptions): Promise<Written>;
|
|
142
|
+
/** Reads, as they arrive, results as they come: UNREACHABLE or COST_GUARD fails the lines still to come and ends
|
|
143
|
+
* it; leaving the loop cancels the lines still running. A write tool is refused for its line. */
|
|
144
|
+
batch(lines: Iterable<BatchCall> | AsyncIterable<BatchCall>, options?: BatchOptions): AsyncGenerator<BatchRead, void, undefined>;
|
|
145
|
+
/** Closes the instance's sessions now, rather than when idle. */
|
|
146
|
+
close(): Promise<void>;
|
|
147
|
+
};
|
|
148
|
+
export declare function createPlugboard(options?: PlugboardOptions): Plugboard;
|
|
149
|
+
/** One read, through the default instance (PLUGBOARD_POLICY, PLUGBOARD_PROFILE, PLUGBOARD_TRANSPORT). */
|
|
150
|
+
export declare const call: Plugboard["call"];
|
|
151
|
+
/** Plans a call through the default instance. */
|
|
152
|
+
export declare const plan: Plugboard["plan"];
|
|
153
|
+
/** Sends an approved plan through the default instance. */
|
|
154
|
+
export declare const write: Plugboard["write"];
|
|
155
|
+
/** A batch of reads through the default instance. */
|
|
156
|
+
export declare const batch: Plugboard["batch"];
|
|
157
|
+
/** Closes the default instance's sessions now, rather than when idle. */
|
|
158
|
+
declare const close$1: () => Promise<void>;
|
|
159
|
+
|
|
160
|
+
export {
|
|
161
|
+
close$1 as close,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export {};
|