my-durable 0.0.0-stage → 0.0.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.
- package/.env.example +7 -0
- package/LICENSE +21 -0
- package/README.md +328 -2
- package/ai_docs/durable_pi/announcement.md +860 -0
- package/ai_docs/durable_pi/changelog.md +51 -0
- package/ai_docs/durable_pi/chord-delta-findings.md +362 -0
- package/ai_docs/durable_pi/coding-agent-integration.md +70 -0
- package/ai_docs/durable_pi/pico-v5-chord-usage.md +391 -0
- package/ai_docs/durable_pi/pico-v5-handoff.md +921 -0
- package/ai_docs/durable_pi/readme.md +617 -0
- package/ai_docs/durable_pi/sources.md +22 -0
- package/ai_docs/durable_pi/spec.md +4696 -0
- package/ai_docs/durable_pi/vacation-planner.md +57 -0
- package/ai_docs/pi/chord.md +268 -0
- package/ai_docs/pi/cli-integration.md +110 -0
- package/ai_docs/pi/cli.md +325 -0
- package/ai_docs/pi/codemode.md +211 -0
- package/ai_docs/pi/compaction.md +467 -0
- package/ai_docs/pi/configuration.md +51 -0
- package/ai_docs/pi/containerization.md +187 -0
- package/ai_docs/pi/custom-provider.md +177 -0
- package/ai_docs/pi/environment-variables.md +102 -0
- package/ai_docs/pi/extensions.md +278 -0
- package/ai_docs/pi/how-pi-works.md +53 -0
- package/ai_docs/pi/index.md +43 -0
- package/ai_docs/pi/json.md +230 -0
- package/ai_docs/pi/keybindings.md +198 -0
- package/ai_docs/pi/llama-cpp.md +118 -0
- package/ai_docs/pi/mcp.md +274 -0
- package/ai_docs/pi/message-types.md +265 -0
- package/ai_docs/pi/models.md +209 -0
- package/ai_docs/pi/overview.md +166 -0
- package/ai_docs/pi/packages.md +133 -0
- package/ai_docs/pi/pi-agent-core.md +568 -0
- package/ai_docs/pi/pi-ai.md +1942 -0
- package/ai_docs/pi/prompt-templates.md +63 -0
- package/ai_docs/pi/providers.md +204 -0
- package/ai_docs/pi/quickstart.md +140 -0
- package/ai_docs/pi/readme.md +99 -0
- package/ai_docs/pi/rpc-commands.md +864 -0
- package/ai_docs/pi/rpc-extension-ui.md +204 -0
- package/ai_docs/pi/rpc.md +197 -0
- package/ai_docs/pi/sdk.md +151 -0
- package/ai_docs/pi/security.md +103 -0
- package/ai_docs/pi/session-format.md +297 -0
- package/ai_docs/pi/sessions.md +70 -0
- package/ai_docs/pi/settings.md +173 -0
- package/ai_docs/pi/shell-aliases.md +97 -0
- package/ai_docs/pi/skills.md +97 -0
- package/ai_docs/pi/slash-commands.md +64 -0
- package/ai_docs/pi/sources.md +57 -0
- package/ai_docs/pi/terminal-setup.md +223 -0
- package/ai_docs/pi/termux.md +121 -0
- package/ai_docs/pi/themes.md +140 -0
- package/ai_docs/pi/tmux.md +59 -0
- package/ai_docs/pi/toolkit.md +168 -0
- package/ai_docs/pi/tui.md +129 -0
- package/ai_docs/pi/usage.md +98 -0
- package/ai_docs/pi/virtual-models.md +118 -0
- package/ai_docs/pi/windows.md +71 -0
- package/apps/dpi-backend/.nvmrc +1 -0
- package/apps/dpi-backend/API.md +99 -0
- package/apps/dpi-backend/README.md +119 -0
- package/apps/dpi-backend/deploy/backend.env.example +9 -0
- package/apps/dpi-backend/deploy/dpi-backend.plist +26 -0
- package/apps/dpi-backend/deploy/dpi-backend.service +22 -0
- package/apps/dpi-backend/package.json +33 -0
- package/apps/dpi-backend/prompts/one_sentence.md +3 -0
- package/apps/dpi-backend/prompts/smart_ass_opus_fix.md +169 -0
- package/apps/dpi-backend/scripts/check-contract.mjs +151 -0
- package/apps/dpi-backend/scripts/migrate-playground.ts +66 -0
- package/apps/dpi-backend/scripts/record-nested-fixture.mts +154 -0
- package/apps/dpi-backend/scripts/token.ts +57 -0
- package/apps/dpi-backend/src/addons.ts +139 -0
- package/apps/dpi-backend/src/auth.ts +20 -0
- package/apps/dpi-backend/src/config.ts +54 -0
- package/apps/dpi-backend/src/contract-check.ts +118 -0
- package/apps/dpi-backend/src/errors.ts +50 -0
- package/apps/dpi-backend/src/extensions.ts +510 -0
- package/apps/dpi-backend/src/faux.ts +80 -0
- package/apps/dpi-backend/src/history.ts +165 -0
- package/apps/dpi-backend/src/idempotency.ts +20 -0
- package/apps/dpi-backend/src/jev.ts +43 -0
- package/apps/dpi-backend/src/jobs.ts +790 -0
- package/apps/dpi-backend/src/main.ts +76 -0
- package/apps/dpi-backend/src/model-catalog.ts +180 -0
- package/apps/dpi-backend/src/pairing-files.ts +142 -0
- package/apps/dpi-backend/src/pairing.ts +459 -0
- package/apps/dpi-backend/src/routes.ts +217 -0
- package/apps/dpi-backend/src/shared-state.ts +85 -0
- package/apps/dpi-backend/src/store.ts +1240 -0
- package/apps/dpi-backend/src/streams.ts +256 -0
- package/apps/dpi-backend/src/tunnel.ts +955 -0
- package/apps/dpi-backend/tsconfig.json +13 -0
- package/apps/dpi-playground/README.md +83 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-CFGc7lHT.js +77 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/assets/index-DFdKpwm_.css +1 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/anthropic.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/deepseek.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/durable-pi.svg +14 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/gemini.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/grok.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/kimi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/lab.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/meta.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/minimax.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/openai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/qwen.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/xiaomi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/icons/zai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/dist/index.html +16 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/index.html +15 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/package.json +5 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/anthropic.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/deepseek.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/durable-pi.svg +14 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/gemini.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/grok.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/kimi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/lab.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/meta.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/minimax.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/openai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/qwen.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/xiaomi.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/public/icons/zai.png +0 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/App.vue +180 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/commands.ts +119 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/composables.ts +129 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/hub.ts +40 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/icon-path.ts +7 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/ids.ts +2 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/jobs.ts +80 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/link-policy.ts +16 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/markdown-policy.ts +115 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/markdown.ts +60 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/pair-close.ts +23 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/pair-handoff.ts +56 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/pair.ts +166 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/qrcode.ts +323 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/signature.ts +146 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/store.ts +373 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/client/stream.ts +183 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/AgentView.vue +342 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Composer.vue +198 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/ContextBar.vue +254 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/DeviceCredentialsDialog.vue +40 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/DeviceIcon.vue +56 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/DirBrowser.vue +95 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/ExtensionsPanel.vue +96 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/HelpDialog.vue +69 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Inspector.vue +425 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/JobCard.vue +221 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/MobileNav.vue +39 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/ModelPicker.vue +71 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NetworkSidebar.vue +236 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/NewSessionDialog.vue +114 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/OfflinePanel.vue +128 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/PairDeviceWizard.vue +433 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/PromptDialog.vue +89 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/StateEditor.vue +179 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TasksPanel.vue +280 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/Toast.vue +11 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TokenManager.vue +175 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TopBar.vue +114 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TranscriptItem.vue +152 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TreeRow.vue +195 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/components/TunnelStatusBar.vue +107 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/extensions.css +105 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/jobs.css +655 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/main.ts +22 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/network.css +675 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/src/style.css +3203 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/tsconfig.json +16 -0
- package/apps/dpi-playground/apps/dpi-playground-fe/vite.config.ts +14 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/package.json +5 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/audit.ts +406 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/client-ip.ts +72 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/credentials.ts +265 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/guard.ts +43 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/http-errors.ts +156 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/identity.ts +60 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/limiter.ts +165 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/main.ts +460 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/monitor.ts +320 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/mux.ts +277 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/pairing.ts +816 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/proxy.ts +128 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/rotation.ts +583 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/seed.ts +11 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/transport.ts +108 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel-token.ts +11 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel-transport.ts +560 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/src/tunnel.ts +873 -0
- package/apps/dpi-playground/apps/dpi-playground-hub/tsconfig.json +13 -0
- package/apps/dpi-playground/package.json +37 -0
- package/apps/dpi-sdk/README.md +74 -0
- package/apps/dpi-sdk/package.json +20 -0
- package/apps/dpi-sdk/scripts/net.ts +73 -0
- package/apps/dpi-sdk/src/api.ts +631 -0
- package/apps/dpi-sdk/src/app-state.ts +111 -0
- package/apps/dpi-sdk/src/client.ts +330 -0
- package/apps/dpi-sdk/src/errors.ts +16 -0
- package/apps/dpi-sdk/src/jobs.ts +99 -0
- package/apps/dpi-sdk/src/models.ts +472 -0
- package/apps/dpi-sdk/src/node/chunk.ts +488 -0
- package/apps/dpi-sdk/src/node/config.ts +175 -0
- package/apps/dpi-sdk/src/node/drivers.ts +402 -0
- package/apps/dpi-sdk/src/node/ops.ts +114 -0
- package/apps/dpi-sdk/src/node/private-dir.ts +48 -0
- package/apps/dpi-sdk/src/node/registry-migration.ts +549 -0
- package/apps/dpi-sdk/src/node/registry.ts +390 -0
- package/apps/dpi-sdk/src/node/sse-writer.ts +151 -0
- package/apps/dpi-sdk/src/protocol/backoff.ts +31 -0
- package/apps/dpi-sdk/src/protocol/limits.ts +199 -0
- package/apps/dpi-sdk/src/protocol/pairing.ts +311 -0
- package/apps/dpi-sdk/src/protocol/rest-routes.ts +105 -0
- package/apps/dpi-sdk/src/protocol/tunnel.ts +331 -0
- package/apps/dpi-sdk/src/sse.ts +117 -0
- package/apps/dpi-sdk/src/transcript.ts +291 -0
- package/apps/dpi-sdk/tsconfig.json +13 -0
- package/apps/dpi-sdk/w +20 -0
- package/apps/dpi-tui/README.md +54 -0
- package/apps/dpi-tui/bin/dpi-tui.mjs +5 -0
- package/apps/dpi-tui/package.json +20 -0
- package/apps/dpi-tui/src/app.ts +433 -0
- package/apps/dpi-tui/src/commands.ts +151 -0
- package/apps/dpi-tui/src/main.ts +122 -0
- package/apps/dpi-tui/src/pairing.ts +287 -0
- package/apps/dpi-tui/src/pickers.ts +238 -0
- package/apps/dpi-tui/src/render.ts +164 -0
- package/apps/dpi-tui/src/theme.ts +57 -0
- package/apps/dpi-tui/tsconfig.json +14 -0
- package/bin/device.mjs +5 -0
- package/bin/hub.mjs +5 -0
- package/bin/tui.mjs +5 -0
- package/deploy/Caddyfile +120 -0
- package/docs/verification.md +102 -0
- package/dpi-network.example.yaml +62 -0
- package/images/01_durable_agent_network.svg +185 -0
- package/images/02_pi_made_durable.svg +204 -0
- package/images/03_restart_mid_tool.svg +168 -0
- package/images/07_one_api_every_client.svg +123 -0
- package/images/08_device_session_agent.svg +123 -0
- package/images/09_compact_keep_history.svg +143 -0
- package/images/10_shared_app_state.svg +177 -0
- package/images/11_durable_jobs_wait.svg +141 -0
- package/images/12_tools_change_mid_run.svg +231 -0
- package/images/13_hook_blocks_tool.svg +122 -0
- package/images/14_fork_at_any_entry.svg +119 -0
- package/images/15_web_client.png +0 -0
- package/images/16_terminal_client.svg +43 -0
- package/images/17_devices_are_data.svg +182 -0
- package/images/18_should_every_agent_be_durable.svg +118 -0
- package/images/19_sqlite_on_every_device.svg +155 -0
- package/images/20_admission_and_effects.svg +134 -0
- package/justfile +33 -0
- package/package.json +41 -4
- package/scripts/verify.mjs +210 -0
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
// The Durable Agent Network wire contract: every JSON body and stream frame between
|
|
2
|
+
// dpi-backend and its clients. Types only, so browsers, Node and the TUI share it.
|
|
3
|
+
//
|
|
4
|
+
// Agent events are pi-durable 1.0.3's `watchEvents()` output passed through verbatim.
|
|
5
|
+
// The Wire* event types below copy their JSON shape; apps/dpi-backend/src/contract-check.ts
|
|
6
|
+
// fails the build if pi-durable's own types stop fitting them.
|
|
7
|
+
|
|
8
|
+
import type { JobDef } from "./jobs.js";
|
|
9
|
+
|
|
10
|
+
// P2 protocol contracts (pairing + tunnel). TYPE-ONLY re-exports: erased at
|
|
11
|
+
// compile time, so the browser bundle never pulls @sinclair/typebox or any
|
|
12
|
+
// Node builtin. Runtime validators are imported from ./protocol/*.js directly
|
|
13
|
+
// by Node-side consumers (backend, hub connector).
|
|
14
|
+
export type {
|
|
15
|
+
PairRequest,
|
|
16
|
+
PairChallenge,
|
|
17
|
+
PairResponse,
|
|
18
|
+
PairPending,
|
|
19
|
+
TokenIssue,
|
|
20
|
+
PairApproval,
|
|
21
|
+
RevokeNotice,
|
|
22
|
+
PairError,
|
|
23
|
+
PairCodeIssue,
|
|
24
|
+
PairCodeState,
|
|
25
|
+
} from "./protocol/pairing.js";
|
|
26
|
+
export type {
|
|
27
|
+
TunnelFrame,
|
|
28
|
+
TunnelChunk,
|
|
29
|
+
TunnelWireMessage,
|
|
30
|
+
TunnelAuthError,
|
|
31
|
+
Direction,
|
|
32
|
+
TunnelPhase,
|
|
33
|
+
} from "./protocol/tunnel.js";
|
|
34
|
+
|
|
35
|
+
export const API_VERSION = 1 as const;
|
|
36
|
+
|
|
37
|
+
export type DeviceKind = "local" | "ssh" | "exe-dev" | "url";
|
|
38
|
+
export type DeviceStatus =
|
|
39
|
+
| "checking"
|
|
40
|
+
| "online"
|
|
41
|
+
| "offline"
|
|
42
|
+
| "unauthorized"
|
|
43
|
+
| "mismatch"
|
|
44
|
+
| "incompatible";
|
|
45
|
+
export type ErrorCode =
|
|
46
|
+
| "unauthorized"
|
|
47
|
+
| "not_found"
|
|
48
|
+
| "invalid"
|
|
49
|
+
| "busy"
|
|
50
|
+
| "conflict"
|
|
51
|
+
| "ambiguous"
|
|
52
|
+
| "unavailable"
|
|
53
|
+
| "internal"
|
|
54
|
+
| "offline"
|
|
55
|
+
| "rate_limited"
|
|
56
|
+
| "timeout";
|
|
57
|
+
export type ThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
58
|
+
export const THINKING_LEVELS: readonly ThinkingLevel[] = [
|
|
59
|
+
"off",
|
|
60
|
+
"minimal",
|
|
61
|
+
"low",
|
|
62
|
+
"medium",
|
|
63
|
+
"high",
|
|
64
|
+
"xhigh",
|
|
65
|
+
];
|
|
66
|
+
export type WhenBusy = "followUp" | "steer" | "reject";
|
|
67
|
+
|
|
68
|
+
export interface ApiErrorBody {
|
|
69
|
+
error: { code: ErrorCode; message: string };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ---------------------------------------------------------------- device
|
|
73
|
+
|
|
74
|
+
export interface ModelInfo {
|
|
75
|
+
id: string;
|
|
76
|
+
provider: string;
|
|
77
|
+
name: string;
|
|
78
|
+
tier: string;
|
|
79
|
+
icon: string;
|
|
80
|
+
contextWindow: number;
|
|
81
|
+
reasoning: boolean;
|
|
82
|
+
cost: { input: number; output: number };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface DeviceInfo {
|
|
86
|
+
uid: string;
|
|
87
|
+
name: string;
|
|
88
|
+
hostname: string;
|
|
89
|
+
platform: string;
|
|
90
|
+
apiVersion: typeof API_VERSION;
|
|
91
|
+
durableVersion: string;
|
|
92
|
+
startedAt: number;
|
|
93
|
+
/** Where new sessions start: the directory browser opens here, relative cwds resolve against the first. */
|
|
94
|
+
startDirs: string[];
|
|
95
|
+
models: ModelInfo[];
|
|
96
|
+
defaultModel: string;
|
|
97
|
+
storage: { dataDir: string; catalogPath: string; appStatePath: string };
|
|
98
|
+
/** The checkout the backend runs from (repo root locally, `code_dir` on deployed devices). */
|
|
99
|
+
codeDir?: string;
|
|
100
|
+
capabilities: Array<"events" | "docs" | "demo" | "jobs">;
|
|
101
|
+
/** Durable jobs any agent on this device can run (`POST .../demo/jobs` or the run_durable_job tool). */
|
|
102
|
+
jobs?: JobDef[];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface DirListing {
|
|
106
|
+
path: string;
|
|
107
|
+
parent?: string;
|
|
108
|
+
dirs: { name: string; path: string }[];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// ---------------------------------------------------------------- sessions and agents
|
|
112
|
+
|
|
113
|
+
export type AgentKind = "root" | "fork" | "subagent";
|
|
114
|
+
|
|
115
|
+
/** An agent is a pi-durable conversation; `id` is the conversation id. */
|
|
116
|
+
export interface AgentRef {
|
|
117
|
+
id: number;
|
|
118
|
+
name: string;
|
|
119
|
+
/** True when `name` was set by a person rather than derived from the id. */
|
|
120
|
+
named: boolean;
|
|
121
|
+
kind: AgentKind;
|
|
122
|
+
parentId?: number;
|
|
123
|
+
forkedAt?: number;
|
|
124
|
+
ownerAgentId?: number;
|
|
125
|
+
ownerTaskId?: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface AgentStatus {
|
|
129
|
+
busy: boolean;
|
|
130
|
+
background: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type AgentSummary = AgentRef & AgentStatus;
|
|
134
|
+
|
|
135
|
+
export interface SessionSummary {
|
|
136
|
+
id: string;
|
|
137
|
+
name: string;
|
|
138
|
+
cwd: string;
|
|
139
|
+
model: string;
|
|
140
|
+
createdAt: number;
|
|
141
|
+
dbPath: string;
|
|
142
|
+
busy: boolean;
|
|
143
|
+
error?: string;
|
|
144
|
+
agents: AgentSummary[];
|
|
145
|
+
/** Automatic compaction thresholds, shared by every agent of the session. */
|
|
146
|
+
compaction?: CompactionSettings;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* pi-durable's compaction policy. Above `contextWindow - reserveTokens` the next request waits for a summary;
|
|
151
|
+
* `backgroundTokens` below that, a summary starts in the background (0 disables it).
|
|
152
|
+
*/
|
|
153
|
+
export interface CompactionSettings {
|
|
154
|
+
enabled: boolean;
|
|
155
|
+
reserveTokens: number;
|
|
156
|
+
backgroundTokens: number;
|
|
157
|
+
keepRecentTokens: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export const DEFAULT_COMPACTION: CompactionSettings = {
|
|
161
|
+
enabled: true,
|
|
162
|
+
reserveTokens: 16384,
|
|
163
|
+
backgroundTokens: 32768,
|
|
164
|
+
keepRecentTokens: 2000,
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
/** The playground's default marker positions: a summary starts in the background at 200k tokens, and the next
|
|
168
|
+
* request waits for it at 250k. */
|
|
169
|
+
export const DEFAULT_COMPACTION_AT = { auto: 200_000, wait: 250_000 };
|
|
170
|
+
|
|
171
|
+
/** Default thresholds for a model window: the positions above, or pi-durable's own margins when the window is smaller. */
|
|
172
|
+
export function defaultCompaction(window: number): CompactionSettings {
|
|
173
|
+
if (!(window > 0)) return { ...DEFAULT_COMPACTION };
|
|
174
|
+
const wait = Math.min(DEFAULT_COMPACTION_AT.wait, window - DEFAULT_COMPACTION.reserveTokens);
|
|
175
|
+
const auto = Math.min(DEFAULT_COMPACTION_AT.auto, wait - DEFAULT_COMPACTION.backgroundTokens);
|
|
176
|
+
return { ...DEFAULT_COMPACTION, reserveTokens: window - wait, backgroundTokens: wait - auto };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/** False when the thresholds leave a model with this window under 32k tokens before every request waits for a summary. */
|
|
180
|
+
export const compactionFits = (window: number, s: CompactionSettings) => window - s.reserveTokens >= 32_768;
|
|
181
|
+
|
|
182
|
+
/** Context sizes where compaction starts for a model window: `auto` in the background, `wait` blocking. */
|
|
183
|
+
export function compactionThresholds(window: number, s: CompactionSettings) {
|
|
184
|
+
const wait = Math.max(0, window - s.reserveTokens);
|
|
185
|
+
return { wait, auto: s.backgroundTokens > 0 ? Math.max(0, wait - s.backgroundTokens) : undefined };
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface DeviceTree {
|
|
189
|
+
uid: string;
|
|
190
|
+
name: string;
|
|
191
|
+
sessions: SessionSummary[];
|
|
192
|
+
at: number;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export interface AgentConfig {
|
|
196
|
+
model?: { provider: string; modelId: string };
|
|
197
|
+
thinkingLevel?: ThinkingLevel;
|
|
198
|
+
instructions?: string;
|
|
199
|
+
cwd?: string;
|
|
200
|
+
/** Offer only tools that read: tools that create, update or delete leave the agent's requests. */
|
|
201
|
+
readOnly?: boolean;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** A custom harness extension an agent can turn on or off: `GET / PATCH .../agents/:a/extensions`. */
|
|
205
|
+
export interface HarnessExtensionInfo {
|
|
206
|
+
name: string;
|
|
207
|
+
title: string;
|
|
208
|
+
description: string;
|
|
209
|
+
enabled: boolean;
|
|
210
|
+
/** For system-prompts: the built-in prompts and which ones this agent renders. */
|
|
211
|
+
prompts?: { id: string; title: string; description: string; enabled: boolean; text: string }[];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export interface AgentExtensions {
|
|
215
|
+
extensions: HarnessExtensionInfo[];
|
|
216
|
+
/** Extensions every agent runs, which cannot be turned off here. */
|
|
217
|
+
builtIn: string[];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface AgentDetail extends AgentSummary {
|
|
221
|
+
sessionId: string;
|
|
222
|
+
config: AgentConfig;
|
|
223
|
+
/**
|
|
224
|
+
* Every tool of the agent's extensions. `parameters` is its JSON Schema, as the model sees it; `writes` marks tools
|
|
225
|
+
* that create, update or delete; `offered` is false for tools the agent's tool filter removes (read only).
|
|
226
|
+
*/
|
|
227
|
+
tools: {
|
|
228
|
+
name: string;
|
|
229
|
+
description: string;
|
|
230
|
+
replay: "safe" | "unsafe";
|
|
231
|
+
parameters?: unknown;
|
|
232
|
+
writes: boolean;
|
|
233
|
+
offered: boolean;
|
|
234
|
+
}[];
|
|
235
|
+
extensions: string[];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
export interface CreateSessionBody {
|
|
239
|
+
name: string;
|
|
240
|
+
cwd: string;
|
|
241
|
+
model: { provider: string; modelId: string };
|
|
242
|
+
thinkingLevel?: ThinkingLevel;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface CreateAgentBody {
|
|
246
|
+
from?: number | string;
|
|
247
|
+
name?: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export interface SendMessageBody {
|
|
251
|
+
content: string;
|
|
252
|
+
whenBusy?: WhenBusy;
|
|
253
|
+
requestId: string;
|
|
254
|
+
waitMs?: number;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export type SendResult =
|
|
258
|
+
| { submissionId: number; status: "queued" | "pending" }
|
|
259
|
+
| { submissionId: number; status: "done"; answer: { entryId: number; text: string } }
|
|
260
|
+
| { submissionId: number; status: "unanswered"; reason: string };
|
|
261
|
+
|
|
262
|
+
export interface ForkBody {
|
|
263
|
+
entryId: number;
|
|
264
|
+
name?: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
export interface Page<T> {
|
|
268
|
+
items: T[];
|
|
269
|
+
next?: string;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// ---------------------------------------------------------------- tasks and usage
|
|
273
|
+
|
|
274
|
+
export interface TaskNode {
|
|
275
|
+
id: number;
|
|
276
|
+
kind: string;
|
|
277
|
+
conversationId: number;
|
|
278
|
+
owner?: number;
|
|
279
|
+
background: boolean;
|
|
280
|
+
aborting?: boolean;
|
|
281
|
+
state: { status: string; phase?: string; on?: number[]; policy?: string };
|
|
282
|
+
conversations: number[];
|
|
283
|
+
/** What the task is: the tool name of a `pi.tool` task, or the job title of a durable job. */
|
|
284
|
+
label?: string;
|
|
285
|
+
/** For `pi.tool` tasks: the tool call id in the transcript. */
|
|
286
|
+
callId?: string;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface TaskOutcome {
|
|
290
|
+
id: number;
|
|
291
|
+
kind: string;
|
|
292
|
+
conversationId?: number;
|
|
293
|
+
state: {
|
|
294
|
+
status: string;
|
|
295
|
+
outcome?: { status: string; result?: unknown; error?: { message: string } };
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ---------------------------------------------------------------- pi-ai / pi-durable JSON shapes
|
|
300
|
+
|
|
301
|
+
export interface WireText {
|
|
302
|
+
type: "text";
|
|
303
|
+
text: string;
|
|
304
|
+
}
|
|
305
|
+
export interface WireThinking {
|
|
306
|
+
type: "thinking";
|
|
307
|
+
thinking: string;
|
|
308
|
+
redacted?: boolean;
|
|
309
|
+
}
|
|
310
|
+
export interface WireToolCall {
|
|
311
|
+
type: "toolCall";
|
|
312
|
+
id: string;
|
|
313
|
+
name: string;
|
|
314
|
+
arguments: unknown;
|
|
315
|
+
}
|
|
316
|
+
export interface WireImage {
|
|
317
|
+
type: "image";
|
|
318
|
+
data: string;
|
|
319
|
+
mimeType: string;
|
|
320
|
+
}
|
|
321
|
+
export type WireAssistantBlock = WireText | WireThinking | WireToolCall;
|
|
322
|
+
|
|
323
|
+
export interface WireUsage {
|
|
324
|
+
input: number;
|
|
325
|
+
output: number;
|
|
326
|
+
cacheRead: number;
|
|
327
|
+
cacheWrite: number;
|
|
328
|
+
totalTokens: number;
|
|
329
|
+
cost: { input: number; output: number; cacheRead: number; cacheWrite: number; total: number };
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export interface WireUserMessage {
|
|
333
|
+
role: "user";
|
|
334
|
+
content: string | readonly (WireText | WireImage)[];
|
|
335
|
+
timestamp?: number;
|
|
336
|
+
}
|
|
337
|
+
export interface WireAssistantMessage {
|
|
338
|
+
role: "assistant";
|
|
339
|
+
content: readonly WireAssistantBlock[];
|
|
340
|
+
provider: string;
|
|
341
|
+
model: string;
|
|
342
|
+
usage: WireUsage;
|
|
343
|
+
stopReason: string;
|
|
344
|
+
errorMessage?: string;
|
|
345
|
+
timestamp?: number;
|
|
346
|
+
}
|
|
347
|
+
export interface WireToolResultMessage {
|
|
348
|
+
role: "toolResult";
|
|
349
|
+
toolCallId: string;
|
|
350
|
+
toolName: string;
|
|
351
|
+
content: readonly (WireText | WireImage)[];
|
|
352
|
+
isError: boolean;
|
|
353
|
+
details?: unknown;
|
|
354
|
+
timestamp?: number;
|
|
355
|
+
}
|
|
356
|
+
export interface WireOtherMessage {
|
|
357
|
+
role: string;
|
|
358
|
+
}
|
|
359
|
+
export type WireMessage =
|
|
360
|
+
| WireUserMessage
|
|
361
|
+
| WireAssistantMessage
|
|
362
|
+
| WireToolResultMessage
|
|
363
|
+
| WireOtherMessage;
|
|
364
|
+
|
|
365
|
+
export interface WireEntry {
|
|
366
|
+
id: number;
|
|
367
|
+
conversationId: number;
|
|
368
|
+
kind: string;
|
|
369
|
+
model?: readonly WireMessage[];
|
|
370
|
+
data?: unknown;
|
|
371
|
+
head?: number;
|
|
372
|
+
byTaskId?: number;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export interface WireToolSlot {
|
|
376
|
+
callId: string;
|
|
377
|
+
name: string;
|
|
378
|
+
taskId?: number;
|
|
379
|
+
status: "pending" | "running" | "done";
|
|
380
|
+
output?: string;
|
|
381
|
+
droppedBytes?: number;
|
|
382
|
+
droppedLines?: number;
|
|
383
|
+
details?: unknown;
|
|
384
|
+
diagnostics?: readonly unknown[];
|
|
385
|
+
entry?: number;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** How a nested call ended: error flag, execution time, spend, and bounded error text. */
|
|
389
|
+
export interface WireNestedToolSummary {
|
|
390
|
+
isError: boolean;
|
|
391
|
+
durationMs?: number;
|
|
392
|
+
usage?: unknown;
|
|
393
|
+
error?: string;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/** A nested call a running tool made through `executeTool()`; shown in `pi.live.nestedTools`. */
|
|
397
|
+
export interface WireNestedToolSlot {
|
|
398
|
+
callId: string;
|
|
399
|
+
name: string;
|
|
400
|
+
status: "pending" | "running" | "done";
|
|
401
|
+
output?: string;
|
|
402
|
+
droppedBytes?: number;
|
|
403
|
+
droppedLines?: number;
|
|
404
|
+
details?: unknown;
|
|
405
|
+
diagnostics?: readonly unknown[];
|
|
406
|
+
parentCallId: string;
|
|
407
|
+
parentTaskId: number;
|
|
408
|
+
taskId: number;
|
|
409
|
+
arguments: Readonly<Record<string, unknown>>;
|
|
410
|
+
summary?: WireNestedToolSummary;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/** The newest compaction failure since a compaction last produced a summary (`pi.live.compactionFailure`). */
|
|
414
|
+
export interface WireCompactionFailure {
|
|
415
|
+
taskId: number;
|
|
416
|
+
reason: string;
|
|
417
|
+
error: string;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** What a nested call returns to its caller; carried by `tool_execution_end.result`, not the transcript. */
|
|
421
|
+
export interface WireNestedToolResult {
|
|
422
|
+
taskId: number;
|
|
423
|
+
structuredOutput?: unknown;
|
|
424
|
+
isError: boolean;
|
|
425
|
+
details?: unknown;
|
|
426
|
+
diagnostics: readonly unknown[];
|
|
427
|
+
usage?: unknown;
|
|
428
|
+
durationMs?: number;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface WireCompaction {
|
|
432
|
+
taskId: number;
|
|
433
|
+
reason: string;
|
|
434
|
+
blocking: boolean;
|
|
435
|
+
attempt: number;
|
|
436
|
+
retry?: { at: number; error: string };
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
export interface WireAgentState {
|
|
440
|
+
model?: { provider: string; modelId: string };
|
|
441
|
+
thinkingLevel?: string;
|
|
442
|
+
extensions?: unknown;
|
|
443
|
+
tools?: unknown;
|
|
444
|
+
instructions?: string;
|
|
445
|
+
cwd?: string;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export interface WireUsageState {
|
|
449
|
+
models: Readonly<Record<string, WireUsage>>;
|
|
450
|
+
tools: Readonly<Record<string, WireUsage>>;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
export interface WireQueued {
|
|
454
|
+
id: number;
|
|
455
|
+
mode: string;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export type WireMessageChange =
|
|
459
|
+
| {
|
|
460
|
+
type: "text_start" | "thinking_start" | "toolcall_start";
|
|
461
|
+
contentIndex: number;
|
|
462
|
+
block: WireAssistantBlock;
|
|
463
|
+
}
|
|
464
|
+
| { type: "text_delta" | "thinking_delta"; contentIndex: number; delta: string }
|
|
465
|
+
| {
|
|
466
|
+
type: "toolcall_delta";
|
|
467
|
+
contentIndex: number;
|
|
468
|
+
path: readonly (string | number)[];
|
|
469
|
+
delta: string;
|
|
470
|
+
}
|
|
471
|
+
| { type: "block"; contentIndex: number; block: WireAssistantBlock }
|
|
472
|
+
| { type: "message"; message: WireAssistantMessage };
|
|
473
|
+
|
|
474
|
+
export interface WireSnapshotEvent {
|
|
475
|
+
type: "snapshot";
|
|
476
|
+
entries: readonly WireEntry[];
|
|
477
|
+
run?: { inputs: readonly number[] };
|
|
478
|
+
generation?: {
|
|
479
|
+
attempt: number;
|
|
480
|
+
message?: WireAssistantMessage;
|
|
481
|
+
retry?: { at: number; error: string };
|
|
482
|
+
deferred?: { pollAt: number };
|
|
483
|
+
};
|
|
484
|
+
tools: readonly WireToolSlot[];
|
|
485
|
+
/** Nested calls of running tool calls (`pi.live.nestedTools`); required, always an array. */
|
|
486
|
+
nestedTools: readonly WireNestedToolSlot[];
|
|
487
|
+
compactions: readonly WireCompaction[];
|
|
488
|
+
/** The newest compaction failure since a compaction last produced a summary; cleared by a later success. */
|
|
489
|
+
compactionFailure?: WireCompactionFailure;
|
|
490
|
+
inbox: readonly WireQueued[];
|
|
491
|
+
agent: WireAgentState;
|
|
492
|
+
usage: WireUsageState;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export type WireToolCallMeta = {
|
|
496
|
+
/** The call's tool task; absent for a call that never got one. */
|
|
497
|
+
taskId?: number;
|
|
498
|
+
/** Set for a nested call: the call that made it, by call ID and by tool task. */
|
|
499
|
+
parentToolCallId?: string;
|
|
500
|
+
parentTaskId?: number;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
export type WireAgentEvent =
|
|
504
|
+
| WireSnapshotEvent
|
|
505
|
+
| { type: "run_start" | "run_end"; inputs: readonly number[] }
|
|
506
|
+
| { type: "turn_start" | "turn_end" }
|
|
507
|
+
| { type: "message_start"; message: WireMessage }
|
|
508
|
+
| { type: "message_update"; usage: WireUsage; changes: readonly WireMessageChange[] }
|
|
509
|
+
| { type: "message_end"; entry: WireEntry }
|
|
510
|
+
| ({ type: "tool_execution_start"; toolCallId: string; toolName: string; args: unknown } & WireToolCallMeta)
|
|
511
|
+
| ({
|
|
512
|
+
type: "tool_execution_update";
|
|
513
|
+
toolCallId: string;
|
|
514
|
+
toolName: string;
|
|
515
|
+
output?: { trimStart?: number; append?: string } | { set: string };
|
|
516
|
+
details?: unknown;
|
|
517
|
+
diagnostics?: readonly unknown[];
|
|
518
|
+
} & WireToolCallMeta)
|
|
519
|
+
// A model-issued call ends with its result `entry`, a nested call with its `result`. Both are absent when the
|
|
520
|
+
// task faulted or was orphaned, or when the slot left `pi.live` unfinished — hence both optional.
|
|
521
|
+
| ({ type: "tool_execution_end"; toolCallId: string; toolName: string; entry?: WireEntry; result?: WireNestedToolResult } & WireToolCallMeta)
|
|
522
|
+
| { type: "inbox_update"; items: readonly WireQueued[] }
|
|
523
|
+
| { type: "submission"; record: { id: number; status: string } }
|
|
524
|
+
| { type: "auto_retry_start"; attempt: number; at: number; errorMessage: string }
|
|
525
|
+
| { type: "auto_retry_end"; attempt: number }
|
|
526
|
+
| { type: "deferred_poll"; pollAt: number }
|
|
527
|
+
| { type: "entry_appended"; entry: WireEntry }
|
|
528
|
+
| { type: "agent_changed"; agent: WireAgentState }
|
|
529
|
+
| { type: "usage_changed"; usage: WireUsageState }
|
|
530
|
+
| { type: "task_failed"; taskId: number; kind: string; message: string }
|
|
531
|
+
| { type: "compaction_start"; taskId: number; reason: string; blocking: boolean }
|
|
532
|
+
// `error` is set when the compaction failed, faulted or was orphaned.
|
|
533
|
+
| { type: "compaction_end"; taskId: number; reason: string; error?: string };
|
|
534
|
+
|
|
535
|
+
/** A queued submission with its content, read from the conversation's `pi.inbox` document. */
|
|
536
|
+
export interface InboxItem {
|
|
537
|
+
id: number;
|
|
538
|
+
mode: "steer" | "followUp" | "write";
|
|
539
|
+
content?: string;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
// ---------------------------------------------------------------- stream frames
|
|
543
|
+
|
|
544
|
+
export interface StreamScope {
|
|
545
|
+
kind: "device" | "session" | "agent";
|
|
546
|
+
sessionId?: string;
|
|
547
|
+
agentId?: number;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export interface Activity {
|
|
551
|
+
type: "agent.started" | "agent.finished";
|
|
552
|
+
sessionId: string;
|
|
553
|
+
agentId: number;
|
|
554
|
+
at: number;
|
|
555
|
+
preview?: string;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
export interface UsageTotals {
|
|
559
|
+
models: Record<string, WireUsage>;
|
|
560
|
+
tools: Record<string, WireUsage>;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/** Pairing metadata safe for the browser: no token hash, no public key material. */
|
|
564
|
+
export interface PublicPairingMetadata {
|
|
565
|
+
status: "paired" | "revoked";
|
|
566
|
+
keyFingerprint: string;
|
|
567
|
+
pairedAt: number;
|
|
568
|
+
credentialGeneration: number;
|
|
569
|
+
rotationPending: boolean;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export interface TunnelDiagnostics {
|
|
573
|
+
state: "connected" | "disconnected";
|
|
574
|
+
lastSeenAt?: number;
|
|
575
|
+
readerCount: number;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
export interface PublicPairing extends PublicPairingMetadata {
|
|
579
|
+
deviceId: string;
|
|
580
|
+
deviceUid: string;
|
|
581
|
+
deviceName: string;
|
|
582
|
+
tunnel: TunnelDiagnostics;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/** The public view of a registry device (the token never leaves the hub or TUI process). */
|
|
586
|
+
export interface NetworkDevice {
|
|
587
|
+
id: string;
|
|
588
|
+
name: string;
|
|
589
|
+
kind: DeviceKind;
|
|
590
|
+
transport: "lan" | "tunnel";
|
|
591
|
+
/** null when transport="tunnel" — consumers must not build links or URLs from it. */
|
|
592
|
+
url: string | null;
|
|
593
|
+
source: "config" | "ui";
|
|
594
|
+
/** LAN-only flag; hasToken=false is NOT unauthorized for tunnel devices. */
|
|
595
|
+
hasToken: boolean;
|
|
596
|
+
deviceUid?: string | null;
|
|
597
|
+
pairing?: PublicPairingMetadata;
|
|
598
|
+
tunnel?: TunnelDiagnostics;
|
|
599
|
+
status: DeviceStatus;
|
|
600
|
+
error?: string;
|
|
601
|
+
lastSeenAt?: number;
|
|
602
|
+
info?: DeviceInfo;
|
|
603
|
+
tree?: DeviceTree;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
export type Frame =
|
|
607
|
+
| { type: "hello"; apiVersion: typeof API_VERSION; serverTime: number; scope: StreamScope }
|
|
608
|
+
| { type: "fault"; error: { code: ErrorCode; message: string } }
|
|
609
|
+
// device scope
|
|
610
|
+
| { type: "tree"; tree: DeviceTree }
|
|
611
|
+
| { type: "activity"; items: Activity[] }
|
|
612
|
+
// session scope
|
|
613
|
+
| { type: "session"; agents: AgentSummary[]; tasks: TaskNode[]; usage: UsageTotals }
|
|
614
|
+
| { type: "agents"; agents: AgentSummary[] }
|
|
615
|
+
| { type: "tasks"; tasks: TaskNode[] }
|
|
616
|
+
| { type: "usage"; usage: UsageTotals }
|
|
617
|
+
// agent scope
|
|
618
|
+
| { type: "snapshot"; snapshot: WireSnapshotEvent; inbox: InboxItem[] }
|
|
619
|
+
| { type: "batch"; events: readonly WireAgentEvent[] }
|
|
620
|
+
| { type: "inbox"; items: InboxItem[] }
|
|
621
|
+
// any scope that asked for documents
|
|
622
|
+
| { type: "doc"; kind: string; value: unknown; revision?: number }
|
|
623
|
+
// hub mux only
|
|
624
|
+
| { type: "network"; devices: NetworkDevice[] }
|
|
625
|
+
| { type: "disconnected"; reason: string };
|
|
626
|
+
|
|
627
|
+
/** One frame of the hub's multiplexed browser stream. */
|
|
628
|
+
export interface MuxFrame {
|
|
629
|
+
sub: string;
|
|
630
|
+
frame: Frame | { type: "stream"; streamId: string };
|
|
631
|
+
}
|