@pasko70/pibo 3.4.1 → 3.4.2

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 (39) hide show
  1. package/dist/agent-runtime/routed-session.js +5 -1
  2. package/dist/agent-runtimes/pi/adapter.js +4 -1
  3. package/dist/agent-runtimes/pi/history.js +55 -1
  4. package/dist/apps/chat/data/chat-data-mappers.js +1 -1
  5. package/dist/apps/chat/stream.js +1 -1
  6. package/dist/apps/chat/trace-v2.js +1 -0
  7. package/dist/apps/chat/web-app.js +2 -1
  8. package/dist/apps/chat-ui/assets/{dist-DnZL1rRp.js → dist-B7Ju7u08.js} +1 -1
  9. package/dist/apps/chat-ui/assets/{dist-ERKABhp3.js → dist-BDnWOTcs.js} +1 -1
  10. package/dist/apps/chat-ui/assets/{dist-D0md0xIR.js → dist-CAiO6h6z.js} +1 -1
  11. package/dist/apps/chat-ui/assets/{dist-Abz605MV.js → dist-CCR1HsaR.js} +1 -1
  12. package/dist/apps/chat-ui/assets/{dist-DHnaUMlq.js → dist-CXWLhBio.js} +1 -1
  13. package/dist/apps/chat-ui/assets/index-0cCGS0o3.js +228 -0
  14. package/dist/apps/chat-ui/assets/index-BMJGoyM8.css +1 -0
  15. package/dist/apps/chat-ui/index.html +2 -2
  16. package/dist/apps/chat-vscode-web/assets/index-BD3Ogz9Z.js +43 -0
  17. package/dist/apps/chat-vscode-web/index.html +1 -1
  18. package/dist/auth/openai-codex-usage.js +34 -5
  19. package/dist/core/session-router.js +94 -11
  20. package/dist/data/ingest-service.js +1 -1
  21. package/dist/data/schema.js +10 -1
  22. package/dist/debug/agents.js +5 -3
  23. package/dist/gateway/server.js +1 -1
  24. package/dist/session-ui/terminalRows.js +3 -1
  25. package/dist/sessions/pibo-data-store.js +38 -1
  26. package/dist/sessions/store.js +38 -0
  27. package/dist/shared/tool-call-metrics.js +77 -0
  28. package/dist/shared/trace-event-projection.js +2 -0
  29. package/dist/shared/trace-live-reducer.js +1 -0
  30. package/dist/shared/trace-patch-nodes.js +4 -0
  31. package/dist/subagents/context.js +2 -2
  32. package/dist/subagents/observation-query.js +28 -1
  33. package/dist/subagents/observations.js +8 -0
  34. package/dist/subagents/tool.js +12 -8
  35. package/npm-shrinkwrap.json +2 -2
  36. package/package.json +1 -1
  37. package/dist/apps/chat-ui/assets/index-BWVPNFjU.js +0 -228
  38. package/dist/apps/chat-ui/assets/index-CywOD6EF.css +0 -1
  39. package/dist/apps/chat-vscode-web/assets/index-CZmxeSn3.js +0 -43
@@ -1,6 +1,31 @@
1
- import { PIBO_AGENT_OBSERVATION_DEFAULT_EVENT_TYPES, PIBO_AGENT_OBSERVATION_DEFAULT_TOOL_EVENT_TYPES, normalizePiboAgentObservationCursor, normalizePiboAgentObservationLimit, normalizePiboAgentObservationOrder, normalizePiboAgentObservationToolDetail, parsePiboAgentObservationTimestamp, piboAgentObservationKind, piboAgentObservationToolSummary, } from "./observations.js";
1
+ import { createHash } from "node:crypto";
2
+ import { PIBO_AGENT_OBSERVATION_DEFAULT_EVENT_TYPES, PIBO_AGENT_OBSERVATION_DEFAULT_TOOL_EVENT_TYPES, normalizePiboAgentObservationCursor, normalizePiboAgentObservationCursorMode, normalizePiboAgentObservationLimit, normalizePiboAgentObservationOrder, normalizePiboAgentObservationToolDetail, parsePiboAgentObservationTimestamp, piboAgentObservationKind, piboAgentObservationToolSummary, } from "./observations.js";
2
3
  import { PIBO_AGENT_TEXT_REGEX_BATCH_MAX_ITEMS, PIBO_AGENT_TEXT_REGEX_BATCH_TARGET_BYTES, matchPiboAgentObservationTextRegex, preparePiboAgentObservationTextRegex, } from "./observation-text-regex.js";
4
+ function sortedUnique(values) {
5
+ return values ? [...new Set(values)].sort() : undefined;
6
+ }
7
+ export function piboAgentObservationCursorScopeKey(input) {
8
+ const scope = {
9
+ requestIds: sortedUnique(input.requestIds),
10
+ toolCallIds: sortedUnique(input.toolCallIds),
11
+ agentIds: sortedUnique(input.agentIds),
12
+ names: sortedUnique(input.names),
13
+ threadKeys: sortedUnique(input.threadKeys),
14
+ eventTypes: sortedUnique(input.eventTypes),
15
+ kinds: input.kinds ? [...new Set(input.kinds)].sort() : undefined,
16
+ roles: sortedUnique(input.roles),
17
+ since: input.since,
18
+ until: input.until,
19
+ textContains: input.textContains?.toLowerCase(),
20
+ textRegex: input.textRegex,
21
+ includeTools: input.includeTools === true,
22
+ toolDetail: input.toolDetail ?? "summary",
23
+ includeDetails: input.includeDetails === true,
24
+ };
25
+ return `v1:${createHash("sha256").update(JSON.stringify(scope)).digest("hex")}`;
26
+ }
3
27
  export function preparePiboAgentObservationQuery(input = {}) {
28
+ const cursorMode = normalizePiboAgentObservationCursorMode(input.cursorMode);
4
29
  const order = normalizePiboAgentObservationOrder(input.order);
5
30
  const limit = normalizePiboAgentObservationLimit(input.limit);
6
31
  const toolDetail = normalizePiboAgentObservationToolDetail(input.toolDetail);
@@ -40,6 +65,7 @@ export function preparePiboAgentObservationQuery(input = {}) {
40
65
  return {
41
66
  filters: {
42
67
  ...input,
68
+ cursorMode,
43
69
  ...(defaultMessageView ? { eventTypes: defaultEventTypes } : {}),
44
70
  ...(afterSequence !== undefined ? { afterSequence } : {}),
45
71
  order,
@@ -49,6 +75,7 @@ export function preparePiboAgentObservationQuery(input = {}) {
49
75
  includeDetails: input.includeDetails === true,
50
76
  },
51
77
  ...(afterSequence !== undefined ? { afterSequence } : {}),
78
+ cursorMode,
52
79
  order,
53
80
  scanOrder: afterSequence !== undefined ? "asc" : order,
54
81
  limit,
@@ -212,6 +212,14 @@ export function normalizePiboAgentObservationOrder(value) {
212
212
  throw new Error(`Agent observation order must be "asc" or "desc".`);
213
213
  return value;
214
214
  }
215
+ export function normalizePiboAgentObservationCursorMode(value) {
216
+ if (value === undefined)
217
+ return "auto";
218
+ if (value !== "auto" && value !== "history") {
219
+ throw new Error(`Agent observation cursorMode must be "auto" or "history".`);
220
+ }
221
+ return value;
222
+ }
215
223
  export function normalizePiboAgentObservationToolDetail(value) {
216
224
  if (value === undefined)
217
225
  return "summary";
@@ -60,12 +60,15 @@ function preparePiboDeprecatedSubagentToolInput(input) {
60
60
  export function formatAgentObservationsForModel(result) {
61
61
  const includeTools = result.filters.includeTools === true;
62
62
  const toolDetail = result.filters.toolDetail ?? "summary";
63
+ const cursorMode = result.filters.cursorMode ?? "auto";
63
64
  const lines = [
64
- `Agent observations (${result.observations.length}; tools=${includeTools ? toolDetail : "hidden"}; order=${result.filters.order ?? "desc"}; limit=${result.filters.limit ?? 20})`,
65
- `nextAfterSequence=${result.nextAfterSequence}; truncated=${result.truncated}`,
65
+ `Agent observations (${result.observations.length}; cursor=${cursorMode}; tools=${includeTools ? toolDetail : "hidden"}; order=${result.filters.order ?? "desc"}; limit=${result.filters.limit ?? 20})`,
66
+ `afterSequence=${result.filters.afterSequence ?? "initial"}; nextAfterSequence=${result.nextAfterSequence}${result.autoCursorSequence === undefined ? "" : `; autoCursorSequence=${result.autoCursorSequence}`}; truncated=${result.truncated}`,
66
67
  ];
67
68
  if (result.observations.length === 0) {
68
- lines.push("", "No delegated-agent observations matched the filters.");
69
+ lines.push("", cursorMode === "auto"
70
+ ? "No new delegated-agent messages matched since the automatic cursor. Use cursorMode=\"history\" only when you need to reread earlier observations."
71
+ : "No historical delegated-agent observations matched the filters.");
69
72
  return lines.join("\n");
70
73
  }
71
74
  for (const observation of result.observations) {
@@ -188,10 +191,10 @@ export function createAgentToolDefinitions(subagents, controller) {
188
191
  title: "Pibo Agents Observe",
189
192
  description: [
190
193
  "Read completed delegated-agent messages with bounded cursor, identity, event, time, substring, regex, order, and limit filters.",
191
- "Default: the newest 20 completed assistant messages, with streaming deltas and tools hidden.",
192
- "Set includeTools=true to add compact tool calls and terminal results, or pass toolCallIds to retrieve only those exact tool observations. Set toolDetail=full only for bounded diagnostic inspection.",
194
+ "Default cursorMode=auto: the first equivalent query returns the newest 20 completed assistant messages; later calls return only unread messages. Streaming deltas, duplicate tool progress events, and tools stay hidden.",
195
+ "Use cursorMode=history only to reread earlier observations. Inspect tools only when an agent appears stuck, reports a problem, or needs targeted diagnosis; prefer exact toolCallIds, then includeTools=true, and use toolDetail=full only when compact summaries are insufficient.",
193
196
  ].join("\n"),
194
- promptSnippet: "Observe child-agent progress through completed assistant messages. Defaults: newest 20 messages, no streaming deltas, no duplicate tool progress events, no tools. Use textContains for case-insensitive substring matching or textRegex for case-sensitive rg/Rust-regex matching; when both are present, both must match. Set includeTools=true for compact tool call/result summaries, pass up to 50 exact toolCallIds to retrieve only those tool observations, use toolDetail=full for bounded raw tool text, or eventTypes/kinds for explicit progress diagnostics. Compact tool entries expose their toolCallId for follow-up queries. Pass afterSequence from the previous result for cursor polling; cursor pages consume the oldest unseen matches even when order is desc.",
197
+ promptSnippet: "Observe child progress through completed assistant messages. cursorMode=auto is the default and remembers each equivalent query, so repeated calls return only unread messages; use cursorMode=history to reread earlier observations. Streaming deltas, duplicate tool progress events, and tools are hidden by default. Inspect tools only for stalls, errors, or targeted diagnosis: prefer exact toolCallIds, use includeTools=true only when broader context is needed, and use toolDetail=full only when summaries are insufficient. Use textContains or textRegex for focused matching; different filters use separate automatic cursors. An explicit afterSequence overrides the stored cursor and advances that automatic query cursor.",
195
198
  executionMode: "parallel",
196
199
  annotations: { readOnly: true },
197
200
  inputSchema: Type.Object({
@@ -207,10 +210,11 @@ export function createAgentToolDefinitions(subagents, controller) {
207
210
  until: Type.Optional(Type.String({ description: "Inclusive ISO-8601 upper timestamp bound" })),
208
211
  textContains: Type.Optional(Type.String({ description: "Case-insensitive substring match against normalized observation text" })),
209
212
  textRegex: Type.Optional(Type.String({ description: "Case-sensitive rg/Rust-regex match against normalized observation text. Use inline flags such as (?i) to change case behavior. Combines with textContains using AND semantics. NUL text and literal or escaped NUL patterns are rejected; regex use requires the optional rg platform binary." })),
210
- afterSequence: Type.Optional(Type.Integer({ description: "Exclusive live observation cursor. Cursor pages consume the oldest unseen matches; desc reverses only the returned page.", minimum: 0 })),
213
+ cursorMode: Type.Optional(piboStringEnum(["auto", "history"], { default: "auto", description: "auto remembers this normalized query and returns only unread observations after its first newest-message snapshot. history ignores and does not change the saved cursor, allowing deliberate rereads." })),
214
+ afterSequence: Type.Optional(Type.Integer({ description: "Explicit exclusive cursor override. In auto mode it replaces and advances the saved cursor for this normalized query; cursor pages consume the oldest unseen matches and desc reverses only the returned page.", minimum: 0 })),
211
215
  order: Type.Optional(piboStringEnum(["asc", "desc"], { default: "desc", description: "Newest first by default when no cursor is supplied" })),
212
216
  limit: Type.Optional(Type.Integer({ description: "Maximum completed messages or activity records to return. Use 50 explicitly when needed.", minimum: 1, maximum: 200, default: 20 })),
213
- includeTools: Type.Optional(Type.Boolean({ description: "Include tools. Default false. With the default message view, true adds tool_call and tool_execution_finished records.", default: false })),
217
+ includeTools: Type.Optional(Type.Boolean({ description: "Include compact tool calls and terminal results. Default false; enable only for stalls, errors, or targeted diagnosis. Prefer exact toolCallIds when known.", default: false })),
214
218
  toolDetail: Type.Optional(piboStringEnum(["summary", "full"], { default: "summary", description: "Tool text detail when tools are included. summary is compact; full remains bounded to the observation text limit." })),
215
219
  includeDetails: Type.Optional(Type.Boolean({ description: "Include the normalized source event in structured details. Default false; use only for diagnostics.", default: false })),
216
220
  }),
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pasko70/pibo",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@pasko70/pibo",
9
- "version": "3.4.1",
9
+ "version": "3.4.2",
10
10
  "workspaces": [
11
11
  "packages/workflows"
12
12
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pasko70/pibo",
3
- "version": "3.4.1",
3
+ "version": "3.4.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",