@pasko70/pibo 1.9.13 → 1.10.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.
Files changed (139) hide show
  1. package/README.md +183 -183
  2. package/context/codex-base-prompt.md +148 -148
  3. package/context/compute-worker.md +23 -23
  4. package/context/pibo-compaction-prompt.md +100 -100
  5. package/context/pibo-native-tooling.md +18 -18
  6. package/context/pibo-system-prompt.md +77 -77
  7. package/dist/apps/chat/agent-profiles.js +2 -2
  8. package/dist/apps/chat/agent-store.js +263 -250
  9. package/dist/apps/chat/chat-request-normalizers.js +10 -0
  10. package/dist/apps/chat/data/project-service.js +168 -168
  11. package/dist/apps/chat/data/read-state-service.js +18 -18
  12. package/dist/apps/chat/data/session-query-service.js +25 -25
  13. package/dist/apps/chat/data/timeline-query-service.js +19 -19
  14. package/dist/apps/chat/loop-api.js +176 -0
  15. package/dist/apps/chat/static-assets.js +854 -854
  16. package/dist/apps/chat/web-app.js +6 -6
  17. package/dist/apps/chat/workflow-manual-trigger-runtime.js +149 -46
  18. package/dist/apps/chat/workflow-persistence.js +255 -255
  19. package/dist/apps/chat-ui/assets/{dist-yCYNNb5d.js → dist-BwKObYnX.js} +1 -1
  20. package/dist/apps/chat-ui/assets/{dist-BCB6zezO.js → dist-CKtT8YGm.js} +1 -1
  21. package/dist/apps/chat-ui/assets/{dist-CnVsqwSG.js → dist-CS7wdk0Z.js} +1 -1
  22. package/dist/apps/chat-ui/assets/{dist-HqTN67dc.js → dist-D-cxLQO1.js} +1 -1
  23. package/dist/apps/chat-ui/assets/{dist-BNMu92bb.js → dist-DUlaXAk7.js} +1 -1
  24. package/dist/apps/chat-ui/assets/{dist-CzE6k3F3.js → dist-DlATLa-U.js} +1 -1
  25. package/dist/apps/chat-ui/assets/{dist-Dq4GxJi3.js → dist-GdEM8UW1.js} +1 -1
  26. package/dist/apps/chat-ui/assets/{dist-BZ2eTC4f.js → dist-LHRs1Nhr.js} +1 -1
  27. package/dist/apps/chat-ui/assets/{dist-D811wJeV.js → dist-Y-AA2omI.js} +1 -1
  28. package/dist/apps/chat-ui/assets/{dist-WyXdYl-w.js → dist-nOLTkZrJ.js} +1 -1
  29. package/dist/apps/chat-ui/assets/{dist-BHa-kcGl.js → dist-wE9nop9V.js} +1 -1
  30. package/dist/apps/chat-ui/assets/{index-DwHJfmiF.js → index-8W_yMHQI.js} +6 -6
  31. package/dist/apps/chat-ui/index.html +17 -17
  32. package/dist/apps/chat-ui/manifest.webmanifest +25 -25
  33. package/dist/apps/chat-ui/sw.js +47 -47
  34. package/dist/apps/chat-vscode-web/index.html +12 -12
  35. package/dist/apps/cli-ui/cliSessionsCommand.js +23 -23
  36. package/dist/apps/context-files-ui/index.html +11 -11
  37. package/dist/cli.js +61 -44
  38. package/dist/compute/cli.js +54 -54
  39. package/dist/core/routed-session.js +30 -1
  40. package/dist/core/runtime.js +6 -1
  41. package/dist/core/session-router.js +4 -2
  42. package/dist/cron/cli.js +15 -15
  43. package/dist/cron/store.js +49 -49
  44. package/dist/data/cli.js +23 -23
  45. package/dist/data/event-log.js +23 -23
  46. package/dist/data/message-store.js +27 -27
  47. package/dist/data/navigation-store.js +9 -9
  48. package/dist/data/observation-store.js +4 -4
  49. package/dist/data/payload-store.js +17 -17
  50. package/dist/data/schema.js +433 -433
  51. package/dist/data/session-store.js +4 -4
  52. package/dist/data/telemetry-queries.js +54 -54
  53. package/dist/data/telemetry.js +197 -197
  54. package/dist/debug/events.js +12 -12
  55. package/dist/debug/failures.js +6 -6
  56. package/dist/debug/index.js +227 -227
  57. package/dist/debug/messages.js +6 -6
  58. package/dist/debug/pty.js +124 -124
  59. package/dist/debug/session.js +29 -29
  60. package/dist/debug/tools.js +5 -5
  61. package/dist/debug/web-snapshot-browser-scripts.js +294 -294
  62. package/dist/debug/web-streaming-browser-library.js +925 -925
  63. package/dist/debug/web-streaming-browser-scripts.js +232 -232
  64. package/dist/debug/web-streaming-provider-telemetry.js +4 -4
  65. package/dist/debug/web.js +93 -93
  66. package/dist/gateway/cli.js +19 -19
  67. package/dist/gateway/server.js +4 -2
  68. package/dist/gateway/web.js +2 -2
  69. package/dist/loops/channel.js +8 -0
  70. package/dist/loops/cli.js +208 -0
  71. package/dist/loops/plugin.js +16 -0
  72. package/dist/loops/prompts.js +83 -0
  73. package/dist/loops/service.js +357 -0
  74. package/dist/loops/stopping.js +170 -0
  75. package/dist/loops/store.js +531 -0
  76. package/dist/loops/templates.js +232 -0
  77. package/dist/loops/tools.js +167 -0
  78. package/dist/loops/types.js +1 -0
  79. package/dist/mcp/config-command.js +53 -53
  80. package/dist/mcp/index.js +21 -21
  81. package/dist/mcp/registry.js +11 -11
  82. package/dist/pi-packages/cli.js +11 -11
  83. package/dist/plugins/builtin.js +8 -0
  84. package/dist/plugins/context-files-store.js +110 -110
  85. package/dist/plugins/context-files.js +4 -4
  86. package/dist/plugins/registry.js +23 -12
  87. package/dist/ralph/cli.js +18 -18
  88. package/dist/ralph/templates.js +140 -140
  89. package/dist/reliability/store.js +226 -226
  90. package/dist/sessions/pibo-data-store.js +16 -16
  91. package/dist/sessions/sqlite-store.js +53 -53
  92. package/dist/setup/cli.js +58 -58
  93. package/dist/tools/agent-browser-wrapper.js +80 -80
  94. package/dist/tools/browser-use-cdp.js +12 -12
  95. package/dist/tools/browser-use-wrapper.js +762 -762
  96. package/dist/tools/guides.js +589 -538
  97. package/dist/tools/index.js +122 -99
  98. package/dist/tools/registry.js +21 -3
  99. package/dist/tools/runtime/node-worker-source.js +205 -205
  100. package/dist/tools/runtime/python-worker-source.js +177 -177
  101. package/dist/vscode/cli.js +9 -9
  102. package/dist/web-annotations/cdp.js +900 -900
  103. package/dist/web-annotations/store.js +96 -96
  104. package/docs/README.md +23 -23
  105. package/docs/ops/install-developer-host.md +112 -112
  106. package/docs/ops/install-user-host.md +96 -96
  107. package/docs/ops/upgrade-user-to-developer-host.md +69 -69
  108. package/docs/ops/vscode-extension-release.md +160 -160
  109. package/package.json +98 -95
  110. package/skills/builtin/graphify/SKILL.md +52 -52
  111. package/skills/builtin/loop/SKILL.md +69 -0
  112. package/skills/builtin/pi-agent-harness/SKILL.md +319 -319
  113. package/skills/builtin/pi-agent-harness/agents/openai.yaml +4 -4
  114. package/skills/builtin/pibo-docker-system/SKILL.md +170 -170
  115. package/skills/builtin/pibo-spec-writing/SKILL.md +330 -330
  116. package/skills/builtin/prd/SKILL.md +143 -143
  117. package/skills/builtin/ralph-loop/SKILL.md +361 -359
  118. package/skills/builtin/ralph-prd-json/SKILL.md +123 -123
  119. package/skills/builtin/skill-creator/LICENSE.txt +201 -201
  120. package/skills/builtin/skill-creator/SKILL.md +513 -513
  121. package/skills/builtin/skill-creator/agents/analyzer.md +274 -274
  122. package/skills/builtin/skill-creator/agents/comparator.md +202 -202
  123. package/skills/builtin/skill-creator/agents/grader.md +223 -223
  124. package/skills/builtin/skill-creator/assets/eval_review.html +146 -146
  125. package/skills/builtin/skill-creator/eval-viewer/generate_review.py +471 -471
  126. package/skills/builtin/skill-creator/eval-viewer/viewer.html +1325 -1325
  127. package/skills/builtin/skill-creator/references/schemas.md +430 -430
  128. package/skills/builtin/skill-creator/scripts/aggregate_benchmark.py +401 -401
  129. package/skills/builtin/skill-creator/scripts/generate_report.py +326 -326
  130. package/skills/builtin/skill-creator/scripts/improve_description.py +247 -247
  131. package/skills/builtin/skill-creator/scripts/package_skill.py +136 -136
  132. package/skills/builtin/skill-creator/scripts/quick_validate.py +102 -102
  133. package/skills/builtin/skill-creator/scripts/run_eval.py +310 -310
  134. package/skills/builtin/skill-creator/scripts/run_loop.py +328 -328
  135. package/skills/builtin/skill-creator/scripts/utils.py +47 -47
  136. package/skills/builtin/web-annotations/SKILL.md +93 -93
  137. package/src/mcp/LICENSE.mcp-cli +21 -21
  138. package/dist/apps/vscode-artifacts/latest.vsix +0 -0
  139. package/dist/apps/vscode-artifacts/pibo-vscode-ext-1.9.13.vsix +0 -0
@@ -0,0 +1,176 @@
1
+ import { PiboWebHttpError, readJsonBody, responseJson } from '../../web/http.js';
2
+ import { getPiboLoopService } from '../../loops/channel.js';
3
+ import { listLoopJobTemplates } from '../../loops/templates.js';
4
+ import { isPiboThinkingLevel } from '../../core/thinking.js';
5
+ import { normalizeLoopStopPolicy } from '../../loops/store.js';
6
+ import { isPiboRoomArchived } from './types/rooms.js';
7
+ const CHAT_WEB_API_PREFIX = '/api/chat';
8
+ function requireSameOriginJsonRequest(request) { const contentType = request.headers.get('content-type')?.split(';')[0]?.trim().toLowerCase(); if (contentType !== 'application/json')
9
+ throw new PiboWebHttpError('Content-Type must be application/json', 415); const origin = request.headers.get('origin'); if (!origin)
10
+ throw new PiboWebHttpError('Origin header is required', 403); if (origin !== new URL(request.url).origin)
11
+ throw new PiboWebHttpError('Origin is not allowed', 403); }
12
+ function accessDenied(error) { throw new PiboWebHttpError(error instanceof Error ? error.message : 'Access denied', 403); }
13
+ function normalizeString(value, field, options = {}) { if (value === undefined || value === null) {
14
+ if (options.required)
15
+ throw new PiboWebHttpError(`${field} is required`, 400);
16
+ return undefined;
17
+ } if (typeof value !== 'string')
18
+ throw new PiboWebHttpError(`${field} must be a string`, 400); const normalized = value.trim(); if (!normalized && options.required)
19
+ throw new PiboWebHttpError(`${field} is required`, 400); if (options.max && normalized.length > options.max)
20
+ throw new PiboWebHttpError(`${field} is too long`, 400); return normalized || undefined; }
21
+ function normalizeEnabled(value) { if (value === undefined)
22
+ return undefined; if (typeof value !== 'boolean')
23
+ throw new PiboWebHttpError('enabled must be a boolean', 400); return value; }
24
+ function normalizeMode(value, fallback) { if (value === undefined || value === null || value === '')
25
+ return fallback; if (value !== 'goal' && value !== 'ralph')
26
+ throw new PiboWebHttpError('mode must be goal or ralph', 400); return value; }
27
+ function normalizeMaxIterations(value) { if (value === undefined || value === null || value === '')
28
+ return undefined; if (typeof value !== 'number' || !Number.isInteger(value) || value < 1)
29
+ throw new PiboWebHttpError('maxIterations must be a positive integer', 400); return value; }
30
+ function normalizeTokenBudget(value) { if (value === undefined || value === null || value === '')
31
+ return undefined; if (typeof value !== 'number' || !Number.isInteger(value) || value < 1)
32
+ throw new PiboWebHttpError('tokenBudget must be a positive integer', 400); return value; }
33
+ function normalizeStopPolicy(value) { if (value === undefined || value === null)
34
+ return undefined; try {
35
+ return normalizeLoopStopPolicy(value);
36
+ }
37
+ catch (error) {
38
+ throw new PiboWebHttpError(error instanceof Error ? error.message : 'Invalid stopPolicy', 400);
39
+ } }
40
+ function normalizeModelOverride(value) { if (value === undefined || value === null)
41
+ return undefined; if (!value || typeof value !== 'object' || Array.isArray(value))
42
+ throw new PiboWebHttpError('modelOverride must be an object', 400); const raw = value; if (typeof raw.provider !== 'string' || typeof raw.id !== 'string')
43
+ throw new PiboWebHttpError('modelOverride must include provider and id', 400); const provider = raw.provider.trim(); const id = raw.id.trim(); if (!provider || !id)
44
+ throw new PiboWebHttpError('modelOverride must include provider and id', 400); return { provider, id }; }
45
+ function normalizeThinkingLevel(value) { if (value === undefined || value === null || value === '')
46
+ return undefined; if (typeof value !== 'string' || !isPiboThinkingLevel(value))
47
+ throw new PiboWebHttpError('thinkingLevel must be one of off, minimal, low, medium, high, xhigh, max', 400); return value; }
48
+ function normalizeFastMode(value) { if (value === undefined || value === null)
49
+ return undefined; if (typeof value !== 'boolean')
50
+ throw new PiboWebHttpError('fastMode must be a boolean', 400); return value; }
51
+ function normalizeTarget(value, options) { if (!value || typeof value !== 'object' || Array.isArray(value))
52
+ throw new PiboWebHttpError('target is required', 400); const raw = value; if (raw.kind === 'room') {
53
+ const roomId = normalizeString(raw.roomId, 'target.roomId', { required: true });
54
+ let room;
55
+ try {
56
+ room = options.roomService.requireRoom(roomId);
57
+ }
58
+ catch (error) {
59
+ accessDenied(error);
60
+ }
61
+ if (isPiboRoomArchived(room))
62
+ throw new PiboWebHttpError('Archived rooms are read-only', 403);
63
+ return { kind: 'room', roomId };
64
+ } if (raw.kind === 'default-chat') {
65
+ options.roomService.ensureDefaultRoom({ name: 'Shared Chat' });
66
+ return { kind: 'default-chat' };
67
+ } throw new PiboWebHttpError('target.kind must be room or default-chat', 400); }
68
+ function resolveProfile(context, fallback, value) { const requested = normalizeString(value, 'profile') ?? fallback; const profile = context.channelContext.getProfiles?.().find((item) => item.name === requested || item.aliases.includes(requested)); if (!profile)
69
+ throw new PiboWebHttpError(`Unknown profile: ${requested}`, 400); return profile.name; }
70
+ function jobResource(pathname) { const prefix = `${CHAT_WEB_API_PREFIX}/loops/jobs/`; if (!pathname.startsWith(prefix))
71
+ return undefined; const parts = pathname.slice(prefix.length).split('/').filter(Boolean).map((part) => decodeURIComponent(part)); if (!parts[0] || parts.length > 2)
72
+ return undefined; if (parts[1] && !['start', 'stop', 'cancel'].includes(parts[1]))
73
+ return undefined; return { id: parts[0], child: parts[1] }; }
74
+ function createPatch(body, options) { const patch = {}; if (body.mode !== undefined)
75
+ patch.mode = normalizeMode(body.mode, 'goal'); const name = normalizeString(body.name, 'name', { max: 120 }); if (body.name !== undefined && name !== undefined)
76
+ patch.name = name; if (body.description !== undefined)
77
+ patch.description = normalizeString(body.description, 'description', { max: 500 }); const enabled = normalizeEnabled(body.enabled); if (enabled !== undefined)
78
+ patch.enabled = enabled; if (body.target !== undefined)
79
+ patch.target = normalizeTarget(body.target, options); if (body.profile !== undefined)
80
+ patch.profile = resolveProfile(options.context, options.defaultProfile, body.profile); if (body.prompt !== undefined)
81
+ patch.prompt = normalizeString(body.prompt, 'prompt', { required: true, max: 20_000 }); if (body.maxIterations !== undefined)
82
+ patch.maxIterations = normalizeMaxIterations(body.maxIterations) ?? null; if (body.tokenBudget !== undefined)
83
+ patch.tokenBudget = normalizeTokenBudget(body.tokenBudget) ?? null; if (body.stopPolicy !== undefined)
84
+ patch.stopPolicy = normalizeStopPolicy(body.stopPolicy) ?? null; if (body.modelOverride !== undefined)
85
+ patch.modelOverride = normalizeModelOverride(body.modelOverride) ?? null; if (body.thinkingLevel !== undefined)
86
+ patch.thinkingLevel = normalizeThinkingLevel(body.thinkingLevel) ?? null; if (body.fastMode !== undefined)
87
+ patch.fastMode = normalizeFastMode(body.fastMode) ?? null; if (Object.keys(patch).length === 0)
88
+ throw new PiboWebHttpError('No Loop job update fields provided', 400); return patch; }
89
+ function serializeTarget(target) { return target.kind === 'room' ? target : { kind: 'default-chat' }; }
90
+ function serializeJob(job) { const { target, ...rest } = job; return { ...rest, target: serializeTarget(target) }; }
91
+ function serializeRun(run) { return run; }
92
+ export async function handleChatLoopApiRequest(options) {
93
+ const { request, loopStore } = options;
94
+ const url = new URL(request.url);
95
+ const legacyRalphRequest = url.pathname.startsWith(`${CHAT_WEB_API_PREFIX}/ralph`);
96
+ if (!legacyRalphRequest && !url.pathname.startsWith(`${CHAT_WEB_API_PREFIX}/loops`) && !url.pathname.startsWith(`${CHAT_WEB_API_PREFIX}/loop`))
97
+ return undefined;
98
+ const apiPath = url.pathname.replace(/^\/api\/chat\/(?:ralph|loop)(?=\/|$)/, `${CHAT_WEB_API_PREFIX}/loops`);
99
+ if (apiPath === `${CHAT_WEB_API_PREFIX}/loops/status` && request.method === 'GET')
100
+ return responseJson({ status: getPiboLoopService()?.status() ?? { enabled: false, ...loopStore.status() } });
101
+ if (apiPath === `${CHAT_WEB_API_PREFIX}/loops/conditions` && request.method === 'GET')
102
+ return responseJson({ conditions: options.context.channelContext.getLoopStopConditionInfos?.() ?? options.context.channelContext.getCapabilityCatalog?.().loopStopConditions ?? [] });
103
+ if (apiPath === `${CHAT_WEB_API_PREFIX}/loops/templates` && request.method === 'GET')
104
+ return responseJson({ templates: listLoopJobTemplates() });
105
+ if (apiPath === `${CHAT_WEB_API_PREFIX}/loops/jobs` && request.method === 'GET')
106
+ return responseJson({ jobs: loopStore.listJobs({ includeDisabled: url.searchParams.get('includeDisabled') === 'true' }).map(serializeJob) });
107
+ if (apiPath === `${CHAT_WEB_API_PREFIX}/loops/jobs` && request.method === 'POST') {
108
+ requireSameOriginJsonRequest(request);
109
+ const body = await readJsonBody(request);
110
+ const mode = normalizeMode(body.mode, legacyRalphRequest ? 'ralph' : 'goal');
111
+ const tokenBudget = normalizeTokenBudget(body.tokenBudget);
112
+ if (mode === 'ralph' && tokenBudget !== undefined)
113
+ throw new PiboWebHttpError('tokenBudget is only available for goal mode', 400);
114
+ const job = loopStore.createJob({ mode, name: normalizeString(body.name, 'name', { max: 120 }), description: normalizeString(body.description, 'description', { max: 500 }), enabled: normalizeEnabled(body.enabled), target: normalizeTarget(body.target, options), profile: resolveProfile(options.context, options.defaultProfile, body.profile), prompt: normalizeString(body.prompt, 'prompt', { required: true, max: 20_000 }), maxIterations: normalizeMaxIterations(body.maxIterations), tokenBudget, stopPolicy: normalizeStopPolicy(body.stopPolicy), modelOverride: normalizeModelOverride(body.modelOverride), thinkingLevel: normalizeThinkingLevel(body.thinkingLevel), fastMode: normalizeFastMode(body.fastMode) });
115
+ return responseJson({ job: serializeJob(job) }, { status: 201 });
116
+ }
117
+ if (apiPath === `${CHAT_WEB_API_PREFIX}/loops/runs` && request.method === 'GET') {
118
+ const jobId = url.searchParams.get('jobId') || undefined;
119
+ const limit = Number(url.searchParams.get('limit') ?? '100');
120
+ if (jobId && !loopStore.getJob(jobId))
121
+ throw new PiboWebHttpError('Loop job not found', 404);
122
+ return responseJson({ runs: loopStore.listRuns({ jobId, limit: Number.isFinite(limit) ? limit : 100 }).map(serializeRun) });
123
+ }
124
+ const resource = jobResource(apiPath);
125
+ if (!resource)
126
+ return undefined;
127
+ if (resource.child && request.method === 'POST') {
128
+ requireSameOriginJsonRequest(request);
129
+ const service = getPiboLoopService();
130
+ if (!service)
131
+ throw new PiboWebHttpError('Loop service is not running', 503);
132
+ if (resource.child === 'start') {
133
+ const run = await service.startJob(resource.id);
134
+ if (!run)
135
+ throw new PiboWebHttpError('Loop job not found, already running, or stopped by a before-run condition', 404);
136
+ return responseJson({ run: serializeRun(run) }, { status: 202 });
137
+ }
138
+ if (resource.child === 'stop') {
139
+ const job = service.stopJob(resource.id);
140
+ if (!job)
141
+ throw new PiboWebHttpError('Loop job not found', 404);
142
+ return responseJson({ job: serializeJob(job) });
143
+ }
144
+ const job = await service.cancelJob(resource.id);
145
+ if (!job)
146
+ throw new PiboWebHttpError('Loop job not found', 404);
147
+ return responseJson({ job: serializeJob(job) });
148
+ }
149
+ if (resource.child)
150
+ return undefined;
151
+ if (request.method === 'GET') {
152
+ const job = loopStore.getJob(resource.id);
153
+ if (!job)
154
+ throw new PiboWebHttpError('Loop job not found', 404);
155
+ return responseJson({ job: serializeJob(job) });
156
+ }
157
+ if (request.method === 'PATCH') {
158
+ requireSameOriginJsonRequest(request);
159
+ const body = await readJsonBody(request);
160
+ const patch = createPatch(body, options);
161
+ const existing = loopStore.getJob(resource.id);
162
+ if (!existing)
163
+ throw new PiboWebHttpError('Loop job not found', 404);
164
+ if ((patch.mode ?? existing.mode) === 'ralph' && patch.tokenBudget !== undefined && patch.tokenBudget !== null)
165
+ throw new PiboWebHttpError('tokenBudget is only available for goal mode', 400);
166
+ const job = loopStore.updateJob(resource.id, patch);
167
+ if (!job)
168
+ throw new PiboWebHttpError('Loop job not found', 404);
169
+ return responseJson({ job: serializeJob(job) });
170
+ }
171
+ if (request.method === 'DELETE') {
172
+ requireSameOriginJsonRequest(request);
173
+ return responseJson({ removed: loopStore.removeJob(resource.id) });
174
+ }
175
+ return undefined;
176
+ }