@1agents/acp-service 0.5.1 → 0.5.3
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/package.json +2 -1
- package/vendor/dsh/README.md +3 -3
- package/vendor/dsh/adapter.d.ts +2 -0
- package/vendor/dsh/adapter.js +18 -5
- package/vendor/dsh/client.js +30 -52
- package/vendor/dsh/imports.d.ts +4 -2
- package/vendor/dsh/imports.js +16 -7
- package/vendor/dsh/state.d.ts +4 -1
- package/vendor/dsh/state.js +9 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1agents/acp-service",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "ACP runtime, CLI, HTTP/WebSocket service and DeepSeek Harness plugin in one package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dreammate",
|
|
@@ -100,6 +100,7 @@
|
|
|
100
100
|
"@deepseek-ai/dsh-client-ui-commands",
|
|
101
101
|
"@deepseek-ai/dsh-client-ui-conversation",
|
|
102
102
|
"@deepseek-ai/dsh-client-ui-chat",
|
|
103
|
+
"@deepseek-ai/dsh-client-ui-tool",
|
|
103
104
|
"@deepseek-ai/dsh-client-locale",
|
|
104
105
|
"@deepseek-ai/dsh-api-remotes"
|
|
105
106
|
]
|
package/vendor/dsh/README.md
CHANGED
|
@@ -26,7 +26,7 @@ The service requires each native Agent’s CLI and credentials. Installing the p
|
|
|
26
26
|
|
|
27
27
|
Choose a discovered **ACP · Agent** in the new-session Agent preset picker, choose a workspace, then send a message. ACP routes are not listed as ordinary DSH models, and the adapter rejects requests from ordinary presets, including previously saved ACP routes. Before the first turn, switching the Agent preset replaces the discovery connection and its native commands. Once a turn starts, the session keeps its remote Agent and workspace; start a new session to change Agent. Native Agent binaries and authentication belong to acp-service.
|
|
28
28
|
|
|
29
|
-
The bundle registers an ACP adapter through DSH's public streaming extension and routes the ACP presets to it. It sends newly admitted messages whose source is `user` to `session/prompt`, not to `subagent-acp`; there is no coordinating DeepSeek model call. DSH-generated workspace instructions and runtime-context messages are excluded. The external Agent owns its model, prompt, tools and native history, including any project instructions it discovers itself. DSH owns its UI and local user/assistant transcript. External tool progress is preserved as display metadata on empty text blocks in DSH's existing assistant stream records and projected onto
|
|
29
|
+
The bundle registers an ACP adapter through DSH's public streaming extension and routes the ACP presets to it. It sends newly admitted messages whose source is `user` to `session/prompt`, not to `subagent-acp`; there is no coordinating DeepSeek model call. DSH-generated workspace instructions and runtime-context messages are excluded. The external Agent owns its model, prompt, tools and native history, including any project instructions it discovers itself. DSH owns its UI and local user/assistant transcript. External tool progress is preserved as display metadata on empty text blocks in DSH's existing assistant stream records and projected onto native tool cards with completed-turn disclosure. ACP updates retain previously supplied fields, and replay is deduplicated by the managed turn sequence. These snapshots contain no visible text and never dispatch local tools; they use the existing persisted session format so conversations can reopen normally. Only Agent thought chunks enter the thinking stream.
|
|
30
30
|
|
|
31
31
|
## Continue imported native sessions
|
|
32
32
|
|
|
@@ -34,14 +34,14 @@ With `@1agents/session-reader` installed, choose **在 DSH 中继续原会话**
|
|
|
34
34
|
|
|
35
35
|
Imported bindings use `session/resume` because the service does not own a complete ACP replay of earlier native history. Existing ordinary ACP bindings continue using `session/load`. Endpoint, source provider and native ID identify an import; repeated admission reuses its DSH session without refreshing or replacing history. Old history-only DSH copies are not adopted. Original Agent history can continue changing outside DSH; the imported DSH history is a snapshot.
|
|
36
36
|
|
|
37
|
-
The service ID is saved before DSH creation. A failed local creation or workspace attachment can be retried after restart without importing again.
|
|
37
|
+
The service ID is saved before DSH creation. A failed local creation or workspace attachment can be retried after restart without importing again. When the original session reports `already has an active writer`, DSH still creates and opens its historical session. The composer is disabled with an explanation; capability refresh retries the original identity and restores input after its writer releases it. A pending import survives plugin restart. Other native restoration and authentication failures are reported, never replaced by a new empty session. If the transport is lost before the import response reaches the plugin, the plugin cannot know the service ID and does not automatically retry that RPC.
|
|
38
38
|
|
|
39
39
|
### Plugin service API
|
|
40
40
|
|
|
41
41
|
`ctx.oneagentsAcpSessions` is a Cordis service owned by this plugin; consumers may declare it optional so history browsing works without ACP. Its TypeScript declarations are exported from `@1agents/acp-service/dsh/imports`. Consumers call the service from the Host and must not instantiate it or write its binding files.
|
|
42
42
|
|
|
43
43
|
- `availability(provider)` returns `{ available, agent?, reason? }` without restoring a session. It checks configuration and the service inventory; successful native restoration remains the final capability/authentication check.
|
|
44
|
-
- `importSession({ provider, nativeSessionId, cwd, events })` accepts current DSH events starting at sequence zero. It returns `{ success: true, dshSessionId, workspace, workspaceId, agent, continuation: 'native' }`
|
|
44
|
+
- `importSession({ provider, nativeSessionId, cwd, events })` accepts current DSH events starting at sequence zero. It returns `{ success: true, dshSessionId, workspace, workspaceId, agent, continuation: 'native', writable, blocked? }` after DSH creation and workspace attachment. An active native writer returns `writable: false, blocked: 'active-writer'` while leaving history available.
|
|
45
45
|
|
|
46
46
|
Provider mapping is `claude → claude`, `codex → codex`, `grok → grok-build`. The service validates history through DSH before restoring a new native binding. No DSH Session format changes are required.
|
|
47
47
|
|
package/vendor/dsh/adapter.d.ts
CHANGED
package/vendor/dsh/adapter.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { randomUUID } from 'node:crypto';
|
|
4
4
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
5
|
import { connect, object } from './transport.js';
|
|
6
|
-
import { State } from './state.js';
|
|
6
|
+
import { State, hasActiveWriter } from './state.js';
|
|
7
7
|
import { mergeTool } from './tool-events.js';
|
|
8
8
|
/** Producer/consumer queue; errors are delivered after already received chunks. */
|
|
9
9
|
class Queue {
|
|
@@ -82,10 +82,18 @@ export class AcpAdapter {
|
|
|
82
82
|
return this.config.agents.includes(name) ? name : undefined;
|
|
83
83
|
}
|
|
84
84
|
async describe(agent) {
|
|
85
|
-
|
|
85
|
+
const name = this.agentName(agent);
|
|
86
|
+
if (!name)
|
|
86
87
|
return null;
|
|
87
|
-
|
|
88
|
-
|
|
88
|
+
try {
|
|
89
|
+
await this.connection(agent);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
if (!this.state.get(agent.id)?.imported || !hasActiveWriter(error))
|
|
93
|
+
throw error;
|
|
94
|
+
return { agent: name, commands: [], configOptions: [], writable: false, blocked: 'active-writer' };
|
|
95
|
+
}
|
|
96
|
+
return { ...this.capabilities.get(agent.id), writable: true };
|
|
89
97
|
}
|
|
90
98
|
async configure(agent, configId, value) {
|
|
91
99
|
if (this.controllers.has(agent.id))
|
|
@@ -214,6 +222,11 @@ export class AcpAdapter {
|
|
|
214
222
|
const existing = this.links.get(agent.id);
|
|
215
223
|
if (existing)
|
|
216
224
|
return existing;
|
|
225
|
+
if (binding?.imported && !binding.sessionId) {
|
|
226
|
+
// Retry the original native identity after its writer releases it; never open an empty replacement.
|
|
227
|
+
binding = { ...await this.importNative(name, cwd, binding.imported.nativeSessionId), imported: binding.imported };
|
|
228
|
+
this.state.save(agent.id, binding);
|
|
229
|
+
}
|
|
217
230
|
const operation = (async () => {
|
|
218
231
|
if (!this.commandContexts.has(agent.id)) {
|
|
219
232
|
const fiber = await agent.ctx.inject(['commands'], scope => {
|
|
@@ -414,7 +427,7 @@ export class AcpAdapter {
|
|
|
414
427
|
}
|
|
415
428
|
};
|
|
416
429
|
let active;
|
|
417
|
-
const cancel = () => { if (binding)
|
|
430
|
+
const cancel = () => { if (binding?.sessionId)
|
|
418
431
|
void active?.rpc.notify('session/cancel', { sessionId: binding.sessionId }).catch(() => { }); };
|
|
419
432
|
signal.addEventListener('abort', cancel, { once: true });
|
|
420
433
|
try {
|
package/vendor/dsh/client.js
CHANGED
|
@@ -21,7 +21,6 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
// src/client.js
|
|
22
22
|
var client_exports = {};
|
|
23
23
|
__export(client_exports, {
|
|
24
|
-
AcpTools: () => AcpTools,
|
|
25
24
|
apply: () => apply,
|
|
26
25
|
choices: () => choices,
|
|
27
26
|
inject: () => inject
|
|
@@ -97,24 +96,29 @@ var toolConversationDefinition = {
|
|
|
97
96
|
const state = context.state;
|
|
98
97
|
if (!state) return null;
|
|
99
98
|
const location = context.start?.location ?? context.matches[0]?.location ?? { kind: "unresolved" };
|
|
99
|
+
const roots = [...state.tools.values()].map((tool) => rootOf(tool, location));
|
|
100
|
+
if (!roots.length) return null;
|
|
101
|
+
const [first, ...remaining] = roots;
|
|
100
102
|
return {
|
|
101
103
|
key: context.key,
|
|
102
104
|
id: context.id,
|
|
103
|
-
kind: "
|
|
105
|
+
kind: "tool-call",
|
|
104
106
|
target: "chat",
|
|
105
|
-
|
|
107
|
+
// Durable snapshots share the final answer event; anchor them before that
|
|
108
|
+
// answer so DSH retains the completed Turn's process disclosure.
|
|
109
|
+
anchorSeq: location.kind === "step" ? location.step.start?.seq ?? state.seq : state.seq,
|
|
106
110
|
location,
|
|
107
111
|
visibility: "visible",
|
|
108
|
-
data: {
|
|
112
|
+
data: { root: { ...first, subCalls: remaining } }
|
|
109
113
|
};
|
|
110
114
|
}
|
|
111
115
|
};
|
|
112
116
|
|
|
113
117
|
// src/client.js
|
|
114
|
-
var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation"];
|
|
118
|
+
var inject = ["slots", "sessions", "commandUi", "remote", "remote.session", "locale", "uiConversation", "conversation"];
|
|
115
119
|
var dictionaries = {
|
|
116
|
-
zh: {
|
|
117
|
-
en: {
|
|
120
|
+
zh: { model: "\u6A21\u578B", choose: "\u9009\u62E9\u6A21\u578B", loading: "\u6B63\u5728\u8FDE\u63A5 Agent\u2026", retry: "\u91CD\u8BD5", mode: "\u6A21\u5F0F", command: "Agent \u6307\u4EE4", effort: "\u601D\u8003\u5F3A\u5EA6", unsupported: "Agent \u672A\u63D0\u4F9B\u53EF\u5207\u6362\u7684\u6A21\u578B", description: "\u9009\u62E9\u5F53\u524D Agent \u7684\u6A21\u578B", error: "\u8FDE\u63A5\u5931\u8D25", noCommands: "Agent \u5C1A\u672A\u63D0\u4F9B\u6307\u4EE4", native: "ACP \u8BBE\u7F6E", activeWriter: "\u539F\u4F1A\u8BDD\u6B63\u5728\u5176\u4ED6\u5BA2\u6237\u7AEF\u8FD0\u884C\uFF0C\u53EF\u67E5\u770B\u5386\u53F2\uFF1B\u5360\u7528\u89E3\u9664\u540E\u81EA\u52A8\u6062\u590D\u8F93\u5165\u3002" },
|
|
121
|
+
en: { model: "Model", choose: "Select model", loading: "Connecting to Agent\u2026", retry: "Retry", mode: "Mode", command: "Agent commands", effort: "Reasoning effort", unsupported: "This Agent does not advertise model selection", description: "Select this Agent\u2019s model", error: "Connection failed", noCommands: "No commands advertised", native: "ACP settings", activeWriter: "The original session is running in another client. History is available; input resumes when it is released." }
|
|
118
122
|
};
|
|
119
123
|
function choices(option) {
|
|
120
124
|
return (option.options ?? []).flatMap((item) => "group" in item ? item.options.map((value) => ({ ...value, group: item.name ?? item.group })) : [item]);
|
|
@@ -142,68 +146,41 @@ function Select({ title, value, rows, disabled, onSelect, placeholder }) {
|
|
|
142
146
|
)
|
|
143
147
|
);
|
|
144
148
|
}
|
|
145
|
-
function AcpTools({ node, t }) {
|
|
146
|
-
return (0, import_react.createElement)("div", { "data-oneagents-acp-tools": "", style: { display: "grid", gap: 6 } }, node.data.roots.map((root) => {
|
|
147
|
-
const running = root.phase === "start";
|
|
148
|
-
const tool = running ? root : root.call;
|
|
149
|
-
const output = running ? [] : root.content;
|
|
150
|
-
const acp = root.meta?.acp;
|
|
151
|
-
let args;
|
|
152
|
-
try {
|
|
153
|
-
args = JSON.parse(tool.argsRaw);
|
|
154
|
-
} catch {
|
|
155
|
-
args = tool.argsRaw;
|
|
156
|
-
}
|
|
157
|
-
const input = args?.command ?? args?.path ?? args?.file_path ?? acp?.title ?? tool.argsRaw;
|
|
158
|
-
const state = running ? "running" : root.isError ? "failed" : "completed";
|
|
159
|
-
const labels = { running: t("toolRunning"), failed: t("toolFailed"), completed: t("toolCompleted"), noOutput: t("toolNoOutput") };
|
|
160
|
-
return (0, import_react.createElement)(
|
|
161
|
-
"details",
|
|
162
|
-
{
|
|
163
|
-
key: root.callId,
|
|
164
|
-
"data-acp-call": root.callId,
|
|
165
|
-
"data-acp-status": state,
|
|
166
|
-
style: { border: "1px solid var(--dsw-alias-border-l1, #8883)", borderRadius: 8, padding: "7px 10px" }
|
|
167
|
-
},
|
|
168
|
-
(0, import_react.createElement)(
|
|
169
|
-
"summary",
|
|
170
|
-
{ style: { cursor: "pointer", fontSize: 13 } },
|
|
171
|
-
(0, import_react.createElement)("strong", null, tool.name),
|
|
172
|
-
" ",
|
|
173
|
-
(0, import_react.createElement)("span", { style: { opacity: 0.65 } }, labels[state]),
|
|
174
|
-
(0, import_react.createElement)("code", { style: { display: "block", whiteSpace: "pre-wrap", overflowWrap: "anywhere", marginTop: 4 } }, typeof input === "string" ? input : JSON.stringify(input))
|
|
175
|
-
),
|
|
176
|
-
(0, import_react.createElement)(
|
|
177
|
-
"pre",
|
|
178
|
-
{ style: { whiteSpace: "pre-wrap", overflowWrap: "anywhere", maxHeight: 360, overflow: "auto", fontSize: 12 } },
|
|
179
|
-
output.length ? output.map((block) => block.text ?? "").join("\n") : running ? labels.running : labels.noOutput
|
|
180
|
-
)
|
|
181
|
-
);
|
|
182
|
-
}));
|
|
183
|
-
}
|
|
184
149
|
function apply(ctx) {
|
|
185
150
|
ctx.uiConversation.events.register(toolConversationDefinition);
|
|
186
|
-
ctx.slots.inject("conversation.chat.node", () => ctx.slots.register({
|
|
187
|
-
name: "conversation.chat.node",
|
|
188
|
-
key: "oneagents-acp-tools",
|
|
189
|
-
locale: "oneagentsAcp"
|
|
190
|
-
}, AcpTools));
|
|
191
151
|
ctx.effect(() => ctx.locale.register("oneagentsAcp", dictionaries));
|
|
192
152
|
const t = ctx.locale.bind("oneagentsAcp");
|
|
193
153
|
const native = /* @__PURE__ */ new Map();
|
|
194
154
|
const pending = /* @__PURE__ */ new Map();
|
|
195
155
|
const listeners = /* @__PURE__ */ new Map();
|
|
156
|
+
const blockedSessions = /* @__PURE__ */ new Set();
|
|
157
|
+
let disposed = false;
|
|
196
158
|
const presetOf = (id) => ctx.sessions.binding(id)?.session.projections.faceOf("agentPreset").getSnapshot();
|
|
197
159
|
const isAcp = (id) => String(presetOf(id) ?? "").startsWith("oneagents-acp-");
|
|
160
|
+
const block = (id, reason) => {
|
|
161
|
+
if (disposed) return;
|
|
162
|
+
if (reason) blockedSessions.add(id);
|
|
163
|
+
else blockedSessions.delete(id);
|
|
164
|
+
ctx.conversation.blocks.set(id, reason ? { reason } : void 0);
|
|
165
|
+
};
|
|
166
|
+
ctx.effect(() => () => {
|
|
167
|
+
disposed = true;
|
|
168
|
+
for (const id of blockedSessions) ctx.conversation.blocks.set(id, void 0);
|
|
169
|
+
});
|
|
198
170
|
const publish = (id, value) => {
|
|
199
171
|
native.set(id, value);
|
|
172
|
+
block(id, value?.writable === false ? t(value.blocked === "active-writer" ? "activeWriter" : "error") : void 0);
|
|
200
173
|
for (const fn of listeners.get(id) ?? []) fn();
|
|
201
174
|
};
|
|
202
175
|
const load = (id) => {
|
|
203
176
|
if (!pending.has(id)) {
|
|
177
|
+
if (!native.has(id)) block(id, t("loading"));
|
|
204
178
|
const operation = acpRequest(id).then((value) => {
|
|
205
179
|
publish(id, value);
|
|
206
180
|
return value;
|
|
181
|
+
}).catch((error) => {
|
|
182
|
+
block(id, `${t("error")}: ${error.message}`);
|
|
183
|
+
throw error;
|
|
207
184
|
}).finally(() => pending.delete(id));
|
|
208
185
|
pending.set(id, operation);
|
|
209
186
|
}
|
|
@@ -214,6 +191,7 @@ function apply(ctx) {
|
|
|
214
191
|
publish(id, updated);
|
|
215
192
|
};
|
|
216
193
|
const reset = () => {
|
|
194
|
+
for (const id of native.keys()) block(id, isAcp(id) ? t("loading") : void 0);
|
|
217
195
|
native.clear();
|
|
218
196
|
for (const set of listeners.values()) for (const fn of set) fn();
|
|
219
197
|
};
|
|
@@ -273,7 +251,7 @@ function apply(ctx) {
|
|
|
273
251
|
setBusy(false);
|
|
274
252
|
}
|
|
275
253
|
};
|
|
276
|
-
const disabled = locked || busy;
|
|
254
|
+
const disabled = locked || busy || external && capabilities?.writable === false;
|
|
277
255
|
const controls = [];
|
|
278
256
|
if (external && capabilities) {
|
|
279
257
|
const configs = capabilities.configOptions.filter((option) => option.type === "select");
|
package/vendor/dsh/imports.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export interface NativeSessionInput {
|
|
|
15
15
|
/** Current DSH events, contiguous from sequence zero. */
|
|
16
16
|
events: readonly SessionEvent[];
|
|
17
17
|
}
|
|
18
|
-
/**
|
|
18
|
+
/** Attached historical session, safe for navigation even while native writing is blocked. */
|
|
19
19
|
export interface ImportResult {
|
|
20
20
|
success: true;
|
|
21
21
|
dshSessionId: SessionId;
|
|
@@ -23,6 +23,8 @@ export interface ImportResult {
|
|
|
23
23
|
workspaceId: string;
|
|
24
24
|
agent: string;
|
|
25
25
|
continuation: 'native';
|
|
26
|
+
writable: boolean;
|
|
27
|
+
blocked?: 'active-writer';
|
|
26
28
|
}
|
|
27
29
|
declare module '@deepseek-ai/cordis' {
|
|
28
30
|
interface Context {
|
|
@@ -45,7 +47,7 @@ export declare class NativeSessions {
|
|
|
45
47
|
availability(provider: string): Promise<ImportAvailability>;
|
|
46
48
|
/** Restore one native session; repeated calls return its existing DSH identity and never replace its history.
|
|
47
49
|
* @param input Native identity, original workspace and historical events.
|
|
48
|
-
* @returns The attached DSH session
|
|
50
|
+
* @returns The attached DSH session and its native writing availability.
|
|
49
51
|
*/
|
|
50
52
|
importSession(input: NativeSessionInput): Promise<ImportResult>;
|
|
51
53
|
/** Stop new admissions and await callers already creating or attaching a session. */
|
package/vendor/dsh/imports.js
CHANGED
|
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
|
|
|
3
3
|
import { realpath, stat } from 'node:fs/promises';
|
|
4
4
|
import { isAbsolute } from 'node:path';
|
|
5
5
|
import { discoverPresets } from './discovery.js';
|
|
6
|
-
import { State } from './state.js';
|
|
6
|
+
import { State, hasActiveWriter } from './state.js';
|
|
7
7
|
const providers = { claude: 'claude', codex: 'codex', grok: 'grok-build' };
|
|
8
8
|
/** Owns import identities and serializes retries through remote import, local creation and workspace attachment. */
|
|
9
9
|
export class NativeSessions {
|
|
@@ -41,7 +41,7 @@ export class NativeSessions {
|
|
|
41
41
|
}
|
|
42
42
|
/** Restore one native session; repeated calls return its existing DSH identity and never replace its history.
|
|
43
43
|
* @param input Native identity, original workspace and historical events.
|
|
44
|
-
* @returns The attached DSH session
|
|
44
|
+
* @returns The attached DSH session and its native writing availability.
|
|
45
45
|
*/
|
|
46
46
|
async importSession(input) {
|
|
47
47
|
if (this.disposed)
|
|
@@ -105,10 +105,18 @@ export class NativeSessions {
|
|
|
105
105
|
this.ctx.sessions.prepare(id, { seed: input.events, meta: { cwd, agentPreset: preset } });
|
|
106
106
|
await this.ctx.agentPresets.resolve(preset);
|
|
107
107
|
}
|
|
108
|
+
let blocked = false;
|
|
108
109
|
if (!binding) {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
110
|
+
const imported = { provider: input.provider, nativeSessionId: input.nativeSessionId, messageIds: [] };
|
|
111
|
+
try {
|
|
112
|
+
binding = { ...await this.adapter.importNative(agent, cwd, input.nativeSessionId), imported };
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!hasActiveWriter(error))
|
|
116
|
+
throw error;
|
|
117
|
+
blocked = true;
|
|
118
|
+
binding = { agent, cwd, endpoint: endpoint.href, restoreMethod: 'session/resume', imported };
|
|
119
|
+
}
|
|
112
120
|
// The service ID survives local creation/attachment failure and plugin restart.
|
|
113
121
|
this.state.save(id, binding);
|
|
114
122
|
}
|
|
@@ -125,9 +133,10 @@ export class NativeSessions {
|
|
|
125
133
|
const resolved = await this.ctx.sessionController.resolveAgent(id);
|
|
126
134
|
if ('error' in resolved)
|
|
127
135
|
throw resolved.error;
|
|
128
|
-
await this.adapter.describe(resolved.agent);
|
|
136
|
+
const capabilities = blocked ? { writable: false, blocked: 'active-writer' } : await this.adapter.describe(resolved.agent);
|
|
129
137
|
const workspace = await this.ctx.workspaceRegistry.create(cwd);
|
|
130
138
|
await workspace.attachSession(id);
|
|
131
|
-
return { success: true, dshSessionId: id, workspace: cwd, workspaceId: workspace.id, agent, continuation: 'native'
|
|
139
|
+
return { success: true, dshSessionId: id, workspace: cwd, workspaceId: workspace.id, agent, continuation: 'native',
|
|
140
|
+
writable: capabilities?.writable !== false, ...(capabilities?.blocked ? { blocked: capabilities.blocked } : {}) };
|
|
132
141
|
}
|
|
133
142
|
}
|
package/vendor/dsh/state.d.ts
CHANGED
|
@@ -8,7 +8,8 @@ export interface Binding {
|
|
|
8
8
|
agent: string;
|
|
9
9
|
cwd: string;
|
|
10
10
|
endpoint: string;
|
|
11
|
-
|
|
11
|
+
/** Absent while the original native session has an active writer. Never use session/new for this binding. */
|
|
12
|
+
sessionId?: string;
|
|
12
13
|
/** Absent on bindings created before native imports were supported. */
|
|
13
14
|
restoreMethod?: 'session/load' | 'session/resume';
|
|
14
15
|
imported?: NativeImport;
|
|
@@ -20,3 +21,5 @@ export declare class State {
|
|
|
20
21
|
get(id: string): Binding | undefined;
|
|
21
22
|
save(id: string, binding: Binding): void;
|
|
22
23
|
}
|
|
24
|
+
/** Native writer ownership prevents execution, but must not prevent reading imported history. */
|
|
25
|
+
export declare function hasActiveWriter(error: unknown): boolean;
|
package/vendor/dsh/state.js
CHANGED
|
@@ -30,7 +30,11 @@ function decodeBinding(value) {
|
|
|
30
30
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
31
31
|
throw new Error('Invalid ACP binding');
|
|
32
32
|
const binding = value;
|
|
33
|
-
if (['agent', 'cwd', 'endpoint'
|
|
33
|
+
if (['agent', 'cwd', 'endpoint'].some(key => typeof binding[key] !== 'string' || !binding[key]))
|
|
34
|
+
throw new Error('Invalid ACP binding identity');
|
|
35
|
+
if (binding.sessionId !== undefined && (typeof binding.sessionId !== 'string' || !binding.sessionId))
|
|
36
|
+
throw new Error('Invalid ACP binding identity');
|
|
37
|
+
if (binding.sessionId === undefined && binding.imported === undefined)
|
|
34
38
|
throw new Error('Invalid ACP binding identity');
|
|
35
39
|
if (binding.restoreMethod !== undefined && binding.restoreMethod !== 'session/load' && binding.restoreMethod !== 'session/resume')
|
|
36
40
|
throw new Error('Invalid ACP restore method');
|
|
@@ -45,3 +49,7 @@ function decodeBinding(value) {
|
|
|
45
49
|
}
|
|
46
50
|
return value;
|
|
47
51
|
}
|
|
52
|
+
/** Native writer ownership prevents execution, but must not prevent reading imported history. */
|
|
53
|
+
export function hasActiveWriter(error) {
|
|
54
|
+
return error instanceof Error && /already has an active writer/.test(error.message);
|
|
55
|
+
}
|