@dsmm/dsmm 0.3.1 → 0.3.2

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.
Files changed (119) hide show
  1. package/cordis.patch.yml +9 -0
  2. package/docs/compatibility.md +10 -0
  3. package/docs/releasing.md +25 -65
  4. package/docs/roadmap.md +44 -2
  5. package/lib/client/ChildPermissions.d.ts +43 -0
  6. package/lib/client/ChildPermissions.js +100 -0
  7. package/lib/client/ChildrenPanel.d.ts +4 -1
  8. package/lib/client/ChildrenPanel.js +3 -3
  9. package/lib/client/DeploymentFields.d.ts +6 -2
  10. package/lib/client/DeploymentFields.js +8 -6
  11. package/lib/client/DeploymentPage.d.ts +4 -1
  12. package/lib/client/DeploymentPage.js +5 -4
  13. package/lib/client/HistoryContinuation.d.ts +7 -0
  14. package/lib/client/HistoryContinuation.js +22 -0
  15. package/lib/client/PermissionPanelEntry.d.ts +8 -0
  16. package/lib/client/PermissionPanelEntry.js +11 -0
  17. package/lib/client/PermissionsPanel.d.ts +3 -1
  18. package/lib/client/PermissionsPanel.js +3 -2
  19. package/lib/client/ProfilesSection.js +3 -3
  20. package/lib/client/RoleAvailability.js +1 -1
  21. package/lib/client/SessionProfiles.js +21 -18
  22. package/lib/client/TemporaryPermissions.d.ts +21 -0
  23. package/lib/client/TemporaryPermissions.js +94 -0
  24. package/lib/client/children-locales.d.ts +4 -4
  25. package/lib/client/controller.d.ts +17 -0
  26. package/lib/client/controller.js +101 -18
  27. package/lib/client/deployment-locales.js +26 -26
  28. package/lib/client/history-controller.d.ts +29 -0
  29. package/lib/client/history-controller.js +111 -0
  30. package/lib/client/history-entry.d.ts +11 -0
  31. package/lib/client/history-entry.js +106 -0
  32. package/lib/client/history-locales.d.ts +95 -0
  33. package/lib/client/history-locales.js +41 -0
  34. package/lib/client/index.js +16 -3
  35. package/lib/client/locales.d.ts +6 -0
  36. package/lib/client/locales.js +104 -92
  37. package/lib/client/permission-locales.d.ts +26 -0
  38. package/lib/client/permission-locales.js +55 -35
  39. package/lib/client/temporary-permission-client.d.ts +20 -0
  40. package/lib/client/temporary-permission-client.js +52 -0
  41. package/lib/client/temporary-permission-entry.d.ts +6 -0
  42. package/lib/client/temporary-permission-entry.js +56 -0
  43. package/lib/client.js +3881 -1981
  44. package/lib/history-candidates.d.ts +30 -0
  45. package/lib/history-candidates.js +176 -0
  46. package/lib/history-codec.d.ts +11 -0
  47. package/lib/history-codec.js +102 -0
  48. package/lib/history-contract.d.ts +44 -0
  49. package/lib/history-contract.js +2 -0
  50. package/lib/history-controller.d.ts +42 -0
  51. package/lib/history-controller.js +329 -0
  52. package/lib/history-policy.d.ts +4 -0
  53. package/lib/history-policy.js +8 -0
  54. package/lib/history-remote.d.ts +28 -0
  55. package/lib/history-remote.js +17 -0
  56. package/lib/history-rpc.d.ts +24 -0
  57. package/lib/history-rpc.js +136 -0
  58. package/lib/history-support.d.ts +15 -0
  59. package/lib/history-support.js +21 -0
  60. package/lib/history-types.d.ts +67 -0
  61. package/lib/history-types.js +2 -0
  62. package/lib/index.d.ts +2 -0
  63. package/lib/index.js +24 -6
  64. package/lib/native-admission.d.ts +21 -0
  65. package/lib/native-admission.js +206 -16
  66. package/lib/permission-child-control.d.ts +36 -0
  67. package/lib/permission-child-control.js +164 -0
  68. package/lib/permission-control.d.ts +2 -0
  69. package/lib/permission-control.js +7 -0
  70. package/lib/permission-controller.js +2 -2
  71. package/lib/permission-exec-argv.d.ts +32 -0
  72. package/lib/permission-exec-argv.js +171 -0
  73. package/lib/permission-fs-search.js +2 -1
  74. package/lib/permission-fs.js +2 -1
  75. package/lib/permission-native-rules.js +3 -3
  76. package/lib/permission-temporary-files.d.ts +19 -0
  77. package/lib/permission-temporary-files.js +248 -0
  78. package/lib/permission-temporary-grants.d.ts +106 -0
  79. package/lib/permission-temporary-grants.js +198 -0
  80. package/lib/permission-temporary-install.d.ts +25 -0
  81. package/lib/permission-temporary-install.js +86 -0
  82. package/lib/permission-temporary-remote.d.ts +19 -0
  83. package/lib/permission-temporary-remote.js +75 -0
  84. package/lib/permission-temporary-rpc.d.ts +37 -0
  85. package/lib/permission-temporary-rpc.js +154 -0
  86. package/lib/permission-temporary-types.d.ts +47 -0
  87. package/lib/permission-temporary-types.js +2 -0
  88. package/lib/permission-temporary-web.d.ts +11 -0
  89. package/lib/permission-temporary-web.js +154 -0
  90. package/lib/permission-web.js +2 -1
  91. package/lib/preset-skills.d.ts +1 -1
  92. package/lib/preset-skills.js +2 -2
  93. package/lib/profile-rpc.js +2 -0
  94. package/lib/profile-runtime.d.ts +12 -1
  95. package/lib/profile-runtime.js +122 -10
  96. package/lib/profile-store.d.ts +2 -2
  97. package/lib/profile-store.js +8 -1
  98. package/lib/profile-types.d.ts +1 -0
  99. package/lib/role-invocation.d.ts +1 -1
  100. package/lib/role-invocation.js +2 -2
  101. package/lib/role-subagents.js +16 -3
  102. package/lib/skills.d.ts +1 -0
  103. package/lib/skills.js +5 -1
  104. package/package.json +41 -33
  105. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-gateway@0.2.1-rc.2.patch +13291 -0
  106. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-api-remotes@0.2.1-rc.2.patch +9133 -0
  107. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-client-ui-approval@0.2.1-rc.2.patch +156 -0
  108. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-subagent@0.2.1-rc.2.patch +3546 -0
  109. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-user-approval@0.2.1-rc.2.patch +431 -0
  110. package/patches/dsh-approval-settlement/@deepseek-ai__dsh-web@0.2.1-rc.2.patch +119 -0
  111. package/patches/dsh-approval-settlement/README.md +41 -0
  112. package/patches/dsh-approval-settlement/metadata.json +10 -0
  113. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-loop@0.2.1-rc.2.patch +383 -0
  114. package/patches/dsh-session-activation/@deepseek-ai__dsh-agent-preset-registry@0.2.1-rc.2.patch +55 -0
  115. package/patches/dsh-session-activation/@deepseek-ai__dsh-api-session-controller@0.2.1-rc.2.patch +16673 -0
  116. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-subagent@0.2.1-rc.2.patch +29 -0
  117. package/patches/dsh-session-activation/@deepseek-ai__dsh-client-ui-workspace@0.2.1-rc.2.patch +196 -0
  118. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence-jsonl@0.2.1-rc.2.patch +35 -0
  119. package/patches/dsh-session-activation/@deepseek-ai__dsh-session-persistence@0.2.1-rc.2.patch +40 -0
@@ -0,0 +1,154 @@
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 { Remote, RemoteError, TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
36
+ import { SessionId } from "@deepseek-ai/dsh-session";
37
+ import { permissionOriginal } from "./permission-control.js";
38
+ import { TEMPORARY_PERMISSION_HOST, parseTemporaryDelivery, parseTemporaryDuration, parseTemporaryId } from "./permission-temporary-remote.js";
39
+ let DsmmTemporaryPermissionsHost = (() => {
40
+ let _classSuper = TypertRemoteService;
41
+ let _instanceExtraInitializers = [];
42
+ let _describe_decorators;
43
+ let _request_decorators;
44
+ let _retain_decorators;
45
+ let _permit_decorators;
46
+ let _revoke_decorators;
47
+ let _child_decorators;
48
+ let _enableChild_decorators;
49
+ let _revokeChild_decorators;
50
+ return class DsmmTemporaryPermissionsHost extends _classSuper {
51
+ static {
52
+ const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
53
+ _describe_decorators = [Remote];
54
+ _request_decorators = [Remote];
55
+ _retain_decorators = [Remote];
56
+ _permit_decorators = [Remote];
57
+ _revoke_decorators = [Remote];
58
+ _child_decorators = [Remote];
59
+ _enableChild_decorators = [Remote];
60
+ _revokeChild_decorators = [Remote];
61
+ __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);
62
+ __esDecorate(this, null, _request_decorators, { kind: "method", name: "request", static: false, private: false, access: { has: obj => "request" in obj, get: obj => obj.request }, metadata: _metadata }, null, _instanceExtraInitializers);
63
+ __esDecorate(this, null, _retain_decorators, { kind: "method", name: "retain", static: false, private: false, access: { has: obj => "retain" in obj, get: obj => obj.retain }, metadata: _metadata }, null, _instanceExtraInitializers);
64
+ __esDecorate(this, null, _permit_decorators, { kind: "method", name: "permit", static: false, private: false, access: { has: obj => "permit" in obj, get: obj => obj.permit }, metadata: _metadata }, null, _instanceExtraInitializers);
65
+ __esDecorate(this, null, _revoke_decorators, { kind: "method", name: "revoke", static: false, private: false, access: { has: obj => "revoke" in obj, get: obj => obj.revoke }, metadata: _metadata }, null, _instanceExtraInitializers);
66
+ __esDecorate(this, null, _child_decorators, { kind: "method", name: "child", static: false, private: false, access: { has: obj => "child" in obj, get: obj => obj.child }, metadata: _metadata }, null, _instanceExtraInitializers);
67
+ __esDecorate(this, null, _enableChild_decorators, { kind: "method", name: "enableChild", static: false, private: false, access: { has: obj => "enableChild" in obj, get: obj => obj.enableChild }, metadata: _metadata }, null, _instanceExtraInitializers);
68
+ __esDecorate(this, null, _revokeChild_decorators, { kind: "method", name: "revokeChild", static: false, private: false, access: { has: obj => "revokeChild" in obj, get: obj => obj.revokeChild }, metadata: _metadata }, null, _instanceExtraInitializers);
69
+ if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
70
+ }
71
+ grants = __runInitializers(this, _instanceExtraInitializers);
72
+ options;
73
+ lifetime = new AbortController();
74
+ constructor(ctx, grants, options) {
75
+ super(ctx, "dsmmTemporaryPermissions");
76
+ this.grants = grants;
77
+ this.options = options;
78
+ ctx.effect(() => () => this.lifetime.abort());
79
+ }
80
+ invoke(sessionId, operation) {
81
+ try {
82
+ const id = SessionId(parseTemporaryId(sessionId)), invocation = this.ctx.invocation;
83
+ const connection = this.ctx.get("connection");
84
+ const peer = invocation?.peer, registry = this.ctx.get("agents"), agent = registry?.get(id);
85
+ if (!connection || !peer || peer !== connection.browserPeer || !agent || peer.signal.aborted || invocation.signal.aborted
86
+ || this.lifetime.signal.aborted)
87
+ throw new Error("Operator ownership unavailable.");
88
+ if (agent.session.id !== sessionId)
89
+ throw new Error("Session identity mismatch.");
90
+ if (!registry.roots().includes(agent) || agent.session.header.origin === "subagent") {
91
+ const child = this.options.authorizeChild?.(peer, agent) ?? this.options.children?.authorizeChild(peer, agent);
92
+ if (!child)
93
+ throw new Error("Explicit child operator authorization required.");
94
+ child.assertCurrent();
95
+ }
96
+ if (permissionOriginal(this.ctx.get("connection")) !== permissionOriginal(connection))
97
+ throw new Error("Connection changed.");
98
+ return operation(agent, peer);
99
+ }
100
+ catch (error) {
101
+ throw new RemoteError("dsmm-temporary-permissions/refused", "Temporary permission operation refused.", { code: error instanceof TypeError ? "validation" : "unavailable" });
102
+ }
103
+ }
104
+ delivery(sessionId, input, operation) {
105
+ const delivery = parseTemporaryDelivery(input);
106
+ return this.invoke(sessionId, (_agent, peer) => {
107
+ const view = this.grants.request(peer, delivery.requestId, delivery.deliveryId);
108
+ if (view.sessionId !== sessionId)
109
+ throw new Error("Approval belongs to another session.");
110
+ return operation(peer, delivery);
111
+ });
112
+ }
113
+ describe(sessionId) { return this.invoke(sessionId, agent => this.grants.list(agent)); }
114
+ request(sessionId, delivery) {
115
+ return this.delivery(sessionId, delivery, (peer, value) => this.grants.request(peer, value.requestId, value.deliveryId));
116
+ }
117
+ retain(sessionId, delivery, duration, scope = "exact") {
118
+ return this.delivery(sessionId, delivery, (peer, value) => this.grants.retain(peer, value.requestId, value.deliveryId, parseTemporaryDuration(duration), parseTemporaryId(scope)));
119
+ }
120
+ permit(sessionId, delivery) {
121
+ return this.delivery(sessionId, delivery, (peer, value) => this.grants.permit(peer, value.requestId, value.deliveryId));
122
+ }
123
+ revoke(sessionId, grantId) { return this.invoke(sessionId, agent => this.grants.revoke(agent, parseTemporaryId(grantId))); }
124
+ async childOperation(sessionId, childSessionId, action) {
125
+ try {
126
+ return await this.invoke(sessionId, (parent, peer) => {
127
+ const children = this.options.children, registry = this.ctx.get("agents"), child = registry?.get(SessionId(parseTemporaryId(childSessionId)));
128
+ const connection = permissionOriginal(this.ctx.get("connection"));
129
+ if (!children || !child || !registry.roots().includes(parent) || !registry.isOwnedBy(child.id, parent))
130
+ throw new Error("Exact direct child required.");
131
+ const check = () => this.invoke(sessionId, (current, currentPeer) => {
132
+ if (current !== parent || currentPeer !== peer || permissionOriginal(this.ctx.get("connection")) !== connection
133
+ || registry.get(child.id) !== child || !registry.isOwnedBy(child.id, parent))
134
+ throw new Error("Child operator changed.");
135
+ });
136
+ return action === "describe" ? children.describe(parent, child) : children[action](parent, child, check);
137
+ });
138
+ }
139
+ catch {
140
+ throw new RemoteError("dsmm-temporary-permissions/refused", "Child permission operation refused.", { code: "unavailable" });
141
+ }
142
+ }
143
+ child(sessionId, childSessionId) { return this.childOperation(sessionId, childSessionId, "describe"); }
144
+ enableChild(sessionId, childSessionId) { return this.childOperation(sessionId, childSessionId, "enable"); }
145
+ revokeChild(sessionId, childSessionId) { return this.childOperation(sessionId, childSessionId, "revoke"); }
146
+ };
147
+ })();
148
+ export { DsmmTemporaryPermissionsHost };
149
+ export function registerTemporaryPermissionRpc(ctx, grants, options = {}) {
150
+ const host = new DsmmTemporaryPermissionsHost(ctx, grants, options);
151
+ ctx.typert.register(TEMPORARY_PERMISSION_HOST);
152
+ return host;
153
+ }
154
+ //# sourceMappingURL=permission-temporary-rpc.js.map
@@ -0,0 +1,47 @@
1
+ /** Wire views contain no executable authority or environment values. */
2
+ export type TemporaryPermissionDuration = "once" | "session" | "15min" | "1h";
3
+ export interface TemporaryPermissionDelivery {
4
+ readonly requestId: string;
5
+ readonly deliveryId: string;
6
+ }
7
+ export interface ChildPermissionView {
8
+ readonly parentSessionId: string;
9
+ readonly childSessionId: string;
10
+ readonly project: string;
11
+ readonly state: "disabled" | "enabled" | "unavailable";
12
+ readonly canEnable: boolean;
13
+ readonly canRevoke: boolean;
14
+ readonly role?: string;
15
+ readonly readOnly?: boolean;
16
+ }
17
+ export interface ChildPermissionRemote {
18
+ child(sessionId: string, childSessionId: string): Promise<ChildPermissionView>;
19
+ enableChild(sessionId: string, childSessionId: string): Promise<ChildPermissionView>;
20
+ revokeChild(sessionId: string, childSessionId: string): Promise<ChildPermissionView>;
21
+ }
22
+ export interface TemporaryPermissionGrantView {
23
+ readonly id: string;
24
+ readonly sessionId: string;
25
+ readonly tool: string;
26
+ readonly summary: string;
27
+ readonly duration: Exclude<TemporaryPermissionDuration, "once">;
28
+ readonly remainingMs?: number;
29
+ }
30
+ export interface TemporaryPermissionRequestView extends TemporaryPermissionDelivery {
31
+ readonly sessionId: string;
32
+ readonly tool: string;
33
+ readonly summary: string;
34
+ readonly reusable: boolean;
35
+ readonly scopes?: readonly {
36
+ readonly id: string;
37
+ readonly summary: string;
38
+ }[];
39
+ }
40
+ export interface TemporaryPermissionRemote {
41
+ describe(sessionId: string): Promise<readonly TemporaryPermissionGrantView[]>;
42
+ request(sessionId: string, delivery: TemporaryPermissionDelivery): Promise<TemporaryPermissionRequestView>;
43
+ retain(sessionId: string, delivery: TemporaryPermissionDelivery, duration: TemporaryPermissionDuration, scope?: string): Promise<string>;
44
+ permit(sessionId: string, delivery: TemporaryPermissionDelivery): Promise<string | null>;
45
+ revoke(sessionId: string, grantId: string): Promise<readonly TemporaryPermissionGrantView[]>;
46
+ }
47
+ //# sourceMappingURL=permission-temporary-types.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=permission-temporary-types.js.map
@@ -0,0 +1,11 @@
1
+ import type { Context } from "@deepseek-ai/cordis";
2
+ import type { TemporaryFileOptions } from "./permission-temporary-files.js";
3
+ /** Captures only the native Web Fetch definition; search remains unchanged. */
4
+ export declare function temporaryWebToolScope(scope: Context): Context;
5
+ export declare function installTemporaryWebPermissions(ctx: Context, options: TemporaryFileOptions): () => void;
6
+ declare module "@deepseek-ai/cordis" {
7
+ interface Context {
8
+ dsmmTemporaryWebPermissions: AbortSignal;
9
+ }
10
+ }
11
+ //# sourceMappingURL=permission-temporary-web.d.ts.map
@@ -0,0 +1,154 @@
1
+ import { AsyncLocalStorage } from "node:async_hooks";
2
+ import { WebRuntime } from "@deepseek-ai/dsh-web";
3
+ import { HttpFetchProvider } from "@deepseek-ai/dsh-web-fetch-http";
4
+ import { FakeIpHttpFetchProvider } from "./web-fetch-fakeip.js";
5
+ import { permissionOriginal } from "./permission-control.js";
6
+ const registrations = new WeakMap();
7
+ const running = new AsyncLocalStorage();
8
+ function supported(provider) {
9
+ const prototype = Object.getPrototypeOf(provider);
10
+ return (prototype === HttpFetchProvider.prototype || prototype === FakeIpHttpFetchProvider.prototype)
11
+ && Reflect.get(provider, "fetch") === prototype.fetch && Reflect.get(provider, "available") === prototype.available;
12
+ }
13
+ /** Captures only the native Web Fetch definition; search remains unchanged. */
14
+ export function temporaryWebToolScope(scope) {
15
+ const web = scope.get("web"), tools = scope.tools;
16
+ if (!web || Object.getPrototypeOf(permissionOriginal(web)) !== WebRuntime.prototype || typeof web.prepareFetch !== "function" || typeof web.fetchPrepared !== "function")
17
+ return scope;
18
+ const facade = new Proxy(web, { get(target, key) {
19
+ if (key === "fetch")
20
+ return (request, signal) => {
21
+ const active = running.getStore();
22
+ if (!active || active.registration.web !== web)
23
+ return target.fetch(request, signal);
24
+ const { prepared } = active;
25
+ if (request.url !== prepared.capability.request.url || signal !== prepared.signal)
26
+ throw new Error("Native fetch request changed.");
27
+ return target.fetchPrepared(prepared.capability, { signal: AbortSignal.any([prepared.signal, prepared.execution.signal]), beforeDispatch() {
28
+ prepared.execution.assertIntegrity();
29
+ prepared.lease?.consume();
30
+ } });
31
+ };
32
+ const value = Reflect.get(target, key, target);
33
+ return typeof value === "function" ? value.bind(target) : value;
34
+ } });
35
+ const toolFacade = new Proxy(tools, { get(target, key) {
36
+ if (key !== "register") {
37
+ const value = Reflect.get(target, key, target);
38
+ return typeof value === "function" ? value.bind(target) : value;
39
+ }
40
+ return (native) => {
41
+ if (native.name !== "web_fetch")
42
+ return tools.register(native);
43
+ const body = native.execute;
44
+ const definition = { ...native, async execute(args, exec) {
45
+ const prepared = registration.pending.get(exec.token);
46
+ if (!prepared) {
47
+ const controller = scope.get("dsmmTemporaryWebPermissions");
48
+ if (controller && !controller.aborted && !registration.bypass.delete(exec.token))
49
+ throw new Error("Controlled fetch preparation did not complete.");
50
+ return body(args, exec);
51
+ }
52
+ try {
53
+ prepared.execution.assertIntegrity();
54
+ prepared.lease?.check();
55
+ return await running.run({ registration, prepared }, () => body(args, exec));
56
+ }
57
+ finally {
58
+ prepared.lease?.finish();
59
+ registration.pending.delete(exec.token);
60
+ }
61
+ } };
62
+ const registration = { scope, web, definition, lifetime: new AbortController(), pending: new Map(), bypass: new Set() };
63
+ registrations.set(definition, registration);
64
+ const unregister = tools.register(definition);
65
+ return scope.effect(() => () => {
66
+ registration.lifetime.abort();
67
+ registrations.delete(definition);
68
+ for (const prepared of registration.pending.values())
69
+ prepared.lease?.finish();
70
+ registration.pending.clear();
71
+ unregister();
72
+ });
73
+ };
74
+ } });
75
+ return scope.extend({ web: facade, tools: toolFacade });
76
+ }
77
+ export function installTemporaryWebPermissions(ctx, options) {
78
+ const lifetime = new AbortController(), active = new Set();
79
+ ctx.provide("dsmmTemporaryWebPermissions", lifetime.signal);
80
+ const pre = ctx.on("tools/pre-execute", async (exec, next) => {
81
+ const definition = ctx.tools.get(exec.name, exec.agent), registration = definition && registrations.get(definition);
82
+ if (!registration || !exec.agent)
83
+ return next();
84
+ const decision = await next();
85
+ if (decision.kind === "deny" || decision.kind === "cancel")
86
+ return decision;
87
+ active.add(registration);
88
+ const args = exec.arguments;
89
+ let url;
90
+ try {
91
+ url = new URL(args.url);
92
+ }
93
+ catch {
94
+ registration.bypass.add(exec.token);
95
+ return decision;
96
+ }
97
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password) {
98
+ registration.bypass.add(exec.token);
99
+ return decision;
100
+ }
101
+ await options.refresh?.();
102
+ const authority = options.capture(exec), { web, scope } = registration;
103
+ const original = permissionOriginal(web), body = definition.execute, argsJson = JSON.stringify(args);
104
+ const prepare = Reflect.get(original, "prepareFetch"), fetchPrepared = Reflect.get(original, "fetchPrepared");
105
+ const capability = web.prepareFetch({ url: args.url });
106
+ const signal = AbortSignal.any([exec.signal, authority.sessionSignal, lifetime.signal, registration.lifetime.signal]);
107
+ const check = () => {
108
+ signal.throwIfAborted();
109
+ authority.assertIntegrity();
110
+ const current = scope.get("web");
111
+ if (!current || permissionOriginal(current) !== original || Reflect.get(original, "prepareFetch") !== prepare || Reflect.get(original, "fetchPrepared") !== fetchPrepared
112
+ || prepare !== WebRuntime.prototype.prepareFetch || fetchPrepared !== WebRuntime.prototype.fetchPrepared
113
+ || ctx.tools.get(exec.name, exec.agent) !== definition || definition.execute !== body || JSON.stringify(exec.arguments) !== argsJson)
114
+ throw new Error("Native fetch execution changed.");
115
+ };
116
+ check();
117
+ authority.assertProgramAllowed();
118
+ const execution = { token: exec.token, agent: exec.agent, owner: authority.owner, generation: authority.generation,
119
+ registration: definition, provider: capability.registration, sessionId: exec.agent.id, tool: exec.name,
120
+ project: exec.agent.session.header.cwd ?? "", target: url.origin, summary: `web_fetch: ${url.origin}; native provider restrictions remain in effect.`,
121
+ reusable: supported(capability.provider), signal, sessionSignal: authority.sessionSignal, assertIntegrity: check,
122
+ assertReusable() {
123
+ check();
124
+ authority.assertProgramAllowed();
125
+ authority.assertRetentionAllowed?.();
126
+ const approval = scope.get("approval");
127
+ if (!supported(capability.provider) || !approval || (approval.overrideOf(exec.agent.session) ?? approval.config.policy ?? "ask") !== "ask")
128
+ throw new Error("Native fetch permission is no longer reusable.");
129
+ } };
130
+ const lease = decision.kind === "ask" ? await options.grants.approve({ agent: exec.agent, callId: exec.callId, toolName: exec.name, signal,
131
+ reason: `${decision.reason}\n${execution.summary}` }, execution) : undefined;
132
+ registration.pending.set(exec.token, { capability, execution, signal: exec.signal, lease });
133
+ return { kind: "allow" };
134
+ }, { prepend: true, global: true });
135
+ const result = ctx.on("tools/result", exec => {
136
+ for (const registration of active) {
137
+ registration.pending.get(exec.token)?.lease?.finish();
138
+ registration.pending.delete(exec.token);
139
+ registration.bypass.delete(exec.token);
140
+ }
141
+ }, { global: true });
142
+ return ctx.effect(() => () => {
143
+ lifetime.abort();
144
+ pre();
145
+ result();
146
+ for (const registration of active) {
147
+ for (const prepared of registration.pending.values())
148
+ prepared.lease?.finish();
149
+ registration.pending.clear();
150
+ }
151
+ active.clear();
152
+ });
153
+ }
154
+ //# sourceMappingURL=permission-temporary-web.js.map
@@ -1,7 +1,8 @@
1
1
  import * as Native from "@deepseek-ai/dsh-tool-web";
2
2
  import { DsmmPermissionController } from "./permission-controller.js";
3
+ import { temporaryWebToolScope } from "./permission-temporary-web.js";
3
4
  export { Config, inject, name } from "@deepseek-ai/dsh-tool-web";
4
5
  export function apply(ctx, config) {
5
- return Native.apply(DsmmPermissionController.toolScope(ctx, "web"), config);
6
+ return Native.apply(temporaryWebToolScope(DsmmPermissionController.toolScope(ctx, "web")), config);
6
7
  }
7
8
  //# sourceMappingURL=permission-web.js.map
@@ -2,5 +2,5 @@ import type { DshAgent, DshContext } from "./dsh-types.js";
2
2
  import type { DsmmSettingsGetter } from "./settings.js";
3
3
  import type { DeepworkModeController } from "./state.js";
4
4
  /** Admission owns installation; mode changes only invalidate this Agent's lazy provider. */
5
- export declare function registerAgentSkills(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter, agent: DshAgent, lifetime: AbortSignal): void;
5
+ export declare function registerAgentSkills(ctx: DshContext, controller: DeepworkModeController, getSettings: DsmmSettingsGetter, agent: DshAgent, lifetime: AbortSignal, catalogReady?: () => boolean): void;
6
6
  //# sourceMappingURL=preset-skills.d.ts.map
@@ -3,7 +3,7 @@ import { registerBundledSkills } from "./skills.js";
3
3
  import { nativeAgentContext, scopeParentOf } from "./native-scope.js";
4
4
  const bindings = new WeakMap();
5
5
  /** Admission owns installation; mode changes only invalidate this Agent's lazy provider. */
6
- export function registerAgentSkills(ctx, controller, getSettings, agent, lifetime) {
6
+ export function registerAgentSkills(ctx, controller, getSettings, agent, lifetime, catalogReady) {
7
7
  const refresh = bindings.get(agent);
8
8
  if (refresh) {
9
9
  refresh();
@@ -26,7 +26,7 @@ export function registerAgentSkills(ctx, controller, getSettings, agent, lifetim
26
26
  return;
27
27
  }
28
28
  remove();
29
- mounted = { parent, registry: raw, provider: registerBundledSkills(agentCtx, getTraceable(agentCtx, raw), { agent, controller, getSettings }) };
29
+ mounted = { parent, registry: raw, provider: registerBundledSkills(agentCtx, getTraceable(agentCtx, raw), { agent, controller, getSettings, catalogReady }) };
30
30
  };
31
31
  const stopMode = controller.watch(changed => { if (changed === agent)
32
32
  reconcile(); });
@@ -132,6 +132,8 @@ let DsmmProfilesHost = (() => {
132
132
  const checkAuthority = () => {
133
133
  if (signal.aborted)
134
134
  throw new DsmmProfileError("cancelled", "The session profile operation was cancelled; no late selection is allowed.");
135
+ if (!readOnly)
136
+ assertLocalSettingsOperator(this.ctx);
135
137
  const currentConnection = this.ctx.get("connection");
136
138
  const currentOwner = currentConnection === undefined ? undefined : Reflect.get(currentConnection, symbols.original) ?? currentConnection;
137
139
  if (currentOwner !== connectionOwner || currentConnection?.browserPeer !== invocation.peer) {
@@ -6,6 +6,7 @@ import type { DsmmProfileAdmission, DsmmSettings, DsmmSettingsGetter, DsmmDeploy
6
6
  import { DeepworkModeController } from "./state.js";
7
7
  import type { DsmmMountedPermissionGetter } from "./modules.js";
8
8
  export interface DsmmProfileRuntimeStore {
9
+ readonly profileDir?: string;
9
10
  readonly readOnly?: boolean;
10
11
  readonly origin?: "central" | "legacy" | "explicit";
11
12
  readonly writeRestriction?: string;
@@ -36,6 +37,12 @@ export type DsmmSessionProfileSnapshot = SessionProfileSnapshot;
36
37
  interface AdmittedProfile extends ProfileSelectionState, DsmmProfileAdmission {
37
38
  baseline: DsmmSettings;
38
39
  }
40
+ export interface PreparedHistoryProfile {
41
+ readonly admission: DsmmProfileAdmission;
42
+ readonly label?: string;
43
+ assertCurrent(): undefined;
44
+ revalidate(signal: AbortSignal): Promise<void>;
45
+ }
39
46
  /** Configuration transactions and immutable snapshots; native admission owns Agent binding. */
40
47
  export declare class DsmmProfileRuntime {
41
48
  private readonly ctx;
@@ -47,6 +54,7 @@ export declare class DsmmProfileRuntime {
47
54
  private document;
48
55
  private readonly bound;
49
56
  private readonly observations;
57
+ private readonly historyAdmissions;
50
58
  private disposed;
51
59
  private queue;
52
60
  private readonly mode;
@@ -58,10 +66,13 @@ export declare class DsmmProfileRuntime {
58
66
  /** Called only by the awaited native creation owner after all Agent-scoped installation. */
59
67
  publish(agent: DshAgent, admission: DsmmProfileAdmission): void;
60
68
  release(agent: DshAgent): void;
69
+ /** Prepare an explicit current choice; historical selection files and epochs are not read. */
70
+ prepareHistory(profileId: string | null, signal: AbortSignal): Promise<PreparedHistoryProfile>;
61
71
  prepareRoot(agent: DshAgent, signal: AbortSignal): Promise<AdmittedProfile>;
62
72
  getSession(agent: DshAgent): Promise<DsmmSessionProfileSnapshot>;
73
+ private sessionSnapshot;
63
74
  selectMode(request: SessionModeSelectRequest, agent: DshAgent, signal?: AbortSignal, authority?: () => void): Promise<DsmmSessionProfileSnapshot>;
64
- selectSession(_request: SessionProfileSelectRequest, agent: DshAgent, _signal?: AbortSignal, _authority?: () => void): Promise<SessionProfileSnapshot>;
75
+ selectSession(request: SessionProfileSelectRequest, agent: DshAgent, signal?: AbortSignal, authority?: () => void): Promise<SessionProfileSnapshot>;
65
76
  private assertRoot;
66
77
  describe(): Promise<ProfileSnapshot>;
67
78
  read(id: string): Promise<ProfileReadResult>;