@pasko70/pibo 1.16.6 → 2.0.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 (145) hide show
  1. package/dist/agent-runtime/auth.js +28 -0
  2. package/dist/agent-runtime/capabilities.js +221 -0
  3. package/dist/agent-runtime/context-build.js +313 -0
  4. package/dist/agent-runtime/contract.js +45 -0
  5. package/dist/agent-runtime/errors.js +57 -0
  6. package/dist/agent-runtime/events.js +1 -0
  7. package/dist/agent-runtime/history.js +1 -0
  8. package/dist/agent-runtime/profile-validation.js +109 -0
  9. package/dist/agent-runtime/registry.js +608 -0
  10. package/dist/agent-runtime/resource-files.js +87 -0
  11. package/dist/agent-runtime/resource-service.js +635 -0
  12. package/dist/agent-runtime/resources.js +1 -0
  13. package/dist/agent-runtime/routed-session.js +931 -0
  14. package/dist/agent-runtime/testing/contract.js +51 -0
  15. package/dist/agent-runtime/testing/fake-adapter.js +192 -0
  16. package/dist/agent-runtime/types.js +3 -0
  17. package/dist/agent-runtimes/codex-native/adapter.js +905 -0
  18. package/dist/agent-runtimes/codex-native/auth.js +476 -0
  19. package/dist/agent-runtimes/codex-native/client.js +734 -0
  20. package/dist/agent-runtimes/codex-native/config.js +152 -0
  21. package/dist/agent-runtimes/codex-native/history.js +283 -0
  22. package/dist/agent-runtimes/codex-native/mcp-stdio-launcher.js +89 -0
  23. package/dist/agent-runtimes/codex-native/models.js +581 -0
  24. package/dist/agent-runtimes/codex-native/process.js +459 -0
  25. package/dist/agent-runtimes/codex-native/protocol-types.js +1 -0
  26. package/dist/agent-runtimes/codex-native/protocol-version.js +7 -0
  27. package/dist/agent-runtimes/codex-native/redaction.js +31 -0
  28. package/dist/agent-runtimes/codex-native/requests.js +378 -0
  29. package/dist/agent-runtimes/codex-native/resource-delivery.js +445 -0
  30. package/dist/agent-runtimes/codex-native/thread.js +388 -0
  31. package/dist/agent-runtimes/codex-native/turn.js +849 -0
  32. package/dist/agent-runtimes/pi/adapter.js +653 -0
  33. package/dist/agent-runtimes/pi/auth.js +455 -0
  34. package/dist/agent-runtimes/pi/history.js +640 -0
  35. package/dist/agent-runtimes/pi/model-catalog.js +87 -0
  36. package/dist/agent-runtimes/pi/routed-session.js +1464 -0
  37. package/dist/agent-runtimes/pi/runtime.js +534 -0
  38. package/dist/agent-runtimes/pi/tool-compiler.js +69 -0
  39. package/dist/apps/chat/agent-profiles.js +40 -23
  40. package/dist/apps/chat/agent-store.js +111 -64
  41. package/dist/apps/chat/chat-api-routes.js +1 -1
  42. package/dist/apps/chat/chat-request-normalizers.js +47 -0
  43. package/dist/apps/chat/data/chat-data-mappers.js +25 -9
  44. package/dist/apps/chat/data/history-query-service.js +108 -0
  45. package/dist/apps/chat/data/session-query-service.js +24 -3
  46. package/dist/apps/chat/data/timeline-query-service.js +3 -3
  47. package/dist/apps/chat/model-catalog.js +1 -55
  48. package/dist/apps/chat/provider-auth-actions.js +171 -23
  49. package/dist/apps/chat/stream.js +12 -0
  50. package/dist/apps/chat/trace-v2.js +1 -0
  51. package/dist/apps/chat/trace.js +126 -415
  52. package/dist/apps/chat/web-app.js +582 -157
  53. package/dist/apps/chat-ui/assets/{dist-BTLtT_Vf.js → dist-9v2ZXT6V.js} +1 -1
  54. package/dist/apps/chat-ui/assets/{dist-CMk1aPug.js → dist-B1LVAytl.js} +1 -1
  55. package/dist/apps/chat-ui/assets/{dist-CcwA_IWN.js → dist-C6LPDFXU.js} +1 -1
  56. package/dist/apps/chat-ui/assets/{dist-DKOthbxr.js → dist-DVtXxfHc.js} +1 -1
  57. package/dist/apps/chat-ui/assets/{dist-ls2I6BIw.js → dist-DW4Qrfbd.js} +1 -1
  58. package/dist/apps/chat-ui/assets/{dist-D1rAtRWs.js → dist-DmbsHdMC.js} +1 -1
  59. package/dist/apps/chat-ui/assets/{dist-C1JQRskW.js → dist-DyvwuSFO.js} +1 -1
  60. package/dist/apps/chat-ui/assets/{dist-DfpaylQ-.js → dist-I26VB0QO.js} +1 -1
  61. package/dist/apps/chat-ui/assets/{dist-D10bTFD5.js → dist-RtHbJRPV.js} +1 -1
  62. package/dist/apps/chat-ui/assets/{dist-5KpmmBBZ.js → dist-sZgJkWZb.js} +1 -1
  63. package/dist/apps/chat-ui/assets/index-BPbNvcZe.css +1 -0
  64. package/dist/apps/chat-ui/assets/index-CIOf2uL2.js +237 -0
  65. package/dist/apps/chat-ui/index.html +2 -2
  66. package/dist/apps/chat-vscode-web/assets/index-1ivRyjFs.js +41 -0
  67. package/dist/apps/chat-vscode-web/index.html +1 -1
  68. package/dist/apps/vscode-artifacts/latest.vsix +0 -0
  69. package/dist/apps/vscode-artifacts/pibo-vscode-ext-2.0.0.vsix +0 -0
  70. package/dist/auth/login-actions.js +5 -251
  71. package/dist/cli-session/localSessionSource.js +8 -1
  72. package/dist/core/context-build.js +124 -20
  73. package/dist/core/default-profile.js +8 -0
  74. package/dist/core/profiles.js +30 -3
  75. package/dist/core/routed-session.js +5 -1446
  76. package/dist/core/runtime.js +5 -561
  77. package/dist/core/session-router.js +637 -83
  78. package/dist/data/cli.js +20 -3
  79. package/dist/data/schema.js +104 -1
  80. package/dist/data/session-store.js +24 -1
  81. package/dist/debug/events.js +25 -10
  82. package/dist/debug/failures.js +23 -3
  83. package/dist/debug/index.js +24 -6
  84. package/dist/debug/messages.js +87 -7
  85. package/dist/debug/persisted-payloads.js +31 -0
  86. package/dist/debug/pty.js +7 -6
  87. package/dist/debug/runtime-binding.js +29 -0
  88. package/dist/debug/session.js +137 -0
  89. package/dist/debug/summary.js +12 -0
  90. package/dist/debug/telemetry.js +28 -0
  91. package/dist/debug/tools.js +12 -2
  92. package/dist/debug/trace.js +154 -76
  93. package/dist/gateway/server.js +87 -2
  94. package/dist/gateway/tool.js +5 -5
  95. package/dist/index.js +21 -2
  96. package/dist/loops/tools.js +13 -12
  97. package/dist/mcp/agent-context.js +13 -4
  98. package/dist/mcp/client.js +10 -6
  99. package/dist/mcp/config.js +5 -2
  100. package/dist/mcp/runtime-session.js +166 -0
  101. package/dist/plugins/builtin.js +191 -53
  102. package/dist/plugins/codex-native.js +29 -0
  103. package/dist/plugins/registry.js +66 -2
  104. package/dist/runs/tools.js +26 -25
  105. package/dist/session-ui/terminalRows.js +2 -2
  106. package/dist/sessions/pibo-data-store.js +125 -16
  107. package/dist/sessions/runtime-binding.js +107 -0
  108. package/dist/sessions/sqlite-store.js +239 -18
  109. package/dist/sessions/store.js +86 -7
  110. package/dist/shared/trace-engine.js +18 -9
  111. package/dist/shared/trace-event-projection.js +29 -11
  112. package/dist/shared/{trace-transcript.js → trace-history.js} +193 -195
  113. package/dist/shared/trace-order.js +9 -4
  114. package/dist/shared/trace-page-merge.js +1 -1
  115. package/dist/signals/projector.js +20 -2
  116. package/dist/signals/registry.js +11 -0
  117. package/dist/subagents/tool.js +8 -6
  118. package/dist/tools/codex-browser.js +20 -19
  119. package/dist/tools/codex-compat.js +10 -9
  120. package/dist/tools/codex-image-generation.js +8 -6
  121. package/dist/tools/contract.js +45 -0
  122. package/dist/tools/credential-registry.js +182 -0
  123. package/dist/tools/mcp-bridge.js +511 -0
  124. package/dist/tools/payload-writer.js +17 -0
  125. package/dist/tools/runtime/tool.js +10 -9
  126. package/dist/tools/schema.js +9 -0
  127. package/dist/tools/session-service.js +193 -0
  128. package/dist/tools/session-tool-set.js +85 -0
  129. package/dist/web-annotations/tools.js +17 -16
  130. package/docs/README.md +11 -0
  131. package/package.json +3 -2
  132. package/skills/builtin/pibo-agent-runtime-adapter/SKILL.md +183 -0
  133. package/skills/builtin/pibo-agent-runtime-adapter/evals/README.md +10 -0
  134. package/skills/builtin/pibo-agent-runtime-adapter/evals/evals.json +45 -0
  135. package/skills/builtin/pibo-agent-runtime-adapter/evals/fixtures/orion-full-harness.md +60 -0
  136. package/skills/builtin/pibo-agent-runtime-adapter/evals/fixtures/relay-partial-harness.md +52 -0
  137. package/skills/builtin/pibo-agent-runtime-adapter/references/capabilities-and-designer.md +194 -0
  138. package/skills/builtin/pibo-agent-runtime-adapter/references/history-debug-and-security.md +213 -0
  139. package/skills/builtin/pibo-agent-runtime-adapter/references/interfaces-and-registration.md +214 -0
  140. package/skills/builtin/pibo-agent-runtime-adapter/references/lifecycle-bindings-and-events.md +193 -0
  141. package/skills/builtin/pibo-agent-runtime-adapter/references/portable-delivery-and-native-behavior.md +226 -0
  142. package/skills/builtin/pibo-agent-runtime-adapter/references/testing-migration-and-validation.md +256 -0
  143. package/dist/apps/chat-ui/assets/index-C2YI0xfw.js +0 -237
  144. package/dist/apps/chat-ui/assets/index-E0RmuCkY.css +0 -1
  145. package/dist/apps/chat-vscode-web/assets/index-D-tSsXLG.js +0 -41
package/dist/debug/pty.js CHANGED
@@ -312,20 +312,21 @@ function builtinScenario(name, options) {
312
312
  PIBO_DEBUG_PTY_ASSISTANT_REPLY: "Mocked PTY assistant response",
313
313
  },
314
314
  steps: [
315
- { waitFor: "Pibo CLI Sessions", timeoutMs: 20_000 },
316
- { typeText: "/new" },
315
+ { waitFor: "select room", timeoutMs: 20_000 },
317
316
  { press: "Enter" },
318
- { sleepMs: 750 },
317
+ { waitFor: "select session", timeoutMs: 10_000 },
318
+ { press: "Enter" },
319
+ { waitFor: "Created session", timeoutMs: 10_000 },
319
320
  { typeText: "Hi", iteration: true },
320
321
  { press: "Enter" },
321
322
  { waitFor: "Mocked PTY assistant response", timeoutMs: 10_000 },
322
323
  { typeText: "/status" },
323
324
  { press: "Enter" },
324
- { waitFor: "source=", timeoutMs: 10_000 },
325
- { typeText: "/quit" },
325
+ { waitFor: "Runtime: local", timeoutMs: 10_000 },
326
+ { typeText: "/exit" },
326
327
  { press: "Enter" },
327
328
  ],
328
- expect: ["Pibo CLI Sessions", "Hi", "Mocked PTY assistant response"],
329
+ expect: ["pibo sessions", "Created session", "Hi", "Mocked PTY assistant response", "Runtime: local"],
329
330
  reject: ["UnhandledPromiseRejection", "source_closed"],
330
331
  }, options);
331
332
  }
@@ -0,0 +1,29 @@
1
+ export function readDebugRuntimeIdentity(db, piboSessionId) {
2
+ const bindingTable = db.prepare("SELECT name FROM sqlite_schema WHERE type = 'table' AND name = 'session_runtime_bindings'").get();
3
+ if (bindingTable) {
4
+ const row = db.prepare(`
5
+ SELECT runtime_instance_id, runtime_adapter_id, native_session_id, binding_state
6
+ FROM session_runtime_bindings WHERE pibo_session_id = ?
7
+ `).get(piboSessionId);
8
+ if (row) {
9
+ return {
10
+ runtimeInstanceId: row.runtime_instance_id,
11
+ runtimeAdapterId: row.runtime_adapter_id,
12
+ nativeSessionId: row.native_session_id ?? undefined,
13
+ runtimeBindingState: row.binding_state,
14
+ };
15
+ }
16
+ }
17
+ const sessionsTable = db.prepare("SELECT name FROM sqlite_schema WHERE type = 'table' AND name = 'sessions'").get();
18
+ if (!sessionsTable)
19
+ return {};
20
+ const session = db.prepare("SELECT pi_session_id FROM sessions WHERE id = ?").get(piboSessionId);
21
+ if (!session)
22
+ return {};
23
+ return {
24
+ runtimeInstanceId: "pi",
25
+ runtimeAdapterId: "pi",
26
+ nativeSessionId: session.pi_session_id ?? undefined,
27
+ runtimeBindingState: session.pi_session_id ? "bound" : "unbound",
28
+ };
29
+ }
@@ -36,6 +36,7 @@ export function inspectDebugSession(input, stores, options = {}) {
36
36
  warnings,
37
37
  session: compactSessionRow(session),
38
38
  metadata,
39
+ runtimeBinding: readRuntimeBinding(sessionsDb, session),
39
40
  room: {
40
41
  urlRoomId: parsed.roomId,
41
42
  sessionRoomId,
@@ -74,6 +75,78 @@ export function inspectDebugSession(input, stores, options = {}) {
74
75
  sessionsDb.close();
75
76
  }
76
77
  }
78
+ export function inspectDebugSessionRuntime(input, stores) {
79
+ const parsed = parseDebugSessionInput(input);
80
+ if (!stores.sessions.exists)
81
+ throw new Error(`Debug store "sessions" not found at ${stores.sessions.path}`);
82
+ const sessionsDb = openReadOnlyDebugDatabase(stores.sessions);
83
+ const chatDb = stores.chat.exists && stores.chat.path !== stores.sessions.path ? openReadOnlyDebugDatabase(stores.chat) : sessionsDb;
84
+ try {
85
+ const session = sessionsDb.prepare("SELECT * FROM sessions WHERE id = ?").get(parsed.piboSessionId);
86
+ if (!session)
87
+ throw new Error(`Pibo session "${parsed.piboSessionId}" not found`);
88
+ const binding = readRuntimeBinding(sessionsDb, session);
89
+ const eventStats = tableExists(chatDb, "event_log")
90
+ ? chatDb.prepare(`
91
+ SELECT COUNT(*) AS count, COUNT(payload_ref) AS payload_refs,
92
+ MIN(session_sequence) AS first_sequence, MAX(session_sequence) AS last_sequence
93
+ FROM event_log WHERE session_id = ?
94
+ `).get(parsed.piboSessionId)
95
+ : { count: 0, payload_refs: 0, first_sequence: null, last_sequence: null };
96
+ const messages = tableExists(chatDb, "chat_messages")
97
+ ? Number(chatDb.prepare("SELECT COUNT(*) AS count FROM chat_messages WHERE session_id = ?").get(parsed.piboSessionId).count)
98
+ : 0;
99
+ const observations = tableExists(chatDb, "observations")
100
+ ? Number(chatDb.prepare("SELECT COUNT(*) AS count FROM observations WHERE session_id = ?").get(parsed.piboSessionId).count)
101
+ : 0;
102
+ return {
103
+ piboSessionId: parsed.piboSessionId,
104
+ resultType: "debug.session.runtime",
105
+ binding,
106
+ productHistory: {
107
+ messages,
108
+ events: Number(eventStats.count),
109
+ observations,
110
+ payloadRefs: Number(eventStats.payload_refs),
111
+ firstEventSequence: eventStats.first_sequence ?? undefined,
112
+ lastEventSequence: eventStats.last_sequence ?? undefined,
113
+ },
114
+ nextCommands: [
115
+ `pibo debug trace ${parsed.piboSessionId} --check`,
116
+ `pibo debug trace ${parsed.piboSessionId} --native-history --check`,
117
+ `pibo debug events ${parsed.piboSessionId} --limit 20`,
118
+ ],
119
+ };
120
+ }
121
+ catch (error) {
122
+ throw withStorePath(withStorePath(error, stores.chat), stores.sessions);
123
+ }
124
+ finally {
125
+ sessionsDb.close();
126
+ if (chatDb !== sessionsDb)
127
+ chatDb.close();
128
+ }
129
+ }
130
+ export function formatDebugSessionRuntime(result) {
131
+ const lines = [
132
+ `piboSessionId: ${result.piboSessionId}`,
133
+ "",
134
+ "Runtime binding:",
135
+ ...Object.entries(result.binding).map(([key, value]) => ` ${key}: ${formatValue(value)}`),
136
+ "",
137
+ "Product history:",
138
+ ` messages: ${result.productHistory.messages}`,
139
+ ` events: ${result.productHistory.events}`,
140
+ ` observations: ${result.productHistory.observations}`,
141
+ ` payloadRefs: ${result.productHistory.payloadRefs}`,
142
+ ];
143
+ if (result.productHistory.firstEventSequence !== undefined)
144
+ lines.push(` firstEventSequence: ${result.productHistory.firstEventSequence}`);
145
+ if (result.productHistory.lastEventSequence !== undefined)
146
+ lines.push(` lastEventSequence: ${result.productHistory.lastEventSequence}`);
147
+ lines.push(...formatNextCommands(result.nextCommands));
148
+ return lines.join("\n");
149
+ }
77
150
  export function formatDebugSessionSummary(summary) {
78
151
  const lines = [];
79
152
  lines.push(`piboSessionId: ${summary.input.piboSessionId}`);
@@ -90,6 +163,13 @@ export function formatDebugSessionSummary(summary) {
90
163
  for (const [key, value] of Object.entries(summary.session)) {
91
164
  lines.push(` ${key}: ${formatValue(value)}`);
92
165
  }
166
+ if (summary.runtimeBinding) {
167
+ lines.push("");
168
+ lines.push("Runtime binding:");
169
+ for (const [key, value] of Object.entries(summary.runtimeBinding)) {
170
+ lines.push(` ${key}: ${formatValue(value)}`);
171
+ }
172
+ }
93
173
  if (Object.keys(summary.metadata).length) {
94
174
  lines.push("");
95
175
  lines.push("Metadata:");
@@ -147,6 +227,63 @@ function listChildSessions(db, piboSessionId, limit) {
147
227
  };
148
228
  });
149
229
  }
230
+ function readRuntimeBinding(db, session) {
231
+ if (!tableExists(db, "session_runtime_bindings")) {
232
+ return {
233
+ pibo_session_id: session.id,
234
+ runtime_instance_id: "pi",
235
+ runtime_adapter_id: "pi",
236
+ native_session_id: session.pi_session_id,
237
+ binding_state: session.pi_session_id ? "bound" : "unbound",
238
+ source: "legacy-synthesized",
239
+ };
240
+ }
241
+ const row = db.prepare(`
242
+ SELECT
243
+ pibo_session_id, runtime_instance_id, runtime_adapter_id, native_session_id,
244
+ binding_state, protocol, protocol_version, adapter_version, locator_json,
245
+ metadata_json, revision, created_at, updated_at
246
+ FROM session_runtime_bindings
247
+ WHERE pibo_session_id = ?
248
+ `).get(session.id);
249
+ if (row) {
250
+ const { locator_json, metadata_json, ...safe } = row;
251
+ return {
252
+ ...safe,
253
+ locator: sanitizeBindingLocator(parseObject(locator_json ?? null)),
254
+ metadata_keys: Object.keys(parseObject(metadata_json ?? null)).sort(),
255
+ };
256
+ }
257
+ return {
258
+ pibo_session_id: session.id,
259
+ runtime_instance_id: "pi",
260
+ runtime_adapter_id: "pi",
261
+ native_session_id: session.pi_session_id,
262
+ binding_state: session.pi_session_id ? "bound" : "unbound",
263
+ source: "legacy-synthesized",
264
+ };
265
+ }
266
+ function sanitizeBindingLocator(locator) {
267
+ const kind = stringValue(locator.kind);
268
+ if (!kind)
269
+ return undefined;
270
+ const value = stringValue(locator.value);
271
+ if (!value)
272
+ return { kind };
273
+ if (kind === "local-file" || kind === "local-directory")
274
+ return { kind, value };
275
+ try {
276
+ const url = new URL(value);
277
+ url.username = "";
278
+ url.password = "";
279
+ url.search = "";
280
+ url.hash = "";
281
+ return { kind, value: url.toString() };
282
+ }
283
+ catch {
284
+ return { kind, value: "[redacted]" };
285
+ }
286
+ }
150
287
  function readChatSession(db, piboSessionId) {
151
288
  if (!tableExists(db, "sessions"))
152
289
  return undefined;
@@ -22,6 +22,10 @@ export async function inspectDebugSummary(input, stores) {
22
22
  }, {});
23
23
  return {
24
24
  piboSessionId: parsed.piboSessionId,
25
+ runtimeInstanceId: session.runtimeBinding?.runtime_instance_id,
26
+ runtimeAdapterId: session.runtimeBinding?.runtime_adapter_id,
27
+ nativeSessionId: session.runtimeBinding?.native_session_id,
28
+ runtimeBindingState: session.runtimeBinding?.binding_state,
25
29
  status: session.session.status,
26
30
  traceStatus,
27
31
  roomId: session.room.sessionRoomId,
@@ -45,6 +49,14 @@ export async function inspectDebugSummary(input, stores) {
45
49
  export function formatDebugSummary(result) {
46
50
  const lines = [];
47
51
  lines.push(`piboSessionId: ${result.piboSessionId}`);
52
+ if (result.runtimeInstanceId !== undefined)
53
+ lines.push(`runtimeInstanceId: ${result.runtimeInstanceId}`);
54
+ if (result.runtimeAdapterId !== undefined)
55
+ lines.push(`runtimeAdapterId: ${result.runtimeAdapterId}`);
56
+ if (result.nativeSessionId !== undefined)
57
+ lines.push(`nativeSessionId: ${result.nativeSessionId}`);
58
+ if (result.runtimeBindingState !== undefined)
59
+ lines.push(`runtimeBindingState: ${result.runtimeBindingState}`);
48
60
  if (result.status !== undefined)
49
61
  lines.push(`status: ${result.status}`);
50
62
  if (result.traceStatus)
@@ -1,6 +1,7 @@
1
1
  import { DatabaseSync } from "node:sqlite";
2
2
  import { TelemetryStaleDetector } from "../core/telemetry-staleness.js";
3
3
  import { TelemetryStore as PiboTelemetryStore } from "../data/telemetry.js";
4
+ import { readDebugRuntimeIdentity } from "./runtime-binding.js";
4
5
  import { formatRows, openReadOnlyDebugDatabase } from "./sql.js";
5
6
  const DEFAULT_TELEMETRY_CLI_LIMIT = 20;
6
7
  const MAX_TELEMETRY_CLI_LIMIT = 200;
@@ -36,6 +37,7 @@ export function inspectTelemetrySession(store, piboSessionId, options = {}) {
36
37
  return notFound(`No telemetry found for Pibo Session ${piboSessionId}.`, piboSessionId);
37
38
  return {
38
39
  available: true,
40
+ ...readTelemetryRuntimeIdentity(store, piboSessionId),
39
41
  command: "session",
40
42
  piboSessionId,
41
43
  limit,
@@ -59,6 +61,7 @@ export function inspectTelemetryTurn(store, turnIdOrEventId, options = {}) {
59
61
  const missingTerminalEvent = timeline.turn.status === "running" && !timeline.phases.some((phase) => phase.name === "finish" && phase.status === "ok");
60
62
  return {
61
63
  available: true,
64
+ ...readTelemetryRuntimeIdentity(store, timeline.turn.piboSessionId),
62
65
  command: "turn",
63
66
  turnIdOrEventId,
64
67
  limit,
@@ -82,6 +85,7 @@ export function inspectTelemetryProvider(store, providerRequestId) {
82
85
  return notFound(`No telemetry found for provider request ${providerRequestId}.`);
83
86
  return {
84
87
  available: true,
88
+ ...readTelemetryRuntimeIdentity(store, request.piboSessionId),
85
89
  command: "provider",
86
90
  providerRequestId,
87
91
  request,
@@ -105,6 +109,7 @@ export function inspectTelemetryProviderEvents(store, providerRequestId, options
105
109
  }));
106
110
  return {
107
111
  available: true,
112
+ ...readTelemetryRuntimeIdentity(store, request.piboSessionId),
108
113
  command: "provider events",
109
114
  providerRequestId,
110
115
  limit,
@@ -123,6 +128,7 @@ export function inspectTelemetryProviderPayload(store, providerRequestId, payloa
123
128
  return notFound(`No telemetry found for provider request ${providerRequestId}.`);
124
129
  return {
125
130
  available: true,
131
+ ...readTelemetryRuntimeIdentity(store, request.piboSessionId),
126
132
  command: "provider payload",
127
133
  providerRequestId,
128
134
  payloadRef,
@@ -138,6 +144,7 @@ export function inspectTelemetryTool(store, toolCallId) {
138
144
  return notFound(`No telemetry found for tool call ${toolCallId}.`);
139
145
  return {
140
146
  available: true,
147
+ ...readTelemetryRuntimeIdentity(store, tool.piboSessionId),
141
148
  command: "tool",
142
149
  toolCallId,
143
150
  tool,
@@ -236,6 +243,7 @@ export function formatTelemetrySession(result) {
236
243
  const toolCallId = firstId(detail.toolCalls, "toolCallId");
237
244
  return [
238
245
  `pibo debug telemetry session ${result.piboSessionId}`,
246
+ ...formatTelemetryRuntimeIdentity(result),
239
247
  `status\t${activeTurn?.status ?? "idle"}`,
240
248
  `queueDepth\t${activeTurn?.queueDepth ?? "-"}`,
241
249
  `activeTurn\t${activeTurn?.turnId ?? "-"}`,
@@ -263,6 +271,7 @@ export function formatTelemetryTurn(result) {
263
271
  return [
264
272
  `pibo debug telemetry turn ${timeline.turn.turnId}`,
265
273
  `session\t${timeline.turn.piboSessionId}`,
274
+ ...formatTelemetryRuntimeIdentity(result),
266
275
  `status\t${timeline.turn.status}`,
267
276
  `currentPhase\t${timeline.turn.currentPhase ?? "-"}`,
268
277
  `openPhases\t${result.openPhases}`,
@@ -285,6 +294,7 @@ export function formatTelemetryProvider(result) {
285
294
  return [
286
295
  `pibo debug telemetry provider ${result.providerRequestId}`,
287
296
  `session\t${request.piboSessionId}`,
297
+ ...formatTelemetryRuntimeIdentity(result),
288
298
  `turn\t${request.turnId}`,
289
299
  `phase\t${request.phaseId ?? "-"}`,
290
300
  `status\t${request.status}`,
@@ -413,6 +423,17 @@ export function formatTelemetryPrune(result) {
413
423
  ...result.nextCommands.map((command) => ` ${command}`),
414
424
  ].join("\n");
415
425
  }
426
+ function readTelemetryRuntimeIdentity(store, piboSessionId) {
427
+ if (!store.exists)
428
+ return {};
429
+ const db = openReadOnlyDebugDatabase(store);
430
+ try {
431
+ return readDebugRuntimeIdentity(db, piboSessionId);
432
+ }
433
+ finally {
434
+ db.close();
435
+ }
436
+ }
416
437
  function withTelemetryStore(store, action, options = {}) {
417
438
  if (!store.exists) {
418
439
  return {
@@ -484,6 +505,13 @@ function notFound(message, piboSessionId, turnId) {
484
505
  ].filter((command) => typeof command === "string"),
485
506
  };
486
507
  }
508
+ function formatTelemetryRuntimeIdentity(result) {
509
+ return [
510
+ result.runtimeInstanceId ? `runtimeInstanceId\t${result.runtimeInstanceId}` : undefined,
511
+ result.runtimeAdapterId ? `runtimeAdapterId\t${result.runtimeAdapterId}` : undefined,
512
+ result.runtimeBindingState ? `runtimeBindingState\t${result.runtimeBindingState}` : undefined,
513
+ ].filter((value) => Boolean(value));
514
+ }
487
515
  function formatUnavailable(result) {
488
516
  return [
489
517
  result.message,
@@ -2,6 +2,8 @@ import { DEFAULT_TOOL_BYTES, formatTruncationFooter, sliceTextByBytes } from "./
2
2
  import { formatNextCommands } from "./next-commands.js";
3
3
  import { eventAttributes, eventPayload, stringifyPayloadValue } from "./payloads.js";
4
4
  import { openReadOnlyDebugDatabase, withStorePath } from "./sql.js";
5
+ import { createDebugPayloadStore, hydrateDebugEventRow } from "./persisted-payloads.js";
6
+ import { readDebugRuntimeIdentity } from "./runtime-binding.js";
5
7
  export function inspectDebugTool(piboSessionId, store, selector, options = {}) {
6
8
  if (!store.exists)
7
9
  throw new Error(`Debug store "chat" not found at ${store.path}`);
@@ -9,12 +11,13 @@ export function inspectDebugTool(piboSessionId, store, selector, options = {}) {
9
11
  try {
10
12
  if (!tableExists(db, "event_log"))
11
13
  return emptyTool(piboSessionId, selector);
14
+ const payloadStore = createDebugPayloadStore(db, store);
12
15
  const rows = db.prepare(`
13
- SELECT stream_id, session_id, session_sequence, event_id, type, created_at, preview_text, attributes_json
16
+ SELECT stream_id, session_id, session_sequence, event_id, type, created_at, payload_ref, preview_text, attributes_json
14
17
  FROM event_log
15
18
  WHERE session_id = ? AND type IN ('tool_call', 'tool_execution_started', 'tool_execution_updated', 'tool_execution_finished')
16
19
  ORDER BY stream_id ASC
17
- `).all(piboSessionId);
20
+ `).all(piboSessionId).map((row) => hydrateDebugEventRow(row, payloadStore));
18
21
  const matching = rows.filter((row) => toolCallIdFromRow(row)?.includes(selector) || row.event_id === selector);
19
22
  if (matching.length === 0)
20
23
  return emptyTool(piboSessionId, selector);
@@ -30,6 +33,7 @@ export function inspectDebugTool(piboSessionId, store, selector, options = {}) {
30
33
  const outputSlice = output !== undefined ? sliceTextByBytes(stringifyPayloadValue(options.error ? (error ?? output) : output), options, DEFAULT_TOOL_BYTES) : undefined;
31
34
  return {
32
35
  piboSessionId,
36
+ ...readDebugRuntimeIdentity(db, piboSessionId),
33
37
  resultType: "debug.tool",
34
38
  selector,
35
39
  toolCallId,
@@ -63,6 +67,12 @@ export function formatDebugTool(result, options = {}) {
63
67
  if (!result.toolCallId)
64
68
  return [`tool: not found`, ...formatNextCommands(result.nextCommands)].join("\n");
65
69
  const lines = [];
70
+ if (result.runtimeInstanceId)
71
+ lines.push(`runtimeInstanceId: ${result.runtimeInstanceId}`);
72
+ if (result.runtimeAdapterId)
73
+ lines.push(`runtimeAdapterId: ${result.runtimeAdapterId}`);
74
+ if (result.runtimeBindingState)
75
+ lines.push(`runtimeBindingState: ${result.runtimeBindingState}`);
66
76
  lines.push(`toolCallId: ${result.toolCallId}`);
67
77
  if (result.toolName)
68
78
  lines.push(`toolName: ${result.toolName}`);