deepclause-sdk 0.1.1 → 0.1.3
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/dist/agent.d.ts +12 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +116 -9
- package/dist/agent.js.map +1 -1
- package/dist/cli/config.d.ts +24 -24
- package/dist/cli/repl.d.ts +21 -4
- package/dist/cli/repl.d.ts.map +1 -1
- package/dist/cli/repl.js +293 -44
- package/dist/cli/repl.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +10 -0
- package/dist/cli/run.js.map +1 -1
- package/dist/prolog/loader.d.ts +32 -0
- package/dist/prolog/loader.d.ts.map +1 -1
- package/dist/prolog/loader.js +87 -0
- package/dist/prolog/loader.js.map +1 -1
- package/dist/prolog-src/deepclause_mi.pl +1028 -118
- package/dist/repl/agent.d.ts +15 -1
- package/dist/repl/agent.d.ts.map +1 -1
- package/dist/repl/agent.js +44 -5
- package/dist/repl/agent.js.map +1 -1
- package/dist/repl/backend.d.ts.map +1 -1
- package/dist/repl/backend.js +18 -5
- package/dist/repl/backend.js.map +1 -1
- package/dist/repl/harness-tools.d.ts +24 -2
- package/dist/repl/harness-tools.d.ts.map +1 -1
- package/dist/repl/harness-tools.js +14 -5
- package/dist/repl/harness-tools.js.map +1 -1
- package/dist/repl/index.d.ts +8 -0
- package/dist/repl/index.d.ts.map +1 -1
- package/dist/repl/index.js +1 -0
- package/dist/repl/index.js.map +1 -1
- package/dist/repl/render.d.ts +60 -3
- package/dist/repl/render.d.ts.map +1 -1
- package/dist/repl/render.js +114 -28
- package/dist/repl/render.js.map +1 -1
- package/dist/repl/session.d.ts +61 -4
- package/dist/repl/session.d.ts.map +1 -1
- package/dist/repl/session.js +174 -9
- package/dist/repl/session.js.map +1 -1
- package/dist/repl/status.d.ts +3 -1
- package/dist/repl/status.d.ts.map +1 -1
- package/dist/repl/status.js +4 -0
- package/dist/repl/status.js.map +1 -1
- package/dist/repl/tool-arguments.d.ts +36 -0
- package/dist/repl/tool-arguments.d.ts.map +1 -0
- package/dist/repl/tool-arguments.js +123 -0
- package/dist/repl/tool-arguments.js.map +1 -0
- package/dist/repl/toolset.d.ts +28 -1
- package/dist/repl/toolset.d.ts.map +1 -1
- package/dist/repl/toolset.js +52 -4
- package/dist/repl/toolset.js.map +1 -1
- package/dist/repl/tui/autocomplete.d.ts +19 -0
- package/dist/repl/tui/autocomplete.d.ts.map +1 -0
- package/dist/repl/tui/autocomplete.js +41 -0
- package/dist/repl/tui/autocomplete.js.map +1 -0
- package/dist/repl/tui/document.d.ts +51 -0
- package/dist/repl/tui/document.d.ts.map +1 -0
- package/dist/repl/tui/document.js +160 -0
- package/dist/repl/tui/document.js.map +1 -0
- package/dist/repl/tui/picker.d.ts +31 -0
- package/dist/repl/tui/picker.d.ts.map +1 -0
- package/dist/repl/tui/picker.js +43 -0
- package/dist/repl/tui/picker.js.map +1 -0
- package/dist/repl/tui/renderer.d.ts +98 -0
- package/dist/repl/tui/renderer.d.ts.map +1 -0
- package/dist/repl/tui/renderer.js +284 -0
- package/dist/repl/tui/renderer.js.map +1 -0
- package/dist/repl/tui/status-bar.d.ts +4 -2
- package/dist/repl/tui/status-bar.d.ts.map +1 -1
- package/dist/repl/tui/status-bar.js +80 -24
- package/dist/repl/tui/status-bar.js.map +1 -1
- package/dist/repl/tui/terminal.d.ts +28 -0
- package/dist/repl/tui/terminal.d.ts.map +1 -0
- package/dist/repl/tui/terminal.js +94 -0
- package/dist/repl/tui/terminal.js.map +1 -0
- package/dist/repl/tui/theme.d.ts +60 -0
- package/dist/repl/tui/theme.d.ts.map +1 -1
- package/dist/repl/tui/theme.js +142 -0
- package/dist/repl/tui/theme.js.map +1 -1
- package/dist/repl/tui/tool-pane.d.ts +68 -0
- package/dist/repl/tui/tool-pane.d.ts.map +1 -0
- package/dist/repl/tui/tool-pane.js +257 -0
- package/dist/repl/tui/tool-pane.js.map +1 -0
- package/dist/repl/tui/working-line.d.ts +23 -0
- package/dist/repl/tui/working-line.d.ts.map +1 -0
- package/dist/repl/tui/working-line.js +58 -0
- package/dist/repl/tui/working-line.js.map +1 -0
- package/dist/runner.d.ts +31 -0
- package/dist/runner.d.ts.map +1 -1
- package/dist/runner.js +192 -17
- package/dist/runner.js.map +1 -1
- package/dist/system/assets/docs/AGENT_PROMPT.md +925 -43
- package/dist/system/assets/docs/DML_AUTHORING.md +96 -17
- package/dist/system/assets/docs/DML_REFERENCE.md +620 -39
- package/dist/system/assets/docs/PROLOG_SNIPPETS.md +45 -1
- package/dist/system/assets/docs/TASK_PROMPT.md +2 -0
- package/dist/system/environment.d.ts +36 -0
- package/dist/system/environment.d.ts.map +1 -0
- package/dist/system/environment.js +81 -0
- package/dist/system/environment.js.map +1 -0
- package/dist/system/runtime/shell-manager.d.ts +40 -2
- package/dist/system/runtime/shell-manager.d.ts.map +1 -1
- package/dist/system/runtime/shell-manager.js +82 -16
- package/dist/system/runtime/shell-manager.js.map +1 -1
- package/dist/system/runtime/shell-tool-events.js +25 -1
- package/dist/system/runtime/shell-tool-events.js.map +1 -1
- package/dist/types.d.ts +27 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +4 -2
- package/src/prolog-src/deepclause_mi.pl +1028 -118
- package/dist/compaction.d.ts +0 -98
- package/dist/compaction.d.ts.map +0 -1
- package/dist/compaction.js +0 -471
- package/dist/compaction.js.map +0 -1
- package/dist/repl/tools.d.ts +0 -53
- package/dist/repl/tools.d.ts.map +0 -1
- package/dist/repl/tools.js +0 -307
- package/dist/repl/tools.js.map +0 -1
- package/dist/system/assets/compactors/default-loop-compactor.dml +0 -43
- package/dist/system/assets/compactors/default-session-compactor.dml +0 -30
- package/dist/system/assets/docs/META_PROMPT.md +0 -68
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../src/repl/status.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAA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AE9B,OAAO,EAAE,wBAAwB;IAS7C,qEAAqE;IACrE,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAI7C,qDAAqD;IACrD,kBAAkB,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQtE,2CAA2C;IAC3C,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAiD9B,OAAO,CAAC,SAAS;IAOjB,0DAA0D;IAC1D,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIjD,QAAQ,IAAI,kBAAkB;CAqB/B;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAgBvE;AAED,qEAAqE;AACrE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAWzE;AAED,qFAAqF;AACrF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAMvE;AAED,2DAA2D;AAC3D,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,MAAM,CAKrE"}
|
package/dist/repl/status.js
CHANGED
|
@@ -139,6 +139,10 @@ export class ReplStatusTracker {
|
|
|
139
139
|
const fallback = isAgent ? this.estimated.agent : this.estimated.harness;
|
|
140
140
|
return emptyContext(this.contextWindow, observed ?? fallback);
|
|
141
141
|
}
|
|
142
|
+
/** Update the reasoning level shown next to the model. */
|
|
143
|
+
setThinkingLevel(level) {
|
|
144
|
+
this.model = { ...this.model, thinkingLevel: level };
|
|
145
|
+
}
|
|
142
146
|
snapshot() {
|
|
143
147
|
const context = { agent: this.slotUsage('agent'), harness: this.slotUsage('harness') };
|
|
144
148
|
const activeSlot = this.activeGroup === 'agent' ? 'agent' : 'harness';
|
package/dist/repl/status.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1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AAO,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC/C,MAAM,KAAK,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC3C,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC5D,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-call parameter validation.
|
|
3
|
+
*
|
|
4
|
+
* A tool call with an unknown parameter used to be accepted and the extra key
|
|
5
|
+
* silently dropped, so `exec(bash(command: "cat", stdin: "…"), R)` looked
|
|
6
|
+
* reasonable, ran `cat` with no input, and reported success. That is the worst
|
|
7
|
+
* kind of failure: nothing to see, nothing to fix, and the DML author blames
|
|
8
|
+
* their own logic. Rejecting the call names the mistake at the point it is made.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately shallow — unknown keys, missing required keys, and the primitive
|
|
11
|
+
* types. Deep or conditional validation belongs in the tool, which knows its own
|
|
12
|
+
* semantics; this exists to catch a call that cannot mean what it says.
|
|
13
|
+
*/
|
|
14
|
+
export interface ToolJsonSchema {
|
|
15
|
+
type?: string;
|
|
16
|
+
properties?: Record<string, {
|
|
17
|
+
type?: string | string[];
|
|
18
|
+
}>;
|
|
19
|
+
required?: string[];
|
|
20
|
+
additionalProperties?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type ArgumentValidation = {
|
|
23
|
+
ok: true;
|
|
24
|
+
} | {
|
|
25
|
+
ok: false;
|
|
26
|
+
error: string;
|
|
27
|
+
};
|
|
28
|
+
/** Read `properties`/`required` out of a JSON Schema tool parameter block. */
|
|
29
|
+
export declare function readToolSchema(schema: unknown): ToolJsonSchema | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Validate a tool call's arguments. Nothing to check is not a failure: a tool
|
|
32
|
+
* with no declared properties, or a schema this cannot read (a Zod schema is
|
|
33
|
+
* enforced by the AI SDK instead), passes.
|
|
34
|
+
*/
|
|
35
|
+
export declare function validateToolArguments(toolName: string, schema: unknown, args: Record<string, unknown>): ArgumentValidation;
|
|
36
|
+
//# sourceMappingURL=tool-arguments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-arguments.d.ts","sourceRoot":"","sources":["../../src/repl/tool-arguments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC1D,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,MAAM,kBAAkB,GAAG;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAgB7E,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,GAAG,SAAS,CAU1E;AAiCD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,kBAAkB,CAkDpB"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool-call parameter validation.
|
|
3
|
+
*
|
|
4
|
+
* A tool call with an unknown parameter used to be accepted and the extra key
|
|
5
|
+
* silently dropped, so `exec(bash(command: "cat", stdin: "…"), R)` looked
|
|
6
|
+
* reasonable, ran `cat` with no input, and reported success. That is the worst
|
|
7
|
+
* kind of failure: nothing to see, nothing to fix, and the DML author blames
|
|
8
|
+
* their own logic. Rejecting the call names the mistake at the point it is made.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately shallow — unknown keys, missing required keys, and the primitive
|
|
11
|
+
* types. Deep or conditional validation belongs in the tool, which knows its own
|
|
12
|
+
* semantics; this exists to catch a call that cannot mean what it says.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Extra advice for mistakes that are easy to make and hard to read back. The
|
|
16
|
+
* generic "unknown parameter" message is enough for a typo, but not for a field
|
|
17
|
+
* that looks like it should exist.
|
|
18
|
+
*/
|
|
19
|
+
const PARAMETER_HINTS = {
|
|
20
|
+
stdin: 'exec(bash(...)) has no stdin. Pass the data as an `argv` element '
|
|
21
|
+
+ '(quoted by the runtime), or write it to a workspace file and name the file.',
|
|
22
|
+
input: 'Pass data as an `argv` element or through a workspace file.',
|
|
23
|
+
shell: 'exec(bash(...)) always runs a shell; put the command in `command`, '
|
|
24
|
+
+ 'or pass a program and its arguments as `argv`.',
|
|
25
|
+
cwd: 'The working directory is always the workspace (/workspace); do not pass one.',
|
|
26
|
+
};
|
|
27
|
+
/** Read `properties`/`required` out of a JSON Schema tool parameter block. */
|
|
28
|
+
export function readToolSchema(schema) {
|
|
29
|
+
if (!schema || typeof schema !== 'object')
|
|
30
|
+
return undefined;
|
|
31
|
+
const record = schema;
|
|
32
|
+
const properties = record.properties;
|
|
33
|
+
if (!properties || typeof properties !== 'object')
|
|
34
|
+
return undefined;
|
|
35
|
+
return {
|
|
36
|
+
properties: properties,
|
|
37
|
+
required: Array.isArray(record.required) ? record.required : [],
|
|
38
|
+
additionalProperties: record.additionalProperties,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Does `value` satisfy the declared primitive type? */
|
|
42
|
+
function matchesType(value, type) {
|
|
43
|
+
if (!type)
|
|
44
|
+
return true;
|
|
45
|
+
const types = Array.isArray(type) ? type : [type];
|
|
46
|
+
return types.some((candidate) => {
|
|
47
|
+
switch (candidate) {
|
|
48
|
+
case 'string':
|
|
49
|
+
return typeof value === 'string';
|
|
50
|
+
case 'number':
|
|
51
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
52
|
+
case 'integer':
|
|
53
|
+
return typeof value === 'number' && Number.isInteger(value);
|
|
54
|
+
case 'boolean':
|
|
55
|
+
return typeof value === 'boolean';
|
|
56
|
+
case 'array':
|
|
57
|
+
return Array.isArray(value);
|
|
58
|
+
case 'object':
|
|
59
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
60
|
+
case 'null':
|
|
61
|
+
return value === null;
|
|
62
|
+
default:
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function describeAccepted(properties) {
|
|
68
|
+
const names = Object.keys(properties);
|
|
69
|
+
return names.length > 0 ? names.join(', ') : '(none)';
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Validate a tool call's arguments. Nothing to check is not a failure: a tool
|
|
73
|
+
* with no declared properties, or a schema this cannot read (a Zod schema is
|
|
74
|
+
* enforced by the AI SDK instead), passes.
|
|
75
|
+
*/
|
|
76
|
+
export function validateToolArguments(toolName, schema, args) {
|
|
77
|
+
const declared = readToolSchema(schema);
|
|
78
|
+
// Nothing declared means nothing to check — a tool with no parameters (which
|
|
79
|
+
// may still be called positionally) cannot have a wrong one.
|
|
80
|
+
if (!declared?.properties || Object.keys(declared.properties).length === 0)
|
|
81
|
+
return { ok: true };
|
|
82
|
+
const properties = declared.properties;
|
|
83
|
+
const unknownKeys = declared.additionalProperties === true
|
|
84
|
+
? []
|
|
85
|
+
: Object.keys(args).filter((key) => !(key in properties) && !key.startsWith('$'));
|
|
86
|
+
if (unknownKeys.length > 0) {
|
|
87
|
+
const quoted = unknownKeys.map((key) => `'${key}'`).join(', ');
|
|
88
|
+
// The hint explains the mistake; the accepted list says what to write
|
|
89
|
+
// instead. Both, or the author is left guessing which parameter was meant.
|
|
90
|
+
const hints = unknownKeys
|
|
91
|
+
.map((key) => PARAMETER_HINTS[key])
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join(' ');
|
|
94
|
+
return {
|
|
95
|
+
ok: false,
|
|
96
|
+
error: `${toolName}: unknown parameter ${quoted}. ${hints} `
|
|
97
|
+
+ `Accepted: ${describeAccepted(properties)}.`.replace(/\s+/g, ' '),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
const missing = (declared.required ?? []).filter((key) => args[key] === undefined || args[key] === null);
|
|
101
|
+
if (missing.length > 0) {
|
|
102
|
+
return {
|
|
103
|
+
ok: false,
|
|
104
|
+
error: `${toolName}: missing required parameter${missing.length > 1 ? 's' : ''} `
|
|
105
|
+
+ `${missing.join(', ')}.`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
for (const [key, value] of Object.entries(args)) {
|
|
109
|
+
if (value === undefined || key.startsWith('$'))
|
|
110
|
+
continue;
|
|
111
|
+
const expected = properties[key]?.type;
|
|
112
|
+
if (!matchesType(value, expected)) {
|
|
113
|
+
const typeLabel = Array.isArray(expected) ? expected.join('|') : String(expected);
|
|
114
|
+
const actual = Array.isArray(value) ? 'array' : value === null ? 'null' : typeof value;
|
|
115
|
+
return {
|
|
116
|
+
ok: false,
|
|
117
|
+
error: `${toolName}: parameter ${key} should be ${typeLabel}, got ${actual}.`,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return { ok: true };
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=tool-arguments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-arguments.js","sourceRoot":"","sources":["../../src/repl/tool-arguments.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH;;;;GAIG;AACH,MAAM,eAAe,GAA2B;IAC9C,KAAK,EAAE,mEAAmE;UACtE,6EAA6E;IACjF,KAAK,EAAE,6DAA6D;IACpE,KAAK,EAAE,qEAAqE;UACxE,gDAAgD;IACpD,GAAG,EAAE,8EAA8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AC,UAAU,CAAC,GAAG,CAAC;YAAE,SAAS;QACzD,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;QACvC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,EAAE,CAAC;YAClC,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAClF,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK,CAAC;YACvF,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,GAAG,QAAQ,eAAe,GAAG,cAAc,SAAS,SAAS,MAAM,GAAG;aAC9E,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;AACtB,CAAC"}
|
package/dist/repl/toolset.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* human-in-the-loop channel (`ask_user` / `input/2`). `--tools`/`--no-tools`
|
|
8
8
|
* control whether `bash` is registered.
|
|
9
9
|
*/
|
|
10
|
-
import { type HostShellConfig } from '../system/runtime/shell-manager.js';
|
|
10
|
+
import { type ExecutionEnvironment, type HostShellConfig } from '../system/runtime/shell-manager.js';
|
|
11
11
|
import type { DMLEvent, ToolDefinition } from '../types.js';
|
|
12
12
|
export declare const DEFAULT_REPL_TOOLS: readonly ["bash"];
|
|
13
13
|
export interface ReplToolsetOptions {
|
|
@@ -24,9 +24,36 @@ export interface ReplToolset {
|
|
|
24
24
|
tools: Map<string, ToolDefinition>;
|
|
25
25
|
/** Catalog text injected into the meta prompt. */
|
|
26
26
|
catalog: string;
|
|
27
|
+
/**
|
|
28
|
+
* How shell commands will actually run here. The caller passes this to the
|
|
29
|
+
* session so the harness `require_sandbox` check, the model's environment
|
|
30
|
+
* block and this toolset all agree on one answer.
|
|
31
|
+
*/
|
|
32
|
+
environment: ExecutionEnvironment;
|
|
27
33
|
dispose(): Promise<void>;
|
|
28
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Describe the `bash` tool, including where it runs.
|
|
37
|
+
*
|
|
38
|
+
* The agent has to reconcile two surfaces — its own tools and DML's `exec` — and
|
|
39
|
+
* they must not disagree about what a path means. So the description states the
|
|
40
|
+
* one name, and states whether anything is actually isolated, rather than
|
|
41
|
+
* letting the agent assume a sandbox is there.
|
|
42
|
+
*/
|
|
43
|
+
export declare function describeBashTool(environment: ExecutionEnvironment): string;
|
|
29
44
|
/** Human-readable catalog of the registered capability tools. */
|
|
30
45
|
export declare function buildToolCatalog(tools: Map<string, ToolDefinition>): string;
|
|
46
|
+
/**
|
|
47
|
+
* Join an argv list into a shell command, quoting every element.
|
|
48
|
+
*
|
|
49
|
+
* This is what makes `exec(bash(argv: [...]))` worth having: the author passes
|
|
50
|
+
* values as a list and never writes a quote, so data containing spaces, quotes,
|
|
51
|
+
* `$`, backticks, `;` or newlines cannot escape into the command. It still runs
|
|
52
|
+
* through the same launch plan, so the sandbox and wrapper are unchanged.
|
|
53
|
+
*
|
|
54
|
+
* POSIX single-quote quoting: wrap in `'`, and end/restart the quote around any
|
|
55
|
+
* embedded `'` (`'\''`).
|
|
56
|
+
*/
|
|
57
|
+
export declare function quoteArgv(argv: readonly string[]): string;
|
|
31
58
|
export declare function createReplToolset(options: ReplToolsetOptions): Promise<ReplToolset>;
|
|
32
59
|
//# sourceMappingURL=toolset.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolset.d.ts","sourceRoot":"","sources":["../../src/repl/toolset.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,
|
|
1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AuEzF"}
|
package/dist/repl/toolset.js
CHANGED
|
@@ -7,9 +7,32 @@
|
|
|
7
7
|
* human-in-the-loop channel (`ask_user` / `input/2`). `--tools`/`--no-tools`
|
|
8
8
|
* control whether `bash` is registered.
|
|
9
9
|
*/
|
|
10
|
-
import { createShellManager } from '../system/runtime/shell-manager.js';
|
|
10
|
+
import { createShellManager, describeShellExecutionBackend, } from '../system/runtime/shell-manager.js';
|
|
11
11
|
import { createShellToolEventBridge } from '../system/runtime/shell-tool-events.js';
|
|
12
12
|
export const DEFAULT_REPL_TOOLS = ['bash'];
|
|
13
|
+
/**
|
|
14
|
+
* Describe the `bash` tool, including where it runs.
|
|
15
|
+
*
|
|
16
|
+
* The agent has to reconcile two surfaces — its own tools and DML's `exec` — and
|
|
17
|
+
* they must not disagree about what a path means. So the description states the
|
|
18
|
+
* one name, and states whether anything is actually isolated, rather than
|
|
19
|
+
* letting the agent assume a sandbox is there.
|
|
20
|
+
*/
|
|
21
|
+
export function describeBashTool(environment) {
|
|
22
|
+
const isolation = environment.kind === 'clean-room'
|
|
23
|
+
? 'There is NO sandbox: commands run as your user account, and anything you '
|
|
24
|
+
+ 'write outside the workspace is real and persists.'
|
|
25
|
+
: `Isolated by ${environment.description}.`;
|
|
26
|
+
return [
|
|
27
|
+
'Run a shell command in the session workspace.',
|
|
28
|
+
'Your working directory is the workspace, and /workspace names that same '
|
|
29
|
+
+ 'directory (DML uses the same name), so out/report.txt and '
|
|
30
|
+
+ '/workspace/out/report.txt are one file.',
|
|
31
|
+
'Only files under the workspace are shared with the host. For scratch use '
|
|
32
|
+
+ '"$TMPDIR" (a per-session directory), not a fixed path like /tmp.',
|
|
33
|
+
isolation,
|
|
34
|
+
].join(' ');
|
|
35
|
+
}
|
|
13
36
|
/** Human-readable catalog of the registered capability tools. */
|
|
14
37
|
export function buildToolCatalog(tools) {
|
|
15
38
|
if (tools.size === 0) {
|
|
@@ -25,10 +48,25 @@ export function buildToolCatalog(tools) {
|
|
|
25
48
|
lines.push('DML file I/O always uses the MI predicates (open/3, close/1, read_string/3, write/2, write_file/2, read_file/2, append_file/2); it is not a host tool.');
|
|
26
49
|
return lines.join('\n');
|
|
27
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Join an argv list into a shell command, quoting every element.
|
|
53
|
+
*
|
|
54
|
+
* This is what makes `exec(bash(argv: [...]))` worth having: the author passes
|
|
55
|
+
* values as a list and never writes a quote, so data containing spaces, quotes,
|
|
56
|
+
* `$`, backticks, `;` or newlines cannot escape into the command. It still runs
|
|
57
|
+
* through the same launch plan, so the sandbox and wrapper are unchanged.
|
|
58
|
+
*
|
|
59
|
+
* POSIX single-quote quoting: wrap in `'`, and end/restart the quote around any
|
|
60
|
+
* embedded `'` (`'\''`).
|
|
61
|
+
*/
|
|
62
|
+
export function quoteArgv(argv) {
|
|
63
|
+
return argv.map((item) => `'${item.replace(/'/g, `'\\''`)}'`).join(' ');
|
|
64
|
+
}
|
|
28
65
|
export async function createReplToolset(options) {
|
|
29
66
|
const requested = options.toolNames === null
|
|
30
67
|
? []
|
|
31
68
|
: options.toolNames ?? [...DEFAULT_REPL_TOOLS];
|
|
69
|
+
const environment = describeShellExecutionBackend(options.sandbox, options.hostConfig ?? {});
|
|
32
70
|
const tools = new Map();
|
|
33
71
|
let shell = requested.includes('bash')
|
|
34
72
|
? createShellManager({
|
|
@@ -41,20 +79,29 @@ export async function createReplToolset(options) {
|
|
|
41
79
|
if (shell) {
|
|
42
80
|
const shellManager = shell;
|
|
43
81
|
tools.set('bash', {
|
|
44
|
-
description:
|
|
82
|
+
description: describeBashTool(environment),
|
|
45
83
|
parameters: {
|
|
46
84
|
type: 'object',
|
|
47
85
|
properties: {
|
|
48
86
|
command: { type: 'string', description: 'Shell command to execute.' },
|
|
87
|
+
argv: {
|
|
88
|
+
type: 'array',
|
|
89
|
+
description: 'Command and arguments as a list, quoted by the runtime. '
|
|
90
|
+
+ 'Prefer this over `command` when any argument is data.',
|
|
91
|
+
},
|
|
49
92
|
timeoutMs: {
|
|
50
93
|
type: 'integer',
|
|
51
94
|
description: 'Wall-clock timeout in milliseconds (optional; overrides DC_HOST_SHELL_TIMEOUT_MS).',
|
|
52
95
|
},
|
|
53
96
|
},
|
|
54
|
-
required: ['command'],
|
|
55
97
|
},
|
|
56
98
|
execute: async (args, context) => {
|
|
57
|
-
const
|
|
99
|
+
const argv = Array.isArray(args.argv)
|
|
100
|
+
? args.argv.map((item) => String(item))
|
|
101
|
+
: undefined;
|
|
102
|
+
const command = argv && argv.length > 0
|
|
103
|
+
? quoteArgv(argv)
|
|
104
|
+
: String(args.command ?? args.arg1 ?? '');
|
|
58
105
|
const timeoutMs = typeof args.timeoutMs === 'number' && Number.isFinite(args.timeoutMs) && args.timeoutMs > 0
|
|
59
106
|
? args.timeoutMs
|
|
60
107
|
: undefined;
|
|
@@ -71,6 +118,7 @@ export async function createReplToolset(options) {
|
|
|
71
118
|
return {
|
|
72
119
|
tools,
|
|
73
120
|
catalog: buildToolCatalog(tools),
|
|
121
|
+
environment,
|
|
74
122
|
dispose: async () => {
|
|
75
123
|
if (shell) {
|
|
76
124
|
await shell.dispose();
|
package/dist/repl/toolset.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toolset.js","sourceRoot":"","sources":["../../src/repl/toolset.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"toolset.js","sourceRoot":"","sources":["../../src/repl/toolset.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,kBAAkB,EAClB,6BAA6B,GAG9B,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AAGpF,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,MAAM,CAAU,CAAC;AA0BpD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAAiC;IAChE,MAAM,SAAS,GAAG,WAAW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,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash-command completion for the REPL editor.
|
|
3
|
+
*
|
|
4
|
+
* Pi's `CombinedAutocompleteProvider` does the work: it matches commands by prefix
|
|
5
|
+
* and, where a base path is given, completes file paths too.
|
|
6
|
+
*
|
|
7
|
+
* The list is *not* what the CLI parses — `classifyReplInput` has its own switch and
|
|
8
|
+
* reads nothing from here — so the two drift, and a command that parses but is not
|
|
9
|
+
* listed is invisible to the user. `/reasoning` and `/show-reasoning` were exactly
|
|
10
|
+
* that. `tests/repl-tui-pickers.test.ts` now checks both directions: every advertised
|
|
11
|
+
* command must parse, and every command the parser accepts must be advertised (or be
|
|
12
|
+
* a deliberate alias).
|
|
13
|
+
*/
|
|
14
|
+
import { type AutocompleteProvider, type SlashCommand } from '@earendil-works/pi-tui';
|
|
15
|
+
/** The REPL's slash commands, with the argument each takes. */
|
|
16
|
+
export declare const REPL_COMMANDS: SlashCommand[];
|
|
17
|
+
/** Build the editor's autocomplete provider, with file completion under `cwd`. */
|
|
18
|
+
export declare function createReplAutocomplete(cwd: string): AutocompleteProvider;
|
|
19
|
+
//# sourceMappingURL=autocomplete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/autocomplete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,YAAY,EAClB,MAAM,wBAAwB,CAAC;AAEhC,+DAA+D;AAC/D,eAAO,MAAM,aAAa,EAAE,YAAY,EAoBvC,CAAC;AAEF,kFAAkF;AAClF,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,oBAAoB,CAExE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slash-command completion for the REPL editor.
|
|
3
|
+
*
|
|
4
|
+
* Pi's `CombinedAutocompleteProvider` does the work: it matches commands by prefix
|
|
5
|
+
* and, where a base path is given, completes file paths too.
|
|
6
|
+
*
|
|
7
|
+
* The list is *not* what the CLI parses — `classifyReplInput` has its own switch and
|
|
8
|
+
* reads nothing from here — so the two drift, and a command that parses but is not
|
|
9
|
+
* listed is invisible to the user. `/reasoning` and `/show-reasoning` were exactly
|
|
10
|
+
* that. `tests/repl-tui-pickers.test.ts` now checks both directions: every advertised
|
|
11
|
+
* command must parse, and every command the parser accepts must be advertised (or be
|
|
12
|
+
* a deliberate alias).
|
|
13
|
+
*/
|
|
14
|
+
import { CombinedAutocompleteProvider, } from '@earendil-works/pi-tui';
|
|
15
|
+
/** The REPL's slash commands, with the argument each takes. */
|
|
16
|
+
export const REPL_COMMANDS = [
|
|
17
|
+
{ name: 'goal', description: 'Run a DML goal', argumentHint: '<dml>' },
|
|
18
|
+
{ name: 'help', description: 'Show help' },
|
|
19
|
+
{ name: 'listing', description: 'List predicates', argumentHint: '[all|Name/Arity|prefix]' },
|
|
20
|
+
{ name: 'viz', description: 'Draw a skill as a diagram', argumentHint: '<entry> [presentation|spec]' },
|
|
21
|
+
{ name: 'export', description: 'Save the harness to a file', argumentHint: '[path]' },
|
|
22
|
+
{ name: 'model', description: 'Switch or show the active model', argumentHint: '[provider:id]' },
|
|
23
|
+
{ name: 'reasoning', description: 'Set the model reasoning level', argumentHint: '[off|minimal|low|medium|high|xhigh|max]' },
|
|
24
|
+
{ name: 'show-reasoning', description: 'How much reasoning to display', argumentHint: '[off|summary|full]' },
|
|
25
|
+
{ name: 'reset', description: 'Clear the harness' },
|
|
26
|
+
{ name: 'rollback', description: 'Restore the previous harness version' },
|
|
27
|
+
{ name: 'compact', description: 'Compact the conversation', argumentHint: '[instructions]' },
|
|
28
|
+
{ name: 'freeze', description: 'Refuse further edits' },
|
|
29
|
+
{ name: 'unfreeze', description: 'Allow edits again' },
|
|
30
|
+
{ name: 'params', description: 'Show session parameters' },
|
|
31
|
+
{ name: 'trace', description: 'Turn the execution trace on' },
|
|
32
|
+
{ name: 'notrace', description: 'Turn the execution trace off' },
|
|
33
|
+
{ name: 'show', description: 'Display a workspace image', argumentHint: '<path>' },
|
|
34
|
+
{ name: 'gen', description: 'Generate an image', argumentHint: '<prompt>' },
|
|
35
|
+
{ name: 'halt', description: 'Exit' },
|
|
36
|
+
];
|
|
37
|
+
/** Build the editor's autocomplete provider, with file completion under `cwd`. */
|
|
38
|
+
export function createReplAutocomplete(cwd) {
|
|
39
|
+
return new CombinedAutocompleteProvider(REPL_COMMANDS, cwd);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=autocomplete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autocomplete.js","sourceRoot":"","sources":["../../../src/repl/tui/autocomplete.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EACL,4BAA4B,GAG7B,MAAM,wBAAwB,CAAC;AAEhC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,aAAa,GAAmB;IAC3C,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE;IACtE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE;IAC1C,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,yBAAyB,EAAE;IAC5F,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,2BAA2B,EAAE,YAAY,EAAE,6BAA6B,EAAE;IACtG,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,4BAA4B,EAAE,YAAY,EAAE,QAAQ,EAAE;IACrF,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,iCAAiC,EAAE,YAAY,EAAE,eAAe,EAAE;IAChG,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,+BAA+B,EAAE,YAAY,EAAE,yCAAyC,EAAE;IAC5H,EAAE,IAAI,EAAE,gBAAgB,EAAE,WAAW,EAAE,+BAA+B,EAAE,YAAY,EAAE,oBAAoB,EAAE;IAC5G,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE;IACnD,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,sCAAsC,EAAE;IACzE,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,0BAA0B,EAAE,YAAY,EAAE,gBAAgB,EAAE;IAC5F,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;IACvD,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE;IACtD,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yBAAyB,EAAE;IAC1D,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,6BAA6B,EAAE;IAC7D,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,8BAA8B,EAAE;IAChE,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,2BAA2B,EAAE,YAAY,EAAE,QAAQ,EAAE;IAClF,EAAE,IAAI,EAAE,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,YAAY,EAAE,UAAU,EAAE;IAC3E,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE;CACtC,CAAC;AAEF,kFAAkF;AAClF,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,IAAI,4BAA4B,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component transcript for the fullscreen TUI.
|
|
3
|
+
*
|
|
4
|
+
* The plain/readline path keeps the line-based `TranscriptComponent`; the TUI
|
|
5
|
+
* needs a tree, because a tool call, a streamed answer and a code fence have to
|
|
6
|
+
* be *components* (so markdown can be re-rendered as text arrives, a tool pane can
|
|
7
|
+
* expand, and `ScrollView` can scroll a bounded document).
|
|
8
|
+
*
|
|
9
|
+
* Entries are either styled text lines (rendered at the current width, so a
|
|
10
|
+
* resize re-wraps them) or components rendered as-is.
|
|
11
|
+
*/
|
|
12
|
+
import { type Component } from '@earendil-works/pi-tui';
|
|
13
|
+
export type DocumentLineStyle = 'user' | 'steer';
|
|
14
|
+
/** A bounded component document: append-only, with one live (unterminated) line. */
|
|
15
|
+
export declare class TranscriptDocument implements Component {
|
|
16
|
+
private entries;
|
|
17
|
+
private pending;
|
|
18
|
+
private pendingStyle?;
|
|
19
|
+
private readonly maxEntries;
|
|
20
|
+
/** Called whenever content changes, so the TUI can schedule a render. */
|
|
21
|
+
onChange?: () => void;
|
|
22
|
+
constructor(maxEntries?: number);
|
|
23
|
+
private trim;
|
|
24
|
+
/** Append one styled line. Consecutive blank lines collapse. */
|
|
25
|
+
appendText(line: string, style?: DocumentLineStyle): void;
|
|
26
|
+
/** Alias for `appendText`, matching the line-based transcript's API. */
|
|
27
|
+
append(line: string, style?: DocumentLineStyle): void;
|
|
28
|
+
/**
|
|
29
|
+
* Append a component (a tool pane, markdown block, status notice).
|
|
30
|
+
*
|
|
31
|
+
* Components get a blank line above them unless the document already ends in one.
|
|
32
|
+
* Without it a tool call, its output and the next tool call read as one wall of
|
|
33
|
+
* text — the transcript has no other separation once the blocks are adjacent.
|
|
34
|
+
*/
|
|
35
|
+
appendComponent(component: Component): void;
|
|
36
|
+
/** Append terminal-image lines verbatim: they must not be wrapped or measured. */
|
|
37
|
+
appendImageLines(lines: string[]): void;
|
|
38
|
+
/** The live (not yet newline-terminated) line, as the line sink writes it. */
|
|
39
|
+
setPending(line: string, style?: DocumentLineStyle): void;
|
|
40
|
+
/** Whether anything has been written (used to separate user turns). */
|
|
41
|
+
isEmpty(): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* One string per entry. Kept for callers that only ask "is there output yet";
|
|
44
|
+
* the rendered text of a component is not available without a width.
|
|
45
|
+
*/
|
|
46
|
+
getLines(): string[];
|
|
47
|
+
clear(): void;
|
|
48
|
+
render(width: number): string[];
|
|
49
|
+
invalidate(): void;
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../../src/repl/tui/document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAGL,KAAK,SAAS,EACf,MAAM,wBAAwB,CAAC;AAIhC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AAkCjD,oFAAoF;AACpF,qBAAa,kBAAmB,YAAW,SAAS;IAClD,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,OAAO,CAAM;IACrB,OAAO,CAAC,YAAY,CAAC,CAAoB;IACzC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;gBAEV,UAAU,SAAO;IAI7B,OAAO,CAAC,IAAI;IAMZ,gEAAgE;IAChE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAUzD,wEAAwE;IACxE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAIrD;;;;;;OAMG;IACH,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,IAAI;IAW3C,kFAAkF;IAClF,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI;IAQvC,8EAA8E;IAC9E,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,iBAAiB,GAAG,IAAI;IAMzD,uEAAuE;IACvE,OAAO,IAAI,OAAO;IAIlB;;;OAGG;IACH,QAAQ,IAAI,MAAM,EAAE;IAKpB,KAAK,IAAI,IAAI;IAMb,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAiD/B,UAAU,IAAI,IAAI;CAKnB"}
|