@ycodium-ai/agent-dsh 0.2.4486 → 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 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; an overlay that does not
67
- compose is dropped with a warning. No failure path throws into the session.
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 asserts both that the entry composes and
71
- that the plugin activates. It exits 0 when no dsh is installed.
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,13 +48,18 @@ export function apply(ctx) {
48
48
  const sync = (session) => {
49
49
  if (session?.header?.parentSession !== undefined) return;
50
50
  try {
51
- if (presets.current(session) !== requested) presets.set(session, requested);
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
  }
55
57
  };
56
58
 
57
- ctx.on("session/created", sync);
59
+ // `session/created` 同步派发期间会话只读(dsh 0.2.2:「cannot append before session/created
60
+ // completes」),在监听器里直接切档必失败、会话照旧按记着的那档跑。派发一结束就可写,
61
+ // 所以挪到微任务里切:恢复完成、ACP 登记会话之前就切好,首条 prompt 拿到会话时档已经换掉。
62
+ ctx.on("session/created", (session) => queueMicrotask(() => sync(session)));
58
63
  try {
59
64
  for (const session of ctx.sessions.list()) sync(session);
60
65
  } catch (error) {
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 = 119;
7374
+ var PLUGIN_API_VERSION = 142;
7375
7375
 
7376
7376
  // src/index.ts
7377
7377
  import * as NodeOS6 from "node:os";
@@ -7466,6 +7466,7 @@ var DSH_CARD = {
7466
7466
  type: "string",
7467
7467
  "x-ycodium-form": {
7468
7468
  titleKey: "form.homePath.title",
7469
+ machineLocal: true,
7469
7470
  descriptionKey: "form.homePath.description",
7470
7471
  placeholderKey: "form.homePath.placeholder"
7471
7472
  }
@@ -7496,6 +7497,7 @@ var DSH_CARD = {
7496
7497
  };
7497
7498
 
7498
7499
  // src/dshInstance.ts
7500
+ import * as NodeCrypto4 from "node:crypto";
7499
7501
  import { modelSelectionStringOption, raceAbort as raceAbort2 } from "@ycodium-ai/plugin-api/executor";
7500
7502
  import { nodeStreamsFromHandle as nodeStreamsFromHandle2 } from "@ycodium-ai/plugin-api/process-stdin";
7501
7503
 
@@ -8494,7 +8496,15 @@ function parsePermissionRequest(params, known) {
8494
8496
  { fallbackStatus: "pending" }
8495
8497
  );
8496
8498
  const kind = toolCall?.kind ?? "unknown";
8497
- const detail = toolCall?.command ?? toolCall?.title ?? toolCall?.detail;
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;
8498
8508
  return {
8499
8509
  kind,
8500
8510
  ...detail ? { detail } : {},
@@ -8735,6 +8745,7 @@ function makeAcpRequestOpenedEvent(input2) {
8735
8745
  ...input2.detail ? { detail: input2.detail } : {},
8736
8746
  ...toolName ? { toolName } : {},
8737
8747
  args: input2.args,
8748
+ ...input2.statement !== void 0 ? { statement: input2.statement } : {},
8738
8749
  ...input2.options ? { options: input2.options } : {},
8739
8750
  ...input2.fileChanges ? { fileChanges: input2.fileChanges } : {},
8740
8751
  declineReasonRelay: "queued"
@@ -31293,7 +31304,7 @@ function ndJsonStream(output2, input2) {
31293
31304
  });
31294
31305
  return write;
31295
31306
  };
31296
- const readable2 = new ReadableStream({
31307
+ const readable = new ReadableStream({
31297
31308
  async start(controller) {
31298
31309
  const lines = new LineBuffer();
31299
31310
  const enqueueLine = async (lineBytes) => {
@@ -31369,7 +31380,7 @@ function ndJsonStream(output2, input2) {
31369
31380
  return writeJson(message);
31370
31381
  }
31371
31382
  });
31372
- return { readable: readable2, writable };
31383
+ return { readable, writable };
31373
31384
  }
31374
31385
 
31375
31386
  // ../../node_modules/.pnpm/@agentclientprotocol+sdk@1.4.0_zod@4.6.5/node_modules/@agentclientprotocol/sdk/dist/schema/guards.gen.js
@@ -34008,6 +34019,38 @@ function createPromptResults({
34008
34019
  return { add, receive, reject, stop, complete, hasInterrupted, forget, wait, finishUnreceived };
34009
34020
  }
34010
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
+
34011
34054
  // ../../packages/ycodium-acp-executor/src/executor/requests.ts
34012
34055
  function createExecutorRequests({
34013
34056
  emit,
@@ -34141,6 +34184,13 @@ function createExecutorRequests({
34141
34184
  return { outcome: { outcome: "selected", optionId } };
34142
34185
  }
34143
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);
34144
34194
  const requestId = randomId();
34145
34195
  const outcome = await new Promise((resolve4) => {
34146
34196
  const pending = {
@@ -34160,10 +34210,11 @@ function createExecutorRequests({
34160
34210
  turnId: shared.activeTurnId,
34161
34211
  requestId,
34162
34212
  permissionRequest,
34163
- detail: permissionRequest.detail,
34213
+ detail: statement.command ?? permissionRequest.detail,
34164
34214
  args: permissionRequest.toolCall?.data["rawInput"] ?? params.toolCall.rawInput,
34215
+ statement,
34165
34216
  options: acpApprovalOptions(params),
34166
- fileChanges: fileChangesFromAcpPermission(permissionRequest),
34217
+ fileChanges,
34167
34218
  source: "acp.jsonrpc",
34168
34219
  method: "session/request_permission",
34169
34220
  rawPayload: params
@@ -36307,11 +36358,10 @@ function dshOverlay(input2) {
36307
36358
  return `${lines.join("\n")}
36308
36359
  `;
36309
36360
  }
36310
- async function ensureDshOverlay(input2, tempRoot = NodeOS3.tmpdir()) {
36311
- const contents = dshOverlay(input2);
36361
+ async function ensureTempFile(tempRoot, extension, contents) {
36312
36362
  const hash2 = NodeCrypto3.createHash("sha256").update(contents).digest("hex").slice(0, 16);
36313
36363
  const directory = NodePath4.join(tempRoot, OVERLAY_DIR);
36314
- const file2 = NodePath4.join(directory, `${hash2}.yml`);
36364
+ const file2 = NodePath4.join(directory, `${hash2}${extension}`);
36315
36365
  const present = await NodeFSP.readFile(file2, "utf8").then(
36316
36366
  (existing) => existing === contents,
36317
36367
  () => false
@@ -36322,10 +36372,18 @@ async function ensureDshOverlay(input2, tempRoot = NodeOS3.tmpdir()) {
36322
36372
  await NodeFSP.writeFile(staging, contents, "utf8");
36323
36373
  await NodeFSP.rename(staging, file2).catch(async (error62) => {
36324
36374
  await NodeFSP.rm(staging, { force: true });
36325
- throw error62;
36375
+ const written = await NodeFSP.readFile(file2, "utf8").catch(() => void 0);
36376
+ if (written !== contents) throw error62;
36326
36377
  });
36327
36378
  return file2;
36328
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
+ }
36329
36387
  async function spawnDsh(host, launch, extraArgs, suffix = []) {
36330
36388
  const spawned = {
36331
36389
  program: launch.program,
@@ -36379,24 +36437,19 @@ function dumpConfigEntries(dump) {
36379
36437
  }
36380
36438
  return Array.isArray(entries) ? entries : [];
36381
36439
  }
36382
- async function readable(path) {
36383
- return NodeFSP.access(path).then(
36384
- () => true,
36385
- () => false
36386
- );
36387
- }
36388
36440
  async function dshOverlayPatchArgs(input2) {
36389
36441
  const { skills, host, launch } = input2;
36390
36442
  const skillsDir = skills !== void 0 && skills.names.length > 0 ? skills.skillsDir : void 0;
36391
- const modulePath = permissionSyncModulePath();
36392
- const expectPermissionSync = await readable(modulePath);
36393
- if (!expectPermissionSync) {
36394
- host.log.warn(
36395
- "dsh permission sync module is missing; switching the permission mode will not reach dsh"
36396
- );
36397
- }
36398
- if (skillsDir === void 0 && !expectPermissionSync) return [];
36399
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 [];
36400
36453
  const overlay = await ensureDshOverlay(
36401
36454
  {
36402
36455
  ...skillsDir === void 0 ? {} : { skillsDir },
@@ -36406,22 +36459,23 @@ async function dshOverlayPatchArgs(input2) {
36406
36459
  );
36407
36460
  if (skillsDir === void 0) return ["--patch", overlay];
36408
36461
  const key = `${launch.cwd}\0${overlay}\0${expectPermissionSync ? "sync" : "no-sync"}`;
36409
- let check2 = input2.verified.get(key);
36410
- if (check2 === void 0) {
36411
- check2 = overlayTakesEffect({
36412
- host,
36413
- launch,
36414
- overlay,
36415
- skillsDir,
36416
- expectPermissionSync
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)
36417
36474
  });
36418
- input2.verified.set(key, check2);
36419
36475
  }
36420
- if (await check2) return ["--patch", overlay];
36421
- host.log.warn(
36422
- "dsh did not take the session overlay; skills and permission switching stay on dsh's own defaults"
36423
- );
36476
+ return modulePath === void 0 ? [] : ["--patch", await ensureDshOverlay({ permissionSyncModule: modulePath }, input2.tempRoot)];
36424
36477
  } catch (error62) {
36478
+ input2.onPermissionSyncUnavailable?.();
36425
36479
  input2.verified.clear();
36426
36480
  host.log.warn(
36427
36481
  "dsh session overlay failed; skills and permission switching stay on dsh's own defaults",
@@ -36712,10 +36766,10 @@ async function probeDshModels(input2) {
36712
36766
  }
36713
36767
  let handshake;
36714
36768
  try {
36715
- const { readable: readable2, writable } = nodeStreamsFromHandle(handle);
36769
+ const { readable, writable } = nodeStreamsFromHandle(handle);
36716
36770
  handshake = await raceAbort(
36717
36771
  openAcpProbeHandshake({
36718
- readable: readable2,
36772
+ readable,
36719
36773
  writable,
36720
36774
  clientInfo: DSH_CLIENT_INFO,
36721
36775
  requestTimeoutMs: PROBE_REQUEST_TIMEOUT_MS
@@ -36772,7 +36826,24 @@ var readShellCommand = (title, rawInput) => {
36772
36826
  const command = input2["command"];
36773
36827
  return typeof command === "string" && command.trim() !== "" ? { command, input: input2 } : void 0;
36774
36828
  };
36775
- var dshPermissionRequestKind = (tool) => readShellCommand(tool.title, tool.rawInput) === void 0 ? void 0 : "execute";
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
+ };
36776
36847
  var slashed = (path) => path.replaceAll("\\", "/").replace(/\/{2,}/g, "/");
36777
36848
  var basename = (path) => {
36778
36849
  const normalized = slashed(path);
@@ -36863,6 +36934,37 @@ function dshOpenCommands(session) {
36863
36934
  };
36864
36935
  }
36865
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
+
36866
36968
  // src/subagents.ts
36867
36969
  var FALLBACK_TITLE = "DeepSeek Harness subagent";
36868
36970
  var TURN_ENDED_DESCRIPTION = "Turn ended. Individual agent status is unavailable.";
@@ -36918,6 +37020,82 @@ var dshToolSubagents = {
36918
37020
  })
36919
37021
  };
36920
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
+
36921
37099
  // src/dshInstance.ts
36922
37100
  var RESUME_SCHEMA_VERSION = 1;
36923
37101
  var yieldTick = () => new Promise((resolve4) => {
@@ -37012,7 +37190,27 @@ var createDshInstance = (config2, host) => {
37012
37190
  if (disposed) throw new Error("instance disposed");
37013
37191
  throwIfStartAborted(signal);
37014
37192
  }
37193
+ const resume = input2.discardResumeCursor === true ? void 0 : parseAcpResumeCursor(input2.resumeCursor, RESUME_SCHEMA_VERSION);
37015
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
+ });
37016
37214
  const launch = {
37017
37215
  program: recipe.binaryPath,
37018
37216
  args: tokenizeLaunchArgs(recipe.launchArgs),
@@ -37023,19 +37221,24 @@ var createDshInstance = (config2, host) => {
37023
37221
  skills: input2.skills,
37024
37222
  host,
37025
37223
  launch,
37026
- verified: overlayChecks
37224
+ verified: overlayChecks,
37225
+ onPermissionSyncUnavailable: permissionSync.unavailable
37027
37226
  });
37028
37227
  throwIfStartAborted(signal);
37029
37228
  const { handle, spawned } = await spawnDsh(host, launch, overlayArgs);
37030
- const { readable: readable2, writable, stderrTail } = nodeStreamsFromHandle2(handle);
37031
- const resume = input2.discardResumeCursor === true ? void 0 : parseAcpResumeCursor(input2.resumeCursor, RESUME_SCHEMA_VERSION);
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
+ });
37032
37235
  const requestedModelId = modelIdFromSelection(input2.modelSelection);
37033
37236
  const requestedEffort = modelSelectionStringOption(
37034
37237
  input2.modelSelection,
37035
37238
  DSH_EFFORT_OPTION_ID
37036
37239
  );
37037
37240
  const executor = createAcpExecutor({
37038
- readable: readable2,
37241
+ readable,
37039
37242
  writable,
37040
37243
  stderrTail,
37041
37244
  exited: handle.exited,
@@ -37055,6 +37258,8 @@ var createDshInstance = (config2, host) => {
37055
37258
  resumeMethod: "session/resume",
37056
37259
  hooks: {
37057
37260
  permissionRequestKind: dshPermissionRequestKind,
37261
+ permissionStatement: dshPermissionStatement,
37262
+ permissionFileChanges: dshPermissionFileChanges,
37058
37263
  // `subagent` / `subagent_fork` 由执行器的子 agent 跟踪接管,不再画成普通工具。
37059
37264
  toolSubagents: dshToolSubagents
37060
37265
  },
@@ -37074,6 +37279,7 @@ var createDshInstance = (config2, host) => {
37074
37279
  const started = await raceStartAbort(executor.start(), signal);
37075
37280
  await yieldTick();
37076
37281
  throwIfStartAborted(signal);
37282
+ if (resume !== void 0) permissionSync.sessionReady();
37077
37283
  const createdAt = nowIso();
37078
37284
  const resumeCursor = {
37079
37285
  schemaVersion: RESUME_SCHEMA_VERSION,
@@ -37103,6 +37309,7 @@ var createDshInstance = (config2, host) => {
37103
37309
  executor,
37104
37310
  handle,
37105
37311
  forwarding,
37312
+ permissionSync,
37106
37313
  spawned
37107
37314
  });
37108
37315
  host.log.info("session started", {
@@ -37125,6 +37332,7 @@ var createDshInstance = (config2, host) => {
37125
37332
  if (disposed) throw new Error("instance disposed");
37126
37333
  const booked = requireThread(input2.threadId);
37127
37334
  if (signal?.aborted) throw new Error("aborted");
37335
+ booked.permissionSync.beforeSendTurn();
37128
37336
  const onAbort = () => {
37129
37337
  void booked.executor.cancel(input2.expectedTurnId).catch(() => void 0);
37130
37338
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ycodium-ai/agent-dsh",
3
- "version": "0.2.4486",
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,8 +22,8 @@
22
22
  "esbuild": "0.28.1",
23
23
  "vite-plus": "0.2.2",
24
24
  "yaml": "^2.9.0",
25
- "ycodium-acp-executor": "0.2.0",
26
- "@ycodium-ai/plugin-api": "0.2.4486",
25
+ "@ycodium-ai/plugin-api": "0.2.5004",
26
+ "ycodium-acp-executor": "0.2.5004",
27
27
  "ycodium-executor-testing": "0.0.0"
28
28
  },
29
29
  "ycodium": {