@dsmm/dsmm 0.3.7 → 0.3.9
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/docs/native-permissions.md +7 -7
- package/docs/settings-status.md +2 -0
- package/lib/client/DeploymentFields.js +9 -6
- package/lib/client/NativeCommandEntries.d.ts +6 -6
- package/lib/client/NativeCommandEntries.js +38 -37
- package/lib/client/PermissionRuleEntries.js +3 -1
- package/lib/client/children-locales.d.ts +1 -1
- package/lib/client/deployment-locales.d.ts +2 -0
- package/lib/client/deployment-locales.js +2 -0
- package/lib/client/permission-locales.d.ts +4 -0
- package/lib/client/permission-locales.js +12 -10
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +11 -0
- package/lib/client.js +171 -124
- package/lib/core-permission-authority.js +9 -3
- package/lib/guards.d.ts +1 -1
- package/lib/guards.js +12 -21
- package/lib/permission-control.d.ts +8 -2
- package/lib/permission-control.js +48 -14
- package/lib/permission-controller.d.ts +4 -0
- package/lib/permission-controller.js +142 -7
- package/lib/permission-native-command.d.ts +5 -1
- package/lib/permission-native-command.js +35 -5
- package/lib/permission-native-rules.d.ts +3 -2
- package/lib/permission-native-rules.js +3 -1
- package/lib/permission-settings.d.ts +31 -1
- package/lib/permission-settings.js +24 -3
- package/lib/settings.js +2 -2
- package/package.json +1 -1
|
@@ -16,9 +16,10 @@ export interface NativeCommandEntry {
|
|
|
16
16
|
readonly match: NativeCommandMatch;
|
|
17
17
|
readonly sandboxMode: "workspace-write" | "danger-full-access";
|
|
18
18
|
}
|
|
19
|
+
export type NativeCommandRule = string | NativeCommandEntry;
|
|
19
20
|
export interface NativeCommandsSettings {
|
|
20
21
|
readonly enabled: boolean;
|
|
21
|
-
readonly entries: readonly
|
|
22
|
+
readonly entries: readonly NativeCommandRule[];
|
|
22
23
|
}
|
|
23
24
|
/** Only enabled is deployment-only. Rules are independently synchronized at runtime. */
|
|
24
25
|
export interface PermissionControlSettings {
|
|
@@ -43,6 +44,8 @@ export interface NativeCommandPattern {
|
|
|
43
44
|
}
|
|
44
45
|
/** Bounded static prefix grammar; the optional final star always denotes the whole argv tail. */
|
|
45
46
|
export declare function parseNativeCommandPattern(input: unknown): NativeCommandPattern;
|
|
47
|
+
/** Literal token prefixes; only the second token may contain alternatives. */
|
|
48
|
+
export declare function parseSimpleCommandPattern(input: unknown): readonly (readonly string[])[];
|
|
46
49
|
export declare function parseNativeCommands(input?: unknown): NativeCommandsSettings;
|
|
47
50
|
export declare const nativeCommandMatchSchema: z<Schemastery.ObjectS<NoInfer<{
|
|
48
51
|
tool: z<"bash" | "pwsh", "bash" | "pwsh", "defined">;
|
|
@@ -53,6 +56,33 @@ export declare const nativeCommandMatchSchema: z<Schemastery.ObjectS<NoInfer<{
|
|
|
53
56
|
workingDirectory: z<string, string, "defined">;
|
|
54
57
|
commandPattern: z<string, string, "defined">;
|
|
55
58
|
}>>, "defined">;
|
|
59
|
+
export declare const nativeCommandEntrySchema: z<Schemastery.ObjectS<NoInfer<{
|
|
60
|
+
id: z<string, string, "defined">;
|
|
61
|
+
mode: z<"allow" | "ask", "allow" | "ask", "defined">;
|
|
62
|
+
match: z<Schemastery.ObjectS<NoInfer<{
|
|
63
|
+
tool: z<"bash" | "pwsh", "bash" | "pwsh", "defined">;
|
|
64
|
+
workingDirectory: z<string, string, "defined">;
|
|
65
|
+
commandPattern: z<string, string, "defined">;
|
|
66
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
67
|
+
tool: z<"bash" | "pwsh", "bash" | "pwsh", "defined">;
|
|
68
|
+
workingDirectory: z<string, string, "defined">;
|
|
69
|
+
commandPattern: z<string, string, "defined">;
|
|
70
|
+
}>>, "defined">;
|
|
71
|
+
sandboxMode: z<"workspace-write" | "danger-full-access", "workspace-write" | "danger-full-access", "defined">;
|
|
72
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
73
|
+
id: z<string, string, "defined">;
|
|
74
|
+
mode: z<"allow" | "ask", "allow" | "ask", "defined">;
|
|
75
|
+
match: z<Schemastery.ObjectS<NoInfer<{
|
|
76
|
+
tool: z<"bash" | "pwsh", "bash" | "pwsh", "defined">;
|
|
77
|
+
workingDirectory: z<string, string, "defined">;
|
|
78
|
+
commandPattern: z<string, string, "defined">;
|
|
79
|
+
}>>, Schemastery.ObjectT<NoInfer<{
|
|
80
|
+
tool: z<"bash" | "pwsh", "bash" | "pwsh", "defined">;
|
|
81
|
+
workingDirectory: z<string, string, "defined">;
|
|
82
|
+
commandPattern: z<string, string, "defined">;
|
|
83
|
+
}>>, "defined">;
|
|
84
|
+
sandboxMode: z<"workspace-write" | "danger-full-access", "workspace-write" | "danger-full-access", "defined">;
|
|
85
|
+
}>>, "defined">;
|
|
56
86
|
export declare const DEFAULT_PERMISSION_CONTROL: PermissionControlSettings;
|
|
57
87
|
export declare const permissionControlSchema: z<PermissionControlSettings>;
|
|
58
88
|
export declare function resolvePermissionControl(input?: PermissionControlSchemaInput): PermissionControlSettings;
|
|
@@ -14,6 +14,22 @@ export function parseNativeCommandPattern(input) {
|
|
|
14
14
|
throw new PermissionRefusal("validation");
|
|
15
15
|
return Object.freeze({ executable: tokens[0], subcommands: Object.freeze(subcommands) });
|
|
16
16
|
}
|
|
17
|
+
/** Literal token prefixes; only the second token may contain alternatives. */
|
|
18
|
+
export function parseSimpleCommandPattern(input) {
|
|
19
|
+
if (typeof input !== "string" || input.length > 32768)
|
|
20
|
+
throw new PermissionRefusal("validation");
|
|
21
|
+
const tokens = input.replace(/^[ \t]+|[ \t]+$/gu, "").split(/[ \t]+/u);
|
|
22
|
+
if (tokens.at(-1) === "*")
|
|
23
|
+
tokens.pop();
|
|
24
|
+
if (!tokens.length)
|
|
25
|
+
throw new PermissionRefusal("validation");
|
|
26
|
+
return Object.freeze(tokens.map((token, index) => {
|
|
27
|
+
const values = index === 1 ? token.split("|") : [token];
|
|
28
|
+
if (values.some(value => !value.length || /[^\p{L}\p{M}\p{N}_./:=+%\\\-]/u.test(value)))
|
|
29
|
+
throw new PermissionRefusal("validation");
|
|
30
|
+
return Object.freeze(values);
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
17
33
|
export function parseNativeCommands(input = {}) {
|
|
18
34
|
const row = permissionRuleRow(input, [], ["enabled", "entries"]);
|
|
19
35
|
if (row.enabled !== undefined && typeof row.enabled !== "boolean" || row.entries !== undefined && (!Array.isArray(row.entries) || row.entries.length > 1024))
|
|
@@ -22,6 +38,10 @@ export function parseNativeCommands(input = {}) {
|
|
|
22
38
|
throw new PermissionRefusal("validation"); return value; };
|
|
23
39
|
const ids = new Set();
|
|
24
40
|
const entries = (row.entries ?? []).map(value => {
|
|
41
|
+
if (typeof value === "string") {
|
|
42
|
+
parseSimpleCommandPattern(value);
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
25
45
|
const entry = permissionRuleRow(value, ["id", "mode", "match", "sandboxMode"]);
|
|
26
46
|
const match = permissionRuleRow(entry.match, ["tool", "workingDirectory", "commandPattern"]);
|
|
27
47
|
const id = text(entry.id), cwd = text(match.workingDirectory);
|
|
@@ -38,9 +58,10 @@ export function parseNativeCommands(input = {}) {
|
|
|
38
58
|
return Object.freeze({ enabled: row.enabled ?? false, entries: Object.freeze(entries) });
|
|
39
59
|
}
|
|
40
60
|
export const nativeCommandMatchSchema = z.object({ tool: z.union(["bash", "pwsh"]).required(), workingDirectory: z.string().required(), commandPattern: z.string().required() }).required();
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
export const nativeCommandEntrySchema = z.object({
|
|
62
|
+
id: z.string().required(), mode: z.union(["ask", "allow"]).required(), match: nativeCommandMatchSchema, sandboxMode: z.union(["workspace-write", "danger-full-access"]).required(),
|
|
63
|
+
}).required();
|
|
64
|
+
const nativeCommands = z.object({ enabled: z.boolean().default(false), entries: z.array(z.union([z.string(), nativeCommandEntrySchema])).default([]) });
|
|
44
65
|
const webDefault = Object.freeze({ enabled: true, rule: "inherit" });
|
|
45
66
|
export const DEFAULT_PERMISSION_CONTROL = Object.freeze({ enabled: true, outsideReads: "inherit", webSearch: webDefault, webFetch: webDefault, rules: Object.freeze([]), nativeCommands: parseNativeCommands() });
|
|
46
67
|
const action = () => z.union(["inherit", "allow", "ask", "deny"]).default("inherit");
|
package/lib/settings.js
CHANGED
|
@@ -6,7 +6,7 @@ import { DEFAULT_DSMM_RUNTIME_POLICY, DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimit
|
|
|
6
6
|
import { DEPRECATED_DSMM_FIELDS, DsmmConfigValidationError, safeDiagnosticField } from "./profile-diagnostics.js";
|
|
7
7
|
import { DSMM_LOCALES } from "./profile-locale.js";
|
|
8
8
|
import { normalizeModelRouteJson, validateModelRouteFieldName } from "./route-json.js";
|
|
9
|
-
import { DEFAULT_PERMISSION_CONTROL, nativeCommandMatchSchema, permissionControlSchema, resolvePermissionControl } from "./permission-settings.js";
|
|
9
|
+
import { DEFAULT_PERMISSION_CONTROL, nativeCommandEntrySchema, nativeCommandMatchSchema, permissionControlSchema, resolvePermissionControl } from "./permission-settings.js";
|
|
10
10
|
export { DSMM_LOCALES } from "./profile-locale.js";
|
|
11
11
|
export { resolveRoleRuntimePolicy } from "./routing-policy.js";
|
|
12
12
|
export { DSMM_SKILL_NAMES, MVP_SKILL_NAMES } from "./skills.js";
|
|
@@ -250,7 +250,7 @@ function sparseSchema(schema) {
|
|
|
250
250
|
if (schema === permissionControlSchema && schema.type === "transform")
|
|
251
251
|
return sparseSchema(schema.inner);
|
|
252
252
|
// Whole command entries are never partial overlays; retain the match's required fields.
|
|
253
|
-
if (schema === nativeCommandMatchSchema)
|
|
253
|
+
if (schema === nativeCommandMatchSchema || schema === nativeCommandEntrySchema)
|
|
254
254
|
return schema;
|
|
255
255
|
const { default: _default, required: _required, ...meta } = schema.meta;
|
|
256
256
|
return new Schema({ ...schema, meta,
|