pi-web-ui 0.115.0 → 0.117.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/CHANGELOG.md +65 -2
- package/bin/device-hub-cli.mjs +26 -3
- package/bin/pi-web-ui.mjs +159 -71
- package/dist/server/agent-service-daemon.js +136 -8
- package/dist/server/agent-service.js +594 -159
- package/dist/server/canvas/canvas-workspace.js +18 -86
- package/dist/server/client-state.js +52 -8
- package/dist/server/compaction-markers.js +43 -24
- package/dist/server/dangling-tools.js +172 -16
- package/dist/server/device-center/bot-execution.js +77 -2
- package/dist/server/device-center/collab-service.js +61 -12
- package/dist/server/device-center/collab-tool.js +482 -21
- package/dist/server/device-center/connector.js +107 -37
- package/dist/server/device-center/delivery-authority.js +98 -0
- package/dist/server/device-center/delivery-subject.js +30 -0
- package/dist/server/device-center/device-integration.js +453 -183
- package/dist/server/device-center/execution-guides.js +17 -7
- package/dist/server/device-center/execution-instructions.js +2 -1
- package/dist/server/device-center/execution-settings.js +138 -25
- package/dist/server/device-center/executor.js +51 -6
- package/dist/server/device-center/file-sync.js +14 -13
- package/dist/server/device-center/group-context-message.js +3 -1
- package/dist/server/device-center/group-context.js +73 -3
- package/dist/server/device-center/hub-conversations.js +71 -6
- package/dist/server/device-center/hub-deliveries.js +120 -15
- package/dist/server/device-center/hub-integration.js +655 -334
- package/dist/server/device-center/hub-locks.js +320 -0
- package/dist/server/device-center/hub-page.js +16 -35
- package/dist/server/device-center/hub-setup.js +23 -1
- package/dist/server/device-center/hub-transaction-log.js +197 -0
- package/dist/server/device-center/hub-webhooks.js +165 -0
- package/dist/server/device-center/hub.js +1531 -305
- package/dist/server/device-center/integration-verification.js +113 -0
- package/dist/server/device-center/local-hub.js +8 -3
- package/dist/server/device-center/local-publication.js +423 -0
- package/dist/server/device-center/local-verification-job.js +97 -0
- package/dist/server/device-center/local-verification.js +274 -0
- package/dist/server/device-center/local.js +181 -13
- package/dist/server/device-center/main.js +4 -1
- package/dist/server/device-center/partition-log.js +330 -0
- package/dist/server/device-center/publication-journal.js +312 -0
- package/dist/server/device-center/publish-intent.js +379 -0
- package/dist/server/device-center/relay.js +134 -24
- package/dist/server/device-center/runtime.js +475 -42
- package/dist/server/device-center/store.js +366 -89
- package/dist/server/device-center/task-outcome.js +81 -0
- package/dist/server/device-center/task-recovery.js +603 -178
- package/dist/server/device-center/task-scheduler.js +48 -3
- package/dist/server/device-center/task-settlement.js +353 -0
- package/dist/server/device-center/task-workspace.js +443 -0
- package/dist/server/device-center/transfers.js +41 -15
- package/dist/server/device-center/verification-limits.js +10 -0
- package/dist/server/device-center/work-contract.js +995 -0
- package/dist/server/dispatch-domain-handlers.js +29 -3
- package/dist/server/dsh/dsh-agent-service.js +9 -2
- package/dist/server/engine-probe.js +112 -1
- package/dist/server/global-loader.js +119 -19
- package/dist/server/index.js +159 -17
- package/dist/server/managed.js +2 -0
- package/dist/server/model-admin.js +48 -6
- package/dist/server/model-enrich.js +10 -1
- package/dist/server/patch-node-pty.js +3 -2
- package/dist/server/patch-remote-catalog.js +3 -2
- package/dist/server/plugins.js +64 -7
- package/dist/server/preset-fields.js +17 -1
- package/dist/server/preset-share.js +1 -0
- package/dist/server/prompt-composer.js +39 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/quick-ask-settings.js +28 -0
- package/dist/server/quick-ask.js +164 -0
- package/dist/server/reasoning-registry.js +207 -0
- package/dist/server/resolve-global-sdk.js +61 -11
- package/dist/server/scheduler-tasks.js +35 -8
- package/dist/server/session-list-scan.js +223 -0
- package/dist/server/session-open.js +93 -0
- package/dist/server/session-parser.js +4 -0
- package/dist/server/session-scan.js +90 -38
- package/dist/server/settings-service.js +9 -1
- package/dist/server/soft-cap.js +5 -0
- package/dist/server/startup-banner.js +35 -0
- package/dist/server/subagents.js +2 -1
- package/dist/server/tool-manager.js +17 -9
- package/dist/server/transcript-prepare.js +73 -0
- package/dist/server/unauthorized-page.js +319 -0
- package/dist/server/universal/drivers/claude-code.js +98 -34
- package/dist/server/universal/universal-session.js +4 -0
- package/dist/server/workspace-handle.js +428 -0
- package/docs/architecture-plugins.md +959 -0
- package/docs/device-center.md +34 -20
- package/package.json +4 -4
- package/plugin-sdk/README.md +16 -8
- package/plugin-sdk/client.d.ts +27 -0
- package/plugin-sdk/client.mjs +82 -0
- package/plugin-sdk/index.d.ts +10 -0
- package/plugin-sdk/index.mjs +4 -683
- package/plugin-sdk/package.json +15 -4
- package/plugin-sdk/testing.d.ts +10 -0
- package/plugin-sdk/testing.mjs +566 -0
- package/themes/flow-cristallo.css +168 -0
- package/themes/flow-ink.css +169 -0
- package/themes/flow-obsidian.css +169 -0
- package/themes/flow-zurich.css +169 -0
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/{BgTasksModal-BYzPgmoq.js → BgTasksModal-BjNRIUIc.js} +1 -1
- package/web/dist/assets/{BgTasksModal-ni0VTmAQ.js → BgTasksModal-C0zuU8FE.js} +1 -1
- package/web/dist/assets/{CanvasStudio-DNmDNBod.js → CanvasStudio-BWvdmJ0M.js} +3 -3
- package/web/dist/assets/{CanvasStudio-BCUeEf25.js → CanvasStudio-VQFjmTGq.js} +3 -3
- package/web/dist/assets/DeviceCenter-DI9_0aBB.js +3 -0
- package/web/dist/assets/DeviceCenter-DsNtXqzY.js +3 -0
- package/web/dist/assets/DeviceExecutionSettings-BLP1Su5G.js +1 -0
- package/web/dist/assets/DeviceGroups-2Pvk0Cds.js +1 -0
- package/web/dist/assets/DeviceGroups-CP7CcyPD.js +1 -0
- package/web/dist/assets/{Dropdown-CGXD0DfT.js → Dropdown-CQtstPGv.js} +1 -1
- package/web/dist/assets/FilePreview-BMB2tNyT.js +2 -0
- package/web/dist/assets/FilePreview-RGFQUbJo.js +2 -0
- package/web/dist/assets/{GlobalSearchModal-mevF-ySi.js → GlobalSearchModal-BM5wxiqU.js} +1 -1
- package/web/dist/assets/{GlobalSearchModal-qL99FN_F.js → GlobalSearchModal-DGv_WINq.js} +1 -1
- package/web/dist/assets/GroupConversation-B7SnuXj1.js +61 -0
- package/web/dist/assets/GroupConversation-Dda69q-2.js +61 -0
- package/web/dist/assets/{HintTip-LHwkS2jV.js → HintTip-ChTW8o1m.js} +1 -1
- package/web/dist/assets/ModelConfigModal-C-0Z4hUZ.js +2 -0
- package/web/dist/assets/ModelConfigModal-yqeadyab.js +2 -0
- package/web/dist/assets/{PiSetupModal-DE5-gEtI.js → PiSetupModal-BX5rUuoI.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-6UMARucA.js → ProviderOAuthControls-DY4SCfXg.js} +1 -1
- package/web/dist/assets/SCMPanel-C4KbQvvK.js +2 -0
- package/web/dist/assets/SCMPanel-DPAyY2sW.js +2 -0
- package/web/dist/assets/SettingsModal-DxZp6D_g.js +32 -0
- package/web/dist/assets/SettingsModal-WhQzaOPt.js +32 -0
- package/web/dist/assets/{TerminalPanel-CTp_BZ4S.js → TerminalPanel-D4By_RVc.js} +2 -2
- package/web/dist/assets/{TerminalPanel-CkYxC-Gh.js → TerminalPanel-lZw8-i3j.js} +2 -2
- package/web/dist/assets/{TuiOverlayModal-1cRLP8IF.js → TuiOverlayModal-C3pAVuC8.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-2xlptqWX.js → TuiOverlayModal-D7_rEXcJ.js} +1 -1
- package/web/dist/assets/app-globals-KqOVtmp1.js +123 -0
- package/web/dist/assets/{canvas-client-Bye9nSFO.js → canvas-client-BY6ojmle.js} +1 -1
- package/web/dist/assets/{desktop-kjBoE3Nu.js → desktop-CV6KKp9R.js} +1 -1
- package/web/dist/assets/index-BawF7ZP5.js +397 -0
- package/web/dist/assets/index-BoGCoq5X.js +397 -0
- package/web/dist/assets/index-CVW9FoY2.css +1 -0
- package/web/dist/assets/{plugin-host-C8mNgghx.js → plugin-host-Dn8Dd6SC.js} +1 -1
- package/web/dist/assets/{remote-ssh-client-CeP3CLUW.js → remote-ssh-client-Dzi-eEyE.js} +1 -1
- package/web/dist/assets/{theme-BXGpyTMh.js → theme-D_bihpdN.js} +1 -1
- package/web/dist/index.html +11 -11
- package/web/dist/sw.js +1 -1
- package/dist/server/patch-turn-end-boundary.js +0 -77
- package/web/dist/assets/DeviceCenter-BcBhRgL6.js +0 -3
- package/web/dist/assets/DeviceCenter-CmL5FZmt.js +0 -3
- package/web/dist/assets/DeviceGroups-CLdpdnI7.js +0 -1
- package/web/dist/assets/DeviceGroups-CgBaDPrD.js +0 -1
- package/web/dist/assets/FilePreview-B8iqnBjy.js +0 -2
- package/web/dist/assets/FilePreview-BqviZKCN.js +0 -2
- package/web/dist/assets/GroupConversation-B88Yy-lt.js +0 -3
- package/web/dist/assets/GroupConversation-BwP5NVOE.js +0 -3
- package/web/dist/assets/ModelConfigModal-Do3Fe3jH.js +0 -2
- package/web/dist/assets/SCMPanel-Hi6QqC1Q.js +0 -2
- package/web/dist/assets/SCMPanel-ezY_ZtCu.js +0 -2
- package/web/dist/assets/SettingsModal-6HgeEsJ8.js +0 -20
- package/web/dist/assets/SettingsModal-CF-7MwqS.js +0 -20
- package/web/dist/assets/app-globals-DZNa9v8u.js +0 -325
- package/web/dist/assets/index-CsFs_HMb.css +0 -1
- package/web/dist/assets/index-DHeeHS_l.js +0 -85
- package/web/dist/assets/index-DTZch8uz.js +0 -85
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { isTrustedTaskWorkspaceCapability, resolveTrustedTaskWorkspace, } from "./task-workspace.js";
|
|
2
3
|
import { isAbsolute, resolve } from "node:path";
|
|
3
4
|
import { getBotExecutionInstructions } from "./execution-instructions.js";
|
|
4
5
|
import { checkGroupTaskPlanGuard, isGroupToolForbiddenInPlanCatalog } from "./group-plan-guard.js";
|
|
@@ -7,6 +8,9 @@ const bindings = new Map();
|
|
|
7
8
|
const interactionReplies = new Map();
|
|
8
9
|
// Advisory only: these tools can create execution contexts or mutate host policy.
|
|
9
10
|
const highPrivilegeTools = new Set([
|
|
11
|
+
"bash",
|
|
12
|
+
"powershell",
|
|
13
|
+
"terminal",
|
|
10
14
|
"conversation",
|
|
11
15
|
"subagent",
|
|
12
16
|
"worktree",
|
|
@@ -27,14 +31,46 @@ const highPrivilegeTools = new Set([
|
|
|
27
31
|
export function isBotToolHighPrivilege(name) {
|
|
28
32
|
return highPrivilegeTools.has(name) || name.startsWith("subagent_") || name.startsWith("team_");
|
|
29
33
|
}
|
|
34
|
+
/** Compute tools that must be stripped due to capability attenuation when a task is dispatched cross-bot. */
|
|
35
|
+
export function computeAttenuatedTools(sourceTools, targetTools) {
|
|
36
|
+
const sourceSet = new Set(sourceTools);
|
|
37
|
+
return targetTools.filter((tool) => isBotToolHighPrivilege(tool) && !sourceSet.has(tool));
|
|
38
|
+
}
|
|
30
39
|
export function registerBotExecution(bot, authorizedResumePath, context) {
|
|
31
40
|
if (!bot?.enabled || !bot.id || !isAbsolute(bot.cwd) || !Number.isSafeInteger(bot.revision)) {
|
|
32
41
|
throw new Error("An enabled, versioned local Bot with an absolute cwd is required");
|
|
33
42
|
}
|
|
34
43
|
if (authorizedResumePath !== undefined && !isAbsolute(authorizedResumePath))
|
|
35
44
|
throw new Error("Resume path must be absolute");
|
|
45
|
+
if (context?.executionMode === "code" && authorizedResumePath) {
|
|
46
|
+
throw new Error("Code execution mode refuses resuming old sessions in first slice");
|
|
47
|
+
}
|
|
48
|
+
if (context?.executionCwd !== undefined && !isAbsolute(context.executionCwd)) {
|
|
49
|
+
throw new Error("Execution cwd must be absolute");
|
|
50
|
+
}
|
|
36
51
|
const snapshot = structuredClone(bot);
|
|
37
52
|
snapshot.cwd = resolve(snapshot.cwd);
|
|
53
|
+
const executionCwd = context?.executionCwd ? resolve(context.executionCwd) : snapshot.cwd;
|
|
54
|
+
const code = context?.executionMode === "code";
|
|
55
|
+
const workspace = context?.workspaceCapability;
|
|
56
|
+
const workspaceBinding = Object.freeze({
|
|
57
|
+
deviceId: context?.deviceId ?? "",
|
|
58
|
+
botId: snapshot.id,
|
|
59
|
+
botRevision: snapshot.revision,
|
|
60
|
+
taskId: context?.taskId ?? "",
|
|
61
|
+
attemptId: context?.attemptId ?? "",
|
|
62
|
+
});
|
|
63
|
+
if (code) {
|
|
64
|
+
if (!isTrustedTaskWorkspaceCapability(workspace) ||
|
|
65
|
+
!workspaceBinding.deviceId ||
|
|
66
|
+
!workspaceBinding.taskId ||
|
|
67
|
+
!workspaceBinding.attemptId ||
|
|
68
|
+
workspace.handleId !== context?.workspaceHandleId)
|
|
69
|
+
throw new Error("Code execution requires a trusted task workspace capability");
|
|
70
|
+
}
|
|
71
|
+
else if (executionCwd !== snapshot.cwd || context?.workspaceHandleId || workspace) {
|
|
72
|
+
throw new Error("Chat execution cwd must match the Bot project");
|
|
73
|
+
}
|
|
38
74
|
Object.freeze(snapshot.tools);
|
|
39
75
|
Object.freeze(snapshot.skills);
|
|
40
76
|
Object.freeze(snapshot.mcpServers);
|
|
@@ -53,31 +89,69 @@ export function registerBotExecution(bot, authorizedResumePath, context) {
|
|
|
53
89
|
}
|
|
54
90
|
Object.freeze(groupContext.members);
|
|
55
91
|
Object.freeze(groupContext.messages);
|
|
92
|
+
if (groupContext.blackboard) {
|
|
93
|
+
Object.freeze(groupContext.blackboard.updatedBy);
|
|
94
|
+
Object.freeze(groupContext.blackboard);
|
|
95
|
+
}
|
|
56
96
|
Object.freeze(groupContext);
|
|
57
97
|
}
|
|
58
98
|
let active = true;
|
|
59
99
|
let model = snapshot.model;
|
|
60
100
|
const tools = new Set(snapshot.tools);
|
|
61
101
|
const skills = new Set(snapshot.skills);
|
|
102
|
+
const attenuatedList = context?.attenuatedTools ? Array.from(new Set(context.attenuatedTools)) : undefined;
|
|
103
|
+
const attenuatedSet = attenuatedList && attenuatedList.length > 0 ? new Set(attenuatedList) : undefined;
|
|
104
|
+
const sourceBotLabel = context?.sourceBotId ?? "unknown";
|
|
105
|
+
const attenuationWarning = attenuatedList && attenuatedList.length > 0
|
|
106
|
+
? `\n\n[SECURITY ATTENUATION] This task originated from bot '${sourceBotLabel}' without privileges for [${attenuatedList.join(", ")}]. Those tools have been strictly disabled for this execution.`
|
|
107
|
+
: "";
|
|
108
|
+
const blackboardBlock = context?.groupContext?.blackboard
|
|
109
|
+
? `\n\n[GROUP BLACKBOARD v${context.groupContext.blackboard.version}]${context.groupContext.blackboard.title ? ` ${context.groupContext.blackboard.title}` : ""}\n${context.groupContext.blackboard.content}`
|
|
110
|
+
: "";
|
|
62
111
|
const capability = {
|
|
63
112
|
bot: snapshot,
|
|
64
113
|
instructions: getBotExecutionInstructions(context?.primary === true) +
|
|
65
114
|
(context?.planOnly
|
|
66
115
|
? "\n\n[PLAN MODE HARD ENFORCEMENT]\nThis task is strictly PLAN ONLY. You are prohibited from mutating files, creating files, running state-changing terminal commands, or dispatching tasks. You must only read, inspect, and draft an executable plan via plan_update. Provide 1–32 steps with unique IDs, nonempty titles (max 200 characters), explicit pending/in_progress/done/failed status, and optional descriptions (max 1000 characters)."
|
|
67
|
-
: "")
|
|
116
|
+
: "") +
|
|
117
|
+
attenuationWarning +
|
|
118
|
+
blackboardBlock,
|
|
68
119
|
groupContext,
|
|
69
120
|
authorizedResumePath,
|
|
70
121
|
planOnly: context?.planOnly === true,
|
|
122
|
+
attenuatedTools: attenuatedList ? Object.freeze([...attenuatedList]) : undefined,
|
|
123
|
+
executionCwd,
|
|
124
|
+
executionMode: context?.executionMode ?? "chat",
|
|
125
|
+
workspaceHandleId: context?.workspaceHandleId,
|
|
126
|
+
taskId: context?.taskId,
|
|
127
|
+
attemptId: context?.attemptId,
|
|
71
128
|
assertActive() {
|
|
72
129
|
if (!active)
|
|
73
130
|
throw new Error("Bot execution capability has been revoked");
|
|
131
|
+
if (code && !isTrustedTaskWorkspaceCapability(workspace))
|
|
132
|
+
throw new Error("Task workspace capability has expired");
|
|
133
|
+
},
|
|
134
|
+
async assertWorkspace(cwd = executionCwd) {
|
|
135
|
+
this.assertActive();
|
|
136
|
+
if (resolve(cwd) !== executionCwd)
|
|
137
|
+
throw new Error("Bot execution cwd mismatch");
|
|
138
|
+
if (code) {
|
|
139
|
+
const actual = await resolveTrustedTaskWorkspace(workspace, workspaceBinding);
|
|
140
|
+
this.assertActive();
|
|
141
|
+
if (resolve(actual.cwd) !== executionCwd || resolve(actual.repoRoot) !== snapshot.cwd)
|
|
142
|
+
throw new Error("Task workspace identity mismatch");
|
|
143
|
+
}
|
|
74
144
|
},
|
|
75
145
|
allowsToolRegistration(name) {
|
|
146
|
+
if (attenuatedSet?.has(name))
|
|
147
|
+
return false;
|
|
76
148
|
return active && tools.has(name) && !isGroupToolForbiddenInPlanCatalog(name, context?.planOnly === true);
|
|
77
149
|
},
|
|
78
150
|
allowsTool(name, params) {
|
|
79
151
|
if (!active)
|
|
80
152
|
return false;
|
|
153
|
+
if (attenuatedSet?.has(name))
|
|
154
|
+
return false;
|
|
81
155
|
if (context?.planOnly) {
|
|
82
156
|
if (name === "plan_update")
|
|
83
157
|
return tools.has(name) && !checkGroupTaskPlanGuard(name, params, true);
|
|
@@ -160,7 +234,8 @@ export function botExecutionMessageAllowed(clientId, type, message) {
|
|
|
160
234
|
return true;
|
|
161
235
|
}
|
|
162
236
|
if (type === "switch_session")
|
|
163
|
-
return (
|
|
237
|
+
return (capability.executionMode !== "code" &&
|
|
238
|
+
!!capability.authorizedResumePath &&
|
|
164
239
|
!!message &&
|
|
165
240
|
typeof message === "object" &&
|
|
166
241
|
"path" in message &&
|
|
@@ -16,7 +16,15 @@ export function createDeviceCollabService(options) {
|
|
|
16
16
|
throw new Error("Invalid workspace");
|
|
17
17
|
const bound = options.getExecutionContext?.(context);
|
|
18
18
|
// Resolve authority before workspace acquisition; never mutate caller arguments.
|
|
19
|
-
if ([
|
|
19
|
+
if ([
|
|
20
|
+
"task_state",
|
|
21
|
+
"task_update",
|
|
22
|
+
"task_evidence",
|
|
23
|
+
"execution_guide",
|
|
24
|
+
"context_metrics",
|
|
25
|
+
"blackboard_read",
|
|
26
|
+
"blackboard_update",
|
|
27
|
+
].includes(action))
|
|
20
28
|
validateDeviceCollabInput({ ...args, action });
|
|
21
29
|
args = { ...args };
|
|
22
30
|
const boundBot = bound?.botId ?? options.getSourceBot?.(context);
|
|
@@ -29,12 +37,16 @@ export function createDeviceCollabService(options) {
|
|
|
29
37
|
throw new Error("Parent task spoofing denied");
|
|
30
38
|
args.sourceBotId ??= bound?.botId;
|
|
31
39
|
args.roomId ??= bound?.roomId;
|
|
40
|
+
if (args.executionMode !== undefined || args.contract !== undefined)
|
|
41
|
+
validateDeviceCollabInput({ ...args, action });
|
|
32
42
|
if (action === "conversation_attention" ||
|
|
33
43
|
action === "conversation_deliver" ||
|
|
34
44
|
action === "task_state" ||
|
|
35
45
|
action === "task_update" ||
|
|
36
46
|
action === "task_evidence")
|
|
37
47
|
args.conversationId ??= bound?.conversationId;
|
|
48
|
+
if (action === "conversation_deliver" || action === "conversation_review")
|
|
49
|
+
validateDeviceCollabInput({ ...args, action });
|
|
38
50
|
if (action === "reply_to_request") {
|
|
39
51
|
if (!bound || bound.kind !== "request" || !bound.sourceConversationId || !bound.requestId)
|
|
40
52
|
throw new Error("Incoming request binding required");
|
|
@@ -113,14 +125,14 @@ export function createDeviceCollabService(options) {
|
|
|
113
125
|
if (resolve(context.cwd) !== resolve(workspace.root))
|
|
114
126
|
throw new Error("Invalid workspace");
|
|
115
127
|
}
|
|
116
|
-
const request = async (path, body, query) => {
|
|
128
|
+
const request = async (path, body, query, method) => {
|
|
117
129
|
signal?.throwIfAborted();
|
|
118
130
|
const url = new URL(base.href);
|
|
119
131
|
url.pathname = `${url.pathname.replace(/\/$/, "")}/api/agent/${path}`;
|
|
120
132
|
if (query)
|
|
121
133
|
url.search = query.toString();
|
|
122
134
|
const response = await (options.fetch ?? fetch)(url, {
|
|
123
|
-
method: body === undefined ? "GET" : "POST",
|
|
135
|
+
method: method ?? (body === undefined ? "GET" : "POST"),
|
|
124
136
|
headers: {
|
|
125
137
|
authorization: `Bearer ${config.credential}`,
|
|
126
138
|
"X-Device-Id": config.deviceId,
|
|
@@ -130,8 +142,17 @@ export function createDeviceCollabService(options) {
|
|
|
130
142
|
signal,
|
|
131
143
|
redirect: "error",
|
|
132
144
|
});
|
|
133
|
-
if (!response.ok)
|
|
134
|
-
|
|
145
|
+
if (!response.ok) {
|
|
146
|
+
let detail = "";
|
|
147
|
+
try {
|
|
148
|
+
const errBody = (await response.json());
|
|
149
|
+
detail = errBody?.error ? `: ${errBody.error}` : "";
|
|
150
|
+
}
|
|
151
|
+
catch { }
|
|
152
|
+
throw Object.assign(new Error(`Hub request failed (${response.status}${detail})`), {
|
|
153
|
+
status: response.status,
|
|
154
|
+
});
|
|
155
|
+
}
|
|
135
156
|
const result = await response.json();
|
|
136
157
|
signal?.throwIfAborted();
|
|
137
158
|
return result;
|
|
@@ -180,6 +201,8 @@ export function createDeviceCollabService(options) {
|
|
|
180
201
|
query.set("limit", String(args.limit));
|
|
181
202
|
if (args.expectedDigest !== undefined)
|
|
182
203
|
query.set("expectedDigest", args.expectedDigest);
|
|
204
|
+
if (args.evidenceKind !== undefined)
|
|
205
|
+
query.set("evidenceKind", args.evidenceKind);
|
|
183
206
|
return await request(path, undefined, query);
|
|
184
207
|
}
|
|
185
208
|
case "list_bots": {
|
|
@@ -188,6 +211,21 @@ export function createDeviceCollabService(options) {
|
|
|
188
211
|
}
|
|
189
212
|
case "list_rooms":
|
|
190
213
|
return await request("rooms");
|
|
214
|
+
case "blackboard_read": {
|
|
215
|
+
const query = new URLSearchParams({ sourceBotId: args.sourceBotId });
|
|
216
|
+
return await request(`${room()}/blackboard`, undefined, query);
|
|
217
|
+
}
|
|
218
|
+
case "blackboard_update": {
|
|
219
|
+
const url = args.sectionId
|
|
220
|
+
? `${room()}/blackboard/sections/${encodeURIComponent(args.sectionId)}`
|
|
221
|
+
: `${room()}/blackboard`;
|
|
222
|
+
return await request(url, {
|
|
223
|
+
sourceBotId: args.sourceBotId,
|
|
224
|
+
content: args.content,
|
|
225
|
+
expectedVersion: args.expectedVersion,
|
|
226
|
+
...(args.title !== undefined ? { title: args.title } : {}),
|
|
227
|
+
}, undefined, "PUT");
|
|
228
|
+
}
|
|
191
229
|
case "read_history": {
|
|
192
230
|
if (args.before !== undefined &&
|
|
193
231
|
(typeof args.before !== "string" || !args.before.trim() || args.before.length > 256))
|
|
@@ -214,8 +252,11 @@ export function createDeviceCollabService(options) {
|
|
|
214
252
|
text: args.prompt,
|
|
215
253
|
sourceBotId: args.sourceBotId,
|
|
216
254
|
targetBotIds: [args.targetBotId],
|
|
217
|
-
idempotencyKey: randomUUID(),
|
|
255
|
+
idempotencyKey: args.idempotencyKey ?? randomUUID(),
|
|
256
|
+
...(args.executionMode ? { executionMode: args.executionMode } : {}),
|
|
257
|
+
...(args.contract ? { contract: args.contract } : {}),
|
|
218
258
|
...(parentTaskId ? { parentTaskId } : {}),
|
|
259
|
+
...(args.resourceLocks?.length ? { resourceLocks: args.resourceLocks } : {}),
|
|
219
260
|
});
|
|
220
261
|
case "conversation_list":
|
|
221
262
|
case "conversation_read": {
|
|
@@ -233,22 +274,21 @@ export function createDeviceCollabService(options) {
|
|
|
233
274
|
case "conversation_deliver": {
|
|
234
275
|
if (!args.conversationId ||
|
|
235
276
|
!parentTaskId ||
|
|
236
|
-
!args.repository ||
|
|
237
|
-
!args.baseCommit ||
|
|
238
|
-
!args.commit ||
|
|
239
277
|
!args.summary ||
|
|
240
|
-
!
|
|
278
|
+
(!args.artifactTaskId &&
|
|
279
|
+
(!args.repository || !args.baseCommit || !args.commit || !Array.isArray(args.checks))))
|
|
241
280
|
throw new Error("Delivery fields required");
|
|
242
281
|
const body = {
|
|
243
282
|
sourceBotId: args.sourceBotId,
|
|
244
283
|
parentTaskId,
|
|
245
284
|
idempotencyKey: args.idempotencyKey ?? randomUUID(),
|
|
285
|
+
artifactTaskId: args.artifactTaskId,
|
|
246
286
|
repository: args.repository,
|
|
247
287
|
baseCommit: args.baseCommit,
|
|
248
288
|
commit: args.commit,
|
|
249
289
|
branch: args.branch,
|
|
250
290
|
summary: args.summary,
|
|
251
|
-
checks: args.checks,
|
|
291
|
+
checks: args.checks ?? [],
|
|
252
292
|
limitations: args.limitations ?? [],
|
|
253
293
|
};
|
|
254
294
|
return await request(`${room()}/conversations/${encodeURIComponent(args.conversationId)}/deliveries`, body);
|
|
@@ -257,7 +297,7 @@ export function createDeviceCollabService(options) {
|
|
|
257
297
|
if (!args.conversationId ||
|
|
258
298
|
!parentTaskId ||
|
|
259
299
|
!args.deliveryId ||
|
|
260
|
-
!args.commit ||
|
|
300
|
+
(!args.commit && !args.artifactDigest) ||
|
|
261
301
|
!args.summary ||
|
|
262
302
|
!args.verdict)
|
|
263
303
|
throw new Error("Review fields required");
|
|
@@ -267,6 +307,10 @@ export function createDeviceCollabService(options) {
|
|
|
267
307
|
idempotencyKey: args.idempotencyKey ?? randomUUID(),
|
|
268
308
|
deliveryId: args.deliveryId,
|
|
269
309
|
commit: args.commit,
|
|
310
|
+
artifactDigest: args.artifactDigest,
|
|
311
|
+
integrationId: args.integrationId,
|
|
312
|
+
verificationDigest: args.verificationDigest,
|
|
313
|
+
criteriaResults: args.criteriaResults,
|
|
270
314
|
verdict: args.verdict,
|
|
271
315
|
summary: args.summary,
|
|
272
316
|
};
|
|
@@ -299,6 +343,8 @@ export function createDeviceCollabService(options) {
|
|
|
299
343
|
return await request(`${room()}/conversations`, {
|
|
300
344
|
targetBotId: args.targetBotId,
|
|
301
345
|
text: args.prompt,
|
|
346
|
+
...(args.executionMode ? { executionMode: args.executionMode } : {}),
|
|
347
|
+
...(args.contract ? { contract: args.contract } : {}),
|
|
302
348
|
...(args.kind ? { kind: args.kind } : {}),
|
|
303
349
|
...(args.requestId ? { requestId: args.requestId } : {}),
|
|
304
350
|
sourceBotId: args.sourceBotId,
|
|
@@ -313,11 +359,14 @@ export function createDeviceCollabService(options) {
|
|
|
313
359
|
throw new Error("Conversation fields required");
|
|
314
360
|
return await request(`${room()}/conversations/${encodeURIComponent(args.conversationId)}/messages`, {
|
|
315
361
|
text: args.message,
|
|
362
|
+
...(args.executionMode ? { executionMode: args.executionMode } : {}),
|
|
363
|
+
...(args.contract ? { contract: args.contract } : {}),
|
|
316
364
|
sourceBotId: args.sourceBotId,
|
|
317
365
|
parentTaskId,
|
|
318
366
|
kind: args.kind ?? "message",
|
|
319
367
|
requestId: args.requestId,
|
|
320
368
|
idempotencyKey: args.idempotencyKey ?? randomUUID(),
|
|
369
|
+
...(args.resourceLocks?.length ? { resourceLocks: args.resourceLocks } : {}),
|
|
321
370
|
});
|
|
322
371
|
case "sync_files": {
|
|
323
372
|
if (!args.targetBotId || !args.roomId || !args.sourceBotId || !args.paths?.length)
|