stitchkit 0.91.2 → 0.92.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/CHANGELOG.md +80 -0
- package/dist/agent-runtime-coding-tools.js +3 -3
- package/dist/agent-runtime-harness.js +5 -5
- package/dist/agent-runtime-sandbox.js +3 -3
- package/dist/agent-runtime.js +8 -8
- package/dist/cli.d.ts +6 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +370 -49
- package/dist/contract/define.d.ts +84 -2
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/index.d.ts +1 -1
- package/dist/contract/index.d.ts.map +1 -1
- package/dist/{index-a2nzz56k.js → index-2c2bjw3s.js} +3 -3
- package/dist/{index-seyy8dvn.js → index-7n145nbe.js} +182 -108
- package/dist/{index-axvavfr4.js → index-bx75zwt7.js} +3 -3
- package/dist/{index-709nh7z7.js → index-cxqhvq21.js} +2 -1
- package/dist/{index-pena034b.js → index-e42wzzz5.js} +3 -3
- package/dist/{index-qjeyx5t2.js → index-fq77yfzc.js} +1 -1
- package/dist/{index-fenaekmk.js → index-h9etkkyk.js} +37 -27
- package/dist/{index-4x809vqd.js → index-mzvgxp0n.js} +2 -2
- package/dist/{index-jpfqfg5c.js → index-n0f51dfn.js} +2 -2
- package/dist/{index-bv7mytab.js → index-sr93cwf9.js} +1 -1
- package/dist/{index-vsbzgd7b.js → index-tmwcrptx.js} +1 -0
- package/dist/{index-8z9we758.js → index-vjpvjqpn.js} +1 -1
- package/dist/{index-7hz88dy8.js → index-vk3kq9sb.js} +1 -1
- package/dist/{index-s3dssqxp.js → index-yn8remb1.js} +60 -56
- package/dist/internal/atomic-file.d.ts +21 -0
- package/dist/internal/atomic-file.d.ts.map +1 -0
- package/dist/node.js +3 -3
- package/dist/observability/audit.d.ts +5 -1
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/changes.d.ts.map +1 -1
- package/dist/observability/context.d.ts +27 -6
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event.d.ts +34 -6
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/index.d.ts +2 -1
- package/dist/observability/index.d.ts.map +1 -1
- package/dist/observability/index.js +50 -6
- package/dist/observability/work.d.ts +55 -0
- package/dist/observability/work.d.ts.map +1 -0
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/index.js +4 -4
- package/dist/server/types.d.ts +20 -6
- package/dist/server/types.d.ts.map +1 -1
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/testing.js +6 -4
- package/dist/tool-invoker.js +5 -5
- package/dist/tools/cli-checkpoint.d.ts +24 -0
- package/dist/tools/cli-checkpoint.d.ts.map +1 -0
- package/dist/tools/cli-format.d.ts +10 -0
- package/dist/tools/cli-format.d.ts.map +1 -1
- package/dist/tools/cli-invoke.d.ts +118 -0
- package/dist/tools/cli-invoke.d.ts.map +1 -0
- package/dist/tools/cli-manifest.d.ts +6 -9
- package/dist/tools/cli-manifest.d.ts.map +1 -1
- package/dist/tools/cli-signature.d.ts +81 -0
- package/dist/tools/cli-signature.d.ts.map +1 -0
- package/dist/tools/cli-stream.d.ts +93 -0
- package/dist/tools/cli-stream.d.ts.map +1 -0
- package/dist/tools/cli-update.d.ts +62 -0
- package/dist/tools/cli-update.d.ts.map +1 -1
- package/dist/tools/cli.d.ts +4 -13
- package/dist/tools/cli.d.ts.map +1 -1
- package/dist/tools/connections/index.js +2 -2
- package/dist/tools/execute.d.ts +21 -0
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/mcp-progress.d.ts +46 -0
- package/dist/tools/mcp-progress.d.ts.map +1 -0
- package/dist/tools/mcp-round-policy.d.ts +25 -1
- package/dist/tools/mcp-round-policy.d.ts.map +1 -1
- package/dist/tools/mcp-round.d.ts +20 -1
- package/dist/tools/mcp-round.d.ts.map +1 -1
- package/dist/tools/mcp-trace.d.ts +9 -1
- package/dist/tools/mcp-trace.d.ts.map +1 -1
- package/dist/tools/mount-wait.d.ts.map +1 -1
- package/dist/tools.js +159 -50
- package/llms-full.txt +358 -8
- package/package.json +1 -1
package/dist/server/types.d.ts
CHANGED
|
@@ -12,16 +12,30 @@ type InferParams<E> = Prop<E, 'params'> extends ZodType<infer P> ? P : E extends
|
|
|
12
12
|
} ? keyof PathParams<TPath> extends never ? undefined : PathParams<TPath> : undefined;
|
|
13
13
|
type InferInput<E> = Prop<E, 'input'> extends ZodType<infer I> ? I : undefined;
|
|
14
14
|
type InferOutput<E> = Prop<E, 'output'> extends ZodType<infer O> ? O : never;
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}[];
|
|
20
|
-
} ? {
|
|
15
|
+
type McpInputOf<R> = R extends readonly {
|
|
16
|
+
key: string;
|
|
17
|
+
schema: ZodType;
|
|
18
|
+
}[] ? {
|
|
21
19
|
mcpInput?: {
|
|
22
20
|
[Request in R[number] as Request['key']]: Request['schema'] extends ZodType<infer I> ? I : never;
|
|
23
21
|
};
|
|
24
22
|
} : unknown;
|
|
23
|
+
/**
|
|
24
|
+
* `ctx.mcpInput`, from either form of the declaration.
|
|
25
|
+
*
|
|
26
|
+
* A resolver is a function, so the first branch cannot see through it — and a
|
|
27
|
+
* dynamic tool losing its typed `mcpInput` would be a real cost, not a detail.
|
|
28
|
+
* The second branch reads the resolver's own return type instead, so a resolver
|
|
29
|
+
* declared to return a precise tuple types the handler exactly as a static list
|
|
30
|
+
* does. One that returns the wide `EndpointMcpInputRequired[]` types it as the
|
|
31
|
+
* wide record, which is the truth about what it promised.
|
|
32
|
+
*/
|
|
33
|
+
type InferMcpInput<E> = Prop<E, 'mcp'> extends {
|
|
34
|
+
inputRequired: infer R;
|
|
35
|
+
} ? R extends readonly {
|
|
36
|
+
key: string;
|
|
37
|
+
schema: ZodType;
|
|
38
|
+
}[] ? McpInputOf<R> : R extends (call: never) => infer P ? McpInputOf<Awaited<P>> : unknown : unknown;
|
|
25
39
|
/**
|
|
26
40
|
* What an endpoint's handler must return: the `Response` itself for a `raw`
|
|
27
41
|
* endpoint, the output type when there is an output schema, nothing otherwise.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,KAAK,EACV,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,wBAAwB,EACxB,uBAAuB,EACvB,cAAc,EACd,cAAc,EACd,UAAU,EACV,sBAAsB,EACtB,mBAAmB,EACnB,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAEpD,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;AACtE,KAAK,WAAW,CAAC,CAAC,IAChB,IAAI,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GACtC,CAAC,GACD,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,KAAK,SAAS,MAAM,CAAA;CAAE,GAC5C,MAAM,UAAU,CAAC,KAAK,CAAC,SAAS,KAAK,GACnC,SAAS,GACT,UAAU,CAAC,KAAK,CAAC,GACnB,SAAS,CAAC;AAClB,KAAK,UAAU,CAAC,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Y,GAAG,UAAU,CAAC,EAAE,CAAC;IAChE,aAAa,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,SAAS,4BAA4B,EAAE,CAAC;IACvD,mFAAmF;IACnF,YAAY,CAAC,EAAE;QACb,GAAG,CAAC,EAAE,qBAAqB,CAAC;QAC5B,KAAK,CAAC,EAAE,sBAAsB,CAAC;QAC/B,GAAG,CAAC,EAAE,qBAAqB,CAAC;KAC7B,CAAC;IACF,sEAAsE;IACtE,WAAW,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC;IAC9D,mFAAmF;IACnF,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,qFAAqF;IACrF,QAAQ,CAAC,EAAE,QAAQ,CACjB,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC,CAC/E,CAAC;IACF,WAAW,CAAC,EAAE,SAAS,oBAAoB,EAAE,CAAC;IAC9C,UAAU,CAAC,EAAE,SAAS,wBAAwB,EAAE,CAAC;CAClD;AAED,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,+BAAyB,CAAC;AA+I5D,+EAA+E;AAC/E,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,GAAG,eAAe,CAuNnF;AAED,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,eAAe,GACxB,IAAI,CAQN"}
|
package/dist/testing.js
CHANGED
|
@@ -50,8 +50,9 @@ import"./index-zcgf3gqf.js";
|
|
|
50
50
|
import {
|
|
51
51
|
mcpProjectionCandidate,
|
|
52
52
|
prepareProjectedMcpTools,
|
|
53
|
-
projectToolSurface
|
|
54
|
-
|
|
53
|
+
projectToolSurface,
|
|
54
|
+
staticInputRounds
|
|
55
|
+
} from "./index-h9etkkyk.js";
|
|
55
56
|
import {
|
|
56
57
|
toJsonSchema
|
|
57
58
|
} from "./index-cby4ar3v.js";
|
|
@@ -1597,12 +1598,13 @@ function operationFrom(kind, source) {
|
|
|
1597
1598
|
};
|
|
1598
1599
|
}
|
|
1599
1600
|
function operationFingerprint(source) {
|
|
1601
|
+
const declaredRounds = source.mcp ? staticInputRounds(source.mcp) : undefined;
|
|
1600
1602
|
const mcp = source.mcp ? {
|
|
1601
|
-
inputRequired:
|
|
1603
|
+
inputRequired: declaredRounds ? declaredRounds.map((request) => ({
|
|
1602
1604
|
key: request.key,
|
|
1603
1605
|
message: request.message,
|
|
1604
1606
|
schema: schemaDigest(request.schema, "input")
|
|
1605
|
-
}))
|
|
1607
|
+
})) : "resolved-per-call"
|
|
1606
1608
|
} : null;
|
|
1607
1609
|
return serializeSurfaceValue({
|
|
1608
1610
|
method: source.method,
|
package/dist/tool-invoker.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToolInvoker
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
3
|
+
} from "./index-bx75zwt7.js";
|
|
4
|
+
import"./index-mzvgxp0n.js";
|
|
5
|
+
import"./index-yn8remb1.js";
|
|
6
|
+
import"./index-tmwcrptx.js";
|
|
7
7
|
import"./index-f9mb610r.js";
|
|
8
8
|
import"./index-e0znv5gn.js";
|
|
9
9
|
import"./index-0a349c33.js";
|
|
@@ -11,7 +11,7 @@ import"./index-rxfy4cq7.js";
|
|
|
11
11
|
import"./index-6k1937bx.js";
|
|
12
12
|
import"./index-zcgf3gqf.js";
|
|
13
13
|
import"./index-7zbps32p.js";
|
|
14
|
-
import"./index-
|
|
14
|
+
import"./index-h9etkkyk.js";
|
|
15
15
|
import"./index-cby4ar3v.js";
|
|
16
16
|
import"./index-2vtcmrj9.js";
|
|
17
17
|
import"./index-kzfs85xp.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** One recorded line: what it was, and what running it produced. */
|
|
2
|
+
export interface CliCheckpointEntry {
|
|
3
|
+
digest: string;
|
|
4
|
+
answer: unknown;
|
|
5
|
+
}
|
|
6
|
+
export interface CliCheckpoint {
|
|
7
|
+
entries: Record<string, CliCheckpointEntry>;
|
|
8
|
+
digestOf(line: {
|
|
9
|
+
command: string;
|
|
10
|
+
args: Record<string, unknown>;
|
|
11
|
+
}): string;
|
|
12
|
+
record(id: string, digest: string, answer: unknown): void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Read a checkpoint, or start an empty one.
|
|
16
|
+
*
|
|
17
|
+
* A file that cannot be parsed starts an empty checkpoint rather than throwing:
|
|
18
|
+
* the alternative is a batch that refuses to run because of a corrupted record
|
|
19
|
+
* of a previous run, which is worse than doing the work again.
|
|
20
|
+
*/
|
|
21
|
+
export declare function readCliCheckpoint(path: string): CliCheckpoint;
|
|
22
|
+
/** Persist the checkpoint atomically. */
|
|
23
|
+
export declare function writeCliCheckpoint(path: string, checkpoint: CliCheckpoint): void;
|
|
24
|
+
//# sourceMappingURL=cli-checkpoint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-checkpoint.d.ts","sourceRoot":"","sources":["../../src/tools/cli-checkpoint.ts"],"names":[],"mappings":"AAmBA,oEAAoE;AACpE,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC5C,QAAQ,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAAE,GAAG,MAAM,CAAC;IAC3E,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;CAC3D;AAYD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,CAgB7D;AAED,yCAAyC;AACzC,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,GAAG,IAAI,CAMhF"}
|
|
@@ -35,5 +35,15 @@ export interface EmitOptions {
|
|
|
35
35
|
* on stdout (pretty by default, compact with `--json`), exit `0`. Failure → the
|
|
36
36
|
* error JSON on stderr, exit per the code map (unknown code → `1`).
|
|
37
37
|
*/
|
|
38
|
+
/**
|
|
39
|
+
* The exit code a result earns, without writing anything.
|
|
40
|
+
*
|
|
41
|
+
* Extracted so a caller that runs an operation in process — a stdin loop, a
|
|
42
|
+
* resumable batch — gets the SAME code the printed path gives, from the same
|
|
43
|
+
* table, rather than re-deriving one from the error code and drifting. It was
|
|
44
|
+
* computed inside `emitResult`, which meant the only way to learn it was to
|
|
45
|
+
* print.
|
|
46
|
+
*/
|
|
47
|
+
export declare function cliExitCode(result: ToolResult, exitCodes?: ExitCodeMap): number;
|
|
38
48
|
export declare function emitResult(result: ToolResult, writers: CliWriters, opts: EmitOptions): number;
|
|
39
49
|
//# sourceMappingURL=cli-format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-format.d.ts","sourceRoot":"","sources":["../../src/tools/cli-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGzD,sDAAsD;AACtD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,WAWhC,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B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MAAM,CAeR"}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Running one already-parsed operation, in this process.
|
|
3
|
+
*
|
|
4
|
+
* The most common way an agent drives a CLI is not one command — it is a
|
|
5
|
+
* stream: a JSON line per operation, an answer per line. The framework owned
|
|
6
|
+
* the parsing, the routing, the JSON mode, the exit codes and the error shape,
|
|
7
|
+
* and handed out no way to say "run this parsed call and give me its result".
|
|
8
|
+
* So a consumer's stream loop spawned the binary again per line: three
|
|
9
|
+
* conversions of the same data (arguments back into `--flag value` strings,
|
|
10
|
+
* nested objects through `JSON.stringify` into an argv slot, the result parsed
|
|
11
|
+
* back out of stdout text) plus a process start each time — measured at 0.15 s,
|
|
12
|
+
* which is thirty seconds for a two-hundred-line manifest before any work
|
|
13
|
+
* happens. The ban on nesting one stream inside another existed for the same
|
|
14
|
+
* reason and disappears with it.
|
|
15
|
+
*
|
|
16
|
+
* `createCliInvoker` compiles the managed surface once and executes against it.
|
|
17
|
+
* `createCli` is built on this same function, so the stream and the command
|
|
18
|
+
* line cannot answer differently: one surface, one runner, one exit table.
|
|
19
|
+
*
|
|
20
|
+
* Native commands (`config.commands`) are deliberately outside it. They write
|
|
21
|
+
* to stdout and stderr by construction — that is what they are — and an
|
|
22
|
+
* operation that prints is not an operation whose result can be returned.
|
|
23
|
+
*/
|
|
24
|
+
import type { ZodObject, z } from 'zod';
|
|
25
|
+
import type { ServiceDef, StitchLogger } from '../server/types.js';
|
|
26
|
+
import { type ExitCodeMap } from './cli-format.js';
|
|
27
|
+
import { type CliCommandPresentation, type CliPresentationPolicyConfig } from './cli-policy.js';
|
|
28
|
+
import { type ErrorHintFn, type ToolCallHooks, type ToolLifecycle, type ToolResult } from './execute.js';
|
|
29
|
+
import { type MountableTool } from './mount.js';
|
|
30
|
+
import type { RuntimeToolDefinition } from './runtime-tool.js';
|
|
31
|
+
export type CliSurfaceSource<TAuth, TValue> = readonly TValue[] | ((auth: Awaited<TAuth> | undefined) => readonly TValue[]);
|
|
32
|
+
/**
|
|
33
|
+
* What an invocation needs to exist: the surface, the identity behind it and
|
|
34
|
+
* the policies every call runs under. Everything about a terminal — argv,
|
|
35
|
+
* writers, `--wait`, downloads — belongs to `CliConfig`, which extends this.
|
|
36
|
+
*/
|
|
37
|
+
export interface CliInvokerConfig<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>, TGlobals extends ZodObject = ZodObject> extends CliPresentationPolicyConfig {
|
|
38
|
+
/** Program name — used in diagnostics. */
|
|
39
|
+
name: string;
|
|
40
|
+
/** Contract services exposed as commands — may depend on the resolved identity. */
|
|
41
|
+
services?: CliSurfaceSource<TAuth, ServiceDef>;
|
|
42
|
+
/** Pathless managed operations. CLI exposure always requires `transports: ['CLI']`. */
|
|
43
|
+
runtimeTools?: CliSurfaceSource<TAuth, RuntimeToolDefinition>;
|
|
44
|
+
auth?: TAuth | Promise<TAuth>;
|
|
45
|
+
resolveAuth?: (globals: z.output<TGlobals>) => TAuth | Promise<TAuth>;
|
|
46
|
+
globalOptions?: TGlobals;
|
|
47
|
+
context?: (auth: Awaited<TAuth> | undefined, globals: z.output<TGlobals>) => TContext;
|
|
48
|
+
signal?: AbortSignal;
|
|
49
|
+
hooks?: ToolCallHooks;
|
|
50
|
+
lifecycle?: ToolLifecycle;
|
|
51
|
+
logger?: StitchLogger;
|
|
52
|
+
coerceJsonArgs?: boolean;
|
|
53
|
+
errorHint?: ErrorHintFn;
|
|
54
|
+
exitCodes?: ExitCodeMap;
|
|
55
|
+
passthrough?: Record<string, string>;
|
|
56
|
+
}
|
|
57
|
+
/** What one parsed invocation produced — never printed, never exited on. */
|
|
58
|
+
export interface CliInvocationResult {
|
|
59
|
+
ok: boolean;
|
|
60
|
+
/** The exit code the printed path would give this same result. */
|
|
61
|
+
exitCode: number;
|
|
62
|
+
/** The validated handler output, on success. */
|
|
63
|
+
data?: unknown;
|
|
64
|
+
/** The refusal, in the shape the CLI prints on failure. */
|
|
65
|
+
error?: {
|
|
66
|
+
code: string;
|
|
67
|
+
message: string;
|
|
68
|
+
details?: unknown;
|
|
69
|
+
hint?: string;
|
|
70
|
+
retryable?: boolean;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** One resolved managed command. */
|
|
74
|
+
export interface CliInvokerCommand {
|
|
75
|
+
name: string;
|
|
76
|
+
description: string;
|
|
77
|
+
}
|
|
78
|
+
/** The compiled surface: what can be run, and how to run it. */
|
|
79
|
+
export interface CliInvoker {
|
|
80
|
+
/** Every managed command, in surface order. */
|
|
81
|
+
readonly commands: readonly CliInvokerCommand[];
|
|
82
|
+
/**
|
|
83
|
+
* Run one parsed call. Never writes, never exits. An unknown command is a
|
|
84
|
+
* `NOT_FOUND` result rather than a throw, because a stream must answer the
|
|
85
|
+
* line that was wrong and keep reading the ones that follow.
|
|
86
|
+
*/
|
|
87
|
+
invoke(command: string, args: Record<string, unknown>): Promise<CliInvocationResult>;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Shape a `ToolResult` into an invocation result — the same error body the CLI
|
|
91
|
+
* prints, and the same exit code, produced without printing either.
|
|
92
|
+
*/
|
|
93
|
+
export declare function cliInvocationResult(result: ToolResult, toolName: string, config: {
|
|
94
|
+
errorHint?: ErrorHintFn;
|
|
95
|
+
exitCodes?: ExitCodeMap;
|
|
96
|
+
}): CliInvocationResult;
|
|
97
|
+
/**
|
|
98
|
+
* Compile the managed surface and return a dispatcher over it.
|
|
99
|
+
*
|
|
100
|
+
* Identity resolves once, not per call: a stream of two hundred operations must
|
|
101
|
+
* not resolve auth two hundred times, and a CLI invocation speaks as one
|
|
102
|
+
* identity by construction.
|
|
103
|
+
*/
|
|
104
|
+
export declare function createCliInvoker<TAuth = unknown, TContext extends Record<string, unknown> = Record<string, unknown>, TGlobals extends ZodObject = ZodObject>(config: CliInvokerConfig<TAuth, TContext, TGlobals>, globals?: Record<string, unknown>): Promise<CliInvoker>;
|
|
105
|
+
/**
|
|
106
|
+
* Walk the declared surface into executable tools and their presentation.
|
|
107
|
+
*
|
|
108
|
+
* Shared with `createCli`, which starts from its native commands rather than an
|
|
109
|
+
* empty map — the uniqueness and shape checks have to see both halves, or a
|
|
110
|
+
* managed command could silently shadow a native one.
|
|
111
|
+
*/
|
|
112
|
+
export declare function buildCliSurface<TAuth, TContext extends Record<string, unknown>, TGlobals extends ZodObject>(config: CliInvokerConfig<TAuth, TContext, TGlobals>, auth: Awaited<TAuth> | undefined, nativeHelp: Map<string, CliCommandPresentation>, applicationGlobalNames: ReadonlySet<string>, assertShape?: (name: string, descriptor: CliCommandPresentation, exists: boolean, passthroughField: string | undefined, globalNames: ReadonlySet<string>) => void): {
|
|
113
|
+
tools: Map<string, MountableTool>;
|
|
114
|
+
help: Map<string, CliCommandPresentation>;
|
|
115
|
+
};
|
|
116
|
+
/** How a managed tool presents itself — the same shape a native command builds. */
|
|
117
|
+
export declare function managedCliDescriptor(tool: MountableTool): Omit<CliCommandPresentation, 'aliases' | 'positionals'>;
|
|
118
|
+
//# sourceMappingURL=cli-invoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-invoke.d.ts","sourceRoot":"","sources":["../../src/tools/cli-invoke.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EACjC,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EAGhB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;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<z.ZodObject<{
|
|
60
|
+
algorithm: z.ZodLiteral<"ed25519">;
|
|
61
|
+
keyId: z.ZodString;
|
|
62
|
+
signature: z.ZodString;
|
|
63
|
+
}, z.core.$strip>>;
|
|
59
64
|
}, z.core.$strip>;
|
|
60
65
|
export type CliBuildManifest = z.infer<typeof CliBuildManifestSchema>;
|
|
61
66
|
/** The stamp a build carries inside itself, so the tool can say what it is. */
|
|
@@ -71,13 +76,5 @@ export declare function formatCliBuildStamp(stamp: CliBuildStamp, name?: string)
|
|
|
71
76
|
export declare function currentCliBuildTarget(): CliBuildTarget;
|
|
72
77
|
/** The asset for one target, or `undefined` when this build was not published. */
|
|
73
78
|
export declare function selectCliBuildAsset(manifest: CliBuildManifest, target?: CliBuildTarget): CliBuildAsset | undefined;
|
|
74
|
-
|
|
75
|
-
* Refuse republishing a version from a different commit.
|
|
76
|
-
*
|
|
77
|
-
* A version is a promise about contents. Publishing `1.4.2` twice from two trees
|
|
78
|
-
* means everyone who already installed `1.4.2` is told they are current and
|
|
79
|
-
* never receives the fix — and nothing about their machine looks wrong. The
|
|
80
|
-
* check is one comparison and belongs in the publisher, before the upload.
|
|
81
|
-
*/
|
|
82
|
-
export declare function assertCliPublishable(previous: CliBuildManifest | undefined, next: CliBuildManifest): void;
|
|
79
|
+
export declare function assertCliPublishable(previous: CliBuildManifest | readonly CliBuildManifest[] | undefined, next: CliBuildManifest): void;
|
|
83
80
|
//# sourceMappingURL=cli-manifest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-manifest.d.ts","sourceRoot":"","sources":["../../src/tools/cli-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-manifest.d.ts","sourceRoot":"","sources":["../../src/tools/cli-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,kFAAkF;AAClF,eAAO,MAAM,oBAAoB;;;iBAG/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;iBAK9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;iBAejC,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE,+EAA+E;AAC/E,eAAO,MAAM,mBAAmB;;;;iBAI9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAG/E;AAED,8EAA8E;AAC9E,wBAAgB,qBAAqB,IAAI,cAAc,CAEtD;AAED,kFAAkF;AAClF,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,gBAAgB,EAC1B,MAAM,GAAE,cAAwC,GAC/C,aAAa,GAAG,SAAS,CAI3B;AAgBD,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,gBAAgB,GAAG,SAAS,gBAAgB,EAAE,GAAG,SAAS,EACpE,IAAI,EAAE,gBAAgB,GACrB,IAAI,CAkBN"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who built the binary — which the asset digest cannot answer.
|
|
3
|
+
*
|
|
4
|
+
* The digest proves the bytes that arrived are the bytes the manifest named. It
|
|
5
|
+
* proves nothing about who named them: the manifest and the assets come from
|
|
6
|
+
* one origin, and whoever can replace one can replace the other. Authorship
|
|
7
|
+
* needs a key the build carries and the server never holds.
|
|
8
|
+
*
|
|
9
|
+
* So the signature covers the manifest's identity AND every asset's digest —
|
|
10
|
+
* `{name, version, commit, builtAt, assets[]}` — and the chain closes on the
|
|
11
|
+
* file that will execute rather than on the document describing it. Signing the
|
|
12
|
+
* document alone would leave an attacker free to swap an asset URL's contents
|
|
13
|
+
* and keep a valid signature over an unchanged document.
|
|
14
|
+
*
|
|
15
|
+
* Ed25519 over `node:crypto`; no dependency is added for this.
|
|
16
|
+
*/
|
|
17
|
+
import { z } from 'zod';
|
|
18
|
+
import type { CliBuildManifest } from './cli-manifest.js';
|
|
19
|
+
/** The detached signature a published manifest carries beside its own fields. */
|
|
20
|
+
export declare const CliBuildSignatureSchema: z.ZodObject<{
|
|
21
|
+
algorithm: z.ZodLiteral<"ed25519">;
|
|
22
|
+
keyId: z.ZodString;
|
|
23
|
+
signature: z.ZodString;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export type CliBuildSignature = z.infer<typeof CliBuildSignatureSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* What a verification concluded. Five answers, and `unenforced` is the one that
|
|
28
|
+
* earns its keep: a build with no pinned key must keep updating, and the fact
|
|
29
|
+
* that nothing was checked has to be VISIBLE rather than assumed. A silent
|
|
30
|
+
* "fine" from a check that never ran is the failure mode this whole file exists
|
|
31
|
+
* to remove.
|
|
32
|
+
*/
|
|
33
|
+
export type CliSignatureVerdict = 'valid' | 'unenforced' | 'missing' | 'unknown-key' | 'invalid';
|
|
34
|
+
/** The keys a build trusts, by id. A build with none enforces nothing. */
|
|
35
|
+
export interface CliTrustRoot {
|
|
36
|
+
/**
|
|
37
|
+
* `keyId` → public key, as SPKI PEM or base64 of the raw 32-byte Ed25519 key.
|
|
38
|
+
* Compiled into the binary: a trust root fetched at runtime from the same
|
|
39
|
+
* origin as the manifest proves nothing.
|
|
40
|
+
*/
|
|
41
|
+
keys: Readonly<Record<string, string>>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The exact bytes a signature covers.
|
|
45
|
+
*
|
|
46
|
+
* Canonical JSON, so two producers that agree on the content agree on the
|
|
47
|
+
* bytes — key order and whitespace are not allowed to decide whether a
|
|
48
|
+
* signature verifies. Every asset contributes its target, its compression, its
|
|
49
|
+
* size and its digest; `url` does not, because where a file is served from is
|
|
50
|
+
* the publisher's business and moving it must not invalidate the proof of what
|
|
51
|
+
* it contains. Everything that decides what happens to the bytes BEFORE the
|
|
52
|
+
* digest can be checked is signed; only the address is free.
|
|
53
|
+
*/
|
|
54
|
+
export declare function cliManifestSigningPayload(manifest: CliBuildManifest): string;
|
|
55
|
+
/**
|
|
56
|
+
* A private key as it comes out of a file or a secret store: PEM text, or DER
|
|
57
|
+
* bytes.
|
|
58
|
+
*
|
|
59
|
+
* Deliberately not `KeyObject`. That type belongs to `node:crypto`, and naming
|
|
60
|
+
* it in a published signature puts `import("node:crypto")` into the declaration
|
|
61
|
+
* files of a package whose browser-safe entries a consumer resolves without
|
|
62
|
+
* Node types at all — the whole surface stops typechecking for them over a
|
|
63
|
+
* function they never call.
|
|
64
|
+
*/
|
|
65
|
+
export type CliSigningKey = string | Uint8Array;
|
|
66
|
+
/** Sign a manifest — for the publisher, which is the only side that holds a key. */
|
|
67
|
+
export declare function signCliManifest(manifest: CliBuildManifest, options: {
|
|
68
|
+
keyId: string;
|
|
69
|
+
privateKey: CliSigningKey;
|
|
70
|
+
}): CliBuildSignature;
|
|
71
|
+
/**
|
|
72
|
+
* Verify a manifest against the build's own trust root.
|
|
73
|
+
*
|
|
74
|
+
* Never throws: a verdict is the answer, including for a malformed key or a
|
|
75
|
+
* signature that is not base64 at all. A caller deciding whether to download
|
|
76
|
+
* something wants a decision, not an exception to translate into one.
|
|
77
|
+
*/
|
|
78
|
+
export declare function verifyCliManifest(manifest: CliBuildManifest, signature: CliBuildSignature | undefined, trust?: CliTrustRoot): CliSignatureVerdict;
|
|
79
|
+
/** Whether a verdict permits installing the build it describes. */
|
|
80
|
+
export declare function cliSignatureAccepted(verdict: CliSignatureVerdict): boolean;
|
|
81
|
+
//# sourceMappingURL=cli-signature.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-signature.d.ts","sourceRoot":"","sources":["../../src/tools/cli-signature.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AASH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,iFAAiF;AACjF,eAAO,MAAM,uBAAuB;;;;iBAMlC,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAC3B,OAAO,GACP,YAAY,GACZ,SAAS,GACT,aAAa,GACb,SAAS,CAAC;AAEd,0EAA0E;AAC1E,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,MAAM,CAkB5E;AAgBD;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhD,oFAAoF;AACpF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,gBAAgB,EAC1B,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,aAAa,CAAA;CAAE,GACpD,iBAAiB,CAenB;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,gBAAgB,EAC1B,SAAS,EAAE,iBAAiB,GAAG,SAAS,EACxC,KAAK,CAAC,EAAE,YAAY,GACnB,mBAAmB,CAiBrB;AAED,mEAAmE;AACnE,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAE1E"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One operation per line, and a batch that can be resumed.
|
|
3
|
+
*
|
|
4
|
+
* Every agent-facing CLI grows the same two commands, and the mechanics contain
|
|
5
|
+
* nothing about any product: read a line, run the operation, answer with the
|
|
6
|
+
* same id, do not let one bad line stop the stream — and for a batch, do not
|
|
7
|
+
* run again what already ran.
|
|
8
|
+
*
|
|
9
|
+
* They are factories rather than framework-owned command names. Reserving
|
|
10
|
+
* `jsonl` and `batch` would take two names out of a namespace that belongs to
|
|
11
|
+
* the consumer: an application that already has a `batch` command would either
|
|
12
|
+
* fail at startup or find its own command silently shadowed. So the consumer
|
|
13
|
+
* mounts these under whatever it calls them, exactly like its own commands.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import type { CliInvocationResult, CliInvoker } from './cli-invoke.js';
|
|
17
|
+
/** One line's answer: the id it came with, plus what running it produced. */
|
|
18
|
+
export interface CliStreamAnswer extends CliInvocationResult {
|
|
19
|
+
/** Correlation id, echoed from the line. */
|
|
20
|
+
id: string;
|
|
21
|
+
/** Present when this answer was replayed from a checkpoint rather than run. */
|
|
22
|
+
replayed?: true;
|
|
23
|
+
}
|
|
24
|
+
export interface CliStreamCommandConfig {
|
|
25
|
+
/** Command name — the consumer's namespace, not the framework's. */
|
|
26
|
+
name?: string;
|
|
27
|
+
description?: string;
|
|
28
|
+
/** The compiled surface to run against. */
|
|
29
|
+
invoker: CliInvoker | (() => Promise<CliInvoker>);
|
|
30
|
+
/**
|
|
31
|
+
* Where the lines come from. Default: `process.stdin`, **as they arrive**.
|
|
32
|
+
*
|
|
33
|
+
* This is the difference between a pipe and a conversation. The framework's
|
|
34
|
+
* ordinary stdin routing accumulates the whole stream and hands the command a
|
|
35
|
+
* string, which is right for `--prompt "$(cat file)"` and fatally wrong here:
|
|
36
|
+
* an agent that writes one line and waits for its answer would wait for its
|
|
37
|
+
* own EOF, which never comes. So the stream owns its input and answers each
|
|
38
|
+
* line as it is read.
|
|
39
|
+
*/
|
|
40
|
+
readLines?: () => AsyncIterable<string>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Lines from a byte stream, delivered as they arrive.
|
|
44
|
+
*
|
|
45
|
+
* Split on `\n` with a trailing `\r` dropped, so a producer on Windows is not a
|
|
46
|
+
* silent parse failure on every line. A final line with no newline is delivered
|
|
47
|
+
* at end of stream rather than discarded.
|
|
48
|
+
*/
|
|
49
|
+
export declare function readStdinLines(source?: AsyncIterable<Uint8Array | string>): AsyncIterable<string>;
|
|
50
|
+
/**
|
|
51
|
+
* Run each line as it arrives, answering before reading the next.
|
|
52
|
+
*
|
|
53
|
+
* Sequential on purpose: the answers carry ids, so a consumer could correlate
|
|
54
|
+
* out-of-order ones — but a stream that runs ahead of its answers removes the
|
|
55
|
+
* one form of backpressure an agent has, which is not answering yet.
|
|
56
|
+
*/
|
|
57
|
+
export declare function runCliStream(invoker: CliInvoker, lines: AsyncIterable<string>, onAnswer: (answer: CliStreamAnswer) => void, hooks?: CliStreamHooks): Promise<void>;
|
|
58
|
+
/** What a caller decides per line, without owning the loop that reads them. */
|
|
59
|
+
export interface CliStreamHooks {
|
|
60
|
+
/** Answer this line without running it — a replay, or a refusal. */
|
|
61
|
+
before?: (id: string, line: {
|
|
62
|
+
command: string;
|
|
63
|
+
args: Record<string, unknown>;
|
|
64
|
+
}) => CliStreamAnswer | undefined;
|
|
65
|
+
/** Observe what running it produced, before the answer is written. */
|
|
66
|
+
after?: (id: string, line: {
|
|
67
|
+
command: string;
|
|
68
|
+
args: Record<string, unknown>;
|
|
69
|
+
}, outcome: CliInvocationResult) => void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A stream command the consumer mounts under its own name.
|
|
73
|
+
*
|
|
74
|
+
* Answers go to stdout one JSON object per line; nothing else does, so a script
|
|
75
|
+
* can read stdout as data while diagnostics stay on stderr.
|
|
76
|
+
*/
|
|
77
|
+
export declare function defineCliStreamCommand(config: CliStreamCommandConfig): import("./cli-command.js").CliCommandDefinitionWithoutOutput<z.ZodObject<{}, z.core.$strip>>;
|
|
78
|
+
export interface CliBatchCommandConfig extends CliStreamCommandConfig {
|
|
79
|
+
/** Where the checkpoint lives. Relative paths resolve against the process cwd. */
|
|
80
|
+
checkpointPath?: string;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A resumable batch.
|
|
84
|
+
*
|
|
85
|
+
* The checkpoint records, per line id, the digest of the line that produced the
|
|
86
|
+
* recorded answer. A re-run replays what already ran; a line whose CONTENT
|
|
87
|
+
* changed under the same id is refused rather than quietly re-run or quietly
|
|
88
|
+
* replayed, because both of those answer a question nobody asked.
|
|
89
|
+
*/
|
|
90
|
+
export declare function defineCliBatchCommand(config: CliBatchCommandConfig): import("./cli-command.js").CliCommandDefinitionWithoutOutput<z.ZodObject<{
|
|
91
|
+
checkpoint: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.core.$strip>>;
|
|
93
|
+
//# sourceMappingURL=cli-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-stream.d.ts","sourceRoot":"","sources":["../../src/tools/cli-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEpE,6EAA6E;AAC7E,MAAM,WAAW,eAAgB,SAAQ,mBAAmB;IAC1D,4CAA4C;IAC5C,EAAE,EAAE,MAAM,CAAC;IACX,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,IAAI,CAAC;CACjB;AASD,MAAM,WAAW,sBAAsB;IACrC,oEAAoE;IACpE,IAAI,CAAC,EAAE,M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