@topce/pizx 0.4.0 → 0.5.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/README.md +39 -3
- package/dist/cli.js +64 -28
- package/dist/cli.js.map +4 -4
- package/dist/index.js +64 -29
- package/dist/index.js.map +4 -4
- package/package.json +12 -8
package/dist/index.js
CHANGED
|
@@ -301,7 +301,8 @@ ${skillContext}` : skillContext;
|
|
|
301
301
|
reasoning: opts.thinkingLevel ?? "medium",
|
|
302
302
|
thinkingBudgets: opts.thinkingBudgets,
|
|
303
303
|
timeoutMs: opts.timeoutMs,
|
|
304
|
-
maxRetries: opts.maxRetries
|
|
304
|
+
maxRetries: opts.maxRetries,
|
|
305
|
+
apiKey: opts.apiKey
|
|
305
306
|
}
|
|
306
307
|
);
|
|
307
308
|
const durationMs = Date.now() - t0;
|
|
@@ -838,9 +839,9 @@ var defaults4 = {
|
|
|
838
839
|
rounds: 1
|
|
839
840
|
};
|
|
840
841
|
var CritiqueRound = class {
|
|
841
|
-
constructor(content,
|
|
842
|
+
constructor(content, critique2, round) {
|
|
842
843
|
this.content = content;
|
|
843
|
-
this.critique =
|
|
844
|
+
this.critique = critique2;
|
|
844
845
|
this.round = round;
|
|
845
846
|
}
|
|
846
847
|
content;
|
|
@@ -904,12 +905,12 @@ Revise the content based on the critique.`,
|
|
|
904
905
|
}
|
|
905
906
|
if (!opts.quiet) process.stderr.write(` \u2192 Critiquing (round ${r + 1})...
|
|
906
907
|
`);
|
|
907
|
-
const
|
|
908
|
+
const critique2 = await ask(currentContent, {
|
|
908
909
|
...opts,
|
|
909
910
|
model: plannerModel,
|
|
910
911
|
system: mergeSystem(opts.system, CRITIQUE_SYSTEM)
|
|
911
912
|
});
|
|
912
|
-
critiqueRounds.push(new CritiqueRound(currentContent,
|
|
913
|
+
critiqueRounds.push(new CritiqueRound(currentContent, critique2, r));
|
|
913
914
|
}
|
|
914
915
|
const t1 = Date.now();
|
|
915
916
|
const finalContent = currentContent;
|
|
@@ -2400,21 +2401,21 @@ ${prompt}`, {
|
|
|
2400
2401
|
}
|
|
2401
2402
|
return { keys, roles: roles.slice(0, agentCount), assignments };
|
|
2402
2403
|
}
|
|
2403
|
-
function formatStore(
|
|
2404
|
-
const entries = Object.entries(
|
|
2404
|
+
function formatStore(store2) {
|
|
2405
|
+
const entries = Object.entries(store2).filter(([, v]) => v);
|
|
2405
2406
|
if (entries.length === 0) return "(empty \u2014 you are the first contributor)";
|
|
2406
2407
|
return entries.map(([k, v]) => `[${k}]: ${v}`).join("\n\n");
|
|
2407
2408
|
}
|
|
2408
|
-
function mergeEntry(
|
|
2409
|
-
if (
|
|
2410
|
-
|
|
2409
|
+
function mergeEntry(store2, key, content) {
|
|
2410
|
+
if (store2[key]) {
|
|
2411
|
+
store2[key] += `
|
|
2411
2412
|
|
|
2412
2413
|
${content}`;
|
|
2413
2414
|
} else {
|
|
2414
|
-
|
|
2415
|
+
store2[key] = content;
|
|
2415
2416
|
}
|
|
2416
2417
|
}
|
|
2417
|
-
async function executeRound(roles, assignments,
|
|
2418
|
+
async function executeRound(roles, assignments, store2, round, opts) {
|
|
2418
2419
|
const workerModel = opts.workerModel ?? opts.model;
|
|
2419
2420
|
const isWrite = round === 1;
|
|
2420
2421
|
const operation = isWrite ? "write" : "update";
|
|
@@ -2422,7 +2423,7 @@ async function executeRound(roles, assignments, store, round, opts) {
|
|
|
2422
2423
|
roles.map(async (role) => {
|
|
2423
2424
|
const assignedKeys = assignments.get(role) ?? ["General"];
|
|
2424
2425
|
const keysStr = assignedKeys.join(", ");
|
|
2425
|
-
const storeText = formatStore(
|
|
2426
|
+
const storeText = formatStore(store2);
|
|
2426
2427
|
const systemPrompt = isWrite ? WRITE_SYSTEM(role, keysStr).replace("{store}", storeText) : UPDATE_SYSTEM(role, keysStr).replace("{store}", storeText);
|
|
2427
2428
|
const task = isWrite ? `Write your initial findings to your assigned keys: ${keysStr}` : `Review the shared context and update your entries for keys: ${keysStr}`;
|
|
2428
2429
|
const response = await ask(task, {
|
|
@@ -2434,7 +2435,7 @@ async function executeRound(roles, assignments, store, round, opts) {
|
|
|
2434
2435
|
})
|
|
2435
2436
|
);
|
|
2436
2437
|
const entries = [];
|
|
2437
|
-
const newStore = { ...
|
|
2438
|
+
const newStore = { ...store2 };
|
|
2438
2439
|
for (const r of roundResults) {
|
|
2439
2440
|
if (r.status !== "fulfilled") continue;
|
|
2440
2441
|
const { role, response } = r.value;
|
|
@@ -2457,8 +2458,8 @@ async function executeRound(roles, assignments, store, round, opts) {
|
|
|
2457
2458
|
}
|
|
2458
2459
|
return { entries, store: newStore };
|
|
2459
2460
|
}
|
|
2460
|
-
async function consolidateStore(task,
|
|
2461
|
-
const storeText = formatStore(
|
|
2461
|
+
async function consolidateStore(task, store2, opts) {
|
|
2462
|
+
const storeText = formatStore(store2);
|
|
2462
2463
|
return ask(
|
|
2463
2464
|
`Original task: ${task}
|
|
2464
2465
|
|
|
@@ -2499,7 +2500,7 @@ async function execute14(pieces, args, opts) {
|
|
|
2499
2500
|
}
|
|
2500
2501
|
}
|
|
2501
2502
|
const allEntries = [];
|
|
2502
|
-
let
|
|
2503
|
+
let store2 = {};
|
|
2503
2504
|
for (let round = 1; round <= totalRounds; round++) {
|
|
2504
2505
|
const label = round === 1 ? "Writing" : "Updating";
|
|
2505
2506
|
if (!opts.quiet) process.stderr.write(` \u2192 Round ${round}/${totalRounds}: ${label}...
|
|
@@ -2507,15 +2508,15 @@ async function execute14(pieces, args, opts) {
|
|
|
2507
2508
|
const { entries, store: updatedStore } = await executeRound(
|
|
2508
2509
|
roles,
|
|
2509
2510
|
assignments,
|
|
2510
|
-
|
|
2511
|
+
store2,
|
|
2511
2512
|
round,
|
|
2512
2513
|
opts
|
|
2513
2514
|
);
|
|
2514
2515
|
allEntries.push(...entries);
|
|
2515
|
-
|
|
2516
|
+
store2 = updatedStore;
|
|
2516
2517
|
}
|
|
2517
2518
|
if (!opts.quiet) process.stderr.write(" \u2192 Consolidating store...\n");
|
|
2518
|
-
const synthesis = await consolidateStore(task,
|
|
2519
|
+
const synthesis = await consolidateStore(task, store2, { ...opts, plannerModel });
|
|
2519
2520
|
if (!opts.quiet && opts.qualityCheck) process.stderr.write(" \u2192 Quality review...\n");
|
|
2520
2521
|
const qualityReview = await runQualityReview(task, synthesis, opts);
|
|
2521
2522
|
const t1 = Date.now();
|
|
@@ -2526,7 +2527,7 @@ async function execute14(pieces, args, opts) {
|
|
|
2526
2527
|
`Entries: ${allEntries.length}`,
|
|
2527
2528
|
`Synthesis: ${synthesis}`
|
|
2528
2529
|
].join("\n\n");
|
|
2529
|
-
return new TauOutput(summary, allEntries,
|
|
2530
|
+
return new TauOutput(summary, allEntries, store2, synthesis, t0, t1, qualityReview);
|
|
2530
2531
|
}
|
|
2531
2532
|
var \u03A4 = createPatternTag(defaults14, execute14);
|
|
2532
2533
|
|
|
@@ -2567,10 +2568,10 @@ The conversation so far:
|
|
|
2567
2568
|
Respond as your role. Be specific, build on or challenge what others have said.
|
|
2568
2569
|
Keep your response under 200 words.`;
|
|
2569
2570
|
var SYNTHESIS_SYSTEM6 = `You are a neutral facilitator. Synthesize the multi-agent conversation thread into a clear, actionable conclusion. Weigh the evidence, resolve conflicts, and present the best path forward.`;
|
|
2570
|
-
function buildThreadPrompt(role,
|
|
2571
|
+
function buildThreadPrompt(role, thread2) {
|
|
2571
2572
|
return THREAD_PROMPT.replace("{role}", role).replace(
|
|
2572
2573
|
"{thread}",
|
|
2573
|
-
|
|
2574
|
+
thread2 || "(This is the first message in the thread.)"
|
|
2574
2575
|
);
|
|
2575
2576
|
}
|
|
2576
2577
|
async function execute15(pieces, args, opts) {
|
|
@@ -2588,17 +2589,17 @@ async function execute15(pieces, args, opts) {
|
|
|
2588
2589
|
`);
|
|
2589
2590
|
}
|
|
2590
2591
|
const messages = [];
|
|
2591
|
-
let
|
|
2592
|
+
let thread2 = `Topic: ${topic}
|
|
2592
2593
|
`;
|
|
2593
2594
|
for (let turn = 1; turn <= maxTurns; turn++) {
|
|
2594
2595
|
if (!opts.quiet) process.stderr.write(` \u2192 Turn ${turn}/${maxTurns}
|
|
2595
2596
|
`);
|
|
2596
2597
|
for (let a = 0; a < roles.length; a++) {
|
|
2597
2598
|
const role = roles[a] ?? `Agent ${a + 1}`;
|
|
2598
|
-
const prompt = buildThreadPrompt(role,
|
|
2599
|
+
const prompt = buildThreadPrompt(role, thread2);
|
|
2599
2600
|
const response = await ask(prompt, { ...opts, model: workerModel });
|
|
2600
2601
|
messages.push(new ThreadMessage(role, turn, response));
|
|
2601
|
-
|
|
2602
|
+
thread2 += `
|
|
2602
2603
|
[${role}] (Turn ${turn}): ${response}
|
|
2603
2604
|
`;
|
|
2604
2605
|
}
|
|
@@ -2608,7 +2609,7 @@ async function execute15(pieces, args, opts) {
|
|
|
2608
2609
|
`Topic: ${topic}
|
|
2609
2610
|
|
|
2610
2611
|
Conversation thread:
|
|
2611
|
-
${
|
|
2612
|
+
${thread2}
|
|
2612
2613
|
|
|
2613
2614
|
Synthesize a clear, actionable conclusion.`,
|
|
2614
2615
|
{
|
|
@@ -2628,6 +2629,23 @@ Synthesize a clear, actionable conclusion.`,
|
|
|
2628
2629
|
}
|
|
2629
2630
|
var \u0398 = createPatternTag(defaults15, execute15);
|
|
2630
2631
|
|
|
2632
|
+
// src/patterns/index.ts
|
|
2633
|
+
var ralph = \u03A1;
|
|
2634
|
+
var fleet = \u03A6;
|
|
2635
|
+
var subagent = \u03A3;
|
|
2636
|
+
var debate = \u0394;
|
|
2637
|
+
var pipeline = \u039B;
|
|
2638
|
+
var critique = \u03A8;
|
|
2639
|
+
var orchestrator = \u03A9;
|
|
2640
|
+
var thread = \u0398;
|
|
2641
|
+
var memory = \u039C;
|
|
2642
|
+
var broadcast = \u0392;
|
|
2643
|
+
var adaptive = \u0391;
|
|
2644
|
+
var graph = \u0393;
|
|
2645
|
+
var team = \u039D;
|
|
2646
|
+
var learn = \u03A7;
|
|
2647
|
+
var store = \u03A4;
|
|
2648
|
+
|
|
2631
2649
|
// src/pi.ts
|
|
2632
2650
|
import {
|
|
2633
2651
|
streamSimple
|
|
@@ -2715,7 +2733,8 @@ function makeOpts(opts) {
|
|
|
2715
2733
|
reasoning: opts.thinkingLevel,
|
|
2716
2734
|
thinkingBudgets: opts.thinkingBudgets,
|
|
2717
2735
|
timeoutMs: opts.timeoutMs,
|
|
2718
|
-
maxRetries: opts.maxRetries
|
|
2736
|
+
maxRetries: opts.maxRetries,
|
|
2737
|
+
apiKey: opts.apiKey
|
|
2719
2738
|
};
|
|
2720
2739
|
}
|
|
2721
2740
|
async function run(pieces, args, opts) {
|
|
@@ -2973,8 +2992,8 @@ export {
|
|
|
2973
2992
|
OrchestratorWorkerResult,
|
|
2974
2993
|
PatternOutput,
|
|
2975
2994
|
PatternPromise,
|
|
2995
|
+
\u03A0 as Pi,
|
|
2976
2996
|
PiOutput,
|
|
2977
|
-
PiPromise,
|
|
2978
2997
|
PipelineOutput,
|
|
2979
2998
|
PipelineStageResult,
|
|
2980
2999
|
RalphOutput,
|
|
@@ -2983,12 +3002,28 @@ export {
|
|
|
2983
3002
|
SubagentResult,
|
|
2984
3003
|
ThreadMessage,
|
|
2985
3004
|
ThreadOutput,
|
|
3005
|
+
adaptive,
|
|
3006
|
+
broadcast,
|
|
2986
3007
|
closeAgent,
|
|
2987
3008
|
configureAgent,
|
|
2988
3009
|
configurePi,
|
|
2989
3010
|
createPatternTag,
|
|
3011
|
+
critique,
|
|
3012
|
+
debate,
|
|
3013
|
+
fleet,
|
|
3014
|
+
graph,
|
|
3015
|
+
learn,
|
|
2990
3016
|
loadSkillContent,
|
|
2991
3017
|
loadSkillContents,
|
|
3018
|
+
memory,
|
|
3019
|
+
orchestrator,
|
|
3020
|
+
\u03C0 as pi,
|
|
3021
|
+
pipeline,
|
|
3022
|
+
ralph,
|
|
3023
|
+
store,
|
|
3024
|
+
subagent,
|
|
3025
|
+
team,
|
|
3026
|
+
thread,
|
|
2992
3027
|
\u0391,
|
|
2993
3028
|
\u0392,
|
|
2994
3029
|
\u0393,
|