@agenteer/stdlib 1.0.0-rc.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/README.md +98 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/context/context_curator.d.ts +115 -0
- package/dist/context/context_curator.d.ts.map +1 -0
- package/dist/context/context_curator.js +132 -0
- package/dist/context/context_curator.js.map +1 -0
- package/dist/humans/approval_gate.d.ts +82 -0
- package/dist/humans/approval_gate.d.ts.map +1 -0
- package/dist/humans/approval_gate.js +76 -0
- package/dist/humans/approval_gate.js.map +1 -0
- package/dist/humans/ask_user.d.ts +79 -0
- package/dist/humans/ask_user.d.ts.map +1 -0
- package/dist/humans/ask_user.js +101 -0
- package/dist/humans/ask_user.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +93 -0
- package/dist/index.js.map +1 -0
- package/dist/meta/cross_check.d.ts +96 -0
- package/dist/meta/cross_check.d.ts.map +1 -0
- package/dist/meta/cross_check.js +165 -0
- package/dist/meta/cross_check.js.map +1 -0
- package/dist/meta/judge_with_stripped_ctx.d.ts +75 -0
- package/dist/meta/judge_with_stripped_ctx.d.ts.map +1 -0
- package/dist/meta/judge_with_stripped_ctx.js +151 -0
- package/dist/meta/judge_with_stripped_ctx.js.map +1 -0
- package/dist/meta/parallel_fanout.d.ts +83 -0
- package/dist/meta/parallel_fanout.d.ts.map +1 -0
- package/dist/meta/parallel_fanout.js +120 -0
- package/dist/meta/parallel_fanout.js.map +1 -0
- package/dist/meta/repair_loop.d.ts +90 -0
- package/dist/meta/repair_loop.d.ts.map +1 -0
- package/dist/meta/repair_loop.js +230 -0
- package/dist/meta/repair_loop.js.map +1 -0
- package/dist/planner/default_planner.d.ts +88 -0
- package/dist/planner/default_planner.d.ts.map +1 -0
- package/dist/planner/default_planner.js +156 -0
- package/dist/planner/default_planner.js.map +1 -0
- package/dist/primitives/file_read.d.ts +60 -0
- package/dist/primitives/file_read.d.ts.map +1 -0
- package/dist/primitives/file_read.js +68 -0
- package/dist/primitives/file_read.js.map +1 -0
- package/dist/primitives/file_write.d.ts +60 -0
- package/dist/primitives/file_write.d.ts.map +1 -0
- package/dist/primitives/file_write.js +66 -0
- package/dist/primitives/file_write.js.map +1 -0
- package/dist/primitives/llm_call.d.ts +85 -0
- package/dist/primitives/llm_call.d.ts.map +1 -0
- package/dist/primitives/llm_call.js +99 -0
- package/dist/primitives/llm_call.js.map +1 -0
- package/dist/primitives/shell_exec.d.ts +66 -0
- package/dist/primitives/shell_exec.d.ts.map +1 -0
- package/dist/primitives/shell_exec.js +106 -0
- package/dist/primitives/shell_exec.js.map +1 -0
- package/dist/primitives/tool_call.d.ts +62 -0
- package/dist/primitives/tool_call.d.ts.map +1 -0
- package/dist/primitives/tool_call.js +69 -0
- package/dist/primitives/tool_call.js.map +1 -0
- package/dist/shared/capture.d.ts +34 -0
- package/dist/shared/capture.d.ts.map +1 -0
- package/dist/shared/capture.js +124 -0
- package/dist/shared/capture.js.map +1 -0
- package/dist/shared/ctx.d.ts +14 -0
- package/dist/shared/ctx.d.ts.map +1 -0
- package/dist/shared/ctx.js +48 -0
- package/dist/shared/ctx.js.map +1 -0
- package/dist/shared/index.d.ts +4 -0
- package/dist/shared/index.d.ts.map +1 -0
- package/dist/shared/index.js +4 -0
- package/dist/shared/index.js.map +1 -0
- package/dist/shared/validator.d.ts +47 -0
- package/dist/shared/validator.d.ts.map +1 -0
- package/dist/shared/validator.js +41 -0
- package/dist/shared/validator.js.map +1 -0
- package/dist/validators/compile.d.ts +83 -0
- package/dist/validators/compile.d.ts.map +1 -0
- package/dist/validators/compile.js +126 -0
- package/dist/validators/compile.js.map +1 -0
- package/dist/validators/json_schema_validate.d.ts +72 -0
- package/dist/validators/json_schema_validate.d.ts.map +1 -0
- package/dist/validators/json_schema_validate.js +85 -0
- package/dist/validators/json_schema_validate.js.map +1 -0
- package/dist/validators/regex_check.d.ts +64 -0
- package/dist/validators/regex_check.d.ts.map +1 -0
- package/dist/validators/regex_check.js +85 -0
- package/dist/validators/regex_check.js.map +1 -0
- package/dist/validators/test_run.d.ts +74 -0
- package/dist/validators/test_run.d.ts.map +1 -0
- package/dist/validators/test_run.js +149 -0
- package/dist/validators/test_run.js.map +1 -0
- package/dist/validators/typecheck.d.ts +61 -0
- package/dist/validators/typecheck.d.ts.map +1 -0
- package/dist/validators/typecheck.js +89 -0
- package/dist/validators/typecheck.js.map +1 -0
- package/package.json +61 -0
- package/src/context/context_curator.ts +154 -0
- package/src/humans/approval_gate.ts +101 -0
- package/src/humans/ask_user.ts +137 -0
- package/src/index.ts +149 -0
- package/src/meta/cross_check.ts +219 -0
- package/src/meta/judge_with_stripped_ctx.ts +171 -0
- package/src/meta/parallel_fanout.ts +142 -0
- package/src/meta/repair_loop.ts +267 -0
- package/src/planner/default_planner.ts +182 -0
- package/src/primitives/file_read.ts +82 -0
- package/src/primitives/file_write.ts +80 -0
- package/src/primitives/llm_call.ts +113 -0
- package/src/primitives/shell_exec.ts +122 -0
- package/src/primitives/tool_call.ts +84 -0
- package/src/shared/capture.ts +155 -0
- package/src/shared/ctx.ts +45 -0
- package/src/shared/index.ts +17 -0
- package/src/shared/validator.ts +51 -0
- package/src/validators/compile.ts +175 -0
- package/src/validators/json_schema_validate.ts +103 -0
- package/src/validators/regex_check.ts +107 -0
- package/src/validators/test_run.ts +199 -0
- package/src/validators/typecheck.ts +121 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-repair-loop` — meta-node that drives a validate →
|
|
3
|
+
* repair → validate cycle via ReplaceMe (sub-plan 03 §14).
|
|
4
|
+
*
|
|
5
|
+
* **ReplaceMe-first.** Per master plan ratified resolutions, the retry
|
|
6
|
+
* mechanism is data-driven convergence: each repair pass returns
|
|
7
|
+
* `replace_me` with a successor carrying the narrowed target. A bounded
|
|
8
|
+
* `max_iterations` ceiling exists only as a runaway backstop.
|
|
9
|
+
*
|
|
10
|
+
* Shape of one iteration:
|
|
11
|
+
* 1. Run the target node (via `SpawnChildren`).
|
|
12
|
+
* 2. Run the validator against the target's output.
|
|
13
|
+
* 3. If validator.verdict === "pass" → Output(final).
|
|
14
|
+
* If validator.verdict === "fail" and iter < ceiling →
|
|
15
|
+
* ReplaceMe(self with target_input augmented by the failing issues).
|
|
16
|
+
* Otherwise → Failed("repair_exhausted").
|
|
17
|
+
*
|
|
18
|
+
* This is the node that earns the framework's "self-obsolescence"
|
|
19
|
+
* pillar — it's where ReplaceMe pays rent in day-to-day workflows.
|
|
20
|
+
*/
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import { type Node } from "@agenteer/core";
|
|
23
|
+
declare const InputSchema: z.ZodObject<{
|
|
24
|
+
target_manifest_id: z.ZodString;
|
|
25
|
+
target_input: z.ZodUnknown;
|
|
26
|
+
validator_manifest_id: z.ZodString;
|
|
27
|
+
validator_input: z.ZodOptional<z.ZodUnknown>;
|
|
28
|
+
max_iterations: z.ZodDefault<z.ZodNumber>;
|
|
29
|
+
iteration: z.ZodDefault<z.ZodNumber>;
|
|
30
|
+
emit_as: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
declare const OutputSchema: z.ZodObject<{
|
|
33
|
+
verdict: z.ZodEnum<{
|
|
34
|
+
pass: "pass";
|
|
35
|
+
fail: "fail";
|
|
36
|
+
}>;
|
|
37
|
+
iterations: z.ZodNumber;
|
|
38
|
+
final_output: z.ZodUnknown;
|
|
39
|
+
last_issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
40
|
+
path: z.ZodOptional<z.ZodString>;
|
|
41
|
+
message: z.ZodString;
|
|
42
|
+
code: z.ZodOptional<z.ZodString>;
|
|
43
|
+
severity: z.ZodOptional<z.ZodEnum<{
|
|
44
|
+
error: "error";
|
|
45
|
+
warning: "warning";
|
|
46
|
+
}>>;
|
|
47
|
+
}, z.core.$strip>>>;
|
|
48
|
+
}, z.core.$strip>;
|
|
49
|
+
type Input = z.input<typeof InputSchema>;
|
|
50
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
51
|
+
export declare function repairLoopFactory(): Node<Input, Output>;
|
|
52
|
+
export declare const repairLoopManifest: {
|
|
53
|
+
manifest_version: 1;
|
|
54
|
+
id: string;
|
|
55
|
+
version: string;
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
required_actions: string[];
|
|
59
|
+
required_capabilities: {
|
|
60
|
+
tool_use: boolean;
|
|
61
|
+
vision: boolean;
|
|
62
|
+
structured_output: "any" | "native" | "text_parse";
|
|
63
|
+
min_context_tokens?: number | undefined;
|
|
64
|
+
};
|
|
65
|
+
dynamic_actions: boolean;
|
|
66
|
+
side_effects: {
|
|
67
|
+
writes_fs: boolean;
|
|
68
|
+
network: boolean;
|
|
69
|
+
mutates_ctx: boolean;
|
|
70
|
+
emits_ctx_variants: string[];
|
|
71
|
+
reads_ctx_variants: string[];
|
|
72
|
+
};
|
|
73
|
+
determinism: "deterministic" | "stochastic";
|
|
74
|
+
tags: string[];
|
|
75
|
+
author: string;
|
|
76
|
+
license: string;
|
|
77
|
+
input_schema?: unknown;
|
|
78
|
+
output_schema?: unknown;
|
|
79
|
+
dynamic_action_spec?: string | undefined;
|
|
80
|
+
homepage?: string | undefined;
|
|
81
|
+
repository?: string | undefined;
|
|
82
|
+
planner_hints?: {
|
|
83
|
+
cost_tier?: "cheap" | "medium" | "expensive" | undefined;
|
|
84
|
+
latency_tier?: "medium" | "fast" | "slow" | undefined;
|
|
85
|
+
typical_use?: string | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
sha256?: string | undefined;
|
|
88
|
+
};
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=repair_loop.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair_loop.d.ts","sourceRoot":"","sources":["../../src/meta/repair_loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,KAAK,IAAI,EAKV,MAAM,gBAAgB,CAAC;AAsBxB,QAAA,MAAM,WAAW;;;;;;;;iBAYf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;iBAchB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACzC,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAK3C,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAiKvD;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAC"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-repair-loop` — meta-node that drives a validate →
|
|
3
|
+
* repair → validate cycle via ReplaceMe (sub-plan 03 §14).
|
|
4
|
+
*
|
|
5
|
+
* **ReplaceMe-first.** Per master plan ratified resolutions, the retry
|
|
6
|
+
* mechanism is data-driven convergence: each repair pass returns
|
|
7
|
+
* `replace_me` with a successor carrying the narrowed target. A bounded
|
|
8
|
+
* `max_iterations` ceiling exists only as a runaway backstop.
|
|
9
|
+
*
|
|
10
|
+
* Shape of one iteration:
|
|
11
|
+
* 1. Run the target node (via `SpawnChildren`).
|
|
12
|
+
* 2. Run the validator against the target's output.
|
|
13
|
+
* 3. If validator.verdict === "pass" → Output(final).
|
|
14
|
+
* If validator.verdict === "fail" and iter < ceiling →
|
|
15
|
+
* ReplaceMe(self with target_input augmented by the failing issues).
|
|
16
|
+
* Otherwise → Failed("repair_exhausted").
|
|
17
|
+
*
|
|
18
|
+
* This is the node that earns the framework's "self-obsolescence"
|
|
19
|
+
* pillar — it's where ReplaceMe pays rent in day-to-day workflows.
|
|
20
|
+
*/
|
|
21
|
+
import { z } from "zod";
|
|
22
|
+
import { asArtifact, makeManifest, } from "@agenteer/core";
|
|
23
|
+
import { ValidatorOutputSchema } from "../shared/index.js";
|
|
24
|
+
const MANIFEST = makeManifest({
|
|
25
|
+
id: "@agenteer/node-repair-loop",
|
|
26
|
+
name: "repair_loop",
|
|
27
|
+
description: "ReplaceMe-first validate/repair loop. Max-iterations is a runaway backstop; progress is data-driven.",
|
|
28
|
+
determinism: "stochastic",
|
|
29
|
+
required_actions: [],
|
|
30
|
+
dynamic_actions: true,
|
|
31
|
+
// We spawn whichever target + validator the caller names.
|
|
32
|
+
dynamic_action_spec: "spawn:${input.target_manifest_id}, spawn:${input.validator_manifest_id}",
|
|
33
|
+
tags: ["meta"],
|
|
34
|
+
side_effects: {
|
|
35
|
+
writes_fs: false,
|
|
36
|
+
network: false,
|
|
37
|
+
mutates_ctx: true,
|
|
38
|
+
emits_ctx_variants: ["artifact.repair_loop.result"],
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const InputSchema = z.object({
|
|
42
|
+
target_manifest_id: z.string().min(1),
|
|
43
|
+
target_input: z.unknown(),
|
|
44
|
+
validator_manifest_id: z.string().min(1),
|
|
45
|
+
validator_input: z.unknown().optional(),
|
|
46
|
+
max_iterations: z.number().int().min(1).max(32).default(4),
|
|
47
|
+
iteration: z.number().int().min(0).default(0),
|
|
48
|
+
/**
|
|
49
|
+
* Optional ctx tag: final result is emitted as an Artifact under this
|
|
50
|
+
* name so downstream nodes can read it via ctx.
|
|
51
|
+
*/
|
|
52
|
+
emit_as: z.string().optional(),
|
|
53
|
+
});
|
|
54
|
+
const OutputSchema = z.object({
|
|
55
|
+
verdict: z.enum(["pass", "fail"]),
|
|
56
|
+
iterations: z.number().int().nonnegative(),
|
|
57
|
+
final_output: z.unknown(),
|
|
58
|
+
last_issues: z
|
|
59
|
+
.array(z.object({
|
|
60
|
+
path: z.string().optional(),
|
|
61
|
+
message: z.string(),
|
|
62
|
+
code: z.string().optional(),
|
|
63
|
+
severity: z.enum(["error", "warning"]).optional(),
|
|
64
|
+
}))
|
|
65
|
+
.optional(),
|
|
66
|
+
});
|
|
67
|
+
const TARGET_CORRELATION = "repair.target";
|
|
68
|
+
const VALIDATOR_CORRELATION = "repair.validator";
|
|
69
|
+
export function repairLoopFactory() {
|
|
70
|
+
return {
|
|
71
|
+
manifest: MANIFEST,
|
|
72
|
+
inputSchema: InputSchema,
|
|
73
|
+
outputSchema: OutputSchema,
|
|
74
|
+
ctx: [],
|
|
75
|
+
model: null,
|
|
76
|
+
async execute(input) {
|
|
77
|
+
const i = input.original;
|
|
78
|
+
const iter = i.iteration ?? 0;
|
|
79
|
+
const maxIter = i.max_iterations ?? 4;
|
|
80
|
+
if (!input.children) {
|
|
81
|
+
// No children yet → we're on entry; spawn the target.
|
|
82
|
+
return {
|
|
83
|
+
kind: "spawn_children",
|
|
84
|
+
join: { mode: "all" },
|
|
85
|
+
children: [
|
|
86
|
+
{
|
|
87
|
+
manifest_id: i.target_manifest_id,
|
|
88
|
+
input: i.target_input,
|
|
89
|
+
correlation: TARGET_CORRELATION,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
// Re-entry. Two shapes to handle:
|
|
95
|
+
// (a) only target-result present → spawn validator
|
|
96
|
+
// (b) target + validator present → decide
|
|
97
|
+
const target = input.children.find((c) => c.correlation === TARGET_CORRELATION);
|
|
98
|
+
const validator = input.children.find((c) => c.correlation === VALIDATOR_CORRELATION);
|
|
99
|
+
if (!target) {
|
|
100
|
+
return {
|
|
101
|
+
kind: "failed",
|
|
102
|
+
reason: "repair_loop: no target child on re-entry",
|
|
103
|
+
retryable: false,
|
|
104
|
+
evidence: { verdict: "fail" },
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
if (target.result.kind !== "output") {
|
|
108
|
+
return {
|
|
109
|
+
kind: "failed",
|
|
110
|
+
reason: `repair_loop: target failed (${target.result.reason ?? target.result.kind})`,
|
|
111
|
+
retryable: false,
|
|
112
|
+
details: { target: target.result },
|
|
113
|
+
evidence: { verdict: "fail" },
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const targetOutput = target.result.value;
|
|
117
|
+
if (!validator) {
|
|
118
|
+
// Spawn the validator with the target's output merged in.
|
|
119
|
+
const validatorInput = buildValidatorInput(i.validator_input, targetOutput);
|
|
120
|
+
return {
|
|
121
|
+
kind: "spawn_children",
|
|
122
|
+
join: { mode: "all" },
|
|
123
|
+
children: [
|
|
124
|
+
{
|
|
125
|
+
manifest_id: i.target_manifest_id,
|
|
126
|
+
input: i.target_input,
|
|
127
|
+
correlation: TARGET_CORRELATION,
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
manifest_id: i.validator_manifest_id,
|
|
131
|
+
input: validatorInput,
|
|
132
|
+
correlation: VALIDATOR_CORRELATION,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// Validator present — interpret.
|
|
138
|
+
if (validator.result.kind !== "output") {
|
|
139
|
+
return {
|
|
140
|
+
kind: "failed",
|
|
141
|
+
reason: `repair_loop: validator failed (${validator.result.reason ?? validator.result.kind})`,
|
|
142
|
+
retryable: false,
|
|
143
|
+
evidence: { verdict: "fail" },
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
const vParsed = ValidatorOutputSchema.safeParse(validator.result.value);
|
|
147
|
+
if (!vParsed.success) {
|
|
148
|
+
return {
|
|
149
|
+
kind: "failed",
|
|
150
|
+
reason: `repair_loop: validator output not a ValidatorOutput shape`,
|
|
151
|
+
retryable: false,
|
|
152
|
+
details: { issues: vParsed.error.issues },
|
|
153
|
+
evidence: { verdict: "fail" },
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
const vout = vParsed.data;
|
|
157
|
+
if (vout.verdict === "pass") {
|
|
158
|
+
const base = {
|
|
159
|
+
verdict: "pass",
|
|
160
|
+
iterations: iter,
|
|
161
|
+
final_output: targetOutput,
|
|
162
|
+
};
|
|
163
|
+
const patch = i.emit_as
|
|
164
|
+
? {
|
|
165
|
+
set: {
|
|
166
|
+
[i.emit_as]: asArtifact({ verdict: "pass", iterations: iter, output: targetOutput }, { media_type: "application/json" }),
|
|
167
|
+
},
|
|
168
|
+
}
|
|
169
|
+
: undefined;
|
|
170
|
+
return {
|
|
171
|
+
kind: "output",
|
|
172
|
+
value: base,
|
|
173
|
+
...(patch ? { ctx_patch: patch } : {}),
|
|
174
|
+
evidence: { verdict: "pass" },
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
// Validator failed.
|
|
178
|
+
if (iter + 1 >= maxIter) {
|
|
179
|
+
return {
|
|
180
|
+
kind: "output",
|
|
181
|
+
value: {
|
|
182
|
+
verdict: "fail",
|
|
183
|
+
iterations: iter + 1,
|
|
184
|
+
final_output: targetOutput,
|
|
185
|
+
last_issues: vout.issues,
|
|
186
|
+
},
|
|
187
|
+
evidence: { verdict: "fail" },
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
// Repair step: ReplaceMe self with `iteration + 1`, feeding the
|
|
191
|
+
// validator's issues back into target_input as a hint.
|
|
192
|
+
const successor = {
|
|
193
|
+
manifest_id: MANIFEST.id,
|
|
194
|
+
// Runtime preserves the frame's correlation on ReplaceMe; this
|
|
195
|
+
// value is only used for lineage tracking on the successor's
|
|
196
|
+
// own spawn event.
|
|
197
|
+
correlation: `repair-iter-${iter + 1}`,
|
|
198
|
+
input: {
|
|
199
|
+
...i,
|
|
200
|
+
iteration: iter + 1,
|
|
201
|
+
target_input: {
|
|
202
|
+
...(typeof i.target_input === "object" && i.target_input !== null
|
|
203
|
+
? i.target_input
|
|
204
|
+
: { original: i.target_input }),
|
|
205
|
+
prior_issues: vout.issues,
|
|
206
|
+
prior_iteration: iter,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
kind: "replace_me",
|
|
212
|
+
reason: `repair_iteration:${iter + 1}:${vout.issues.length}_issues`,
|
|
213
|
+
successor,
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
export const repairLoopManifest = MANIFEST;
|
|
219
|
+
function buildValidatorInput(baseValidatorInput, targetOutput) {
|
|
220
|
+
// If the caller didn't specify, pass the target output through as
|
|
221
|
+
// `candidate` — a reasonable default for validators that inspect output.
|
|
222
|
+
if (baseValidatorInput === undefined || baseValidatorInput === null) {
|
|
223
|
+
return { candidate: targetOutput };
|
|
224
|
+
}
|
|
225
|
+
if (typeof baseValidatorInput === "object") {
|
|
226
|
+
return { ...baseValidatorInput, candidate: targetOutput };
|
|
227
|
+
}
|
|
228
|
+
return baseValidatorInput;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=repair_loop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"repair_loop.js","sourceRoot":"","sources":["../../src/meta/repair_loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,UAAU,EACV,YAAY,GAMb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAwB,MAAM,oBAAoB,CAAC;AAEjF,MAAM,QAAQ,GAAiB,YAAY,CAAC;IAC1C,EAAE,EAAE,4BAA4B;IAChC,IAAI,EAAE,aAAa;IACnB,WAAW,EACT,sGAAsG;IACxG,WAAW,EAAE,YAAY;IACzB,gBAAgB,EAAE,EAAE;IACpB,eAAe,EAAE,IAAI;IACrB,0DAA0D;IAC1D,mBAAmB,EAAE,yEAAyE;IAC9F,IAAI,EAAE,CAAC,MAAM,CAAC;IACd,YAAY,EAAE;QACZ,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,KAAK;QACd,WAAW,EAAE,IAAI;QACjB,kBAAkB,EAAE,CAAC,6BAA6B,CAAC;KACpD;CACF,CAAC,CA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C3B,YAAqB;IAErB,kEAAkE;IAClE,yEAAyE;IACzE,IAAI,kBAAkB,KAAK,SAAS,IAAI,kBAAkB,KAAK,IAAI,EAAE,CAAC;QACpE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;IACrC,CAAC;IACD,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAC3C,OAAO,EAAE,GAAI,kBAA8C,EAAE,SAAS,EAAE,YAAY,EAAE,CAAC;IACzF,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-default-planner` — LLM-driven plan composer (sub-plan 03 §17).
|
|
3
|
+
*
|
|
4
|
+
* **Returns a plan as DATA**, not as `SpawnChildren` (master plan ratified
|
|
5
|
+
* resolution). This enables:
|
|
6
|
+
* - Replay: a plan is a value you can serialize, review, and diff.
|
|
7
|
+
* - Human approval: pair with `approval_gate` to require sign-off before exec.
|
|
8
|
+
* - Judge review: `judge_with_stripped_ctx` can score the plan.
|
|
9
|
+
* - Swapping planners: another node consumes the plan and spawns.
|
|
10
|
+
*
|
|
11
|
+
* The node emits the plan as an Artifact via `ctx.set(asArtifact(...))`
|
|
12
|
+
* (uses R3-A) so downstream nodes see it via their context slice.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { type Node } from "@agenteer/core";
|
|
16
|
+
declare const InputSchema: z.ZodObject<{
|
|
17
|
+
goal: z.ZodString;
|
|
18
|
+
available_manifests: z.ZodArray<z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
description: z.ZodString;
|
|
22
|
+
required_actions: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
23
|
+
}, z.core.$strip>>;
|
|
24
|
+
model_id: z.ZodString;
|
|
25
|
+
emit_as: z.ZodDefault<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
declare const OutputSchema: z.ZodObject<{
|
|
28
|
+
plan: z.ZodObject<{
|
|
29
|
+
goal: z.ZodString;
|
|
30
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
manifest_id: z.ZodString;
|
|
33
|
+
input: z.ZodUnknown;
|
|
34
|
+
rationale: z.ZodOptional<z.ZodString>;
|
|
35
|
+
depends_on: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
36
|
+
attenuate: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
model: z.ZodString;
|
|
41
|
+
method: z.ZodEnum<{
|
|
42
|
+
native: "native";
|
|
43
|
+
text_parse: "text_parse";
|
|
44
|
+
mock: "mock";
|
|
45
|
+
}>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
type Input = z.input<typeof InputSchema>;
|
|
48
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
49
|
+
export declare function defaultPlannerFactory(): Node<Input, Output>;
|
|
50
|
+
export declare const defaultPlannerManifest: {
|
|
51
|
+
manifest_version: 1;
|
|
52
|
+
id: string;
|
|
53
|
+
version: string;
|
|
54
|
+
name: string;
|
|
55
|
+
description: string;
|
|
56
|
+
required_actions: string[];
|
|
57
|
+
required_capabilities: {
|
|
58
|
+
tool_use: boolean;
|
|
59
|
+
vision: boolean;
|
|
60
|
+
structured_output: "any" | "native" | "text_parse";
|
|
61
|
+
min_context_tokens?: number | undefined;
|
|
62
|
+
};
|
|
63
|
+
dynamic_actions: boolean;
|
|
64
|
+
side_effects: {
|
|
65
|
+
writes_fs: boolean;
|
|
66
|
+
network: boolean;
|
|
67
|
+
mutates_ctx: boolean;
|
|
68
|
+
emits_ctx_variants: string[];
|
|
69
|
+
reads_ctx_variants: string[];
|
|
70
|
+
};
|
|
71
|
+
determinism: "deterministic" | "stochastic";
|
|
72
|
+
tags: string[];
|
|
73
|
+
author: string;
|
|
74
|
+
license: string;
|
|
75
|
+
input_schema?: unknown;
|
|
76
|
+
output_schema?: unknown;
|
|
77
|
+
dynamic_action_spec?: string | undefined;
|
|
78
|
+
homepage?: string | undefined;
|
|
79
|
+
repository?: string | undefined;
|
|
80
|
+
planner_hints?: {
|
|
81
|
+
cost_tier?: "cheap" | "medium" | "expensive" | undefined;
|
|
82
|
+
latency_tier?: "medium" | "fast" | "slow" | undefined;
|
|
83
|
+
typical_use?: string | undefined;
|
|
84
|
+
} | undefined;
|
|
85
|
+
sha256?: string | undefined;
|
|
86
|
+
};
|
|
87
|
+
export {};
|
|
88
|
+
//# sourceMappingURL=default_planner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default_planner.d.ts","sourceRoot":"","sources":["../../src/planner/default_planner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAGL,KAAK,IAAI,EAKV,MAAM,gBAAgB,CAAC;AAmCxB,QAAA,MAAM,WAAW;;;;;;;;;;iBAqBf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;iBAIhB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACzC,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C,wBAAgB,qBAAqB,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CA8D3D;AAED,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-default-planner` — LLM-driven plan composer (sub-plan 03 §17).
|
|
3
|
+
*
|
|
4
|
+
* **Returns a plan as DATA**, not as `SpawnChildren` (master plan ratified
|
|
5
|
+
* resolution). This enables:
|
|
6
|
+
* - Replay: a plan is a value you can serialize, review, and diff.
|
|
7
|
+
* - Human approval: pair with `approval_gate` to require sign-off before exec.
|
|
8
|
+
* - Judge review: `judge_with_stripped_ctx` can score the plan.
|
|
9
|
+
* - Swapping planners: another node consumes the plan and spawns.
|
|
10
|
+
*
|
|
11
|
+
* The node emits the plan as an Artifact via `ctx.set(asArtifact(...))`
|
|
12
|
+
* (uses R3-A) so downstream nodes see it via their context slice.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import { asArtifact, makeManifest, } from "@agenteer/core";
|
|
16
|
+
const MANIFEST = makeManifest({
|
|
17
|
+
id: "@agenteer/node-default-planner",
|
|
18
|
+
name: "default_planner",
|
|
19
|
+
description: "LLM-driven planner. Returns a plan (as data + ctx artifact); does NOT spawn the plan itself.",
|
|
20
|
+
determinism: "stochastic",
|
|
21
|
+
required_actions: [],
|
|
22
|
+
dynamic_actions: true,
|
|
23
|
+
dynamic_action_spec: "model:${input.model_id}",
|
|
24
|
+
tags: ["meta", "planner"],
|
|
25
|
+
side_effects: {
|
|
26
|
+
writes_fs: false,
|
|
27
|
+
network: true,
|
|
28
|
+
mutates_ctx: true,
|
|
29
|
+
emits_ctx_variants: ["artifact.plan"],
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const PlanStepSchema = z.object({
|
|
33
|
+
id: z.string().min(1),
|
|
34
|
+
manifest_id: z.string().min(1),
|
|
35
|
+
input: z.unknown(),
|
|
36
|
+
rationale: z.string().optional(),
|
|
37
|
+
depends_on: z.array(z.string()).default([]),
|
|
38
|
+
attenuate: z.array(z.string()).optional(),
|
|
39
|
+
});
|
|
40
|
+
const PlanSchema = z.object({
|
|
41
|
+
goal: z.string(),
|
|
42
|
+
steps: z.array(PlanStepSchema).min(1),
|
|
43
|
+
notes: z.string().optional(),
|
|
44
|
+
});
|
|
45
|
+
const InputSchema = z.object({
|
|
46
|
+
goal: z.string().min(1),
|
|
47
|
+
/**
|
|
48
|
+
* Manifests the planner is allowed to include. Structural filter —
|
|
49
|
+
* the planner picks from this set and only this set. No semantic
|
|
50
|
+
* "free-for-all"; matches the "planner filters structurally first"
|
|
51
|
+
* invariant.
|
|
52
|
+
*/
|
|
53
|
+
available_manifests: z
|
|
54
|
+
.array(z.object({
|
|
55
|
+
id: z.string().min(1),
|
|
56
|
+
name: z.string(),
|
|
57
|
+
description: z.string(),
|
|
58
|
+
required_actions: z.array(z.string()).default([]),
|
|
59
|
+
}))
|
|
60
|
+
.min(1),
|
|
61
|
+
model_id: z.string().min(1),
|
|
62
|
+
/** Tag under which the plan is emitted to ctx (default: "plan"). */
|
|
63
|
+
emit_as: z.string().default("plan"),
|
|
64
|
+
});
|
|
65
|
+
const OutputSchema = z.object({
|
|
66
|
+
plan: PlanSchema,
|
|
67
|
+
model: z.string(),
|
|
68
|
+
method: z.enum(["native", "text_parse", "mock"]),
|
|
69
|
+
});
|
|
70
|
+
export function defaultPlannerFactory() {
|
|
71
|
+
return {
|
|
72
|
+
manifest: MANIFEST,
|
|
73
|
+
inputSchema: InputSchema,
|
|
74
|
+
outputSchema: OutputSchema,
|
|
75
|
+
ctx: [],
|
|
76
|
+
model: null,
|
|
77
|
+
async execute(input, handle) {
|
|
78
|
+
const i = input.original;
|
|
79
|
+
const emitAs = i.emit_as ?? "plan";
|
|
80
|
+
const systemPrompt = buildSystemPrompt();
|
|
81
|
+
const userPrompt = buildUserPrompt(i);
|
|
82
|
+
try {
|
|
83
|
+
const res = await handle.callModel({
|
|
84
|
+
model_id: i.model_id,
|
|
85
|
+
prompt: userPrompt,
|
|
86
|
+
system: systemPrompt,
|
|
87
|
+
schema: PlanSchema,
|
|
88
|
+
});
|
|
89
|
+
const plan = res.value;
|
|
90
|
+
// Defensive: reject plans whose steps reference manifests outside
|
|
91
|
+
// the allowed set. The kernel would refuse at spawn anyway, but
|
|
92
|
+
// we fail fast here so the planner sees feedback as a `Failed`
|
|
93
|
+
// that a repair_loop can digest.
|
|
94
|
+
const allowed = new Set(i.available_manifests.map((m) => m.id));
|
|
95
|
+
const illegal = plan.steps.filter((s) => !allowed.has(s.manifest_id));
|
|
96
|
+
if (illegal.length > 0) {
|
|
97
|
+
return {
|
|
98
|
+
kind: "failed",
|
|
99
|
+
reason: `planner chose manifests outside available_manifests: ${illegal.map((s) => s.manifest_id).join(", ")}`,
|
|
100
|
+
retryable: true,
|
|
101
|
+
evidence: { verdict: "fail" },
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
kind: "output",
|
|
106
|
+
value: { plan, model: res.model, method: res.method },
|
|
107
|
+
ctx_patch: {
|
|
108
|
+
set: {
|
|
109
|
+
[emitAs]: asArtifact(plan, {
|
|
110
|
+
media_type: "application/json",
|
|
111
|
+
schema_ref: "@agenteer/default_planner.plan.v1",
|
|
112
|
+
}),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
evidence: { verdict: "pass" },
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
const reason = err instanceof Error ? err.message : String(err);
|
|
120
|
+
return {
|
|
121
|
+
kind: "failed",
|
|
122
|
+
reason,
|
|
123
|
+
retryable: /timeout|rate.?limit|5\d\d|structured_output_exhausted/i.test(reason),
|
|
124
|
+
evidence: { verdict: "fail" },
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export const defaultPlannerManifest = MANIFEST;
|
|
131
|
+
function buildSystemPrompt() {
|
|
132
|
+
return [
|
|
133
|
+
"You are a software-engineering planner.",
|
|
134
|
+
"You produce a JSON plan whose steps can be executed by the given manifests.",
|
|
135
|
+
"Constraints:",
|
|
136
|
+
"- Every step.manifest_id MUST be drawn from the provided `available_manifests` list.",
|
|
137
|
+
"- Every step.id is unique within the plan.",
|
|
138
|
+
"- `depends_on` references earlier step ids only; no cycles.",
|
|
139
|
+
"- `input` must match what the named manifest expects.",
|
|
140
|
+
"- Keep plans minimal — no speculative steps.",
|
|
141
|
+
].join("\n");
|
|
142
|
+
}
|
|
143
|
+
function buildUserPrompt(input) {
|
|
144
|
+
const catalog = input.available_manifests
|
|
145
|
+
.map((m) => `- ${m.id} (${m.name}): ${m.description}`)
|
|
146
|
+
.join("\n");
|
|
147
|
+
return [
|
|
148
|
+
`Goal: ${input.goal}`,
|
|
149
|
+
``,
|
|
150
|
+
`Available manifests:`,
|
|
151
|
+
catalog,
|
|
152
|
+
``,
|
|
153
|
+
`Return JSON matching: { goal, steps: [{ id, manifest_id, input, rationale?, depends_on[] }], notes? }`,
|
|
154
|
+
].join("\n");
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=default_planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default_planner.js","sourceRoot":"","sources":["../../src/planner/default_planner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,UAAU,EACV,YAAY,GAMb,MAAM,gBAAgB,CAAC;AAExB,MAAM,QAAQ,GAAiB,YAAY,CAAC;IAC1C,EAAE,EAAE,gCAAgC;IACpC,IAAI,EAAE,iBAAiB;IACvB,WAAW,EACT,8FAA8F;IAChG,WAAW,EAAE,YAAY;IACzB,gBAAgB,EAAE,EAAE;IACpB,eAAe,EAAE,IAAI;IACrB,mBAAmB,EAAE,yBAAyB;IAC9C,IAAI,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;IACzB,YAAY,EAAE;QACZ,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,IAAI;QACjB,kBAAkB,EAAE,CAAC,eAAe,CAAC;KACtC;CACF,CAAC,CAAC;AAEH,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;I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AE,EAAE,OAAO,EAAE,MAAM,EAAE;iBAC9B,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,QAAQ,CAAC;AAE/C,SAAS,iBAAiB;IACxB,OAAO;QACL,yCAAyC;QACzC,6EAA6E;QAC7E,cAAc;QACd,sFAAsF;QACtF,4CAA4C;QAC5C,6DAA6D;QAC7D,uDAAuD;QACvD,8CAA8C;KAC/C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CAAC,KAAY;IACnC,MAAM,OAAO,GAAG,KAAK,CAAC,mBAAmB;SACtC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC;SACrD,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO;QACL,SAAS,KAAK,CAAC,IAAI,EAAE;QACrB,EAAE;QACF,sBAAsB;QACtB,OAAO;QACP,EAAE;QACF,uGAAuG;KACxG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@agenteer/node-file-read` — permissioned filesystem read (sub-plan 03 §3).
|
|
3
|
+
*
|
|
4
|
+
* Deterministic. Declares `fs.read:*`; actual scope attenuation happens at
|
|
5
|
+
* spawn time. At dispatch the permission kernel synthesizes the concrete
|
|
6
|
+
* `fs.read:<path>` capability and checks against `granted`.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { type Node } from "@agenteer/core";
|
|
10
|
+
declare const InputSchema: z.ZodObject<{
|
|
11
|
+
path: z.ZodString;
|
|
12
|
+
emit_as: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, z.core.$strip>;
|
|
14
|
+
declare const OutputSchema: z.ZodObject<{
|
|
15
|
+
path: z.ZodString;
|
|
16
|
+
content: z.ZodString;
|
|
17
|
+
bytes: z.ZodNumber;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type Input = z.infer<typeof InputSchema>;
|
|
20
|
+
type Output = z.infer<typeof OutputSchema>;
|
|
21
|
+
export declare function fileReadFactory(): Node<Input, Output>;
|
|
22
|
+
export declare const fileReadManifest: {
|
|
23
|
+
manifest_version: 1;
|
|
24
|
+
id: string;
|
|
25
|
+
version: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
required_actions: string[];
|
|
29
|
+
required_capabilities: {
|
|
30
|
+
tool_use: boolean;
|
|
31
|
+
vision: boolean;
|
|
32
|
+
structured_output: "any" | "native" | "text_parse";
|
|
33
|
+
min_context_tokens?: number | undefined;
|
|
34
|
+
};
|
|
35
|
+
dynamic_actions: boolean;
|
|
36
|
+
side_effects: {
|
|
37
|
+
writes_fs: boolean;
|
|
38
|
+
network: boolean;
|
|
39
|
+
mutates_ctx: boolean;
|
|
40
|
+
emits_ctx_variants: string[];
|
|
41
|
+
reads_ctx_variants: string[];
|
|
42
|
+
};
|
|
43
|
+
determinism: "deterministic" | "stochastic";
|
|
44
|
+
tags: string[];
|
|
45
|
+
author: string;
|
|
46
|
+
license: string;
|
|
47
|
+
input_schema?: unknown;
|
|
48
|
+
output_schema?: unknown;
|
|
49
|
+
dynamic_action_spec?: string | undefined;
|
|
50
|
+
homepage?: string | undefined;
|
|
51
|
+
repository?: string | undefined;
|
|
52
|
+
planner_hints?: {
|
|
53
|
+
cost_tier?: "cheap" | "medium" | "expensive" | undefined;
|
|
54
|
+
latency_tier?: "medium" | "fast" | "slow" | undefined;
|
|
55
|
+
typical_use?: string | undefined;
|
|
56
|
+
} | undefined;
|
|
57
|
+
sha256?: string | undefined;
|
|
58
|
+
};
|
|
59
|
+
export {};
|
|
60
|
+
//# sourceMappingURL=file_read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file_read.d.ts","sourceRoot":"","sources":["../../src/primitives/file_read.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAEL,KAAK,IAAI,EAKV,MAAM,gBAAgB,CAAC;AAqBxB,QAAA,MAAM,WAAW;;;iBAIf,CAAC;AAEH,QAAA,MAAM,YAAY;;;;iBAIhB,CAAC;AAEH,KAAK,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AACzC,KAAK,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAE3C,wBAAgB,eAAe,IAAI,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CA2BrD;AAED,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAW,CAAC"}
|