@pasko70/pibo 1.9.13 → 1.10.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 +183 -183
- package/context/codex-base-prompt.md +148 -148
- package/context/compute-worker.md +23 -23
- package/context/pibo-compaction-prompt.md +100 -100
- package/context/pibo-native-tooling.md +18 -18
- package/context/pibo-system-prompt.md +77 -77
- package/dist/apps/chat/agent-profiles.js +2 -2
- package/dist/apps/chat/agent-store.js +263 -250
- package/dist/apps/chat/chat-request-normalizers.js +17 -0
- package/dist/apps/chat/data/chat-data-mappers.js +2 -0
- package/dist/apps/chat/data/project-service.js +168 -168
- package/dist/apps/chat/data/read-state-service.js +18 -18
- package/dist/apps/chat/data/session-query-service.js +25 -25
- package/dist/apps/chat/data/timeline-query-service.js +19 -19
- package/dist/apps/chat/loop-api.js +181 -0
- package/dist/apps/chat/static-assets.js +854 -854
- package/dist/apps/chat/web-app.js +36 -16
- package/dist/apps/chat/workflow-manual-trigger-runtime.js +149 -46
- package/dist/apps/chat/workflow-persistence.js +255 -255
- package/dist/apps/chat-ui/assets/{dist-BZ2eTC4f.js → dist-3Sts0Afa.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BHa-kcGl.js → dist-4NlLjLs7.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-yCYNNb5d.js → dist-BA6mhAec.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-D811wJeV.js → dist-BPl-fzRB.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-Dq4GxJi3.js → dist-BPnn9e2B.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CzE6k3F3.js → dist-BpfBSMzK.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CnVsqwSG.js → dist-Cvx5M97R.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-WyXdYl-w.js → dist-DnXWNQRm.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BNMu92bb.js → dist-hU-2oAb6.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-BCB6zezO.js → dist-r31x5Fcc.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-HqTN67dc.js → dist-uF6UXzI7.js} +1 -1
- package/dist/apps/chat-ui/assets/index-CaTGYBOS.js +173 -0
- package/dist/apps/chat-ui/assets/{index-C0x9nEcf.css → index-al8DeEjA.css} +1 -1
- package/dist/apps/chat-ui/index.html +18 -18
- package/dist/apps/chat-ui/manifest.webmanifest +25 -25
- package/dist/apps/chat-ui/sw.js +47 -47
- package/dist/apps/chat-vscode-web/assets/index-CK4SMZuu.js +41 -0
- package/dist/apps/chat-vscode-web/index.html +13 -13
- package/dist/apps/cli-ui/cliSessionsCommand.js +23 -23
- package/dist/apps/context-files-ui/index.html +11 -11
- package/dist/cli-session/localSessionSource.js +34 -12
- package/dist/cli.js +61 -44
- package/dist/compute/cli.js +54 -54
- package/dist/compute/resource-health.js +35 -2
- package/dist/core/events.js +6 -1
- package/dist/core/routed-session.js +97 -5
- package/dist/core/runtime.js +6 -1
- package/dist/core/session-router.js +27 -8
- package/dist/cron/cli.js +15 -15
- package/dist/cron/store.js +49 -49
- package/dist/data/cli.js +23 -23
- package/dist/data/event-log.js +23 -23
- package/dist/data/ingest-service.js +3 -1
- package/dist/data/message-store.js +27 -27
- package/dist/data/navigation-store.js +9 -9
- package/dist/data/observation-store.js +4 -4
- package/dist/data/payload-store.js +17 -17
- package/dist/data/schema.js +433 -433
- package/dist/data/session-store.js +4 -4
- package/dist/data/telemetry-queries.js +54 -54
- package/dist/data/telemetry.js +197 -197
- package/dist/debug/events.js +12 -12
- package/dist/debug/failures.js +6 -6
- package/dist/debug/index.js +231 -227
- package/dist/debug/messages.js +6 -6
- package/dist/debug/pty.js +124 -124
- package/dist/debug/session.js +29 -29
- package/dist/debug/tools.js +5 -5
- package/dist/debug/trace.js +42 -7
- package/dist/debug/web-snapshot-browser-scripts.js +294 -294
- package/dist/debug/web-streaming-browser-library.js +925 -925
- package/dist/debug/web-streaming-browser-scripts.js +232 -232
- package/dist/debug/web-streaming-provider-telemetry.js +4 -4
- package/dist/debug/web.js +93 -93
- package/dist/gateway/cli.js +19 -19
- package/dist/gateway/server.js +4 -2
- package/dist/gateway/web.js +2 -2
- package/dist/index.js +1 -0
- package/dist/loops/accounting.js +19 -0
- package/dist/loops/channel.js +8 -0
- package/dist/loops/cli.js +224 -0
- package/dist/loops/plugin.js +16 -0
- package/dist/loops/prompts.js +86 -0
- package/dist/loops/service.js +446 -0
- package/dist/loops/stopping.js +170 -0
- package/dist/loops/store.js +642 -0
- package/dist/loops/templates.js +232 -0
- package/dist/loops/tools.js +184 -0
- package/dist/loops/types.js +1 -0
- package/dist/mcp/config-command.js +53 -53
- package/dist/mcp/index.js +21 -21
- package/dist/mcp/registry.js +11 -11
- package/dist/pi-packages/cli.js +11 -11
- package/dist/plugins/builtin.js +8 -0
- package/dist/plugins/context-files-store.js +110 -110
- package/dist/plugins/context-files.js +4 -4
- package/dist/plugins/registry.js +23 -12
- package/dist/ralph/cli.js +18 -18
- package/dist/ralph/templates.js +140 -140
- package/dist/reliability/store.js +256 -229
- package/dist/runs/lifecycle.js +59 -0
- package/dist/runs/registry.js +47 -1
- package/dist/runs/tools.js +31 -13
- package/dist/session-ui/terminalRows.js +66 -2
- package/dist/sessions/pibo-data-store.js +16 -16
- package/dist/sessions/sqlite-store.js +53 -53
- package/dist/setup/cli.js +58 -58
- package/dist/shared/trace-async-agent-runs.js +4 -4
- package/dist/shared/trace-event-projection.js +59 -19
- package/dist/shared/trace-nodes.js +5 -0
- package/dist/shared/trace-page-merge.js +15 -0
- package/dist/shared/trace-run-notifications.js +3 -1
- package/dist/signals/projector.js +6 -2
- package/dist/tools/agent-browser-wrapper.js +80 -80
- package/dist/tools/browser-pool.js +50 -0
- package/dist/tools/browser-use-cdp.js +12 -12
- package/dist/tools/browser-use-leases.js +12 -8
- package/dist/tools/browser-use-wrapper.js +762 -762
- package/dist/tools/guides.js +596 -538
- package/dist/tools/index.js +123 -99
- package/dist/tools/registry.js +21 -3
- package/dist/tools/runtime/node-worker-source.js +205 -205
- package/dist/tools/runtime/python-worker-source.js +177 -177
- package/dist/vscode/cli.js +9 -9
- package/dist/web-annotations/cdp.js +900 -900
- package/dist/web-annotations/store.js +96 -96
- package/docs/README.md +23 -23
- package/docs/ops/install-developer-host.md +112 -112
- package/docs/ops/install-user-host.md +96 -96
- package/docs/ops/upgrade-user-to-developer-host.md +69 -69
- package/docs/ops/vscode-extension-release.md +160 -160
- package/package.json +99 -95
- package/skills/builtin/graphify/SKILL.md +52 -52
- package/skills/builtin/loop/SKILL.md +78 -0
- package/skills/builtin/pi-agent-harness/SKILL.md +319 -319
- package/skills/builtin/pi-agent-harness/agents/openai.yaml +4 -4
- package/skills/builtin/pibo-docker-system/SKILL.md +170 -170
- package/skills/builtin/pibo-spec-writing/SKILL.md +330 -330
- package/skills/builtin/prd/SKILL.md +143 -143
- package/skills/builtin/ralph-loop/SKILL.md +361 -359
- package/skills/builtin/ralph-prd-json/SKILL.md +123 -123
- package/skills/builtin/skill-creator/LICENSE.txt +201 -201
- package/skills/builtin/skill-creator/SKILL.md +513 -513
- package/skills/builtin/skill-creator/agents/analyzer.md +274 -274
- package/skills/builtin/skill-creator/agents/comparator.md +202 -202
- package/skills/builtin/skill-creator/agents/grader.md +223 -223
- package/skills/builtin/skill-creator/assets/eval_review.html +146 -146
- package/skills/builtin/skill-creator/eval-viewer/generate_review.py +471 -471
- package/skills/builtin/skill-creator/eval-viewer/viewer.html +1325 -1325
- package/skills/builtin/skill-creator/references/schemas.md +430 -430
- package/skills/builtin/skill-creator/scripts/aggregate_benchmark.py +401 -401
- package/skills/builtin/skill-creator/scripts/generate_report.py +326 -326
- package/skills/builtin/skill-creator/scripts/improve_description.py +247 -247
- package/skills/builtin/skill-creator/scripts/package_skill.py +136 -136
- package/skills/builtin/skill-creator/scripts/quick_validate.py +102 -102
- package/skills/builtin/skill-creator/scripts/run_eval.py +310 -310
- package/skills/builtin/skill-creator/scripts/run_loop.py +328 -328
- package/skills/builtin/skill-creator/scripts/utils.py +47 -47
- package/skills/builtin/web-annotations/SKILL.md +93 -93
- package/src/mcp/LICENSE.mcp-cli +21 -21
- package/dist/apps/chat-ui/assets/index-DwHJfmiF.js +0 -173
- package/dist/apps/chat-vscode-web/assets/index-BAMxIaI_.js +0 -41
- package/dist/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.9.13.vsix +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
export const PROMISE_COMPLETE_STOP_TOKEN = '<promise>COMPLETE</promise>';
|
|
3
|
+
export const MAX_ITERATIONS_STOP_CONDITION = 'pibo.loop.max-iterations';
|
|
4
|
+
export const PROMISE_COMPLETE_STOP_CONDITION = 'pibo.loop.promise-complete';
|
|
5
|
+
export const FACT_COUNT_STOP_CONDITION = 'pibo.loop.fact-count';
|
|
6
|
+
export const GOAL_STATUS_STOP_CONDITION = 'pibo.loop.goal-status';
|
|
7
|
+
function hasPromiseCompleteMarker(finalAnswer) { return finalAnswer.split(/\r?\n/).some((line) => line.trim() === PROMISE_COMPLETE_STOP_TOKEN); }
|
|
8
|
+
function isObject(value) { return !!value && typeof value === 'object' && !Array.isArray(value); }
|
|
9
|
+
function stringOption(options, key) { const value = options?.[key]; return typeof value === 'string' && value.trim() ? value.trim() : undefined; }
|
|
10
|
+
function numberOption(options, key) { const value = options?.[key]; return typeof value === 'number' && Number.isFinite(value) ? value : undefined; }
|
|
11
|
+
function boolOption(options, key) { const value = options?.[key]; return typeof value === 'boolean' ? value : undefined; }
|
|
12
|
+
export function getDefaultLoopStopPolicy(job) {
|
|
13
|
+
const conditions = [];
|
|
14
|
+
if (job.maxIterations !== undefined)
|
|
15
|
+
conditions.push({ id: 'max-iterations', type: MAX_ITERATIONS_STOP_CONDITION });
|
|
16
|
+
if (job.mode === 'goal')
|
|
17
|
+
conditions.push({ id: 'goal-status', type: GOAL_STATUS_STOP_CONDITION });
|
|
18
|
+
else
|
|
19
|
+
conditions.push({ id: 'promise-complete', type: PROMISE_COMPLETE_STOP_CONDITION });
|
|
20
|
+
return { mode: 'any', conditions };
|
|
21
|
+
}
|
|
22
|
+
export function getEffectiveLoopStopPolicy(job) {
|
|
23
|
+
return job.stopPolicy ?? getDefaultLoopStopPolicy(job);
|
|
24
|
+
}
|
|
25
|
+
export function createBuiltInLoopStopConditions() {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
type: MAX_ITERATIONS_STOP_CONDITION,
|
|
29
|
+
name: 'Max iterations',
|
|
30
|
+
description: 'Stops a Loop job after its configured number of completed run attempts, regardless of outcome.',
|
|
31
|
+
phases: ['before-run', 'after-run'],
|
|
32
|
+
evaluate(context) {
|
|
33
|
+
const maxIterations = context.job.maxIterations;
|
|
34
|
+
if (maxIterations === undefined)
|
|
35
|
+
return { action: 'continue' };
|
|
36
|
+
const current = context.job.state.completedIterations ?? 0;
|
|
37
|
+
const completed = context.phase === 'after-run' && context.outcome ? current + 1 : current;
|
|
38
|
+
if (completed >= maxIterations)
|
|
39
|
+
return { action: 'stop-after-run', reason: 'max-iterations', details: { maxIterations, completedIterations: completed } };
|
|
40
|
+
return { action: 'continue', details: { maxIterations, completedIterations: completed } };
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: PROMISE_COMPLETE_STOP_CONDITION,
|
|
45
|
+
name: 'Promise complete token',
|
|
46
|
+
description: 'Stops after a successful run whose final answer contains the promise-complete marker on its own line.',
|
|
47
|
+
phases: ['after-run'],
|
|
48
|
+
evaluate(context) {
|
|
49
|
+
const finalAnswer = context.outcome?.finalAnswer ?? '';
|
|
50
|
+
if (context.outcome?.status === 'ok' && hasPromiseCompleteMarker(finalAnswer))
|
|
51
|
+
return { action: 'stop-after-run', reason: 'promise-complete', details: { token: PROMISE_COMPLETE_STOP_TOKEN } };
|
|
52
|
+
return { action: 'continue' };
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: GOAL_STATUS_STOP_CONDITION,
|
|
57
|
+
name: 'Goal status',
|
|
58
|
+
description: 'Stops a Goal loop after native tooling or accounting marks it complete, blocked, or budget limited.',
|
|
59
|
+
phases: ['before-run', 'after-run'],
|
|
60
|
+
evaluate(context) {
|
|
61
|
+
if (context.job.mode !== 'goal')
|
|
62
|
+
return { action: 'continue' };
|
|
63
|
+
const status = context.job.state.goalStatus ?? (context.job.enabled ? 'active' : 'paused');
|
|
64
|
+
if (status === 'complete' || status === 'blocked' || status === 'budget_limited')
|
|
65
|
+
return { action: 'stop-after-run', reason: `goal-${status}`, details: { status } };
|
|
66
|
+
return { action: 'continue', details: { status } };
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
type: FACT_COUNT_STOP_CONDITION,
|
|
71
|
+
name: 'Run fact count',
|
|
72
|
+
description: 'Stops when the current run or job history contains at least a configured number of matching Loop run facts.',
|
|
73
|
+
phases: ['after-run'],
|
|
74
|
+
defaultOptions: { factType: 'example.fact', threshold: 1, currentRunOnly: true },
|
|
75
|
+
optionsSchema: {
|
|
76
|
+
type: 'object',
|
|
77
|
+
properties: {
|
|
78
|
+
factType: { type: 'string', description: 'Fact type to count.' },
|
|
79
|
+
threshold: { type: 'number', description: 'Stop after at least this many facts.' },
|
|
80
|
+
currentRunOnly: { type: 'boolean', description: 'Only count facts for the current run.' },
|
|
81
|
+
reason: { type: 'string', description: 'Optional stop reason.' },
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
evaluate(context) {
|
|
85
|
+
const factType = stringOption(context.instance.options, 'factType');
|
|
86
|
+
if (!factType)
|
|
87
|
+
return { action: 'continue', details: { missingOption: 'factType' } };
|
|
88
|
+
const threshold = Math.max(1, Math.floor(numberOption(context.instance.options, 'threshold') ?? 1));
|
|
89
|
+
const currentRunOnly = boolOption(context.instance.options, 'currentRunOnly') ?? true;
|
|
90
|
+
const runId = currentRunOnly ? context.run?.id : undefined;
|
|
91
|
+
const count = context.facts.count({ type: factType, runId });
|
|
92
|
+
if (count >= threshold)
|
|
93
|
+
return { action: 'stop-after-run', reason: stringOption(context.instance.options, 'reason') ?? `fact:${factType}`, details: { factType, threshold, count, currentRunOnly } };
|
|
94
|
+
return { action: 'continue', details: { factType, threshold, count, currentRunOnly } };
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
function severity(action) {
|
|
100
|
+
if (action === 'cancel-current-run')
|
|
101
|
+
return 2;
|
|
102
|
+
if (action === 'stop-after-run')
|
|
103
|
+
return 1;
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
function highest(left, right) { return severity(right) > severity(left) ? right : left; }
|
|
107
|
+
function sanitizeDecision(value) {
|
|
108
|
+
if (!isObject(value))
|
|
109
|
+
throw new Error('condition returned a non-object decision');
|
|
110
|
+
if (value.action !== 'continue' && value.action !== 'stop-after-run' && value.action !== 'cancel-current-run')
|
|
111
|
+
throw new Error('condition returned an invalid action');
|
|
112
|
+
return { action: value.action, reason: typeof value.reason === 'string' ? value.reason : undefined, details: isObject(value.details) ? value.details : undefined, nextState: isObject(value.nextState) ? value.nextState : undefined };
|
|
113
|
+
}
|
|
114
|
+
async function withTimeout(promise, timeoutMs, signal) {
|
|
115
|
+
if (!timeoutMs || timeoutMs <= 0)
|
|
116
|
+
return await promise;
|
|
117
|
+
return await new Promise((resolve, reject) => {
|
|
118
|
+
const timeout = setTimeout(() => reject(new Error(`condition timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
119
|
+
if (signal)
|
|
120
|
+
signal.addEventListener('abort', () => reject(new Error('condition aborted')), { once: true });
|
|
121
|
+
promise.then((value) => { clearTimeout(timeout); resolve(value); }, (error) => { clearTimeout(timeout); reject(error); });
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
export async function evaluateLoopStopPolicy(input) {
|
|
125
|
+
const now = (input.now ?? new Date()).toISOString();
|
|
126
|
+
const policy = getEffectiveLoopStopPolicy(input.job);
|
|
127
|
+
const definitions = new Map(input.definitions.map((definition) => [definition.type, definition]));
|
|
128
|
+
const decisions = [];
|
|
129
|
+
const conditionStates = { ...(input.job.state.conditionStates ?? {}) };
|
|
130
|
+
let finalAction = 'continue';
|
|
131
|
+
for (const instance of policy.conditions) {
|
|
132
|
+
const base = { id: instance.id, type: instance.type, phase: input.phase };
|
|
133
|
+
if (instance.enabled === false) {
|
|
134
|
+
decisions.push({ ...base, action: 'continue', skipped: true, reason: 'disabled' });
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const compatibleType = instance.type.startsWith('pibo.ralph.') ? instance.type.replace('pibo.ralph.', 'pibo.loop.') : instance.type;
|
|
138
|
+
const definition = definitions.get(instance.type) ?? definitions.get(compatibleType);
|
|
139
|
+
if (!definition) {
|
|
140
|
+
decisions.push({ ...base, action: 'continue', skipped: true, error: `Unknown Loop stop condition type: ${instance.type}` });
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (!definition.phases.includes(input.phase)) {
|
|
144
|
+
decisions.push({ ...base, action: 'continue', skipped: true, reason: 'unsupported-phase' });
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
try {
|
|
148
|
+
const state = conditionStates[instance.id] ?? {};
|
|
149
|
+
const decision = sanitizeDecision(await withTimeout(Promise.resolve(definition.evaluate({ phase: input.phase, job: input.job, policy, instance, state, now, run: input.run, outcome: input.outcome, facts: input.facts, signal: input.signal })), instance.timeoutMs ?? definition.timeoutMs, input.signal));
|
|
150
|
+
if (decision.nextState)
|
|
151
|
+
conditionStates[instance.id] = decision.nextState;
|
|
152
|
+
decisions.push({ ...base, action: decision.action, reason: decision.reason, details: decision.details });
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
const failClosed = instance.failClosed ?? definition.failClosedDefault ?? false;
|
|
156
|
+
const action = failClosed ? 'stop-after-run' : 'continue';
|
|
157
|
+
decisions.push({ ...base, action, reason: failClosed ? 'condition-error-fail-closed' : 'condition-error', error: error instanceof Error ? error.message : String(error) });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const active = decisions.filter((decision) => !decision.skipped);
|
|
161
|
+
if (policy.mode === 'all' && active.length > 0) {
|
|
162
|
+
const allStop = active.every((decision) => severity(decision.action) >= severity('stop-after-run'));
|
|
163
|
+
finalAction = allStop ? active.reduce((action, decision) => highest(action, decision.action), 'stop-after-run') : 'continue';
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
finalAction = active.reduce((action, decision) => highest(action, decision.action), 'continue');
|
|
167
|
+
}
|
|
168
|
+
const contributing = finalAction === 'continue' ? active.find((decision) => decision.error || decision.reason) : active.find((decision) => decision.action === finalAction) ?? active.find((decision) => severity(decision.action) > 0);
|
|
169
|
+
return { evaluation: { id: `rse_${randomUUID()}`, phase: input.phase, at: now, mode: policy.mode, finalAction, reason: contributing?.reason ?? (contributing?.error ? 'condition-error' : undefined), decisions }, conditionStates };
|
|
170
|
+
}
|