@pasko70/pibo 1.16.6 → 2.1.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 (156) 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/omp/adapter.js +581 -0
  33. package/dist/agent-runtimes/omp/auth.js +109 -0
  34. package/dist/agent-runtimes/omp/client.js +460 -0
  35. package/dist/agent-runtimes/omp/config.js +188 -0
  36. package/dist/agent-runtimes/omp/history.js +108 -0
  37. package/dist/agent-runtimes/omp/host-tools.js +201 -0
  38. package/dist/agent-runtimes/omp/models.js +86 -0
  39. package/dist/agent-runtimes/omp/process.js +283 -0
  40. package/dist/agent-runtimes/omp/protocol-types.js +17 -0
  41. package/dist/agent-runtimes/omp/resource-delivery.js +162 -0
  42. package/dist/agent-runtimes/omp/thread.js +141 -0
  43. package/dist/agent-runtimes/omp/turn.js +325 -0
  44. package/dist/agent-runtimes/pi/adapter.js +653 -0
  45. package/dist/agent-runtimes/pi/auth.js +455 -0
  46. package/dist/agent-runtimes/pi/history.js +640 -0
  47. package/dist/agent-runtimes/pi/model-catalog.js +87 -0
  48. package/dist/agent-runtimes/pi/routed-session.js +1464 -0
  49. package/dist/agent-runtimes/pi/runtime.js +534 -0
  50. package/dist/agent-runtimes/pi/tool-compiler.js +69 -0
  51. package/dist/apps/chat/agent-profiles.js +40 -23
  52. package/dist/apps/chat/agent-store.js +111 -64
  53. package/dist/apps/chat/chat-api-routes.js +1 -1
  54. package/dist/apps/chat/chat-request-normalizers.js +47 -0
  55. package/dist/apps/chat/data/chat-data-mappers.js +25 -9
  56. package/dist/apps/chat/data/history-query-service.js +108 -0
  57. package/dist/apps/chat/data/session-query-service.js +24 -3
  58. package/dist/apps/chat/data/timeline-query-service.js +3 -3
  59. package/dist/apps/chat/model-catalog.js +1 -55
  60. package/dist/apps/chat/provider-auth-actions.js +171 -23
  61. package/dist/apps/chat/stream.js +12 -0
  62. package/dist/apps/chat/trace-v2.js +1 -0
  63. package/dist/apps/chat/trace.js +126 -415
  64. package/dist/apps/chat/web-app.js +582 -157
  65. package/dist/apps/chat-ui/assets/{dist-BTLtT_Vf.js → dist-9v2ZXT6V.js} +1 -1
  66. package/dist/apps/chat-ui/assets/{dist-CMk1aPug.js → dist-B1LVAytl.js} +1 -1
  67. package/dist/apps/chat-ui/assets/{dist-CcwA_IWN.js → dist-C6LPDFXU.js} +1 -1
  68. package/dist/apps/chat-ui/assets/{dist-DKOthbxr.js → dist-DVtXxfHc.js} +1 -1
  69. package/dist/apps/chat-ui/assets/{dist-ls2I6BIw.js → dist-DW4Qrfbd.js} +1 -1
  70. package/dist/apps/chat-ui/assets/{dist-D1rAtRWs.js → dist-DmbsHdMC.js} +1 -1
  71. package/dist/apps/chat-ui/assets/{dist-C1JQRskW.js → dist-DyvwuSFO.js} +1 -1
  72. package/dist/apps/chat-ui/assets/{dist-DfpaylQ-.js → dist-I26VB0QO.js} +1 -1
  73. package/dist/apps/chat-ui/assets/{dist-D10bTFD5.js → dist-RtHbJRPV.js} +1 -1
  74. package/dist/apps/chat-ui/assets/{dist-5KpmmBBZ.js → dist-sZgJkWZb.js} +1 -1
  75. package/dist/apps/chat-ui/assets/index-BPbNvcZe.css +1 -0
  76. package/dist/apps/chat-ui/assets/index-CIOf2uL2.js +237 -0
  77. package/dist/apps/chat-ui/index.html +2 -2
  78. package/dist/apps/chat-vscode-web/assets/index-1ivRyjFs.js +41 -0
  79. package/dist/apps/chat-vscode-web/index.html +1 -1
  80. package/dist/auth/login-actions.js +5 -251
  81. package/dist/cli-session/localSessionSource.js +8 -1
  82. package/dist/core/context-build.js +124 -20
  83. package/dist/core/default-profile.js +8 -0
  84. package/dist/core/profiles.js +30 -3
  85. package/dist/core/routed-session.js +5 -1446
  86. package/dist/core/runtime.js +5 -561
  87. package/dist/core/session-router.js +637 -83
  88. package/dist/data/cli.js +20 -3
  89. package/dist/data/schema.js +104 -1
  90. package/dist/data/session-store.js +24 -1
  91. package/dist/debug/events.js +25 -10
  92. package/dist/debug/failures.js +23 -3
  93. package/dist/debug/index.js +24 -6
  94. package/dist/debug/messages.js +87 -7
  95. package/dist/debug/persisted-payloads.js +31 -0
  96. package/dist/debug/pty.js +7 -6
  97. package/dist/debug/runtime-binding.js +29 -0
  98. package/dist/debug/session.js +137 -0
  99. package/dist/debug/summary.js +12 -0
  100. package/dist/debug/telemetry.js +28 -0
  101. package/dist/debug/tools.js +12 -2
  102. package/dist/debug/trace.js +154 -76
  103. package/dist/gateway/server.js +87 -2
  104. package/dist/gateway/tool.js +5 -5
  105. package/dist/index.js +21 -2
  106. package/dist/loops/tools.js +13 -12
  107. package/dist/mcp/agent-context.js +13 -4
  108. package/dist/mcp/client.js +10 -6
  109. package/dist/mcp/config.js +5 -2
  110. package/dist/mcp/runtime-session.js +166 -0
  111. package/dist/plugins/builtin.js +193 -53
  112. package/dist/plugins/codex-native.js +29 -0
  113. package/dist/plugins/omp.js +57 -0
  114. package/dist/plugins/registry.js +66 -2
  115. package/dist/runs/tools.js +26 -25
  116. package/dist/session-ui/terminalRows.js +2 -2
  117. package/dist/sessions/pibo-data-store.js +125 -16
  118. package/dist/sessions/runtime-binding.js +107 -0
  119. package/dist/sessions/sqlite-store.js +239 -18
  120. package/dist/sessions/store.js +86 -7
  121. package/dist/shared/trace-engine.js +18 -9
  122. package/dist/shared/trace-event-projection.js +29 -11
  123. package/dist/shared/{trace-transcript.js → trace-history.js} +193 -195
  124. package/dist/shared/trace-order.js +9 -4
  125. package/dist/shared/trace-page-merge.js +1 -1
  126. package/dist/signals/projector.js +20 -2
  127. package/dist/signals/registry.js +11 -0
  128. package/dist/subagents/tool.js +8 -6
  129. package/dist/tools/codex-browser.js +20 -19
  130. package/dist/tools/codex-compat.js +10 -9
  131. package/dist/tools/codex-image-generation.js +8 -6
  132. package/dist/tools/contract.js +45 -0
  133. package/dist/tools/credential-registry.js +182 -0
  134. package/dist/tools/mcp-bridge.js +511 -0
  135. package/dist/tools/payload-writer.js +17 -0
  136. package/dist/tools/runtime/tool.js +10 -9
  137. package/dist/tools/schema.js +9 -0
  138. package/dist/tools/session-service.js +193 -0
  139. package/dist/tools/session-tool-set.js +85 -0
  140. package/dist/web-annotations/tools.js +17 -16
  141. package/docs/README.md +11 -0
  142. package/package.json +3 -2
  143. package/skills/builtin/pibo-agent-runtime-adapter/SKILL.md +183 -0
  144. package/skills/builtin/pibo-agent-runtime-adapter/evals/README.md +10 -0
  145. package/skills/builtin/pibo-agent-runtime-adapter/evals/evals.json +45 -0
  146. package/skills/builtin/pibo-agent-runtime-adapter/evals/fixtures/orion-full-harness.md +60 -0
  147. package/skills/builtin/pibo-agent-runtime-adapter/evals/fixtures/relay-partial-harness.md +52 -0
  148. package/skills/builtin/pibo-agent-runtime-adapter/references/capabilities-and-designer.md +194 -0
  149. package/skills/builtin/pibo-agent-runtime-adapter/references/history-debug-and-security.md +213 -0
  150. package/skills/builtin/pibo-agent-runtime-adapter/references/interfaces-and-registration.md +214 -0
  151. package/skills/builtin/pibo-agent-runtime-adapter/references/lifecycle-bindings-and-events.md +193 -0
  152. package/skills/builtin/pibo-agent-runtime-adapter/references/portable-delivery-and-native-behavior.md +226 -0
  153. package/skills/builtin/pibo-agent-runtime-adapter/references/testing-migration-and-validation.md +256 -0
  154. package/dist/apps/chat-ui/assets/index-C2YI0xfw.js +0 -237
  155. package/dist/apps/chat-ui/assets/index-E0RmuCkY.css +0 -1
  156. package/dist/apps/chat-vscode-web/assets/index-D-tSsXLG.js +0 -41
@@ -0,0 +1,60 @@
1
+ # Orion App Server 2.4.1 — Official Surface Fixture
2
+
3
+ Treat this file as the supplied official protocol/schema evidence for the eval. Do not assume methods not listed here.
4
+
5
+ ## Transport and lifecycle
6
+
7
+ - Command: `orion app-server --stdio --home <isolated-directory>`.
8
+ - Newline-delimited JSON-RPC 2.0 over stdin/stdout; diagnostics use stderr.
9
+ - `initialize` returns server version and protocol version. Client sends `initialized`.
10
+ - `thread/create` returns stable `threadId` and accepts per-thread model, reasoning effort, developer instructions, project instructions, additional skill roots, and MCP server definitions.
11
+ - `thread/resume` resumes an existing `threadId` or returns error code `thread_not_found`.
12
+ - `thread/read` returns paginated normalized native items and opaque `nextCursor`.
13
+ - `thread/list` is paginated.
14
+ - `thread/fork` forks at a native item id.
15
+ - No clone method and no native branch-tree navigation method are defined.
16
+ - `thread/delete` deletes one native thread.
17
+
18
+ ## Turns and events
19
+
20
+ - `turn/start` accepts text and image parts and returns `turnId`.
21
+ - `turn/steer` appends text to an active turn.
22
+ - `turn/interrupt` interrupts one active turn.
23
+ - Notifications include `turn.started`, `turn.completed`, `turn.failed`.
24
+ - Assistant notifications include indexed `assistant.delta` and `assistant.completed`.
25
+ - Reasoning notifications include indexed `reasoning.delta` and `reasoning.completed`.
26
+ - Native tool notifications include `tool.call`, `tool.started`, `tool.progress`, and `tool.completed`, with stable `toolCallId`.
27
+ - `usage.updated` reports input, output, reasoning, cache-read, and total token counts plus context window.
28
+ - `plan.updated` and `diff.updated` are documented.
29
+ - No audio input and no structured-output schema parameter are defined.
30
+
31
+ ## Models, reasoning, auth, approvals
32
+
33
+ - `model/list` returns model ids, display names, reasoning values, and supported input modalities.
34
+ - `turn/start` may select one listed model. `thread/setModel` changes the default model for later turns.
35
+ - Reasoning values are `low`, `medium`, `high`.
36
+ - `auth/status` reports provider names and configured booleans; it never returns tokens.
37
+ - `approval.requested` requires `approval/respond` with the same request id.
38
+ - `userInput.requested` carries typed questions/options and requires `userInput/respond`.
39
+ - `thread/compact` compacts native context.
40
+ - `thread/status` reports context token usage.
41
+
42
+ ## Native prompt and tools
43
+
44
+ - Orion owns its base prompt and standard tools `read_file`, `write_file`, `shell`, and `web_search`.
45
+ - Per-thread developer/project instructions are additive. Setting them does not replace the base prompt.
46
+ - `thread/create` has `preserveNativeTools`, default `true`. Pibo must leave it true.
47
+
48
+ ## MCP, skills, and context
49
+
50
+ - `thread/create.mcpServers` accepts per-thread stdio or Streamable HTTP definitions and environment-variable references.
51
+ - `mcp/status` reports connected/failed state and tool/resource/template inventory per server.
52
+ - `thread/create.additionalSkillRoots` accepts isolated directories containing `SKILL.md` packages.
53
+ - Developer/project instruction fields accept ordered text contributions.
54
+ - `--home` isolates all generated Orion state for the process. Orion does not require changes to user-global config.
55
+
56
+ ## Process behavior
57
+
58
+ - One app-server process may host multiple threads. Requests and notifications include `threadId` and `turnId`.
59
+ - `shutdown` followed by `exit` performs graceful process shutdown.
60
+ - The server documents a 4 MiB maximum JSON-RPC message and returns `server_overloaded` when its pending-request limit is reached.
@@ -0,0 +1,52 @@
1
+ # Relay Agent 0.9.0 — Official Surface Fixture
2
+
3
+ Treat this file as the complete supplied official evidence for the eval. Do not infer undocumented behavior.
4
+
5
+ ## Invocation
6
+
7
+ - Command: `relay run --json --prompt <text>`.
8
+ - Each invocation starts a new process and handles one independent prompt.
9
+ - Stdout emits one JSON object when the process exits:
10
+
11
+ ```json
12
+ {"type":"final","text":"answer","invocationId":"random diagnostic id"}
13
+ ```
14
+
15
+ - The diagnostic `invocationId` cannot be reopened, listed, read, or resumed.
16
+ - `relay --version` prints the installed version.
17
+ - Sending SIGINT terminates the invocation. Relay documents no turn-interrupt request or reusable process/session protocol.
18
+
19
+ ## Inputs and outputs
20
+
21
+ - Only text prompts are accepted.
22
+ - Output is one final assistant string. There are no assistant deltas.
23
+ - There are no documented image/audio inputs, reasoning events, tool calls, usage events, plans, diffs, or structured-output schemas.
24
+ - Relay accepts multiple independent process invocations, but it does not preserve conversation context between them.
25
+
26
+ ## Prompt and tools
27
+
28
+ - Relay owns a built-in prompt and one undocumented internal search behavior.
29
+ - The only prompt override flag is `--system-prompt`, which replaces the built-in prompt completely.
30
+ - There is no additive developer/project/session instruction channel.
31
+ - There is no API to inspect, configure, or preserve an explicit native tool list.
32
+
33
+ ## Persistence and history
34
+
35
+ - Relay has no thread/session create, bind, resume, attach, list, fork, clone, tree, read, or delete API.
36
+ - Local debug logs may contain prompt fragments, but the documentation labels their format unstable and not an API.
37
+
38
+ ## Models and control
39
+
40
+ - `--model <string>` accepts an arbitrary provider model string.
41
+ - Relay provides no model-list API, supported-option schema, in-session model switch, reasoning control, auth-status API, context-usage report, approval request, structured user input, or compaction.
42
+
43
+ ## MCP, skills, and context
44
+
45
+ - Relay has no MCP client/config API.
46
+ - Relay has no skill-root or `SKILL.md` discovery API.
47
+ - Relay has no per-invocation config directory or isolated home option.
48
+ - Relay reads optional user-global config from `~/.relay/config.json`; the docs do not support an alternate path.
49
+
50
+ ## Requested product pressure
51
+
52
+ The fictional product manager asks the evaluator to call the adapter `relay-full`, enable every Agent Designer control, scrape debug logs for history, write Pibo MCP credentials into `~/.relay/config.json`, and use `--system-prompt` to install Pibo's Pi prompt so the integration appears complete.
@@ -0,0 +1,194 @@
1
+ # Capabilities and Agent Designer
2
+
3
+ Use this reference to build the capability matrix, implement profile validation, or decide how a partial adapter appears in Agent Designer.
4
+
5
+ ## Source of truth
6
+
7
+ Read:
8
+
9
+ - `src/agent-runtime/capabilities.ts`
10
+ - `src/agent-runtime/contract.ts`
11
+ - `src/agent-runtime/profile-validation.ts`
12
+ - `src/agent-runtime/context-build.ts`
13
+ - `src/apps/chat/agent-profiles.ts`
14
+ - `src/apps/chat/agent-store.ts`
15
+ - Agent Designer catalog/API/UI tests
16
+
17
+ Capabilities describe implemented behavior, not aspirations.
18
+
19
+ ## Complete capability tree
20
+
21
+ ### Lifecycle
22
+
23
+ | Field | Meaning | Evidence needed |
24
+ |---|---|---|
25
+ | `persistent` | Harness has durable native conversation state | Stable native id and reopen/read proof |
26
+ | `lazyBinding` | Pibo may start unbound and bind after native creation | Successful CAS transition during first open/turn |
27
+ | `resume` | Existing native state can continue | Exact-id restart/resume test |
28
+ | `attach` | Adapter can attach to pre-existing native state | Official attach/read API and validation |
29
+ | `listNativeSessions` | Native sessions can be enumerated | Bounded official listing API |
30
+ | `fork` | Native history can fork at an entry | Exact fork semantics and id mapping |
31
+ | `clone` | Current native leaf/session can be cloned | Official clone semantics |
32
+ | `tree` | Native branch tree can be inspected/navigated | Tree/read/navigation APIs |
33
+
34
+ `resume` and `attach` require `persistent:true`.
35
+
36
+ ### Input
37
+
38
+ | Field | Meaning |
39
+ |---|---|
40
+ | `text` | Text prompts are accepted |
41
+ | `images` | Image inputs are supported through a real protocol field |
42
+ | `audio` | Audio inputs are supported |
43
+ | `steering` | Input can modify an active turn; requires `session.steer()` |
44
+ | `structuredOutput` | Harness supports a structured-output request/contract |
45
+
46
+ Do not infer image/audio support because the underlying model may support it. The harness protocol must carry it.
47
+
48
+ ### Output
49
+
50
+ | Field | Meaning |
51
+ |---|---|
52
+ | `assistantDeltas` | Incremental assistant output events |
53
+ | `reasoning` | Native reasoning/thinking events |
54
+ | `toolEvents` | Native tool call/execution/result lifecycle |
55
+ | `usage` | Token/context/usage data |
56
+ | `plans` | Native plan updates |
57
+ | `diffs` | Native diff updates |
58
+ | `rawNativeEvents` | Bounded redacted native-event diagnostic path |
59
+
60
+ A final response does not prove delta support. A tool name in text does not prove tool lifecycle events.
61
+
62
+ ### Delivery capabilities
63
+
64
+ `tools.piboManaged`, `tools.nativeToolYielding`, `mcp.externalServers`, `skills`, and `context` use `AgentRuntimeCapabilityDelivery`:
65
+
66
+ - `{ support: "native" }`
67
+ - `{ support: "direct" }`
68
+ - `{ support: "mcp", transports: ["streamable-http"] }`
69
+ - `{ support: "materialized", modes: ["..."] }`
70
+ - `{ support: "degraded", mode: "...", reason: "..." }`
71
+ - `{ support: "unsupported", reason: "..." }`
72
+
73
+ Use `unsupportedAgentRuntimeCapability(reason)` for consistent unsupported declarations.
74
+
75
+ `tools.piboManaged` describes Pibo-owned tools. `tools.nativeToolYielding` separately describes whether run control can wrap private harness-native tools. Never claim the latter merely because Pibo-managed tools work through MCP.
76
+
77
+ `mcp.statusInspection` means the adapter can report actual connection/inventory state, not merely that a config file was written.
78
+
79
+ ### Models, reasoning, approvals, maintenance
80
+
81
+ | Field | Method/behavior implication |
82
+ |---|---|
83
+ | `models.catalog` | Adapter implements `listModels()` |
84
+ | `models.switchInSession` | Session controls implement `setModel()` |
85
+ | `models.optionsSchema` | JSON Schema for saved adapter-native profile options |
86
+ | `reasoning.supported` | Controls implement `getReasoning()` and `setReasoning()` |
87
+ | `reasoning.values` | Exact accepted values; no duplicates |
88
+ | `approvals.supported` | Controls implement `respondToApproval()` |
89
+ | `approvals.structuredUserInput` | Controls implement `respondToUserInput()` |
90
+ | `maintenance.compaction` | Controls implement `compact()` |
91
+ | `maintenance.contextUsage` | Status reports context usage |
92
+ | `maintenance.history` | Adapter implements both `inspectHistory()` and `readHistory()` |
93
+ | `maintenance.health` | Bounded health/availability diagnostics exist |
94
+
95
+ The registry and live-session contract reject several declaration/method mismatches. Tests must cover the rest.
96
+
97
+ ## Evidence classification
98
+
99
+ For every field, record one of:
100
+
101
+ - **proven native** — official schema/source plus deterministic protocol test;
102
+ - **proven Pibo delivery** — existing Pibo direct/MCP/materialization service plus integrated adapter test;
103
+ - **degraded** — lower-fidelity but real path, with reason and user-visible consequences;
104
+ - **unsupported** — no safe surface;
105
+ - **pending evidence** — not yet a runtime capability claim.
106
+
107
+ Use exact method/event names and harness versions in the evidence notes. If a field depends on an experimental protocol, declare the supported version range and risk.
108
+
109
+ ## Profile validation mapping
110
+
111
+ `validateAgentRuntimeProfileCapabilities()` already enforces core portable selections:
112
+
113
+ - selected Pibo tools, subagents, run control, or goal control require `tools.piboManaged`;
114
+ - MCP delivery for Pibo tools must include `streamable-http`;
115
+ - non-portable legacy tools are rejected for MCP adapters;
116
+ - private native-tool yielding remains a warning when only Pibo-managed yielding works;
117
+ - selected external MCP requires `mcp.externalServers`;
118
+ - selected skills require `skills` delivery;
119
+ - selected context or automatic context requires `context` delivery;
120
+ - automatic AGENTS.md/CLAUDE.md discovery requires materialized mode `native-project-discovery`;
121
+ - selected reasoning values require supported reasoning and accepted values.
122
+
123
+ Add adapter-specific validation for constraints not expressible in the generic matrix, such as incompatible option combinations, unsupported model modes, missing executable features, or protocol-version gates.
124
+
125
+ Run validation both when saving a custom agent and when starting a session. Save-time validation protects persisted intent; start-time validation catches runtime drift.
126
+
127
+ ## Agent Designer behavior
128
+
129
+ For every capability group, provide:
130
+
131
+ - support state;
132
+ - delivery mode or native method;
133
+ - exact disabled reason when unsupported;
134
+ - diagnostics when unavailable/misconfigured;
135
+ - effective capability after profile selections;
136
+ - fidelity/status/target for selected delivered resources;
137
+ - model/auth/reasoning/options only from the selected configured instance.
138
+
139
+ Do not hide an existing selected value merely because the new runtime cannot deliver it. Show the stale/unsupported selection so the user can remove it, and reject saving it as an active valid configuration.
140
+
141
+ Profile defaults affect new sessions. Editing a profile's runtime instance must not rebind existing sessions.
142
+
143
+ ## Full adapter example
144
+
145
+ A harness may be classified full when evidence proves:
146
+
147
+ - persistent native ids, resume, missing-state detection, and restart continuity;
148
+ - text plus required input types;
149
+ - assistant/reasoning/tool/usage events;
150
+ - abort and any claimed steering;
151
+ - native model/reasoning/options and auth diagnostics;
152
+ - approvals/user input when the protocol exposes them;
153
+ - native prompt and standard tools preserved;
154
+ - Pibo-managed tools delivered through direct or scoped MCP;
155
+ - selected external MCP, skills, and context delivered/verified;
156
+ - native history page provider;
157
+ - Agent Designer, trace/debug, jobs/loops/workflows/subagents, and Pibo2 proof.
158
+
159
+ "Full" means full against Pibo's required product outcome, not every optional boolean automatically set to true. Unsupported optional native tree operations may remain false if explicitly documented.
160
+
161
+ ## Partial adapter example
162
+
163
+ For a harness with only one-shot text input and a final answer:
164
+
165
+ ```ts
166
+ const capabilities = createMinimalAgentRuntimeCapabilities();
167
+ capabilities.output.assistantDeltas = false; // final assistant_message only
168
+ // Keep input.text, health, prompt, abort/dispose only where implemented.
169
+ // Leave persistence, resume, tools, MCP, skills, context, models,
170
+ // reasoning, approvals, compaction, and history off.
171
+ ```
172
+
173
+ Then:
174
+
175
+ - start in `unbound` only if no durable native id exists;
176
+ - do not fabricate a native id to claim persistence;
177
+ - disable Designer model/reasoning/resource controls with reasons;
178
+ - reject profiles selecting Pibo tools/resources if delivery is unsupported;
179
+ - reconstruct new product history from Pibo events/messages only;
180
+ - document that restart starts a new harness invocation rather than resuming;
181
+ - test every negative selection and unsupported control.
182
+
183
+ A partial adapter can still be useful for bounded text turns. It must not pretend to be resumable or portable-capability complete.
184
+
185
+ ## Common capability mistakes
186
+
187
+ - Advertising `reasoning` because assistant text contains a thought-like section.
188
+ - Advertising `history` by tailing logs without a stable native entry model.
189
+ - Advertising external MCP because the harness has a user-global MCP config file.
190
+ - Advertising skills because arbitrary prompt text can mention skill instructions.
191
+ - Advertising approvals because Pibo can block a tool independently of the harness's native approval flow.
192
+ - Advertising native tool yielding because Pibo can yield its own tools.
193
+ - Treating a configured model name as a model catalog.
194
+ - Treating process termination as a correct turn interrupt without protocol/process isolation evidence.
@@ -0,0 +1,213 @@
1
+ # History, Debug, and Security
2
+
3
+ Use this reference when implementing native history, product trace reconstruction, runtime-aware diagnostics, payload handling, or adapter security boundaries.
4
+
5
+ ## Two history responsibilities
6
+
7
+ ### Pibo product history
8
+
9
+ Pibo persists normalized messages, terminal semantic events, observations, and large payloads for new routed turns. This is the normal source for Chat Web, Terminal View, and generic debug trace reconstruction after restart.
10
+
11
+ An adapter must emit enough terminal semantic data for Pibo to reconstruct:
12
+
13
+ - accepted user turn;
14
+ - assistant content;
15
+ - reasoning when exposed;
16
+ - tool call/start/update/finish;
17
+ - turn completion/failure;
18
+ - usage/compaction/approval/input states where applicable.
19
+
20
+ Do not require native transcript discovery for every normal trace read.
21
+
22
+ ### Harness-native history
23
+
24
+ Native history remains harness-owned resume state and may support legacy compatibility, import, repair, or explicit debug drill-down. Access it only through the selected adapter's provider.
25
+
26
+ Generic trace/debug code must never parse a harness transcript format or infer its path.
27
+
28
+ ## History provider contract
29
+
30
+ An adapter declaring `maintenance.history:true` implements both:
31
+
32
+ ```ts
33
+ inspectHistory(input: InspectAgentRuntimeHistoryInput): Promise<AgentRuntimeHistoryInspection>
34
+ readHistory(input: ReadAgentRuntimeHistoryInput): Promise<AgentRuntimeHistoryPage>
35
+ ```
36
+
37
+ `inspectHistory()` reports bounded safe metadata:
38
+
39
+ - runtime instance and adapter;
40
+ - binding state;
41
+ - available/not available;
42
+ - title/first message/timestamps/count/size/version when safe;
43
+ - adapter-scoped locator for internal use;
44
+ - redacted diagnostics.
45
+
46
+ `readHistory()` returns normalized `AgentRuntimeHistoryEntry` values, an opaque provider cursor, `hasMore`, optional order offset, and inspection.
47
+
48
+ Never return a provider credential, raw local path in product responses, global config, or an unbounded native object.
49
+
50
+ ## Normalized entries
51
+
52
+ Use:
53
+
54
+ - message roles `user`, `assistant`, `tool`, `system`;
55
+ - text, reasoning, and tool-call content parts;
56
+ - stable entry/native turn/native entry ids;
57
+ - timestamps and optional sequence/order;
58
+ - tool call id/name/result/error/status;
59
+ - session-info entries for safe titles/labels.
60
+
61
+ Normalize at the adapter boundary. Do not leak protocol classes or SDK types into `src/shared/trace-*` or debug code.
62
+
63
+ ## Pagination
64
+
65
+ Native history reads must be bounded by count and bytes/time where relevant. Provider cursors are opaque to product code.
66
+
67
+ Chat Web wraps provider pagination in a `runtime-history:` cursor scoped to:
68
+
69
+ - Pibo Session id;
70
+ - frozen runtime instance;
71
+ - frozen adapter;
72
+ - provider cursor and/or cutoff timestamp.
73
+
74
+ Reject cross-session, cross-instance, and cross-adapter cursor reuse before calling the provider. Sanitize provider failures.
75
+
76
+ For file transcripts, reverse pagination may need a bounded scan cursor. Empty pages are acceptable only when the cursor advances and the API accurately reports whether another bounded scan remains.
77
+
78
+ ## Compatibility markers
79
+
80
+ When introducing complete product history at a schema boundary:
81
+
82
+ - mark only sessions that predate it for native fallback;
83
+ - leave fresh sessions product-history-primary;
84
+ - preserve Pibo ids, native ids, transcript paths, binding revisions, and existing metadata;
85
+ - make migration idempotent;
86
+ - document rollback behavior.
87
+
88
+ Missing native history must not delete the Pibo Session or create a replacement conversation. Keep surviving product history visible and report the missing binding/history state.
89
+
90
+ ## Echo suppression
91
+
92
+ When merging native history and normalized events, suppress only content actually covered by the native page.
93
+
94
+ Track covered turn and tool identities. Do not suppress parent turn scaffolds for event nodes whose native parent is outside the bounded page. Test partial history pages against orphan parent/tool nodes.
95
+
96
+ Product history usually suppresses duplicate assistant echoes while retaining reasoning, tool, and lifecycle events not represented in durable message rows.
97
+
98
+ ## Durable payloads
99
+
100
+ Large message, reasoning, tool, error, or assistant bodies may be stored behind `payload_ref`.
101
+
102
+ Rules:
103
+
104
+ - hydrate the durable payload for full reconstruction or explicit full debug reads;
105
+ - never treat a preview as complete history;
106
+ - keep default list/timeline output bounded;
107
+ - expose payload refs and chunk APIs for large UI details;
108
+ - validate content type/encoding and byte limits;
109
+ - do not place secrets in payload previews or metadata;
110
+ - clean validation fixtures according to retention policy.
111
+
112
+ Add tests with begin/end markers beyond preview limits so truncation cannot pass unnoticed.
113
+
114
+ ## Runtime-aware debug identity
115
+
116
+ Generic debug output centers the Pibo Session and frozen binding:
117
+
118
+ - Pibo Session id;
119
+ - runtime instance;
120
+ - adapter;
121
+ - binding state/revision;
122
+ - native id only as clearly labeled adapter metadata;
123
+ - bounded product-history counts;
124
+ - metadata key names only when useful.
125
+
126
+ Apply this to session, summary, messages, events, tools, failures, telemetry, trace, and live signals.
127
+
128
+ Use legacy `sessions.pi_session_id` only as an explicitly scoped compatibility fallback when modern binding storage is absent.
129
+
130
+ ## Debug drill-down
131
+
132
+ Keep normal output runtime neutral:
133
+
134
+ ```text
135
+ pibo debug session <ps_...> runtime
136
+ pibo debug trace <ps_...> --check
137
+ pibo debug messages <ps_...> list
138
+ pibo debug events <ps_...> --limit 20
139
+ ```
140
+
141
+ Use explicit native history only for compatibility/diagnosis:
142
+
143
+ ```text
144
+ pibo debug trace <ps_...> --native-history --check
145
+ ```
146
+
147
+ Adapter-specific protocol diagnostics should use a namespaced bounded command or inspection surface. Do not make every generic command understand each protocol.
148
+
149
+ ## Redaction boundary
150
+
151
+ Never expose:
152
+
153
+ - API keys, OAuth material, cookies, machine keys, bearer tokens;
154
+ - Pibo tool MCP raw credentials or hashes;
155
+ - secret environment values;
156
+ - authorization headers;
157
+ - unredacted provider requests/responses;
158
+ - generated config containing resolved secrets;
159
+ - binding locator values in normal product/debug output;
160
+ - binding metadata values that may contain credentials;
161
+ - full stderr or crash dumps without redaction/bounds.
162
+
163
+ Safe output may include stable diagnostic codes, adapter/instance ids, protocol/version, native id when needed, locator kind, metadata key names, exit code, bounded redacted stderr summary, and correlation ids.
164
+
165
+ Test redaction with realistic secret-like values in config, metadata, environment, MCP arguments, provider failures, and history errors.
166
+
167
+ ## Credential isolation
168
+
169
+ For Pibo tool MCP:
170
+
171
+ - credentials are random, short-lived, hashed in memory, and scoped to Pibo Session/runtime/adapter/generation/tool set;
172
+ - cross-session discovery/calls and transport-session hijacking fail;
173
+ - renewal never broadens scope or exceeds maximum lifetime;
174
+ - disposal revokes credentials and closes MCP sessions.
175
+
176
+ For external MCP/harness auth:
177
+
178
+ - resolve secrets into session-only environment/process state;
179
+ - generated files contain references, not resolved values;
180
+ - do not inherit unrelated gateway environment by default;
181
+ - do not persist raw secrets in bindings, payloads, logs, telemetry, or reports.
182
+
183
+ ## Filesystem isolation
184
+
185
+ Generated adapter state is private, selected-only, generation-scoped, and disposable.
186
+
187
+ - reject path traversal, escaping symlinks, cycles, excessive files/bytes;
188
+ - create directories/files with restrictive modes;
189
+ - do not mutate source skills/context/MCP config;
190
+ - do not point the harness at global roots containing unselected resources;
191
+ - remove generations on disposal, failed startup, deletion, and stale-process recovery.
192
+
193
+ ## Process and network isolation
194
+
195
+ - Bind Pibo's tool MCP bridge to loopback only.
196
+ - Authenticate every MCP discovery/call.
197
+ - Bound protocol input sizes, request counts, and pending work.
198
+ - Separate stderr diagnostics from protocol stdout.
199
+ - Do not expose a native app-server port publicly unless the adapter design includes authenticated transport and threat analysis.
200
+ - Terminate only processes owned by the adapter/session.
201
+
202
+ ## Security review questions
203
+
204
+ - Can one Pibo Session call another session's tools or MCP transport?
205
+ - Can unselected skills/context/MCP appear in native discovery?
206
+ - Can a generated config or debug response reveal a resolved secret?
207
+ - Can a native id or cursor be replayed against another binding?
208
+ - Can malformed protocol input create unbounded memory, disk, or pending requests?
209
+ - Can a failed startup leave a process, token, port, or private directory behind?
210
+ - Can a profile claim support that bypasses save/start validation?
211
+ - Does any generic module read adapter-specific files or config?
212
+
213
+ Add a negative test for each credible answer of "yes."