@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
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { PermissionRefusal, permissionOriginal } from "./permission-control.js";
|
|
2
|
-
import { TemporaryPermissionGrants } from "./permission-temporary-grants.js";
|
|
3
|
-
import { installPermissionExecArgv } from "./permission-exec-argv.js";
|
|
4
|
-
import { installTemporaryFilePermissions } from "./permission-temporary-files.js";
|
|
5
|
-
import { installTemporaryWebPermissions } from "./permission-temporary-web.js";
|
|
6
|
-
import { registerTemporaryPermissionRpc } from "./permission-temporary-rpc.js";
|
|
7
|
-
import { ChildPermissionControl } from "./permission-child-control.js";
|
|
8
|
-
import { DSMM_ROLES } from "./roles.js";
|
|
9
|
-
/** Composition from the real Core/role owners; no boolean ownership or test-provider authority. */
|
|
10
|
-
export function temporaryPermissionCapture(options, exec) {
|
|
11
|
-
const current = options.core.authority.current(exec), integrity = options.core.authority.captureIntegrity?.(exec);
|
|
12
|
-
if (!integrity || !integrity.signal || !exec.agent)
|
|
13
|
-
throw new PermissionRefusal("unavailable");
|
|
14
|
-
const snapshot = options.rules.getPolicy();
|
|
15
|
-
const assertIntegrity = () => {
|
|
16
|
-
integrity.assertCurrent();
|
|
17
|
-
options.roles.assertToolExecution(exec);
|
|
18
|
-
const tools = exec.agent.ctx.get("tools");
|
|
19
|
-
if (!tools || options.roles.toolDenial(exec.agent, exec.name, tools, exec))
|
|
20
|
-
throw new PermissionRefusal("denied");
|
|
21
|
-
};
|
|
22
|
-
return { owner: current.owner, generation: current.permissionRevision, sessionSignal: integrity.signal, assertIntegrity,
|
|
23
|
-
assertProgramAllowed() {
|
|
24
|
-
assertIntegrity();
|
|
25
|
-
options.core.authority.assertCurrent(current, exec);
|
|
26
|
-
if (options.rules.getPolicy() !== snapshot || options.rules.status().state !== "synced")
|
|
27
|
-
throw new PermissionRefusal("stale");
|
|
28
|
-
} };
|
|
29
|
-
}
|
|
30
|
-
/** Install in the same Host fiber as the Core authority, after the patched Approval/Gateway and rules owners. */
|
|
31
|
-
export function installTemporaryPermissions(ctx, options) {
|
|
32
|
-
const approval = ctx.get("approval"), gateway = ctx.get("typertGateway");
|
|
33
|
-
if (!options.rules.status().mounted || !approval || !gateway || typeof approval.settlement !== "function" || typeof gateway.registerApprovalPermits !== "function")
|
|
34
|
-
throw new PermissionRefusal("unavailable");
|
|
35
|
-
const grants = new TemporaryPermissionGrants(approval, gateway);
|
|
36
|
-
ctx.effect(() => () => grants.dispose());
|
|
37
|
-
const children = new ChildPermissionControl(ctx, grants, { refresh: () => options.rules.refresh(), capture(parent, child) {
|
|
38
|
-
options.core.assertWritable(parent);
|
|
39
|
-
const structural = child, root = parent;
|
|
40
|
-
options.roles.assertModuleAdmission(structural);
|
|
41
|
-
const identity = options.roles.identity(structural), parentIdentity = options.roles.identity(root);
|
|
42
|
-
const check = () => {
|
|
43
|
-
options.core.assertWritable(parent);
|
|
44
|
-
options.roles.assertModuleAdmission(structural);
|
|
45
|
-
const current = options.roles.identity(structural), currentParent = options.roles.identity(root);
|
|
46
|
-
if (!current.child || current.parent !== parent || current.epoch !== identity.epoch || current.role !== identity.role || current.readOnly !== identity.readOnly
|
|
47
|
-
|| currentParent.epoch !== parentIdentity.epoch || currentParent.role !== parentIdentity.role)
|
|
48
|
-
throw new PermissionRefusal("stale");
|
|
49
|
-
};
|
|
50
|
-
check();
|
|
51
|
-
return { check, role: identity.role, readOnly: identity.readOnly === true || DSMM_ROLES.find(role => role.id === identity.role)?.access === "read-only" };
|
|
52
|
-
} });
|
|
53
|
-
const capture = (exec) => {
|
|
54
|
-
const nativeApproval = exec.agent?.ctx.get("approval");
|
|
55
|
-
if (!nativeApproval || permissionOriginal(nativeApproval) !== permissionOriginal(approval))
|
|
56
|
-
throw new PermissionRefusal("unavailable");
|
|
57
|
-
const authority = temporaryPermissionCapture(options, exec);
|
|
58
|
-
return { ...authority, assertRetentionAllowed() {
|
|
59
|
-
if (!exec.agent || !ctx.get("agents")?.roots().includes(exec.agent) || exec.agent.session.header.origin === "subagent")
|
|
60
|
-
children.assertEnabled(exec.agent);
|
|
61
|
-
} };
|
|
62
|
-
};
|
|
63
|
-
const files = installTemporaryFilePermissions(ctx, { grants, capture, refresh: () => options.rules.refresh() });
|
|
64
|
-
const web = installTemporaryWebPermissions(ctx, { grants, capture, refresh: () => options.rules.refresh() });
|
|
65
|
-
const argv = options.argv && installPermissionExecArgv(ctx, { ...options.argv, grants, capture(exec) {
|
|
66
|
-
const authority = capture(exec);
|
|
67
|
-
return { ...authority, assertProgramAllowed() {
|
|
68
|
-
authority.assertProgramAllowed();
|
|
69
|
-
const { policy } = options.rules.getPolicy();
|
|
70
|
-
// Arbitrary argv cannot prove shell-rule equivalence or confined file reads.
|
|
71
|
-
if (policy.outsideReads === "deny" || policy.rules.some(rule => !rule.revoked && rule.action === "deny"
|
|
72
|
-
&& (rule.match.kind === "shell" || rule.match.kind === "outside-read")))
|
|
73
|
-
throw new PermissionRefusal("unavailable");
|
|
74
|
-
} };
|
|
75
|
-
} });
|
|
76
|
-
const argvDefinition = argv && ctx.tools.get("dsmm_exec_argv");
|
|
77
|
-
const refreshArgv = argvDefinition && ctx.on("tools/pre-execute", async (exec, next) => {
|
|
78
|
-
if (ctx.tools.get(exec.name, exec.agent) === argvDefinition)
|
|
79
|
-
await options.rules.refresh();
|
|
80
|
-
return next();
|
|
81
|
-
}, { prepend: true, global: true });
|
|
82
|
-
const rpc = registerTemporaryPermissionRpc(ctx, grants, { children });
|
|
83
|
-
ctx.on("agent/disposed", ({ agent }) => grants.revokeAgent(agent), { global: true });
|
|
84
|
-
return { grants, rpc, children, dispose() { children.dispose(); refreshArgv?.(); argv?.(); web(); files(); grants.dispose(); } };
|
|
85
|
-
}
|
|
86
|
-
//# sourceMappingURL=permission-temporary-install.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { TypertRemoteContribution } from "@deepseek-ai/dsh-typert-protocol";
|
|
2
|
-
import type { TypertContribution } from "@deepseek-ai/dsh-typert-registry";
|
|
3
|
-
import type { ChildPermissionView, TemporaryPermissionDelivery, TemporaryPermissionDuration, TemporaryPermissionGrantView, TemporaryPermissionRequestView } from "./permission-temporary-types.js";
|
|
4
|
-
export declare function parseTemporaryId(value: unknown): string;
|
|
5
|
-
export declare function parseTemporaryDuration(value: unknown): TemporaryPermissionDuration;
|
|
6
|
-
export declare function parseTemporaryDelivery(value: unknown): TemporaryPermissionDelivery;
|
|
7
|
-
export declare function parseTemporaryGrants(value: unknown): readonly TemporaryPermissionGrantView[];
|
|
8
|
-
export declare function parseTemporaryRequest(value: unknown): TemporaryPermissionRequestView;
|
|
9
|
-
export declare function parseChildPermission(value: unknown): ChildPermissionView;
|
|
10
|
-
export declare const TEMPORARY_PERMISSION_REMOTE: TypertRemoteContribution;
|
|
11
|
-
export declare const TEMPORARY_PERMISSION_HOST: TypertContribution;
|
|
12
|
-
declare module "@deepseek-ai/dsh-typert-protocol/types" {
|
|
13
|
-
interface RemoteErrorDetailsMap {
|
|
14
|
-
"dsmm-temporary-permissions/refused": {
|
|
15
|
-
code: string;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=permission-temporary-remote.d.ts.map
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
function row(value, required, optional = []) {
|
|
2
|
-
if (!value || typeof value !== "object" || Array.isArray(value) || required.some(key => !Object.hasOwn(value, key))
|
|
3
|
-
|| Object.keys(value).some(key => !required.includes(key) && !optional.includes(key)))
|
|
4
|
-
throw new TypeError("Invalid temporary permission DTO.");
|
|
5
|
-
return value;
|
|
6
|
-
}
|
|
7
|
-
export function parseTemporaryId(value) {
|
|
8
|
-
if (typeof value !== "string" || !value.length || value.length > 512 || /[\u0000-\u001f]/u.test(value))
|
|
9
|
-
throw new TypeError("Invalid temporary permission identity.");
|
|
10
|
-
return value;
|
|
11
|
-
}
|
|
12
|
-
export function parseTemporaryDuration(value) {
|
|
13
|
-
if (value !== "once" && value !== "session" && value !== "15min" && value !== "1h")
|
|
14
|
-
throw new TypeError("Invalid duration.");
|
|
15
|
-
return value;
|
|
16
|
-
}
|
|
17
|
-
export function parseTemporaryDelivery(value) {
|
|
18
|
-
const input = row(value, ["requestId", "deliveryId"]);
|
|
19
|
-
return { requestId: parseTemporaryId(input.requestId), deliveryId: parseTemporaryId(input.deliveryId) };
|
|
20
|
-
}
|
|
21
|
-
function summary(value) {
|
|
22
|
-
if (typeof value !== "string" || value.length > 65_536)
|
|
23
|
-
throw new TypeError("Invalid summary.");
|
|
24
|
-
return value;
|
|
25
|
-
}
|
|
26
|
-
export function parseTemporaryGrants(value) {
|
|
27
|
-
if (!Array.isArray(value) || value.length > 1024)
|
|
28
|
-
throw new TypeError("Invalid grants.");
|
|
29
|
-
return value.map(item => {
|
|
30
|
-
const input = row(item, ["id", "sessionId", "tool", "summary", "duration"], ["remainingMs"]), duration = parseTemporaryDuration(input.duration);
|
|
31
|
-
if (duration === "once" || input.remainingMs !== undefined && (typeof input.remainingMs !== "number" || !Number.isFinite(input.remainingMs) || input.remainingMs < 0))
|
|
32
|
-
throw new TypeError("Invalid grant lifetime.");
|
|
33
|
-
return { id: parseTemporaryId(input.id), sessionId: parseTemporaryId(input.sessionId), tool: parseTemporaryId(input.tool), summary: summary(input.summary), duration,
|
|
34
|
-
...(typeof input.remainingMs === "number" ? { remainingMs: input.remainingMs } : {}) };
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
export function parseTemporaryRequest(value) {
|
|
38
|
-
const input = row(value, ["requestId", "deliveryId", "sessionId", "tool", "summary", "reusable"], ["scopes"]);
|
|
39
|
-
if (typeof input.reusable !== "boolean")
|
|
40
|
-
throw new TypeError("Invalid request capability.");
|
|
41
|
-
let scopes;
|
|
42
|
-
if (input.scopes !== undefined) {
|
|
43
|
-
if (!Array.isArray(input.scopes) || input.scopes.length > 4)
|
|
44
|
-
throw new TypeError("Invalid scopes.");
|
|
45
|
-
scopes = input.scopes.map(value => { const scope = row(value, ["id", "summary"]); return { id: parseTemporaryId(scope.id), summary: summary(scope.summary) }; });
|
|
46
|
-
}
|
|
47
|
-
return { requestId: parseTemporaryId(input.requestId), deliveryId: parseTemporaryId(input.deliveryId), sessionId: parseTemporaryId(input.sessionId),
|
|
48
|
-
tool: parseTemporaryId(input.tool), summary: summary(input.summary), reusable: input.reusable, ...(scopes ? { scopes } : {}) };
|
|
49
|
-
}
|
|
50
|
-
const codec = (name, parse) => ({ mode: "strict", typeSymbol: `@dsmm/dsmm#Temporary${name}`, create: () => ({ parse }) });
|
|
51
|
-
export function parseChildPermission(value) {
|
|
52
|
-
const input = row(value, ["parentSessionId", "childSessionId", "project", "state", "canEnable", "canRevoke"], ["role", "readOnly"]);
|
|
53
|
-
const state = input.state;
|
|
54
|
-
if (state !== "disabled" && state !== "enabled" && state !== "unavailable" || typeof input.canEnable !== "boolean" || typeof input.canRevoke !== "boolean"
|
|
55
|
-
|| input.readOnly !== undefined && typeof input.readOnly !== "boolean")
|
|
56
|
-
throw new TypeError("Invalid child permission state.");
|
|
57
|
-
return { parentSessionId: parseTemporaryId(input.parentSessionId), childSessionId: parseTemporaryId(input.childSessionId), project: summary(input.project),
|
|
58
|
-
state, canEnable: input.canEnable, canRevoke: input.canRevoke,
|
|
59
|
-
...(input.role === undefined ? {} : { role: parseTemporaryId(input.role) }), ...(typeof input.readOnly === "boolean" ? { readOnly: input.readOnly } : {}) };
|
|
60
|
-
}
|
|
61
|
-
const id = codec("Id", parseTemporaryId), delivery = codec("Delivery", parseTemporaryDelivery);
|
|
62
|
-
const grants = codec("Grants", parseTemporaryGrants), request = codec("Request", parseTemporaryRequest);
|
|
63
|
-
function descriptor(method, fields, result) {
|
|
64
|
-
return { id: `@dsmm/dsmm-temporary-permissions#dsmmTemporaryPermissions/${method}`, service: "dsmmTemporaryPermissions", namespace: "dsmmTemporaryPermissions", method,
|
|
65
|
-
invocation: { kind: "direct" }, parameters: [["sessionId", id], ...fields].map(([name, codec]) => ({ name, wire: name, source: "json", codec })), result };
|
|
66
|
-
}
|
|
67
|
-
export const TEMPORARY_PERMISSION_REMOTE = { package: "@dsmm/dsmm-temporary-permissions", descriptors: [
|
|
68
|
-
descriptor("describe", [], grants), descriptor("request", [["delivery", delivery]], request),
|
|
69
|
-
descriptor("retain", [["delivery", delivery], ["duration", codec("Duration", parseTemporaryDuration)], ["scope", codec("Scope", value => value === undefined ? "exact" : parseTemporaryId(value))]], id),
|
|
70
|
-
descriptor("permit", [["delivery", delivery]], codec("Permit", value => value === null ? null : parseTemporaryId(value))),
|
|
71
|
-
descriptor("revoke", [["grantId", id]], grants),
|
|
72
|
-
...["child", "enableChild", "revokeChild"].map(method => descriptor(method, [["childSessionId", id]], codec("Child", parseChildPermission))),
|
|
73
|
-
] };
|
|
74
|
-
export const TEMPORARY_PERMISSION_HOST = { package: TEMPORARY_PERMISSION_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: TEMPORARY_PERMISSION_REMOTE.descriptors };
|
|
75
|
-
//# sourceMappingURL=permission-temporary-remote.js.map
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import { TypertRemoteService } from "@deepseek-ai/dsh-typert-protocol";
|
|
3
|
-
import type { Agent } from "@deepseek-ai/dsh-agent";
|
|
4
|
-
import type { TemporaryPermissionGrants } from "./permission-temporary-grants.js";
|
|
5
|
-
import type { TemporaryPermissionDelivery, TemporaryPermissionDuration } from "./permission-temporary-types.js";
|
|
6
|
-
import type { ChildPermissionControl } from "./permission-child-control.js";
|
|
7
|
-
/** Child access is an explicit current operator capability, never inferred from lineage strings. */
|
|
8
|
-
export interface TemporaryPermissionRpcOptions {
|
|
9
|
-
readonly children?: ChildPermissionControl;
|
|
10
|
-
authorizeChild?(peer: object, child: Agent): {
|
|
11
|
-
assertCurrent(): void;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export declare class DsmmTemporaryPermissionsHost extends TypertRemoteService {
|
|
15
|
-
private readonly grants;
|
|
16
|
-
private readonly options;
|
|
17
|
-
private readonly lifetime;
|
|
18
|
-
constructor(ctx: Context, grants: TemporaryPermissionGrants, options: TemporaryPermissionRpcOptions);
|
|
19
|
-
private invoke;
|
|
20
|
-
private delivery;
|
|
21
|
-
describe(sessionId: string): readonly import("./permission-temporary-types.js").TemporaryPermissionGrantView[];
|
|
22
|
-
request(sessionId: string, delivery: TemporaryPermissionDelivery): unknown;
|
|
23
|
-
retain(sessionId: string, delivery: TemporaryPermissionDelivery, duration: TemporaryPermissionDuration, scope?: string): unknown;
|
|
24
|
-
permit(sessionId: string, delivery: TemporaryPermissionDelivery): unknown;
|
|
25
|
-
revoke(sessionId: string, grantId: string): readonly import("./permission-temporary-types.js").TemporaryPermissionGrantView[];
|
|
26
|
-
private childOperation;
|
|
27
|
-
child(sessionId: string, childSessionId: string): Promise<import("./permission-temporary-types.js").ChildPermissionView>;
|
|
28
|
-
enableChild(sessionId: string, childSessionId: string): Promise<import("./permission-temporary-types.js").ChildPermissionView>;
|
|
29
|
-
revokeChild(sessionId: string, childSessionId: string): Promise<import("./permission-temporary-types.js").ChildPermissionView>;
|
|
30
|
-
}
|
|
31
|
-
declare module "@deepseek-ai/cordis" {
|
|
32
|
-
interface Context {
|
|
33
|
-
dsmmTemporaryPermissions: DsmmTemporaryPermissionsHost;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export declare function registerTemporaryPermissionRpc(ctx: Context, grants: TemporaryPermissionGrants, options?: TemporaryPermissionRpcOptions): DsmmTemporaryPermissionsHost;
|
|
37
|
-
//# sourceMappingURL=permission-temporary-rpc.d.ts.map
|
|
@@ -1,154 +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 { 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
|
|
@@ -1,47 +0,0 @@
|
|
|
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
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
|
@@ -1,154 +0,0 @@
|
|
|
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
|