@pasko70/pibo 1.10.0 → 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.
Files changed (54) hide show
  1. package/dist/apps/chat/chat-request-normalizers.js +7 -0
  2. package/dist/apps/chat/data/chat-data-mappers.js +2 -0
  3. package/dist/apps/chat/loop-api.js +11 -6
  4. package/dist/apps/chat/web-app.js +30 -10
  5. package/dist/apps/chat-ui/assets/{dist-LHRs1Nhr.js → dist-3Sts0Afa.js} +1 -1
  6. package/dist/apps/chat-ui/assets/{dist-wE9nop9V.js → dist-4NlLjLs7.js} +1 -1
  7. package/dist/apps/chat-ui/assets/{dist-BwKObYnX.js → dist-BA6mhAec.js} +1 -1
  8. package/dist/apps/chat-ui/assets/{dist-Y-AA2omI.js → dist-BPl-fzRB.js} +1 -1
  9. package/dist/apps/chat-ui/assets/{dist-GdEM8UW1.js → dist-BPnn9e2B.js} +1 -1
  10. package/dist/apps/chat-ui/assets/{dist-DlATLa-U.js → dist-BpfBSMzK.js} +1 -1
  11. package/dist/apps/chat-ui/assets/{dist-CS7wdk0Z.js → dist-Cvx5M97R.js} +1 -1
  12. package/dist/apps/chat-ui/assets/{dist-nOLTkZrJ.js → dist-DnXWNQRm.js} +1 -1
  13. package/dist/apps/chat-ui/assets/{dist-DUlaXAk7.js → dist-hU-2oAb6.js} +1 -1
  14. package/dist/apps/chat-ui/assets/{dist-CKtT8YGm.js → dist-r31x5Fcc.js} +1 -1
  15. package/dist/apps/chat-ui/assets/{dist-D-cxLQO1.js → dist-uF6UXzI7.js} +1 -1
  16. package/dist/apps/chat-ui/assets/index-CaTGYBOS.js +173 -0
  17. package/dist/apps/chat-ui/assets/{index-C0x9nEcf.css → index-al8DeEjA.css} +1 -1
  18. package/dist/apps/chat-ui/index.html +2 -2
  19. package/dist/apps/chat-vscode-web/assets/index-CK4SMZuu.js +41 -0
  20. package/dist/apps/chat-vscode-web/index.html +1 -1
  21. package/dist/cli-session/localSessionSource.js +34 -12
  22. package/dist/compute/resource-health.js +35 -2
  23. package/dist/core/events.js +6 -1
  24. package/dist/core/routed-session.js +67 -4
  25. package/dist/core/session-router.js +23 -6
  26. package/dist/data/ingest-service.js +3 -1
  27. package/dist/debug/index.js +4 -0
  28. package/dist/debug/trace.js +42 -7
  29. package/dist/index.js +1 -0
  30. package/dist/loops/accounting.js +19 -0
  31. package/dist/loops/cli.js +22 -6
  32. package/dist/loops/prompts.js +4 -1
  33. package/dist/loops/service.js +97 -8
  34. package/dist/loops/store.js +128 -17
  35. package/dist/loops/tools.js +24 -7
  36. package/dist/reliability/store.js +34 -7
  37. package/dist/runs/lifecycle.js +59 -0
  38. package/dist/runs/registry.js +47 -1
  39. package/dist/runs/tools.js +31 -13
  40. package/dist/session-ui/terminalRows.js +66 -2
  41. package/dist/shared/trace-async-agent-runs.js +4 -4
  42. package/dist/shared/trace-event-projection.js +59 -19
  43. package/dist/shared/trace-nodes.js +5 -0
  44. package/dist/shared/trace-page-merge.js +15 -0
  45. package/dist/shared/trace-run-notifications.js +3 -1
  46. package/dist/signals/projector.js +6 -2
  47. package/dist/tools/browser-pool.js +50 -0
  48. package/dist/tools/browser-use-leases.js +12 -8
  49. package/dist/tools/guides.js +8 -1
  50. package/dist/tools/index.js +1 -0
  51. package/package.json +2 -1
  52. package/skills/builtin/loop/SKILL.md +12 -3
  53. package/dist/apps/chat-ui/assets/index-8W_yMHQI.js +0 -173
  54. package/dist/apps/chat-vscode-web/assets/index-BAMxIaI_.js +0 -41
@@ -368,6 +368,13 @@ export function normalizeMessageText(value) {
368
368
  }
369
369
  return value;
370
370
  }
371
+ export function normalizeMessageDelivery(value) {
372
+ if (value === undefined)
373
+ return "queue";
374
+ if (value === "queue" || value === "steer")
375
+ return value;
376
+ throw new PiboWebHttpError('Message delivery must be "queue" or "steer"', 400);
377
+ }
371
378
  export function defaultStreamingFixtureDeltas(mix) {
372
379
  if (mix === "markdown")
373
380
  return [" **a**", " **b**", " **c**", " **d**", " **e**", " **f**", " **g**", " **h**", " **i**", " **j**", " **k**", " **l**"];
@@ -23,6 +23,8 @@ function outputPayloadFromV2Row(row, attributes) {
23
23
  return { ...base, type: "assistant_message", text: row.preview_text ?? "" };
24
24
  if (row.type === "message_queued")
25
25
  return { ...base, type: "message_queued", text: stringAttribute(attributes, "inlineText") ?? row.preview_text ?? "", source: stringAttribute(attributes, "source") ?? "user", queuedMessages: numberAttribute(attributes, "queuedMessages") ?? 1 };
26
+ if (row.type === "message_steered")
27
+ return { ...base, type: "message_steered", text: stringAttribute(attributes, "inlineText") ?? row.preview_text ?? "", source: stringAttribute(attributes, "source") ?? "user", activeEventId: stringAttribute(attributes, "activeEventId") };
26
28
  if (row.type === "message_started")
27
29
  return { ...base, type: "message_started", text: row.preview_text ?? "" };
28
30
  if (row.type === "message_finished")
@@ -30,6 +30,9 @@ function normalizeMaxIterations(value) { if (value === undefined || value === nu
30
30
  function normalizeTokenBudget(value) { if (value === undefined || value === null || value === '')
31
31
  return undefined; if (typeof value !== 'number' || !Number.isInteger(value) || value < 1)
32
32
  throw new PiboWebHttpError('tokenBudget must be a positive integer', 400); return value; }
33
+ function normalizeTokenReserve(value) { if (value === undefined || value === null || value === '')
34
+ return undefined; if (typeof value !== 'number' || !Number.isInteger(value) || value < 0)
35
+ throw new PiboWebHttpError('tokenReserve must be a non-negative integer', 400); return value; }
33
36
  function normalizeStopPolicy(value) { if (value === undefined || value === null)
34
37
  return undefined; try {
35
38
  return normalizeLoopStopPolicy(value);
@@ -80,7 +83,8 @@ function createPatch(body, options) { const patch = {}; if (body.mode !== undefi
80
83
  patch.profile = resolveProfile(options.context, options.defaultProfile, body.profile); if (body.prompt !== undefined)
81
84
  patch.prompt = normalizeString(body.prompt, 'prompt', { required: true, max: 20_000 }); if (body.maxIterations !== undefined)
82
85
  patch.maxIterations = normalizeMaxIterations(body.maxIterations) ?? null; if (body.tokenBudget !== undefined)
83
- patch.tokenBudget = normalizeTokenBudget(body.tokenBudget) ?? null; if (body.stopPolicy !== undefined)
86
+ patch.tokenBudget = normalizeTokenBudget(body.tokenBudget) ?? null; if (body.tokenReserve !== undefined)
87
+ patch.tokenReserve = normalizeTokenReserve(body.tokenReserve) ?? null; if (body.stopPolicy !== undefined)
84
88
  patch.stopPolicy = normalizeStopPolicy(body.stopPolicy) ?? null; if (body.modelOverride !== undefined)
85
89
  patch.modelOverride = normalizeModelOverride(body.modelOverride) ?? null; if (body.thinkingLevel !== undefined)
86
90
  patch.thinkingLevel = normalizeThinkingLevel(body.thinkingLevel) ?? null; if (body.fastMode !== undefined)
@@ -109,9 +113,10 @@ export async function handleChatLoopApiRequest(options) {
109
113
  const body = await readJsonBody(request);
110
114
  const mode = normalizeMode(body.mode, legacyRalphRequest ? 'ralph' : 'goal');
111
115
  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) });
116
+ const tokenReserve = normalizeTokenReserve(body.tokenReserve);
117
+ if (mode === 'ralph' && (tokenBudget !== undefined || tokenReserve !== undefined))
118
+ throw new PiboWebHttpError('tokenBudget and tokenReserve are only available for goal mode', 400);
119
+ 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, tokenReserve, stopPolicy: normalizeStopPolicy(body.stopPolicy), modelOverride: normalizeModelOverride(body.modelOverride), thinkingLevel: normalizeThinkingLevel(body.thinkingLevel), fastMode: normalizeFastMode(body.fastMode) });
115
120
  return responseJson({ job: serializeJob(job) }, { status: 201 });
116
121
  }
117
122
  if (apiPath === `${CHAT_WEB_API_PREFIX}/loops/runs` && request.method === 'GET') {
@@ -161,8 +166,8 @@ export async function handleChatLoopApiRequest(options) {
161
166
  const existing = loopStore.getJob(resource.id);
162
167
  if (!existing)
163
168
  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);
169
+ if ((patch.mode ?? existing.mode) === 'ralph' && ((patch.tokenBudget !== undefined && patch.tokenBudget !== null) || (patch.tokenReserve !== undefined && patch.tokenReserve !== null)))
170
+ throw new PiboWebHttpError('tokenBudget and tokenReserve are only available for goal mode', 400);
166
171
  const job = loopStore.updateJob(resource.id, patch);
167
172
  if (!job)
168
173
  throw new PiboWebHttpError('Loop job not found', 404);
@@ -1,6 +1,7 @@
1
1
  import { createHash, randomUUID } from "node:crypto";
2
2
  import os from "node:os";
3
3
  import { monitorEventLoopDelay } from "node:perf_hooks";
4
+ import { PiboSteeringUnavailableError } from "../../core/events.js";
4
5
  import { summarizeSessionSignalStatus } from "../../signals/status.js";
5
6
  import { PiboWebHttpError, readJsonBody, responseJson } from "../../web/http.js";
6
7
  import { OutputCompactor } from "./output-compactor.js";
@@ -45,7 +46,7 @@ import { chatSettingsRoute, chatSettingsRouteInvalidatesBootstrapCatalog, chatSe
45
46
  import { chatCapabilityRoute, chatCapabilityRouteRequiresSameOrigin, handleChatCapabilityRoute, } from "./chat-capability-routes.js";
46
47
  import { chatUserSkillRoute, chatUserSkillRouteRequiresSameOrigin, handleChatUserSkillRoute, syncChatUserSkills, } from "./chat-user-skill-routes.js";
47
48
  import { CHAT_WEB_API_PREFIX, agentResourceId, projectResourcePath, projectSessionResourceId, projectWorkflowHumanActionsResource, projectWorkflowSessionStartResource, roomResourcePath, sessionActionResource, sessionResourceId, signalResource, workflowArchiveResourceId, workflowCatalogResourceId, workflowDraftActionResource, workflowDraftManualTriggerRunResource, workflowDraftResourceId, workflowDuplicateResourceId, workflowNextDraftResourceId, workflowPickerKind, workflowPromptAssetResourceId, workflowVersionResource, } from "./chat-api-routes.js";
48
- import { assertProjectSessionPatchFields, buildStreamingFixtureSchedule, createAgentInput, createAgentUpdate, createRoomUpdate, createSessionUpdate, normalizeAgentArchived, normalizeClientTxnId, normalizeMessageText, normalizeParentRoomId, normalizeProjectArchived, normalizeProjectDescription, normalizeProjectPath, normalizeProjectSessionArchived, normalizeRoomDeleteConfirmation, normalizeRoomName, normalizeRoomTopic, normalizeRoomType, normalizeRoomWorkspace, normalizeSessionDeleteConfirmation, normalizeSessionTitle, normalizeStreamingFixtureCadenceMs, normalizeStreamingFixtureDeltas, normalizeStreamingFixtureMix, normalizeStreamingFixturePreludeMessages, normalizeStreamingFixturePreludeOnly, normalizeStreamingFixtureProfile, normalizeStreamingFixtureSuppressLiveDeltas, normalizeStreamingFixtureTraceSnapshots, resolveCreateSessionProfile, } from "./chat-request-normalizers.js";
49
+ import { assertProjectSessionPatchFields, buildStreamingFixtureSchedule, createAgentInput, createAgentUpdate, createRoomUpdate, createSessionUpdate, normalizeAgentArchived, normalizeClientTxnId, normalizeMessageDelivery, normalizeMessageText, normalizeParentRoomId, normalizeProjectArchived, normalizeProjectDescription, normalizeProjectPath, normalizeProjectSessionArchived, normalizeRoomDeleteConfirmation, normalizeRoomName, normalizeRoomTopic, normalizeRoomType, normalizeRoomWorkspace, normalizeSessionDeleteConfirmation, normalizeSessionTitle, normalizeStreamingFixtureCadenceMs, normalizeStreamingFixtureDeltas, normalizeStreamingFixtureMix, normalizeStreamingFixturePreludeMessages, normalizeStreamingFixturePreludeOnly, normalizeStreamingFixtureProfile, normalizeStreamingFixtureSuppressLiveDeltas, normalizeStreamingFixtureTraceSnapshots, resolveCreateSessionProfile, } from "./chat-request-normalizers.js";
49
50
  import { ChatWorkflowArchiveStore, ChatWorkflowDraftStore, ChatWorkflowLifecycleEventStore, ChatWorkflowPromptAssetStore, ChatWorkflowPublishedVersionStore, ChatWorkflowTombstoneStore, hashWorkflowDefinitionJson, normalizeWorkflowPromptAssetLabel, sanitizeWorkflowDiagnostics, } from "./workflow-persistence.js";
50
51
  import { normalizeProjectWorkflowHumanActionBody, projectWorkflowHumanActionDiagnosticResponse, projectWorkflowHumanActionLifecyclePayload, projectWorkflowHumanActionRuntimeDiagnostic, projectWorkflowHumanActionSubmittedLifecyclePayload, projectWorkflowPendingHumanActionFromToken, validateProjectWorkflowHumanActionRequest, } from "./project-workflow-human-actions.js";
51
52
  import { createProjectWorkflowRunCurrent, createProjectWorkflowSessionSnapshot, normalizeProjectWorkflowSessionConfiguration, workflowVersionFromSnapshot, } from "./project-workflow-sessions.js";
@@ -2785,6 +2786,7 @@ function applyProjectSessionArchiveState(nodes, archivedBySessionId) {
2785
2786
  }
2786
2787
  async function sendProjectMessage(input) {
2787
2788
  const text = normalizeMessageText(input.body.text);
2789
+ const delivery = normalizeMessageDelivery(input.body.delivery);
2788
2790
  const clientTxnId = normalizeClientTxnId(input.body.clientTxnId);
2789
2791
  if (typeof input.body.piboSessionId !== "string")
2790
2792
  throw new PiboWebHttpError("Project session is required", 400);
@@ -2808,20 +2810,30 @@ async function sendProjectMessage(input) {
2808
2810
  piboSessionId: selectedSession.id,
2809
2811
  projectId: projectSession.projectId,
2810
2812
  text,
2813
+ delivery,
2811
2814
  ...(clientTxnId ? { clientTxnId } : {}),
2812
2815
  },
2813
2816
  });
2814
2817
  for (const listener of input.state.liveListeners)
2815
2818
  listener(accepted);
2816
2819
  const messageId = clientTxnId ?? randomUUID();
2817
- const output = await input.context.channelContext.emit({
2818
- type: "message",
2819
- piboSessionId: selectedSession.id,
2820
- id: messageId,
2821
- text,
2822
- source: "user",
2823
- });
2824
- return responseJson({ accepted, output });
2820
+ try {
2821
+ const output = await input.context.channelContext.emit({
2822
+ type: "message",
2823
+ piboSessionId: selectedSession.id,
2824
+ id: messageId,
2825
+ text,
2826
+ delivery,
2827
+ source: "user",
2828
+ });
2829
+ return responseJson({ accepted, output });
2830
+ }
2831
+ catch (error) {
2832
+ if (error instanceof PiboSteeringUnavailableError) {
2833
+ throw new PiboWebHttpError(error.message, 409);
2834
+ }
2835
+ throw error;
2836
+ }
2825
2837
  }
2826
2838
  function startChatStreamingFixture(input) {
2827
2839
  const requestedRoomId = typeof input.body.roomId === "string" ? input.body.roomId : undefined;
@@ -2918,6 +2930,7 @@ function startChatStreamingFixture(input) {
2918
2930
  }
2919
2931
  async function sendChatMessage(input) {
2920
2932
  const text = normalizeMessageText(input.body.text);
2933
+ const delivery = normalizeMessageDelivery(input.body.delivery);
2921
2934
  const clientTxnId = normalizeClientTxnId(input.body.clientTxnId);
2922
2935
  const requestedRoomId = input.forcedRoomId ?? (typeof input.body.roomId === "string" ? input.body.roomId : undefined);
2923
2936
  const selectedSession = resolveRequestedSession(input.state, input.context, input.webSession, input.defaultProfile, typeof input.body.piboSessionId === "string" ? input.body.piboSessionId : undefined, requestedRoomId);
@@ -2955,6 +2968,7 @@ async function sendChatMessage(input) {
2955
2968
  piboSessionId: selectedSession.id,
2956
2969
  roomId: room.id,
2957
2970
  text: fileAttachmentContext.messageText,
2971
+ delivery,
2958
2972
  ...(webAnnotationContext.attachments.length ? {
2959
2973
  webAnnotationIds: webAnnotationContext.ids,
2960
2974
  webAnnotationAttachments: webAnnotationContext.attachments,
@@ -2991,12 +3005,15 @@ async function sendChatMessage(input) {
2991
3005
  piboSessionId: selectedSession.id,
2992
3006
  id: messageId,
2993
3007
  text: fileAttachmentContext.messageText,
3008
+ delivery,
2994
3009
  source: "user",
2995
3010
  });
2996
3011
  }
2997
3012
  catch (error) {
2998
3013
  const errorMessage = error instanceof Error ? error.message : String(error);
2999
- input.context.channelContext.reportSessionError?.(selectedSession.id, errorMessage, { eventId: messageId, source: "pibo" });
3014
+ if (!(error instanceof PiboSteeringUnavailableError)) {
3015
+ input.context.channelContext.reportSessionError?.(selectedSession.id, errorMessage, { eventId: messageId, source: "pibo" });
3016
+ }
3000
3017
  const failed = input.state.eventCommands.appendEvent({
3001
3018
  roomId: room.id,
3002
3019
  piboSessionId: selectedSession.id,
@@ -3014,6 +3031,9 @@ async function sendChatMessage(input) {
3014
3031
  });
3015
3032
  for (const listener of input.state.liveListeners)
3016
3033
  listener(failed);
3034
+ if (error instanceof PiboSteeringUnavailableError) {
3035
+ throw new PiboWebHttpError(error.message, 409);
3036
+ }
3017
3037
  throw error;
3018
3038
  }
3019
3039
  markWebAnnotationsAttached(webAnnotationContext);