@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.
- package/dist/agent-runtime/auth.js +28 -0
- package/dist/agent-runtime/capabilities.js +221 -0
- package/dist/agent-runtime/context-build.js +313 -0
- package/dist/agent-runtime/contract.js +45 -0
- package/dist/agent-runtime/errors.js +57 -0
- package/dist/agent-runtime/events.js +1 -0
- package/dist/agent-runtime/history.js +1 -0
- package/dist/agent-runtime/profile-validation.js +109 -0
- package/dist/agent-runtime/registry.js +608 -0
- package/dist/agent-runtime/resource-files.js +87 -0
- package/dist/agent-runtime/resource-service.js +635 -0
- package/dist/agent-runtime/resources.js +1 -0
- package/dist/agent-runtime/routed-session.js +931 -0
- package/dist/agent-runtime/testing/contract.js +51 -0
- package/dist/agent-runtime/testing/fake-adapter.js +192 -0
- package/dist/agent-runtime/types.js +3 -0
- package/dist/agent-runtimes/codex-native/adapter.js +905 -0
- package/dist/agent-runtimes/codex-native/auth.js +476 -0
- package/dist/agent-runtimes/codex-native/client.js +734 -0
- package/dist/agent-runtimes/codex-native/config.js +152 -0
- package/dist/agent-runtimes/codex-native/history.js +283 -0
- package/dist/agent-runtimes/codex-native/mcp-stdio-launcher.js +89 -0
- package/dist/agent-runtimes/codex-native/models.js +581 -0
- package/dist/agent-runtimes/codex-native/process.js +459 -0
- package/dist/agent-runtimes/codex-native/protocol-types.js +1 -0
- package/dist/agent-runtimes/codex-native/protocol-version.js +7 -0
- package/dist/agent-runtimes/codex-native/redaction.js +31 -0
- package/dist/agent-runtimes/codex-native/requests.js +378 -0
- package/dist/agent-runtimes/codex-native/resource-delivery.js +445 -0
- package/dist/agent-runtimes/codex-native/thread.js +388 -0
- package/dist/agent-runtimes/codex-native/turn.js +849 -0
- package/dist/agent-runtimes/pi/adapter.js +653 -0
- package/dist/agent-runtimes/pi/auth.js +455 -0
- package/dist/agent-runtimes/pi/history.js +640 -0
- package/dist/agent-runtimes/pi/model-catalog.js +87 -0
- package/dist/agent-runtimes/pi/routed-session.js +1464 -0
- package/dist/agent-runtimes/pi/runtime.js +534 -0
- package/dist/agent-runtimes/pi/tool-compiler.js +69 -0
- package/dist/apps/chat/agent-profiles.js +40 -23
- package/dist/apps/chat/agent-store.js +111 -64
- package/dist/apps/chat/chat-api-routes.js +1 -1
- package/dist/apps/chat/chat-request-normalizers.js +47 -0
- package/dist/apps/chat/data/chat-data-mappers.js +25 -9
- package/dist/apps/chat/data/history-query-service.js +108 -0
- package/dist/apps/chat/data/session-query-service.js +24 -3
- package/dist/apps/chat/data/timeline-query-service.js +3 -3
- package/dist/apps/chat/model-catalog.js +1 -55
- package/dist/apps/chat/provider-auth-actions.js +171 -23
- package/dist/apps/chat/stream.js +12 -0
- package/dist/apps/chat/trace-v2.js +1 -0
- package/dist/apps/chat/trace.js +126 -415
- package/dist/apps/chat/web-app.js +582 -157
- package/dist/apps/chat-ui/assets/{dist-BTLtT_Vf.js → dist-9v2ZXT6V.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CMk1aPug.js → dist-B1LVAytl.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-CcwA_IWN.js → dist-C6LPDFXU.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-DKOthbxr.js → dist-DVtXxfHc.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-ls2I6BIw.js → dist-DW4Qrfbd.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-D1rAtRWs.js → dist-DmbsHdMC.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-C1JQRskW.js → dist-DyvwuSFO.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-DfpaylQ-.js → dist-I26VB0QO.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-D10bTFD5.js → dist-RtHbJRPV.js} +1 -1
- package/dist/apps/chat-ui/assets/{dist-5KpmmBBZ.js → dist-sZgJkWZb.js} +1 -1
- package/dist/apps/chat-ui/assets/index-BPbNvcZe.css +1 -0
- package/dist/apps/chat-ui/assets/index-CIOf2uL2.js +237 -0
- package/dist/apps/chat-ui/index.html +2 -2
- package/dist/apps/chat-vscode-web/assets/index-1ivRyjFs.js +41 -0
- package/dist/apps/chat-vscode-web/index.html +1 -1
- package/dist/apps/vscode-artifacts/latest.vsix +0 -0
- package/dist/apps/vscode-artifacts/pibo-vscode-ext-2.0.0.vsix +0 -0
- package/dist/auth/login-actions.js +5 -251
- package/dist/cli-session/localSessionSource.js +8 -1
- package/dist/core/context-build.js +124 -20
- package/dist/core/default-profile.js +8 -0
- package/dist/core/profiles.js +30 -3
- package/dist/core/routed-session.js +5 -1446
- package/dist/core/runtime.js +5 -561
- package/dist/core/session-router.js +637 -83
- package/dist/data/cli.js +20 -3
- package/dist/data/schema.js +104 -1
- package/dist/data/session-store.js +24 -1
- package/dist/debug/events.js +25 -10
- package/dist/debug/failures.js +23 -3
- package/dist/debug/index.js +24 -6
- package/dist/debug/messages.js +87 -7
- package/dist/debug/persisted-payloads.js +31 -0
- package/dist/debug/pty.js +7 -6
- package/dist/debug/runtime-binding.js +29 -0
- package/dist/debug/session.js +137 -0
- package/dist/debug/summary.js +12 -0
- package/dist/debug/telemetry.js +28 -0
- package/dist/debug/tools.js +12 -2
- package/dist/debug/trace.js +154 -76
- package/dist/gateway/server.js +87 -2
- package/dist/gateway/tool.js +5 -5
- package/dist/index.js +21 -2
- package/dist/loops/tools.js +13 -12
- package/dist/mcp/agent-context.js +13 -4
- package/dist/mcp/client.js +10 -6
- package/dist/mcp/config.js +5 -2
- package/dist/mcp/runtime-session.js +166 -0
- package/dist/plugins/builtin.js +191 -53
- package/dist/plugins/codex-native.js +29 -0
- package/dist/plugins/registry.js +66 -2
- package/dist/runs/tools.js +26 -25
- package/dist/session-ui/terminalRows.js +2 -2
- package/dist/sessions/pibo-data-store.js +125 -16
- package/dist/sessions/runtime-binding.js +107 -0
- package/dist/sessions/sqlite-store.js +239 -18
- package/dist/sessions/store.js +86 -7
- package/dist/shared/trace-engine.js +18 -9
- package/dist/shared/trace-event-projection.js +29 -11
- package/dist/shared/{trace-transcript.js → trace-history.js} +193 -195
- package/dist/shared/trace-order.js +9 -4
- package/dist/shared/trace-page-merge.js +1 -1
- package/dist/signals/projector.js +20 -2
- package/dist/signals/registry.js +11 -0
- package/dist/subagents/tool.js +8 -6
- package/dist/tools/codex-browser.js +20 -19
- package/dist/tools/codex-compat.js +10 -9
- package/dist/tools/codex-image-generation.js +8 -6
- package/dist/tools/contract.js +45 -0
- package/dist/tools/credential-registry.js +182 -0
- package/dist/tools/mcp-bridge.js +511 -0
- package/dist/tools/payload-writer.js +17 -0
- package/dist/tools/runtime/tool.js +10 -9
- package/dist/tools/schema.js +9 -0
- package/dist/tools/session-service.js +193 -0
- package/dist/tools/session-tool-set.js +85 -0
- package/dist/web-annotations/tools.js +17 -16
- package/docs/README.md +11 -0
- package/package.json +3 -2
- package/skills/builtin/pibo-agent-runtime-adapter/SKILL.md +183 -0
- package/skills/builtin/pibo-agent-runtime-adapter/evals/README.md +10 -0
- package/skills/builtin/pibo-agent-runtime-adapter/evals/evals.json +45 -0
- package/skills/builtin/pibo-agent-runtime-adapter/evals/fixtures/orion-full-harness.md +60 -0
- package/skills/builtin/pibo-agent-runtime-adapter/evals/fixtures/relay-partial-harness.md +52 -0
- package/skills/builtin/pibo-agent-runtime-adapter/references/capabilities-and-designer.md +194 -0
- package/skills/builtin/pibo-agent-runtime-adapter/references/history-debug-and-security.md +213 -0
- package/skills/builtin/pibo-agent-runtime-adapter/references/interfaces-and-registration.md +214 -0
- package/skills/builtin/pibo-agent-runtime-adapter/references/lifecycle-bindings-and-events.md +193 -0
- package/skills/builtin/pibo-agent-runtime-adapter/references/portable-delivery-and-native-behavior.md +226 -0
- package/skills/builtin/pibo-agent-runtime-adapter/references/testing-migration-and-validation.md +256 -0
- package/dist/apps/chat-ui/assets/index-C2YI0xfw.js +0 -237
- package/dist/apps/chat-ui/assets/index-E0RmuCkY.css +0 -1
- package/dist/apps/chat-vscode-web/assets/index-D-tSsXLG.js +0 -41
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { assertAgentRuntimeSessionContract } from "../contract.js";
|
|
2
|
+
function invariant(condition, message) {
|
|
3
|
+
if (!condition)
|
|
4
|
+
throw new Error(`Agent runtime contract violation: ${message}`);
|
|
5
|
+
}
|
|
6
|
+
export async function exerciseAgentRuntimeAdapterContract(adapter, input, prompt = "runtime adapter contract prompt") {
|
|
7
|
+
invariant(adapter.instanceId.length > 0, "configured instance id is required");
|
|
8
|
+
invariant(adapter.descriptor.id.length > 0, "adapter id is required");
|
|
9
|
+
invariant(adapter.descriptor.displayName.length > 0, "adapter display name is required");
|
|
10
|
+
invariant(adapter.enabled, `instance "${adapter.instanceId}" must be enabled for the contract run`);
|
|
11
|
+
const diagnostics = await adapter.diagnose();
|
|
12
|
+
invariant(diagnostics.every((diagnostic) => diagnostic.severity !== "error"), "enabled adapter diagnostics returned an error");
|
|
13
|
+
const validation = adapter.validateProfile({ profile: input.profile, workspace: input.workspace });
|
|
14
|
+
invariant(validation.every((diagnostic) => diagnostic.severity !== "error"), "profile validation returned an error");
|
|
15
|
+
const session = await adapter.openSession(input);
|
|
16
|
+
invariant(session.runtimeInstanceId === adapter.instanceId, "session instance id does not match adapter instance");
|
|
17
|
+
invariant(session.adapterId === adapter.descriptor.id, "session adapter id does not match descriptor");
|
|
18
|
+
invariant(session.cwd === input.workspace, "session cwd does not match open input");
|
|
19
|
+
assertAgentRuntimeSessionContract(session);
|
|
20
|
+
const binding = session.getBinding();
|
|
21
|
+
invariant(binding.piboSessionId === input.piboSession.id, "binding Pibo Session id does not match open input");
|
|
22
|
+
invariant(binding.runtimeInstanceId === adapter.instanceId, "binding runtime instance id does not match adapter");
|
|
23
|
+
invariant(binding.adapterId === adapter.descriptor.id, "binding adapter id does not match descriptor");
|
|
24
|
+
const events = [];
|
|
25
|
+
const unsubscribe = session.subscribe((event) => events.push(event));
|
|
26
|
+
try {
|
|
27
|
+
await session.prompt({ text: prompt, source: "rpc" });
|
|
28
|
+
const status = session.getStatus();
|
|
29
|
+
invariant(status.cwd === input.workspace, "status cwd does not match session cwd");
|
|
30
|
+
invariant(status.streaming === false, "session remained streaming after prompt settled");
|
|
31
|
+
const startedEvents = events.filter((event) => event.type === "turn_started");
|
|
32
|
+
const completedEvents = events.filter((event) => event.type === "turn_completed");
|
|
33
|
+
const failedEvents = events.filter((event) => event.type === "turn_failed");
|
|
34
|
+
invariant(startedEvents.length === 1, "successful prompt must emit exactly one turn_started event");
|
|
35
|
+
invariant(completedEvents.length === 1, "successful prompt must emit exactly one turn_completed event");
|
|
36
|
+
invariant(failedEvents.length === 0, "successful prompt emitted turn_failed");
|
|
37
|
+
invariant(events.indexOf(startedEvents[0]) < events.indexOf(completedEvents[0]), "turn_completed preceded turn_started");
|
|
38
|
+
const settledBinding = session.getBinding();
|
|
39
|
+
invariant(settledBinding.piboSessionId === binding.piboSessionId, "prompt changed the binding Pibo Session id");
|
|
40
|
+
invariant(settledBinding.runtimeInstanceId === binding.runtimeInstanceId, "prompt changed the binding runtime instance");
|
|
41
|
+
invariant(settledBinding.adapterId === binding.adapterId, "prompt changed the binding adapter");
|
|
42
|
+
await session.abort();
|
|
43
|
+
invariant(session.getStatus().streaming === false, "idle abort left the session streaming");
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
unsubscribe();
|
|
47
|
+
await session.dispose();
|
|
48
|
+
await session.dispose();
|
|
49
|
+
}
|
|
50
|
+
return { session, events };
|
|
51
|
+
}
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { createMinimalAgentRuntimeCapabilities } from "../capabilities.js";
|
|
2
|
+
import { AgentRuntimeBindingMissingError } from "../errors.js";
|
|
3
|
+
export class FakeAgentRuntimeSession {
|
|
4
|
+
script;
|
|
5
|
+
adapterId;
|
|
6
|
+
runtimeInstanceId;
|
|
7
|
+
cwd;
|
|
8
|
+
capabilities;
|
|
9
|
+
listeners = new Set();
|
|
10
|
+
binding;
|
|
11
|
+
streaming = false;
|
|
12
|
+
disposed = false;
|
|
13
|
+
aborted = false;
|
|
14
|
+
promptIndex = 0;
|
|
15
|
+
abortWaiters = [];
|
|
16
|
+
prompts = [];
|
|
17
|
+
disposeCalls = 0;
|
|
18
|
+
abortCalls = 0;
|
|
19
|
+
constructor(input, adapterId, script, capabilities, nativeSessionId) {
|
|
20
|
+
this.script = script;
|
|
21
|
+
this.adapterId = adapterId;
|
|
22
|
+
this.runtimeInstanceId = input.binding?.runtimeInstanceId ?? input.profile.runtimeInstanceId;
|
|
23
|
+
this.cwd = input.workspace;
|
|
24
|
+
this.capabilities = capabilities;
|
|
25
|
+
this.binding = input.binding?.state === "bound"
|
|
26
|
+
? { ...input.binding }
|
|
27
|
+
: {
|
|
28
|
+
piboSessionId: input.piboSession.id,
|
|
29
|
+
runtimeInstanceId: this.runtimeInstanceId,
|
|
30
|
+
adapterId: this.adapterId,
|
|
31
|
+
nativeSessionId,
|
|
32
|
+
state: "bound",
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
getBinding() {
|
|
36
|
+
return structuredClone(this.binding);
|
|
37
|
+
}
|
|
38
|
+
subscribe(listener) {
|
|
39
|
+
this.listeners.add(listener);
|
|
40
|
+
return () => this.listeners.delete(listener);
|
|
41
|
+
}
|
|
42
|
+
async prompt(input) {
|
|
43
|
+
this.assertActive();
|
|
44
|
+
this.prompts.push({ ...input });
|
|
45
|
+
this.promptIndex += 1;
|
|
46
|
+
this.streaming = true;
|
|
47
|
+
this.aborted = false;
|
|
48
|
+
const turnId = `fake-turn-${this.promptIndex}`;
|
|
49
|
+
const script = typeof this.script === "function" ? this.script(input, this.promptIndex) : this.script ?? {};
|
|
50
|
+
this.emit({ type: "turn_started", turnId });
|
|
51
|
+
try {
|
|
52
|
+
if (script.waitForAbort) {
|
|
53
|
+
await new Promise((resolve) => this.abortWaiters.push(resolve));
|
|
54
|
+
}
|
|
55
|
+
if (this.aborted)
|
|
56
|
+
return;
|
|
57
|
+
for (const event of script.events ?? [])
|
|
58
|
+
this.emit(event);
|
|
59
|
+
if (script.failWith) {
|
|
60
|
+
this.emit({ type: "turn_failed", turnId, message: script.failWith });
|
|
61
|
+
throw new Error(script.failWith);
|
|
62
|
+
}
|
|
63
|
+
if (script.bindingPatchAfterPrompt) {
|
|
64
|
+
this.binding = {
|
|
65
|
+
...this.binding,
|
|
66
|
+
...structuredClone(script.bindingPatchAfterPrompt),
|
|
67
|
+
piboSessionId: this.binding.piboSessionId,
|
|
68
|
+
runtimeInstanceId: this.binding.runtimeInstanceId,
|
|
69
|
+
adapterId: this.binding.adapterId,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
this.emit({ type: "turn_completed", turnId, status: "completed" });
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
this.streaming = false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async steer(input) {
|
|
79
|
+
this.assertActive();
|
|
80
|
+
if (!this.streaming || !this.capabilities.input.steering) {
|
|
81
|
+
throw new Error("Fake runtime is not accepting steering.");
|
|
82
|
+
}
|
|
83
|
+
this.prompts.push({ ...input });
|
|
84
|
+
}
|
|
85
|
+
async abort() {
|
|
86
|
+
this.abortCalls += 1;
|
|
87
|
+
const wasStreaming = this.streaming;
|
|
88
|
+
this.aborted = true;
|
|
89
|
+
const waiters = this.abortWaiters;
|
|
90
|
+
this.abortWaiters = [];
|
|
91
|
+
for (const resolve of waiters)
|
|
92
|
+
resolve();
|
|
93
|
+
this.streaming = false;
|
|
94
|
+
if (wasStreaming)
|
|
95
|
+
this.emit({ type: "turn_completed", turnId: `fake-turn-${this.promptIndex}`, status: "aborted" });
|
|
96
|
+
}
|
|
97
|
+
async dispose() {
|
|
98
|
+
this.disposeCalls += 1;
|
|
99
|
+
if (this.disposed)
|
|
100
|
+
return;
|
|
101
|
+
this.disposed = true;
|
|
102
|
+
await this.abort();
|
|
103
|
+
this.listeners.clear();
|
|
104
|
+
}
|
|
105
|
+
getStatus() {
|
|
106
|
+
return {
|
|
107
|
+
streaming: this.disposed ? false : this.streaming,
|
|
108
|
+
enabledTools: [],
|
|
109
|
+
cwd: this.cwd,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
emit(event) {
|
|
113
|
+
for (const listener of this.listeners)
|
|
114
|
+
listener(event);
|
|
115
|
+
}
|
|
116
|
+
assertActive() {
|
|
117
|
+
if (this.disposed)
|
|
118
|
+
throw new Error("Fake runtime session is disposed.");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
export class FakeAgentRuntimeAdapter {
|
|
122
|
+
instanceId;
|
|
123
|
+
descriptor;
|
|
124
|
+
options;
|
|
125
|
+
config;
|
|
126
|
+
displayName;
|
|
127
|
+
enabled;
|
|
128
|
+
sessions = [];
|
|
129
|
+
openInputs = [];
|
|
130
|
+
nextNativeSession = 1;
|
|
131
|
+
constructor(instanceId, descriptor, config, displayName, enabled, options) {
|
|
132
|
+
this.instanceId = instanceId;
|
|
133
|
+
this.descriptor = descriptor;
|
|
134
|
+
this.options = options;
|
|
135
|
+
this.config = structuredClone(config);
|
|
136
|
+
this.displayName = displayName ?? descriptor.displayName;
|
|
137
|
+
this.enabled = enabled;
|
|
138
|
+
}
|
|
139
|
+
async diagnose() {
|
|
140
|
+
return [...(this.options.diagnostics ?? [])];
|
|
141
|
+
}
|
|
142
|
+
validateProfile(_input) {
|
|
143
|
+
return [];
|
|
144
|
+
}
|
|
145
|
+
async openSession(input) {
|
|
146
|
+
this.openInputs.push(input);
|
|
147
|
+
const script = typeof this.options.script === "function"
|
|
148
|
+
? this.options.script({ text: "", source: "rpc" }, 0)
|
|
149
|
+
: this.options.script;
|
|
150
|
+
if (script?.missingNativeSession && input.binding?.state === "bound") {
|
|
151
|
+
throw new AgentRuntimeBindingMissingError(input.piboSession.id, this.instanceId, input.binding.nativeSessionId);
|
|
152
|
+
}
|
|
153
|
+
const nativeSessionId = input.binding?.nativeSessionId ?? `fake-native-${this.nextNativeSession++}`;
|
|
154
|
+
const normalizedInput = {
|
|
155
|
+
...input,
|
|
156
|
+
binding: input.binding
|
|
157
|
+
? { ...input.binding, adapterId: this.descriptor.id, runtimeInstanceId: this.instanceId }
|
|
158
|
+
: undefined,
|
|
159
|
+
};
|
|
160
|
+
const session = new FakeAgentRuntimeSession(normalizedInput, this.descriptor.id, this.options.script, this.descriptor.capabilities, nativeSessionId);
|
|
161
|
+
this.sessions.push(session);
|
|
162
|
+
return session;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export function createFakeAgentRuntimeDriver(options = {}) {
|
|
166
|
+
const adapterId = options.adapterId ?? "fake";
|
|
167
|
+
const descriptor = {
|
|
168
|
+
id: adapterId,
|
|
169
|
+
displayName: options.displayName ?? "Fake Agent Runtime",
|
|
170
|
+
transport: "embedded",
|
|
171
|
+
configSchema: {
|
|
172
|
+
type: "object",
|
|
173
|
+
additionalProperties: false,
|
|
174
|
+
},
|
|
175
|
+
capabilities: options.capabilities ?? createMinimalAgentRuntimeCapabilities(),
|
|
176
|
+
supportsMultipleInstances: true,
|
|
177
|
+
};
|
|
178
|
+
return {
|
|
179
|
+
descriptor,
|
|
180
|
+
defaultConfig: () => ({}),
|
|
181
|
+
parseConfig(value) {
|
|
182
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
183
|
+
throw new Error("config must be an object");
|
|
184
|
+
if (Object.keys(value).length > 0)
|
|
185
|
+
throw new Error("fake runtime config does not accept instance fields");
|
|
186
|
+
return {};
|
|
187
|
+
},
|
|
188
|
+
create(input) {
|
|
189
|
+
return new FakeAgentRuntimeAdapter(input.instanceId, descriptor, input.config, input.displayName, input.enabled, options);
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|