@dsmm/dsmm 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/cordis.patch.yml +0 -9
- package/docs/agent-presets.md +5 -5
- package/docs/compatibility.md +2 -6
- package/docs/migration-from-ocmm.md +1 -1
- package/docs/roadmap.md +5 -12
- package/docs/settings-status.md +1 -1
- package/lib/client/ChildrenPanel.d.ts +1 -4
- package/lib/client/ChildrenPanel.js +3 -3
- package/lib/client/DeploymentPage.d.ts +1 -3
- package/lib/client/DeploymentPage.js +2 -2
- package/lib/client/PermissionsPanel.d.ts +1 -3
- package/lib/client/PermissionsPanel.js +2 -3
- package/lib/client/children-locales.d.ts +4 -4
- package/lib/client/controller.js +4 -1
- package/lib/client/deployment-locales.js +0 -1
- package/lib/client/deployment-modules.js +1 -1
- package/lib/client/index.js +2 -7
- package/lib/client/locales.js +131 -119
- package/lib/client/permission-locales.d.ts +0 -26
- package/lib/client/permission-locales.js +0 -20
- package/lib/client.js +1837 -3634
- package/lib/index.d.ts +0 -2
- package/lib/index.js +9 -22
- package/lib/native-admission.d.ts +0 -3
- package/lib/native-admission.js +12 -45
- package/lib/permission-fs-search.js +1 -2
- package/lib/permission-fs.js +1 -2
- package/lib/permission-web.js +1 -2
- package/lib/preset-materializer.js +3 -3
- package/lib/preset-registry.d.ts +20 -2
- package/lib/preset-registry.js +46 -17
- package/lib/profile-diagnostics.js +1 -1
- package/lib/profile-remote.js +1 -3
- package/lib/role-policy.js +2 -2
- package/lib/role-subagents.js +2 -1
- package/lib/roles.d.ts +2 -0
- package/lib/roles.js +2 -0
- package/lib/settings.d.ts +1 -3
- package/lib/settings.js +4 -9
- package/package.json +1 -5
- package/lib/client/ChildPermissions.d.ts +0 -43
- package/lib/client/ChildPermissions.js +0 -100
- package/lib/client/HistoryContinuation.d.ts +0 -7
- package/lib/client/HistoryContinuation.js +0 -22
- package/lib/client/PermissionPanelEntry.d.ts +0 -8
- package/lib/client/PermissionPanelEntry.js +0 -11
- package/lib/client/TemporaryPermissions.d.ts +0 -21
- package/lib/client/TemporaryPermissions.js +0 -94
- package/lib/client/history-controller.d.ts +0 -29
- package/lib/client/history-controller.js +0 -111
- package/lib/client/history-entry.d.ts +0 -11
- package/lib/client/history-entry.js +0 -106
- package/lib/client/history-locales.d.ts +0 -95
- package/lib/client/history-locales.js +0 -41
- package/lib/client/temporary-permission-client.d.ts +0 -20
- package/lib/client/temporary-permission-client.js +0 -52
- package/lib/client/temporary-permission-entry.d.ts +0 -6
- package/lib/client/temporary-permission-entry.js +0 -56
- package/lib/history-candidates.d.ts +0 -30
- package/lib/history-candidates.js +0 -176
- package/lib/history-codec.d.ts +0 -11
- package/lib/history-codec.js +0 -102
- package/lib/history-contract.d.ts +0 -44
- package/lib/history-contract.js +0 -2
- package/lib/history-controller.d.ts +0 -42
- package/lib/history-controller.js +0 -329
- package/lib/history-policy.d.ts +0 -4
- package/lib/history-policy.js +0 -8
- package/lib/history-remote.d.ts +0 -28
- package/lib/history-remote.js +0 -17
- package/lib/history-rpc.d.ts +0 -24
- package/lib/history-rpc.js +0 -136
- package/lib/history-support.d.ts +0 -15
- package/lib/history-support.js +0 -21
- package/lib/history-types.d.ts +0 -67
- package/lib/history-types.js +0 -2
- package/lib/permission-child-control.d.ts +0 -36
- package/lib/permission-child-control.js +0 -164
- package/lib/permission-exec-argv.d.ts +0 -32
- package/lib/permission-exec-argv.js +0 -171
- package/lib/permission-temporary-files.d.ts +0 -19
- package/lib/permission-temporary-files.js +0 -248
- package/lib/permission-temporary-grants.d.ts +0 -106
- package/lib/permission-temporary-grants.js +0 -198
- package/lib/permission-temporary-install.d.ts +0 -25
- package/lib/permission-temporary-install.js +0 -86
- package/lib/permission-temporary-remote.d.ts +0 -19
- package/lib/permission-temporary-remote.js +0 -75
- package/lib/permission-temporary-rpc.d.ts +0 -37
- package/lib/permission-temporary-rpc.js +0 -154
- package/lib/permission-temporary-types.d.ts +0 -47
- package/lib/permission-temporary-types.js +0 -2
- package/lib/permission-temporary-web.d.ts +0 -11
- package/lib/permission-temporary-web.js +0 -154
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +0 -13291
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +0 -9133
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +0 -156
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +0 -3546
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +0 -431
- package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +0 -119
- package/patches/dsh-approval-settlement/README.md +0 -41
- package/patches/dsh-approval-settlement/metadata.json +0 -10
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +0 -383
- package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +0 -55
- package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +0 -16673
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +0 -29
- package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +0 -196
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +0 -35
- package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +0 -40
package/lib/history-types.d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/** History content remains on the native list/page/follow and presentation surfaces. */
|
|
2
|
-
export type HistoryExecution = "authorization-required" | "activating" | "active" | "unavailable";
|
|
3
|
-
export type HistoryFailureCode = "validation" | "not-owned" | "not-found" | "unsupported-host" | "unsupported-backend" | "unavailable" | "busy" | "stale" | "cancelled" | "authorization-required" | "child-owner-required" | "format-unavailable" | "initialization-failed";
|
|
4
|
-
export interface HistoryFailure {
|
|
5
|
-
code: HistoryFailureCode;
|
|
6
|
-
storageEffects: "none" | "may-have-committed";
|
|
7
|
-
}
|
|
8
|
-
export interface HistoryStatus {
|
|
9
|
-
sessionId: string;
|
|
10
|
-
readable: "readable" | "unavailable";
|
|
11
|
-
execution: HistoryExecution;
|
|
12
|
-
compatibleHost: boolean;
|
|
13
|
-
reason?: HistoryFailureCode;
|
|
14
|
-
}
|
|
15
|
-
export interface HistoryChoice {
|
|
16
|
-
id: string;
|
|
17
|
-
label: string;
|
|
18
|
-
}
|
|
19
|
-
export interface HistoryChoices {
|
|
20
|
-
presets: HistoryChoice[];
|
|
21
|
-
profiles: HistoryChoice[];
|
|
22
|
-
}
|
|
23
|
-
export interface HistoryPreviewRequest {
|
|
24
|
-
sessionId: string;
|
|
25
|
-
preset: string;
|
|
26
|
-
/** null selects the deployment baseline, not a historical session selection. */
|
|
27
|
-
profileId: string | null;
|
|
28
|
-
}
|
|
29
|
-
export interface HistoryConfirmRequest {
|
|
30
|
-
sessionId: string;
|
|
31
|
-
intentId: string;
|
|
32
|
-
processPending: boolean;
|
|
33
|
-
acceptMigration: boolean;
|
|
34
|
-
}
|
|
35
|
-
export type HistoryJson = null | boolean | number | string | HistoryJson[] | {
|
|
36
|
-
[key: string]: HistoryJson;
|
|
37
|
-
};
|
|
38
|
-
export interface HistoryCandidateView {
|
|
39
|
-
preset: HistoryChoice;
|
|
40
|
-
profile: HistoryChoice | null;
|
|
41
|
-
model: {
|
|
42
|
-
provider: string;
|
|
43
|
-
model: string;
|
|
44
|
-
reasoningEffort?: string;
|
|
45
|
-
};
|
|
46
|
-
roles: HistoryChoice[];
|
|
47
|
-
/** Current, effective restrictions from the trusted policy provider. */
|
|
48
|
-
restrictions: string[];
|
|
49
|
-
differences: string[];
|
|
50
|
-
}
|
|
51
|
-
export interface HistoryPreview {
|
|
52
|
-
sessionId: string;
|
|
53
|
-
intentId: string;
|
|
54
|
-
cwd: string;
|
|
55
|
-
candidate: HistoryCandidateView;
|
|
56
|
-
migrationRequired: boolean;
|
|
57
|
-
/** Native inbox projection, displayed as untrusted input and never replayed by DSMM. */
|
|
58
|
-
pending: {
|
|
59
|
-
nextTurn: HistoryJson[];
|
|
60
|
-
nextStep: HistoryJson[];
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
export interface HistoryContinuationResult {
|
|
64
|
-
sessionId: string;
|
|
65
|
-
execution: "active";
|
|
66
|
-
}
|
|
67
|
-
//# sourceMappingURL=history-types.d.ts.map
|
package/lib/history-types.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
3
|
-
import type { TemporaryPermissionGrants } from "./permission-temporary-grants.js";
|
|
4
|
-
import type { ChildPermissionView } from "./permission-temporary-types.js";
|
|
5
|
-
interface ChildScope {
|
|
6
|
-
readonly role?: string;
|
|
7
|
-
readonly readOnly: boolean;
|
|
8
|
-
check(): void;
|
|
9
|
-
}
|
|
10
|
-
export interface ChildPermissionOptions {
|
|
11
|
-
capture(parent: Agent, child: Agent): ChildScope;
|
|
12
|
-
refresh(): Promise<unknown>;
|
|
13
|
-
}
|
|
14
|
-
/** A live operator policy transition, separate from the immutable native creation fact. */
|
|
15
|
-
export declare class ChildPermissionControl {
|
|
16
|
-
private readonly ctx;
|
|
17
|
-
private readonly grants;
|
|
18
|
-
private readonly options;
|
|
19
|
-
private readonly operators;
|
|
20
|
-
private readonly transitions;
|
|
21
|
-
private readonly lifetime;
|
|
22
|
-
constructor(ctx: Context, grants: TemporaryPermissionGrants, options: ChildPermissionOptions);
|
|
23
|
-
private live;
|
|
24
|
-
private operator;
|
|
25
|
-
assertEnabled(child: Agent): void;
|
|
26
|
-
authorizeChild(_peer: object, child: Agent): {
|
|
27
|
-
assertCurrent(): void;
|
|
28
|
-
};
|
|
29
|
-
describe(parent: Agent, child: Agent): ChildPermissionView;
|
|
30
|
-
private change;
|
|
31
|
-
enable(parent: Agent, child: Agent, checkOperator: () => void): Promise<ChildPermissionView>;
|
|
32
|
-
revoke(parent: Agent, child: Agent, checkOperator: () => void): Promise<ChildPermissionView>;
|
|
33
|
-
dispose(): void;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
36
|
-
//# sourceMappingURL=permission-child-control.d.ts.map
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import { SubagentRuntime } from "@deepseek-ai/dsh-subagent";
|
|
2
|
-
import { ApprovalService } from "@deepseek-ai/dsh-user-approval";
|
|
3
|
-
import { SessionSeq } from "@deepseek-ai/dsh-session";
|
|
4
|
-
import { PermissionRefusal, permissionApprovalAdapter, permissionOriginal } from "./permission-control.js";
|
|
5
|
-
function latestPolicy(agent) {
|
|
6
|
-
for (let seq = agent.session.seq - 1; seq >= 0; seq--) {
|
|
7
|
-
const event = agent.session.eventAt(SessionSeq(seq));
|
|
8
|
-
if (event?.type === "approval/policy")
|
|
9
|
-
return event;
|
|
10
|
-
}
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
/** A live operator policy transition, separate from the immutable native creation fact. */
|
|
14
|
-
export class ChildPermissionControl {
|
|
15
|
-
ctx;
|
|
16
|
-
grants;
|
|
17
|
-
options;
|
|
18
|
-
operators = new Map();
|
|
19
|
-
transitions = new WeakMap();
|
|
20
|
-
lifetime = new AbortController();
|
|
21
|
-
constructor(ctx, grants, options) {
|
|
22
|
-
this.ctx = ctx;
|
|
23
|
-
this.grants = grants;
|
|
24
|
-
this.options = options;
|
|
25
|
-
const guard = ctx.on("approval/request", permissionApprovalAdapter(ctx, (request, next) => {
|
|
26
|
-
const agent = request.agent, agents = ctx.get("agents");
|
|
27
|
-
if (agents?.roots().includes(agent) && agent.session.header.origin !== "subagent")
|
|
28
|
-
return next();
|
|
29
|
-
try {
|
|
30
|
-
this.assertEnabled(agent);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return Promise.resolve("unavailable");
|
|
34
|
-
}
|
|
35
|
-
return next();
|
|
36
|
-
}), { prepend: true, global: true });
|
|
37
|
-
const disposed = ctx.on("agent/disposed", ({ agent }) => {
|
|
38
|
-
for (const [child, authority] of this.operators)
|
|
39
|
-
if (child === agent || authority.parent === agent) {
|
|
40
|
-
this.grants.revokeAgent(child);
|
|
41
|
-
this.transitions.set(child, {});
|
|
42
|
-
this.operators.delete(child);
|
|
43
|
-
}
|
|
44
|
-
}, { global: true });
|
|
45
|
-
ctx.effect(() => () => { this.lifetime.abort(); guard(); disposed(); for (const child of this.operators.keys())
|
|
46
|
-
this.grants.revokeAgent(child); this.operators.clear(); });
|
|
47
|
-
}
|
|
48
|
-
live(parent, child) {
|
|
49
|
-
this.lifetime.signal.throwIfAborted();
|
|
50
|
-
const agents = this.ctx.get("agents"), runtime = this.ctx.get("subagents"), approval = child.ctx.get("approval");
|
|
51
|
-
if (!agents || !runtime || !approval || agents.get(parent.id) !== parent || agents.get(child.id) !== child || !agents.roots().includes(parent)
|
|
52
|
-
|| !agents.isOwnedBy(child.id, parent) || child.session.header.parentSession !== parent.id || child.session.id !== child.id
|
|
53
|
-
|| Object.getPrototypeOf(permissionOriginal(runtime)) !== SubagentRuntime.prototype || Reflect.get(permissionOriginal(runtime), "creationApprovalOf") !== SubagentRuntime.prototype.creationApprovalOf
|
|
54
|
-
|| Object.getPrototypeOf(permissionOriginal(approval)) !== ApprovalService.prototype || Reflect.get(permissionOriginal(approval), "setPolicy") !== ApprovalService.prototype.setPolicy)
|
|
55
|
-
throw new PermissionRefusal("not-owned");
|
|
56
|
-
const origin = runtime.creationApprovalOf(child);
|
|
57
|
-
if (!origin || origin.parent !== parent || origin.child !== child)
|
|
58
|
-
throw new PermissionRefusal("unavailable");
|
|
59
|
-
return { origin, approval };
|
|
60
|
-
}
|
|
61
|
-
operator(child, authority) {
|
|
62
|
-
const live = this.live(authority.parent, child);
|
|
63
|
-
if (live.origin !== authority.origin || permissionOriginal(live.approval) !== permissionOriginal(authority.approval)
|
|
64
|
-
|| child.session !== authority.session || latestPolicy(child) !== authority.record
|
|
65
|
-
|| authority.approval.overrideOf(child.session) !== (authority.enabled ? "ask" : "never"))
|
|
66
|
-
throw new PermissionRefusal("stale");
|
|
67
|
-
}
|
|
68
|
-
assertEnabled(child) {
|
|
69
|
-
const authority = this.operators.get(child);
|
|
70
|
-
if (!authority?.enabled)
|
|
71
|
-
throw new PermissionRefusal("denied");
|
|
72
|
-
this.operator(child, authority);
|
|
73
|
-
authority.scope.check();
|
|
74
|
-
}
|
|
75
|
-
authorizeChild(_peer, child) {
|
|
76
|
-
this.assertEnabled(child);
|
|
77
|
-
const authority = this.operators.get(child);
|
|
78
|
-
return { assertCurrent: () => { if (this.operators.get(child) !== authority)
|
|
79
|
-
throw new PermissionRefusal("stale"); this.assertEnabled(child); } };
|
|
80
|
-
}
|
|
81
|
-
describe(parent, child) {
|
|
82
|
-
const value = { parentSessionId: parent.id, childSessionId: child.id, project: child.session.header.cwd ?? "",
|
|
83
|
-
state: "unavailable", canEnable: false, canRevoke: this.operators.has(child) || this.grants.list(child).length > 0 };
|
|
84
|
-
try {
|
|
85
|
-
const { origin } = this.live(parent, child), authority = this.operators.get(child), scope = this.options.capture(parent, child);
|
|
86
|
-
scope.check();
|
|
87
|
-
if (authority) {
|
|
88
|
-
this.operator(child, authority);
|
|
89
|
-
if (authority.enabled)
|
|
90
|
-
authority.scope.check();
|
|
91
|
-
}
|
|
92
|
-
else
|
|
93
|
-
origin.assertCurrent(parent, child);
|
|
94
|
-
return { ...value, state: authority?.enabled ? "enabled" : "disabled", canEnable: true, readOnly: scope.readOnly, ...(scope.role ? { role: scope.role } : {}) };
|
|
95
|
-
}
|
|
96
|
-
catch {
|
|
97
|
-
return value;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
change(child, operation) {
|
|
101
|
-
if (child.status === "running") {
|
|
102
|
-
operation();
|
|
103
|
-
return Promise.resolve();
|
|
104
|
-
}
|
|
105
|
-
if (child.status !== "idle")
|
|
106
|
-
throw new PermissionRefusal("unavailable");
|
|
107
|
-
return child.runMaintenance(async (signal) => { signal.throwIfAborted(); operation(); });
|
|
108
|
-
}
|
|
109
|
-
async enable(parent, child, checkOperator) {
|
|
110
|
-
checkOperator();
|
|
111
|
-
const initial = this.live(parent, child), previous = this.operators.get(child), transition = {};
|
|
112
|
-
if (previous)
|
|
113
|
-
this.operator(child, previous);
|
|
114
|
-
else
|
|
115
|
-
initial.origin.assertCurrent(parent, child);
|
|
116
|
-
this.transitions.set(child, transition);
|
|
117
|
-
await this.options.refresh();
|
|
118
|
-
const scope = this.options.capture(parent, child);
|
|
119
|
-
await this.change(child, () => {
|
|
120
|
-
checkOperator();
|
|
121
|
-
scope.check();
|
|
122
|
-
const current = this.live(parent, child);
|
|
123
|
-
if (this.transitions.get(child) !== transition || current.origin !== initial.origin || permissionOriginal(current.approval) !== permissionOriginal(initial.approval)
|
|
124
|
-
|| !this.ctx.get("typertGateway")?.hasLiveClient())
|
|
125
|
-
throw new PermissionRefusal("unavailable");
|
|
126
|
-
if (previous)
|
|
127
|
-
this.operator(child, previous);
|
|
128
|
-
else
|
|
129
|
-
current.origin.assertCurrent(parent, child);
|
|
130
|
-
current.approval.setPolicy(child, "ask");
|
|
131
|
-
this.operators.set(child, { parent, origin: current.origin, scope, approval: current.approval, session: child.session, record: latestPolicy(child), enabled: true });
|
|
132
|
-
});
|
|
133
|
-
return this.describe(parent, child);
|
|
134
|
-
}
|
|
135
|
-
async revoke(parent, child, checkOperator) {
|
|
136
|
-
checkOperator();
|
|
137
|
-
this.grants.revokeAgent(child);
|
|
138
|
-
this.transitions.set(child, {});
|
|
139
|
-
const previous = this.operators.get(child);
|
|
140
|
-
if (!previous)
|
|
141
|
-
return this.describe(parent, child);
|
|
142
|
-
const enabled = previous.enabled;
|
|
143
|
-
previous.enabled = false;
|
|
144
|
-
try {
|
|
145
|
-
await this.change(child, () => {
|
|
146
|
-
checkOperator();
|
|
147
|
-
const live = this.live(parent, child);
|
|
148
|
-
if (previous.parent !== parent || live.origin !== previous.origin || child.session !== previous.session || latestPolicy(child) !== previous.record
|
|
149
|
-
|| permissionOriginal(live.approval) !== permissionOriginal(previous.approval)
|
|
150
|
-
|| live.approval.overrideOf(child.session) !== (enabled ? "ask" : "never"))
|
|
151
|
-
throw new PermissionRefusal("stale");
|
|
152
|
-
live.approval.setPolicy(child, "never");
|
|
153
|
-
previous.record = latestPolicy(child);
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
catch {
|
|
157
|
-
return { ...this.describe(parent, child), state: "unavailable", canEnable: false };
|
|
158
|
-
}
|
|
159
|
-
return this.describe(parent, child);
|
|
160
|
-
}
|
|
161
|
-
dispose() { this.lifetime.abort(); for (const child of this.operators.keys())
|
|
162
|
-
this.grants.revokeAgent(child); this.operators.clear(); }
|
|
163
|
-
}
|
|
164
|
-
//# sourceMappingURL=permission-child-control.js.map
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
2
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
3
|
-
import type { TemporaryPermissionGrants } from "./permission-temporary-grants.js";
|
|
4
|
-
export interface ArgvInput {
|
|
5
|
-
readonly executable: string;
|
|
6
|
-
readonly args: readonly string[];
|
|
7
|
-
readonly cwd: string;
|
|
8
|
-
}
|
|
9
|
-
export interface ArgvPermissionAuthority {
|
|
10
|
-
readonly owner: object;
|
|
11
|
-
readonly generation: string | number;
|
|
12
|
-
readonly sessionSignal: AbortSignal;
|
|
13
|
-
/** Includes live ownership and absolute role/readonly ceilings, not a config-revision veto. */
|
|
14
|
-
assertIntegrity(): void;
|
|
15
|
-
/** Initial admission and reusable permits include every applicable command/path/tool deny. */
|
|
16
|
-
assertProgramAllowed(): void;
|
|
17
|
-
/** A child additionally needs its current explicit operator interaction authority. */
|
|
18
|
-
assertRetentionAllowed?(): void;
|
|
19
|
-
}
|
|
20
|
-
export interface ArgvPermissionOptions {
|
|
21
|
-
readonly grants: TemporaryPermissionGrants;
|
|
22
|
-
capture(execution: Readonly<ToolExecution>, input: ArgvInput): ArgvPermissionAuthority;
|
|
23
|
-
/** Explicit Host classification; unknown programs and interpreters are once-only. */
|
|
24
|
-
programKind(executable: string): "native" | "interpreter" | "unknown";
|
|
25
|
-
readonly environment?: Readonly<Record<string, string | undefined>>;
|
|
26
|
-
readonly maxOutputBytes?: number;
|
|
27
|
-
readonly timeoutMs?: number;
|
|
28
|
-
}
|
|
29
|
-
export declare function effectiveArgvEnvironment(overrides: Readonly<Record<string, string | undefined>>, parent?: Record<string, string>): string;
|
|
30
|
-
/** Explicit argv only. Native shell tools keep their own semantics and approvals. */
|
|
31
|
-
export declare function installPermissionExecArgv(ctx: Context, options: ArgvPermissionOptions): () => void;
|
|
32
|
-
//# sourceMappingURL=permission-exec-argv.d.ts.map
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { isAbsolute } from "node:path";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import { realpath } from "node:fs/promises";
|
|
4
|
-
import { LocalSubprocessRuntime } from "@deepseek-ai/dsh-subprocess-local";
|
|
5
|
-
import { defineTool } from "@deepseek-ai/dsh-tools";
|
|
6
|
-
import { permissionOriginal } from "./permission-control.js";
|
|
7
|
-
// Resolve the public seam through the installed local provider, not private provider files.
|
|
8
|
-
const subprocessModule = createRequire(createRequire(import.meta.url).resolve("@deepseek-ai/dsh-subprocess-local"))("@deepseek-ai/dsh-subprocess");
|
|
9
|
-
export function effectiveArgvEnvironment(overrides, parent = subprocessModule.scrubbedParentEnv()) {
|
|
10
|
-
const entries = new Map();
|
|
11
|
-
const ambiguous = new Set();
|
|
12
|
-
const keyOf = (key) => process.platform === "win32" ? key.toUpperCase() : key;
|
|
13
|
-
for (const [key, value] of Object.entries(parent)) {
|
|
14
|
-
const normalized = keyOf(key);
|
|
15
|
-
if (entries.has(normalized) && entries.get(normalized) !== value)
|
|
16
|
-
ambiguous.add(normalized);
|
|
17
|
-
entries.set(normalized, value);
|
|
18
|
-
}
|
|
19
|
-
for (const [key, value] of Object.entries(overrides)) {
|
|
20
|
-
ambiguous.delete(keyOf(key));
|
|
21
|
-
if (value === undefined)
|
|
22
|
-
entries.delete(keyOf(key));
|
|
23
|
-
else
|
|
24
|
-
entries.set(keyOf(key), value);
|
|
25
|
-
}
|
|
26
|
-
if (ambiguous.size)
|
|
27
|
-
throw new Error("Ambiguous case-insensitive target environment.");
|
|
28
|
-
return JSON.stringify([...entries].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
29
|
-
}
|
|
30
|
-
function parseInput(value) {
|
|
31
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
32
|
-
throw new TypeError("Expected structured argv.");
|
|
33
|
-
const row = value;
|
|
34
|
-
if (Object.keys(row).some(key => !["executable", "args", "cwd"].includes(key)) || typeof row.executable !== "string"
|
|
35
|
-
|| !isAbsolute(row.executable) || typeof row.cwd !== "string" || !isAbsolute(row.cwd)
|
|
36
|
-
|| !Array.isArray(row.args) || row.args.some(arg => typeof arg !== "string" || arg.includes("\0"))
|
|
37
|
-
|| row.executable.includes("\0") || row.cwd.includes("\0"))
|
|
38
|
-
throw new TypeError("Absolute executable/cwd and a complete string argv are required.");
|
|
39
|
-
return Object.freeze({ executable: row.executable, cwd: row.cwd, args: Object.freeze([...row.args]) });
|
|
40
|
-
}
|
|
41
|
-
async function assertCanonical(input) {
|
|
42
|
-
const [executable, cwd] = await Promise.all([realpath(input.executable), realpath(input.cwd)]);
|
|
43
|
-
if (executable !== input.executable || cwd !== input.cwd)
|
|
44
|
-
throw new Error("Use canonical absolute executable and working-directory paths.");
|
|
45
|
-
}
|
|
46
|
-
/** Explicit argv only. Native shell tools keep their own semantics and approvals. */
|
|
47
|
-
export function installPermissionExecArgv(ctx, options) {
|
|
48
|
-
const subprocess = ctx.get("subprocess"), sandbox = ctx.get("sandbox"), policyService = ctx.get("sandboxPolicy");
|
|
49
|
-
if (!subprocess || !policyService)
|
|
50
|
-
throw new Error("Native subprocess and sandbox policy services required.");
|
|
51
|
-
const original = permissionOriginal(subprocess);
|
|
52
|
-
const policyOwner = permissionOriginal(policyService), sandboxOwner = sandbox && permissionOriginal(sandbox);
|
|
53
|
-
const spawnMethod = Reflect.get(original, "spawn"), resolveMethod = Reflect.get(original, "resolveExecutable");
|
|
54
|
-
const policyMethod = Reflect.get(policyOwner, "resolve"), confineMethod = sandboxOwner && Reflect.get(sandboxOwner, "confine");
|
|
55
|
-
if (Object.getPrototypeOf(original) !== LocalSubprocessRuntime.prototype
|
|
56
|
-
|| Reflect.get(original, "spawn") !== LocalSubprocessRuntime.prototype.spawn
|
|
57
|
-
|| Reflect.get(original, "resolveExecutable") !== LocalSubprocessRuntime.prototype.resolveExecutable)
|
|
58
|
-
throw new Error("Only the verified local subprocess provider is supported.");
|
|
59
|
-
const overrides = Object.freeze({ ...options.environment }), lifetime = new AbortController();
|
|
60
|
-
if (Object.keys(overrides).some(key => overrides[key] !== undefined && (subprocessModule.SENSITIVE_ENV_PATTERN.test(key) || /^DSH_/iu.test(key))))
|
|
61
|
-
throw new Error("Credential and Host identity overrides are not supported by this tool.");
|
|
62
|
-
const prepared = new Map();
|
|
63
|
-
const definition = defineTool({
|
|
64
|
-
name: "dsmm_exec_argv",
|
|
65
|
-
description: "Run an absolute executable with complete literal argv and cwd under the current sandbox. No shell, env input, escalation, stdin or PTY. Approval does not pin binary contents or make subprocesses/hook effects read-only.",
|
|
66
|
-
parameters: {
|
|
67
|
-
executable: { type: "string", required: true },
|
|
68
|
-
args: { type: "array", items: { type: "string" }, required: true },
|
|
69
|
-
cwd: { type: "string", required: true },
|
|
70
|
-
},
|
|
71
|
-
output: { schema: { type: "object", additionalProperties: false, properties: {
|
|
72
|
-
exitCode: { oneOf: [{ type: "number" }, { type: "null" }], required: true }, stdout: { type: "string", required: true }, stderr: { type: "string", required: true },
|
|
73
|
-
truncated: { type: "boolean", required: true }, enforcement: { type: "string", required: true },
|
|
74
|
-
} }, render(_args, value) { return [{ type: "text", text: JSON.stringify(value) }]; } },
|
|
75
|
-
async execute(args, exec) {
|
|
76
|
-
const item = prepared.get(exec.token);
|
|
77
|
-
if (!item)
|
|
78
|
-
throw new Error("Native approval preparation is unavailable.");
|
|
79
|
-
const { input, execution, lease, policy } = item;
|
|
80
|
-
const signal = AbortSignal.any([exec.signal, execution.signal, AbortSignal.timeout(options.timeoutMs ?? 30_000)]);
|
|
81
|
-
try {
|
|
82
|
-
if (JSON.stringify(parseInput(args)) !== JSON.stringify(input))
|
|
83
|
-
throw new Error("Execution arguments changed.");
|
|
84
|
-
let argv = [input.executable, ...input.args], enforcement = "standing-full-access";
|
|
85
|
-
if (policy.mode !== "danger-full-access") {
|
|
86
|
-
if (!sandbox)
|
|
87
|
-
throw new Error("Sandbox backend unavailable; no unconfined fallback.");
|
|
88
|
-
const confined = await sandbox.confine(argv, { ...policy, mode: policy.mode, sessionId: exec.agent?.id }, signal);
|
|
89
|
-
if (confined.enforcement !== "full" && confined.enforcement !== "partial")
|
|
90
|
-
throw new Error("Sandbox enforcement unavailable.");
|
|
91
|
-
argv = confined.argv;
|
|
92
|
-
enforcement = confined.enforcement;
|
|
93
|
-
}
|
|
94
|
-
await assertCanonical(input);
|
|
95
|
-
const spec = { argv, cwd: input.cwd, env: overrides, signal, graceMs: 200,
|
|
96
|
-
stdio: { stdin: "ignore", stdout: { maxBytes: options.maxOutputBytes ?? 16_384 }, stderr: { maxBytes: options.maxOutputBytes ?? 16_384 } } };
|
|
97
|
-
// The complete effective environment is checked after all asynchronous preparation.
|
|
98
|
-
signal.throwIfAborted();
|
|
99
|
-
execution.assertIntegrity();
|
|
100
|
-
lease.consume();
|
|
101
|
-
const handle = subprocess.spawn(spec);
|
|
102
|
-
const outcome = await handle.done;
|
|
103
|
-
const stdout = handle.collected.stdout.readFrom(0), stderr = handle.collected.stderr.readFrom(0);
|
|
104
|
-
return { exitCode: outcome.exitCode, stdout: stdout.text, stderr: stderr.text,
|
|
105
|
-
truncated: stdout.lossy || stderr.lossy, enforcement };
|
|
106
|
-
}
|
|
107
|
-
finally {
|
|
108
|
-
lease.finish();
|
|
109
|
-
prepared.delete(exec.token);
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
const unregister = ctx.tools.register(definition);
|
|
114
|
-
const registeredBody = definition.execute;
|
|
115
|
-
const pre = ctx.on("tools/pre-execute", async (exec, next) => {
|
|
116
|
-
if (ctx.tools.get(exec.name, exec.agent) !== definition)
|
|
117
|
-
return next();
|
|
118
|
-
const downstream = await next();
|
|
119
|
-
if (downstream.kind === "deny" || downstream.kind === "cancel")
|
|
120
|
-
return downstream;
|
|
121
|
-
if (!exec.agent)
|
|
122
|
-
return { kind: "deny", reason: "A live owned session is required." };
|
|
123
|
-
const input = parseInput(exec.arguments), authority = options.capture(exec, input);
|
|
124
|
-
authority.assertIntegrity();
|
|
125
|
-
authority.assertProgramAllowed();
|
|
126
|
-
const capturedPolicy = policyService.resolve({ session: exec.agent.session });
|
|
127
|
-
const policy = Object.freeze({ ...capturedPolicy }), environment = effectiveArgvEnvironment(overrides);
|
|
128
|
-
const signal = AbortSignal.any([exec.signal, authority.sessionSignal, lifetime.signal]);
|
|
129
|
-
const target = JSON.stringify({ input, environment, policy });
|
|
130
|
-
const check = () => {
|
|
131
|
-
signal.throwIfAborted();
|
|
132
|
-
authority.assertIntegrity();
|
|
133
|
-
if (ctx.tools.get(exec.name, exec.agent) !== definition || definition.execute !== registeredBody || permissionOriginal(ctx.subprocess) !== original
|
|
134
|
-
|| Reflect.get(original, "spawn") !== spawnMethod || Reflect.get(original, "resolveExecutable") !== resolveMethod
|
|
135
|
-
|| Reflect.get(policyOwner, "resolve") !== policyMethod || (sandboxOwner && Reflect.get(sandboxOwner, "confine")) !== confineMethod
|
|
136
|
-
|| (ctx.get("sandbox") && permissionOriginal(ctx.sandbox)) !== sandboxOwner
|
|
137
|
-
|| !ctx.get("sandboxPolicy") || permissionOriginal(ctx.sandboxPolicy) !== policyOwner
|
|
138
|
-
|| JSON.stringify(policyService.resolve({ session: exec.agent.session })) !== JSON.stringify(policy)
|
|
139
|
-
|| effectiveArgvEnvironment(overrides) !== environment)
|
|
140
|
-
throw new Error("Execution provider, policy or environment changed.");
|
|
141
|
-
};
|
|
142
|
-
const resolved = await subprocess.resolveExecutable(input.executable, undefined, signal);
|
|
143
|
-
await assertCanonical(input);
|
|
144
|
-
check();
|
|
145
|
-
if (resolved !== input.executable)
|
|
146
|
-
throw new Error("Executable identity changed; request its canonical absolute path.");
|
|
147
|
-
const execution = { token: exec.token, agent: exec.agent, owner: authority.owner,
|
|
148
|
-
generation: authority.generation, registration: definition, provider: original, sessionId: exec.agent.id,
|
|
149
|
-
tool: exec.name, project: exec.agent.session.header.cwd ?? "", target,
|
|
150
|
-
summary: `${input.executable} ${JSON.stringify(input.args)}\n${input.cwd}\n${policy.mode}; exact effective environment (values hidden). Program/config/hooks may change.`,
|
|
151
|
-
reusable: options.programKind(input.executable) === "native", signal, sessionSignal: authority.sessionSignal,
|
|
152
|
-
assertIntegrity: check, assertReusable() {
|
|
153
|
-
check();
|
|
154
|
-
authority.assertProgramAllowed();
|
|
155
|
-
authority.assertRetentionAllowed?.();
|
|
156
|
-
if (options.programKind(input.executable) !== "native")
|
|
157
|
-
throw new Error("Reusable program classification is no longer current.");
|
|
158
|
-
const approval = ctx.approval;
|
|
159
|
-
if ((approval.overrideOf(exec.agent.session) ?? approval.config.policy ?? "ask") !== "ask")
|
|
160
|
-
throw new Error("Current native policy does not allow automatic approval.");
|
|
161
|
-
} };
|
|
162
|
-
const lease = await options.grants.approve({ agent: exec.agent, toolName: exec.name, callId: exec.callId, signal,
|
|
163
|
-
reason: [downstream.kind === "ask" ? downstream.reason : undefined, execution.summary].filter(Boolean).join("\n") }, execution);
|
|
164
|
-
prepared.set(exec.token, { input, execution, policy, lease });
|
|
165
|
-
return { kind: "allow" };
|
|
166
|
-
}, { prepend: true, global: true });
|
|
167
|
-
const result = ctx.on("tools/result", exec => { const item = prepared.get(exec.token); item?.lease.finish(); prepared.delete(exec.token); }, { global: true });
|
|
168
|
-
return ctx.effect(() => () => { lifetime.abort(); pre(); result(); unregister(); for (const item of prepared.values())
|
|
169
|
-
item.lease.finish(); prepared.clear(); });
|
|
170
|
-
}
|
|
171
|
-
//# sourceMappingURL=permission-exec-argv.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import type { ToolExecution } from "@deepseek-ai/dsh-tools";
|
|
3
|
-
import type { TemporaryPermissionGrants } from "./permission-temporary-grants.js";
|
|
4
|
-
import type { ArgvPermissionAuthority } from "./permission-exec-argv.js";
|
|
5
|
-
/** Called only around the actual native module's apply, before its definitions are registered. */
|
|
6
|
-
export declare function temporaryFileToolScope(scope: Context, module: "fs" | "fs-search"): Context;
|
|
7
|
-
export interface TemporaryFileOptions {
|
|
8
|
-
readonly grants: TemporaryPermissionGrants;
|
|
9
|
-
refresh?(): Promise<unknown>;
|
|
10
|
-
capture(execution: Readonly<ToolExecution>): ArgvPermissionAuthority;
|
|
11
|
-
}
|
|
12
|
-
/** Native asks are settled once by the existing ApprovalService; providers remain the original ones. */
|
|
13
|
-
export declare function installTemporaryFilePermissions(ctx: Context, options: TemporaryFileOptions): () => void;
|
|
14
|
-
declare module "@deepseek-ai/cordis" {
|
|
15
|
-
interface Context {
|
|
16
|
-
dsmmTemporaryFilePermissions: AbortSignal;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=permission-temporary-files.d.ts.map
|