@agimon-ai/po-plan 0.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/apiContracts.cjs +57 -0
- package/dist/apiContracts.cjs.map +1 -0
- package/dist/apiContracts.d.mts +53 -0
- package/dist/apiContracts.d.mts.map +1 -0
- package/dist/apiContracts.mjs +52 -0
- package/dist/apiContracts.mjs.map +1 -0
- package/dist/config-BC-Tou05.mjs +25 -0
- package/dist/config-BC-Tou05.mjs.map +1 -0
- package/dist/config-D0iTexGm.cjs +42 -0
- package/dist/config-D0iTexGm.cjs.map +1 -0
- package/dist/config-DWo57HKB.d.mts +13 -0
- package/dist/config-DWo57HKB.d.mts.map +1 -0
- package/dist/config.cjs +12 -0
- package/dist/config.d.mts +2 -0
- package/dist/config.mjs +2 -0
- package/dist/extensions/mcp-ui.mjs +46 -0
- package/dist/extensions/mcp-ui.mjs.map +1 -0
- package/dist/extensions/mcp.cjs +93 -0
- package/dist/extensions/mcp.cjs.map +1 -0
- package/dist/extensions/mcp.d.mts +5 -0
- package/dist/extensions/mcp.d.mts.map +1 -0
- package/dist/extensions/mcp.mjs +88 -0
- package/dist/extensions/mcp.mjs.map +1 -0
- package/dist/extensions/server.cjs +1025 -0
- package/dist/extensions/server.cjs.map +1 -0
- package/dist/extensions/server.d.mts +5 -0
- package/dist/extensions/server.d.mts.map +1 -0
- package/dist/extensions/server.mjs +993 -0
- package/dist/extensions/server.mjs.map +1 -0
- package/dist/extensions/web.mjs +861 -0
- package/dist/extensions/web.mjs.map +1 -0
- package/dist/fableFlow-BDc8a__Y.mjs +214 -0
- package/dist/fableFlow-BDc8a__Y.mjs.map +1 -0
- package/dist/fableFlow-CzfrLPzJ.cjs +279 -0
- package/dist/fableFlow-CzfrLPzJ.cjs.map +1 -0
- package/dist/fableFlow.cjs +13 -0
- package/dist/fableFlow.d.mts +2 -0
- package/dist/fableFlow.mjs +2 -0
- package/dist/index-C8e7IK60.d.mts +68 -0
- package/dist/index-C8e7IK60.d.mts.map +1 -0
- package/dist/index-C9QBG9cw.d.mts +51 -0
- package/dist/index-C9QBG9cw.d.mts.map +1 -0
- package/dist/index.cjs +31 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +4 -0
- package/dist/logSinkTelemetry.cjs +42 -0
- package/dist/logSinkTelemetry.cjs.map +1 -0
- package/dist/logSinkTelemetry.d.mts +33 -0
- package/dist/logSinkTelemetry.d.mts.map +1 -0
- package/dist/logSinkTelemetry.mjs +40 -0
- package/dist/logSinkTelemetry.mjs.map +1 -0
- package/dist/planConfig.cjs +190 -0
- package/dist/planConfig.cjs.map +1 -0
- package/dist/planConfig.d.mts +47 -0
- package/dist/planConfig.d.mts.map +1 -0
- package/dist/planConfig.mjs +186 -0
- package/dist/planConfig.mjs.map +1 -0
- package/dist/prompts-DUVUPNZd.cjs +103 -0
- package/dist/prompts-DUVUPNZd.cjs.map +1 -0
- package/dist/prompts-DnVJGtEC.mjs +68 -0
- package/dist/prompts-DnVJGtEC.mjs.map +1 -0
- package/dist/prompts.cjs +8 -0
- package/dist/prompts.d.mts +2 -0
- package/dist/prompts.mjs +2 -0
- package/llms.txt +9 -0
- package/package.json +164 -0
- package/src/prompts/po-use-plan/SKILL.md +44 -0
- package/src/types/planApi.ts +125 -0
- package/src/types/planSettings.ts +78 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
let node_buffer = require("node:buffer");
|
|
2
|
+
//#region src/services/fableFlow/index.ts
|
|
3
|
+
const FABLE_PROVIDER_SOURCE = "@agimon-ai/po-team";
|
|
4
|
+
const FABLE_PLAN_REQUESTER = "@agimon-ai/po-plan";
|
|
5
|
+
const FABLE_PLAN_RUNTIME = "claude";
|
|
6
|
+
const FABLE_PLAN_MODEL = "fable";
|
|
7
|
+
const FABLE_PLAN_PROFILE = "claude/fable-plan-v1";
|
|
8
|
+
const MAX_FABLE_PACKET_BYTES = 32768;
|
|
9
|
+
const MAX_FABLE_TEXT_BYTES = 4096;
|
|
10
|
+
const MAX_FABLE_ARRAY_ITEMS = 24;
|
|
11
|
+
const SECRET_PATTERNS = [
|
|
12
|
+
/(?:api[_-]?key|access[_-]?token|client[_-]?secret|password|private[_-]?key|authorization|bearer)\s*[:=]/iu,
|
|
13
|
+
/-----BEGIN [A-Z ]*PRIVATE KEY-----/u,
|
|
14
|
+
/\bsk-[A-Za-z0-9_-]{16,}\b/u,
|
|
15
|
+
/\bgh[pousr]_[A-Za-z0-9_]{16,}\b/u
|
|
16
|
+
];
|
|
17
|
+
const CONTROL_CHARACTER_MAX = 31;
|
|
18
|
+
const DELETE_CHARACTER = 127;
|
|
19
|
+
const MAX_SOURCE_PATH_LENGTH = 512;
|
|
20
|
+
function isRecord(value) {
|
|
21
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
function hasControlCharacter(value) {
|
|
24
|
+
for (const character of value) {
|
|
25
|
+
const code = character.codePointAt(0);
|
|
26
|
+
if (code !== void 0 && (code <= CONTROL_CHARACTER_MAX || code === DELETE_CHARACTER)) return true;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
function containsSuspectedCredential(value) {
|
|
31
|
+
return SECRET_PATTERNS.some((pattern) => pattern.test(value));
|
|
32
|
+
}
|
|
33
|
+
function boundedText(value, field, required = true) {
|
|
34
|
+
if (typeof value !== "string") throw new Error(`${field} must be a string.`);
|
|
35
|
+
const text = value.trim();
|
|
36
|
+
if (!text && required) throw new Error(`${field} must not be empty.`);
|
|
37
|
+
if (node_buffer.Buffer.byteLength(text, "utf8") > 4096 || hasControlCharacter(text)) throw new Error(`${field} exceeds the bounded Fable text limit or contains control characters.`);
|
|
38
|
+
if (containsSuspectedCredential(text)) throw new Error(`${field} appears to contain a credential.`);
|
|
39
|
+
return text;
|
|
40
|
+
}
|
|
41
|
+
function boundedList(value, field, required = true) {
|
|
42
|
+
if (!Array.isArray(value)) throw new Error(`${field} must be an array.`);
|
|
43
|
+
if (value.length > 24) throw new Error(`${field} exceeds the bounded item limit.`);
|
|
44
|
+
const items = value.map((item, index) => boundedText(item, `${field}[${index}]`));
|
|
45
|
+
if (required && items.length === 0) throw new Error(`${field} must contain at least one item.`);
|
|
46
|
+
return items;
|
|
47
|
+
}
|
|
48
|
+
function boundedPath(value, field) {
|
|
49
|
+
if (typeof value !== "string") throw new Error(`${field} must be a string.`);
|
|
50
|
+
const sourcePath = value.trim();
|
|
51
|
+
if (!sourcePath || sourcePath.length > MAX_SOURCE_PATH_LENGTH || hasControlCharacter(sourcePath)) throw new Error(`${field} is not a safe source path.`);
|
|
52
|
+
if (containsSuspectedCredential(sourcePath)) throw new Error(`${field} appears to contain a credential.`);
|
|
53
|
+
return sourcePath;
|
|
54
|
+
}
|
|
55
|
+
function boundedFindings(value) {
|
|
56
|
+
if (!Array.isArray(value)) throw new Error("verifiedFindings must be an array.");
|
|
57
|
+
if (value.length > 24) throw new Error("verifiedFindings exceeds the bounded item limit.");
|
|
58
|
+
return value.map((item, index) => {
|
|
59
|
+
if (!isRecord(item)) throw new Error(`verifiedFindings[${index}] must be an object.`);
|
|
60
|
+
if (Object.keys(item).some((key) => key !== "path" && key !== "finding")) throw new Error(`verifiedFindings[${index}] contains an unsupported field.`);
|
|
61
|
+
return {
|
|
62
|
+
path: boundedPath(item.path, `verifiedFindings[${index}].path`),
|
|
63
|
+
finding: boundedText(item.finding, `verifiedFindings[${index}].finding`)
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function assertAllowedKeys(value, keys, field) {
|
|
68
|
+
const allowed = new Set(keys);
|
|
69
|
+
const unexpected = Object.keys(value).find((key) => !allowed.has(key));
|
|
70
|
+
if (unexpected) throw new Error(`${field} contains unsupported field '${unexpected}'.`);
|
|
71
|
+
}
|
|
72
|
+
function sanitizeFablePacket(value) {
|
|
73
|
+
if (!isRecord(value)) throw new Error("Fable packet must be an object.");
|
|
74
|
+
assertAllowedKeys(value, [
|
|
75
|
+
"goal",
|
|
76
|
+
"constraints",
|
|
77
|
+
"decisions",
|
|
78
|
+
"verifiedFindings",
|
|
79
|
+
"inferredFindings",
|
|
80
|
+
"unresolvedQuestions",
|
|
81
|
+
"currentPlan"
|
|
82
|
+
], "Fable packet");
|
|
83
|
+
const packet = {
|
|
84
|
+
goal: boundedList(value.goal, "goal"),
|
|
85
|
+
constraints: boundedList(value.constraints, "constraints", false),
|
|
86
|
+
decisions: boundedList(value.decisions, "decisions", false),
|
|
87
|
+
verifiedFindings: boundedFindings(value.verifiedFindings),
|
|
88
|
+
inferredFindings: boundedList(value.inferredFindings, "inferredFindings", false),
|
|
89
|
+
unresolvedQuestions: boundedList(value.unresolvedQuestions, "unresolvedQuestions", false),
|
|
90
|
+
...value.currentPlan === void 0 ? {} : { currentPlan: boundedText(value.currentPlan, "currentPlan", false) }
|
|
91
|
+
};
|
|
92
|
+
if (node_buffer.Buffer.byteLength(JSON.stringify(packet), "utf8") > 32768) throw new Error("Fable packet exceeds the bounded packet size.");
|
|
93
|
+
return packet;
|
|
94
|
+
}
|
|
95
|
+
function safeResult(result) {
|
|
96
|
+
if (containsSuspectedCredential([result.draft, result.review].filter((value) => value !== void 0).join("\n"))) return {
|
|
97
|
+
operationId: result.operationId,
|
|
98
|
+
status: "failed",
|
|
99
|
+
stage: "failed",
|
|
100
|
+
durationMs: result.durationMs,
|
|
101
|
+
errorCode: "unsafe_output"
|
|
102
|
+
};
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
function timedOutResult(operationId, startedAt) {
|
|
106
|
+
return {
|
|
107
|
+
operationId,
|
|
108
|
+
status: "timed_out",
|
|
109
|
+
stage: "interrupted",
|
|
110
|
+
durationMs: Math.max(0, Date.now() - startedAt),
|
|
111
|
+
errorCode: "timeout"
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
function createFablePlanFlow(options) {
|
|
115
|
+
const newOperationId = options.newOperationId ?? (() => crypto.randomUUID());
|
|
116
|
+
let active;
|
|
117
|
+
const cancel = (reason = "Fable operation cancelled.") => {
|
|
118
|
+
const current = active;
|
|
119
|
+
if (!current) return;
|
|
120
|
+
if (!current.cancelSent) {
|
|
121
|
+
current.cancelSent = true;
|
|
122
|
+
try {
|
|
123
|
+
options.broker?.cancel(current.operationId, reason);
|
|
124
|
+
} catch (error) {
|
|
125
|
+
options.onError?.(error);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
current.controller.abort(new Error(reason));
|
|
129
|
+
};
|
|
130
|
+
const run = async (value, signal) => {
|
|
131
|
+
if (active) throw new Error("A Fable operation is already active for this session.");
|
|
132
|
+
if (!options.isAuthorized()) throw new Error("The Fable capability profile is not authorized.");
|
|
133
|
+
const packet = sanitizeFablePacket(value);
|
|
134
|
+
const operationId = `fable-${newOperationId()}`;
|
|
135
|
+
const startedAt = Date.now();
|
|
136
|
+
const controller = new AbortController();
|
|
137
|
+
active = {
|
|
138
|
+
operationId,
|
|
139
|
+
controller,
|
|
140
|
+
cancelSent: false
|
|
141
|
+
};
|
|
142
|
+
options.onStage?.("draft");
|
|
143
|
+
const parentAbort = () => controller.abort(signal?.reason);
|
|
144
|
+
if (signal) {
|
|
145
|
+
signal.addEventListener("abort", parentAbort, { once: true });
|
|
146
|
+
if (signal.aborted) parentAbort();
|
|
147
|
+
}
|
|
148
|
+
const brokerRequest = {
|
|
149
|
+
requester: FABLE_PLAN_REQUESTER,
|
|
150
|
+
operationId,
|
|
151
|
+
runtime: FABLE_PLAN_RUNTIME,
|
|
152
|
+
model: FABLE_PLAN_MODEL,
|
|
153
|
+
profile: FABLE_PLAN_PROFILE,
|
|
154
|
+
packet
|
|
155
|
+
};
|
|
156
|
+
let timeout;
|
|
157
|
+
let timeoutTriggered = false;
|
|
158
|
+
try {
|
|
159
|
+
if (!options.broker) return timedOutResult(operationId, startedAt);
|
|
160
|
+
const brokerResult = options.broker.start(brokerRequest, controller.signal);
|
|
161
|
+
const cancelledResult = new Promise((resolve) => {
|
|
162
|
+
const onAbort = () => {
|
|
163
|
+
if (timeoutTriggered) return;
|
|
164
|
+
resolve({
|
|
165
|
+
operationId,
|
|
166
|
+
status: "cancelled",
|
|
167
|
+
stage: "cancelled",
|
|
168
|
+
durationMs: Math.max(0, Date.now() - startedAt),
|
|
169
|
+
errorCode: "cancelled"
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
controller.signal.addEventListener("abort", onAbort, { once: true });
|
|
173
|
+
});
|
|
174
|
+
const timeoutResult = options.timeoutMs === void 0 ? void 0 : new Promise((resolve) => {
|
|
175
|
+
timeout = setTimeout(() => {
|
|
176
|
+
timeoutTriggered = true;
|
|
177
|
+
cancel("Fable operation timed out.");
|
|
178
|
+
resolve(timedOutResult(operationId, startedAt));
|
|
179
|
+
}, options.timeoutMs);
|
|
180
|
+
});
|
|
181
|
+
const safe = safeResult(timeoutResult === void 0 ? await Promise.race([brokerResult, cancelledResult]) : await Promise.race([
|
|
182
|
+
brokerResult,
|
|
183
|
+
timeoutResult,
|
|
184
|
+
cancelledResult
|
|
185
|
+
]));
|
|
186
|
+
options.onStage?.(safe.status === "completed" ? "completed" : safe.status === "cancelled" ? "cancelled" : safe.stage);
|
|
187
|
+
return safe;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
options.onError?.(error);
|
|
190
|
+
const failure = {
|
|
191
|
+
operationId,
|
|
192
|
+
status: "failed",
|
|
193
|
+
stage: "failed",
|
|
194
|
+
durationMs: Math.max(0, Date.now() - startedAt),
|
|
195
|
+
errorCode: "unavailable"
|
|
196
|
+
};
|
|
197
|
+
options.onStage?.("failed");
|
|
198
|
+
return failure;
|
|
199
|
+
} finally {
|
|
200
|
+
if (timeout) clearTimeout(timeout);
|
|
201
|
+
if (signal) signal.removeEventListener("abort", parentAbort);
|
|
202
|
+
active = void 0;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
return {
|
|
206
|
+
run,
|
|
207
|
+
cancel,
|
|
208
|
+
isActive: () => active !== void 0
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
//#endregion
|
|
212
|
+
Object.defineProperty(exports, "FABLE_PLAN_MODEL", {
|
|
213
|
+
enumerable: true,
|
|
214
|
+
get: function() {
|
|
215
|
+
return FABLE_PLAN_MODEL;
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
Object.defineProperty(exports, "FABLE_PLAN_PROFILE", {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function() {
|
|
221
|
+
return FABLE_PLAN_PROFILE;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
Object.defineProperty(exports, "FABLE_PLAN_REQUESTER", {
|
|
225
|
+
enumerable: true,
|
|
226
|
+
get: function() {
|
|
227
|
+
return FABLE_PLAN_REQUESTER;
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
Object.defineProperty(exports, "FABLE_PLAN_RUNTIME", {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function() {
|
|
233
|
+
return FABLE_PLAN_RUNTIME;
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(exports, "FABLE_PROVIDER_SOURCE", {
|
|
237
|
+
enumerable: true,
|
|
238
|
+
get: function() {
|
|
239
|
+
return FABLE_PROVIDER_SOURCE;
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
Object.defineProperty(exports, "MAX_FABLE_ARRAY_ITEMS", {
|
|
243
|
+
enumerable: true,
|
|
244
|
+
get: function() {
|
|
245
|
+
return MAX_FABLE_ARRAY_ITEMS;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
Object.defineProperty(exports, "MAX_FABLE_PACKET_BYTES", {
|
|
249
|
+
enumerable: true,
|
|
250
|
+
get: function() {
|
|
251
|
+
return MAX_FABLE_PACKET_BYTES;
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
Object.defineProperty(exports, "MAX_FABLE_TEXT_BYTES", {
|
|
255
|
+
enumerable: true,
|
|
256
|
+
get: function() {
|
|
257
|
+
return MAX_FABLE_TEXT_BYTES;
|
|
258
|
+
}
|
|
259
|
+
});
|
|
260
|
+
Object.defineProperty(exports, "containsSuspectedCredential", {
|
|
261
|
+
enumerable: true,
|
|
262
|
+
get: function() {
|
|
263
|
+
return containsSuspectedCredential;
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
Object.defineProperty(exports, "createFablePlanFlow", {
|
|
267
|
+
enumerable: true,
|
|
268
|
+
get: function() {
|
|
269
|
+
return createFablePlanFlow;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
Object.defineProperty(exports, "sanitizeFablePacket", {
|
|
273
|
+
enumerable: true,
|
|
274
|
+
get: function() {
|
|
275
|
+
return sanitizeFablePacket;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
//# sourceMappingURL=fableFlow-CzfrLPzJ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fableFlow-CzfrLPzJ.cjs","names":["Buffer"],"sources":["../src/services/fableFlow/index.ts"],"sourcesContent":["import { Buffer } from 'node:buffer';\n\nexport const FABLE_PROVIDER_SOURCE = '@agimon-ai/po-team';\nexport const FABLE_PLAN_REQUESTER = '@agimon-ai/po-plan';\nexport const FABLE_PLAN_RUNTIME = 'claude';\nexport const FABLE_PLAN_MODEL = 'fable';\nexport const FABLE_PLAN_PROFILE = 'claude/fable-plan-v1';\nexport const MAX_FABLE_PACKET_BYTES = 32 * 1024;\nexport const MAX_FABLE_TEXT_BYTES = 4 * 1024;\nexport const MAX_FABLE_ARRAY_ITEMS = 24;\n\nconst SECRET_PATTERNS = [\n /(?:api[_-]?key|access[_-]?token|client[_-]?secret|password|private[_-]?key|authorization|bearer)\\s*[:=]/iu,\n /-----BEGIN [A-Z ]*PRIVATE KEY-----/u,\n /\\bsk-[A-Za-z0-9_-]{16,}\\b/u,\n /\\bgh[pousr]_[A-Za-z0-9_]{16,}\\b/u,\n];\nconst CONTROL_CHARACTER_MAX = 31;\nconst DELETE_CHARACTER = 127;\nconst MAX_SOURCE_PATH_LENGTH = 512;\n\nexport interface FablePlanFinding {\n path: string;\n finding: string;\n}\n\nexport interface FablePlanPacket {\n goal: string[];\n constraints: string[];\n decisions: string[];\n verifiedFindings: FablePlanFinding[];\n inferredFindings: string[];\n unresolvedQuestions: string[];\n currentPlan?: string;\n}\n\nexport type FablePlanStatus = 'completed' | 'failed' | 'timed_out' | 'cancelled' | 'interrupted';\nexport type FablePlanStage = 'draft' | 'review' | 'completed' | 'failed' | 'cancelled' | 'interrupted';\n\nexport interface FablePlanResult {\n operationId: string;\n status: FablePlanStatus;\n stage: FablePlanStage;\n draft?: string;\n review?: string;\n draftRunId?: string;\n reviewRunId?: string;\n durationMs: number;\n errorCode?: string;\n}\n\nexport interface FablePlanRequest {\n requester: typeof FABLE_PLAN_REQUESTER;\n operationId: string;\n runtime: typeof FABLE_PLAN_RUNTIME;\n model: typeof FABLE_PLAN_MODEL;\n profile: typeof FABLE_PLAN_PROFILE;\n packet: FablePlanPacket;\n}\n\nexport interface FablePlanBroker {\n start(request: FablePlanRequest, signal: AbortSignal): Promise<FablePlanResult>;\n cancel(operationId: string, reason: string): void;\n}\n\nexport interface FableFlowOptions {\n broker?: FablePlanBroker;\n isAuthorized: () => boolean;\n /** Supplies operation ids. Injected so a test can pin them. */\n newOperationId?: () => string;\n timeoutMs?: number;\n onStage?: (stage: FableStage) => void;\n onError?: (error: unknown) => void;\n}\n\nexport type FableStage = 'idle' | 'draft' | 'review' | 'completed' | 'failed' | 'cancelled' | 'interrupted';\n\nexport interface FablePlanFlow {\n run(value: unknown, signal?: AbortSignal): Promise<FablePlanResult>;\n cancel(reason?: string): void;\n isActive(): boolean;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction hasControlCharacter(value: string): boolean {\n for (const character of value) {\n const code = character.codePointAt(0);\n if (code !== undefined && (code <= CONTROL_CHARACTER_MAX || code === DELETE_CHARACTER)) return true;\n }\n return false;\n}\n\nexport function containsSuspectedCredential(value: string): boolean {\n return SECRET_PATTERNS.some((pattern) => pattern.test(value));\n}\n\nfunction boundedText(value: unknown, field: string, required = true): string {\n if (typeof value !== 'string') throw new Error(`${field} must be a string.`);\n const text = value.trim();\n if (!text && required) throw new Error(`${field} must not be empty.`);\n if (Buffer.byteLength(text, 'utf8') > MAX_FABLE_TEXT_BYTES || hasControlCharacter(text)) {\n throw new Error(`${field} exceeds the bounded Fable text limit or contains control characters.`);\n }\n if (containsSuspectedCredential(text)) throw new Error(`${field} appears to contain a credential.`);\n return text;\n}\n\nfunction boundedList(value: unknown, field: string, required = true): string[] {\n if (!Array.isArray(value)) throw new Error(`${field} must be an array.`);\n if (value.length > MAX_FABLE_ARRAY_ITEMS) throw new Error(`${field} exceeds the bounded item limit.`);\n const items = value.map((item, index) => boundedText(item, `${field}[${index}]`));\n if (required && items.length === 0) throw new Error(`${field} must contain at least one item.`);\n return items;\n}\n\nfunction boundedPath(value: unknown, field: string): string {\n if (typeof value !== 'string') throw new Error(`${field} must be a string.`);\n const sourcePath = value.trim();\n if (!sourcePath || sourcePath.length > MAX_SOURCE_PATH_LENGTH || hasControlCharacter(sourcePath)) {\n throw new Error(`${field} is not a safe source path.`);\n }\n if (containsSuspectedCredential(sourcePath)) throw new Error(`${field} appears to contain a credential.`);\n return sourcePath;\n}\n\nfunction boundedFindings(value: unknown): FablePlanFinding[] {\n if (!Array.isArray(value)) throw new Error('verifiedFindings must be an array.');\n if (value.length > MAX_FABLE_ARRAY_ITEMS) throw new Error('verifiedFindings exceeds the bounded item limit.');\n return value.map((item, index) => {\n if (!isRecord(item)) throw new Error(`verifiedFindings[${index}] must be an object.`);\n const keys = Object.keys(item);\n if (keys.some((key) => key !== 'path' && key !== 'finding')) {\n throw new Error(`verifiedFindings[${index}] contains an unsupported field.`);\n }\n return {\n path: boundedPath(item.path, `verifiedFindings[${index}].path`),\n finding: boundedText(item.finding, `verifiedFindings[${index}].finding`),\n };\n });\n}\n\nfunction assertAllowedKeys(value: Record<string, unknown>, keys: readonly string[], field: string): void {\n const allowed = new Set(keys);\n const unexpected = Object.keys(value).find((key) => !allowed.has(key));\n if (unexpected) throw new Error(`${field} contains unsupported field '${unexpected}'.`);\n}\n\nexport function sanitizeFablePacket(value: unknown): FablePlanPacket {\n if (!isRecord(value)) throw new Error('Fable packet must be an object.');\n assertAllowedKeys(\n value,\n ['goal', 'constraints', 'decisions', 'verifiedFindings', 'inferredFindings', 'unresolvedQuestions', 'currentPlan'],\n 'Fable packet',\n );\n const packet: FablePlanPacket = {\n goal: boundedList(value.goal, 'goal'),\n constraints: boundedList(value.constraints, 'constraints', false),\n decisions: boundedList(value.decisions, 'decisions', false),\n verifiedFindings: boundedFindings(value.verifiedFindings),\n inferredFindings: boundedList(value.inferredFindings, 'inferredFindings', false),\n unresolvedQuestions: boundedList(value.unresolvedQuestions, 'unresolvedQuestions', false),\n ...(value.currentPlan === undefined ? {} : { currentPlan: boundedText(value.currentPlan, 'currentPlan', false) }),\n };\n if (Buffer.byteLength(JSON.stringify(packet), 'utf8') > MAX_FABLE_PACKET_BYTES) {\n throw new Error('Fable packet exceeds the bounded packet size.');\n }\n return packet;\n}\n\nfunction safeResult(result: FablePlanResult): FablePlanResult {\n const output = [result.draft, result.review].filter((value): value is string => value !== undefined).join('\\n');\n if (containsSuspectedCredential(output)) {\n return {\n operationId: result.operationId,\n status: 'failed',\n stage: 'failed',\n durationMs: result.durationMs,\n errorCode: 'unsafe_output',\n };\n }\n return result;\n}\n\nfunction timedOutResult(operationId: string, startedAt: number): FablePlanResult {\n return {\n operationId,\n status: 'timed_out',\n stage: 'interrupted',\n durationMs: Math.max(0, Date.now() - startedAt),\n errorCode: 'timeout',\n };\n}\n\nexport function createFablePlanFlow(options: FableFlowOptions): FablePlanFlow {\n const newOperationId = options.newOperationId ?? (() => crypto.randomUUID());\n let active:\n | {\n operationId: string;\n controller: AbortController;\n cancelSent: boolean;\n }\n | undefined;\n\n const cancel = (reason = 'Fable operation cancelled.'): void => {\n const current = active;\n if (!current) return;\n if (!current.cancelSent) {\n current.cancelSent = true;\n try {\n options.broker?.cancel(current.operationId, reason);\n } catch (error) {\n options.onError?.(error);\n }\n }\n current.controller.abort(new Error(reason));\n };\n\n const run = async (value: unknown, signal?: AbortSignal): Promise<FablePlanResult> => {\n if (active) throw new Error('A Fable operation is already active for this session.');\n if (!options.isAuthorized()) throw new Error('The Fable capability profile is not authorized.');\n const packet = sanitizeFablePacket(value);\n const operationId = `fable-${newOperationId()}`;\n const startedAt = Date.now();\n const controller = new AbortController();\n active = { operationId, controller, cancelSent: false };\n options.onStage?.('draft');\n\n const parentAbort = (): void => controller.abort(signal?.reason);\n if (signal) {\n signal.addEventListener('abort', parentAbort, { once: true });\n if (signal.aborted) parentAbort();\n }\n\n const brokerRequest: FablePlanRequest = {\n requester: FABLE_PLAN_REQUESTER,\n operationId,\n runtime: FABLE_PLAN_RUNTIME,\n model: FABLE_PLAN_MODEL,\n profile: FABLE_PLAN_PROFILE,\n packet,\n };\n let timeout: ReturnType<typeof setTimeout> | undefined;\n let timeoutTriggered = false;\n try {\n if (!options.broker) return timedOutResult(operationId, startedAt);\n const brokerResult = options.broker.start(brokerRequest, controller.signal);\n const cancelledResult = new Promise<FablePlanResult>((resolve) => {\n const onAbort = (): void => {\n if (timeoutTriggered) return;\n resolve({\n operationId,\n status: 'cancelled',\n stage: 'cancelled',\n durationMs: Math.max(0, Date.now() - startedAt),\n errorCode: 'cancelled',\n });\n };\n controller.signal.addEventListener('abort', onAbort, { once: true });\n });\n const timeoutResult =\n options.timeoutMs === undefined\n ? undefined\n : new Promise<FablePlanResult>((resolve) => {\n timeout = setTimeout(() => {\n timeoutTriggered = true;\n cancel('Fable operation timed out.');\n resolve(timedOutResult(operationId, startedAt));\n }, options.timeoutMs);\n });\n const result =\n timeoutResult === undefined\n ? await Promise.race([brokerResult, cancelledResult])\n : await Promise.race([brokerResult, timeoutResult, cancelledResult]);\n const safe = safeResult(result);\n options.onStage?.(\n safe.status === 'completed' ? 'completed' : safe.status === 'cancelled' ? 'cancelled' : safe.stage,\n );\n return safe;\n } catch (error) {\n options.onError?.(error);\n const failure: FablePlanResult = {\n operationId,\n status: 'failed',\n stage: 'failed',\n durationMs: Math.max(0, Date.now() - startedAt),\n errorCode: 'unavailable',\n };\n options.onStage?.('failed');\n return failure;\n } finally {\n if (timeout) clearTimeout(timeout);\n if (signal) signal.removeEventListener('abort', parentAbort);\n active = undefined;\n }\n };\n\n return {\n run,\n cancel,\n isActive: () => active !== undefined,\n };\n}\n"],"mappings":";;AAEA,MAAa,wBAAwB;AACrC,MAAa,uBAAuB;AACpC,MAAa,qBAAqB;AAClC,MAAa,mBAAmB;AAChC,MAAa,qBAAqB;AAClC,MAAa,yBAAyB;AACtC,MAAa,uBAAuB;AACpC,MAAa,wBAAwB;AAErC,MAAM,kBAAkB;CACtB;CACA;CACA;CACA;AACF;AACA,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AACzB,MAAM,yBAAyB;AAgE/B,SAAS,SAAS,OAAkD;CAClE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC5E;AAEA,SAAS,oBAAoB,OAAwB;CACnD,KAAK,MAAM,aAAa,OAAO;EAC7B,MAAM,OAAO,UAAU,YAAY,CAAC;EACpC,IAAI,SAAS,KAAA,MAAc,QAAQ,yBAAyB,SAAS,mBAAmB,OAAO;CACjG;CACA,OAAO;AACT;AAEA,SAAgB,4BAA4B,OAAwB;CAClE,OAAO,gBAAgB,MAAM,YAAY,QAAQ,KAAK,KAAK,CAAC;AAC9D;AAEA,SAAS,YAAY,OAAgB,OAAe,WAAW,MAAc;CAC3E,IAAI,OAAO,UAAU,UAAU,MAAM,IAAI,MAAM,GAAG,MAAM,mBAAmB;CAC3E,MAAM,OAAO,MAAM,KAAK;CACxB,IAAI,CA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,OAAO,oBAAoB,SAAS,WAAW;GAC3D,SAAS,KAAA;EACX;CACF;CAEA,OAAO;EACL;EACA;EACA,gBAAgB,WAAW,KAAA;CAC7B;AACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_fableFlow = require("./fableFlow-CzfrLPzJ.cjs");
|
|
3
|
+
exports.FABLE_PLAN_MODEL = require_fableFlow.FABLE_PLAN_MODEL;
|
|
4
|
+
exports.FABLE_PLAN_PROFILE = require_fableFlow.FABLE_PLAN_PROFILE;
|
|
5
|
+
exports.FABLE_PLAN_REQUESTER = require_fableFlow.FABLE_PLAN_REQUESTER;
|
|
6
|
+
exports.FABLE_PLAN_RUNTIME = require_fableFlow.FABLE_PLAN_RUNTIME;
|
|
7
|
+
exports.FABLE_PROVIDER_SOURCE = require_fableFlow.FABLE_PROVIDER_SOURCE;
|
|
8
|
+
exports.MAX_FABLE_ARRAY_ITEMS = require_fableFlow.MAX_FABLE_ARRAY_ITEMS;
|
|
9
|
+
exports.MAX_FABLE_PACKET_BYTES = require_fableFlow.MAX_FABLE_PACKET_BYTES;
|
|
10
|
+
exports.MAX_FABLE_TEXT_BYTES = require_fableFlow.MAX_FABLE_TEXT_BYTES;
|
|
11
|
+
exports.containsSuspectedCredential = require_fableFlow.containsSuspectedCredential;
|
|
12
|
+
exports.createFablePlanFlow = require_fableFlow.createFablePlanFlow;
|
|
13
|
+
exports.sanitizeFablePacket = require_fableFlow.sanitizeFablePacket;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as MAX_FABLE_PACKET_BYTES, a as FABLE_PROVIDER_SOURCE, b as createFablePlanFlow, c as FablePlanFinding, d as FablePlanRequest, f as FablePlanResult, g as MAX_FABLE_ARRAY_ITEMS, h as FableStage, i as FABLE_PLAN_RUNTIME, l as FablePlanFlow, m as FablePlanStatus, n as FABLE_PLAN_PROFILE, o as FableFlowOptions, p as FablePlanStage, r as FABLE_PLAN_REQUESTER, s as FablePlanBroker, t as FABLE_PLAN_MODEL, u as FablePlanPacket, v as MAX_FABLE_TEXT_BYTES, x as sanitizeFablePacket, y as containsSuspectedCredential } from "./index-C8e7IK60.mjs";
|
|
2
|
+
export { FABLE_PLAN_MODEL, FABLE_PLAN_PROFILE, FABLE_PLAN_REQUESTER, FABLE_PLAN_RUNTIME, FABLE_PROVIDER_SOURCE, FableFlowOptions, FablePlanBroker, FablePlanFinding, FablePlanFlow, FablePlanPacket, FablePlanRequest, FablePlanResult, FablePlanStage, FablePlanStatus, FableStage, MAX_FABLE_ARRAY_ITEMS, MAX_FABLE_PACKET_BYTES, MAX_FABLE_TEXT_BYTES, containsSuspectedCredential, createFablePlanFlow, sanitizeFablePacket };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as FABLE_PROVIDER_SOURCE, c as MAX_FABLE_TEXT_BYTES, d as sanitizeFablePacket, i as FABLE_PLAN_RUNTIME, l as containsSuspectedCredential, n as FABLE_PLAN_PROFILE, o as MAX_FABLE_ARRAY_ITEMS, r as FABLE_PLAN_REQUESTER, s as MAX_FABLE_PACKET_BYTES, t as FABLE_PLAN_MODEL, u as createFablePlanFlow } from "./fableFlow-BDc8a__Y.mjs";
|
|
2
|
+
export { FABLE_PLAN_MODEL, FABLE_PLAN_PROFILE, FABLE_PLAN_REQUESTER, FABLE_PLAN_RUNTIME, FABLE_PROVIDER_SOURCE, MAX_FABLE_ARRAY_ITEMS, MAX_FABLE_PACKET_BYTES, MAX_FABLE_TEXT_BYTES, containsSuspectedCredential, createFablePlanFlow, sanitizeFablePacket };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
//#region src/services/fableFlow/index.d.ts
|
|
2
|
+
declare const FABLE_PROVIDER_SOURCE = "@agimon-ai/po-team";
|
|
3
|
+
declare const FABLE_PLAN_REQUESTER = "@agimon-ai/po-plan";
|
|
4
|
+
declare const FABLE_PLAN_RUNTIME = "claude";
|
|
5
|
+
declare const FABLE_PLAN_MODEL = "fable";
|
|
6
|
+
declare const FABLE_PLAN_PROFILE = "claude/fable-plan-v1";
|
|
7
|
+
declare const MAX_FABLE_PACKET_BYTES: number;
|
|
8
|
+
declare const MAX_FABLE_TEXT_BYTES: number;
|
|
9
|
+
declare const MAX_FABLE_ARRAY_ITEMS = 24;
|
|
10
|
+
interface FablePlanFinding {
|
|
11
|
+
path: string;
|
|
12
|
+
finding: string;
|
|
13
|
+
}
|
|
14
|
+
interface FablePlanPacket {
|
|
15
|
+
goal: string[];
|
|
16
|
+
constraints: string[];
|
|
17
|
+
decisions: string[];
|
|
18
|
+
verifiedFindings: FablePlanFinding[];
|
|
19
|
+
inferredFindings: string[];
|
|
20
|
+
unresolvedQuestions: string[];
|
|
21
|
+
currentPlan?: string;
|
|
22
|
+
}
|
|
23
|
+
type FablePlanStatus = 'completed' | 'failed' | 'timed_out' | 'cancelled' | 'interrupted';
|
|
24
|
+
type FablePlanStage = 'draft' | 'review' | 'completed' | 'failed' | 'cancelled' | 'interrupted';
|
|
25
|
+
interface FablePlanResult {
|
|
26
|
+
operationId: string;
|
|
27
|
+
status: FablePlanStatus;
|
|
28
|
+
stage: FablePlanStage;
|
|
29
|
+
draft?: string;
|
|
30
|
+
review?: string;
|
|
31
|
+
draftRunId?: string;
|
|
32
|
+
reviewRunId?: string;
|
|
33
|
+
durationMs: number;
|
|
34
|
+
errorCode?: string;
|
|
35
|
+
}
|
|
36
|
+
interface FablePlanRequest {
|
|
37
|
+
requester: typeof FABLE_PLAN_REQUESTER;
|
|
38
|
+
operationId: string;
|
|
39
|
+
runtime: typeof FABLE_PLAN_RUNTIME;
|
|
40
|
+
model: typeof FABLE_PLAN_MODEL;
|
|
41
|
+
profile: typeof FABLE_PLAN_PROFILE;
|
|
42
|
+
packet: FablePlanPacket;
|
|
43
|
+
}
|
|
44
|
+
interface FablePlanBroker {
|
|
45
|
+
start(request: FablePlanRequest, signal: AbortSignal): Promise<FablePlanResult>;
|
|
46
|
+
cancel(operationId: string, reason: string): void;
|
|
47
|
+
}
|
|
48
|
+
interface FableFlowOptions {
|
|
49
|
+
broker?: FablePlanBroker;
|
|
50
|
+
isAuthorized: () => boolean;
|
|
51
|
+
/** Supplies operation ids. Injected so a test can pin them. */
|
|
52
|
+
newOperationId?: () => string;
|
|
53
|
+
timeoutMs?: number;
|
|
54
|
+
onStage?: (stage: FableStage) => void;
|
|
55
|
+
onError?: (error: unknown) => void;
|
|
56
|
+
}
|
|
57
|
+
type FableStage = 'idle' | 'draft' | 'review' | 'completed' | 'failed' | 'cancelled' | 'interrupted';
|
|
58
|
+
interface FablePlanFlow {
|
|
59
|
+
run(value: unknown, signal?: AbortSignal): Promise<FablePlanResult>;
|
|
60
|
+
cancel(reason?: string): void;
|
|
61
|
+
isActive(): boolean;
|
|
62
|
+
}
|
|
63
|
+
declare function containsSuspectedCredential(value: string): boolean;
|
|
64
|
+
declare function sanitizeFablePacket(value: unknown): FablePlanPacket;
|
|
65
|
+
declare function createFablePlanFlow(options: FableFlowOptions): FablePlanFlow;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { MAX_FABLE_PACKET_BYTES as _, FABLE_PROVIDER_SOURCE as a, createFablePlanFlow as b, FablePlanFinding as c, FablePlanRequest as d, FablePlanResult as f, MAX_FABLE_ARRAY_ITEMS as g, FableStage as h, FABLE_PLAN_RUNTIME as i, FablePlanFlow as l, FablePlanStatus as m, FABLE_PLAN_PROFILE as n, FableFlowOptions as o, FablePlanStage as p, FABLE_PLAN_REQUESTER as r, FablePlanBroker as s, FABLE_PLAN_MODEL as t, FablePlanPacket as u, MAX_FABLE_TEXT_BYTES as v, sanitizeFablePacket as x, containsSuspectedCredential as y };
|
|
68
|
+
//# sourceMappingURL=index-C8e7IK60.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C8e7IK60.d.mts","names":[],"sources":["../src/services/fableFlow/index.ts"],"mappings":";cAEa;cACA;cACA;cACA;cACA;cACA;cACA;cACA;UAYI;EACf;EACA;;UAGe;EACf;EACA;EACA;EACA,kBAAkB;EAClB;EACA;EACA;;KAGU;KACA;UAEK;EACf;EACA,QAAQ;EACR,OAAO;EACP;EACA;EACA;EACA;EACA;EACA;;UAGe;EACf,kBAAkB;EAClB;EACA,gBAAgB;EAChB,cAAc;EACd,gBAAgB;EAChB,QAAQ;;UAGO;EACf,MAAM,SAAS,kBAAkB,QAAQ,cAAc,QAAQ;EAC/D,OAAO,qBAAqB;;UAGb;EACf,SAAS;EACT;;EAEA;EACA;EACA,WAAW,OAAO;EAClB,WAAW;;KAGD;UAEK;EACf,IAAI,gBAAgB,SAAS,cAAc,QAAQ;EACnD,OAAO;EACP;;iBAec,4BAA4B;iBAuD5B,oBAAoB,iBAAiB;iBA8CrC,oBAAoB,SAAS,mBAAmB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/services/prompts/index.d.ts
|
|
2
|
+
type PlanningFlavor = 'normal' | 'debug' | 'code-review';
|
|
3
|
+
interface DebugEvidencePacket {
|
|
4
|
+
issue: string;
|
|
5
|
+
expectedBehavior: string;
|
|
6
|
+
reproductionAttempt: string;
|
|
7
|
+
actualBehavior: string;
|
|
8
|
+
logs: string[];
|
|
9
|
+
correlatedTraceEvidence: string[];
|
|
10
|
+
processOutput: string[];
|
|
11
|
+
browserConsoleEvidence: string[];
|
|
12
|
+
correlationIds: string[];
|
|
13
|
+
timestamps: string[];
|
|
14
|
+
verifiedFacts: string[];
|
|
15
|
+
hypotheses: string[];
|
|
16
|
+
unavailableEvidence: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What a host's plan tooling can actually do, declared as capabilities rather than as a host
|
|
20
|
+
* name. The prompt must instruct only what the host's tool surface accepts: the server's
|
|
21
|
+
* complete_plan takes no parameters, so telling that model to pass a decision asks for an
|
|
22
|
+
* argument its provider schema rejects. A `cli | server` flag would encode identity and invite
|
|
23
|
+
* the next divergence to hide behind it.
|
|
24
|
+
*/
|
|
25
|
+
interface PlanHostCapabilities {
|
|
26
|
+
/** The host's complete_plan accepts a `decision` argument. */
|
|
27
|
+
readonly completePlanTakesDecision: boolean;
|
|
28
|
+
/** The host can narrate the plan review under autonomous voice. */
|
|
29
|
+
readonly narratesReview: boolean;
|
|
30
|
+
/** The host has a Fable broker. */
|
|
31
|
+
readonly fableAvailable: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The host-independent plan mode block, pushed ahead of the flavor block.
|
|
35
|
+
*
|
|
36
|
+
* Both the Pi extension and the server facet append this. It lives here so the cockpit and the
|
|
37
|
+
* terminal cannot drift into giving the agent different instructions for the same mode. The two
|
|
38
|
+
* facets may differ only through {@link PlanHostCapabilities}, so every other sentence is shared
|
|
39
|
+
* by construction.
|
|
40
|
+
*/
|
|
41
|
+
declare function buildPlanModeBasePrompt(plansDirectory: string, capabilities: PlanHostCapabilities): string;
|
|
42
|
+
/** Normal planning adds only the flavor-specific brief to the shared planning workflow. */
|
|
43
|
+
declare function buildNormalPlanningPrompt(): string;
|
|
44
|
+
declare function buildDebugPlanningPrompt(plansDirectory: string, evidence: DebugEvidencePacket | undefined): string;
|
|
45
|
+
declare function buildCodeReviewPlanningPrompt(plansDirectory: string): string;
|
|
46
|
+
/** @deprecated Fable is no longer an activatable planning flavor. Retained for API compatibility. */
|
|
47
|
+
declare function buildFablePlanningPrompt(plansDirectory: string, stage: string, capabilities: PlanHostCapabilities): string;
|
|
48
|
+
declare function buildFlavorPlanningPrompt(flavor: PlanningFlavor, plansDirectory: string, evidence: DebugEvidencePacket | undefined, _fableStage?: string, _capabilities?: PlanHostCapabilities): string;
|
|
49
|
+
//#endregion
|
|
50
|
+
export { buildDebugPlanningPrompt as a, buildNormalPlanningPrompt as c, buildCodeReviewPlanningPrompt as i, buildPlanModeBasePrompt as l, PlanHostCapabilities as n, buildFablePlanningPrompt as o, PlanningFlavor as r, buildFlavorPlanningPrompt as s, DebugEvidencePacket as t };
|
|
51
|
+
//# sourceMappingURL=index-C9QBG9cw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-C9QBG9cw.d.mts","names":[],"sources":["../src/services/prompts/index.ts"],"mappings":";KAAY;UAEK;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;;;;;;;;UAmCe;;WAEN;;WAEA;;WAEA;;;;;;;;;;iBA8BK,wBAAwB,wBAAwB,cAAc;;iBAM9D;iBAIA,yBAAyB,wBAAwB,UAAU;iBAO3D,8BAA8B;;iBAK9B,yBACd,wBACA,eACA,cAAc;iBAQA,0BACd,QAAQ,gBACR,wBACA,UAAU,iCACV,sBACA,gBAAgB"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_config = require("./config-D0iTexGm.cjs");
|
|
3
|
+
const require_fableFlow = require("./fableFlow-CzfrLPzJ.cjs");
|
|
4
|
+
const require_prompts = require("./prompts-DUVUPNZd.cjs");
|
|
5
|
+
let _agimon_ai_po_config = require("@agimon-ai/po-config");
|
|
6
|
+
exports.FABLE_PLAN_MODEL = require_fableFlow.FABLE_PLAN_MODEL;
|
|
7
|
+
exports.FABLE_PLAN_PROFILE = require_fableFlow.FABLE_PLAN_PROFILE;
|
|
8
|
+
exports.FABLE_PLAN_REQUESTER = require_fableFlow.FABLE_PLAN_REQUESTER;
|
|
9
|
+
exports.FABLE_PLAN_RUNTIME = require_fableFlow.FABLE_PLAN_RUNTIME;
|
|
10
|
+
exports.FABLE_PROVIDER_SOURCE = require_fableFlow.FABLE_PROVIDER_SOURCE;
|
|
11
|
+
exports.MAX_FABLE_ARRAY_ITEMS = require_fableFlow.MAX_FABLE_ARRAY_ITEMS;
|
|
12
|
+
exports.MAX_FABLE_PACKET_BYTES = require_fableFlow.MAX_FABLE_PACKET_BYTES;
|
|
13
|
+
exports.MAX_FABLE_TEXT_BYTES = require_fableFlow.MAX_FABLE_TEXT_BYTES;
|
|
14
|
+
exports.buildCodeReviewPlanningPrompt = require_prompts.buildCodeReviewPlanningPrompt;
|
|
15
|
+
exports.buildDebugPlanningPrompt = require_prompts.buildDebugPlanningPrompt;
|
|
16
|
+
exports.buildFablePlanningPrompt = require_prompts.buildFablePlanningPrompt;
|
|
17
|
+
exports.buildFlavorPlanningPrompt = require_prompts.buildFlavorPlanningPrompt;
|
|
18
|
+
exports.buildNormalPlanningPrompt = require_prompts.buildNormalPlanningPrompt;
|
|
19
|
+
exports.buildPlanModeBasePrompt = require_prompts.buildPlanModeBasePrompt;
|
|
20
|
+
exports.containsSuspectedCredential = require_fableFlow.containsSuspectedCredential;
|
|
21
|
+
exports.createFablePlanFlow = require_fableFlow.createFablePlanFlow;
|
|
22
|
+
exports.getHarnessState = _agimon_ai_po_config.getHarnessState;
|
|
23
|
+
exports.globalDoomConfigPath = _agimon_ai_po_config.globalDoomConfigPath;
|
|
24
|
+
exports.loadDoomConfig = require_config.loadDoomConfig;
|
|
25
|
+
exports.loadHarnessState = _agimon_ai_po_config.loadHarnessState;
|
|
26
|
+
exports.mergeDoomConfigs = require_config.mergeDoomConfigs;
|
|
27
|
+
exports.parseDoomConfig = require_config.parseDoomConfig;
|
|
28
|
+
exports.parsePlanningModeConfig = _agimon_ai_po_config.parsePlanningModeConfig;
|
|
29
|
+
exports.repositoryDoomConfigPath = _agimon_ai_po_config.repositoryDoomConfigPath;
|
|
30
|
+
exports.resolvePlanningPlansDirectory = _agimon_ai_po_config.resolvePlanningPlansDirectory;
|
|
31
|
+
exports.sanitizeFablePacket = require_fableFlow.sanitizeFablePacket;
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as getHarnessState, c as loadHarnessState, d as parsePlanningModeConfig, f as repositoryDoomConfigPath, i as PlanningThinkingLevel, l as mergeDoomConfigs, n as PlanningAgentConfig, o as globalDoomConfigPath, p as resolvePlanningPlansDirectory, r as PlanningModeConfig, s as loadDoomConfig, t as DoomConfig, u as parseDoomConfig } from "./config-DWo57HKB.mjs";
|
|
2
|
+
import { _ as MAX_FABLE_PACKET_BYTES, a as FABLE_PROVIDER_SOURCE, b as createFablePlanFlow, c as FablePlanFinding, d as FablePlanRequest, f as FablePlanResult, g as MAX_FABLE_ARRAY_ITEMS, h as FableStage, i as FABLE_PLAN_RUNTIME, l as FablePlanFlow, m as FablePlanStatus, n as FABLE_PLAN_PROFILE, o as FableFlowOptions, p as FablePlanStage, r as FABLE_PLAN_REQUESTER, s as FablePlanBroker, t as FABLE_PLAN_MODEL, u as FablePlanPacket, v as MAX_FABLE_TEXT_BYTES, x as sanitizeFablePacket, y as containsSuspectedCredential } from "./index-C8e7IK60.mjs";
|
|
3
|
+
import { a as buildDebugPlanningPrompt, c as buildNormalPlanningPrompt, i as buildCodeReviewPlanningPrompt, l as buildPlanModeBasePrompt, n as PlanHostCapabilities, o as buildFablePlanningPrompt, r as PlanningFlavor, s as buildFlavorPlanningPrompt, t as DebugEvidencePacket } from "./index-C9QBG9cw.mjs";
|
|
4
|
+
export { DebugEvidencePacket, DoomConfig, FABLE_PLAN_MODEL, FABLE_PLAN_PROFILE, FABLE_PLAN_REQUESTER, FABLE_PLAN_RUNTIME, FABLE_PROVIDER_SOURCE, FableFlowOptions, FablePlanBroker, FablePlanFinding, FablePlanFlow, FablePlanPacket, FablePlanRequest, FablePlanResult, FablePlanStage, FablePlanStatus, FableStage, MAX_FABLE_ARRAY_ITEMS, MAX_FABLE_PACKET_BYTES, MAX_FABLE_TEXT_BYTES, PlanHostCapabilities, type PlanningAgentConfig, PlanningFlavor, type PlanningModeConfig, type PlanningThinkingLevel, buildCodeReviewPlanningPrompt, buildDebugPlanningPrompt, buildFablePlanningPrompt, buildFlavorPlanningPrompt, buildNormalPlanningPrompt, buildPlanModeBasePrompt, containsSuspectedCredential, createFablePlanFlow, getHarnessState, globalDoomConfigPath, loadDoomConfig, loadHarnessState, mergeDoomConfigs, parseDoomConfig, parsePlanningModeConfig, repositoryDoomConfigPath, resolvePlanningPlansDirectory, sanitizeFablePacket };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { a as mergeDoomConfigs, c as repositoryDoomConfigPath, i as loadHarnessState, l as resolvePlanningPlansDirectory, n as globalDoomConfigPath, o as parseDoomConfig, r as loadDoomConfig, s as parsePlanningModeConfig, t as getHarnessState } from "./config-BC-Tou05.mjs";
|
|
2
|
+
import { a as FABLE_PROVIDER_SOURCE, c as MAX_FABLE_TEXT_BYTES, d as sanitizeFablePacket, i as FABLE_PLAN_RUNTIME, l as containsSuspectedCredential, n as FABLE_PLAN_PROFILE, o as MAX_FABLE_ARRAY_ITEMS, r as FABLE_PLAN_REQUESTER, s as MAX_FABLE_PACKET_BYTES, t as FABLE_PLAN_MODEL, u as createFablePlanFlow } from "./fableFlow-BDc8a__Y.mjs";
|
|
3
|
+
import { a as buildNormalPlanningPrompt, i as buildFlavorPlanningPrompt, n as buildDebugPlanningPrompt, o as buildPlanModeBasePrompt, r as buildFablePlanningPrompt, t as buildCodeReviewPlanningPrompt } from "./prompts-DnVJGtEC.mjs";
|
|
4
|
+
export { FABLE_PLAN_MODEL, FABLE_PLAN_PROFILE, FABLE_PLAN_REQUESTER, FABLE_PLAN_RUNTIME, FABLE_PROVIDER_SOURCE, MAX_FABLE_ARRAY_ITEMS, MAX_FABLE_PACKET_BYTES, MAX_FABLE_TEXT_BYTES, buildCodeReviewPlanningPrompt, buildDebugPlanningPrompt, buildFablePlanningPrompt, buildFlavorPlanningPrompt, buildNormalPlanningPrompt, buildPlanModeBasePrompt, containsSuspectedCredential, createFablePlanFlow, getHarnessState, globalDoomConfigPath, loadDoomConfig, loadHarnessState, mergeDoomConfigs, parseDoomConfig, parsePlanningModeConfig, repositoryDoomConfigPath, resolvePlanningPlansDirectory, sanitizeFablePacket };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let _agimon_ai_po_telemetry = require("@agimon-ai/po-telemetry");
|
|
3
|
+
//#region src/services/logSinkTelemetry/index.ts
|
|
4
|
+
const SERVICE_NAME = "doom-plan";
|
|
5
|
+
const PACKAGE_NAME = "@agimon-ai/po-plan";
|
|
6
|
+
const PLAN_EVENT = {
|
|
7
|
+
configLoadFailed: "doom_plan.config_load_failed",
|
|
8
|
+
writePlanFailed: "doom_plan.write_plan_failed",
|
|
9
|
+
writePlanTimedOut: "doom_plan.write_plan_timed_out",
|
|
10
|
+
writePlanUnsafePath: "doom_plan.write_plan_unsafe_path",
|
|
11
|
+
modelResolveFailed: "doom_plan.model_resolve_failed",
|
|
12
|
+
modeEnabled: "doom_plan.mode_enabled",
|
|
13
|
+
modeDisabled: "doom_plan.mode_disabled",
|
|
14
|
+
planWritten: "doom_plan.plan_written",
|
|
15
|
+
planPointerFailed: "doom_plan.plan_pointer_failed",
|
|
16
|
+
planReviewCompleted: "doom_plan.plan_review_completed"
|
|
17
|
+
};
|
|
18
|
+
function createPlanTelemetry(options = {}) {
|
|
19
|
+
const telemetry = (0, _agimon_ai_po_telemetry.createDoomTelemetry)({
|
|
20
|
+
serviceName: SERVICE_NAME,
|
|
21
|
+
packageName: PACKAGE_NAME,
|
|
22
|
+
cwd: options.cwd,
|
|
23
|
+
workspaceRoot: options.workspaceRoot,
|
|
24
|
+
env: options.env,
|
|
25
|
+
telemetryFactory: options.telemetryFactory,
|
|
26
|
+
warn: options.warn,
|
|
27
|
+
enableLogs: true,
|
|
28
|
+
enableTraces: true
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),
|
|
32
|
+
recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),
|
|
33
|
+
recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),
|
|
34
|
+
flush: () => telemetry.flush(),
|
|
35
|
+
shutdown: () => telemetry.shutdown()
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
exports.PLAN_EVENT = PLAN_EVENT;
|
|
40
|
+
exports.createPlanTelemetry = createPlanTelemetry;
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=logSinkTelemetry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.cjs","names":["createDoomTelemetry"],"sources":["../src/services/logSinkTelemetry/index.ts"],"sourcesContent":["import { createDoomTelemetry, type DoomTelemetry, type DoomTelemetryOptions } from '@agimon-ai/po-telemetry';\n\nconst SERVICE_NAME = 'doom-plan';\nconst PACKAGE_NAME = '@agimon-ai/po-plan';\n\nexport const PLAN_EVENT = {\n configLoadFailed: 'doom_plan.config_load_failed',\n writePlanFailed: 'doom_plan.write_plan_failed',\n writePlanTimedOut: 'doom_plan.write_plan_timed_out',\n writePlanUnsafePath: 'doom_plan.write_plan_unsafe_path',\n modelResolveFailed: 'doom_plan.model_resolve_failed',\n modeEnabled: 'doom_plan.mode_enabled',\n modeDisabled: 'doom_plan.mode_disabled',\n planWritten: 'doom_plan.plan_written',\n planPointerFailed: 'doom_plan.plan_pointer_failed',\n planReviewCompleted: 'doom_plan.plan_review_completed',\n} as const;\n\nexport type PlanEventName = (typeof PLAN_EVENT)[keyof typeof PLAN_EVENT];\nexport type PlanEventAttributes = Record<string, string | number | boolean>;\n\nexport interface PlanTelemetryOptions {\n cwd?: string;\n workspaceRoot?: string;\n env?: NodeJS.ProcessEnv;\n telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;\n warn?: (message: string) => void;\n}\n\nexport interface PlanTelemetry {\n recordError(event: PlanEventName, error: unknown, attributes?: PlanEventAttributes): Promise<void>;\n recordWarning(event: PlanEventName, error: unknown, attributes?: PlanEventAttributes): Promise<void>;\n recordEvent(event: PlanEventName, attributes?: PlanEventAttributes): Promise<void>;\n flush(): Promise<void>;\n shutdown(): Promise<void>;\n}\n\nexport function createPlanTelemetry(options: PlanTelemetryOptions = {}): PlanTelemetry {\n const telemetry: DoomTelemetry = createDoomTelemetry({\n serviceName: SERVICE_NAME,\n packageName: PACKAGE_NAME,\n cwd: options.cwd,\n workspaceRoot: options.workspaceRoot,\n env: options.env,\n telemetryFactory: options.telemetryFactory,\n warn: options.warn,\n enableLogs: true,\n enableTraces: true,\n });\n return {\n recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),\n recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),\n recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),\n flush: () => telemetry.flush(),\n shutdown: () => telemetry.shutdown(),\n };\n}\n"],"mappings":";;;AAEA,MAAM,eAAe;AACrB,MAAM,eAAe;AAErB,MAAa,aAAa;CACxB,kBAAkB;CAClB,iBAAiB;CACjB,mBAAmB;CACnB,qBAAqB;CACrB,oBAAoB;CACpB,aAAa;CACb,cAAc;CACd,aAAa;CACb,mBAAmB;CACnB,qBAAqB;AACvB;AAqBA,SAAgB,oBAAoB,UAAgC,CAAC,GAAkB;CACrF,MAAM,aAAA,GAA2BA,wBAAAA,oBAAAA,CAAoB;EACnD,aAAa;EACb,aAAa;EACb,KAAK,QAAQ;EACb,eAAe,QAAQ;EACvB,KAAK,QAAQ;EACb,kBAAkB,QAAQ;EAC1B,MAAM,QAAQ;EACd,YAAY;EACZ,cAAc;CAChB,CAAC;CACD,OAAO;EACL,cAAc,OAAO,OAAO,eAAe,UAAU,YAAY,OAAO,OAAO,UAAU;EACzF,gBAAgB,OAAO,OAAO,eAAe,UAAU,cAAc,OAAO,OAAO,UAAU;EAC7F,cAAc,OAAO,eAAe,UAAU,YAAY,OAAO,UAAU;EAC3E,aAAa,UAAU,MAAM;EAC7B,gBAAgB,UAAU,SAAS;CACrC;AACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { DoomTelemetryOptions } from "@agimon-ai/po-telemetry";
|
|
2
|
+
//#region src/services/logSinkTelemetry/index.d.ts
|
|
3
|
+
export declare const PLAN_EVENT: {
|
|
4
|
+
readonly configLoadFailed: 'doom_plan.config_load_failed';
|
|
5
|
+
readonly writePlanFailed: 'doom_plan.write_plan_failed';
|
|
6
|
+
readonly writePlanTimedOut: 'doom_plan.write_plan_timed_out';
|
|
7
|
+
readonly writePlanUnsafePath: 'doom_plan.write_plan_unsafe_path';
|
|
8
|
+
readonly modelResolveFailed: 'doom_plan.model_resolve_failed';
|
|
9
|
+
readonly modeEnabled: 'doom_plan.mode_enabled';
|
|
10
|
+
readonly modeDisabled: 'doom_plan.mode_disabled';
|
|
11
|
+
readonly planWritten: 'doom_plan.plan_written';
|
|
12
|
+
readonly planPointerFailed: 'doom_plan.plan_pointer_failed';
|
|
13
|
+
readonly planReviewCompleted: 'doom_plan.plan_review_completed';
|
|
14
|
+
};
|
|
15
|
+
export type PlanEventName = (typeof PLAN_EVENT)[keyof typeof PLAN_EVENT];
|
|
16
|
+
export type PlanEventAttributes = Record<string, string | number | boolean>;
|
|
17
|
+
export interface PlanTelemetryOptions {
|
|
18
|
+
cwd?: string;
|
|
19
|
+
workspaceRoot?: string;
|
|
20
|
+
env?: NodeJS.ProcessEnv;
|
|
21
|
+
telemetryFactory?: NonNullable<DoomTelemetryOptions['telemetryFactory']>;
|
|
22
|
+
warn?: (message: string) => void;
|
|
23
|
+
}
|
|
24
|
+
export interface PlanTelemetry {
|
|
25
|
+
recordError(event: PlanEventName, error: unknown, attributes?: PlanEventAttributes): Promise<void>;
|
|
26
|
+
recordWarning(event: PlanEventName, error: unknown, attributes?: PlanEventAttributes): Promise<void>;
|
|
27
|
+
recordEvent(event: PlanEventName, attributes?: PlanEventAttributes): Promise<void>;
|
|
28
|
+
flush(): Promise<void>;
|
|
29
|
+
shutdown(): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare function createPlanTelemetry(options?: PlanTelemetryOptions): PlanTelemetry;
|
|
32
|
+
//#endregion
|
|
33
|
+
//# sourceMappingURL=logSinkTelemetry.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logSinkTelemetry.d.mts","names":[],"sources":["../src/services/logSinkTelemetry/index.ts"],"mappings":";;qBAKa;WACX;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;YAGU,wBAAwB,yBAAyB;YACjD,sBAAsB;iBAEjB;EACf;EACA;EACA,MAAM,OAAO;EACb,mBAAmB,YAAY;EAC/B,QAAQ;;iBAGO;EACf,YAAY,OAAO,eAAe,gBAAgB,aAAa,sBAAsB;EACrF,cAAc,OAAO,eAAe,gBAAgB,aAAa,sBAAsB;EACvF,YAAY,OAAO,eAAe,aAAa,sBAAsB;EACrE,SAAS;EACT,YAAY;;wBAGE,oBAAoB,UAAS,uBAA4B"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { createDoomTelemetry } from "@agimon-ai/po-telemetry";
|
|
2
|
+
//#region src/services/logSinkTelemetry/index.ts
|
|
3
|
+
const SERVICE_NAME = "doom-plan";
|
|
4
|
+
const PACKAGE_NAME = "@agimon-ai/po-plan";
|
|
5
|
+
const PLAN_EVENT = {
|
|
6
|
+
configLoadFailed: "doom_plan.config_load_failed",
|
|
7
|
+
writePlanFailed: "doom_plan.write_plan_failed",
|
|
8
|
+
writePlanTimedOut: "doom_plan.write_plan_timed_out",
|
|
9
|
+
writePlanUnsafePath: "doom_plan.write_plan_unsafe_path",
|
|
10
|
+
modelResolveFailed: "doom_plan.model_resolve_failed",
|
|
11
|
+
modeEnabled: "doom_plan.mode_enabled",
|
|
12
|
+
modeDisabled: "doom_plan.mode_disabled",
|
|
13
|
+
planWritten: "doom_plan.plan_written",
|
|
14
|
+
planPointerFailed: "doom_plan.plan_pointer_failed",
|
|
15
|
+
planReviewCompleted: "doom_plan.plan_review_completed"
|
|
16
|
+
};
|
|
17
|
+
function createPlanTelemetry(options = {}) {
|
|
18
|
+
const telemetry = createDoomTelemetry({
|
|
19
|
+
serviceName: SERVICE_NAME,
|
|
20
|
+
packageName: PACKAGE_NAME,
|
|
21
|
+
cwd: options.cwd,
|
|
22
|
+
workspaceRoot: options.workspaceRoot,
|
|
23
|
+
env: options.env,
|
|
24
|
+
telemetryFactory: options.telemetryFactory,
|
|
25
|
+
warn: options.warn,
|
|
26
|
+
enableLogs: true,
|
|
27
|
+
enableTraces: true
|
|
28
|
+
});
|
|
29
|
+
return {
|
|
30
|
+
recordError: (event, error, attributes) => telemetry.recordError(event, error, attributes),
|
|
31
|
+
recordWarning: (event, error, attributes) => telemetry.recordWarning(event, error, attributes),
|
|
32
|
+
recordEvent: (event, attributes) => telemetry.recordEvent(event, attributes),
|
|
33
|
+
flush: () => telemetry.flush(),
|
|
34
|
+
shutdown: () => telemetry.shutdown()
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { PLAN_EVENT, createPlanTelemetry };
|
|
39
|
+
|
|
40
|
+
//# sourceMappingURL=logSinkTelemetry.mjs.map
|