@deepseek-ai/dsh-permission-presets 0.2.2-alpha.3 → 0.2.2-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -427,7 +427,7 @@ export const TYPERT = {
427
427
  },
428
428
  {
429
429
  "name": "MessageSourceMap",
430
- "declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'tool-registry': { kind: 'tool-registry'; };\n 'action-cards': { kind: 'action-cards'; through: SessionSeq; } & ContextFormed;\n 'runtime-context': { kind: 'runtime-context'; } & ContextFormed;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; principal?: Principal; };\n 'working-directory': { kind: 'working-directory'; };\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'skill-invocation': SkillInvocationSource;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'compact-checkpoint': CompactionCheckpointSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n 'user-question-reply': { kind: 'user-question-reply'; callId: ToolCallId; outcome: 'answered'; };\n 'team-message': TeamMessageSource;\n goal: GoalMessageSource;\n 'plan-mode': { kind: 'plan-mode'; } & ContextFormed;\n schedule: { kind: 'schedule'; } & ContextFormed;\n 'session-reference': SessionReferenceSource;\n webhook: { readonly kind: 'webhook'; readonly provider: string; readonly source: WebhookSourceId; readonly deliveryId: WebhookDeliveryId; readonly ruleId: WebhookRuleId; readonly form: 'notice'; readonly summary: string; };\n}"
430
+ "declaration": "export interface MessageSourceMap {\n user: { kind: 'user'; };\n model: ModelMessageSource;\n tool: ToolMessageSource;\n 'system-prompt': SystemPromptMessageSource;\n 'model-selection': { kind: 'model-selection'; } & ContextFormed;\n 'tool-registry': { kind: 'tool-registry'; };\n 'action-cards': { kind: 'action-cards'; through: SessionSeq; } & ContextFormed;\n 'runtime-context': { kind: 'runtime-context'; } & ContextFormed;\n 'team-message': TeamMessageSource;\n 'working-directory': { kind: 'working-directory'; };\n 'user-approval': { kind: 'user-approval'; } & ContextFormed;\n 'agent-message': AgentMessageSource;\n 'subagent-settled': SubagentSettledMessageSource;\n 'user-rpc': { kind: 'user'; rpcId: SessionRequestId; clientTimeZone?: string; principal?: Principal; };\n 'retry-rpc': { kind: 'retry'; rpcId: SessionRequestId; clientTimeZone?: string; principal?: Principal; };\n 'skill-invocation': SkillInvocationSource;\n 'ptc-mode': { kind: 'ptc-mode'; };\n 'compact-checkpoint': CompactionCheckpointSource;\n 'cordis-host-runner': { kind: 'cordis-host-runner'; };\n 'user-question-reply': { kind: 'user-question-reply'; callId: ToolCallId; outcome: 'answered'; };\n goal: GoalMessageSource;\n 'plan-mode': { kind: 'plan-mode'; } & ContextFormed;\n schedule: { kind: 'schedule'; } & ContextFormed;\n 'session-reference': SessionReferenceSource;\n webhook: { readonly kind: 'webhook'; readonly provider: string; readonly source: WebhookSourceId; readonly deliveryId: WebhookDeliveryId; readonly ruleId: WebhookRuleId; readonly form: 'notice'; readonly summary: string; };\n}"
431
431
  },
432
432
  {
433
433
  "name": "ModelMessageSource",
@@ -531,15 +531,19 @@ export const TYPERT = {
531
531
  },
532
532
  {
533
533
  "name": "Session",
534
- "declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
534
+ "declaration": "export class Session {\n get surface(): SessionSurface;\n readonly header: SessionHeader;\n readonly inheritedEventCount: SessionLogOffset;\n get id(): SessionId;\n readonly firstLiveSeq: SessionLogOffset;\n readonly firstLifecycleSeq: SessionLogOffset;\n eventAt(seq: SessionSeq): SessionEvent | undefined;\n snapshotEvents(fromSeq: SessionLogOffset = SessionLogOffset(0), toSeqExclusive: SessionLogOffset = this.seq): readonly SessionEvent[];\n ownEvents(): readonly SessionEvent[];\n isOwnSeq(seq: SessionSeq): boolean;\n get seq(): SessionLogOffset;\n get currentBatchPublication(): SessionEvent | undefined;\n append(inputs: readonly SessionEventInput[]): readonly SessionEvent[];\n append<T extends SessionEventType>(type: T, data: SessionEventMap[T], ...opts: T extends SurfaceEventType ? [opts: SurfaceIntent<T>] : []): SessionEvent<T>;\n requestHeader(): EpochHeader | undefined;\n requestContext(): RequestContext | undefined;\n toolHistory(): ToolHistory;\n deriveMessages(): Message[];\n deriveEventMessage(event: SessionEvent): Message | null;\n}"
535
535
  },
536
536
  {
537
537
  "name": "SessionEvent",
538
538
  "declaration": "export type SessionEvent<T extends SessionEventType = SessionEventType> = { [K in SessionEventType]: { type: K; seq: SessionSeq; time: number; data: SessionEventMap[K]; ignorable?: true; } & (K extends SurfaceEventType ? SurfaceIntent<K> : { surfaceOp?: never; sourceEventSeqs?: never; }) }[T];"
539
539
  },
540
+ {
541
+ "name": "SessionEventInput",
542
+ "declaration": "export type SessionEventInput = { [K in SessionEventType]: readonly [type: K, data: SessionEventMap[K], ...opts: K extends SurfaceEventType ? [opts: SurfaceIntent<K>] : []] }[SessionEventType];"
543
+ },
540
544
  {
541
545
  "name": "SessionEventMap",
542
- "declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'model/selection': ModelSelection;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'agent-preset/selected': { agentPreset: string; };\n 'job/registered': JobRegisteredData;\n 'job/settled': JobSettledData;\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'working-directory/change': { cwd: string; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'permission/preset': { preset: string; };\n 'subagent/descriptor': SubagentDescriptorData;\n 'subagent/catalog': SubagentCatalogEvent;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'feedback/record': FeedbackRecord;\n 'llm/retry': LlmRetryEventData;\n 'llm/retry-started': LlmRetryStartedEventData;\n 'team/member': { version: 2; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 2; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 2; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 2; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'plan/mode': { active: boolean; };\n 'schedule/change': ScheduleChange;\n 'session-log-deepseek/delivery-accepted': { sessionId: import('@deepseek-ai/dsh-session/types').SessionId; sessionFormatVersion?: number; throughSeq: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'subagent/model-selection-policy': { allowedModels: AllowedModelRoute[]; };\n 'workspace/changes': { turn: number; };\n}"
546
+ "declaration": "export interface SessionEventMap {\n 'turn/start': { turn: number; };\n 'turn/end': { turn: number; reason: TurnEndReason; };\n 'step/start': { turn: number; step: number; };\n 'step/end': { turn: number; step: number; };\n 'user/message': UserMessage;\n 'developer/message': { turn: number; step: number; message: DeveloperMessage; headerSeq?: SessionSeq; };\n 'system/message': { turn: number; step: number; message: SystemMessage; };\n 'assistant/message': { turn: number; step: number; message: AssistantMessage; stream: AssistantStreamRecord[]; usage?: TokenUsage; interrupted?: true; };\n 'assistant/attempt': { turn: number; step: number; stream: AssistantStreamRecord[]; };\n 'tool/call': { turn: number; step: number; callId: ToolCallId; name: string; arguments: string; };\n 'tool/result': { turn: number; step: number; message: ToolResultMessage; error?: { name: string; code: string; reason?: string; }; meta?: JsonValue; };\n 'request/header': { header: EpochHeader; reason: RequestHeaderReason; startsSeries?: true; };\n 'request/context': RequestContext;\n 'session/end-seed': { inherited?: true; };\n 'agent/inbox/spliced': { target: InboxTarget; start: number; removedCount?: number; inserted: UserMessage[]; outcome?: 'canceled'; };\n 'model/selection': ModelSelection;\n 'sandbox/mode': { mode: SandboxMode; source?: 'delegation'; };\n 'agent-preset/selected': { agentPreset: string; };\n 'team/mode': { enabled: boolean; };\n 'team/member': { version: 2; teamId: TeamId; member: TeamMemberSnapshot; };\n 'team/task': { version: 2; teamId: TeamId; task: TeamTaskSnapshot; };\n 'team/message/queued': { version: 2; teamId: TeamId; message: TeamMessageSnapshot; };\n 'team/message/delivered': { version: 2; teamId: TeamId; messageId: TeamMessageId; targetId: SessionId; };\n 'working-directory/change': { cwd: string; };\n 'image/offload': { targets: ImageOffloadTarget[]; };\n 'session/title': SessionTitleEventData;\n 'todo/write': { todos: TodoItem[]; };\n 'approval/asked': { id: ApprovalRequestId; toolName: string; callId?: ToolCallId; reason?: string; };\n 'approval/decided': { id: ApprovalRequestId; outcome: ApprovalOutcome; };\n 'approval/policy': { policy: ApprovalPolicy; source?: 'delegation'; };\n 'command/run': { commandId: CommandId; name: string; args?: string; source: CommandSource; };\n 'command/done': { commandId: CommandId; kind: 'success' | 'error'; text?: string; sourceEventSeq?: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'permission/preset': { preset: string; };\n 'subagent/descriptor': SubagentDescriptorData;\n 'subagent/catalog': SubagentCatalogEvent;\n 'job/registered': JobRegisteredData;\n 'job/settled': JobSettledData;\n 'compaction/start': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; };\n 'compaction/summary': { compactionId: CompactionId; sourceCommandId?: CommandId; summary: ContentBlock[]; shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; provider: string; model: string; maxTokens?: number; usage?: TokenUsage; } & ({ rawOutput: ContentBlock[]; llmStreamCall: true; } | { rawOutput?: ContentBlock[]; llmStreamCall?: never; });\n 'compaction/end': { compactionId: CompactionId; sourceCommandId?: CommandId; turn: number | null; error?: string; };\n 'compaction/prune': { shadowedRange: { start: SessionSeq; end: SessionSeq; }; shadowedSeqs: SessionSeq[]; shadowedTokenCount: number; };\n 'tool/ptc-dispatch-start': PtcDispatchStartEventData;\n 'tool/ptc-dispatch': PtcDispatchEventData;\n 'feedback/record': FeedbackRecord;\n 'llm/retry': LlmRetryEventData;\n 'llm/retry-started': LlmRetryStartedEventData;\n 'goal/change': GoalChangeMeta;\n 'feedback/message-put': MessageFeedbackPut;\n 'feedback/message-delete': MessageFeedbackDelete;\n 'plan/mode': { active: boolean; };\n 'schedule/change': ScheduleChange;\n 'session-log-deepseek/delivery-accepted': { sessionId: import('@deepseek-ai/dsh-session/types').SessionId; sessionFormatVersion?: number; throughSeq: import('@deepseek-ai/dsh-session/types').SessionSeq; };\n 'subagent/model-selection-policy': { allowedModels: AllowedModelRoute[]; };\n 'workspace/changes': { turn: number; };\n}"
543
547
  },
544
548
  {
545
549
  "name": "SessionEventType",
@@ -603,7 +607,7 @@ export const TYPERT = {
603
607
  },
604
608
  {
605
609
  "name": "SubagentCatalogEvent",
606
- "declaration": "export type SubagentCatalogEvent = { readonly childId: SessionId; readonly childCreatedAt: number; } & (({ readonly version: 0; } & KnownCatalogMode) | ({ readonly version: 1; } & (KnownCatalogMode | { readonly mode: 'unknown'; readonly label?: string; })) | { readonly version: 2; readonly mode: 'external'; readonly label?: string; });"
610
+ "declaration": "export type SubagentCatalogEvent = { readonly childId: SessionId; readonly childCreatedAt: number; } & (({ readonly version: 0; } & KnownCatalogMode) | ({ readonly version: 1; } & (KnownCatalogMode | { readonly mode: 'unknown'; readonly label?: string; })) | { readonly version: 2; readonly mode: 'external'; readonly label?: string; } | ({ readonly version: 3; readonly name: string; } & ({ readonly mode: 'continuable'; readonly label: string; } | { readonly mode: 'external'; readonly label?: string; })));"
607
611
  },
608
612
  {
609
613
  "name": "SubagentDescriptorBase",
@@ -613,9 +617,21 @@ export const TYPERT = {
613
617
  "name": "SubagentDescriptorData",
614
618
  "declaration": "export type SubagentDescriptorData = OneShotSubagentDescriptorData | ContinuableSubagentDescriptorData;"
615
619
  },
620
+ {
621
+ "name": "SubagentResult",
622
+ "declaration": "export interface SubagentResult {\n readonly output: readonly ContentBlock[];\n readonly structured?: unknown;\n readonly diagnostic?: string;\n readonly stopReason: SubagentStopReason;\n}"
623
+ },
616
624
  {
617
625
  "name": "SubagentSettledMessageSource",
618
- "declaration": "export interface SubagentSettledMessageSource {\n readonly kind: 'subagent-settled';\n readonly form: 'notice';\n readonly summary: string;\n readonly senderSessionId: SessionId;\n}"
626
+ "declaration": "export interface SubagentSettledMessageSource {\n readonly kind: 'subagent-settled';\n readonly form: 'notice';\n readonly summary: string;\n readonly stopReason?: SubagentResult['stopReason'];\n readonly senderSessionId: SessionId;\n}"
627
+ },
628
+ {
629
+ "name": "SubagentStopReason",
630
+ "declaration": "export type SubagentStopReason = SubagentStopReasonMap[keyof SubagentStopReasonMap];"
631
+ },
632
+ {
633
+ "name": "SubagentStopReasonMap",
634
+ "declaration": "export interface SubagentStopReasonMap {\n completed: 'completed';\n aborted: 'aborted';\n error: 'error';\n 'max-tokens': 'max-tokens';\n refusal: 'refusal';\n}"
619
635
  },
620
636
  {
621
637
  "name": "SurfaceEventType",
@@ -671,7 +687,7 @@ export const TYPERT = {
671
687
  },
672
688
  {
673
689
  "name": "TeamTaskSnapshot",
674
- "declaration": "export interface TeamTaskSnapshot {\n readonly id: TeamTaskId;\n readonly revision: number;\n readonly subject: string;\n readonly description: string;\n readonly status: TeamTaskStatus;\n readonly ownerId?: SessionId;\n readonly blockedBy: TeamTaskId[];\n readonly writeScopes: string[];\n}"
690
+ "declaration": "export interface TeamTaskSnapshot {\n readonly id: TeamTaskId;\n readonly revision: number;\n readonly subject: string;\n readonly description: string;\n readonly status: TeamTaskStatus;\n readonly ownerId?: SessionId;\n readonly ownerName?: string;\n readonly blockedBy: TeamTaskId[];\n readonly writeScopes: string[];\n}"
675
691
  },
676
692
  {
677
693
  "name": "TeamTaskStatus",
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typert.remote-client.d.ts","names":["catalog"],"sources":["../src/index.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;IAmSEA,O;;;IAAAA,2B","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,mBAAmB,YAAY,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAEnD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAExC,OAAO,EAAU,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AAC9E,OAAO,KAAK,EAAE,OAAO,EAAgB,MAAM,0BAA0B,CAAA;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAK3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,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B;;;;;;WAMG;QACH,WAAW,EAAE,mBAAmB,CAAA;KACjC;CACF"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@deepseek-ai/dsh-permission-presets",
3
3
  "description": "User-facing permission presets (ctx.permissionPresets) for the DeepSeek Harness: one product-level Permissions select bundling the sandbox-mode and approval-policy knobs, written through to their own session events",
4
- "version": "0.2.2-alpha.3",
4
+ "version": "0.2.2-rc.2",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -43,40 +43,44 @@
43
43
  "lib/index.js",
44
44
  "lib/types/**/*.js",
45
45
  "lib/types/**/*.d.ts",
46
+ "lib/types/**/*.d.ts.map",
47
+ "lib/**/*.js.map",
46
48
  "lib/typert.host.js",
47
49
  "lib/typert.host.d.ts",
48
50
  "lib/typert.remote-client.js",
49
- "lib/typert.remote-client.d.ts"
51
+ "lib/typert.remote-client.d.ts",
52
+ "lib/typert.remote-client.d.ts.map",
53
+ "src"
50
54
  ],
51
55
  "license": "MIT",
52
56
  "peerDependencies": {
53
- "@deepseek-ai/dsh-agent": "0.2.2-alpha.3",
54
- "@deepseek-ai/dsh-shell": "0.2.2-alpha.3",
55
- "@deepseek-ai/dsh-commands": "0.2.2-alpha.3",
56
- "@deepseek-ai/dsh-sandbox": "0.2.2-alpha.3",
57
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-alpha.3",
58
- "@deepseek-ai/dsh-session": "0.2.2-alpha.3",
59
- "@deepseek-ai/dsh-session-projection": "0.2.2-alpha.3",
60
- "@deepseek-ai/dsh-typert-protocol": "0.2.2-alpha.3",
61
- "@deepseek-ai/dsh-user-approval": "0.2.2-alpha.3",
62
- "@deepseek-ai/cordis": "~4.0.6-alpha.2"
57
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
58
+ "@deepseek-ai/dsh-shell": "0.2.2-rc.2",
59
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.2",
60
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
61
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
62
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
63
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
64
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.2",
65
+ "@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
66
+ "@deepseek-ai/cordis": "~4.1.0"
63
67
  },
64
68
  "dependencies": {
65
- "@deepseek-ai/schemastery": "~3.18.6-alpha.2",
66
- "zod": "4.4.3"
69
+ "@deepseek-ai/schemastery": "~3.19.0",
70
+ "zod": "4.6.6"
67
71
  },
68
72
  "devDependencies": {
69
- "@deepseek-ai/dsh-agent": "0.2.2-alpha.3",
70
- "@deepseek-ai/dsh-shell": "0.2.2-alpha.3",
71
- "@deepseek-ai/dsh-commands": "0.2.2-alpha.3",
72
- "@deepseek-ai/dsh-sandbox": "0.2.2-alpha.3",
73
- "@deepseek-ai/dsh-sandbox-policy": "0.2.2-alpha.3",
74
- "@deepseek-ai/dsh-session": "0.2.2-alpha.3",
75
- "@deepseek-ai/dsh-session-projection": "0.2.2-alpha.3",
76
- "@deepseek-ai/dsh-typert-protocol": "0.2.2-alpha.3",
77
- "@deepseek-ai/dsh-user-approval": "0.2.2-alpha.3",
78
- "@deepseek-ai/cordis": "~4.0.6-alpha.2",
79
- "@deepseek-ai/dsh-settings": "0.2.2-alpha.3",
80
- "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-alpha.3"
73
+ "@deepseek-ai/dsh-agent": "0.2.2-rc.2",
74
+ "@deepseek-ai/dsh-shell": "0.2.2-rc.2",
75
+ "@deepseek-ai/dsh-commands": "0.2.2-rc.2",
76
+ "@deepseek-ai/dsh-sandbox": "0.2.2-rc.2",
77
+ "@deepseek-ai/dsh-sandbox-policy": "0.2.2-rc.2",
78
+ "@deepseek-ai/dsh-session": "0.2.2-rc.2",
79
+ "@deepseek-ai/dsh-session-projection": "0.2.2-rc.2",
80
+ "@deepseek-ai/dsh-typert-protocol": "0.2.2-rc.2",
81
+ "@deepseek-ai/dsh-user-approval": "0.2.2-rc.2",
82
+ "@deepseek-ai/cordis": "~4.1.0",
83
+ "@deepseek-ai/dsh-settings": "0.2.2-rc.2",
84
+ "@deepseek-ai/dsh-agent-loop-testkit": "0.2.2-rc.2"
81
85
  }
82
86
  }
package/src/client.ts ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Client-namespace projection of the permission domain: a pure re-export of
3
+ * the package's types outlet. Client code imports ONLY the client namespace
4
+ * (repo discipline), so `./client` projects the same single-source content
5
+ * `./types` serves to host consumers — zero duplication.
6
+ *
7
+ * @module @deepseek-ai/dsh-permission-presets/client
8
+ */
9
+
10
+ export type * from './types.ts'
package/src/index.ts ADDED
@@ -0,0 +1,482 @@
1
+ /**
2
+ * User-facing permission presets over the independent sandbox-mode and
3
+ * approval-policy knobs. A switch records the selected preset, then writes
4
+ * changed knobs through their canonical setters. Execution, prompt narration,
5
+ * and replay keep reading their knob folds. The preset event preserves user
6
+ * intent when two presets share a bundle. The Auto review integration may
7
+ * publish one fixed, current-session-only preset with a synchronous admission
8
+ * check; settings defaults remain limited to the configured table. The read
9
+ * side exposes a process catalog plus the current-value-only `permissions`
10
+ * Session projection; the write side ships as the `/permission` command.
11
+ *
12
+ * @module dsh-permission-presets
13
+ */
14
+ import type {} from '@deepseek-ai/dsh-settings'
15
+ import type {} from '@deepseek-ai/dsh-agent'
16
+
17
+ import type { Volatile } from '@deepseek-ai/cordis'
18
+
19
+ import { Context, Service } from '@deepseek-ai/cordis'
20
+ import { CommandDefinitionId } from '@deepseek-ai/dsh-commands/brand'
21
+ import z from '@deepseek-ai/schemastery'
22
+ import { z as zod } from 'zod'
23
+ import { Remote, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol'
24
+ import type { Session, SessionEvent } from '@deepseek-ai/dsh-session'
25
+ import type { SandboxMode } from '@deepseek-ai/dsh-sandbox'
26
+ import { SANDBOX_MODES, setSandboxMode } from '@deepseek-ai/dsh-sandbox-policy'
27
+ // Side-effect type import: declaration-merges `ctx.shell` (the capability fact
28
+ // `sandboxMode` this service reads), without a value dependency on the seam.
29
+ import type {} from '@deepseek-ai/dsh-shell'
30
+ import type { ApprovalPolicy } from '@deepseek-ai/dsh-user-approval'
31
+ import { APPROVAL_POLICIES, setApprovalPolicy } from '@deepseek-ai/dsh-user-approval'
32
+ // Type-only: resolves the required projection service and optional settings/command children.
33
+ import type { ProjectionHandle } from '@deepseek-ai/dsh-session-projection'
34
+ import type {} from '@deepseek-ai/dsh-commands'
35
+ import type { PermissionCatalog, PermissionSelection, PresetOption } from './types.ts'
36
+
37
+ export type * from './types.ts'
38
+
39
+ declare module '@deepseek-ai/cordis' {
40
+ interface Context {
41
+ permissionPresets: PermissionPresetService
42
+ }
43
+ }
44
+
45
+ declare module '@deepseek-ai/dsh-session/types' {
46
+ interface SessionEventMap {
47
+ /**
48
+ * Records the selected preset as durable, log-only user intent. The knob
49
+ * events follow in the same turn and control execution; this event stays
50
+ * out of the model transcript and lets the permission projection unit
51
+ * preserve a selection when bundles match.
52
+ */
53
+ 'permission/preset': { preset: string }
54
+ }
55
+ }
56
+
57
+ /** One preset's sandbox/approval bundle and optional client presentation. */
58
+ export interface PresetSpec {
59
+ /** The `sandbox/mode` value the preset writes through. */
60
+ sandbox: SandboxMode
61
+ /** The `approval/policy` value the preset writes through. */
62
+ approval: ApprovalPolicy
63
+ /** The display label a client shows for this preset; the raw table key when omitted. */
64
+ name?: string
65
+ /** One user-facing sentence on what the preset means; omitted when not configured. */
66
+ description?: string
67
+ }
68
+
69
+ /**
70
+ * Returned when effective knob values match no available preset. Clients may
71
+ * show it as the current value, but it is never a switch target or event payload.
72
+ */
73
+ export const CUSTOM_PRESET = 'custom'
74
+
75
+ /** Canonical identity of the experimental per-call review preset. */
76
+ export const AUTO_PRESET = 'auto'
77
+
78
+ /**
79
+ * Fixed execution bundle for the live Auto integration. `ask` routes reviewer
80
+ * denials to the user; a stored Auto identity also matches `never`, which a
81
+ * delegated child pins so its reviewer denials stay final.
82
+ */
83
+ const AUTO_PRESET_SPEC: PresetSpec = {
84
+ sandbox: 'danger-full-access',
85
+ approval: 'ask',
86
+ }
87
+
88
+ /**
89
+ * The projection unit's knob state: the last seen value of each knob event,
90
+ * null before an override (composition defaults apply at view time).
91
+ */
92
+ export interface KnobState {
93
+ /** Last `permission/preset` payload, or null. */
94
+ preset: string | null
95
+ /** Last `sandbox/mode` payload, or null. */
96
+ sandbox: SandboxMode | null
97
+ /** Last `approval/policy` payload, or null. */
98
+ approval: ApprovalPolicy | null
99
+ }
100
+
101
+ /** Projection state for permission overrides and constructor-seed status. */
102
+ interface PermissionProjectionState extends KnobState {
103
+ /** Whether the log contains a constructor-seed boundary. */
104
+ seeded: boolean
105
+ }
106
+
107
+ const permissionStateSchema: zod.ZodType<PermissionProjectionState> = zod.object({
108
+ preset: zod.string().nullable(),
109
+ sandbox: zod.union([
110
+ zod.literal('read-only'),
111
+ zod.literal('workspace-write'),
112
+ zod.literal('danger-full-access'),
113
+ ]).nullable(),
114
+ approval: zod.union([zod.literal('ask'), zod.literal('never')]).nullable(),
115
+ seeded: zod.boolean(),
116
+ }).strict()
117
+
118
+ /** State for the empty log: every knob at its composition default. */
119
+ const EMPTY_KNOBS: KnobState = { preset: null, sandbox: null, approval: null }
120
+
121
+ /**
122
+ * One-event permission-state transition (the projection unit's `apply`). Unrelated
123
+ * events return the same reference — the registry's change gate.
124
+ * @param state - the folded knob state before `event`.
125
+ * @param event - one committed session event.
126
+ * @returns the next state; the same reference when the event is unrelated.
127
+ */
128
+ function applyPermissionEvent(
129
+ state: PermissionProjectionState,
130
+ event: SessionEvent,
131
+ ): PermissionProjectionState {
132
+ switch (event.type) {
133
+ case 'permission/preset':
134
+ return { ...state, preset: event.data.preset }
135
+ case 'sandbox/mode':
136
+ return { ...state, sandbox: event.data.mode }
137
+ case 'approval/policy':
138
+ return { ...state, approval: event.data.policy }
139
+ case 'session/end-seed':
140
+ return { ...state, seeded: true }
141
+ default:
142
+ return state
143
+ }
144
+ }
145
+
146
+ /** User setting resolved when a new session receives its initial permission. */
147
+ export interface PermissionSettings {
148
+ /** Preset pinned into a newly created session. */
149
+ defaultPreset: string
150
+ }
151
+
152
+ /** The {@link PermissionPresetService} config: preset table and composition default. */
153
+ export interface Config {
154
+ /**
155
+ * The preset table: name → knob bundle. Defaults to `workspace-write`
156
+ * (workspace-write + ask) and `danger-full-access` (danger-full-access +
157
+ * never). The names `custom` and `auto` are reserved for derived state and
158
+ * the Auto review integration respectively.
159
+ */
160
+ presets: Record<string, PresetSpec>
161
+ /**
162
+ * Default for new sessions. When omitted, the preset matching the composed
163
+ * sandbox and approval defaults is used.
164
+ */
165
+ defaultPreset: Volatile<string | undefined>
166
+ }
167
+
168
+ /**
169
+ * Owns the deployment's configured permission presets, the fixed Auto
170
+ * integration hook, and their write path. Requires a confining `ctx.shell` executor and
171
+ * `ctx.approval`; unmatched knob values are reported as
172
+ * {@link CUSTOM_PRESET}, not an error.
173
+ */
174
+ export class PermissionPresetService extends TypertRemoteService {
175
+ // Inline schema call: the config catalog walks `static Config` statically.
176
+ static Config = z.object({
177
+ presets: z.dict(z.object({
178
+ sandbox: z.union(SANDBOX_MODES as SandboxMode[]).required(),
179
+ approval: z.union(APPROVAL_POLICIES as ApprovalPolicy[]).required(),
180
+ name: z.string(),
181
+ description: z.string(),
182
+ })).default({
183
+ 'workspace-write': {
184
+ sandbox: 'workspace-write', approval: 'ask',
185
+ name: 'workspace-write', description: 'Write inside the workspace and permitted temporary directories; wider retries require approval.',
186
+ },
187
+ 'danger-full-access': {
188
+ sandbox: 'danger-full-access', approval: 'never',
189
+ name: 'danger-full-access', description: 'Full file access without approval prompts.',
190
+ },
191
+ }),
192
+ defaultPreset: z.string().volatile(),
193
+ })
194
+
195
+ static inject = ['shell', 'approval', 'sessions', 'agents', 'sessionProjections']
196
+
197
+ private readonly presets: Record<string, PresetSpec>
198
+ private autoAdmit: (() => void) | undefined
199
+ private defaultSettings: () => PermissionSettings
200
+
201
+ private permissionProjectionHandle: ProjectionHandle<PermissionProjectionState> | undefined
202
+
203
+ constructor(ctx: Context, config: Config) {
204
+ super(ctx, 'permissionPresets')
205
+
206
+ ctx.inject(['settings'], (child) => { child.effect(() => child.settings.configure({ auto: false }, ctx.fiber)) })
207
+ // The schema defaulted the table — the cast records that runtime fact.
208
+ this.presets = config.presets
209
+ if (CUSTOM_PRESET in this.presets) {
210
+ throw new Error(`permission: "${CUSTOM_PRESET}" is reserved for the derived not-a-preset state and cannot name a table entry`)
211
+ }
212
+ if (AUTO_PRESET in this.presets) {
213
+ throw new Error(`permission: "${AUTO_PRESET}" is reserved and cannot name a configured preset`)
214
+ }
215
+ if (ctx.shell.sandboxMode === undefined) {
216
+ throw new Error('permission: the mounted bash executor does not confine (no sandboxMode) — presets bundle a sandbox mode, so composing this plugin over an unconfined executor is a misconfiguration')
217
+ }
218
+ const inferredDefault = this.derive(EMPTY_KNOBS)
219
+ const defaultPreset = config.defaultPreset.get() ?? inferredDefault
220
+ if (defaultPreset === CUSTOM_PRESET) {
221
+ throw new Error('permission: composed sandbox and approval defaults match no preset; configure defaultPreset explicitly')
222
+ }
223
+ this.resolve(defaultPreset)
224
+ this.defaultSettings = () => {
225
+ const defaultPreset = config.defaultPreset.get() ?? inferredDefault
226
+ if (!Object.hasOwn(this.presets, defaultPreset)) throw new Error(`permission: unknown default preset "${defaultPreset}"`)
227
+ return { defaultPreset }
228
+ }
229
+ }
230
+
231
+ protected async [Service.init](): Promise<void> {
232
+ const ctx = this.ctx
233
+ ctx.on('agent/created', ({ agent }) => {
234
+ this.pinInitialPermission(agent.session)
235
+ }, { prepend: true })
236
+ const selectionSchema = zod.object({
237
+ currentValue: zod.string().min(1),
238
+ }) as zod.ZodType<PermissionSelection>
239
+ this.permissionProjectionHandle = await ctx.sessionProjections.register({
240
+ key: 'permissions',
241
+ stateVersion: 2,
242
+ stateSchema: permissionStateSchema,
243
+ init: () => ({ ...EMPTY_KNOBS, seeded: false }),
244
+ apply: applyPermissionEvent,
245
+ wire: { viewSchema: selectionSchema, view: state => ({ currentValue: this.derive(state) }) },
246
+ })
247
+ for (const agent of ctx.agents.list()) {
248
+ this.pinInitialPermission(agent.session)
249
+ }
250
+
251
+ // The /permission command: the one write path a web client uses (the
252
+ // popup contribution submits the picked preset as this line). The child
253
+ // activates only when a command registry is composed.
254
+ ctx.inject(['commands'], (commandCtx) => {
255
+ commandCtx.commands.register({
256
+ definitionId: CommandDefinitionId('@deepseek-ai/dsh-permission-presets'),
257
+ name: 'permission',
258
+ description: 'Switch the permission preset (sandbox mode + approval policy)',
259
+ input: { hint: '<preset>' },
260
+ // No settlement text labels its value with this command's own name: a
261
+ // surface that renders `name · text` (the web command row) would
262
+ // otherwise read `permission · Permission preset: workspace-write.`
263
+ handler: ({ agent, rawInput }) => {
264
+ const name = rawInput.trim()
265
+ if (name === '') {
266
+ return { kind: 'success', text: `current preset ${this.current(agent.session)} (available: ${this.names.join(', ')})` }
267
+ }
268
+ if (!this.names.includes(name)) {
269
+ return { kind: 'error', text: `unknown preset "${name}" (available: ${this.names.join(', ')})` }
270
+ }
271
+ this.apply(agent.session, name, (policy) => { this.ctx.approval.setPolicy(agent, policy) })
272
+ return { kind: 'success', text: `preset ${name}` }
273
+ },
274
+ })
275
+ })
276
+ }
277
+
278
+ /**
279
+ * The advertised preset names: configured entries in declaration order,
280
+ * followed by Auto while its integration is live.
281
+ * @returns every switchable preset name.
282
+ */
283
+ get names(): readonly string[] {
284
+ return [...Object.keys(this.presets), ...(this.autoAdmit === undefined ? [] : [AUTO_PRESET])]
285
+ }
286
+
287
+ /**
288
+ * Read the complete process-level catalog exposed to current-session UI.
289
+ * @returns every currently selectable preset in contribution order.
290
+ */
291
+ @Remote('catalog')
292
+ catalog(): PermissionCatalog {
293
+ return {
294
+ options: this.names.map(name => this.optionOf(name)),
295
+ defaultOptions: Object.keys(this.presets).map(name => this.optionOf(name)),
296
+ defaultPreset: this.defaultSettings().defaultPreset,
297
+ }
298
+ }
299
+
300
+ /**
301
+ * Publish the fixed current-session Auto preset for the calling
302
+ * integration's effect lifetime.
303
+ * @param admit - synchronous gate run before live Auto selection or restore.
304
+ * @returns the async effect disposer that removes Auto.
305
+ */
306
+ registerAuto(admit: () => void): () => Promise<void> {
307
+ return this.ctx.effect(() => {
308
+ if (this.autoAdmit !== undefined) throw new Error('permission: preset "auto" is already registered')
309
+ this.autoAdmit = admit
310
+ this.emitCatalogChanged()
311
+ return () => {
312
+ this.autoAdmit = undefined
313
+ this.emitCatalogChanged()
314
+ }
315
+ }, 'permissionPresets.registerAuto()')
316
+ }
317
+
318
+ /**
319
+ * The preset currently selected as the default for future sessions.
320
+ * @returns the resolved settings value, or the composition default without
321
+ * a mounted settings provider.
322
+ */
323
+ get defaultPreset(): string {
324
+ return this.defaultSettings().defaultPreset
325
+ }
326
+
327
+ private permissionState(session: Session): PermissionProjectionState {
328
+ if (this.permissionProjectionHandle === undefined) {
329
+ throw new Error('permission: presets are not ready; await plugin activation before creating or restoring a session')
330
+ }
331
+ return this.permissionProjectionHandle.stateOf(session)
332
+ }
333
+
334
+ /**
335
+ * Resolve the preset matching the effective knob values. A still-matching
336
+ * last selection wins shared-bundle ties, and a still-selected Auto also
337
+ * matches the `never` approval policy; otherwise the first configured
338
+ * match wins. Returns
339
+ * {@link CUSTOM_PRESET} when no available preset matches.
340
+ * @param session - the session whose knob state is read.
341
+ * @returns the effective preset name, or `custom` when nothing matches.
342
+ */
343
+ current(session: Session): string {
344
+ return this.derive(this.permissionState(session))
345
+ }
346
+
347
+ /** Resolve the preset for one folded knob state (the shared mathematics of `current` and the projection unit). */
348
+ private derive(state: KnobState): string {
349
+ const sandbox = state.sandbox ?? this.ctx.shell.sandboxMode
350
+ const approval = state.approval ?? this.ctx.approval.config.policy ?? 'ask'
351
+ const matches = (spec: PresetSpec): boolean => spec.sandbox === sandbox && spec.approval === approval
352
+ if (state.preset !== null) {
353
+ const spec = this.specOf(state.preset)
354
+ if (spec !== undefined && matches(spec)) return state.preset
355
+ if (state.preset === AUTO_PRESET && spec?.sandbox === sandbox && approval === 'never') return AUTO_PRESET
356
+ }
357
+ for (const [name, spec] of Object.entries(this.presets)) {
358
+ if (matches(spec)) return name
359
+ }
360
+ return CUSTOM_PRESET
361
+ }
362
+
363
+ /**
364
+ * Resolve an available preset's knob bundle.
365
+ * @param name - the preset name to resolve.
366
+ * @returns the configured bundle.
367
+ * @throws when `name` is neither configured nor the currently live Auto preset.
368
+ */
369
+ resolve(name: string): PresetSpec {
370
+ const spec = this.specOf(name)
371
+ if (spec === undefined) {
372
+ throw new Error(`permission: unknown preset "${name}" (known: ${this.names.join(', ')})`)
373
+ }
374
+ return spec
375
+ }
376
+
377
+ /**
378
+ * Build the client option for an available preset or {@link CUSTOM_PRESET}.
379
+ * A missing label falls back to the preset key.
380
+ * @param name - a configured preset key, live `auto`, or `custom`.
381
+ * @returns the option a client renders.
382
+ * @throws when `name` is neither a configured preset, live `auto`, nor `custom`.
383
+ */
384
+ optionOf(name: string): PresetOption {
385
+ if (name === CUSTOM_PRESET) {
386
+ return { value: CUSTOM_PRESET, name: 'Custom', description: 'Current sandbox and approval settings do not match a preset.' }
387
+ }
388
+ const spec = this.resolve(name)
389
+ return { value: name, name: spec.name ?? name, ...spec.description !== undefined ? { description: spec.description } : {} }
390
+ }
391
+
392
+ /**
393
+ * Record a changed preset, then update each changed knob through its own
394
+ * setter. Selecting the effective preset again appends nothing.
395
+ * @param session - the session the switch belongs to.
396
+ * @param name - the preset to switch to; unknown names throw.
397
+ */
398
+ set(session: Session, name: string): void {
399
+ this.apply(session, name, (policy) => { setApprovalPolicy(session, policy) })
400
+ }
401
+
402
+ /** Apply one preset through its durable identity and canonical knob setters. */
403
+ private apply(session: Session, name: string, setApproval: (policy: ApprovalPolicy) => void): void {
404
+ const spec = this.resolve(name)
405
+ if (name === AUTO_PRESET) this.autoAdmit?.()
406
+ const current = this.current(session)
407
+ const knobs = this.permissionState(session)
408
+ const updateKnobs = (): void => {
409
+ if (spec.sandbox !== (knobs.sandbox ?? this.ctx.shell.sandboxMode)) {
410
+ setSandboxMode(session, spec.sandbox)
411
+ }
412
+ if (spec.approval !== (knobs.approval ?? this.ctx.approval.config.policy ?? 'ask')) {
413
+ setApproval(spec.approval)
414
+ }
415
+ }
416
+ if (current !== name) session.append('permission/preset', { preset: name })
417
+ updateKnobs()
418
+ }
419
+
420
+ /**
421
+ * Fill every missing permission fact during Agent creation. A
422
+ * genuinely fresh session uses the current user default; seeded or partially
423
+ * initialized sessions preserve their effective knob values and only gain
424
+ * the missing durable facts. A stored Auto identity requires its live
425
+ * integration and passes its admission check before
426
+ * creation completes. Creation while the permission reader is still registering
427
+ * fails so the publishing caller can roll back.
428
+ */
429
+ private pinInitialPermission(session: Session): void {
430
+ const state = this.permissionState(session)
431
+ const { preset, sandbox, approval, seeded } = state
432
+ if (preset === AUTO_PRESET) {
433
+ if (this.autoAdmit === undefined) {
434
+ throw new Error('permission: cannot restore preset "auto" without its active integration')
435
+ }
436
+ this.autoAdmit()
437
+ }
438
+ if (preset === null && sandbox === null && approval === null && !seeded) {
439
+ const name = this.defaultPreset
440
+ const spec = this.resolve(name)
441
+ session.append('permission/preset', { preset: name })
442
+ setSandboxMode(session, spec.sandbox)
443
+ setApprovalPolicy(session, spec.approval)
444
+ return
445
+ }
446
+
447
+ const effective = this.derive(state)
448
+ if (preset === null && effective !== CUSTOM_PRESET) {
449
+ session.append('permission/preset', { preset: effective })
450
+ }
451
+ if (sandbox === null) {
452
+ setSandboxMode(session, this.ctx.shell.sandboxMode as SandboxMode)
453
+ }
454
+ if (approval === null) {
455
+ setApprovalPolicy(session, this.ctx.approval.config.policy ?? 'ask')
456
+ }
457
+ }
458
+
459
+ /** Publish a non-vetoing payload-free catalog invalidation. */
460
+ private emitCatalogChanged(): void {
461
+ for (const listener of this.ctx.events.dispatch('emit', ['permission-presets/catalog-changed']) as Array<() => unknown>) {
462
+ try {
463
+ const returned = listener()
464
+ if (returned != null && typeof (returned as PromiseLike<unknown>).then === 'function') {
465
+ void Promise.resolve(returned as PromiseLike<unknown>).catch((error: unknown) => {
466
+ this.ctx.logger.warn(`permission: catalog-changed listener failed: ${error instanceof Error ? error.message : String(error)}`)
467
+ })
468
+ }
469
+ } catch (error: unknown) {
470
+ this.ctx.logger.warn(`permission: catalog-changed listener failed: ${error instanceof Error ? error.message : String(error)}`)
471
+ }
472
+ }
473
+ }
474
+
475
+ /** Resolve one configured or currently live fixed preset without throwing. */
476
+ private specOf(name: string): PresetSpec | undefined {
477
+ return this.presets[name]
478
+ ?? (name === AUTO_PRESET && this.autoAdmit !== undefined ? AUTO_PRESET_SPEC : undefined)
479
+ }
480
+ }
481
+
482
+ export default PermissionPresetService
package/src/types.ts ADDED
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Pure types of the permission domain: the ONE home of the `permissions`
3
+ * projection-key declaration plus its payload types, free of this package's
4
+ * host-side value imports (cordis, schemastery). Two namespace projections
5
+ * serve it — the package root re-export for host consumers, `./client` (the
6
+ * browser half-entry's re-export) for client aggregates — with zero content
7
+ * duplication.
8
+ *
9
+ * @module @deepseek-ai/dsh-permission-presets/types
10
+ */
11
+
12
+ /** Presentation for an available preset or the derived `custom` current value. */
13
+ export interface PresetOption {
14
+ /** Stable option value: a configured preset key, live `auto`, or derived `custom`. */
15
+ value: string
16
+ /** The display label. */
17
+ name: string
18
+ /** One user-facing sentence on what the value means; omitted when not configured. */
19
+ description?: string
20
+ }
21
+
22
+ /**
23
+ * Process-level permission catalog. It changes with live contributions and is
24
+ * deliberately separate from Session history.
25
+ */
26
+ export interface PermissionCatalog {
27
+ /** Every currently selectable preset, in contribution order. */
28
+ options: PresetOption[]
29
+ /** Configured presets eligible as defaults for future sessions. */
30
+ defaultOptions: PresetOption[]
31
+ /** Effective default when the Config field is omitted. */
32
+ defaultPreset: string
33
+ }
34
+
35
+ /** Whole `permissions` Session projection: current durable selection only. */
36
+ export interface PermissionSelection {
37
+ /** The effective current value: a configured preset key, `auto`, or `custom`. */
38
+ currentValue: string
39
+ }
40
+
41
+ declare module '@deepseek-ai/cordis' {
42
+ interface Events {
43
+ /**
44
+ * The selectable process catalog changed. Payload-free by design:
45
+ * consumers subscribe first, then re-read the complete catalog.
46
+ * @mode emit
47
+ */
48
+ 'permission-presets/catalog-changed'(): void
49
+ }
50
+ }
51
+
52
+ declare module '@deepseek-ai/dsh-session-projection/types' {
53
+ interface SessionProjectionMap {
54
+ /**
55
+ * The session's current permission, folded from the three whole-value
56
+ * knob events (`permission/preset`, `sandbox/mode`, `approval/policy`)
57
+ * over the composition defaults. Selectable options come from the
58
+ * process-level catalog Remote. Key absence means no permission service
59
+ * is composed — clients hide the control.
60
+ */
61
+ permissions: PermissionSelection
62
+ }
63
+ }