@dsmm/dsmm 0.3.10 → 0.3.12
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 +1 -1
- package/agent-presets/dsmm-builder/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-code-search/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-coding/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-complex/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-creative/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-deep/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-documenting/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-frontend/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-oracle/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-planner/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-quick/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-research/agent.cordis.yml +0 -4
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +0 -4
- package/docs/agent-presets.md +5 -5
- package/docs/compatibility.md +10 -4
- package/docs/deferred-native-approval-risk.md +11 -1
- package/docs/design.md +15 -5
- package/docs/lsp.md +1 -1
- package/docs/model-routing.md +6 -6
- package/docs/native-permissions.md +5 -1
- package/docs/profiles.md +36 -5
- package/docs/roadmap.md +3 -3
- package/docs/runtime-recovery.md +5 -5
- package/docs/safety-guards.md +23 -5
- package/docs/settings-status.md +3 -3
- package/lib/child-capture.d.ts +9 -0
- package/lib/child-capture.js +29 -2
- package/lib/client/ProfilesSection.js +65 -13
- package/lib/client/RoleToolView-data.d.ts +4 -4
- package/lib/client/RoleToolView-data.js +3 -1
- package/lib/client/RoleToolView-locales.d.ts +7 -4
- package/lib/client/RoleToolView-locales.js +10 -6
- package/lib/client/RoleToolView.js +20 -5
- package/lib/client/SessionProfiles.d.ts +5 -1
- package/lib/client/SessionProfiles.js +13 -9
- package/lib/client/StructuredEditor.d.ts +32 -0
- package/lib/client/StructuredEditor.js +75 -23
- package/lib/client/controller.d.ts +10 -0
- package/lib/client/controller.js +44 -14
- package/lib/client/deployment-locales.js +1 -0
- package/lib/client/locales.d.ts +36 -0
- package/lib/client/locales.js +47 -17
- package/lib/client/permission-locales.js +8 -8
- package/lib/client/session-labels.js +4 -1
- package/lib/client/structured.d.ts +4 -0
- package/lib/client/structured.js +16 -1
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +19 -1
- package/lib/client.js +772 -312
- package/lib/command-approval.d.ts +50 -0
- package/lib/command-approval.js +148 -0
- package/lib/core-permissions.d.ts +2 -1
- package/lib/core-permissions.js +6 -3
- package/lib/guards.d.ts +2 -1
- package/lib/guards.js +45 -8
- package/lib/host-llm.js +3 -3
- package/lib/index.d.ts +1 -1
- package/lib/index.js +5 -3
- package/lib/model-routing.d.ts +3 -2
- package/lib/model-routing.js +28 -7
- package/lib/native-admission.d.ts +2 -0
- package/lib/native-admission.js +106 -34
- package/lib/permission-control.d.ts +5 -2
- package/lib/permission-control.js +46 -24
- package/lib/permission-controller.d.ts +2 -0
- package/lib/permission-controller.js +13 -8
- package/lib/permission-native-command.d.ts +2 -0
- package/lib/permission-native-command.js +9 -4
- package/lib/permission-native-rules.d.ts +2 -2
- package/lib/permission-native-rules.js +12 -10
- package/lib/profile-diagnostics.js +1 -1
- package/lib/profile-runtime.d.ts +11 -0
- package/lib/profile-runtime.js +48 -13
- package/lib/profile-store.d.ts +4 -1
- package/lib/profile-store.js +37 -14
- package/lib/profiles.js +2 -1
- package/lib/prompt-content.js +2 -2
- package/lib/role-control-rpc.js +18 -5
- package/lib/role-llm-runtime.js +10 -1
- package/lib/role-policy.d.ts +4 -3
- package/lib/role-policy.js +6 -6
- package/lib/role-providers.js +1 -0
- package/lib/runtime-recovery.d.ts +2 -2
- package/lib/runtime-recovery.js +7 -4
- package/lib/settings.d.ts +2 -0
- package/lib/settings.js +10 -0
- package/lib/shell-command.d.ts +16 -0
- package/lib/shell-command.js +443 -119
- package/package.json +1 -1
package/lib/native-admission.js
CHANGED
|
@@ -2,15 +2,19 @@ import { randomUUID } from "node:crypto";
|
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
import { getTraceable, symbols } from "@deepseek-ai/cordis";
|
|
4
4
|
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
5
|
-
import {
|
|
5
|
+
import { ReasoningEffortId } from "@deepseek-ai/dsh-llm";
|
|
6
|
+
import { SubagentError, delegationDepthOf, foldSubagentDescriptor } from "@deepseek-ai/dsh-subagent";
|
|
6
7
|
import { freezeSettings } from "./settings.js";
|
|
7
8
|
import { scopeLifetime } from "./lifetime.js";
|
|
8
|
-
import { sessionEvents } from "./session-scope.js";
|
|
9
|
-
import { scopeParentOf } from "./native-scope.js";
|
|
9
|
+
import { sessionEvents, childOwnedSessionEvents } from "./session-scope.js";
|
|
10
|
+
import { scopeParentOf, scopeOf } from "./native-scope.js";
|
|
10
11
|
import { DsmmProfileError } from "./profiles.js";
|
|
11
12
|
import { roleProviderName } from "./roles.js";
|
|
12
13
|
import { resolveRoleInvocation } from "./role-invocation.js";
|
|
13
14
|
import { resolvedModelParameterPolicy } from "./model-parameter-policy.js";
|
|
15
|
+
import { roleFromProviderName } from "./role-providers.js";
|
|
16
|
+
import { isDsmmRoleId } from "./roles.js";
|
|
17
|
+
import { latestNativeModelSelection } from "./role-routing.js";
|
|
14
18
|
/** Short-lived creation correlations and exact live bindings, never an execution queue. */
|
|
15
19
|
export class NativeAdmission {
|
|
16
20
|
ctx;
|
|
@@ -18,6 +22,8 @@ export class NativeAdmission {
|
|
|
18
22
|
policy;
|
|
19
23
|
lifetime = new AbortController();
|
|
20
24
|
pending = new Map();
|
|
25
|
+
providers = new Map();
|
|
26
|
+
registerProvider(provider) { this.providers.set(provider.name, provider); }
|
|
21
27
|
live = new WeakMap();
|
|
22
28
|
candidates = new WeakMap();
|
|
23
29
|
agents = new Set();
|
|
@@ -65,7 +71,7 @@ export class NativeAdmission {
|
|
|
65
71
|
profiles.release(agent);
|
|
66
72
|
policy.release(agent);
|
|
67
73
|
}, { global: true });
|
|
68
|
-
//
|
|
74
|
+
// Exact admitted and failed-admission objects stay guarded through retirement.
|
|
69
75
|
ctx.on("agent/pre-step", async (frame, next) => { await this.guardExecution(frame.agent); return next(); }, { global: true, prepend: true });
|
|
70
76
|
ctx.on("agent/request", async (frame, next) => { await this.guardExecution(frame.agent); return next(); }, { global: true, prepend: true });
|
|
71
77
|
ctx.on("tools/execute", async (exec, next) => {
|
|
@@ -148,6 +154,11 @@ export class NativeAdmission {
|
|
|
148
154
|
throw new SubagentError("Session configuration maintenance is in progress", "UNAUTHORIZED");
|
|
149
155
|
if (!this.isReady || !live || this.ctx.agents.get(agent.id) !== agent)
|
|
150
156
|
throw new SubagentError("No trusted live admission; create a new session", "UNAUTHORIZED");
|
|
157
|
+
if (this.ctx.get("sessions")?.get(agent.id) !== agent.session || agent.session.id !== agent.id || agent.session.header.id !== agent.id
|
|
158
|
+
|| scopeOf(agent.ctx) !== agent || original(agent.ctx.get("agents")) !== original(this.ctx.agents)
|
|
159
|
+
|| live.dependencies && this.dependencies(agent).some((value, index) => value !== live.dependencies[index])
|
|
160
|
+
|| live.provider && this.ctx.get("subagents")?.getProvider(live.provider.name) !== live.provider)
|
|
161
|
+
throw new SubagentError("Native admission dependencies changed", "UNAUTHORIZED");
|
|
151
162
|
if (live.preset !== agent.ctx.get("agentPresets")?.composedPreset(agent.ctx) || live.scopeParent !== scopeParentOf(agent))
|
|
152
163
|
throw new SubagentError("Preset composition changed; create a new session", "UNAUTHORIZED");
|
|
153
164
|
if (live.parent && (this.ctx.agents.get(live.parent.id) !== live.parent || !this.ctx.agents.isOwnedBy(agent.id, live.parent)))
|
|
@@ -393,7 +404,7 @@ export class NativeAdmission {
|
|
|
393
404
|
this.agentLifetimes.get(agent).signal.throwIfAborted();
|
|
394
405
|
if (!this.isReady || this.ctx.agents.get(agent.id) !== agent || this.live.get(agent) !== previous || scopeParentOf(agent) !== scopeParent)
|
|
395
406
|
throw new SubagentError("Composition changed during blank admission", "UNAUTHORIZED");
|
|
396
|
-
this.live.set(agent, Object.freeze({ ...previous, preset, scopeParent }));
|
|
407
|
+
this.live.set(agent, Object.freeze({ ...previous, preset, scopeParent, dependencies: this.dependencies(agent) }));
|
|
397
408
|
}
|
|
398
409
|
async created(agent, source, creationSignal) {
|
|
399
410
|
if (this.owns(agent)) {
|
|
@@ -401,21 +412,55 @@ export class NativeAdmission {
|
|
|
401
412
|
return;
|
|
402
413
|
}
|
|
403
414
|
const pending = this.pending.get(agent.id);
|
|
404
|
-
// Native resume, promotion and durable provider recovery do not restore a DSMM role grant.
|
|
405
|
-
if (source === "resume" && pending === undefined)
|
|
406
|
-
return;
|
|
407
415
|
if (pending && source !== "startup")
|
|
408
416
|
throw new SubagentError("Role creation requires its first pending call", "UNAUTHORIZED");
|
|
409
417
|
if (!this.isReady || !this.install)
|
|
410
418
|
throw new SubagentError("DSMM admission is initializing", "UNAUTHORIZED");
|
|
411
|
-
|
|
419
|
+
let signal = AbortSignal.any([...creationSignal ? [creationSignal] : [], this.lifetime.signal]);
|
|
412
420
|
signal.throwIfAborted();
|
|
413
421
|
const parents = this.ctx.agents.list().filter(parent => parent !== agent && this.ctx.agents.isOwnedBy(agent.id, parent));
|
|
414
422
|
const parent = parents[0], preset = agent.ctx.get("agentPresets")?.composedPreset(agent.ctx), presetScope = scopeParentOf(agent);
|
|
415
|
-
if (parents.length > 1 || this.ctx.agents.get(agent.id) !== agent)
|
|
423
|
+
if (parents.length > 1 || this.ctx.agents.get(agent.id) !== agent || this.ctx.get("sessions")?.get(agent.id) !== agent.session
|
|
424
|
+
|| agent.session.id !== agent.id || agent.session.header.id !== agent.id || scopeOf(agent.ctx) !== agent
|
|
425
|
+
|| original(agent.ctx.get("agents")) !== original(this.ctx.agents))
|
|
416
426
|
throw new SubagentError("Invalid native ownership", "UNAUTHORIZED");
|
|
417
|
-
|
|
427
|
+
const own = childOwnedSessionEvents(agent.session);
|
|
428
|
+
const descriptor = foldSubagentDescriptor(own);
|
|
429
|
+
if (!pending && parent && !this.owns(parent)) {
|
|
430
|
+
if (descriptor && roleFromProviderName(descriptor.provider) || isDsmmRoleId(preset)
|
|
431
|
+
|| source === "resume" && await this.profiles.readChildIdentity(agent.id, parent.id))
|
|
432
|
+
throw new SubagentError("Role continuation requires an admitted parent", "UNAUTHORIZED");
|
|
418
433
|
return;
|
|
434
|
+
}
|
|
435
|
+
if (!parent && (!this.ctx.agents.roots().includes(agent) || agent.session.header.origin === "subagent" || descriptor !== undefined))
|
|
436
|
+
throw new SubagentError("Child requires its native parent", "UNAUTHORIZED");
|
|
437
|
+
this.agentLifetimes.set(agent, new AbortController());
|
|
438
|
+
signal = AbortSignal.any([signal, this.agentLifetimes.get(agent).signal, ...parent ? [this.agentLifetimes.get(parent).signal] : []]);
|
|
439
|
+
scopeLifetime(agent.ctx, "dsmm: retire exact Agent work", () => { void this.retireAgent(agent).catch(() => { }); });
|
|
440
|
+
agent.ctx.effect(() => async () => {
|
|
441
|
+
try {
|
|
442
|
+
await this.retireAgent(agent);
|
|
443
|
+
}
|
|
444
|
+
finally {
|
|
445
|
+
this.live.delete(agent);
|
|
446
|
+
this.candidates.delete(agent);
|
|
447
|
+
this.agents.delete(agent);
|
|
448
|
+
this.profiles.release(agent);
|
|
449
|
+
this.policy.release(agent);
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
const dependencies = this.dependencies(agent);
|
|
453
|
+
const parentAdmission = parent ? this.assert(parent) : undefined;
|
|
454
|
+
const check = () => {
|
|
455
|
+
signal.throwIfAborted();
|
|
456
|
+
this.agentLifetimes.get(agent).signal.throwIfAborted();
|
|
457
|
+
if (!this.isReady || this.ctx.agents.get(agent.id) !== agent || this.ctx.get("sessions")?.get(agent.id) !== agent.session
|
|
458
|
+
|| scopeOf(agent.ctx) !== agent || original(agent.ctx.get("agents")) !== original(this.ctx.agents)
|
|
459
|
+
|| this.dependencies(agent).some((value, index) => value !== dependencies[index]) || scopeParentOf(agent) !== presetScope || preset !== agent.ctx.get("agentPresets")?.composedPreset(agent.ctx)
|
|
460
|
+
|| parent && (this.assert(parent) !== parentAdmission || !this.ctx.agents.isOwnedBy(agent.id, parent)))
|
|
461
|
+
throw new SubagentError("Activation owner changed", "UNAUTHORIZED");
|
|
462
|
+
};
|
|
463
|
+
let continuation, independent = false, continuationProvider;
|
|
419
464
|
let admission;
|
|
420
465
|
if (parent) {
|
|
421
466
|
const parentAdmission = this.assert(parent), controlled = this.policy.identity(parent).role !== undefined;
|
|
@@ -430,6 +475,46 @@ export class NativeAdmission {
|
|
|
430
475
|
throw new SubagentError("Child exceeds depth ceiling", "UNAUTHORIZED");
|
|
431
476
|
admission = pending.admission;
|
|
432
477
|
}
|
|
478
|
+
else if (source === "resume") {
|
|
479
|
+
if (descriptor?.mode !== "continuable")
|
|
480
|
+
throw new SubagentError("Native child is not continuable", "NOT_RESUMABLE");
|
|
481
|
+
const subagents = this.ctx.get("subagents");
|
|
482
|
+
const rows = await subagents.listChildren(parent.id, signal);
|
|
483
|
+
check();
|
|
484
|
+
const row = rows.find(row => row.id === agent.id);
|
|
485
|
+
if (!row || row.mode !== "continuable")
|
|
486
|
+
throw new SubagentError("Native child catalog mismatch", "UNAUTHORIZED");
|
|
487
|
+
const metadata = await this.profiles.readChildIdentity(agent.id, parent.id);
|
|
488
|
+
check();
|
|
489
|
+
const ownPreset = own.find(event => event.type === "agent-preset/selected" || event.type === "subagent/descriptor");
|
|
490
|
+
independent = ownPreset?.type === "agent-preset/selected";
|
|
491
|
+
if (!independent && (preset !== parent.ctx.get("agentPresets")?.composedPreset(parent.ctx) || presetScope !== scopeParentOf(parent)))
|
|
492
|
+
throw new SubagentError("Inherited composition changed", "UNAUTHORIZED");
|
|
493
|
+
const nativeRole = roleFromProviderName(descriptor.provider) ?? (independent && isDsmmRoleId(preset) ? preset : undefined);
|
|
494
|
+
if (metadata && nativeRole && metadata.role !== nativeRole)
|
|
495
|
+
throw new SubagentError("Child role identity conflict", "UNAUTHORIZED");
|
|
496
|
+
const role = nativeRole ?? metadata?.role;
|
|
497
|
+
if (!role) {
|
|
498
|
+
admission = await this.profiles.prepareChild(agent, parentAdmission, signal);
|
|
499
|
+
check();
|
|
500
|
+
}
|
|
501
|
+
else {
|
|
502
|
+
continuationProvider = this.providers.get(roleProviderName(role));
|
|
503
|
+
const currentProvider = continuationProvider && subagents.getProvider(continuationProvider.name);
|
|
504
|
+
if (!continuationProvider || !currentProvider || original(currentProvider) !== original(continuationProvider))
|
|
505
|
+
throw new SubagentError("Role provider is unavailable", "UNAUTHORIZED");
|
|
506
|
+
admission = await this.profiles.prepareChild(agent, parentAdmission, signal, metadata);
|
|
507
|
+
check();
|
|
508
|
+
if (!admission.settings.modules.deepwork.enabled || !admission.settings.roles[role])
|
|
509
|
+
throw new SubagentError("Role is disabled", "UNAUTHORIZED");
|
|
510
|
+
this.policy.assertDelegation(parent, role);
|
|
511
|
+
const manual = latestNativeModelSelection(agent)?.route;
|
|
512
|
+
continuation = await resolveRoleInvocation(parent, role, admission.settings, signal, metadata ? { level: metadata.level } : {}, manual === undefined ? undefined : {
|
|
513
|
+
provider: manual.provider, model: manual.model, ...(manual.reasoningEffort === undefined ? {} : { reasoningEffort: ReasoningEffortId(manual.reasoningEffort) })
|
|
514
|
+
}, resolvedModelParameterPolicy(admission));
|
|
515
|
+
check();
|
|
516
|
+
}
|
|
517
|
+
}
|
|
433
518
|
else {
|
|
434
519
|
if (controlled || preset?.startsWith("dsmm-"))
|
|
435
520
|
throw new SubagentError("Use an admitted DSMM role tool", "UNAUTHORIZED");
|
|
@@ -440,22 +525,9 @@ export class NativeAdmission {
|
|
|
440
525
|
if (pending)
|
|
441
526
|
throw new SubagentError("Missing exact parent", "UNAUTHORIZED");
|
|
442
527
|
admission = await this.profiles.prepareRoot(agent, signal);
|
|
528
|
+
check();
|
|
443
529
|
this.policy.validateRootRole(agent, admission);
|
|
444
530
|
}
|
|
445
|
-
this.agentLifetimes.set(agent, new AbortController());
|
|
446
|
-
scopeLifetime(agent.ctx, "dsmm: retire exact Agent work", () => { void this.retireAgent(agent).catch(() => { }); });
|
|
447
|
-
agent.ctx.effect(() => async () => {
|
|
448
|
-
try {
|
|
449
|
-
await this.retireAgent(agent);
|
|
450
|
-
}
|
|
451
|
-
finally {
|
|
452
|
-
this.live.delete(agent);
|
|
453
|
-
this.candidates.delete(agent);
|
|
454
|
-
this.agents.delete(agent);
|
|
455
|
-
this.profiles.release(agent);
|
|
456
|
-
this.policy.release(agent);
|
|
457
|
-
}
|
|
458
|
-
});
|
|
459
531
|
this.candidates.set(agent, admission);
|
|
460
532
|
this.agents.add(agent);
|
|
461
533
|
// These registrations belong to the Agent, not the plugin owner. Revocation remains effective after unload.
|
|
@@ -473,21 +545,21 @@ export class NativeAdmission {
|
|
|
473
545
|
try {
|
|
474
546
|
if (pending)
|
|
475
547
|
this.policy.bindChild(agent, parent, admission, pending.invocation, pending.maxDepth, pending.toolFilter);
|
|
548
|
+
else if (continuation)
|
|
549
|
+
this.policy.bindChild(agent, parent, admission, continuation, this.ctx.get("subagents").resolveMaxDepth(admission.settings.subagents.maxDepth), this.policy.visibleToolCeiling(parent), independent);
|
|
476
550
|
else if (parent)
|
|
477
|
-
this.policy.bindInheritedChild(agent, parent, admission);
|
|
551
|
+
this.policy.bindInheritedChild(agent, parent, admission, source === "resume");
|
|
478
552
|
await this.install(agent, this.getter(agent));
|
|
479
|
-
|
|
480
|
-
this.
|
|
553
|
+
check();
|
|
554
|
+
await this.profiles.revalidateActivation(admission);
|
|
555
|
+
check();
|
|
481
556
|
if (pending)
|
|
482
557
|
this.check(pending);
|
|
483
|
-
if (
|
|
484
|
-
|
|
485
|
-
if (!this.isReady || this.ctx.agents.get(agent.id) !== agent || preset !== agent.ctx.get("agentPresets")?.composedPreset(agent.ctx)
|
|
486
|
-
|| presetScope !== scopeParentOf(agent) || parent && !this.ctx.agents.isOwnedBy(agent.id, parent))
|
|
487
|
-
throw new SubagentError("Agent changed during initialization", "UNAUTHORIZED");
|
|
558
|
+
if (continuationProvider && this.ctx.get("subagents").getProvider(continuationProvider.name) !== continuationProvider)
|
|
559
|
+
throw new SubagentError("Role provider changed", "UNAUTHORIZED");
|
|
488
560
|
this.profiles.publish(agent, admission);
|
|
489
561
|
const published = this.profiles.admission(agent);
|
|
490
|
-
this.live.set(agent, Object.freeze({ admission: published, preset, scopeParent: scopeParentOf(agent), parent, invocation: pending?.invocation }));
|
|
562
|
+
this.live.set(agent, Object.freeze({ admission: published, preset, scopeParent: scopeParentOf(agent), parent, invocation: pending?.invocation ?? continuation, dependencies, provider: pending?.provider ?? continuationProvider }));
|
|
491
563
|
if (pending)
|
|
492
564
|
this.pending.delete(agent.id);
|
|
493
565
|
}
|
|
@@ -3,6 +3,8 @@ import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
|
3
3
|
import type { PreToolDecision, ToolDefinition, ToolExecution, ToolRunContext } from "@deepseek-ai/dsh-tools";
|
|
4
4
|
import type { NativeCommandEntry } from "./permission-settings.js";
|
|
5
5
|
import type { NativePermissionMode } from "./permission-native-access.js";
|
|
6
|
+
import { CommandApprovals } from "./command-approval.js";
|
|
7
|
+
import type { CommandApprovalScope, CommandRuleContribution } from "./command-approval.js";
|
|
6
8
|
export { PermissionRefusal } from "./permission-errors.js";
|
|
7
9
|
export interface PermissionExecutionAuthority {
|
|
8
10
|
readonly agent: Agent;
|
|
@@ -55,8 +57,9 @@ export declare class PermissionControl {
|
|
|
55
57
|
private readonly bindings;
|
|
56
58
|
private readonly requests;
|
|
57
59
|
private readonly execution;
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
readonly commandApprovals: CommandApprovals;
|
|
61
|
+
constructor(ctx: Context, collaborators: PermissionControlCollaborators, approvals?: CommandApprovals);
|
|
62
|
+
compose(exec: Readonly<ToolExecution>, registration: PermissionRegistration, entry: NativeCommandEntry | undefined, action: "inherit" | "allow" | "ask", next: () => Promise<PreToolDecision>, cwd: string, simple?: boolean, contributions?: readonly CommandRuleContribution[], source?: CommandApprovalScope): Promise<PreToolDecision>;
|
|
60
63
|
private composeDecision;
|
|
61
64
|
private checkIntegrity;
|
|
62
65
|
guard(exec: Readonly<ToolExecution>): string | undefined;
|
|
@@ -4,6 +4,7 @@ import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
|
4
4
|
import { TOOL_ABORTED } from "@deepseek-ai/dsh-tools";
|
|
5
5
|
import { PermissionRefusal, permissionOutcome } from "./permission-errors.js";
|
|
6
6
|
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
7
|
+
import { CommandApprovals } from "./command-approval.js";
|
|
7
8
|
export { PermissionRefusal } from "./permission-errors.js";
|
|
8
9
|
export function permissionOriginal(value) { return Reflect.get(value, symbols.original) ?? value; }
|
|
9
10
|
/** Explicitly audited DSMM approval adapters retain identity through the patched dispatcher. */
|
|
@@ -24,12 +25,14 @@ export class PermissionControl {
|
|
|
24
25
|
bindings = new Map();
|
|
25
26
|
requests = new WeakMap();
|
|
26
27
|
execution = new AsyncLocalStorage();
|
|
27
|
-
|
|
28
|
+
commandApprovals;
|
|
29
|
+
constructor(ctx, collaborators, approvals) {
|
|
28
30
|
this.ctx = ctx;
|
|
29
31
|
this.collaborators = collaborators;
|
|
32
|
+
this.commandApprovals = approvals ?? new CommandApprovals(ctx);
|
|
30
33
|
}
|
|
31
|
-
async compose(exec, registration, entry, action, next, cwd, simple = false) {
|
|
32
|
-
const previous = this.bindings.get(exec
|
|
34
|
+
async compose(exec, registration, entry, action, next, cwd, simple = false, contributions = [], source = {}) {
|
|
35
|
+
const previous = this.bindings.get(exec);
|
|
33
36
|
if (simple && previous?.simple) {
|
|
34
37
|
this.checkIntegrity(previous);
|
|
35
38
|
return this.composeDecision(previous, next, false);
|
|
@@ -54,22 +57,30 @@ export class PermissionControl {
|
|
|
54
57
|
const args = exec.arguments;
|
|
55
58
|
const officialMode = !nativeOnly && (args.sandbox_permissions === "workspace-write" || args.sandbox_permissions === "danger-full-access") ? args.sandbox_permissions : undefined;
|
|
56
59
|
const standing = registration.standingMode(exec);
|
|
57
|
-
const target = simple ? "danger-full-access" : officialMode ?? (entry === undefined ? undefined : isSandboxWidening(entry.sandboxMode, standing) ? entry.sandboxMode : standing ?? entry.sandboxMode);
|
|
58
|
-
const
|
|
60
|
+
const target = simple ? "danger-full-access" : officialMode ?? (entry === undefined ? undefined : isSandboxWidening(entry.sandboxMode, standing) ? entry.sandboxMode : entry.mode === "allow" ? standing ?? entry.sandboxMode : undefined);
|
|
61
|
+
const rules = simple || nativeOnly || contributions.length === 0 ? undefined : this.commandApprovals.capture(exec, contributions, {
|
|
62
|
+
...source, deferredCommit: true, owner: authority?.owner, ownerGeneration: authority?.ownerGeneration, realm: authority?.realm, assertCurrent: () => integrity.assertCurrent(),
|
|
63
|
+
});
|
|
64
|
+
const ask = !simple && (rules === undefined ? action === "ask" || entry?.mode === "ask" : rules.missing.length > 0);
|
|
65
|
+
const ruleNames = (rules?.missing ?? contributions).map(rule => {
|
|
66
|
+
const semantics = rule.semantics;
|
|
67
|
+
return semantics !== null && typeof semantics === "object" && "id" in semantics ? `${rule.kind}:${String(semantics.id)}` : rule.kind;
|
|
68
|
+
});
|
|
69
|
+
const reason = `DSMM command: ${String(args.command)}\nWorking directory: ${cwd}\n${ruleNames.length === 0 ? "" : `Command rules: ${ruleNames.join(", ")}\n`}Sandbox mode: ${target ?? "native standing policy"}. ${target === "danger-full-access" ? "Command execution may write outside the workspace to any OS-permitted location; this is not a cache-only or path-whitelist grant." : "Exact native tool invocation under the stated native sandbox policy."}`;
|
|
59
70
|
const lifetime = new AbortController();
|
|
60
|
-
const binding = { exec, args: exec.arguments, agent: exec.agent, callId: exec.callId, name: exec.name,
|
|
71
|
+
const binding = { exec, token: exec.token, session: exec.agent?.session, args: exec.arguments, agent: exec.agent, callId: exec.callId, name: exec.name,
|
|
61
72
|
registration, root: authority?.root, integrity, entry, officialMode, simple,
|
|
62
73
|
target: target === "workspace-write" || target === "danger-full-access" ? target : undefined,
|
|
63
|
-
reason, ask
|
|
74
|
+
reason, ask, rules, lifetime,
|
|
64
75
|
signal: AbortSignal.any([exec.signal, lifetime.signal, this.lifetime.signal,
|
|
65
76
|
...integrity.signal === undefined ? [] : [integrity.signal], ...registration.signal === undefined ? [] : [registration.signal]]),
|
|
66
|
-
entered: false, nativeRequest: false };
|
|
77
|
+
entered: false, nativeRequest: false, askSatisfied: !ask };
|
|
67
78
|
this.checkIntegrity(binding);
|
|
68
|
-
this.bindings.set(exec
|
|
79
|
+
this.bindings.set(exec, binding);
|
|
69
80
|
return this.composeDecision(binding, next, nativeOnly);
|
|
70
81
|
}
|
|
71
82
|
async composeDecision(binding, next, nativeOnly) {
|
|
72
|
-
const { exec, registration,
|
|
83
|
+
const { exec, registration, reason } = binding;
|
|
73
84
|
const downstream = await next();
|
|
74
85
|
if (exec.signal.aborted)
|
|
75
86
|
return { kind: "cancel" };
|
|
@@ -78,13 +89,13 @@ export class PermissionControl {
|
|
|
78
89
|
return downstream;
|
|
79
90
|
if (nativeOnly)
|
|
80
91
|
return downstream;
|
|
81
|
-
const needsAsk = downstream.kind === "ask" || binding.ask && (entry === undefined || officialMode !== undefined);
|
|
92
|
+
const needsAsk = downstream.kind === "ask" || binding.ask && (binding.entry === undefined || binding.officialMode !== undefined);
|
|
82
93
|
if (!needsAsk)
|
|
83
94
|
return downstream;
|
|
84
95
|
const reasons = [downstream.kind === "ask" ? downstream.reason : undefined, reason].filter(Boolean).join("\n");
|
|
85
96
|
const displayReason = Object.freeze({ en: reasons, zh: reasons,
|
|
86
97
|
...downstream.kind === "ask" && downstream.displayReason !== undefined ? Object.fromEntries(Object.entries(downstream.displayReason).map(([locale, text]) => [locale, `${text}\n${reason}`])) : {} });
|
|
87
|
-
if (binding.target === undefined)
|
|
98
|
+
if (binding.target === undefined && !binding.ask)
|
|
88
99
|
return { kind: "ask", reason: reasons, displayReason };
|
|
89
100
|
const approval = registration.approval();
|
|
90
101
|
if (approval === undefined || exec.agent === undefined)
|
|
@@ -96,6 +107,8 @@ export class PermissionControl {
|
|
|
96
107
|
this.checkIntegrity(binding);
|
|
97
108
|
if (outcome !== "allowed-once")
|
|
98
109
|
return { kind: "deny", reason: `Native command approval ${outcome}.` };
|
|
110
|
+
binding.rules?.resolved(outcome);
|
|
111
|
+
binding.askSatisfied = true;
|
|
99
112
|
binding.approvedTarget = binding.target;
|
|
100
113
|
return { kind: "allow" };
|
|
101
114
|
}
|
|
@@ -103,15 +116,16 @@ export class PermissionControl {
|
|
|
103
116
|
if (binding.signal.aborted || binding.exec.signal.aborted)
|
|
104
117
|
throw new HarnessError("Permission-controlled call cancelled.", TOOL_ABORTED);
|
|
105
118
|
const { exec, registration } = binding;
|
|
106
|
-
if (exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
119
|
+
if (exec.token !== binding.token || exec.agent?.session !== binding.session || exec.arguments !== binding.args || exec.agent !== binding.agent || exec.callId !== binding.callId || exec.name !== binding.name
|
|
107
120
|
|| !registration.active || !registration.unchanged() || registration.definition.execute !== (registration.wrapper ?? registration.body)
|
|
108
121
|
|| this.ctx.tools.get(binding.name, binding.agent) !== registration.registered)
|
|
109
122
|
throw new PermissionRefusal("stale");
|
|
110
123
|
binding.integrity.assertCurrent();
|
|
111
124
|
registration.assertIntegrity?.(exec);
|
|
125
|
+
binding.rules?.assertCurrent();
|
|
112
126
|
}
|
|
113
127
|
guard(exec) {
|
|
114
|
-
const binding = this.bindings.get(exec
|
|
128
|
+
const binding = this.bindings.get(exec);
|
|
115
129
|
if (binding === undefined)
|
|
116
130
|
return undefined;
|
|
117
131
|
try {
|
|
@@ -138,7 +152,7 @@ export class PermissionControl {
|
|
|
138
152
|
return owned.allow ? "allowed-once" : permissionOutcome(next, owned.binding.signal, "cancelled");
|
|
139
153
|
}
|
|
140
154
|
isSimple(exec) {
|
|
141
|
-
const binding = this.bindings.get(exec
|
|
155
|
+
const binding = this.bindings.get(exec);
|
|
142
156
|
if (binding?.simple !== true)
|
|
143
157
|
return false;
|
|
144
158
|
this.checkIntegrity(binding);
|
|
@@ -146,7 +160,7 @@ export class PermissionControl {
|
|
|
146
160
|
}
|
|
147
161
|
pending(registration) { return [...this.bindings.values()].some(binding => binding.registration === registration); }
|
|
148
162
|
async run(exec, args, registration, body) {
|
|
149
|
-
const binding = this.bindings.get(exec
|
|
163
|
+
const binding = this.bindings.get(exec);
|
|
150
164
|
if (binding === undefined && registration.simpleOnly)
|
|
151
165
|
return body(exec.signal, args);
|
|
152
166
|
if (binding === undefined || binding.registration !== registration || binding.entered || args !== binding.args)
|
|
@@ -155,7 +169,7 @@ export class PermissionControl {
|
|
|
155
169
|
this.checkIntegrity(binding);
|
|
156
170
|
binding.entered = true;
|
|
157
171
|
try {
|
|
158
|
-
if (binding.entry !== undefined && binding.officialMode === undefined && !nativeStandingFullAccess(this.ctx, exec.agent)) {
|
|
172
|
+
if (binding.entry !== undefined && (binding.target !== undefined || !binding.askSatisfied) && binding.officialMode === undefined && !nativeStandingFullAccess(this.ctx, exec.agent)) {
|
|
159
173
|
if (binding.approvedTarget === undefined) {
|
|
160
174
|
const approval = registration.approval();
|
|
161
175
|
if (approval === undefined || exec.agent === undefined)
|
|
@@ -166,10 +180,13 @@ export class PermissionControl {
|
|
|
166
180
|
throw new HarnessError("Native permission request cancelled.", TOOL_ABORTED);
|
|
167
181
|
if (outcome !== "allowed-once")
|
|
168
182
|
throw new PermissionRefusal(outcome === "unavailable" ? "unavailable" : "denied");
|
|
183
|
+
binding.rules?.resolved(outcome);
|
|
184
|
+
binding.askSatisfied = true;
|
|
169
185
|
binding.approvedTarget = binding.target;
|
|
170
186
|
}
|
|
171
187
|
binding.mode = binding.approvedTarget;
|
|
172
188
|
}
|
|
189
|
+
this.commandApprovals.commit(binding.exec);
|
|
173
190
|
return await this.execution.run(binding, () => body(binding.signal, binding.simple ? Object.freeze({ ...args,
|
|
174
191
|
sandbox_permissions: "danger-full-access", justification: binding.reason }) : args));
|
|
175
192
|
}
|
|
@@ -204,10 +221,14 @@ export class PermissionControl {
|
|
|
204
221
|
}
|
|
205
222
|
const actual = { ...request, reason: [request.reason, binding.reason].filter(Boolean).join("\n") };
|
|
206
223
|
const covers = binding.entry !== undefined && (binding.entry.sandboxMode === "danger-full-access" || binding.officialMode === "workspace-write");
|
|
207
|
-
|
|
224
|
+
const outcome = await this.request(binding, actual, service, covers && binding.entry.mode === "allow" && !binding.ask);
|
|
225
|
+
binding.rules?.resolved(outcome);
|
|
226
|
+
if (outcome === "allowed-once")
|
|
227
|
+
this.commandApprovals.commit(binding.exec);
|
|
228
|
+
return outcome;
|
|
208
229
|
}
|
|
209
230
|
approvedTarget(exec) {
|
|
210
|
-
const binding = this.bindings.get(exec
|
|
231
|
+
const binding = this.bindings.get(exec);
|
|
211
232
|
if (binding === undefined)
|
|
212
233
|
return undefined;
|
|
213
234
|
this.checkIntegrity(binding);
|
|
@@ -224,20 +245,21 @@ export class PermissionControl {
|
|
|
224
245
|
return mode;
|
|
225
246
|
}
|
|
226
247
|
finish(exec) {
|
|
227
|
-
const binding = this.bindings.get(exec
|
|
248
|
+
const binding = this.bindings.get(exec);
|
|
228
249
|
if (binding !== undefined) {
|
|
229
250
|
binding.mode = undefined;
|
|
230
251
|
binding.approvedTarget = undefined;
|
|
231
252
|
binding.lifetime.abort();
|
|
232
253
|
}
|
|
233
|
-
this.bindings.delete(exec
|
|
254
|
+
this.bindings.delete(exec);
|
|
255
|
+
this.commandApprovals.finish(exec);
|
|
234
256
|
}
|
|
235
|
-
revokePolicy() { }
|
|
257
|
+
revokePolicy() { this.commandApprovals.invalidate(); }
|
|
236
258
|
revokeRegistration(registration) { registration.active = false; }
|
|
237
|
-
revokeAgent(agent) { for (const binding of this.bindings.values())
|
|
259
|
+
revokeAgent(agent) { this.commandApprovals.revokeAgent(agent); for (const binding of this.bindings.values())
|
|
238
260
|
if (binding.agent === agent || binding.root === agent)
|
|
239
261
|
this.finish(binding.exec); }
|
|
240
|
-
retire() { this.lifetime.abort(); for (const binding of this.bindings.values()) {
|
|
262
|
+
retire() { this.lifetime.abort(); this.commandApprovals.invalidate(); for (const binding of this.bindings.values()) {
|
|
241
263
|
binding.lifetime.abort();
|
|
242
264
|
binding.mode = undefined;
|
|
243
265
|
binding.approvedTarget = undefined;
|
|
@@ -4,6 +4,7 @@ import type { ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
|
4
4
|
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
5
5
|
import { PermissionControl } from "./permission-control.js";
|
|
6
6
|
import type { PermissionControlCollaborators } from "./permission-control.js";
|
|
7
|
+
import type { CommandApprovals } from "./command-approval.js";
|
|
7
8
|
import type { PermissionShellIdentity } from "./permission-shell.js";
|
|
8
9
|
import type { NativePermissionCapabilityView, NativePermissionFileSystem, NativePermissionToolIdentity } from "./permission-native-rules.js";
|
|
9
10
|
import type { PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
@@ -13,6 +14,7 @@ export type ManagedPermissionTool = "fs" | "fs-search" | "web";
|
|
|
13
14
|
type NativeToolKind = Exclude<NativePermissionToolIdentity["kind"], "shell">;
|
|
14
15
|
export declare const PERMISSION_CONTROLLER_INJECT: readonly ["tools", "agents"];
|
|
15
16
|
export interface PermissionControllerOptions {
|
|
17
|
+
readonly commandApprovals?: CommandApprovals;
|
|
16
18
|
/** The existing live Core owner/admission/Root/realm/run facts, not serialized settings or a ready boolean. */
|
|
17
19
|
readonly authority: PermissionControlCollaborators;
|
|
18
20
|
readonly rules: PermissionRulesRuntimeSync;
|
|
@@ -3,7 +3,7 @@ import { HarnessError } from "@deepseek-ai/dsh-llm";
|
|
|
3
3
|
import { TOOL_ABORTED } from "@deepseek-ai/dsh-tools";
|
|
4
4
|
import { isSandboxWidening, PermissionControl, PermissionRefusal, permissionApprovalAdapter, permissionOriginal } from "./permission-control.js";
|
|
5
5
|
import { classifyPermissionShell } from "./permission-shell.js";
|
|
6
|
-
import {
|
|
6
|
+
import { nativeCommandMatches, simpleCommandMatch, simpleShellCommand, simpleShellDialect } from "./permission-native-command.js";
|
|
7
7
|
import { NATIVE_PERMISSION_CAPABILITIES, registerNativePermissionRules } from "./permission-native-rules.js";
|
|
8
8
|
import { nativeStandingFullAccess } from "./permission-native-access.js";
|
|
9
9
|
export const PERMISSION_CONTROLLER_INJECT = ["tools", "agents"];
|
|
@@ -62,7 +62,7 @@ export class DsmmPermissionController extends Service {
|
|
|
62
62
|
throw new PermissionRefusal("stale");
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
|
-
this.permissions = new PermissionControl(ctx, authority);
|
|
65
|
+
this.permissions = new PermissionControl(ctx, authority, options.commandApprovals);
|
|
66
66
|
if (this.rules.status().mounted) {
|
|
67
67
|
registerNativePermissionRules(ctx, {
|
|
68
68
|
runtime: this.rules,
|
|
@@ -92,7 +92,7 @@ export class DsmmPermissionController extends Service {
|
|
|
92
92
|
return { signal: current.signal, assertCurrent: () => options.authority.assertCurrent(current, exec) };
|
|
93
93
|
},
|
|
94
94
|
assertCurrent: exec => authority.assertCurrent(authority.current(exec), exec),
|
|
95
|
-
managedShellDecision: async (exec, action, downstream, snapshot) => {
|
|
95
|
+
managedShellDecision: async (exec, action, downstream, snapshot, asks) => {
|
|
96
96
|
const definition = ctx.tools.get(exec.name, exec.agent), managed = definition === undefined ? undefined : this.registrations.get(definition);
|
|
97
97
|
if (managed === undefined)
|
|
98
98
|
throw new PermissionRefusal("stale");
|
|
@@ -100,14 +100,19 @@ export class DsmmPermissionController extends Service {
|
|
|
100
100
|
const full = nativeStandingFullAccess(ctx, exec.agent);
|
|
101
101
|
if (full)
|
|
102
102
|
return this.permissions.compose(exec, managed.registration, undefined, "inherit", downstream, workspace);
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
103
|
+
const source = snapshot ?? this.rules.getPolicy(), policy = source.policy;
|
|
104
|
+
const entries = nativeCommandMatches(policy.nativeCommands, managed.kind, managed.shell, exec.arguments, workspace);
|
|
105
|
+
if (entries === "ambiguous")
|
|
106
106
|
managed.scope.logger.warn("Ambiguous native command sandbox modes; retaining native execution policy.");
|
|
107
|
-
|
|
107
|
+
const entry = entries === "ambiguous" ? undefined : entries.find(entry => entry.mode === "ask") ?? entries[0];
|
|
108
|
+
if (entry !== undefined && managed.scope.get("shell")?.sandboxMode === undefined)
|
|
108
109
|
return { kind: "deny", reason: "Native command sandbox enhancement is unavailable in this executor." };
|
|
109
110
|
const operation = classifyPermissionShell(managed.shell, exec.arguments, workspace, exec);
|
|
110
|
-
|
|
111
|
+
const contributions = [
|
|
112
|
+
...asks.map(rule => ({ kind: "shell", semantics: rule })),
|
|
113
|
+
...entries === "ambiguous" ? [] : entries.filter(entry => entry.mode === "ask").map(entry => ({ kind: "native-command", semantics: entry })),
|
|
114
|
+
];
|
|
115
|
+
return this.permissions.compose(exec, managed.registration, entry, action, downstream, operation.workingDirectory, false, contributions, { source, sourceCurrent: () => this.rules.getPolicy() });
|
|
111
116
|
},
|
|
112
117
|
});
|
|
113
118
|
ctx.on("tools/pre-execute", async (exec, next) => {
|
|
@@ -7,6 +7,8 @@ export declare function parseHostNativeCommands(input?: unknown): NativeCommands
|
|
|
7
7
|
* Unsupported syntax retains the ordinary native path. */
|
|
8
8
|
export declare function literalCommand(command: string, dialect: PermissionShellIdentity["dialect"], mode?: "legacy" | "simple"): readonly string[] | undefined;
|
|
9
9
|
export declare function nativeCommandMatch(settings: NativeCommandsSettings, tool: "bash" | "pwsh", identity: PermissionShellIdentity, args: unknown, workspace: string): NativeCommandEntry | "ambiguous" | undefined;
|
|
10
|
+
/** All matching entries retain provenance; mode ambiguity is resolved before any memory lookup. */
|
|
11
|
+
export declare function nativeCommandMatches(settings: NativeCommandsSettings, tool: "bash" | "pwsh", identity: PermissionShellIdentity, args: unknown, workspace: string): readonly NativeCommandEntry[] | "ambiguous";
|
|
10
12
|
export declare function simpleShellDialect(name: string): PermissionShellIdentity["dialect"] | undefined;
|
|
11
13
|
export declare function simpleShellCommand(args: unknown): string | undefined;
|
|
12
14
|
/** A simple hit carries no legacy entry, cwd grant, read trust or sandbox target. */
|
|
@@ -76,15 +76,20 @@ export function literalCommand(command, dialect, mode = "legacy") {
|
|
|
76
76
|
return Object.freeze(words);
|
|
77
77
|
}
|
|
78
78
|
export function nativeCommandMatch(settings, tool, identity, args, workspace) {
|
|
79
|
+
const matches = nativeCommandMatches(settings, tool, identity, args, workspace);
|
|
80
|
+
return matches === "ambiguous" ? matches : matches.find(entry => entry.mode === "ask") ?? matches[0];
|
|
81
|
+
}
|
|
82
|
+
/** All matching entries retain provenance; mode ambiguity is resolved before any memory lookup. */
|
|
83
|
+
export function nativeCommandMatches(settings, tool, identity, args, workspace) {
|
|
79
84
|
if (!settings.enabled || args === null || typeof args !== "object")
|
|
80
|
-
return
|
|
85
|
+
return [];
|
|
81
86
|
const command = Reflect.get(args, identity.commandField), modelCwd = identity.cwdField === undefined ? undefined : Reflect.get(args, identity.cwdField);
|
|
82
87
|
if (typeof command !== "string" || !isAbsolute(workspace) || modelCwd !== undefined && typeof modelCwd !== "string")
|
|
83
|
-
return
|
|
88
|
+
return [];
|
|
84
89
|
const cwd = normalize(modelCwd === undefined ? workspace : resolve(workspace, modelCwd));
|
|
85
90
|
const words = literalCommand(command, identity.dialect);
|
|
86
91
|
if (words === undefined)
|
|
87
|
-
return
|
|
92
|
+
return [];
|
|
88
93
|
const matches = parseHostNativeCommands(settings).entries.filter((entry) => {
|
|
89
94
|
if (typeof entry === "string")
|
|
90
95
|
return false;
|
|
@@ -96,7 +101,7 @@ export function nativeCommandMatch(settings, tool, identity, args, workspace) {
|
|
|
96
101
|
});
|
|
97
102
|
if (new Set(matches.map(entry => entry.sandboxMode)).size > 1)
|
|
98
103
|
return "ambiguous";
|
|
99
|
-
return matches
|
|
104
|
+
return matches;
|
|
100
105
|
}
|
|
101
106
|
export function simpleShellDialect(name) {
|
|
102
107
|
const lower = name.toLowerCase();
|
|
@@ -2,7 +2,7 @@ import type { Context } from "@deepseek-ai/cordis";
|
|
|
2
2
|
import type { PreToolDecision, ToolDefinition, ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
3
3
|
import type { PermissionExecutionIntegrity } from "./permission-control.js";
|
|
4
4
|
import type { PermissionShellIdentity } from "./permission-shell.js";
|
|
5
|
-
import type { PermissionRuleSnapshot, PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
5
|
+
import type { PermissionRule, PermissionRuleSnapshot, PermissionRulesRuntimeSync } from "./permission-rules.js";
|
|
6
6
|
import type { PermissionRulesStatus } from "./permission-rules.js";
|
|
7
7
|
import type { PermissionRuleAction } from "./permission-settings.js";
|
|
8
8
|
export interface NativePermissionFsTarget {
|
|
@@ -44,7 +44,7 @@ export interface NativePermissionRulesOptions {
|
|
|
44
44
|
/** Pure restriction fallback for standalone consumers without an authority capture. */
|
|
45
45
|
assertCurrent(execution: Readonly<ToolExecution>): void;
|
|
46
46
|
/** Compose this exact registration's native request; never creates an independent approval UI. */
|
|
47
|
-
managedShellDecision?(execution: Readonly<ToolExecution>, action: Exclude<PermissionRuleAction, "deny">, downstream: () => Promise<PreToolDecision>, snapshot: PermissionRuleSnapshot | undefined): Promise<PreToolDecision>;
|
|
47
|
+
managedShellDecision?(execution: Readonly<ToolExecution>, action: Exclude<PermissionRuleAction, "deny">, downstream: () => Promise<PreToolDecision>, snapshot: PermissionRuleSnapshot | undefined, asks: readonly PermissionRule[]): Promise<PreToolDecision>;
|
|
48
48
|
}
|
|
49
49
|
/** The public native search tools accept pattern/path/include only; no model-controlled rg flags. */
|
|
50
50
|
export declare function parseNativePermissionReadPaths(kind: "read" | "glob" | "grep", input: unknown): readonly string[];
|