@dsmm/dsmm 0.3.2 → 0.3.4
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/agent-presets/dsmm-builder/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-clarifier/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-code-search/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-coding/agent.cordis.yml +3 -2
- package/agent-presets/dsmm-complex/agent.cordis.yml +2 -1
- package/agent-presets/dsmm-creative/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-deep/agent.cordis.yml +2 -1
- package/agent-presets/dsmm-doc-search/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-documenting/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-frontend/agent.cordis.yml +4 -2
- package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-media-reader/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-normal-task/agent.cordis.yml +3 -2
- package/agent-presets/dsmm-oracle/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-orchestrator/agent.cordis.yml +11 -1
- package/agent-presets/dsmm-plan-critic/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-planner/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-quick/agent.cordis.yml +2 -1
- package/agent-presets/dsmm-research/agent.cordis.yml +1 -1
- package/agent-presets/dsmm-reviewer/agent.cordis.yml +1 -1
- 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/native-permissions.md +11 -3
- package/docs/roadmap.md +31 -11
- package/docs/runtime-recovery.md +30 -2
- package/docs/settings-status.md +7 -5
- package/docs/skill-sync.md +13 -14
- package/lib/client/ChildrenPanel.d.ts +1 -4
- package/lib/client/ChildrenPanel.js +3 -3
- package/lib/client/DeploymentFields.js +12 -1
- package/lib/client/DeploymentPage.d.ts +1 -3
- package/lib/client/DeploymentPage.js +30 -18
- package/lib/client/NativeCommandEntries.js +47 -37
- package/lib/client/PermissionRuleEntries.d.ts +17 -0
- package/lib/client/PermissionRuleEntries.js +70 -0
- package/lib/client/PermissionsPanel.d.ts +1 -3
- package/lib/client/PermissionsPanel.js +5 -4
- package/lib/client/children-locales.d.ts +4 -4
- package/lib/client/controller.js +4 -1
- package/lib/client/deployment-locales.d.ts +2 -2
- package/lib/client/deployment-locales.js +8 -9
- package/lib/client/deployment-modules.d.ts +5 -3
- package/lib/client/deployment-modules.js +4 -4
- package/lib/client/deployment-workspace.d.ts +4 -0
- package/lib/client/deployment-workspace.js +37 -11
- package/lib/client/index.js +2 -7
- package/lib/client/locales.js +131 -119
- package/lib/client/permission-controller.d.ts +13 -0
- package/lib/client/permission-controller.js +50 -23
- package/lib/client/permission-locales.d.ts +28 -30
- package/lib/client/permission-locales.js +38 -38
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +8 -8
- package/lib/client.js +2272 -3773
- package/lib/core-permission-authority.js +28 -16
- package/lib/index.d.ts +0 -2
- package/lib/index.js +11 -31
- package/lib/native-admission.d.ts +3 -3
- package/lib/native-admission.js +67 -66
- package/lib/permission-controller.js +1 -1
- package/lib/permission-fs-search.js +1 -2
- package/lib/permission-fs.js +1 -2
- package/lib/permission-native-command.js +6 -4
- package/lib/permission-settings.d.ts +21 -7
- package/lib/permission-settings.js +21 -9
- 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-identity.d.ts +1 -1
- package/lib/role-identity.js +16 -4
- package/lib/role-policy.d.ts +3 -0
- package/lib/role-policy.js +30 -6
- package/lib/role-subagents.js +6 -4
- package/lib/roles.d.ts +2 -0
- package/lib/roles.js +2 -0
- package/lib/runtime-integration.js +4 -4
- package/lib/settings.d.ts +1 -3
- package/lib/settings.js +8 -10
- package/lib/state.d.ts +4 -1
- package/lib/state.js +37 -6
- package/package.json +1 -5
- package/prompts/deepwork.md +13 -1
- package/prompts/source/agents/orchestrator.md +10 -0
- package/prompts/source/category/coding.md +2 -1
- package/prompts/source/category/complex.md +1 -0
- package/prompts/source/category/deep.md +1 -0
- package/prompts/source/category/frontend.md +3 -1
- package/prompts/source/category/normal-task.md +2 -1
- package/prompts/source/category/quick.md +1 -0
- package/prompts/source/deepwork/claude-opus-5.md +2 -0
- package/prompts/source/deepwork/default.md +12 -0
- package/prompts/source/deepwork/gemini.md +6 -1
- package/prompts/source/deepwork/glm.md +5 -1
- package/prompts/source/deepwork/gpt.md +22 -2
- package/prompts/source/deepwork/kimi-k27.md +2 -0
- package/prompts/source/deepwork/planner.md +3 -1
- package/prompts/source/deepwork/swe-2.md +2 -0
- package/prompts/source/manifest.json +3 -68
- package/prompts/source/shared/dsh-host-contract.md +1 -1
- package/skills/ast-grep/SKILL.md +1 -1
- package/skills/brainstorming/SKILL.md +1 -1
- package/skills/coding-agent-sessions/SKILL.md +1 -1
- package/skills/debugging/SKILL.md +1 -1
- package/skills/dispatching-parallel-agents/SKILL.md +1 -1
- package/skills/frontend/SKILL.md +1 -1
- package/skills/git-master/SKILL.md +1 -1
- package/skills/init-deep/SKILL.md +1 -1
- package/skills/receiving-code-review/SKILL.md +1 -1
- package/skills/remove-ai-slops/SKILL.md +1 -1
- package/skills/requesting-code-review/SKILL.md +1 -1
- package/skills/subagent-driven-development/SKILL.md +1 -1
- package/skills/using-git-worktrees/SKILL.md +1 -1
- package/skills/writing-plans/SKILL.md +1 -1
- 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-rpc.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
2
|
-
var useValue = arguments.length > 2;
|
|
3
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
4
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
5
|
-
}
|
|
6
|
-
return useValue ? value : void 0;
|
|
7
|
-
};
|
|
8
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
9
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
10
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
11
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
12
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
13
|
-
var _, done = false;
|
|
14
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
15
|
-
var context = {};
|
|
16
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
17
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
18
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
19
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
20
|
-
if (kind === "accessor") {
|
|
21
|
-
if (result === void 0) continue;
|
|
22
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
23
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
24
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
25
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
26
|
-
}
|
|
27
|
-
else if (_ = accept(result)) {
|
|
28
|
-
if (kind === "field") initializers.unshift(_);
|
|
29
|
-
else descriptor[key] = _;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
33
|
-
done = true;
|
|
34
|
-
};
|
|
35
|
-
import { getTraceable, symbols } from "@deepseek-ai/cordis";
|
|
36
|
-
import { RemoteAccessService } from "@deepseek-ai/dsh-api-remote-access";
|
|
37
|
-
import { SessionId } from "@deepseek-ai/dsh-session";
|
|
38
|
-
import { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
39
|
-
import { assertLocalSettingsOperator } from "./profile-rpc.js";
|
|
40
|
-
import { scopeLifetime } from "./lifetime.js";
|
|
41
|
-
import { HistoryContinuations, HistoryRefusal, historyFailure } from "./history-controller.js";
|
|
42
|
-
import { HISTORY_HOST } from "./history-remote.js";
|
|
43
|
-
import { historySessionId, parseHistoryConfirmRequest, parseHistoryFailure, parseHistoryPreviewRequest } from "./history-codec.js";
|
|
44
|
-
/** Native authenticated local-operator RPC; browser payloads carry no admission authority. */
|
|
45
|
-
let DsmmHistoryHost = (() => {
|
|
46
|
-
let _classSuper = TypertRemoteService;
|
|
47
|
-
let _instanceExtraInitializers = [];
|
|
48
|
-
let _describe_decorators;
|
|
49
|
-
let _choices_decorators;
|
|
50
|
-
let _preview_decorators;
|
|
51
|
-
let _confirm_decorators;
|
|
52
|
-
return class DsmmHistoryHost extends _classSuper {
|
|
53
|
-
static {
|
|
54
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
|
|
55
|
-
_describe_decorators = [Remote];
|
|
56
|
-
_choices_decorators = [Remote];
|
|
57
|
-
_preview_decorators = [Remote];
|
|
58
|
-
_confirm_decorators = [Remote];
|
|
59
|
-
__esDecorate(this, null, _describe_decorators, { kind: "method", name: "describe", static: false, private: false, access: { has: obj => "describe" in obj, get: obj => obj.describe }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
60
|
-
__esDecorate(this, null, _choices_decorators, { kind: "method", name: "choices", static: false, private: false, access: { has: obj => "choices" in obj, get: obj => obj.choices }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
61
|
-
__esDecorate(this, null, _preview_decorators, { kind: "method", name: "preview", static: false, private: false, access: { has: obj => "preview" in obj, get: obj => obj.preview }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
62
|
-
__esDecorate(this, null, _confirm_decorators, { kind: "method", name: "confirm", static: false, private: false, access: { has: obj => "confirm" in obj, get: obj => obj.confirm }, metadata: _metadata }, null, _instanceExtraInitializers);
|
|
63
|
-
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
64
|
-
}
|
|
65
|
-
history = __runInitializers(this, _instanceExtraInitializers);
|
|
66
|
-
lifetime = new AbortController();
|
|
67
|
-
constructor(ctx, history) {
|
|
68
|
-
super(ctx, "dsmmHistory");
|
|
69
|
-
this.history = history;
|
|
70
|
-
scopeLifetime(ctx, "dsmm: close history RPC", () => this.lifetime.abort());
|
|
71
|
-
}
|
|
72
|
-
operator() {
|
|
73
|
-
try {
|
|
74
|
-
assertLocalSettingsOperator(this.ctx);
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
throw new HistoryRefusal("not-owned");
|
|
78
|
-
}
|
|
79
|
-
const ctx = this.ctx, invocation = ctx.invocation;
|
|
80
|
-
const connection = ctx.get("connection");
|
|
81
|
-
const owner = Reflect.get(connection, symbols.original) ?? connection;
|
|
82
|
-
const peer = invocation.peer;
|
|
83
|
-
const signal = AbortSignal.any([invocation.signal, peer.signal, this.lifetime.signal]);
|
|
84
|
-
const assertOwner = () => {
|
|
85
|
-
this.lifetime.signal.throwIfAborted();
|
|
86
|
-
peer.signal.throwIfAborted();
|
|
87
|
-
const current = ctx.get("connection");
|
|
88
|
-
if (!current || (Reflect.get(current, symbols.original) ?? current) !== owner || current.browserPeer !== peer
|
|
89
|
-
|| ctx.get("webServer")?.host !== "127.0.0.1" || ctx.get("settings")?.writable !== true)
|
|
90
|
-
throw new HistoryRefusal("not-owned");
|
|
91
|
-
};
|
|
92
|
-
return { peer, connection: owner, peerSignal: peer.signal, signal, assertOwner,
|
|
93
|
-
assertCurrent: () => { signal.throwIfAborted(); assertOwner(); },
|
|
94
|
-
assertVisible: id => {
|
|
95
|
-
assertOwner();
|
|
96
|
-
const access = ctx.get("remoteAccess");
|
|
97
|
-
if (!(access instanceof RemoteAccessService) || !access.allows({ kind: "session", id: SessionId(id) }))
|
|
98
|
-
throw new HistoryRefusal("not-owned");
|
|
99
|
-
} };
|
|
100
|
-
}
|
|
101
|
-
async invoke(operation) {
|
|
102
|
-
try {
|
|
103
|
-
return await operation(getTraceable(this.ctx, this.history), this.operator());
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
throw new RemoteError("dsmm-history/refused", "The Host refused history continuation.", parseHistoryFailure(historyFailure(error)));
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
describe(sessionId) { return this.invoke((history, operator) => history.describe(historySessionId(sessionId), operator)); }
|
|
110
|
-
choices() { return this.invoke((history, operator) => history.choices(operator)); }
|
|
111
|
-
preview(sessionId, input) {
|
|
112
|
-
return this.invoke((history, operator) => {
|
|
113
|
-
const request = parseHistoryPreviewRequest(input);
|
|
114
|
-
if (historySessionId(sessionId) !== request.sessionId)
|
|
115
|
-
throw new HistoryRefusal("validation");
|
|
116
|
-
return history.preview(request, operator);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
confirm(sessionId, input) {
|
|
120
|
-
return this.invoke((history, operator) => {
|
|
121
|
-
const request = parseHistoryConfirmRequest(input);
|
|
122
|
-
if (historySessionId(sessionId) !== request.sessionId)
|
|
123
|
-
throw new HistoryRefusal("validation");
|
|
124
|
-
return history.confirm(request, operator);
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
})();
|
|
129
|
-
export { DsmmHistoryHost };
|
|
130
|
-
export function registerHistoryContinuationRpc(ctx, candidates, admission) {
|
|
131
|
-
const history = new HistoryContinuations(ctx, candidates, admission);
|
|
132
|
-
const host = new DsmmHistoryHost(ctx, history);
|
|
133
|
-
ctx.typert.register(HISTORY_HOST);
|
|
134
|
-
return host;
|
|
135
|
-
}
|
|
136
|
-
//# sourceMappingURL=history-rpc.js.map
|
package/lib/history-support.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
/** Supply these native plugin configs before their constructors or configured restores run. */
|
|
3
|
-
export declare const DSMM_HISTORY_HOST_CONFIG: Readonly<{
|
|
4
|
-
agentLoop: Readonly<{
|
|
5
|
-
activationAdmissionRequired: true;
|
|
6
|
-
}>;
|
|
7
|
-
sessionController: Readonly<{
|
|
8
|
-
activateOnFollow: false;
|
|
9
|
-
}>;
|
|
10
|
-
}>;
|
|
11
|
-
/** Mount independently from the Core so failed configuration cannot reopen the Client gate. */
|
|
12
|
-
export declare function apply(ctx: Context): void;
|
|
13
|
-
/** A present patched loop becomes fail-closed before asynchronous DSMM configuration loading. */
|
|
14
|
-
export declare function requireHistoryAdmission(ctx: Context): void;
|
|
15
|
-
//# sourceMappingURL=history-support.d.ts.map
|
package/lib/history-support.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/** Supply these native plugin configs before their constructors or configured restores run. */
|
|
2
|
-
export const DSMM_HISTORY_HOST_CONFIG = Object.freeze({
|
|
3
|
-
agentLoop: Object.freeze({ activationAdmissionRequired: true }),
|
|
4
|
-
sessionController: Object.freeze({ activateOnFollow: false }),
|
|
5
|
-
});
|
|
6
|
-
/** Mount independently from the Core so failed configuration cannot reopen the Client gate. */
|
|
7
|
-
export function apply(ctx) {
|
|
8
|
-
requireHistoryAdmission(ctx);
|
|
9
|
-
ctx.events.on("webserver/index-inject", (rows) => {
|
|
10
|
-
rows.push({ kind: "global", name: "__DSMM_HISTORY_REQUIRED__", value: true });
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
/** A present patched loop becomes fail-closed before asynchronous DSMM configuration loading. */
|
|
14
|
-
export function requireHistoryAdmission(ctx) {
|
|
15
|
-
ctx.inject(["agentLoop"], scope => {
|
|
16
|
-
const loop = scope.agentLoop;
|
|
17
|
-
if (typeof loop.requireActivationAdmission === "function")
|
|
18
|
-
loop.requireActivationAdmission();
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=history-support.js.map
|
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
|