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,342 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, nextTick, ref, watch } from "vue";
|
|
3
|
+
import {
|
|
4
|
+
Activity,
|
|
5
|
+
ArrowUpRight,
|
|
6
|
+
Braces,
|
|
7
|
+
Check,
|
|
8
|
+
ChevronDown,
|
|
9
|
+
ChevronRight,
|
|
10
|
+
CornerDownRight,
|
|
11
|
+
FolderOpen,
|
|
12
|
+
GitFork,
|
|
13
|
+
MessageSquare,
|
|
14
|
+
Pencil,
|
|
15
|
+
} from "lucide-vue-next";
|
|
16
|
+
import type { AgentSummary } from "@sdk/api";
|
|
17
|
+
import { lineage } from "@sdk/models";
|
|
18
|
+
import TranscriptItem from "./TranscriptItem.vue";
|
|
19
|
+
import DeviceIcon from "./DeviceIcon.vue";
|
|
20
|
+
import Composer from "./Composer.vue";
|
|
21
|
+
import {
|
|
22
|
+
activeLineage,
|
|
23
|
+
agent,
|
|
24
|
+
agentHandle,
|
|
25
|
+
agentState,
|
|
26
|
+
device,
|
|
27
|
+
notify,
|
|
28
|
+
preset,
|
|
29
|
+
select,
|
|
30
|
+
selected,
|
|
31
|
+
sessionAgents,
|
|
32
|
+
sessionSummary,
|
|
33
|
+
toggle,
|
|
34
|
+
layout,
|
|
35
|
+
ui,
|
|
36
|
+
} from "../client/store";
|
|
37
|
+
|
|
38
|
+
const chat = ref<HTMLElement>();
|
|
39
|
+
const lineageNav = ref<HTMLElement>();
|
|
40
|
+
const picker = ref(false);
|
|
41
|
+
const items = computed(() => agentState.value.items);
|
|
42
|
+
const liveItem = computed(() => items.value.some((i) => i.kind === "assistant" && i.streaming));
|
|
43
|
+
const runningTool = computed(() =>
|
|
44
|
+
items.value.some(
|
|
45
|
+
(i) =>
|
|
46
|
+
(i.kind === "tool" && i.call.status === "running") ||
|
|
47
|
+
(i.kind === "assistant" &&
|
|
48
|
+
i.blocks.some((b) => b.type === "tool" && b.call.status === "running")),
|
|
49
|
+
),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const source = (a: AgentSummary) =>
|
|
53
|
+
a.kind === "fork"
|
|
54
|
+
? `Forked from agent #${a.parentId} at entry #${a.forkedAt}`
|
|
55
|
+
: a.kind === "subagent"
|
|
56
|
+
? `Owned by agent #${a.ownerAgentId}`
|
|
57
|
+
: "Root agent";
|
|
58
|
+
const choices = computed(() =>
|
|
59
|
+
sessionAgents.value
|
|
60
|
+
.map((a) => ({ ...a, lineage: lineage(sessionAgents.value, a.id) }))
|
|
61
|
+
.sort((a, b) => {
|
|
62
|
+
for (let i = 0; i < Math.min(a.lineage.length, b.lineage.length); i++)
|
|
63
|
+
if (a.lineage[i].id !== b.lineage[i].id) return a.lineage[i].id - b.lineage[i].id;
|
|
64
|
+
return a.lineage.length - b.lineage.length;
|
|
65
|
+
}),
|
|
66
|
+
);
|
|
67
|
+
const current = computed(() => activeLineage.value.at(-1));
|
|
68
|
+
|
|
69
|
+
const kindLabel = (a: AgentSummary) => (a.kind === "root" ? "agent" : a.kind);
|
|
70
|
+
|
|
71
|
+
/** Device crumb: show it in the network tree. Workspace crumb: open its root agent. */
|
|
72
|
+
function revealDevice() {
|
|
73
|
+
if (!selected.value) return;
|
|
74
|
+
layout.tree = true;
|
|
75
|
+
toggle(selected.value.deviceId, true);
|
|
76
|
+
}
|
|
77
|
+
function openWorkspace() {
|
|
78
|
+
const root = sessionAgents.value.find((a) => a.kind === "root") ?? sessionAgents.value[0];
|
|
79
|
+
if (root) choose(root.id);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function choose(id: number) {
|
|
83
|
+
picker.value = false;
|
|
84
|
+
if (selected.value) select({ ...selected.value, agentId: id });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function fork(entryId: number) {
|
|
88
|
+
const handle = agentHandle.value;
|
|
89
|
+
const t = selected.value;
|
|
90
|
+
if (!handle || !t) return;
|
|
91
|
+
ui.dialog = {
|
|
92
|
+
kind: "prompt",
|
|
93
|
+
title: "Fork conversation",
|
|
94
|
+
hint: `${current.value?.name ?? `Agent #${t.agentId}`} / entry #${entryId}. Leave the name blank to use Fork #ID.`,
|
|
95
|
+
label: "Fork name",
|
|
96
|
+
optional: true,
|
|
97
|
+
placeholder: "e.g. Alternative approach",
|
|
98
|
+
submit: "Create fork",
|
|
99
|
+
run: async (name) => {
|
|
100
|
+
const created = await handle.fork({ entryId, name: name || undefined });
|
|
101
|
+
select({ ...t, agentId: created.id });
|
|
102
|
+
notify(`Forked at entry #${entryId}. App State stays shared.`);
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function renameAgent() {
|
|
108
|
+
const handle = agentHandle.value;
|
|
109
|
+
const a = current.value;
|
|
110
|
+
if (!handle || !a) return;
|
|
111
|
+
ui.dialog = {
|
|
112
|
+
kind: "prompt",
|
|
113
|
+
title: "Rename agent",
|
|
114
|
+
label: "Agent name",
|
|
115
|
+
value: a.named ? a.name : "",
|
|
116
|
+
placeholder: a.name,
|
|
117
|
+
submit: "Save name",
|
|
118
|
+
run: (name) => handle.rename(name),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
watch(selected, () => {
|
|
123
|
+
picker.value = false;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Follow the bottom of the transcript unless the reader scrolled up.
|
|
127
|
+
let pinned = true;
|
|
128
|
+
watch(
|
|
129
|
+
agent.version,
|
|
130
|
+
() => {
|
|
131
|
+
const el = chat.value;
|
|
132
|
+
pinned = !el || el.scrollHeight - el.scrollTop - el.clientHeight < 120;
|
|
133
|
+
},
|
|
134
|
+
{ flush: "pre" },
|
|
135
|
+
);
|
|
136
|
+
watch(agent.version, () => {
|
|
137
|
+
if (pinned)
|
|
138
|
+
void nextTick(() =>
|
|
139
|
+
chat.value?.scrollTo({ top: chat.value.scrollHeight, behavior: "instant" }),
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
watch(
|
|
143
|
+
() => activeLineage.value.length,
|
|
144
|
+
() =>
|
|
145
|
+
void nextTick(
|
|
146
|
+
() => lineageNav.value && (lineageNav.value.scrollLeft = lineageNav.value.scrollWidth),
|
|
147
|
+
),
|
|
148
|
+
);
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<template>
|
|
152
|
+
<section class="chat-panel">
|
|
153
|
+
<header class="chat-header">
|
|
154
|
+
<div class="lineage-picker">
|
|
155
|
+
<div class="lineage-toolbar">
|
|
156
|
+
<nav
|
|
157
|
+
ref="lineageNav"
|
|
158
|
+
class="crumbs conversation-lineage"
|
|
159
|
+
aria-label="Conversation lineage"
|
|
160
|
+
>
|
|
161
|
+
<button class="crumb" :title="`${device?.name} · ${device?.url}`" @click="revealDevice">
|
|
162
|
+
<span class="crumb-kind">device</span>
|
|
163
|
+
<span class="crumb-main"
|
|
164
|
+
><DeviceIcon :device="device" :size="18" /><span class="device-chip">{{
|
|
165
|
+
device?.id
|
|
166
|
+
}}</span></span
|
|
167
|
+
>
|
|
168
|
+
</button>
|
|
169
|
+
<ChevronRight class="crumb-sep" :size="18" aria-hidden="true" />
|
|
170
|
+
<button class="crumb" :title="sessionSummary?.cwd" @click="openWorkspace">
|
|
171
|
+
<span class="crumb-kind">workspace</span>
|
|
172
|
+
<span class="crumb-main"
|
|
173
|
+
><FolderOpen :size="18" aria-hidden="true" /><span class="crumb-name">{{
|
|
174
|
+
sessionSummary?.name
|
|
175
|
+
}}</span></span
|
|
176
|
+
>
|
|
177
|
+
</button>
|
|
178
|
+
<template v-for="c in activeLineage" :key="c.id">
|
|
179
|
+
<ChevronRight class="crumb-sep" :size="18" aria-hidden="true" />
|
|
180
|
+
<button
|
|
181
|
+
class="crumb"
|
|
182
|
+
:class="{ current: c.id === selected?.agentId }"
|
|
183
|
+
:aria-current="c.id === selected?.agentId ? 'page' : undefined"
|
|
184
|
+
:title="source(c)"
|
|
185
|
+
@click="choose(c.id)"
|
|
186
|
+
>
|
|
187
|
+
<span class="crumb-kind">{{ kindLabel(c) }}</span>
|
|
188
|
+
<span class="crumb-main"
|
|
189
|
+
><GitFork
|
|
190
|
+
v-if="c.kind === 'fork'"
|
|
191
|
+
:size="18"
|
|
192
|
+
aria-hidden="true"
|
|
193
|
+
/><CornerDownRight
|
|
194
|
+
v-else-if="c.kind === 'subagent'"
|
|
195
|
+
:size="18"
|
|
196
|
+
aria-hidden="true"
|
|
197
|
+
/><MessageSquare v-else :size="18" aria-hidden="true" /><span
|
|
198
|
+
class="crumb-name"
|
|
199
|
+
>{{ c.name }}</span
|
|
200
|
+
></span
|
|
201
|
+
>
|
|
202
|
+
</button>
|
|
203
|
+
</template>
|
|
204
|
+
</nav>
|
|
205
|
+
<button
|
|
206
|
+
class="icon-button"
|
|
207
|
+
aria-label="Rename agent"
|
|
208
|
+
title="Rename this agent"
|
|
209
|
+
:disabled="!current"
|
|
210
|
+
@click="renameAgent"
|
|
211
|
+
>
|
|
212
|
+
<Pencil :size="18" />
|
|
213
|
+
</button>
|
|
214
|
+
<button
|
|
215
|
+
class="icon-button conversation-menu-toggle"
|
|
216
|
+
aria-label="Browse conversations"
|
|
217
|
+
aria-haspopup="dialog"
|
|
218
|
+
:aria-expanded="picker"
|
|
219
|
+
aria-controls="conversation-picker"
|
|
220
|
+
title="Browse roots and forks"
|
|
221
|
+
@click="picker = !picker"
|
|
222
|
+
>
|
|
223
|
+
<ChevronDown :size="18" />
|
|
224
|
+
</button>
|
|
225
|
+
</div>
|
|
226
|
+
<div v-if="current && current.kind !== 'root'" class="lineage-source">
|
|
227
|
+
{{ source(current) }}
|
|
228
|
+
</div>
|
|
229
|
+
<template v-if="picker">
|
|
230
|
+
<button
|
|
231
|
+
class="conversation-menu-dismiss"
|
|
232
|
+
aria-label="Close conversation picker"
|
|
233
|
+
@click="picker = false"
|
|
234
|
+
/>
|
|
235
|
+
<section
|
|
236
|
+
id="conversation-picker"
|
|
237
|
+
class="conversation-picker"
|
|
238
|
+
role="dialog"
|
|
239
|
+
aria-label="Choose conversation"
|
|
240
|
+
>
|
|
241
|
+
<div class="conversation-picker-heading">Roots & forks</div>
|
|
242
|
+
<button
|
|
243
|
+
v-for="c in choices"
|
|
244
|
+
:key="c.id"
|
|
245
|
+
class="conversation-choice"
|
|
246
|
+
:class="{ selected: c.id === selected?.agentId }"
|
|
247
|
+
:aria-label="c.lineage.map((x) => x.name).join(' → ')"
|
|
248
|
+
:aria-current="c.id === selected?.agentId ? 'page' : undefined"
|
|
249
|
+
@click="choose(c.id)"
|
|
250
|
+
>
|
|
251
|
+
<div class="conversation-choice-content">
|
|
252
|
+
<span class="choice-lineage">
|
|
253
|
+
<template v-for="(ancestor, index) in c.lineage" :key="ancestor.id">
|
|
254
|
+
<ChevronRight v-if="index" :size="18" aria-hidden="true" />
|
|
255
|
+
<span :class="{ 'choice-ancestor': index < c.lineage.length - 1 }">{{
|
|
256
|
+
ancestor.name
|
|
257
|
+
}}</span>
|
|
258
|
+
</template>
|
|
259
|
+
</span>
|
|
260
|
+
<span class="choice-source">{{ source(c) }}</span>
|
|
261
|
+
</div>
|
|
262
|
+
<Check v-if="c.id === selected?.agentId" :size="18" aria-hidden="true" />
|
|
263
|
+
<GitFork v-else-if="c.kind === 'fork'" :size="18" aria-hidden="true" />
|
|
264
|
+
<MessageSquare v-else :size="18" aria-hidden="true" />
|
|
265
|
+
</button>
|
|
266
|
+
</section>
|
|
267
|
+
</template>
|
|
268
|
+
</div>
|
|
269
|
+
</header>
|
|
270
|
+
<div
|
|
271
|
+
v-if="
|
|
272
|
+
agent.fault.value ||
|
|
273
|
+
agent.status.value === 'fault' ||
|
|
274
|
+
agent.status.value === 'reconnecting' ||
|
|
275
|
+
(agentState.ready && agent.status.value === 'connecting')
|
|
276
|
+
"
|
|
277
|
+
class="agent-stream-status"
|
|
278
|
+
role="alert"
|
|
279
|
+
>
|
|
280
|
+
<div>
|
|
281
|
+
<strong>{{
|
|
282
|
+
agentState.ready ? "Cached transcript is stale." : "Agent stream unavailable."
|
|
283
|
+
}}</strong>
|
|
284
|
+
<p>{{ agent.fault.value || "Updates are paused while the stream reconnects." }}</p>
|
|
285
|
+
<p>Sending is paused until a fresh snapshot arrives. Your draft is kept.</p>
|
|
286
|
+
</div>
|
|
287
|
+
<button :disabled="agent.status.value === 'connecting'" @click="agent.retry">
|
|
288
|
+
Retry stream
|
|
289
|
+
</button>
|
|
290
|
+
</div>
|
|
291
|
+
<div ref="chat" class="chat-scroll" data-testid="chat">
|
|
292
|
+
<div v-if="!agentState.ready" class="chat-empty">
|
|
293
|
+
<Activity :size="30" />
|
|
294
|
+
<h2 v-if="agent.status.value === 'fault'">This agent is unavailable.</h2>
|
|
295
|
+
<h2 v-else>Connecting to the agent…</h2>
|
|
296
|
+
<p>The agent keeps working on {{ device?.id }} while this view connects.</p>
|
|
297
|
+
</div>
|
|
298
|
+
<template v-else>
|
|
299
|
+
<div v-if="!items.length" class="chat-empty">
|
|
300
|
+
<div class="agent-orb"><img src="/icons/durable-pi.svg" alt="Durable Pi" /><i /></div>
|
|
301
|
+
<span class="eyebrow">YOUR DURABLE AGENT IS READY</span>
|
|
302
|
+
<h2>A conversation with continuity.</h2>
|
|
303
|
+
<p>Messages, tools and state live on {{ device?.id }}, beyond this window.</p>
|
|
304
|
+
<div class="starter-grid">
|
|
305
|
+
<button
|
|
306
|
+
@click="
|
|
307
|
+
preset(
|
|
308
|
+
'Inspect this directory using your tools and give me a brief overview. Do not modify any files.',
|
|
309
|
+
)
|
|
310
|
+
"
|
|
311
|
+
>
|
|
312
|
+
<FolderOpen :size="18" /><strong>Explore this directory</strong
|
|
313
|
+
><span>See coding tools in action</span><ArrowUpRight :size="18" /></button
|
|
314
|
+
><button
|
|
315
|
+
@click="
|
|
316
|
+
preset(
|
|
317
|
+
'Use read_state, then update_state to add a field called progress with value 1 and a boolean called ready with value false.',
|
|
318
|
+
)
|
|
319
|
+
"
|
|
320
|
+
>
|
|
321
|
+
<Braces :size="18" /><strong>Make a state change</strong
|
|
322
|
+
><span>Watch the workspace update</span><ArrowUpRight :size="18" />
|
|
323
|
+
</button>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
<TranscriptItem v-for="item in items" :key="item.id" :item="item" @fork="fork" />
|
|
327
|
+
<div v-if="agentState.running && !liveItem && !runningTool" class="entry live-generation">
|
|
328
|
+
<div class="message-label">
|
|
329
|
+
AGENT
|
|
330
|
+
<span class="streaming">{{ agentState.retry ? "Retry scheduled" : "Working" }}</span>
|
|
331
|
+
</div>
|
|
332
|
+
<div class="typing"><i /><i /><i /></div>
|
|
333
|
+
</div>
|
|
334
|
+
<p v-if="agentState.retry" class="hint retry-note">
|
|
335
|
+
Retrying: {{ agentState.retry.error }}
|
|
336
|
+
</p>
|
|
337
|
+
<p v-for="(n, i) in agentState.notices" :key="i" class="message-error">{{ n }}</p>
|
|
338
|
+
</template>
|
|
339
|
+
</div>
|
|
340
|
+
<Composer />
|
|
341
|
+
</section>
|
|
342
|
+
</template>
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed, ref, watch } from "vue";
|
|
3
|
+
import { ArrowUp, ChevronDown, Clock3, Octagon, X } from "lucide-vue-next";
|
|
4
|
+
import type { WhenBusy } from "@sdk/api";
|
|
5
|
+
import { newId } from "../client/ids";
|
|
6
|
+
import { commands, parseCommand, type SlashCommand } from "../client/commands";
|
|
7
|
+
import {
|
|
8
|
+
agent,
|
|
9
|
+
agentHandle,
|
|
10
|
+
agentState,
|
|
11
|
+
attempt,
|
|
12
|
+
busy,
|
|
13
|
+
interrupt,
|
|
14
|
+
interrupting,
|
|
15
|
+
online,
|
|
16
|
+
selected,
|
|
17
|
+
streamState,
|
|
18
|
+
ui,
|
|
19
|
+
} from "../client/store";
|
|
20
|
+
|
|
21
|
+
const mode = ref<WhenBusy>("followUp");
|
|
22
|
+
const pending = ref(false);
|
|
23
|
+
const canSend = computed(
|
|
24
|
+
() =>
|
|
25
|
+
online.value &&
|
|
26
|
+
agentState.value.ready &&
|
|
27
|
+
agent.status.value === "live" &&
|
|
28
|
+
streamState.value === "live",
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
// Typing "/" lists the slash commands; arrows pick, Tab or Enter completes.
|
|
32
|
+
const menuIndex = ref(0);
|
|
33
|
+
const menuClosed = ref(false);
|
|
34
|
+
const matches = computed(() => {
|
|
35
|
+
const m = ui.composer.match(/^\/(\S*)$/);
|
|
36
|
+
return m && !menuClosed.value
|
|
37
|
+
? commands.filter((c) => c.name.startsWith(m[1].toLowerCase()))
|
|
38
|
+
: [];
|
|
39
|
+
});
|
|
40
|
+
watch(
|
|
41
|
+
() => ui.composer,
|
|
42
|
+
() => {
|
|
43
|
+
menuIndex.value = 0;
|
|
44
|
+
if (!ui.composer.startsWith("/")) menuClosed.value = false;
|
|
45
|
+
},
|
|
46
|
+
);
|
|
47
|
+
// Enter on a fully typed name runs it unless it needs an argument; otherwise the name completes.
|
|
48
|
+
async function pick(command: SlashCommand, enter = false) {
|
|
49
|
+
const runNow =
|
|
50
|
+
!command.args || (enter && command.args.startsWith("[") && ui.composer === `/${command.name}`);
|
|
51
|
+
if (!runNow) ui.composer = `/${command.name} `;
|
|
52
|
+
else {
|
|
53
|
+
ui.composer = `/${command.name}`;
|
|
54
|
+
await send();
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function keydown(e: KeyboardEvent) {
|
|
58
|
+
if (!matches.value.length) {
|
|
59
|
+
if (e.key === "Enter" && !e.shiftKey && !e.isComposing) {
|
|
60
|
+
e.preventDefault();
|
|
61
|
+
void send();
|
|
62
|
+
}
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") {
|
|
66
|
+
const n = matches.value.length;
|
|
67
|
+
menuIndex.value = (menuIndex.value + (e.key === "ArrowDown" ? 1 : n - 1)) % n;
|
|
68
|
+
} else if (e.key === "Tab" || (e.key === "Enter" && !e.shiftKey))
|
|
69
|
+
void pick(matches.value[menuIndex.value], e.key === "Enter");
|
|
70
|
+
else if (e.key === "Escape") menuClosed.value = true;
|
|
71
|
+
else return;
|
|
72
|
+
e.preventDefault();
|
|
73
|
+
e.stopPropagation();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
async function runCommand(text: string) {
|
|
77
|
+
const parsed = parseCommand(text);
|
|
78
|
+
if (!parsed) return false;
|
|
79
|
+
pending.value = true;
|
|
80
|
+
await attempt(async () => {
|
|
81
|
+
await parsed.command.run(parsed.arg);
|
|
82
|
+
ui.composer = "";
|
|
83
|
+
});
|
|
84
|
+
pending.value = false;
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// A retried send (same agent, text and mode) reuses its requestId, so the device admits it once.
|
|
89
|
+
async function send() {
|
|
90
|
+
const content = ui.composer.trim();
|
|
91
|
+
const handle = agentHandle.value;
|
|
92
|
+
if (!content || pending.value || !handle || !canSend.value) return;
|
|
93
|
+
if (content.startsWith("/") && (await runCommand(content))) return;
|
|
94
|
+
pending.value = true;
|
|
95
|
+
const t = selected.value!;
|
|
96
|
+
const key = `${t.deviceId}/${t.sessionId}/${t.agentId}`;
|
|
97
|
+
let saved: { key: string; content: string; mode: string; requestId: string } | undefined;
|
|
98
|
+
try {
|
|
99
|
+
saved = JSON.parse(sessionStorage.getItem("dpi.pending-send") ?? "null");
|
|
100
|
+
} catch {}
|
|
101
|
+
const requestId =
|
|
102
|
+
saved?.key === key && saved.content === content && saved.mode === mode.value
|
|
103
|
+
? saved.requestId
|
|
104
|
+
: newId();
|
|
105
|
+
sessionStorage.setItem(
|
|
106
|
+
"dpi.pending-send",
|
|
107
|
+
JSON.stringify({ key, content, mode: mode.value, requestId }),
|
|
108
|
+
);
|
|
109
|
+
await attempt(async () => {
|
|
110
|
+
await handle.send(content, mode.value, requestId);
|
|
111
|
+
sessionStorage.removeItem("dpi.pending-send");
|
|
112
|
+
ui.composer = "";
|
|
113
|
+
});
|
|
114
|
+
pending.value = false;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function withdraw(id: number) {
|
|
118
|
+
void attempt(() => agentHandle.value!.withdraw(id));
|
|
119
|
+
}
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<template>
|
|
123
|
+
<div class="composer-region">
|
|
124
|
+
<div v-if="agentState.inbox.length" class="queue">
|
|
125
|
+
<div v-for="item in agentState.inbox" :key="item.id">
|
|
126
|
+
<Clock3 :size="18" /><span
|
|
127
|
+
>{{ item.mode === "steer" ? "Steer" : "Queued" }}:
|
|
128
|
+
{{ item.content ?? "Context update" }}</span
|
|
129
|
+
><button
|
|
130
|
+
class="icon-button"
|
|
131
|
+
:aria-label="`Withdraw submission ${item.id}`"
|
|
132
|
+
title="Withdraw queued input"
|
|
133
|
+
@click="withdraw(item.id)"
|
|
134
|
+
>
|
|
135
|
+
<X :size="18" />
|
|
136
|
+
</button>
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
<div class="composer">
|
|
140
|
+
<ul v-if="matches.length" class="slash-menu" role="listbox" aria-label="Slash commands">
|
|
141
|
+
<li
|
|
142
|
+
v-for="(c, i) in matches"
|
|
143
|
+
:key="c.name"
|
|
144
|
+
role="option"
|
|
145
|
+
:aria-selected="i === menuIndex"
|
|
146
|
+
:class="{ active: i === menuIndex }"
|
|
147
|
+
@mousedown.prevent="pick(c)"
|
|
148
|
+
>
|
|
149
|
+
<code>/{{ c.name }}</code
|
|
150
|
+
><span v-if="c.args" class="slash-args">{{ c.args }}</span
|
|
151
|
+
><span class="slash-desc">{{ c.description }}</span>
|
|
152
|
+
</li>
|
|
153
|
+
</ul>
|
|
154
|
+
<textarea
|
|
155
|
+
v-model="ui.composer"
|
|
156
|
+
rows="2"
|
|
157
|
+
placeholder="Give your agent something to do, or type / for commands…"
|
|
158
|
+
aria-label="Message your agent"
|
|
159
|
+
@keydown="keydown"
|
|
160
|
+
/>
|
|
161
|
+
<div class="composer-toolbar">
|
|
162
|
+
<div class="composer-left">
|
|
163
|
+
<div class="queue-mode">
|
|
164
|
+
<select
|
|
165
|
+
v-model="mode"
|
|
166
|
+
aria-label="When busy"
|
|
167
|
+
title="Follow-up waits for this run. Steer joins after a tool round."
|
|
168
|
+
>
|
|
169
|
+
<option value="followUp">Follow-up</option>
|
|
170
|
+
<option value="steer">Steer</option>
|
|
171
|
+
<option value="reject">Reject if busy</option></select
|
|
172
|
+
><ChevronDown :size="24" aria-hidden="true" />
|
|
173
|
+
</div>
|
|
174
|
+
</div>
|
|
175
|
+
<div class="composer-right">
|
|
176
|
+
<button
|
|
177
|
+
class="interrupt"
|
|
178
|
+
:disabled="!busy || interrupting"
|
|
179
|
+
title="Stop foreground work and owned subagents (Escape). Background jobs continue."
|
|
180
|
+
@click="interrupt"
|
|
181
|
+
>
|
|
182
|
+
<Octagon :size="24" class="stop-sign" fill="currentColor" />Interrupt</button
|
|
183
|
+
><button
|
|
184
|
+
class="send"
|
|
185
|
+
aria-label="Send message"
|
|
186
|
+
:disabled="!ui.composer.trim() || pending || !canSend"
|
|
187
|
+
@click="send"
|
|
188
|
+
>
|
|
189
|
+
<ArrowUp :size="20" />
|
|
190
|
+
</button>
|
|
191
|
+
</div>
|
|
192
|
+
</div>
|
|
193
|
+
</div>
|
|
194
|
+
<div class="composer-footnote">
|
|
195
|
+
<span><i class="live-dot" />Closing this window never interrupts your agent.</span>
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
198
|
+
</template>
|