@ycodium-ai/agent-dsh 0.2.4688 → 0.2.5004
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/README.md +14 -4
- package/assets/permission-sync.mjs +3 -1
- package/dist/index.js +251 -44
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -63,12 +63,22 @@ Contract and drift policy:
|
|
|
63
63
|
`ctx.sessions.list()`, the `session/created` event, and `insert` entries in a `--patch`
|
|
64
64
|
overlay. Verified against dsh 0.2.1-rc.2.
|
|
65
65
|
- Failure is always open: `inject` keeps the plugin inactive when the service is gone; a
|
|
66
|
-
changed method shape writes one stderr line and does nothing
|
|
67
|
-
|
|
66
|
+
changed method shape writes one stderr line and does nothing. If skill configuration
|
|
67
|
+
verification fails, the overlay keeps only the permission insert and logs a skills warning.
|
|
68
|
+
No failure path throws into the session.
|
|
69
|
+
- Resumed session processes check stderr for activation and a confirmation matching the
|
|
70
|
+
session id and requested mode (`switched` or `already`). A switch failure for this session,
|
|
71
|
+
missing preset methods, or an absent permission insert produces one `runtime.warning`
|
|
72
|
+
and a host log entry once resume completes. Scan and stderr read errors matter only
|
|
73
|
+
without confirmation for this session. Missing activation or confirmation is checked
|
|
74
|
+
on the first `sendTurn`; stderr delivered before that call can satisfy the check. Each process warns at most once and keeps
|
|
75
|
+
running. New sessions use DSH's native environment setting without this check.
|
|
76
|
+
On dsh 0.2.2-rc.1 on Windows, activation arrives before the `initialize` response;
|
|
77
|
+
session synchronization runs before the `session/new` or `session/resume` response.
|
|
68
78
|
- After a DSH upgrade run
|
|
69
79
|
`pnpm --filter @ycodium-ai/agent-dsh check:permission-sync` (or set `DSH_BIN`). It boots
|
|
70
|
-
`dsh --profile acp` with the same overlay and
|
|
71
|
-
|
|
80
|
+
`dsh --profile acp` with the same overlay and verifies composition, activation, and
|
|
81
|
+
matching session confirmations for creation and resume. It exits 0 when no dsh is installed.
|
|
72
82
|
- Exit plan: when DSH applies `DSH_PERMISSION_MODE` on resume, or exposes the permission
|
|
73
83
|
preset over ACP (session mode or config option), delete the inserted plugin, its overlay
|
|
74
84
|
entry, and this section.
|
|
@@ -48,7 +48,9 @@ export function apply(ctx) {
|
|
|
48
48
|
const sync = (session) => {
|
|
49
49
|
if (session?.header?.parentSession !== undefined) return;
|
|
50
50
|
try {
|
|
51
|
-
|
|
51
|
+
const changed = presets.current(session) !== requested;
|
|
52
|
+
if (changed) presets.set(session, requested);
|
|
53
|
+
report(`session ${session.id} mode=${requested} ${changed ? "switched" : "already"}`);
|
|
52
54
|
} catch (error) {
|
|
53
55
|
report(`cannot switch session ${session?.id ?? "?"} to ${requested}: ${messageOf(error)}`);
|
|
54
56
|
}
|
package/dist/index.js
CHANGED
|
@@ -7371,7 +7371,7 @@ var require_dist = __commonJS({
|
|
|
7371
7371
|
import { definePlugin } from "@ycodium-ai/plugin-api";
|
|
7372
7372
|
|
|
7373
7373
|
// ../../packages/plugin-api/src/version.ts
|
|
7374
|
-
var PLUGIN_API_VERSION =
|
|
7374
|
+
var PLUGIN_API_VERSION = 142;
|
|
7375
7375
|
|
|
7376
7376
|
// src/index.ts
|
|
7377
7377
|
import * as NodeOS6 from "node:os";
|
|
@@ -7497,6 +7497,7 @@ var DSH_CARD = {
|
|
|
7497
7497
|
};
|
|
7498
7498
|
|
|
7499
7499
|
// src/dshInstance.ts
|
|
7500
|
+
import * as NodeCrypto4 from "node:crypto";
|
|
7500
7501
|
import { modelSelectionStringOption, raceAbort as raceAbort2 } from "@ycodium-ai/plugin-api/executor";
|
|
7501
7502
|
import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
|
|
7502
7503
|
|
|
@@ -8495,7 +8496,15 @@ function parsePermissionRequest(params, known) {
|
|
|
8495
8496
|
{ fallbackStatus: "pending" }
|
|
8496
8497
|
);
|
|
8497
8498
|
const kind = toolCall?.kind ?? "unknown";
|
|
8498
|
-
const
|
|
8499
|
+
const content = toolCall?.data["content"];
|
|
8500
|
+
const firstText = Array.isArray(content) ? content.flatMap((entry) => {
|
|
8501
|
+
if (!isRecord2(entry) || entry["type"] !== "content" || !isRecord2(entry["content"]))
|
|
8502
|
+
return [];
|
|
8503
|
+
const block = entry["content"];
|
|
8504
|
+
return block["type"] === "text" && typeof block["text"] === "string" && block["text"].trim() ? [block["text"]] : [];
|
|
8505
|
+
})[0] : void 0;
|
|
8506
|
+
const originalTitle = (request.title ?? known?.rawTitle)?.trim() || void 0;
|
|
8507
|
+
const detail = toolCall?.command ?? firstText ?? originalTitle;
|
|
8499
8508
|
return {
|
|
8500
8509
|
kind,
|
|
8501
8510
|
...detail ? { detail } : {},
|
|
@@ -8736,6 +8745,7 @@ function makeAcpRequestOpenedEvent(input2) {
|
|
|
8736
8745
|
...input2.detail ? { detail: input2.detail } : {},
|
|
8737
8746
|
...toolName ? { toolName } : {},
|
|
8738
8747
|
args: input2.args,
|
|
8748
|
+
...input2.statement !== void 0 ? { statement: input2.statement } : {},
|
|
8739
8749
|
...input2.options ? { options: input2.options } : {},
|
|
8740
8750
|
...input2.fileChanges ? { fileChanges: input2.fileChanges } : {},
|
|
8741
8751
|
declineReasonRelay: "queued"
|
|
@@ -31294,7 +31304,7 @@ function ndJsonStream(output2, input2) {
|
|
|
31294
31304
|
});
|
|
31295
31305
|
return write;
|
|
31296
31306
|
};
|
|
31297
|
-
const
|
|
31307
|
+
const readable = new ReadableStream({
|
|
31298
31308
|
async start(controller) {
|
|
31299
31309
|
const lines = new LineBuffer();
|
|
31300
31310
|
const enqueueLine = async (lineBytes) => {
|
|
@@ -31370,7 +31380,7 @@ function ndJsonStream(output2, input2) {
|
|
|
31370
31380
|
return writeJson(message);
|
|
31371
31381
|
}
|
|
31372
31382
|
});
|
|
31373
|
-
return { readable
|
|
31383
|
+
return { readable, writable };
|
|
31374
31384
|
}
|
|
31375
31385
|
|
|
31376
31386
|
// ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.4.0_zod@4.6.5/node_modules/@agentclientprotocol/sdk/dist/schema/guards.gen.js
|
|
@@ -34009,6 +34019,38 @@ function createPromptResults({
|
|
|
34009
34019
|
return { add, receive, reject, stop, complete, hasInterrupted, forget, wait, finishUnreceived };
|
|
34010
34020
|
}
|
|
34011
34021
|
|
|
34022
|
+
// ../../packages/ycodium-acp-executor/src/permission-statement.ts
|
|
34023
|
+
function defaultPermissionStatement(request) {
|
|
34024
|
+
const rawInput = request.toolCall?.data["rawInput"];
|
|
34025
|
+
const input2 = isRecord2(rawInput) ? rawInput : {};
|
|
34026
|
+
const coveredArgs = [];
|
|
34027
|
+
const text = (name) => {
|
|
34028
|
+
const value = input2[name];
|
|
34029
|
+
if (typeof value !== "string" || value.trim().length === 0) return void 0;
|
|
34030
|
+
coveredArgs.push(name);
|
|
34031
|
+
return value;
|
|
34032
|
+
};
|
|
34033
|
+
const description = text("description");
|
|
34034
|
+
const justification = text("justification") ?? text("reason");
|
|
34035
|
+
const command = request.kind === "execute" ? text("command") ?? text("cmd") ?? request.toolCall?.command : void 0;
|
|
34036
|
+
let outsideSandbox = false;
|
|
34037
|
+
for (const name of ["sandbox_permissions", "sandboxPermissions", "dangerouslyDisableSandbox"]) {
|
|
34038
|
+
const value = input2[name];
|
|
34039
|
+
const outside = name === "dangerouslyDisableSandbox" ? value === true || value === "true" : typeof value === "string" && /full[-_]access|danger|escalat/i.test(value);
|
|
34040
|
+
if (!outside) continue;
|
|
34041
|
+
outsideSandbox = true;
|
|
34042
|
+
coveredArgs.push(name);
|
|
34043
|
+
}
|
|
34044
|
+
if ("timeoutMs" in input2) coveredArgs.push("timeoutMs");
|
|
34045
|
+
return {
|
|
34046
|
+
...description !== void 0 ? { description } : {},
|
|
34047
|
+
...justification !== void 0 ? { justification } : {},
|
|
34048
|
+
...command !== void 0 ? { command } : {},
|
|
34049
|
+
...outsideSandbox ? { outsideSandbox: true } : {},
|
|
34050
|
+
...coveredArgs.length > 0 ? { coveredArgs } : {}
|
|
34051
|
+
};
|
|
34052
|
+
}
|
|
34053
|
+
|
|
34012
34054
|
// ../../packages/ycodium-acp-executor/src/executor/requests.ts
|
|
34013
34055
|
function createExecutorRequests({
|
|
34014
34056
|
emit,
|
|
@@ -34142,6 +34184,13 @@ function createExecutorRequests({
|
|
|
34142
34184
|
return { outcome: { outcome: "selected", optionId } };
|
|
34143
34185
|
}
|
|
34144
34186
|
}
|
|
34187
|
+
const permissionContext = {
|
|
34188
|
+
request: params,
|
|
34189
|
+
permissionRequest,
|
|
34190
|
+
previousToolCall: tracked?.state
|
|
34191
|
+
};
|
|
34192
|
+
const statement = hooks.permissionStatement?.(permissionContext) ?? defaultPermissionStatement(permissionRequest);
|
|
34193
|
+
const fileChanges = hooks.permissionFileChanges?.(permissionContext) ?? fileChangesFromAcpPermission(permissionRequest);
|
|
34145
34194
|
const requestId = randomId();
|
|
34146
34195
|
const outcome = await new Promise((resolve4) => {
|
|
34147
34196
|
const pending = {
|
|
@@ -34161,10 +34210,11 @@ function createExecutorRequests({
|
|
|
34161
34210
|
turnId: shared.activeTurnId,
|
|
34162
34211
|
requestId,
|
|
34163
34212
|
permissionRequest,
|
|
34164
|
-
detail: permissionRequest.detail,
|
|
34213
|
+
detail: statement.command ?? permissionRequest.detail,
|
|
34165
34214
|
args: permissionRequest.toolCall?.data["rawInput"] ?? params.toolCall.rawInput,
|
|
34215
|
+
statement,
|
|
34166
34216
|
options: acpApprovalOptions(params),
|
|
34167
|
-
fileChanges
|
|
34217
|
+
fileChanges,
|
|
34168
34218
|
source: "acp.jsonrpc",
|
|
34169
34219
|
method: "session/request_permission",
|
|
34170
34220
|
rawPayload: params
|
|
@@ -36308,11 +36358,10 @@ function dshOverlay(input2) {
|
|
|
36308
36358
|
return `${lines.join("\n")}
|
|
36309
36359
|
`;
|
|
36310
36360
|
}
|
|
36311
|
-
async function
|
|
36312
|
-
const contents = dshOverlay(input2);
|
|
36361
|
+
async function ensureTempFile(tempRoot, extension, contents) {
|
|
36313
36362
|
const hash2 = NodeCrypto3.createHash("sha256").update(contents).digest("hex").slice(0, 16);
|
|
36314
36363
|
const directory = NodePath4.join(tempRoot, OVERLAY_DIR);
|
|
36315
|
-
const file2 = NodePath4.join(directory, `${hash2}
|
|
36364
|
+
const file2 = NodePath4.join(directory, `${hash2}${extension}`);
|
|
36316
36365
|
const present = await NodeFSP.readFile(file2, "utf8").then(
|
|
36317
36366
|
(existing) => existing === contents,
|
|
36318
36367
|
() => false
|
|
@@ -36323,10 +36372,18 @@ async function ensureDshOverlay(input2, tempRoot = NodeOS3.tmpdir()) {
|
|
|
36323
36372
|
await NodeFSP.writeFile(staging, contents, "utf8");
|
|
36324
36373
|
await NodeFSP.rename(staging, file2).catch(async (error62) => {
|
|
36325
36374
|
await NodeFSP.rm(staging, { force: true });
|
|
36326
|
-
|
|
36375
|
+
const written = await NodeFSP.readFile(file2, "utf8").catch(() => void 0);
|
|
36376
|
+
if (written !== contents) throw error62;
|
|
36327
36377
|
});
|
|
36328
36378
|
return file2;
|
|
36329
36379
|
}
|
|
36380
|
+
async function ensureDshOverlay(input2, tempRoot = NodeOS3.tmpdir()) {
|
|
36381
|
+
return ensureTempFile(tempRoot, ".yml", dshOverlay(input2));
|
|
36382
|
+
}
|
|
36383
|
+
async function ensurePermissionSyncCopy(tempRoot = NodeOS3.tmpdir()) {
|
|
36384
|
+
const source = await NodeFSP.readFile(permissionSyncModulePath(), "utf8").catch(() => void 0);
|
|
36385
|
+
return source === void 0 ? void 0 : ensureTempFile(tempRoot, ".mjs", source);
|
|
36386
|
+
}
|
|
36330
36387
|
async function spawnDsh(host, launch, extraArgs, suffix = []) {
|
|
36331
36388
|
const spawned = {
|
|
36332
36389
|
program: launch.program,
|
|
@@ -36380,24 +36437,19 @@ function dumpConfigEntries(dump) {
|
|
|
36380
36437
|
}
|
|
36381
36438
|
return Array.isArray(entries) ? entries : [];
|
|
36382
36439
|
}
|
|
36383
|
-
async function readable(path) {
|
|
36384
|
-
return NodeFSP.access(path).then(
|
|
36385
|
-
() => true,
|
|
36386
|
-
() => false
|
|
36387
|
-
);
|
|
36388
|
-
}
|
|
36389
36440
|
async function dshOverlayPatchArgs(input2) {
|
|
36390
36441
|
const { skills, host, launch } = input2;
|
|
36391
36442
|
const skillsDir = skills !== void 0 && skills.names.length > 0 ? skills.skillsDir : void 0;
|
|
36392
|
-
const modulePath = permissionSyncModulePath();
|
|
36393
|
-
const expectPermissionSync = await readable(modulePath);
|
|
36394
|
-
if (!expectPermissionSync) {
|
|
36395
|
-
host.log.warn(
|
|
36396
|
-
"dsh permission sync module is missing; switching the permission mode will not reach dsh"
|
|
36397
|
-
);
|
|
36398
|
-
}
|
|
36399
|
-
if (skillsDir === void 0 && !expectPermissionSync) return [];
|
|
36400
36443
|
try {
|
|
36444
|
+
const modulePath = await ensurePermissionSyncCopy(input2.tempRoot);
|
|
36445
|
+
const expectPermissionSync = modulePath !== void 0;
|
|
36446
|
+
if (!expectPermissionSync) {
|
|
36447
|
+
input2.onPermissionSyncUnavailable?.();
|
|
36448
|
+
host.log.warn(
|
|
36449
|
+
"dsh permission sync module is missing; switching the permission mode will not reach dsh"
|
|
36450
|
+
);
|
|
36451
|
+
}
|
|
36452
|
+
if (skillsDir === void 0 && !expectPermissionSync) return [];
|
|
36401
36453
|
const overlay = await ensureDshOverlay(
|
|
36402
36454
|
{
|
|
36403
36455
|
...skillsDir === void 0 ? {} : { skillsDir },
|
|
@@ -36407,22 +36459,23 @@ async function dshOverlayPatchArgs(input2) {
|
|
|
36407
36459
|
);
|
|
36408
36460
|
if (skillsDir === void 0) return ["--patch", overlay];
|
|
36409
36461
|
const key = `${launch.cwd}\0${overlay}\0${expectPermissionSync ? "sync" : "no-sync"}`;
|
|
36410
|
-
|
|
36411
|
-
|
|
36412
|
-
check2
|
|
36413
|
-
host,
|
|
36414
|
-
|
|
36415
|
-
|
|
36416
|
-
|
|
36417
|
-
|
|
36462
|
+
try {
|
|
36463
|
+
let check2 = input2.verified.get(key);
|
|
36464
|
+
if (check2 === void 0) {
|
|
36465
|
+
check2 = overlayTakesEffect({ host, launch, overlay, skillsDir, expectPermissionSync });
|
|
36466
|
+
input2.verified.set(key, check2);
|
|
36467
|
+
}
|
|
36468
|
+
if (await check2) return ["--patch", overlay];
|
|
36469
|
+
host.log.warn("dsh did not take the session skills overlay; using dsh's own skills");
|
|
36470
|
+
} catch (error62) {
|
|
36471
|
+
input2.verified.delete(key);
|
|
36472
|
+
host.log.warn("dsh session skills verification failed; using dsh's own skills", {
|
|
36473
|
+
error: error62 instanceof Error ? error62.message : String(error62)
|
|
36418
36474
|
});
|
|
36419
|
-
input2.verified.set(key, check2);
|
|
36420
36475
|
}
|
|
36421
|
-
|
|
36422
|
-
host.log.warn(
|
|
36423
|
-
"dsh did not take the session overlay; skills and permission switching stay on dsh's own defaults"
|
|
36424
|
-
);
|
|
36476
|
+
return modulePath === void 0 ? [] : ["--patch", await ensureDshOverlay({ permissionSyncModule: modulePath }, input2.tempRoot)];
|
|
36425
36477
|
} catch (error62) {
|
|
36478
|
+
input2.onPermissionSyncUnavailable?.();
|
|
36426
36479
|
input2.verified.clear();
|
|
36427
36480
|
host.log.warn(
|
|
36428
36481
|
"dsh session overlay failed; skills and permission switching stay on dsh's own defaults",
|
|
@@ -36713,10 +36766,10 @@ async function probeDshModels(input2) {
|
|
|
36713
36766
|
}
|
|
36714
36767
|
let handshake;
|
|
36715
36768
|
try {
|
|
36716
|
-
const { readable
|
|
36769
|
+
const { readable, writable } = nodeStreamsFromHandle(handle);
|
|
36717
36770
|
handshake = await raceAbort(
|
|
36718
36771
|
openAcpProbeHandshake({
|
|
36719
|
-
readable
|
|
36772
|
+
readable,
|
|
36720
36773
|
writable,
|
|
36721
36774
|
clientInfo: DSH_CLIENT_INFO,
|
|
36722
36775
|
requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS
|
|
@@ -36773,7 +36826,24 @@ var readShellCommand = (title, rawInput) => {
|
|
|
36773
36826
|
const command = input2["command"];
|
|
36774
36827
|
return typeof command === "string" && command.trim() !== "" ? { command, input: input2 } : void 0;
|
|
36775
36828
|
};
|
|
36776
|
-
var dshPermissionRequestKind = (tool) =>
|
|
36829
|
+
var dshPermissionRequestKind = (tool) => {
|
|
36830
|
+
if (readShellCommand(tool.title, tool.rawInput) !== void 0) return "execute";
|
|
36831
|
+
switch (tool.title) {
|
|
36832
|
+
case "edit":
|
|
36833
|
+
case "write":
|
|
36834
|
+
return "edit";
|
|
36835
|
+
case "read":
|
|
36836
|
+
case "glob":
|
|
36837
|
+
case "grep":
|
|
36838
|
+
return "read";
|
|
36839
|
+
case "web_search":
|
|
36840
|
+
return "search";
|
|
36841
|
+
case "web_fetch":
|
|
36842
|
+
return "fetch";
|
|
36843
|
+
default:
|
|
36844
|
+
return void 0;
|
|
36845
|
+
}
|
|
36846
|
+
};
|
|
36777
36847
|
var slashed = (path) => path.replaceAll("\\", "/").replace(/\/{2,}/g, "/");
|
|
36778
36848
|
var basename = (path) => {
|
|
36779
36849
|
const normalized = slashed(path);
|
|
@@ -36864,6 +36934,37 @@ function dshOpenCommands(session) {
|
|
|
36864
36934
|
};
|
|
36865
36935
|
}
|
|
36866
36936
|
|
|
36937
|
+
// src/approvalStatement.ts
|
|
36938
|
+
var rawInputOf = (input2) => typeof input2 === "object" && input2 !== null && !Array.isArray(input2) ? input2 : {};
|
|
36939
|
+
var dshPermissionStatement = (context) => {
|
|
36940
|
+
const { permissionRequest } = context;
|
|
36941
|
+
const statement = defaultPermissionStatement(permissionRequest);
|
|
36942
|
+
const rawInput = rawInputOf(permissionRequest.toolCall?.data["rawInput"]);
|
|
36943
|
+
const fileChange = dshPermissionFileChanges(context) !== void 0;
|
|
36944
|
+
const hidden = fileChange ? ["file_path", "old_string", "new_string", "content"] : [];
|
|
36945
|
+
return {
|
|
36946
|
+
...statement,
|
|
36947
|
+
coveredArgs: [...statement.coveredArgs ?? [], ...hidden.filter((name) => name in rawInput)]
|
|
36948
|
+
};
|
|
36949
|
+
};
|
|
36950
|
+
var dshPermissionFileChanges = ({
|
|
36951
|
+
permissionRequest
|
|
36952
|
+
}) => {
|
|
36953
|
+
if (permissionRequest.kind !== "edit") return void 0;
|
|
36954
|
+
const input2 = rawInputOf(permissionRequest.toolCall?.data["rawInput"]);
|
|
36955
|
+
const path = input2["file_path"];
|
|
36956
|
+
const oldText = input2["old_string"];
|
|
36957
|
+
const newText = input2["new_string"] ?? input2["content"];
|
|
36958
|
+
if (typeof path !== "string" || !path.trim() || typeof newText !== "string") return void 0;
|
|
36959
|
+
return [
|
|
36960
|
+
{
|
|
36961
|
+
path,
|
|
36962
|
+
changeKind: typeof oldText === "string" ? "modify" : "add",
|
|
36963
|
+
content: { kind: "replace", ...typeof oldText === "string" ? { oldText } : {}, newText }
|
|
36964
|
+
}
|
|
36965
|
+
];
|
|
36966
|
+
};
|
|
36967
|
+
|
|
36867
36968
|
// src/subagents.ts
|
|
36868
36969
|
var FALLBACK_TITLE = "DeepSeek Harness subagent";
|
|
36869
36970
|
var TURN_ENDED_DESCRIPTION = "Turn ended. Individual agent status is unavailable.";
|
|
@@ -36919,6 +37020,82 @@ var dshToolSubagents = {
|
|
|
36919
37020
|
})
|
|
36920
37021
|
};
|
|
36921
37022
|
|
|
37023
|
+
// src/permissionSyncHealth.ts
|
|
37024
|
+
function createPermissionSyncHealth(input2) {
|
|
37025
|
+
const requested = input2.requested?.trim();
|
|
37026
|
+
let active2 = false;
|
|
37027
|
+
let confirmed = false;
|
|
37028
|
+
let ready = false;
|
|
37029
|
+
let sending = false;
|
|
37030
|
+
let warned = false;
|
|
37031
|
+
let failure2;
|
|
37032
|
+
let unconfirmedFailure;
|
|
37033
|
+
let pending = "";
|
|
37034
|
+
const decoder = new TextDecoder();
|
|
37035
|
+
const check2 = () => {
|
|
37036
|
+
if (!requested || !input2.sessionId || !ready || warned) return;
|
|
37037
|
+
if (failure2 === void 0 && (!sending || active2 && confirmed)) return;
|
|
37038
|
+
warned = true;
|
|
37039
|
+
try {
|
|
37040
|
+
input2.warn(
|
|
37041
|
+
failure2 ?? (!confirmed ? unconfirmedFailure : void 0) ?? "permission sync activation or session confirmation was not reported"
|
|
37042
|
+
);
|
|
37043
|
+
} catch {
|
|
37044
|
+
}
|
|
37045
|
+
};
|
|
37046
|
+
const fail = (reason) => {
|
|
37047
|
+
failure2 ??= reason;
|
|
37048
|
+
check2();
|
|
37049
|
+
};
|
|
37050
|
+
const line = (value) => {
|
|
37051
|
+
const text = value.trim();
|
|
37052
|
+
if (text.endsWith(`[ycodium-permission-sync] active requested=${requested}`)) active2 = true;
|
|
37053
|
+
const confirmation = `[ycodium-permission-sync] session ${input2.sessionId} mode=${requested}`;
|
|
37054
|
+
if (text.endsWith(`${confirmation} switched`) || text.endsWith(`${confirmation} already`)) {
|
|
37055
|
+
confirmed = true;
|
|
37056
|
+
}
|
|
37057
|
+
const at = text.lastIndexOf("[ycodium-permission-sync]");
|
|
37058
|
+
const diagnostic = at < 0 ? "" : text.slice(at);
|
|
37059
|
+
if (diagnostic.startsWith(
|
|
37060
|
+
`[ycodium-permission-sync] cannot switch session ${input2.sessionId} `
|
|
37061
|
+
) || diagnostic.startsWith("[ycodium-permission-sync] permissionPresets.set/current is missing")) {
|
|
37062
|
+
fail("permission sync plugin reported a failure");
|
|
37063
|
+
}
|
|
37064
|
+
if (diagnostic.startsWith("[ycodium-permission-sync] cannot scan existing sessions")) {
|
|
37065
|
+
unconfirmedFailure ??= "permission sync could not scan existing sessions";
|
|
37066
|
+
check2();
|
|
37067
|
+
}
|
|
37068
|
+
};
|
|
37069
|
+
return {
|
|
37070
|
+
unavailable: () => fail("session overlay does not include permission sync"),
|
|
37071
|
+
sessionReady: () => {
|
|
37072
|
+
ready = true;
|
|
37073
|
+
check2();
|
|
37074
|
+
},
|
|
37075
|
+
beforeSendTurn: () => {
|
|
37076
|
+
sending = true;
|
|
37077
|
+
check2();
|
|
37078
|
+
},
|
|
37079
|
+
stderr: async function* (source) {
|
|
37080
|
+
try {
|
|
37081
|
+
for await (const chunk of source) {
|
|
37082
|
+
if (requested) {
|
|
37083
|
+
const lines = (pending + decoder.decode(chunk, { stream: true })).split("\n");
|
|
37084
|
+
pending = lines.pop() ?? "";
|
|
37085
|
+
for (const value of lines) line(value);
|
|
37086
|
+
pending = pending.slice(-4096);
|
|
37087
|
+
}
|
|
37088
|
+
yield chunk;
|
|
37089
|
+
}
|
|
37090
|
+
if (requested) line(pending + decoder.decode());
|
|
37091
|
+
} catch {
|
|
37092
|
+
unconfirmedFailure ??= "cannot read permission sync diagnostics from stderr";
|
|
37093
|
+
check2();
|
|
37094
|
+
}
|
|
37095
|
+
}
|
|
37096
|
+
};
|
|
37097
|
+
}
|
|
37098
|
+
|
|
36922
37099
|
// src/dshInstance.ts
|
|
36923
37100
|
var RESUME_SCHEMA_VERSION = 1;
|
|
36924
37101
|
var yieldTick = () => new Promise((resolve4) => {
|
|
@@ -37013,7 +37190,27 @@ var createDshInstance = (config2, host) => {
|
|
|
37013
37190
|
if (disposed) throw new Error("instance disposed");
|
|
37014
37191
|
throwIfStartAborted(signal);
|
|
37015
37192
|
}
|
|
37193
|
+
const resume = input2.discardResumeCursor === true ? void 0 : parseAcpResumeCursor(input2.resumeCursor, RESUME_SCHEMA_VERSION);
|
|
37016
37194
|
const env = buildSpawnEnv(recipe, resolveHomePath(recipe.homePath), input2.nativeModeId);
|
|
37195
|
+
const permissionSync = createPermissionSyncHealth({
|
|
37196
|
+
sessionId: resume?.sessionId,
|
|
37197
|
+
requested: env.DSH_PERMISSION_MODE ?? process.env.DSH_PERMISSION_MODE,
|
|
37198
|
+
warn: (reason) => {
|
|
37199
|
+
host.log.warn("dsh permission sync is unavailable", { threadId: input2.threadId, reason });
|
|
37200
|
+
input2.events.emit({
|
|
37201
|
+
type: "runtime.warning",
|
|
37202
|
+
eventId: NodeCrypto4.randomUUID(),
|
|
37203
|
+
provider: DSH_DRIVER_KIND,
|
|
37204
|
+
providerInstanceId: host.instanceId,
|
|
37205
|
+
threadId: input2.threadId,
|
|
37206
|
+
createdAt: nowIso(),
|
|
37207
|
+
payload: {
|
|
37208
|
+
code: "permission-mode-not-applied",
|
|
37209
|
+
message: "The access mode change did not apply to this thread. It will keep its previous access mode. Start a new thread to use the new access mode."
|
|
37210
|
+
}
|
|
37211
|
+
});
|
|
37212
|
+
}
|
|
37213
|
+
});
|
|
37017
37214
|
const launch = {
|
|
37018
37215
|
program: recipe.binaryPath,
|
|
37019
37216
|
args: tokenizeLaunchArgs(recipe.launchArgs),
|
|
@@ -37024,19 +37221,24 @@ var createDshInstance = (config2, host) => {
|
|
|
37024
37221
|
skills: input2.skills,
|
|
37025
37222
|
host,
|
|
37026
37223
|
launch,
|
|
37027
|
-
verified: overlayChecks
|
|
37224
|
+
verified: overlayChecks,
|
|
37225
|
+
onPermissionSyncUnavailable: permissionSync.unavailable
|
|
37028
37226
|
});
|
|
37029
37227
|
throwIfStartAborted(signal);
|
|
37030
37228
|
const { handle, spawned } = await spawnDsh(host, launch, overlayArgs);
|
|
37031
|
-
const { readable
|
|
37032
|
-
|
|
37229
|
+
const { readable, writable, stderrTail } = nodeStreamsFromHandle2({
|
|
37230
|
+
stdout: handle.stdout,
|
|
37231
|
+
stderr: permissionSync.stderr(handle.stderr),
|
|
37232
|
+
writeStdin: (chunk) => handle.writeStdin(chunk),
|
|
37233
|
+
closeStdin: () => handle.closeStdin()
|
|
37234
|
+
});
|
|
37033
37235
|
const requestedModelId = modelIdFromSelection(input2.modelSelection);
|
|
37034
37236
|
const requestedEffort = modelSelectionStringOption(
|
|
37035
37237
|
input2.modelSelection,
|
|
37036
37238
|
DSH_EFFORT_OPTION_ID
|
|
37037
37239
|
);
|
|
37038
37240
|
const executor = createAcpExecutor({
|
|
37039
|
-
readable
|
|
37241
|
+
readable,
|
|
37040
37242
|
writable,
|
|
37041
37243
|
stderrTail,
|
|
37042
37244
|
exited: handle.exited,
|
|
@@ -37056,6 +37258,8 @@ var createDshInstance = (config2, host) => {
|
|
|
37056
37258
|
resumeMethod: "session/resume",
|
|
37057
37259
|
hooks: {
|
|
37058
37260
|
permissionRequestKind: dshPermissionRequestKind,
|
|
37261
|
+
permissionStatement: dshPermissionStatement,
|
|
37262
|
+
permissionFileChanges: dshPermissionFileChanges,
|
|
37059
37263
|
// `subagent` / `subagent_fork` 由执行器的子 agent 跟踪接管,不再画成普通工具。
|
|
37060
37264
|
toolSubagents: dshToolSubagents
|
|
37061
37265
|
},
|
|
@@ -37075,6 +37279,7 @@ var createDshInstance = (config2, host) => {
|
|
|
37075
37279
|
const started = await raceStartAbort(executor.start(), signal);
|
|
37076
37280
|
await yieldTick();
|
|
37077
37281
|
throwIfStartAborted(signal);
|
|
37282
|
+
if (resume !== void 0) permissionSync.sessionReady();
|
|
37078
37283
|
const createdAt = nowIso();
|
|
37079
37284
|
const resumeCursor = {
|
|
37080
37285
|
schemaVersion: RESUME_SCHEMA_VERSION,
|
|
@@ -37104,6 +37309,7 @@ var createDshInstance = (config2, host) => {
|
|
|
37104
37309
|
executor,
|
|
37105
37310
|
handle,
|
|
37106
37311
|
forwarding,
|
|
37312
|
+
permissionSync,
|
|
37107
37313
|
spawned
|
|
37108
37314
|
});
|
|
37109
37315
|
host.log.info("session started", {
|
|
@@ -37126,6 +37332,7 @@ var createDshInstance = (config2, host) => {
|
|
|
37126
37332
|
if (disposed) throw new Error("instance disposed");
|
|
37127
37333
|
const booked = requireThread(input2.threadId);
|
|
37128
37334
|
if (signal?.aborted) throw new Error("aborted");
|
|
37335
|
+
booked.permissionSync.beforeSendTurn();
|
|
37129
37336
|
const onAbort = () => {
|
|
37130
37337
|
void booked.executor.cancel(input2.expectedTurnId).catch(() => void 0);
|
|
37131
37338
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ycodium-ai/agent-dsh",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.5004",
|
|
4
4
|
"description": "DeepSeek Harness executor: dsh CLI over Agent Client Protocol stdio.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ycodium",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"esbuild": "0.28.1",
|
|
23
23
|
"vite-plus": "0.2.2",
|
|
24
24
|
"yaml": "^2.9.0",
|
|
25
|
-
"@ycodium-ai/plugin-api": "0.2.
|
|
26
|
-
"ycodium-executor
|
|
27
|
-
"ycodium-
|
|
25
|
+
"@ycodium-ai/plugin-api": "0.2.5004",
|
|
26
|
+
"ycodium-acp-executor": "0.2.5004",
|
|
27
|
+
"ycodium-executor-testing": "0.0.0"
|
|
28
28
|
},
|
|
29
29
|
"ycodium": {
|
|
30
30
|
"plugin": "./dist/index.js",
|