@dsmm/dsmm 0.3.4 → 0.3.6
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/settings-status.md +1 -1
- package/lib/client/DeploymentFields.js +18 -1
- package/lib/client/DeploymentPage.js +1 -1
- package/lib/client/NativeCommandEntries.js +1 -1
- package/lib/client/PermissionsPanel.js +7 -6
- package/lib/client/deployment-locales.d.ts +0 -1
- package/lib/client/deployment-locales.js +12 -12
- package/lib/client/index.js +2 -18
- package/lib/client/permission-controller.d.ts +11 -1
- package/lib/client/permission-controller.js +17 -12
- package/lib/client/permission-locales.d.ts +2 -1
- package/lib/client/permission-locales.js +36 -34
- package/lib/client/permission-session.d.ts +37 -0
- package/lib/client/permission-session.js +34 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +8 -0
- package/lib/client.js +486 -446
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -5465,6 +5465,14 @@ var PROFILE_STYLES = `
|
|
|
5465
5465
|
.dsmm-scope-save{display:flex;flex-direction:column;gap:8px;padding-top:16px;border-top:1px solid var(--dsw-alias-border-l4)}
|
|
5466
5466
|
.dsmm-deployment .dsmm-deployment-group{border-top:1px solid var(--dsw-alias-border-l4);padding-top:8px;min-width:0}
|
|
5467
5467
|
.dsmm-deployment .dsmm-deployment-group>div{display:flex;flex-direction:column;gap:8px;padding-top:8px}
|
|
5468
|
+
.dsmm-deployment .dsmm-deployment-group>summary.dsmm-group-summary-row{display:flex;align-items:center;gap:8px;list-style:none}
|
|
5469
|
+
.dsmm-deployment .dsmm-deployment-group>summary.dsmm-group-summary-row::-webkit-details-marker{display:none}
|
|
5470
|
+
.dsmm-deployment .dsmm-deployment-group>summary.dsmm-group-summary-row::before{content:"▶";flex:0 0 auto;width:12px;text-align:center;color:var(--dsw-alias-label-secondary)}
|
|
5471
|
+
.dsmm-deployment .dsmm-deployment-group[open]>summary.dsmm-group-summary-row::before{content:"▼"}
|
|
5472
|
+
.dsmm-deployment summary .dsmm-group-summary{display:flex;align-items:center;gap:8px;min-width:0;flex:1 1 auto}
|
|
5473
|
+
.dsmm-deployment .dsmm-group-summary-label{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}
|
|
5474
|
+
.dsmm-deployment .dsmm-group-summary-action{flex:0 0 auto;min-height:28px;height:28px;padding:0 8px}
|
|
5475
|
+
.dsmm-deployment .dsmm-group-summary-action[hidden]{display:none}
|
|
5468
5476
|
.dsmm-deployment code{font-family:var(--ds-font-family-code);overflow-wrap:anywhere}
|
|
5469
5477
|
.dsmm-deployment label code,.dsmm-deployment summary code{margin-left:8px;font-size:12px;line-height:18px;font-weight:400;color:var(--dsw-alias-label-secondary)}
|
|
5470
5478
|
.dsmm-deployment pre{margin:0;max-width:100%;white-space:pre-wrap;overflow-wrap:anywhere;font-family:var(--ds-font-family-code)}
|
|
@@ -6004,17 +6012,17 @@ var deploymentEn = {
|
|
|
6004
6012
|
summary: "Global config and profile overrides",
|
|
6005
6013
|
description: "Layers save independently; native models and running sessions stay unchanged.",
|
|
6006
6014
|
global: "DSMM Global config",
|
|
6007
|
-
globalHint: "Shared by this Home
|
|
6015
|
+
globalHint: "Shared by this Home. Unset fields use built-in defaults.",
|
|
6008
6016
|
profile: "Current DSH profile overrides",
|
|
6009
|
-
profileHint: "This
|
|
6017
|
+
profileHint: "This profile only. Unset fields use Global, then Host defaults.",
|
|
6010
6018
|
profileUnavailable: "Unavailable",
|
|
6011
|
-
unavailableForm: "
|
|
6019
|
+
unavailableForm: "Read-only profile. Reconnect and refresh to check editing access.",
|
|
6012
6020
|
ceiling: "Deepwork master is Global-only; profiles and session modes cannot lift its captured ceiling.",
|
|
6013
6021
|
hostUnknown: "Host bundle status: unknown (separate switch).",
|
|
6014
|
-
boundaries: "Saved settings apply to new sessions
|
|
6022
|
+
boundaries: "Saved settings apply to new sessions; restart-required changes need a separate Host restart that may cancel sessions.",
|
|
6015
6023
|
core: "Core",
|
|
6016
6024
|
coreHint: "Core-owned desired settings. Model-parameter passthrough is ordinary config, not a subplugin. The permission-control enabled flag is startup-pinned. Save does not change current-session admission; inspect desired, startup and admitted values below. Unavailable admission stays unknown.",
|
|
6017
|
-
modelParametersHint: "Off
|
|
6025
|
+
modelParametersHint: "Off sends no custom parameters and uses native reasoning defaults. Saved values and the selected model stay unchanged.",
|
|
6018
6026
|
permissionControlHint: "Permission-control mounting is startup-pinned. Saved configuration does not prove runtime coverage or remove current protections. Root rules keep their independent authority inside Permissions.",
|
|
6019
6027
|
modules: "Configuration sections",
|
|
6020
6028
|
scope: "Configuration scope",
|
|
@@ -6036,7 +6044,6 @@ var deploymentEn = {
|
|
|
6036
6044
|
keepDraft: "Keep draft and return",
|
|
6037
6045
|
discardDraft: "Discard draft and leave",
|
|
6038
6046
|
rootRules: "Global permission rules",
|
|
6039
|
-
rootRulesHint: "Choose an open main session with editing access as the editor for Global rules. Saved rules persist in Global policy and affect every context that uses it; they are not session-private. This transaction saves separately from configuration.",
|
|
6040
6047
|
rootRulesUnavailable: "Permission rules unavailable. Reconnect and refresh.",
|
|
6041
6048
|
nativeRuntimeHint: "Native default On; Host base pins still apply. Mounting is captured at startup. Saving stages desired configuration only; it does not start/stop providers or cancel running sessions. A separate Host restart may cancel sessions.",
|
|
6042
6049
|
nativeRuntimeReadinessHint: "Task progress is available in the session.",
|
|
@@ -6106,17 +6113,17 @@ var deploymentZh = {
|
|
|
6106
6113
|
summary: "全局配置与当前配置覆盖",
|
|
6107
6114
|
description: "两层独立保存,不改原生模型或运行中会话。",
|
|
6108
6115
|
global: "DSMM 全局配置",
|
|
6109
|
-
globalHint: "同一 Home
|
|
6116
|
+
globalHint: "同一 Home 共用;未设置字段使用内建默认值。",
|
|
6110
6117
|
profile: "当前 DSH 配置覆盖",
|
|
6111
|
-
profileHint: "
|
|
6118
|
+
profileHint: "仅影响此配置。未设置字段依次使用全局与宿主默认值。",
|
|
6112
6119
|
profileUnavailable: "不可用",
|
|
6113
|
-
unavailableForm: "
|
|
6120
|
+
unavailableForm: "此配置只读;重连并刷新以检查编辑权限。",
|
|
6114
6121
|
ceiling: "Deepwork 总开关仅全局可改;配置和会话模式不能突破已捕获上限。",
|
|
6115
6122
|
hostUnknown: "宿主整包状态:未知(独立开关)。",
|
|
6116
|
-
boundaries: "
|
|
6123
|
+
boundaries: "保存的设置供新会话使用;需重启的更改须另行重启宿主,可能取消会话。",
|
|
6117
6124
|
core: "Core 核心配置",
|
|
6118
6125
|
coreHint: "Core 所有的 desired 意图配置。模型参数透传为普通配置,非子插件;权限控制 enabled 仅启动时捕获。保存不改变当前会话准入;下方可检查意图、启动与准入值,不可用的准入仍为未知。",
|
|
6119
|
-
modelParametersHint: "
|
|
6126
|
+
modelParametersHint: "关闭后不发送自定义参数,改用原生推理默认值;已保存值与所选模型不变。",
|
|
6120
6127
|
permissionControlHint: "权限控制挂载仅启动时捕获。保存配置不证明运行时覆盖,也不移除当前保护;Root 规则在权限模块内保持独立权限。",
|
|
6121
6128
|
modules: "配置分区",
|
|
6122
6129
|
scope: "配置范围",
|
|
@@ -6138,7 +6145,6 @@ var deploymentZh = {
|
|
|
6138
6145
|
keepDraft: "保留草稿并返回",
|
|
6139
6146
|
discardDraft: "放弃草稿并离开",
|
|
6140
6147
|
rootRules: "全局权限规则",
|
|
6141
|
-
rootRulesHint: "请选择已打开且有编辑权限的主会话作为全局规则的编辑入口。保存的规则写入全局策略,对所有使用该策略的上下文生效,并非会话私有。此事务与配置分别保存。",
|
|
6142
6148
|
rootRulesUnavailable: "权限规则不可用,请重连后刷新。",
|
|
6143
6149
|
nativeRuntimeHint: "原生默认开启,Host base 固定值仍适用;挂载仅启动时捕获。保存只设置 desired,不会启动/停止提供商或取消当前会话;独立 Host 重启可能取消会话。",
|
|
6144
6150
|
nativeRuntimeReadinessHint: "任务进度可在会话中查看。",
|
|
@@ -6270,8 +6276,10 @@ var deploymentFieldLabels = {
|
|
|
6270
6276
|
var PERMISSIONS_NS = "settings.dsmm-permissions";
|
|
6271
6277
|
var permissionEn = {
|
|
6272
6278
|
title: "Permission control",
|
|
6273
|
-
rules: "
|
|
6274
|
-
nativeApproval: "Approve commands in the native prompt
|
|
6279
|
+
rules: "Rules",
|
|
6280
|
+
nativeApproval: "Approve commands in the native prompt; Allow covers that call only.",
|
|
6281
|
+
sandboxScope: "These rules set allow, ask or deny. The Host sandbox and its native prompt still decide what an approved call may touch.",
|
|
6282
|
+
unconfirmedObservation: "Showing the last successful observation. The current selection is not confirmed yet, so editing and saving stay unavailable.",
|
|
6275
6283
|
root: "Selected main session",
|
|
6276
6284
|
noRoot: "Select a main session to view its permission rules.",
|
|
6277
6285
|
child: "Select this child’s main session to edit Global rules.",
|
|
@@ -6301,11 +6309,11 @@ var permissionEn = {
|
|
|
6301
6309
|
pathScope: "Path match",
|
|
6302
6310
|
exact: "Exact path",
|
|
6303
6311
|
tree: "Path and descendants",
|
|
6304
|
-
networkLimit: "Web rules cover public web tools only
|
|
6305
|
-
rulesHint: "
|
|
6306
|
-
configPolicyHint: "Profile settings override Global
|
|
6307
|
-
configRulesHint: "Record list for this
|
|
6308
|
-
coldHint: "
|
|
6312
|
+
networkLimit: "Web rules cover public web tools only; private networks, shell and sockets are outside this permission.",
|
|
6313
|
+
rulesHint: "Global policy, saved separately from configuration. Clear blocking profile overrides, then refresh.",
|
|
6314
|
+
configPolicyHint: "Profile settings override Global; arrays replace inherited lists. Refresh to check what is effective.",
|
|
6315
|
+
configRulesHint: "Record list for this layer. The Host owns source and revision; imported records are never verified approvals. An empty list is an explicit empty replacement.",
|
|
6316
|
+
coldHint: "Host restart required; current protection stays active. Restart may cancel sessions.",
|
|
6309
6317
|
guardScope: "Guard scope",
|
|
6310
6318
|
shellSafety: "Shell command safety",
|
|
6311
6319
|
gitWrite: "Git write approval",
|
|
@@ -6318,8 +6326,8 @@ var permissionEn = {
|
|
|
6318
6326
|
unitBytes: "bytes",
|
|
6319
6327
|
unitChars: "characters",
|
|
6320
6328
|
nativeCommands: "Command rules",
|
|
6321
|
-
nativeCommandsHint: "Default Off.
|
|
6322
|
-
registrationUnresolved: "Executor identity
|
|
6329
|
+
nativeCommandsHint: "Default Off. New entries use Ask and workspace-write; other permission limits still apply.",
|
|
6330
|
+
registrationUnresolved: "Executor identity unconfirmed; verify tool, executable, environment and sandbox.",
|
|
6323
6331
|
entryId: "Entry ID",
|
|
6324
6332
|
tool: "Tool",
|
|
6325
6333
|
sandboxMode: "Sandbox mode",
|
|
@@ -6330,13 +6338,12 @@ var permissionEn = {
|
|
|
6330
6338
|
unset: "Unset — restore inheritance",
|
|
6331
6339
|
inheritedEntries: "Inherited entries; editing pins a replacement array in this layer.",
|
|
6332
6340
|
explicitEntries: "Explicit replacement array in this layer.",
|
|
6333
|
-
invalidEntry: "Invalid entry:
|
|
6341
|
+
invalidEntry: "Invalid entry: IDs must be unique and nonblank, pattern valid, working directory absolute. Draft retained; Save locked.",
|
|
6334
6342
|
pattern: "Command pattern",
|
|
6335
|
-
patternHint: "
|
|
6336
|
-
invalidPattern: "Invalid pattern:
|
|
6337
|
-
patternScope: "Any trailing arguments are allowed, so the selected program can run its own builds, tests and internal scripts. This is not a path or filesystem grant, and shell pipes, chaining, redirects and substitutions still follow the ordinary native path.",
|
|
6343
|
+
patternHint: "Example: go build|test *. With or without *, any trailing arguments (including program scripts) are allowed. No character glob, regex or path grants.",
|
|
6344
|
+
invalidPattern: "Invalid pattern: one executable and the subcommand position only, space-separated. Pipe alternatives must be nonblank literals; * may only be the final token.",
|
|
6338
6345
|
restrictedFullAccess: "danger-full-access — retained from the saved value; not offered here",
|
|
6339
|
-
rulesUnavailable: "Editing requires an open main session, local editing permission and
|
|
6346
|
+
rulesUnavailable: "Editing requires an open main session, local editing permission and synced rules. Check profile overrides, then reconnect and refresh.",
|
|
6340
6347
|
configRules: "Imported configuration rules",
|
|
6341
6348
|
inheritedRules: "Inherited records; editing pins a replacement list in this layer.",
|
|
6342
6349
|
explicitRules: "Explicit replacement list in this layer.",
|
|
@@ -6344,13 +6351,13 @@ var permissionEn = {
|
|
|
6344
6351
|
addRule: "Add imported rule",
|
|
6345
6352
|
removeRule: "Remove rule",
|
|
6346
6353
|
advancedRules: "Advanced rule JSON",
|
|
6347
|
-
invalidRule: "Invalid rule list:
|
|
6354
|
+
invalidRule: "Invalid rule list: IDs must be unique and nonblank, actions allow/ask/deny, and matches complete. Draft retained; Save locked.",
|
|
6348
6355
|
recordedOperator: "Recorded operator source (metadata, not approval)",
|
|
6349
|
-
invalidPatternHint: "
|
|
6356
|
+
invalidPatternHint: "Fix invalid patterns before saving. Removing a row drops only its draft; Unset replaces the whole array with the inherited list.",
|
|
6350
6357
|
observedPolicy: "Effective policy (including profile overrides)",
|
|
6351
6358
|
profileOverrideState: "Profile overrides",
|
|
6352
|
-
profileOverrideUnknown: "Unknown
|
|
6353
|
-
matchHint: "Match an exact path or
|
|
6359
|
+
profileOverrideUnknown: "Unknown — select the DSH profile scope to inspect.",
|
|
6360
|
+
matchHint: "Match an exact path or tree, an exact shell tool/command/directory, or a web tool. Allow grants no outside-workspace writes.",
|
|
6354
6361
|
source: "Actual source",
|
|
6355
6362
|
recordVersion: "Record version",
|
|
6356
6363
|
savedAt: "Saved at",
|
|
@@ -6371,7 +6378,7 @@ var permissionEn = {
|
|
|
6371
6378
|
restart: "Independent restart required",
|
|
6372
6379
|
coverageTitle: "Tool coverage",
|
|
6373
6380
|
coverageDetails: "Details",
|
|
6374
|
-
coverage: "Last
|
|
6381
|
+
coverage: "Last observation for this main session; executor readiness and network access need separate checks.",
|
|
6375
6382
|
coverageUnavailable: "Coverage unavailable / unknown. No trusted live observation was returned.",
|
|
6376
6383
|
coverageEmpty: "No trusted tool registrations observed for this Root.",
|
|
6377
6384
|
coverageRuntime: "Observed consumer state",
|
|
@@ -6424,8 +6431,10 @@ var permissionEn = {
|
|
|
6424
6431
|
};
|
|
6425
6432
|
var permissionZh = {
|
|
6426
6433
|
title: "权限控制",
|
|
6427
|
-
rules: "
|
|
6434
|
+
rules: "规则",
|
|
6428
6435
|
nativeApproval: "请在原生提示中批准命令;「允许」仅批准本次调用。",
|
|
6436
|
+
sandboxScope: "这些规则决定允许、询问或拒绝;具体调用可触及的范围仍由宿主沙箱及其原生提示决定。",
|
|
6437
|
+
unconfirmedObservation: "当前显示上次成功观测;当前选择尚未确认,编辑与保存暂不可用。",
|
|
6429
6438
|
root: "所选主会话",
|
|
6430
6439
|
noRoot: "请选择主会话以查看权限规则。",
|
|
6431
6440
|
child: "请切换到此子会话的主会话后编辑全局规则。",
|
|
@@ -6455,10 +6464,10 @@ var permissionZh = {
|
|
|
6455
6464
|
pathScope: "路径匹配",
|
|
6456
6465
|
exact: "精确路径",
|
|
6457
6466
|
tree: "此路径及子树",
|
|
6458
|
-
networkLimit: "
|
|
6459
|
-
rulesHint: "
|
|
6460
|
-
configPolicyHint: "
|
|
6461
|
-
configRulesHint: "
|
|
6467
|
+
networkLimit: "网页规则仅覆盖公共网页工具;私网、Shell 与 socket 不在此权限内。",
|
|
6468
|
+
rulesHint: "全局策略,与配置分别保存。若配置覆盖阻止保存,请先清除覆盖再刷新。",
|
|
6469
|
+
configPolicyHint: "当前配置优先于全局,数组整体替换继承列表。保存后刷新以检查实际生效状态。",
|
|
6470
|
+
configRulesHint: "此配置层的记录列表。来源与版本由宿主维护;导入记录永不代表已核验批准。空列表表示显式清空。",
|
|
6462
6471
|
coldHint: "更改此开关需重启宿主,此前保留当前保护。重启可能取消会话。",
|
|
6463
6472
|
guardScope: "保护范围",
|
|
6464
6473
|
shellSafety: "Shell 命令安全",
|
|
@@ -6472,8 +6481,8 @@ var permissionZh = {
|
|
|
6472
6481
|
unitBytes: "字节",
|
|
6473
6482
|
unitChars: "字符",
|
|
6474
6483
|
nativeCommands: "命令规则",
|
|
6475
|
-
nativeCommandsHint: "
|
|
6476
|
-
registrationUnresolved: "
|
|
6484
|
+
nativeCommandsHint: "默认关闭;新条目使用询问与 workspace-write,仍受其他权限限制。",
|
|
6485
|
+
registrationUnresolved: "执行器身份未确认;请先核验工具、可执行程序、环境与沙箱。",
|
|
6477
6486
|
entryId: "条目 ID",
|
|
6478
6487
|
tool: "工具",
|
|
6479
6488
|
sandboxMode: "沙箱模式",
|
|
@@ -6484,13 +6493,12 @@ var permissionZh = {
|
|
|
6484
6493
|
unset: "Unset——恢复继承",
|
|
6485
6494
|
inheritedEntries: "继承的条目;编辑后在此层固定为整体替换数组。",
|
|
6486
6495
|
explicitEntries: "此层显式整体替换数组。",
|
|
6487
|
-
invalidEntry: "条目无效:ID
|
|
6496
|
+
invalidEntry: "条目无效:ID 需唯一非空、模式有效、工作目录为绝对路径。草稿保留,保存已锁定。",
|
|
6488
6497
|
pattern: "命令模式",
|
|
6489
|
-
patternHint: "
|
|
6490
|
-
invalidPattern: "
|
|
6491
|
-
patternScope: "允许任意后续参数,因此被选程序可以运行自身的构建、测试和内部脚本。这不是路径或文件系统授权;shell 管道、拼接、重定向与替换仍走普通原生路径。",
|
|
6498
|
+
patternHint: "例:go build|test *。省略 * 也允许任意后续参数(含程序脚本);不支持字符通配或正则,也不授予路径权限。",
|
|
6499
|
+
invalidPattern: "模式无效:仅一个可执行程序与子命令位置,以空格分隔。竖线备选须为非空字面量,* 只能是最后一个 token。",
|
|
6492
6500
|
restrictedFullAccess: "danger-full-access——保留自已保存的值,此处不提供创建",
|
|
6493
|
-
rulesUnavailable: "
|
|
6501
|
+
rulesUnavailable: "编辑需要已打开的主会话、本地编辑权限与已同步规则。请检查配置覆盖,再重连刷新。",
|
|
6494
6502
|
configRules: "导入的配置规则",
|
|
6495
6503
|
inheritedRules: "继承的记录;编辑后在此层固定为整体替换列表。",
|
|
6496
6504
|
explicitRules: "此层显式整体替换列表。",
|
|
@@ -6498,13 +6506,13 @@ var permissionZh = {
|
|
|
6498
6506
|
addRule: "添加导入规则",
|
|
6499
6507
|
removeRule: "移除规则",
|
|
6500
6508
|
advancedRules: "高级规则 JSON",
|
|
6501
|
-
invalidRule: "规则列表无效:ID
|
|
6509
|
+
invalidRule: "规则列表无效:ID 需唯一非空,动作为 allow/ask/deny,匹配条件完整。草稿保留,保存已锁定。",
|
|
6502
6510
|
recordedOperator: "记录的 operator 来源(元数据,不代表批准)",
|
|
6503
|
-
invalidPatternHint: "
|
|
6511
|
+
invalidPatternHint: "请先修正无效模式。移除某行只丢弃该行草稿;Unset 用继承列表整体替换。",
|
|
6504
6512
|
observedPolicy: "有效策略(含当前配置覆盖)",
|
|
6505
6513
|
profileOverrideState: "配置覆盖",
|
|
6506
6514
|
profileOverrideUnknown: "未知,请在上方选择当前 DSH 配置查看覆盖值。",
|
|
6507
|
-
matchHint: "可匹配精确路径或目录树、精确 Shell
|
|
6515
|
+
matchHint: "可匹配精确路径或目录树、精确 Shell 工具与命令及目录,或网页工具。允许不授予工作区外写入。",
|
|
6508
6516
|
source: "实际来源",
|
|
6509
6517
|
recordVersion: "记录版本",
|
|
6510
6518
|
savedAt: "保存时间",
|
|
@@ -6705,7 +6713,6 @@ function NativeCommandEntries({ value, inherited, controller, disabled, onChange
|
|
|
6705
6713
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-structured", children: [
|
|
6706
6714
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("nativeCommandsHint") }),
|
|
6707
6715
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("patternHint") }),
|
|
6708
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("patternScope") }),
|
|
6709
6716
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("registrationUnresolved") }),
|
|
6710
6717
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t(value === void 0 ? "inheritedEntries" : "explicitEntries") }),
|
|
6711
6718
|
!valid && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-issue", role: "alert", children: t("invalidEntry") }),
|
|
@@ -6992,19 +6999,35 @@ function Field({ schema, path, controller, initiallyOpen = false, disclosures, t
|
|
|
6992
6999
|
disclosures?.set(name2, expanded);
|
|
6993
7000
|
setOpen(expanded);
|
|
6994
7001
|
};
|
|
7002
|
+
const unsetGroup = (event) => {
|
|
7003
|
+
event?.preventDefault();
|
|
7004
|
+
event?.stopPropagation();
|
|
7005
|
+
const summary = event?.currentTarget.closest("summary"), action2 = event?.currentTarget ?? null;
|
|
7006
|
+
controller.clearRaw(name2);
|
|
7007
|
+
controller.edit(path, void 0);
|
|
7008
|
+
if (summary !== null && summary !== void 0) {
|
|
7009
|
+
const restore = () => {
|
|
7010
|
+
const active = document.activeElement;
|
|
7011
|
+
if (active === null || active === document.body || active === action2) summary.focus();
|
|
7012
|
+
};
|
|
7013
|
+
if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => {
|
|
7014
|
+
restore();
|
|
7015
|
+
requestAnimationFrame(restore);
|
|
7016
|
+
});
|
|
7017
|
+
}
|
|
7018
|
+
};
|
|
6995
7019
|
const explicit = at(state.draft, path), inherited = controller.layer === "global" ? at(snapshot4.defaults, path) : at(mergeLayer(mergeLayer(snapshot4.defaults, snapshot4.global), snapshot4.nativeForm?.base ?? {}), path);
|
|
6996
7020
|
const choices = enumValues(schema), disabled = !controller.canEdit();
|
|
6997
7021
|
if (name2 === "permissionControl.nativeCommands.entries") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { "data-field": name2, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(NativeCommandEntries, { controller, value: explicit, inherited: inherited ?? [], disabled, onChange: (value) => controller.edit(path, value), setInvalid: (key, bad) => controller.setInvalid(key, bad), t: permissionText(t) }) });
|
|
6998
7022
|
if (name2 === "permissionControl.rules") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { "data-field": name2, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PermissionRuleEntries, { controller, value: explicit, inherited: inherited ?? [], disabled, onChange: (value) => controller.edit(path, value), expanded: open, onExpandedChange: expand, t: permissionText(t) }) });
|
|
6999
7023
|
if (schema.type === "object" && schema.fields !== void 0 && path[0] !== "roleRouting") return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: "dsmm-deployment-group", "data-field": name2, open, onToggle: (event) => expand(event.currentTarget.open), children: [
|
|
7000
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { children:
|
|
7024
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { className: "dsmm-group-summary-row", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "dsmm-group-summary", children: [
|
|
7025
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "dsmm-group-summary-label", children: fieldLabel(path, t) }),
|
|
7026
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", className: "dsmm-group-summary-action", "data-dsmm-unset": name2, hidden: !open, disabled: disabled || explicit === void 0 && !Object.keys(state.raw).some((key) => key === name2 || key.startsWith(`${name2}.`)), onClick: unsetGroup, children: t("unsetGroup") })
|
|
7027
|
+
] }) }),
|
|
7001
7028
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
|
|
7002
7029
|
name2 === "permissionControl" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: permissionText(t)("configPolicyHint") }),
|
|
7003
7030
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t(explicit === void 0 ? "inherit" : "explicit") }),
|
|
7004
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", "data-dsmm-unset": name2, disabled: disabled || explicit === void 0 && !Object.keys(state.raw).some((key) => key === name2 || key.startsWith(`${name2}.`)), onClick: () => {
|
|
7005
|
-
controller.clearRaw(name2);
|
|
7006
|
-
controller.edit(path, void 0);
|
|
7007
|
-
}, children: t("unsetGroup") }),
|
|
7008
7031
|
Object.entries(schema.fields).map(([key, node]) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { schema: node, path: [...path, key], controller, disclosures, t }, key))
|
|
7009
7032
|
] })
|
|
7010
7033
|
] });
|
|
@@ -7034,6 +7057,328 @@ function Field({ schema, path, controller, initiallyOpen = false, disclosures, t
|
|
|
7034
7057
|
// src/client/PermissionsPanel.tsx
|
|
7035
7058
|
var import_react8 = require("react");
|
|
7036
7059
|
var import_dsh_client_ui_primitives8 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
7060
|
+
|
|
7061
|
+
// src/permission-remote.ts
|
|
7062
|
+
function fail3() {
|
|
7063
|
+
throw new TypeError("Invalid permission DTO.");
|
|
7064
|
+
}
|
|
7065
|
+
function text3(value, max = 512) {
|
|
7066
|
+
if (typeof value !== "string" || value.length === 0 || value.length > max || /[\u0000-\u001f\u007f]/u.test(value)) fail3();
|
|
7067
|
+
return value;
|
|
7068
|
+
}
|
|
7069
|
+
function parsePermissionSessionId(value) {
|
|
7070
|
+
return text3(value, 256);
|
|
7071
|
+
}
|
|
7072
|
+
function parseRuntime(value) {
|
|
7073
|
+
const runtime = permissionRuleRow(value, ["savedRevision", "runtimeRevision", "state", "mounted", "restartRequired"]);
|
|
7074
|
+
if (!["synced", "updating", "unsynced"].includes(runtime.state) || typeof runtime.mounted !== "boolean" || typeof runtime.restartRequired !== "boolean") fail3();
|
|
7075
|
+
return { savedRevision: permissionRevision(runtime.savedRevision), runtimeRevision: permissionRevision(runtime.runtimeRevision), state: runtime.state, mounted: runtime.mounted, restartRequired: runtime.restartRequired };
|
|
7076
|
+
}
|
|
7077
|
+
function parseCapabilities(value) {
|
|
7078
|
+
const input = permissionRuleRow(value, ["limits", "runtime", "tools"]);
|
|
7079
|
+
const limits = permissionRuleRow(input.limits, ["outsideReads", "finalInode", "scopedMemory", "webFetch", "webSearchDestinations", "proxyAddressBinding", "shellSockets", "providerAuthMcp"]);
|
|
7080
|
+
if (limits.outsideReads !== "tool-call-boundary" || limits.finalInode !== false || limits.scopedMemory !== "not-provided-by-native-rules" || limits.webFetch !== "native-public-only" || limits.webSearchDestinations !== "unsupported" || limits.proxyAddressBinding !== "native-proxy-dependent" || limits.shellSockets !== "native-executor-dependent" || limits.providerAuthMcp !== "not-covered") fail3();
|
|
7081
|
+
if (!Array.isArray(input.tools) || input.tools.length > 1024) fail3();
|
|
7082
|
+
const tools = [];
|
|
7083
|
+
const names = /* @__PURE__ */ new Set();
|
|
7084
|
+
for (const value2 of input.tools) {
|
|
7085
|
+
const tool = permissionRuleRow(value2, ["name", "kind", "approval", "scopedMemory"]), name2 = text3(tool.name);
|
|
7086
|
+
if (!["read", "glob", "grep", "shell", "webSearch", "webFetch"].includes(tool.kind) || tool.approval !== "native-once" || tool.scopedMemory !== false || names.has(name2)) fail3();
|
|
7087
|
+
names.add(name2);
|
|
7088
|
+
tools.push({ name: name2, kind: tool.kind, approval: "native-once", scopedMemory: false });
|
|
7089
|
+
}
|
|
7090
|
+
return { limits: {
|
|
7091
|
+
outsideReads: "tool-call-boundary",
|
|
7092
|
+
finalInode: false,
|
|
7093
|
+
scopedMemory: "not-provided-by-native-rules",
|
|
7094
|
+
webFetch: "native-public-only",
|
|
7095
|
+
webSearchDestinations: "unsupported",
|
|
7096
|
+
proxyAddressBinding: "native-proxy-dependent",
|
|
7097
|
+
shellSockets: "native-executor-dependent",
|
|
7098
|
+
providerAuthMcp: "not-covered"
|
|
7099
|
+
}, runtime: parseRuntime(input.runtime), tools };
|
|
7100
|
+
}
|
|
7101
|
+
function parsePermissionRulesResult(value) {
|
|
7102
|
+
const input = permissionRuleRow(value, ["snapshot", "runtime"], ["capabilities"]), snapshot4 = permissionRuleRow(input.snapshot, ["revision", "policy"]);
|
|
7103
|
+
return {
|
|
7104
|
+
snapshot: { revision: permissionRevision(snapshot4.revision), policy: resolvePermissionControl(snapshot4.policy) },
|
|
7105
|
+
runtime: parseRuntime(input.runtime),
|
|
7106
|
+
...Object.hasOwn(input, "capabilities") ? { capabilities: parseCapabilities(input.capabilities) } : {}
|
|
7107
|
+
};
|
|
7108
|
+
}
|
|
7109
|
+
var codec2 = (name2, parse3) => ({ mode: "strict", typeSymbol: `@dsmm/dsmm#${name2}`, create: () => ({ parse: parse3 }) });
|
|
7110
|
+
function descriptor2(method, result, request) {
|
|
7111
|
+
return {
|
|
7112
|
+
id: `@dsmm/dsmm-permissions#dsmmPermissions/${method}`,
|
|
7113
|
+
service: "dsmmPermissions",
|
|
7114
|
+
namespace: "dsmmPermissions",
|
|
7115
|
+
method,
|
|
7116
|
+
invocation: { kind: "direct" },
|
|
7117
|
+
parameters: [
|
|
7118
|
+
{ name: "sessionId", wire: "sessionId", source: "json", codec: codec2("PermissionSessionId", parsePermissionSessionId) },
|
|
7119
|
+
...request === void 0 ? [] : [{ name: "request", wire: "request", source: "json", codec: request }]
|
|
7120
|
+
],
|
|
7121
|
+
result
|
|
7122
|
+
};
|
|
7123
|
+
}
|
|
7124
|
+
var PERMISSION_REMOTE = { package: "@dsmm/dsmm-permissions", descriptors: [
|
|
7125
|
+
descriptor2("describeRules", codec2("PermissionRulesResult", parsePermissionRulesResult)),
|
|
7126
|
+
descriptor2("saveRules", codec2("PermissionRulesResult", parsePermissionRulesResult), codec2("PermissionRulesSaveRequest", parsePermissionRulesSave))
|
|
7127
|
+
] };
|
|
7128
|
+
var PERMISSION_HOST = { package: PERMISSION_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: PERMISSION_REMOTE.descriptors };
|
|
7129
|
+
|
|
7130
|
+
// src/client/permission-client.ts
|
|
7131
|
+
var PermissionClientError = class extends Error {
|
|
7132
|
+
constructor(code) {
|
|
7133
|
+
super("Permission operation unavailable.");
|
|
7134
|
+
this.code = code;
|
|
7135
|
+
}
|
|
7136
|
+
};
|
|
7137
|
+
var codes = /* @__PURE__ */ new Set(["not-owned", "stale", "cancelled", "unavailable", "validation", "not-found", "scope-unavailable", "replayed", "denied"]);
|
|
7138
|
+
function permissionClient(connection) {
|
|
7139
|
+
return async (method, args, signal) => {
|
|
7140
|
+
const descriptor4 = PERMISSION_REMOTE.descriptors.find((item) => item.method === method);
|
|
7141
|
+
const payload = {};
|
|
7142
|
+
descriptor4.parameters.forEach((parameter, index) => {
|
|
7143
|
+
payload[parameter.wire] = args[index];
|
|
7144
|
+
});
|
|
7145
|
+
let result;
|
|
7146
|
+
try {
|
|
7147
|
+
result = await connection.rpc.call("/api", `dsmmPermissions/${method}`, { args: payload }, signal);
|
|
7148
|
+
} catch {
|
|
7149
|
+
throw new PermissionClientError(signal.aborted ? "cancelled" : "transport");
|
|
7150
|
+
}
|
|
7151
|
+
if (!result.ok) {
|
|
7152
|
+
const code = Reflect.get(result.error.details, "code");
|
|
7153
|
+
throw new PermissionClientError(result.error.code === "dsmm-permissions/refused" && codes.has(code) ? code : "unavailable");
|
|
7154
|
+
}
|
|
7155
|
+
signal.throwIfAborted();
|
|
7156
|
+
try {
|
|
7157
|
+
if (descriptor4.result.mode !== "strict") throw new Error("Strict permission codec required.");
|
|
7158
|
+
return descriptor4.result.create().parse(result.value);
|
|
7159
|
+
} catch {
|
|
7160
|
+
throw new PermissionClientError("protocol");
|
|
7161
|
+
}
|
|
7162
|
+
};
|
|
7163
|
+
}
|
|
7164
|
+
|
|
7165
|
+
// src/client/permission-controller.ts
|
|
7166
|
+
var draftOf = (policy) => ({ outsideReads: policy.outsideReads, webSearch: { ...policy.webSearch }, webFetch: { ...policy.webFetch }, upsert: [], revoke: [], editor: null });
|
|
7167
|
+
var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
7168
|
+
function permissionChanges(view) {
|
|
7169
|
+
const { base, draft: draft2 } = view;
|
|
7170
|
+
if (base === null || draft2 === null) return null;
|
|
7171
|
+
const changes = Object.fromEntries(["outsideReads", "webSearch", "webFetch"].filter((key) => !same(base.policy[key], draft2[key])).map((key) => [key, draft2[key]]));
|
|
7172
|
+
if (Object.keys(changes).length === 0 && draft2.upsert.length === 0 && draft2.revoke.length === 0) return null;
|
|
7173
|
+
return { expectedRevision: base.revision, ...Object.keys(changes).length ? { changes } : {}, ...draft2.upsert.length ? { upsert: draft2.upsert } : {}, ...draft2.revoke.length ? { revoke: draft2.revoke } : {} };
|
|
7174
|
+
}
|
|
7175
|
+
var empty = () => ({
|
|
7176
|
+
generation: 0,
|
|
7177
|
+
sessionId: null,
|
|
7178
|
+
scope: "unknown",
|
|
7179
|
+
connected: false,
|
|
7180
|
+
reading: false,
|
|
7181
|
+
revalidating: false,
|
|
7182
|
+
busy: null,
|
|
7183
|
+
rules: null,
|
|
7184
|
+
display: null,
|
|
7185
|
+
base: null,
|
|
7186
|
+
draft: null,
|
|
7187
|
+
rulesIssue: null,
|
|
7188
|
+
dirty: false,
|
|
7189
|
+
notice: null
|
|
7190
|
+
});
|
|
7191
|
+
var observedRules = (view) => view.rules ?? view.display;
|
|
7192
|
+
var displayUnconfirmed = (view) => view.display !== null && view.rules === null;
|
|
7193
|
+
var PermissionController = class {
|
|
7194
|
+
state = empty();
|
|
7195
|
+
listeners = /* @__PURE__ */ new Set();
|
|
7196
|
+
invoke = null;
|
|
7197
|
+
connection;
|
|
7198
|
+
owner = null;
|
|
7199
|
+
request = new AbortController();
|
|
7200
|
+
requestSequence = 0;
|
|
7201
|
+
timer;
|
|
7202
|
+
watchers = 0;
|
|
7203
|
+
disposed = false;
|
|
7204
|
+
/** A successful read/save exists for the current scope fence; not mutation authority. */
|
|
7205
|
+
observed = false;
|
|
7206
|
+
store = { getSnapshot: () => this.state, subscribe: (listener) => {
|
|
7207
|
+
this.listeners.add(listener);
|
|
7208
|
+
return () => {
|
|
7209
|
+
this.listeners.delete(listener);
|
|
7210
|
+
};
|
|
7211
|
+
} };
|
|
7212
|
+
publish(patch) {
|
|
7213
|
+
if (this.disposed) return;
|
|
7214
|
+
this.state = { ...this.state, ...patch };
|
|
7215
|
+
for (const listener of this.listeners) listener();
|
|
7216
|
+
}
|
|
7217
|
+
cancel() {
|
|
7218
|
+
this.request.abort();
|
|
7219
|
+
this.request = new AbortController();
|
|
7220
|
+
this.requestSequence++;
|
|
7221
|
+
clearTimeout(this.timer);
|
|
7222
|
+
}
|
|
7223
|
+
/** An observed snapshot exists for this fence; background work must stay invisible until it changes what is possible. */
|
|
7224
|
+
trusted() {
|
|
7225
|
+
return this.observed;
|
|
7226
|
+
}
|
|
7227
|
+
fence(preserveDraft, preserveBase = preserveDraft, preserveDisplay = true) {
|
|
7228
|
+
this.cancel();
|
|
7229
|
+
this.observed = false;
|
|
7230
|
+
this.publish({
|
|
7231
|
+
generation: this.state.generation + 1,
|
|
7232
|
+
reading: false,
|
|
7233
|
+
revalidating: false,
|
|
7234
|
+
busy: null,
|
|
7235
|
+
notice: null,
|
|
7236
|
+
rules: null,
|
|
7237
|
+
rulesIssue: null,
|
|
7238
|
+
...preserveDisplay ? {} : { display: null },
|
|
7239
|
+
...preserveDraft ? {} : { draft: null, dirty: false },
|
|
7240
|
+
...preserveBase ? {} : { base: null }
|
|
7241
|
+
});
|
|
7242
|
+
}
|
|
7243
|
+
bindConnection(invoke, generation) {
|
|
7244
|
+
if (this.disposed || this.invoke === invoke && this.connection === generation) return;
|
|
7245
|
+
this.invoke = invoke;
|
|
7246
|
+
this.connection = generation;
|
|
7247
|
+
this.fence(true);
|
|
7248
|
+
this.publish({ connected: invoke !== null });
|
|
7249
|
+
this.schedule(true);
|
|
7250
|
+
}
|
|
7251
|
+
bindScope(sessionId2, owner, scope) {
|
|
7252
|
+
if (this.disposed || this.state.sessionId === sessionId2 && this.owner === owner && this.state.scope === scope) return;
|
|
7253
|
+
const sameSession = sessionId2 !== null && sessionId2 === this.state.sessionId;
|
|
7254
|
+
this.owner = owner;
|
|
7255
|
+
this.fence(sameSession, false, sameSession);
|
|
7256
|
+
this.publish({ sessionId: sessionId2, scope });
|
|
7257
|
+
this.schedule(true);
|
|
7258
|
+
}
|
|
7259
|
+
watch() {
|
|
7260
|
+
this.watchers++;
|
|
7261
|
+
if (this.watchers === 1) this.schedule(true);
|
|
7262
|
+
let active = true;
|
|
7263
|
+
return () => {
|
|
7264
|
+
if (!active) return;
|
|
7265
|
+
active = false;
|
|
7266
|
+
this.watchers--;
|
|
7267
|
+
if (this.watchers === 0) this.fence(true);
|
|
7268
|
+
};
|
|
7269
|
+
}
|
|
7270
|
+
dispose() {
|
|
7271
|
+
if (this.disposed) return;
|
|
7272
|
+
this.fence(false, false, false);
|
|
7273
|
+
this.disposed = true;
|
|
7274
|
+
this.listeners.clear();
|
|
7275
|
+
this.invoke = null;
|
|
7276
|
+
this.owner = null;
|
|
7277
|
+
}
|
|
7278
|
+
live(generation) {
|
|
7279
|
+
return !this.disposed && generation === this.state.generation && this.owner !== null && this.invoke !== null && this.state.scope === "root" && this.state.sessionId !== null;
|
|
7280
|
+
}
|
|
7281
|
+
schedule(immediate = false) {
|
|
7282
|
+
clearTimeout(this.timer);
|
|
7283
|
+
if (this.watchers === 0 || !this.live(this.state.generation)) return;
|
|
7284
|
+
this.timer = setTimeout(() => {
|
|
7285
|
+
void this.revalidate(this.state.generation);
|
|
7286
|
+
}, immediate ? 0 : 1e3);
|
|
7287
|
+
this.timer.unref?.();
|
|
7288
|
+
}
|
|
7289
|
+
issue(error) {
|
|
7290
|
+
return error instanceof PermissionClientError ? error.code : "transport";
|
|
7291
|
+
}
|
|
7292
|
+
synchronized() {
|
|
7293
|
+
const value = this.state.rules;
|
|
7294
|
+
return value !== null && value.runtime.state === "synced" && value.runtime.savedRevision === value.snapshot.revision && value.runtime.runtimeRevision === value.snapshot.revision;
|
|
7295
|
+
}
|
|
7296
|
+
/** A background request in flight never disables editing or saving; only its own save/authority does. */
|
|
7297
|
+
canEdit(generation) {
|
|
7298
|
+
return this.live(generation) && this.state.rulesIssue === null && this.synchronized() && this.state.busy === null;
|
|
7299
|
+
}
|
|
7300
|
+
canSave(generation) {
|
|
7301
|
+
return this.canEdit(generation) && this.state.dirty && this.state.draft?.editor === null;
|
|
7302
|
+
}
|
|
7303
|
+
/** User-triggered refresh: visible busy state on this transaction only. */
|
|
7304
|
+
async refresh(generation, discard = false) {
|
|
7305
|
+
await this.load(generation, discard, false);
|
|
7306
|
+
}
|
|
7307
|
+
/** Watch-driven revalidation. Invisible once a trusted snapshot exists. */
|
|
7308
|
+
async revalidate(generation) {
|
|
7309
|
+
await this.load(generation, false, true);
|
|
7310
|
+
}
|
|
7311
|
+
async load(generation, discard, background) {
|
|
7312
|
+
if (!this.live(generation) || this.state.busy !== null || this.state.reading) return;
|
|
7313
|
+
if (background && this.state.revalidating) return;
|
|
7314
|
+
if (!background && this.state.revalidating) this.cancel();
|
|
7315
|
+
const visible = !background || !this.trusted() && this.state.display === null;
|
|
7316
|
+
const sequence = ++this.requestSequence, signal = this.request.signal, id2 = this.state.sessionId;
|
|
7317
|
+
this.publish(visible ? { reading: true, revalidating: false } : { revalidating: true });
|
|
7318
|
+
try {
|
|
7319
|
+
const value = await this.invoke("describeRules", [id2], signal);
|
|
7320
|
+
if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence) return;
|
|
7321
|
+
this.observed = true;
|
|
7322
|
+
const retain = this.state.dirty && !discard;
|
|
7323
|
+
this.publish({
|
|
7324
|
+
rules: value,
|
|
7325
|
+
display: value,
|
|
7326
|
+
rulesIssue: retain && this.state.base?.revision !== value.snapshot.revision ? "stale" : null,
|
|
7327
|
+
...retain ? {} : { base: value.snapshot, draft: draftOf(value.snapshot.policy), dirty: false }
|
|
7328
|
+
});
|
|
7329
|
+
} catch (error) {
|
|
7330
|
+
if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence) return;
|
|
7331
|
+
this.publish({ rulesIssue: this.issue(error) });
|
|
7332
|
+
} finally {
|
|
7333
|
+
if (this.live(generation) && sequence === this.requestSequence) this.publish({ reading: false, revalidating: false });
|
|
7334
|
+
}
|
|
7335
|
+
this.schedule();
|
|
7336
|
+
}
|
|
7337
|
+
edit(generation, patch) {
|
|
7338
|
+
if (!this.canEdit(generation) || this.state.draft === null) return;
|
|
7339
|
+
const draft2 = { ...this.state.draft, ...patch };
|
|
7340
|
+
this.publish({ draft: draft2, notice: null });
|
|
7341
|
+
this.publish({ dirty: draft2.editor !== null || permissionChanges(this.state) !== null });
|
|
7342
|
+
}
|
|
7343
|
+
stageRule(generation) {
|
|
7344
|
+
const draft2 = this.state.draft, editor = draft2?.editor;
|
|
7345
|
+
if (editor == null || !editor.id || editor.id.length > 256 || editor.id.includes("\0")) return;
|
|
7346
|
+
const match = editor.match;
|
|
7347
|
+
if (match.kind === "outside-read" && !match.path || match.kind === "shell" && (!match.executable || !match.command || !match.workingDirectory)) return;
|
|
7348
|
+
this.edit(generation, { upsert: [...draft2.upsert.filter((row) => row.id !== editor.id), structuredClone(editor)], revoke: draft2.revoke.filter((id2) => id2 !== editor.id), editor: null });
|
|
7349
|
+
}
|
|
7350
|
+
stageRevoke(generation, id2) {
|
|
7351
|
+
const draft2 = this.state.draft;
|
|
7352
|
+
if (draft2 === null || !this.state.base?.policy.rules.some((rule) => rule.id === id2)) return;
|
|
7353
|
+
this.edit(generation, { upsert: draft2.upsert.filter((row) => row.id !== id2), revoke: [.../* @__PURE__ */ new Set([...draft2.revoke, id2])], editor: draft2.editor?.id === id2 ? null : draft2.editor });
|
|
7354
|
+
}
|
|
7355
|
+
begin(busy) {
|
|
7356
|
+
this.cancel();
|
|
7357
|
+
this.publish({ busy, reading: false, revalidating: false, notice: null });
|
|
7358
|
+
return { signal: this.request.signal, id: this.state.sessionId };
|
|
7359
|
+
}
|
|
7360
|
+
async save(generation) {
|
|
7361
|
+
const request = permissionChanges(this.state);
|
|
7362
|
+
if (!this.canSave(generation) || request === null) return;
|
|
7363
|
+
const current = this.begin("save");
|
|
7364
|
+
try {
|
|
7365
|
+
const result = await this.invoke("saveRules", [current.id, request], current.signal);
|
|
7366
|
+
if (this.live(generation)) {
|
|
7367
|
+
this.observed = true;
|
|
7368
|
+
this.publish({ rules: result, display: result, base: result.snapshot, draft: draftOf(result.snapshot.policy), dirty: false, rulesIssue: null, notice: "saved" });
|
|
7369
|
+
}
|
|
7370
|
+
} catch (error) {
|
|
7371
|
+
if (this.live(generation)) this.publish({ rulesIssue: this.issue(error) });
|
|
7372
|
+
} finally {
|
|
7373
|
+
if (this.live(generation)) {
|
|
7374
|
+
this.publish({ busy: null });
|
|
7375
|
+
this.schedule();
|
|
7376
|
+
}
|
|
7377
|
+
}
|
|
7378
|
+
}
|
|
7379
|
+
};
|
|
7380
|
+
|
|
7381
|
+
// src/client/PermissionsPanel.tsx
|
|
7037
7382
|
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
7038
7383
|
var actions2 = ["inherit", "allow", "ask", "deny"];
|
|
7039
7384
|
var kinds2 = ["outside-read", "shell", "webSearch", "webFetch"];
|
|
@@ -7117,7 +7462,7 @@ function RuleEditor({ controller, state, t }) {
|
|
|
7117
7462
|
] });
|
|
7118
7463
|
}
|
|
7119
7464
|
function RuleRecords({ controller, state, t }) {
|
|
7120
|
-
const records = state
|
|
7465
|
+
const records = observedRules(state)?.snapshot.policy.rules ?? state.base?.policy.rules;
|
|
7121
7466
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-structured", children: [
|
|
7122
7467
|
records?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("noRules") }),
|
|
7123
7468
|
records?.map((rule) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("fieldset", { children: [
|
|
@@ -7157,9 +7502,11 @@ function RuleRecords({ controller, state, t }) {
|
|
|
7157
7502
|
] });
|
|
7158
7503
|
}
|
|
7159
7504
|
function PermissionCoverage({ state, t }) {
|
|
7160
|
-
const value = state
|
|
7505
|
+
const value = observedRules(state)?.capabilities;
|
|
7161
7506
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-structured", "aria-label": t("coverageTitle"), children: [
|
|
7162
7507
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { children: t("coverageTitle") }),
|
|
7508
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("matchHint") }),
|
|
7509
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("networkLimit") }),
|
|
7163
7510
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("coverage") }),
|
|
7164
7511
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("registrationUnresolved") }),
|
|
7165
7512
|
value === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("coverageUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
@@ -7207,14 +7554,13 @@ function PermissionCoverage({ state, t }) {
|
|
|
7207
7554
|
] });
|
|
7208
7555
|
}
|
|
7209
7556
|
function PermissionRulesEditor({ controller, state, t }) {
|
|
7210
|
-
const id2 = (0, import_react8.useId)(), draft2 = state.draft, disabled = !controller.canEdit(state.generation), value = state
|
|
7557
|
+
const id2 = (0, import_react8.useId)(), draft2 = state.draft, disabled = !controller.canEdit(state.generation), value = observedRules(state), observedPolicy = value?.snapshot ?? null;
|
|
7211
7558
|
const writable = state.scope === "root" && state.connected;
|
|
7212
7559
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [
|
|
7213
7560
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { children: t("rules") }),
|
|
7214
7561
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("rulesHint") }),
|
|
7215
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("networkLimit") }),
|
|
7216
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("matchHint") }),
|
|
7217
7562
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Issue, { value: state.rulesIssue, t }),
|
|
7563
|
+
displayUnconfirmed(state) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("unconfirmedObservation") }),
|
|
7218
7564
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("observedPolicy") }),
|
|
7219
7565
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
|
|
7220
7566
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("profileOverrideState") }),
|
|
@@ -7227,16 +7573,16 @@ function PermissionRulesEditor({ controller, state, t }) {
|
|
|
7227
7573
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })
|
|
7228
7574
|
] }),
|
|
7229
7575
|
value?.runtime.restartRequired && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("restart") }),
|
|
7230
|
-
disabled && !state.reading && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("rulesUnavailable") }),
|
|
7231
|
-
|
|
7576
|
+
disabled && !state.reading && !displayUnconfirmed(state) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("rulesUnavailable") }),
|
|
7577
|
+
observedPolicy !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
|
|
7232
7578
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: "permissionControl.enabled" }),
|
|
7233
7579
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
|
|
7234
|
-
t(
|
|
7580
|
+
t(observedPolicy.policy.enabled ? "on" : "off"),
|
|
7235
7581
|
" · ",
|
|
7236
7582
|
t("coldHint")
|
|
7237
7583
|
] }),
|
|
7238
7584
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: "permissionControl.nativeCommands.enabled" }),
|
|
7239
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t(
|
|
7585
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t(observedPolicy.policy.nativeCommands.enabled ? "on" : "off") })
|
|
7240
7586
|
] }),
|
|
7241
7587
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { className: "dsmm-deployment-group", children: [
|
|
7242
7588
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("summary", { children: t("coverageDetails") }),
|
|
@@ -7306,7 +7652,11 @@ function PermissionsPanel({ controller, t, sessionId: sessionId2 }) {
|
|
|
7306
7652
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-profiles dsmm-children dsmm-permissions", "data-dsmm-permissions": true, "aria-label": t("title"), "aria-busy": state.reading, children: [
|
|
7307
7653
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { children: t("title") }),
|
|
7308
7654
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RootState, { state, t }),
|
|
7309
|
-
/* @__PURE__ */ (0, import_jsx_runtime10.
|
|
7655
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "dsmm-hint", children: [
|
|
7656
|
+
t("nativeApproval"),
|
|
7657
|
+
" ",
|
|
7658
|
+
t("sandboxScope")
|
|
7659
|
+
] }),
|
|
7310
7660
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: state.busy !== null ? t("busy") : state.reading ? t("reading") : state.notice === null ? "" : t(state.notice) }),
|
|
7311
7661
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PermissionRulesEditor, { controller, state, t })
|
|
7312
7662
|
] });
|
|
@@ -7534,11 +7884,7 @@ function DeploymentPage(props) {
|
|
|
7534
7884
|
active === "run" && controller.layer === "profile" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t })
|
|
7535
7885
|
] }),
|
|
7536
7886
|
scopeActions,
|
|
7537
|
-
active === "permissions" && /* @__PURE__ */ (0, import_jsx_runtime11.
|
|
7538
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { children: t("rootRules") }),
|
|
7539
|
-
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t("rootRulesHint") }),
|
|
7540
|
-
workspace.permissions === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("rootRulesUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PermissionsPanel, { controller: workspace.permissions, t: props.permissionsT ?? ((key) => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key) })
|
|
7541
|
-
] })
|
|
7887
|
+
active === "permissions" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("section", { className: "dsmm-zone dsmm-rules-transaction", "aria-label": t("rootRules"), children: workspace.permissions === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("rootRulesUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PermissionsPanel, { controller: workspace.permissions, t: props.permissionsT ?? ((key) => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key) }) })
|
|
7542
7888
|
] })
|
|
7543
7889
|
] }),
|
|
7544
7890
|
navigation.pending !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: "dsmm-confirm", role: "group", "aria-label": t("leaveDraft"), onKeyDown: (event) => {
|
|
@@ -7572,65 +7918,65 @@ var ROLE_CONTROL_ERROR_CODES = ["validation", "not-owned", "unavailable", "cance
|
|
|
7572
7918
|
var ROLE_CONTROL_ERROR_FIELDS = ["sessionId", "parentSessionId", "childSessionId", "request", "content", "clientTimeZone"];
|
|
7573
7919
|
|
|
7574
7920
|
// src/role-control-remote.ts
|
|
7575
|
-
function
|
|
7921
|
+
function fail4() {
|
|
7576
7922
|
throw new TypeError("Invalid Deepwork child control DTO.");
|
|
7577
7923
|
}
|
|
7578
7924
|
function json(value, depth2 = 0, active = /* @__PURE__ */ new Set()) {
|
|
7579
|
-
if (depth2 > 24)
|
|
7925
|
+
if (depth2 > 24) fail4();
|
|
7580
7926
|
if (value === null || typeof value === "boolean" || typeof value === "string") return value;
|
|
7581
7927
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
7582
|
-
if (typeof value !== "object" || value === null || active.has(value))
|
|
7928
|
+
if (typeof value !== "object" || value === null || active.has(value)) fail4();
|
|
7583
7929
|
const isArray = Array.isArray(value);
|
|
7584
|
-
if (Object.getPrototypeOf(value) !== (isArray ? Array.prototype : Object.prototype) && (isArray || Object.getPrototypeOf(value) !== null))
|
|
7585
|
-
if (Object.getOwnPropertySymbols(value).length)
|
|
7930
|
+
if (Object.getPrototypeOf(value) !== (isArray ? Array.prototype : Object.prototype) && (isArray || Object.getPrototypeOf(value) !== null)) fail4();
|
|
7931
|
+
if (Object.getOwnPropertySymbols(value).length) fail4();
|
|
7586
7932
|
for (const [key, property2] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
|
|
7587
7933
|
if (isArray && key === "length") continue;
|
|
7588
|
-
if (!Object.hasOwn(property2, "value") || !property2.enumerable || ["__proto__", "prototype", "constructor"].includes(key) || isArray && !/^(0|[1-9][0-9]*)$/u.test(key))
|
|
7934
|
+
if (!Object.hasOwn(property2, "value") || !property2.enumerable || ["__proto__", "prototype", "constructor"].includes(key) || isArray && !/^(0|[1-9][0-9]*)$/u.test(key)) fail4();
|
|
7589
7935
|
}
|
|
7590
|
-
if (isArray && Object.keys(value).length !== value.length)
|
|
7936
|
+
if (isArray && Object.keys(value).length !== value.length) fail4();
|
|
7591
7937
|
active.add(value);
|
|
7592
7938
|
const result = isArray ? value.map((child2) => json(child2, depth2 + 1, active)) : Object.fromEntries(Object.entries(value).map(([key, child2]) => [key, json(child2, depth2 + 1, active)]));
|
|
7593
7939
|
active.delete(value);
|
|
7594
7940
|
return result;
|
|
7595
7941
|
}
|
|
7596
7942
|
function object2(value, required, optional2 = []) {
|
|
7597
|
-
if (typeof value !== "object" || value === null || Array.isArray(value))
|
|
7943
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) fail4();
|
|
7598
7944
|
const row = value;
|
|
7599
|
-
if (required.some((key) => !Object.hasOwn(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional2.includes(key)))
|
|
7945
|
+
if (required.some((key) => !Object.hasOwn(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional2.includes(key))) fail4();
|
|
7600
7946
|
return row;
|
|
7601
7947
|
}
|
|
7602
7948
|
function choice(value, choices) {
|
|
7603
|
-
if (!choices.includes(value))
|
|
7949
|
+
if (!choices.includes(value)) fail4();
|
|
7604
7950
|
return value;
|
|
7605
7951
|
}
|
|
7606
|
-
function
|
|
7607
|
-
if (typeof value !== "string" || value.length > max || /[\u0000-\u001f\u007f]/u.test(value) || new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value)
|
|
7952
|
+
function text4(value, max) {
|
|
7953
|
+
if (typeof value !== "string" || value.length > max || /[\u0000-\u001f\u007f]/u.test(value) || new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) fail4();
|
|
7608
7954
|
return value;
|
|
7609
7955
|
}
|
|
7610
7956
|
function identity(value) {
|
|
7611
|
-
if (!isNativeSessionId(value))
|
|
7957
|
+
if (!isNativeSessionId(value)) fail4();
|
|
7612
7958
|
return value;
|
|
7613
7959
|
}
|
|
7614
7960
|
function epoch2(value) {
|
|
7615
|
-
if (typeof value !== "string" || !/^[a-f0-9]{64}$/u.test(value))
|
|
7961
|
+
if (typeof value !== "string" || !/^[a-f0-9]{64}$/u.test(value)) fail4();
|
|
7616
7962
|
return value;
|
|
7617
7963
|
}
|
|
7618
7964
|
function array(value, max = 4096) {
|
|
7619
|
-
if (!Array.isArray(value) || value.length > max)
|
|
7965
|
+
if (!Array.isArray(value) || value.length > max) fail4();
|
|
7620
7966
|
return value;
|
|
7621
7967
|
}
|
|
7622
7968
|
function bool(value) {
|
|
7623
|
-
if (typeof value !== "boolean")
|
|
7969
|
+
if (typeof value !== "boolean") fail4();
|
|
7624
7970
|
return value;
|
|
7625
7971
|
}
|
|
7626
7972
|
function depth(value) {
|
|
7627
|
-
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 4096)
|
|
7973
|
+
if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 4096) fail4();
|
|
7628
7974
|
return value;
|
|
7629
7975
|
}
|
|
7630
7976
|
function availability(value) {
|
|
7631
7977
|
const row = object2(value, ["enabled"], ["reason"]);
|
|
7632
7978
|
if (row.enabled === true && !Object.hasOwn(row, "reason")) return { enabled: true };
|
|
7633
|
-
if (row.enabled !== false)
|
|
7979
|
+
if (row.enabled !== false) fail4();
|
|
7634
7980
|
return { enabled: false, reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) };
|
|
7635
7981
|
}
|
|
7636
7982
|
function capabilities(value) {
|
|
@@ -7643,12 +7989,12 @@ function child(value) {
|
|
|
7643
7989
|
const mode = choice(row.mode, ["one-shot", "continuable", "unknown"]);
|
|
7644
7990
|
const prompt = availability(controls.prompt), interrupt = availability(controls.interrupt);
|
|
7645
7991
|
const readonly = bool(row.readonly);
|
|
7646
|
-
if (readonly !== (!prompt.enabled && !interrupt.enabled) || mode !== "continuable" && (prompt.enabled || interrupt.enabled))
|
|
7992
|
+
if (readonly !== (!prompt.enabled && !interrupt.enabled) || mode !== "continuable" && (prompt.enabled || interrupt.enabled)) fail4();
|
|
7647
7993
|
const invocation = Object.hasOwn(row, "invocation") ? parseDsmmInvocationView(row.invocation) : void 0;
|
|
7648
7994
|
const routeComparison = Object.hasOwn(row, "routeComparison") ? parseDsmmRoleRouteComparison(row.routeComparison) : void 0;
|
|
7649
7995
|
const id2 = identity(row.id);
|
|
7650
|
-
if (invocation !== void 0 && (invocation.childId !== id2 || invocation.mode !== mode))
|
|
7651
|
-
if (routeComparison !== void 0 && routeComparison.childId !== id2)
|
|
7996
|
+
if (invocation !== void 0 && (invocation.childId !== id2 || invocation.mode !== mode)) fail4();
|
|
7997
|
+
if (routeComparison !== void 0 && routeComparison.childId !== id2) fail4();
|
|
7652
7998
|
return {
|
|
7653
7999
|
id: id2,
|
|
7654
8000
|
parentSessionId: identity(row.parentSessionId),
|
|
@@ -7656,7 +8002,7 @@ function child(value) {
|
|
|
7656
8002
|
activity: choice(row.activity, ["running", "inactive"]),
|
|
7657
8003
|
readonly,
|
|
7658
8004
|
controls: { prompt, interrupt },
|
|
7659
|
-
...Object.hasOwn(row, "label") ? { label:
|
|
8005
|
+
...Object.hasOwn(row, "label") ? { label: text4(row.label, 120) } : {},
|
|
7660
8006
|
...invocation === void 0 ? {} : { invocation },
|
|
7661
8007
|
...routeComparison === void 0 ? {} : { routeComparison }
|
|
7662
8008
|
};
|
|
@@ -7664,7 +8010,7 @@ function child(value) {
|
|
|
7664
8010
|
function snapshot3(value) {
|
|
7665
8011
|
const row = object2(value, ["sessionId", "admissionEpoch", "children", "capabilities"]);
|
|
7666
8012
|
const sessionId2 = identity(row.sessionId), admissionEpoch = epoch2(row.admissionEpoch), children = array(row.children).map(child);
|
|
7667
|
-
if (children.some((child2) => child2.parentSessionId !== sessionId2))
|
|
8013
|
+
if (children.some((child2) => child2.parentSessionId !== sessionId2)) fail4();
|
|
7668
8014
|
return { sessionId: sessionId2, admissionEpoch, children, capabilities: capabilities(row.capabilities) };
|
|
7669
8015
|
}
|
|
7670
8016
|
function descendants(value) {
|
|
@@ -7675,39 +8021,39 @@ function descendants(value) {
|
|
|
7675
8021
|
if (entry.kind === "child") {
|
|
7676
8022
|
object2(entry, ["kind", "depth", "child", "hasChildren"]);
|
|
7677
8023
|
const projected = child(entry.child);
|
|
7678
|
-
if (entry.depth !== 1 && (projected.controls.prompt.enabled || projected.controls.interrupt.enabled))
|
|
8024
|
+
if (entry.depth !== 1 && (projected.controls.prompt.enabled || projected.controls.interrupt.enabled)) fail4();
|
|
7679
8025
|
return { kind: "child", depth: depth(entry.depth), child: projected, hasChildren: bool(entry.hasChildren) };
|
|
7680
8026
|
}
|
|
7681
8027
|
object2(entry, ["kind", "depth", "id", "parentSessionId", "reason"]);
|
|
7682
|
-
if (entry.kind !== "diagnostic")
|
|
8028
|
+
if (entry.kind !== "diagnostic") fail4();
|
|
7683
8029
|
return { kind: "diagnostic", depth: depth(entry.depth), id: identity(entry.id), parentSessionId: identity(entry.parentSessionId), reason: choice(entry.reason, ["corrupt", "unsupported", "unavailable"]) };
|
|
7684
8030
|
});
|
|
7685
8031
|
for (const entry of entries) {
|
|
7686
8032
|
const parent = entry.kind === "child" ? entry.child.parentSessionId : entry.parentSessionId;
|
|
7687
|
-
if (entry.depth === 1 !== (parent === sessionId2))
|
|
8033
|
+
if (entry.depth === 1 !== (parent === sessionId2)) fail4();
|
|
7688
8034
|
}
|
|
7689
8035
|
return { sessionId: sessionId2, admissionEpoch, descendants: entries };
|
|
7690
8036
|
}
|
|
7691
8037
|
function promptRequest(value) {
|
|
7692
8038
|
const row = object2(value, ["requestId", "parentSessionId", "childSessionId", "mode", "delivery", "content"], ["clientTimeZone"]);
|
|
7693
|
-
if (row.mode !== "continuable")
|
|
8039
|
+
if (row.mode !== "continuable") fail4();
|
|
7694
8040
|
const content2 = array(row.content, Number.MAX_SAFE_INTEGER).map((value2) => {
|
|
7695
8041
|
const part = object2(value2, ["type"], ["text", "mediaType", "data", "name"]);
|
|
7696
8042
|
if (part.type === "text") {
|
|
7697
8043
|
object2(part, ["type", "text"]);
|
|
7698
|
-
if (typeof part.text !== "string")
|
|
8044
|
+
if (typeof part.text !== "string") fail4();
|
|
7699
8045
|
return { type: "text", text: part.text };
|
|
7700
8046
|
}
|
|
7701
8047
|
object2(part, ["type", "mediaType", "data"], ["name"]);
|
|
7702
|
-
if (part.type !== "image" || typeof part.data !== "string")
|
|
8048
|
+
if (part.type !== "image" || typeof part.data !== "string") fail4();
|
|
7703
8049
|
return {
|
|
7704
8050
|
type: "image",
|
|
7705
8051
|
mediaType: choice(part.mediaType, ["image/png", "image/jpeg", "image/webp", "image/gif"]),
|
|
7706
8052
|
data: part.data,
|
|
7707
|
-
...Object.hasOwn(part, "name") ? { name:
|
|
8053
|
+
...Object.hasOwn(part, "name") ? { name: text4(part.name, 256) } : {}
|
|
7708
8054
|
};
|
|
7709
8055
|
});
|
|
7710
|
-
if (content2.length === 0)
|
|
8056
|
+
if (content2.length === 0) fail4();
|
|
7711
8057
|
return {
|
|
7712
8058
|
requestId: identity(row.requestId),
|
|
7713
8059
|
parentSessionId: identity(row.parentSessionId),
|
|
@@ -7715,12 +8061,12 @@ function promptRequest(value) {
|
|
|
7715
8061
|
mode: "continuable",
|
|
7716
8062
|
delivery: choice(row.delivery, ["queue", "steer"]),
|
|
7717
8063
|
content: content2,
|
|
7718
|
-
...Object.hasOwn(row, "clientTimeZone") ? { clientTimeZone:
|
|
8064
|
+
...Object.hasOwn(row, "clientTimeZone") ? { clientTimeZone: text4(row.clientTimeZone, 128) } : {}
|
|
7719
8065
|
};
|
|
7720
8066
|
}
|
|
7721
8067
|
function interruptRequest(value) {
|
|
7722
8068
|
const row = object2(value, ["parentSessionId", "childSessionId", "mode"]);
|
|
7723
|
-
if (row.mode !== "continuable")
|
|
8069
|
+
if (row.mode !== "continuable") fail4();
|
|
7724
8070
|
return { parentSessionId: identity(row.parentSessionId), childSessionId: identity(row.childSessionId), mode: "continuable" };
|
|
7725
8071
|
}
|
|
7726
8072
|
function promptReceipt(value) {
|
|
@@ -7729,7 +8075,7 @@ function promptReceipt(value) {
|
|
|
7729
8075
|
}
|
|
7730
8076
|
function interruptReceipt(value) {
|
|
7731
8077
|
const row = object2(value, ["accepted"]);
|
|
7732
|
-
if (row.accepted !== true)
|
|
8078
|
+
if (row.accepted !== true) fail4();
|
|
7733
8079
|
return { accepted: true };
|
|
7734
8080
|
}
|
|
7735
8081
|
function errorInfo2(value) {
|
|
@@ -7742,348 +8088,61 @@ function errorInfo2(value) {
|
|
|
7742
8088
|
}
|
|
7743
8089
|
var parseRoleControlErrorInfo = (value) => errorInfo2(json(value));
|
|
7744
8090
|
var parseChildSessionSnapshot = (value) => snapshot3(json(value));
|
|
7745
|
-
var parseRoleControlDescendants = (value) => descendants(json(value));
|
|
7746
|
-
var parseRoleControlPromptRequest = (value) => promptRequest(json(value));
|
|
7747
|
-
function
|
|
7748
|
-
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: (value) => parse3(json(value)) }) };
|
|
7749
|
-
}
|
|
7750
|
-
function descriptor2(method, result, request) {
|
|
7751
|
-
return {
|
|
7752
|
-
id: `@dsmm/dsmm-children#dsmmChildren/${method}`,
|
|
7753
|
-
service: "dsmmChildren",
|
|
7754
|
-
namespace: "dsmmChildren",
|
|
7755
|
-
method,
|
|
7756
|
-
invocation: { kind: "direct" },
|
|
7757
|
-
parameters: [
|
|
7758
|
-
{ name: "sessionId", wire: "sessionId", source: "json", codec: codec2("ChildControlSessionId", identity) },
|
|
7759
|
-
...request === void 0 ? [] : [{ name: "request", wire: "request", source: "json", codec: request }]
|
|
7760
|
-
],
|
|
7761
|
-
result
|
|
7762
|
-
};
|
|
7763
|
-
}
|
|
7764
|
-
var ROLE_CONTROL_REMOTE = { package: "@dsmm/dsmm-children", descriptors: [
|
|
7765
|
-
descriptor2("describe", codec2("ChildSessionSnapshot", snapshot3)),
|
|
7766
|
-
descriptor2("descendants", codec2("RoleControlDescendantsSnapshot", descendants)),
|
|
7767
|
-
descriptor2("prompt", codec2("SubagentPromptReceipt", promptReceipt), codec2("SubagentPromptRequest", promptRequest)),
|
|
7768
|
-
descriptor2("interrupt", codec2("SubagentInterruptReceipt", interruptReceipt), codec2("RoleControlInterruptRequest", interruptRequest))
|
|
7769
|
-
] };
|
|
7770
|
-
var ROLE_CONTROL_HOST = { package: ROLE_CONTROL_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: ROLE_CONTROL_REMOTE.descriptors };
|
|
7771
|
-
|
|
7772
|
-
// src/permission-remote.ts
|
|
7773
|
-
function fail4() {
|
|
7774
|
-
throw new TypeError("Invalid permission DTO.");
|
|
7775
|
-
}
|
|
7776
|
-
function text4(value, max = 512) {
|
|
7777
|
-
if (typeof value !== "string" || value.length === 0 || value.length > max || /[\u0000-\u001f\u007f]/u.test(value)) fail4();
|
|
7778
|
-
return value;
|
|
7779
|
-
}
|
|
7780
|
-
function parsePermissionSessionId(value) {
|
|
7781
|
-
return text4(value, 256);
|
|
7782
|
-
}
|
|
7783
|
-
function parseRuntime(value) {
|
|
7784
|
-
const runtime = permissionRuleRow(value, ["savedRevision", "runtimeRevision", "state", "mounted", "restartRequired"]);
|
|
7785
|
-
if (!["synced", "updating", "unsynced"].includes(runtime.state) || typeof runtime.mounted !== "boolean" || typeof runtime.restartRequired !== "boolean") fail4();
|
|
7786
|
-
return { savedRevision: permissionRevision(runtime.savedRevision), runtimeRevision: permissionRevision(runtime.runtimeRevision), state: runtime.state, mounted: runtime.mounted, restartRequired: runtime.restartRequired };
|
|
7787
|
-
}
|
|
7788
|
-
function parseCapabilities(value) {
|
|
7789
|
-
const input = permissionRuleRow(value, ["limits", "runtime", "tools"]);
|
|
7790
|
-
const limits = permissionRuleRow(input.limits, ["outsideReads", "finalInode", "scopedMemory", "webFetch", "webSearchDestinations", "proxyAddressBinding", "shellSockets", "providerAuthMcp"]);
|
|
7791
|
-
if (limits.outsideReads !== "tool-call-boundary" || limits.finalInode !== false || limits.scopedMemory !== "not-provided-by-native-rules" || limits.webFetch !== "native-public-only" || limits.webSearchDestinations !== "unsupported" || limits.proxyAddressBinding !== "native-proxy-dependent" || limits.shellSockets !== "native-executor-dependent" || limits.providerAuthMcp !== "not-covered") fail4();
|
|
7792
|
-
if (!Array.isArray(input.tools) || input.tools.length > 1024) fail4();
|
|
7793
|
-
const tools = [];
|
|
7794
|
-
const names = /* @__PURE__ */ new Set();
|
|
7795
|
-
for (const value2 of input.tools) {
|
|
7796
|
-
const tool = permissionRuleRow(value2, ["name", "kind", "approval", "scopedMemory"]), name2 = text4(tool.name);
|
|
7797
|
-
if (!["read", "glob", "grep", "shell", "webSearch", "webFetch"].includes(tool.kind) || tool.approval !== "native-once" || tool.scopedMemory !== false || names.has(name2)) fail4();
|
|
7798
|
-
names.add(name2);
|
|
7799
|
-
tools.push({ name: name2, kind: tool.kind, approval: "native-once", scopedMemory: false });
|
|
7800
|
-
}
|
|
7801
|
-
return { limits: {
|
|
7802
|
-
outsideReads: "tool-call-boundary",
|
|
7803
|
-
finalInode: false,
|
|
7804
|
-
scopedMemory: "not-provided-by-native-rules",
|
|
7805
|
-
webFetch: "native-public-only",
|
|
7806
|
-
webSearchDestinations: "unsupported",
|
|
7807
|
-
proxyAddressBinding: "native-proxy-dependent",
|
|
7808
|
-
shellSockets: "native-executor-dependent",
|
|
7809
|
-
providerAuthMcp: "not-covered"
|
|
7810
|
-
}, runtime: parseRuntime(input.runtime), tools };
|
|
7811
|
-
}
|
|
7812
|
-
function parsePermissionRulesResult(value) {
|
|
7813
|
-
const input = permissionRuleRow(value, ["snapshot", "runtime"], ["capabilities"]), snapshot4 = permissionRuleRow(input.snapshot, ["revision", "policy"]);
|
|
7814
|
-
return {
|
|
7815
|
-
snapshot: { revision: permissionRevision(snapshot4.revision), policy: resolvePermissionControl(snapshot4.policy) },
|
|
7816
|
-
runtime: parseRuntime(input.runtime),
|
|
7817
|
-
...Object.hasOwn(input, "capabilities") ? { capabilities: parseCapabilities(input.capabilities) } : {}
|
|
7818
|
-
};
|
|
8091
|
+
var parseRoleControlDescendants = (value) => descendants(json(value));
|
|
8092
|
+
var parseRoleControlPromptRequest = (value) => promptRequest(json(value));
|
|
8093
|
+
function codec3(symbol, parse3) {
|
|
8094
|
+
return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: (value) => parse3(json(value)) }) };
|
|
7819
8095
|
}
|
|
7820
|
-
var codec3 = (name2, parse3) => ({ mode: "strict", typeSymbol: `@dsmm/dsmm#${name2}`, create: () => ({ parse: parse3 }) });
|
|
7821
8096
|
function descriptor3(method, result, request) {
|
|
7822
8097
|
return {
|
|
7823
|
-
id: `@dsmm/dsmm-
|
|
7824
|
-
service: "
|
|
7825
|
-
namespace: "
|
|
8098
|
+
id: `@dsmm/dsmm-children#dsmmChildren/${method}`,
|
|
8099
|
+
service: "dsmmChildren",
|
|
8100
|
+
namespace: "dsmmChildren",
|
|
7826
8101
|
method,
|
|
7827
8102
|
invocation: { kind: "direct" },
|
|
7828
8103
|
parameters: [
|
|
7829
|
-
{ name: "sessionId", wire: "sessionId", source: "json", codec: codec3("
|
|
8104
|
+
{ name: "sessionId", wire: "sessionId", source: "json", codec: codec3("ChildControlSessionId", identity) },
|
|
7830
8105
|
...request === void 0 ? [] : [{ name: "request", wire: "request", source: "json", codec: request }]
|
|
7831
8106
|
],
|
|
7832
8107
|
result
|
|
7833
8108
|
};
|
|
7834
8109
|
}
|
|
7835
|
-
var
|
|
7836
|
-
descriptor3("
|
|
7837
|
-
descriptor3("
|
|
8110
|
+
var ROLE_CONTROL_REMOTE = { package: "@dsmm/dsmm-children", descriptors: [
|
|
8111
|
+
descriptor3("describe", codec3("ChildSessionSnapshot", snapshot3)),
|
|
8112
|
+
descriptor3("descendants", codec3("RoleControlDescendantsSnapshot", descendants)),
|
|
8113
|
+
descriptor3("prompt", codec3("SubagentPromptReceipt", promptReceipt), codec3("SubagentPromptRequest", promptRequest)),
|
|
8114
|
+
descriptor3("interrupt", codec3("SubagentInterruptReceipt", interruptReceipt), codec3("RoleControlInterruptRequest", interruptRequest))
|
|
7838
8115
|
] };
|
|
7839
|
-
var
|
|
8116
|
+
var ROLE_CONTROL_HOST = { package: ROLE_CONTROL_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: ROLE_CONTROL_REMOTE.descriptors };
|
|
7840
8117
|
|
|
7841
|
-
// src/client/permission-
|
|
7842
|
-
|
|
7843
|
-
|
|
7844
|
-
|
|
7845
|
-
|
|
7846
|
-
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
return async (method, args, signal) => {
|
|
7851
|
-
const descriptor4 = PERMISSION_REMOTE.descriptors.find((item) => item.method === method);
|
|
7852
|
-
const payload = {};
|
|
7853
|
-
descriptor4.parameters.forEach((parameter, index) => {
|
|
7854
|
-
payload[parameter.wire] = args[index];
|
|
7855
|
-
});
|
|
7856
|
-
let result;
|
|
7857
|
-
try {
|
|
7858
|
-
result = await connection.rpc.call("/api", `dsmmPermissions/${method}`, { args: payload }, signal);
|
|
7859
|
-
} catch {
|
|
7860
|
-
throw new PermissionClientError(signal.aborted ? "cancelled" : "transport");
|
|
7861
|
-
}
|
|
7862
|
-
if (!result.ok) {
|
|
7863
|
-
const code = Reflect.get(result.error.details, "code");
|
|
7864
|
-
throw new PermissionClientError(result.error.code === "dsmm-permissions/refused" && codes.has(code) ? code : "unavailable");
|
|
7865
|
-
}
|
|
7866
|
-
signal.throwIfAborted();
|
|
7867
|
-
try {
|
|
7868
|
-
if (descriptor4.result.mode !== "strict") throw new Error("Strict permission codec required.");
|
|
7869
|
-
return descriptor4.result.create().parse(result.value);
|
|
7870
|
-
} catch {
|
|
7871
|
-
throw new PermissionClientError("protocol");
|
|
8118
|
+
// src/client/permission-session.ts
|
|
8119
|
+
function bindPermissionSession(source, sessions, permissions) {
|
|
8120
|
+
let observed, stop;
|
|
8121
|
+
const update = () => {
|
|
8122
|
+
const id2 = source.getSnapshot().key, binding = id2 === void 0 ? void 0 : sessions.binding(id2);
|
|
8123
|
+
if (binding !== observed) {
|
|
8124
|
+
stop?.();
|
|
8125
|
+
observed = binding;
|
|
8126
|
+
stop = binding?.session.subscribe(update);
|
|
7872
8127
|
}
|
|
8128
|
+
const snapshot4 = binding?.session.getSnapshot(), catalog = sessions.list.getSnapshot(), summary = id2 === void 0 ? void 0 : catalog.byId[id2];
|
|
8129
|
+
const child2 = snapshot4?.subagent != null || summary?.origin === "subagent" || summary?.parentId !== void 0;
|
|
8130
|
+
const root = id2 !== void 0 && binding?.sessionId === id2 && snapshot4?.sessionId === id2 && snapshot4.openState === "open" && !snapshot4.removed && catalog.ids.includes(id2) && summary !== void 0 && !child2;
|
|
8131
|
+
permissions.bindScope(id2 ?? null, binding ?? null, child2 ? "child" : root ? "root" : "unknown");
|
|
8132
|
+
};
|
|
8133
|
+
update();
|
|
8134
|
+
const stopSource = source.subscribe(update), stopCatalog = sessions.list.subscribe(update);
|
|
8135
|
+
let active = true;
|
|
8136
|
+
return () => {
|
|
8137
|
+
if (!active) return;
|
|
8138
|
+
active = false;
|
|
8139
|
+
stopSource();
|
|
8140
|
+
stopCatalog();
|
|
8141
|
+
stop?.();
|
|
8142
|
+
permissions.bindScope(null, null, "unknown");
|
|
7873
8143
|
};
|
|
7874
8144
|
}
|
|
7875
8145
|
|
|
7876
|
-
// src/client/permission-controller.ts
|
|
7877
|
-
var draftOf = (policy) => ({ outsideReads: policy.outsideReads, webSearch: { ...policy.webSearch }, webFetch: { ...policy.webFetch }, upsert: [], revoke: [], editor: null });
|
|
7878
|
-
var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
7879
|
-
function permissionChanges(view) {
|
|
7880
|
-
const { base, draft: draft2 } = view;
|
|
7881
|
-
if (base === null || draft2 === null) return null;
|
|
7882
|
-
const changes = Object.fromEntries(["outsideReads", "webSearch", "webFetch"].filter((key) => !same(base.policy[key], draft2[key])).map((key) => [key, draft2[key]]));
|
|
7883
|
-
if (Object.keys(changes).length === 0 && draft2.upsert.length === 0 && draft2.revoke.length === 0) return null;
|
|
7884
|
-
return { expectedRevision: base.revision, ...Object.keys(changes).length ? { changes } : {}, ...draft2.upsert.length ? { upsert: draft2.upsert } : {}, ...draft2.revoke.length ? { revoke: draft2.revoke } : {} };
|
|
7885
|
-
}
|
|
7886
|
-
var empty = () => ({
|
|
7887
|
-
generation: 0,
|
|
7888
|
-
sessionId: null,
|
|
7889
|
-
scope: "unknown",
|
|
7890
|
-
connected: false,
|
|
7891
|
-
reading: false,
|
|
7892
|
-
revalidating: false,
|
|
7893
|
-
busy: null,
|
|
7894
|
-
rules: null,
|
|
7895
|
-
base: null,
|
|
7896
|
-
draft: null,
|
|
7897
|
-
rulesIssue: null,
|
|
7898
|
-
dirty: false,
|
|
7899
|
-
notice: null
|
|
7900
|
-
});
|
|
7901
|
-
var PermissionController = class {
|
|
7902
|
-
state = empty();
|
|
7903
|
-
listeners = /* @__PURE__ */ new Set();
|
|
7904
|
-
invoke = null;
|
|
7905
|
-
connection;
|
|
7906
|
-
owner = null;
|
|
7907
|
-
request = new AbortController();
|
|
7908
|
-
requestSequence = 0;
|
|
7909
|
-
timer;
|
|
7910
|
-
watchers = 0;
|
|
7911
|
-
disposed = false;
|
|
7912
|
-
/** A successful read/save exists for the current scope fence; not mutation authority. */
|
|
7913
|
-
observed = false;
|
|
7914
|
-
store = { getSnapshot: () => this.state, subscribe: (listener) => {
|
|
7915
|
-
this.listeners.add(listener);
|
|
7916
|
-
return () => {
|
|
7917
|
-
this.listeners.delete(listener);
|
|
7918
|
-
};
|
|
7919
|
-
} };
|
|
7920
|
-
publish(patch) {
|
|
7921
|
-
if (this.disposed) return;
|
|
7922
|
-
this.state = { ...this.state, ...patch };
|
|
7923
|
-
for (const listener of this.listeners) listener();
|
|
7924
|
-
}
|
|
7925
|
-
cancel() {
|
|
7926
|
-
this.request.abort();
|
|
7927
|
-
this.request = new AbortController();
|
|
7928
|
-
this.requestSequence++;
|
|
7929
|
-
clearTimeout(this.timer);
|
|
7930
|
-
}
|
|
7931
|
-
/** An observed snapshot exists; background work must stay invisible until it changes what is possible. */
|
|
7932
|
-
trusted() {
|
|
7933
|
-
return this.observed;
|
|
7934
|
-
}
|
|
7935
|
-
fence(preserveDraft, preserveBase = preserveDraft) {
|
|
7936
|
-
this.cancel();
|
|
7937
|
-
this.observed = false;
|
|
7938
|
-
this.publish({
|
|
7939
|
-
generation: this.state.generation + 1,
|
|
7940
|
-
reading: false,
|
|
7941
|
-
revalidating: false,
|
|
7942
|
-
busy: null,
|
|
7943
|
-
notice: null,
|
|
7944
|
-
rules: null,
|
|
7945
|
-
rulesIssue: null,
|
|
7946
|
-
...preserveDraft ? {} : { draft: null, dirty: false },
|
|
7947
|
-
...preserveBase ? {} : { base: null }
|
|
7948
|
-
});
|
|
7949
|
-
}
|
|
7950
|
-
bindConnection(invoke, generation) {
|
|
7951
|
-
if (this.disposed || this.invoke === invoke && this.connection === generation) return;
|
|
7952
|
-
this.invoke = invoke;
|
|
7953
|
-
this.connection = generation;
|
|
7954
|
-
this.fence(true);
|
|
7955
|
-
this.publish({ connected: invoke !== null });
|
|
7956
|
-
this.schedule(true);
|
|
7957
|
-
}
|
|
7958
|
-
bindScope(sessionId2, owner, scope) {
|
|
7959
|
-
if (this.disposed || this.state.sessionId === sessionId2 && this.owner === owner && this.state.scope === scope) return;
|
|
7960
|
-
const sameSession = sessionId2 === this.state.sessionId;
|
|
7961
|
-
this.owner = owner;
|
|
7962
|
-
this.fence(sameSession, false);
|
|
7963
|
-
this.publish({ sessionId: sessionId2, scope });
|
|
7964
|
-
this.schedule(true);
|
|
7965
|
-
}
|
|
7966
|
-
watch() {
|
|
7967
|
-
this.watchers++;
|
|
7968
|
-
if (this.watchers === 1) this.schedule(true);
|
|
7969
|
-
let active = true;
|
|
7970
|
-
return () => {
|
|
7971
|
-
if (!active) return;
|
|
7972
|
-
active = false;
|
|
7973
|
-
this.watchers--;
|
|
7974
|
-
if (this.watchers === 0) this.fence(true);
|
|
7975
|
-
};
|
|
7976
|
-
}
|
|
7977
|
-
dispose() {
|
|
7978
|
-
if (this.disposed) return;
|
|
7979
|
-
this.fence(false);
|
|
7980
|
-
this.disposed = true;
|
|
7981
|
-
this.listeners.clear();
|
|
7982
|
-
this.invoke = null;
|
|
7983
|
-
this.owner = null;
|
|
7984
|
-
}
|
|
7985
|
-
live(generation) {
|
|
7986
|
-
return !this.disposed && generation === this.state.generation && this.owner !== null && this.invoke !== null && this.state.scope === "root" && this.state.sessionId !== null;
|
|
7987
|
-
}
|
|
7988
|
-
schedule(immediate = false) {
|
|
7989
|
-
clearTimeout(this.timer);
|
|
7990
|
-
if (this.watchers === 0 || !this.live(this.state.generation)) return;
|
|
7991
|
-
this.timer = setTimeout(() => {
|
|
7992
|
-
void this.revalidate(this.state.generation);
|
|
7993
|
-
}, immediate ? 0 : 1e3);
|
|
7994
|
-
this.timer.unref?.();
|
|
7995
|
-
}
|
|
7996
|
-
issue(error) {
|
|
7997
|
-
return error instanceof PermissionClientError ? error.code : "transport";
|
|
7998
|
-
}
|
|
7999
|
-
synchronized() {
|
|
8000
|
-
const value = this.state.rules;
|
|
8001
|
-
return value !== null && value.runtime.state === "synced" && value.runtime.savedRevision === value.snapshot.revision && value.runtime.runtimeRevision === value.snapshot.revision;
|
|
8002
|
-
}
|
|
8003
|
-
/** A background request in flight never disables editing or saving; only its own save/authority does. */
|
|
8004
|
-
canEdit(generation) {
|
|
8005
|
-
return this.live(generation) && this.state.rulesIssue === null && this.synchronized() && this.state.busy === null;
|
|
8006
|
-
}
|
|
8007
|
-
canSave(generation) {
|
|
8008
|
-
return this.canEdit(generation) && this.state.dirty && this.state.draft?.editor === null;
|
|
8009
|
-
}
|
|
8010
|
-
/** User-triggered refresh: visible busy state on this transaction only. */
|
|
8011
|
-
async refresh(generation, discard = false) {
|
|
8012
|
-
await this.load(generation, discard, false);
|
|
8013
|
-
}
|
|
8014
|
-
/** Watch-driven revalidation. Invisible once a trusted snapshot exists. */
|
|
8015
|
-
async revalidate(generation) {
|
|
8016
|
-
await this.load(generation, false, true);
|
|
8017
|
-
}
|
|
8018
|
-
async load(generation, discard, background) {
|
|
8019
|
-
if (!this.live(generation) || this.state.busy !== null || this.state.reading) return;
|
|
8020
|
-
if (background && this.state.revalidating) return;
|
|
8021
|
-
if (!background && this.state.revalidating) this.cancel();
|
|
8022
|
-
const visible = !background || !this.trusted();
|
|
8023
|
-
const sequence = ++this.requestSequence, signal = this.request.signal, id2 = this.state.sessionId;
|
|
8024
|
-
this.publish(visible ? { reading: true, revalidating: false } : { revalidating: true });
|
|
8025
|
-
try {
|
|
8026
|
-
const value = await this.invoke("describeRules", [id2], signal);
|
|
8027
|
-
if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence) return;
|
|
8028
|
-
this.observed = true;
|
|
8029
|
-
const retain = this.state.dirty && !discard;
|
|
8030
|
-
this.publish({
|
|
8031
|
-
rules: value,
|
|
8032
|
-
rulesIssue: retain && this.state.base?.revision !== value.snapshot.revision ? "stale" : null,
|
|
8033
|
-
...retain ? {} : { base: value.snapshot, draft: draftOf(value.snapshot.policy), dirty: false }
|
|
8034
|
-
});
|
|
8035
|
-
} catch (error) {
|
|
8036
|
-
if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence) return;
|
|
8037
|
-
this.publish({ rulesIssue: this.issue(error) });
|
|
8038
|
-
} finally {
|
|
8039
|
-
if (this.live(generation) && sequence === this.requestSequence) this.publish({ reading: false, revalidating: false });
|
|
8040
|
-
}
|
|
8041
|
-
this.schedule();
|
|
8042
|
-
}
|
|
8043
|
-
edit(generation, patch) {
|
|
8044
|
-
if (!this.canEdit(generation) || this.state.draft === null) return;
|
|
8045
|
-
const draft2 = { ...this.state.draft, ...patch };
|
|
8046
|
-
this.publish({ draft: draft2, notice: null });
|
|
8047
|
-
this.publish({ dirty: draft2.editor !== null || permissionChanges(this.state) !== null });
|
|
8048
|
-
}
|
|
8049
|
-
stageRule(generation) {
|
|
8050
|
-
const draft2 = this.state.draft, editor = draft2?.editor;
|
|
8051
|
-
if (editor == null || !editor.id || editor.id.length > 256 || editor.id.includes("\0")) return;
|
|
8052
|
-
const match = editor.match;
|
|
8053
|
-
if (match.kind === "outside-read" && !match.path || match.kind === "shell" && (!match.executable || !match.command || !match.workingDirectory)) return;
|
|
8054
|
-
this.edit(generation, { upsert: [...draft2.upsert.filter((row) => row.id !== editor.id), structuredClone(editor)], revoke: draft2.revoke.filter((id2) => id2 !== editor.id), editor: null });
|
|
8055
|
-
}
|
|
8056
|
-
stageRevoke(generation, id2) {
|
|
8057
|
-
const draft2 = this.state.draft;
|
|
8058
|
-
if (draft2 === null || !this.state.base?.policy.rules.some((rule) => rule.id === id2)) return;
|
|
8059
|
-
this.edit(generation, { upsert: draft2.upsert.filter((row) => row.id !== id2), revoke: [.../* @__PURE__ */ new Set([...draft2.revoke, id2])], editor: draft2.editor?.id === id2 ? null : draft2.editor });
|
|
8060
|
-
}
|
|
8061
|
-
begin(busy) {
|
|
8062
|
-
this.cancel();
|
|
8063
|
-
this.publish({ busy, reading: false, revalidating: false, notice: null });
|
|
8064
|
-
return { signal: this.request.signal, id: this.state.sessionId };
|
|
8065
|
-
}
|
|
8066
|
-
async save(generation) {
|
|
8067
|
-
const request = permissionChanges(this.state);
|
|
8068
|
-
if (!this.canSave(generation) || request === null) return;
|
|
8069
|
-
const current = this.begin("save");
|
|
8070
|
-
try {
|
|
8071
|
-
const result = await this.invoke("saveRules", [current.id, request], current.signal);
|
|
8072
|
-
if (this.live(generation)) {
|
|
8073
|
-
this.observed = true;
|
|
8074
|
-
this.publish({ rules: result, base: result.snapshot, draft: draftOf(result.snapshot.policy), dirty: false, rulesIssue: null, notice: "saved" });
|
|
8075
|
-
}
|
|
8076
|
-
} catch (error) {
|
|
8077
|
-
if (this.live(generation)) this.publish({ rulesIssue: this.issue(error) });
|
|
8078
|
-
} finally {
|
|
8079
|
-
if (this.live(generation)) {
|
|
8080
|
-
this.publish({ busy: null });
|
|
8081
|
-
this.schedule();
|
|
8082
|
-
}
|
|
8083
|
-
}
|
|
8084
|
-
}
|
|
8085
|
-
};
|
|
8086
|
-
|
|
8087
8146
|
// src/client/RoleToolView.tsx
|
|
8088
8147
|
var import_dsh_client_ui_primitives10 = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
8089
8148
|
|
|
@@ -8959,26 +9018,7 @@ async function apply(ctx) {
|
|
|
8959
9018
|
});
|
|
8960
9019
|
void ctx.inject(["uiSession", "sessions"], (sessionCtx) => {
|
|
8961
9020
|
const source = sessionCtx.uiSession.adapter.current, sessions = sessionCtx.sessions;
|
|
8962
|
-
|
|
8963
|
-
const update = () => {
|
|
8964
|
-
const id2 = source.getSnapshot().key, binding = id2 === void 0 ? void 0 : sessions.binding(id2);
|
|
8965
|
-
if (binding !== observed) {
|
|
8966
|
-
stop?.();
|
|
8967
|
-
observed = binding;
|
|
8968
|
-
stop = binding?.session.subscribe(update);
|
|
8969
|
-
}
|
|
8970
|
-
const snapshot4 = binding?.session.getSnapshot(), catalog = sessions.list.getSnapshot(), summary = id2 === void 0 ? void 0 : catalog.byId[id2];
|
|
8971
|
-
const child2 = snapshot4?.subagent != null || summary?.origin === "subagent" || summary?.parentId !== void 0;
|
|
8972
|
-
const root = id2 !== void 0 && binding?.sessionId === id2 && snapshot4?.sessionId === id2 && snapshot4.openState === "open" && !snapshot4.removed && catalog.ids.includes(id2) && summary !== void 0 && !child2;
|
|
8973
|
-
permissions.bindScope(id2 ?? null, binding ?? null, child2 ? "child" : root ? "root" : "unknown");
|
|
8974
|
-
};
|
|
8975
|
-
update();
|
|
8976
|
-
sessionCtx.effect(() => source.subscribe(update));
|
|
8977
|
-
sessionCtx.effect(() => sessions.list.subscribe(update));
|
|
8978
|
-
sessionCtx.effect(() => () => {
|
|
8979
|
-
stop?.();
|
|
8980
|
-
permissions.bindScope(null, null, "unknown");
|
|
8981
|
-
}, "dsmm: permission native session withdrawal");
|
|
9021
|
+
sessionCtx.effect(() => bindPermissionSession(source, sessions, permissions), "dsmm: permission native session withdrawal");
|
|
8982
9022
|
});
|
|
8983
9023
|
let deployment = null;
|
|
8984
9024
|
let profiles = null;
|