@gotgenes/pi-permission-system 31.0.2 → 31.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/public.d.ts +15 -15
  3. package/docs/configuration.md +6 -2
  4. package/docs/cross-extension-api.md +1 -1
  5. package/docs/session-approvals.md +2 -2
  6. package/package.json +1 -1
  7. package/src/access-intent/access-intent.ts +1 -1
  8. package/src/access-intent/bash/bash-path-resolver.ts +11 -14
  9. package/src/access-intent/bash/command-enumeration.ts +6 -12
  10. package/src/access-intent/bash/msys-bash-tokens.ts +1 -1
  11. package/src/access-intent/bash/nested-execution.ts +1 -1
  12. package/src/access-intent/bash/node-text.ts +2 -2
  13. package/src/access-intent/bash/parser.ts +1 -1
  14. package/src/access-intent/bash/program.ts +4 -7
  15. package/src/access-intent/bash/redirect-analysis.ts +2 -2
  16. package/src/access-intent/bash/shell-variable-expansion.ts +1 -1
  17. package/src/access-intent/bash/sync-commands.ts +2 -5
  18. package/src/access-intent/bash/token-collection.ts +6 -9
  19. package/src/access-intent/bash/wrapper-analysis.ts +1 -1
  20. package/src/access-intent/input-normalizer.ts +2 -2
  21. package/src/access-intent/path-normalization.ts +1 -1
  22. package/src/access-intent/path-surfaces.ts +1 -1
  23. package/src/access-intent/tool-input-path.ts +1 -1
  24. package/src/access-intent/tool-kind.ts +1 -1
  25. package/src/authority/approval-escalator.ts +13 -13
  26. package/src/authority/authorizer-chain.ts +1 -1
  27. package/src/authority/authorizer-registry.ts +1 -1
  28. package/src/authority/authorizer-selection.ts +1 -1
  29. package/src/authority/authorizer.ts +9 -9
  30. package/src/authority/decision-resolution.ts +2 -5
  31. package/src/authority/denying-authorizer.ts +1 -1
  32. package/src/authority/forwarded-request-server.ts +21 -24
  33. package/src/authority/forwarder-context.ts +2 -2
  34. package/src/authority/forwarding-io.ts +14 -12
  35. package/src/authority/forwarding-liveness.ts +5 -8
  36. package/src/authority/forwarding-manager.ts +1 -1
  37. package/src/authority/inherited-registrations.ts +2 -2
  38. package/src/authority/local-user-authorizer.ts +13 -13
  39. package/src/authority/permission-dialog.ts +2 -2
  40. package/src/authority/permission-forwarding.ts +6 -3
  41. package/src/authority/permission-prompt-component.ts +12 -15
  42. package/src/authority/permission-prompt-decision.ts +2 -2
  43. package/src/authority/permission-prompter.ts +8 -8
  44. package/src/authority/subagent-context.ts +3 -3
  45. package/src/authority/subagent-detection.ts +3 -3
  46. package/src/{config-loader.ts → config/config-loader.ts} +3 -3
  47. package/src/{config-modal.ts → config/config-modal.ts} +1 -2
  48. package/src/{config-reporter.ts → config/config-reporter.ts} +1 -1
  49. package/src/{config-store.ts → config/config-store.ts} +1 -2
  50. package/src/{extension-config.ts → config/extension-config.ts} +4 -4
  51. package/src/{extension-paths.ts → config/extension-paths.ts} +1 -1
  52. package/src/{policy-loader.ts → config/policy-loader.ts} +2 -2
  53. package/src/{skill-prompt-sanitizer.ts → exposure/skill-prompt-sanitizer.ts} +2 -2
  54. package/src/{tool-registry.ts → exposure/tool-registry.ts} +1 -1
  55. package/src/exposure/tool-surface-baseline.ts +101 -0
  56. package/src/handlers/before-agent-start.ts +48 -21
  57. package/src/handlers/gates/bash-command.ts +2 -2
  58. package/src/handlers/gates/bash-external-directory.ts +3 -3
  59. package/src/handlers/gates/bash-path-extractor.ts +1 -1
  60. package/src/handlers/gates/bash-path.ts +4 -4
  61. package/src/handlers/gates/descriptor.ts +2 -2
  62. package/src/handlers/gates/external-directory-policy.ts +2 -2
  63. package/src/handlers/gates/external-directory.ts +4 -4
  64. package/src/handlers/gates/helpers.ts +1 -1
  65. package/src/handlers/gates/path.ts +4 -4
  66. package/src/handlers/gates/runner.ts +4 -4
  67. package/src/handlers/gates/skill-read.ts +3 -3
  68. package/src/handlers/gates/tool-call-gate-pipeline.ts +7 -7
  69. package/src/handlers/gates/tool.ts +3 -3
  70. package/src/handlers/lifecycle.ts +6 -7
  71. package/src/handlers/permission-gate-handler.ts +11 -11
  72. package/src/handlers/session-turn-prep.ts +1 -1
  73. package/src/handlers/tool-call-boundary.ts +3 -3
  74. package/src/index.ts +40 -39
  75. package/src/{decision-reporter.ts → logging/decision-reporter.ts} +1 -1
  76. package/src/{logging.ts → logging/logging.ts} +1 -1
  77. package/src/{session-logger.ts → logging/session-logger.ts} +14 -5
  78. package/src/path/approval-pattern.ts +1 -1
  79. package/src/path/canonicalize-path.ts +1 -1
  80. package/src/path/path-containment.ts +2 -2
  81. package/src/path/path-flavor.ts +1 -1
  82. package/src/{path-normalizer.ts → path/path-normalizer.ts} +6 -8
  83. package/src/path/pi-infrastructure-read.ts +3 -3
  84. package/src/{normalize.ts → policy/normalize.ts} +2 -2
  85. package/src/{permission-gate.ts → policy/permission-gate.ts} +1 -1
  86. package/src/{permission-manager.ts → policy/permission-manager.ts} +21 -15
  87. package/src/{permission-merge.ts → policy/permission-merge.ts} +1 -1
  88. package/src/{permission-resolver.ts → policy/permission-resolver.ts} +5 -5
  89. package/src/{rule.ts → policy/rule.ts} +3 -4
  90. package/src/{scope-merge.ts → policy/scope-merge.ts} +3 -3
  91. package/src/{synthesize.ts → policy/synthesize.ts} +1 -1
  92. package/src/{wildcard-matcher.ts → policy/wildcard-matcher.ts} +1 -1
  93. package/src/presentation/agent-renderer.ts +5 -5
  94. package/src/presentation/dialog-renderer.ts +3 -3
  95. package/src/presentation/fact-vocabulary.ts +1 -4
  96. package/src/presentation/forwarded-ask-payload.ts +1 -4
  97. package/src/presentation/path-ask-payload.ts +2 -5
  98. package/src/{pattern-suggest.ts → presentation/pattern-suggest.ts} +6 -3
  99. package/src/{permission-prompts.ts → presentation/permission-prompts.ts} +1 -1
  100. package/src/presentation/review-log-renderer.ts +1 -1
  101. package/src/presentation/skill-ask-payload.ts +3 -3
  102. package/src/presentation/tool-ask-payload.ts +3 -6
  103. package/src/{bash-advisory-check.ts → service/bash-advisory-check.ts} +1 -1
  104. package/src/{permissions-service.ts → service/permissions-service.ts} +10 -10
  105. package/src/{service-lifecycle.ts → service/service-lifecycle.ts} +5 -5
  106. package/src/service.ts +18 -18
  107. package/src/{permission-session.ts → session/permission-session.ts} +39 -15
  108. package/src/{session-approval.ts → session/session-approval.ts} +2 -2
  109. package/src/{session-rules.ts → session/session-rules.ts} +1 -1
  110. package/src/{builtin-tool-input-formatters.ts → tool-input/builtin-tool-input-formatters.ts} +1 -1
  111. package/src/{tool-input-preview.ts → tool-input/tool-input-preview.ts} +2 -2
  112. package/src/{tool-input-prompt-formatters.ts → tool-input/tool-input-prompt-formatters.ts} +1 -1
  113. package/src/{tool-preview-formatter.ts → tool-input/tool-preview-formatter.ts} +3 -3
  114. package/src/types.ts +2 -2
  115. /package/src/{async-cache.ts → access-intent/bash/async-cache.ts} +0 -0
  116. /package/src/{bash-arity.ts → access-intent/bash/bash-arity.ts} +0 -0
  117. /package/src/{config-paths.ts → config/config-paths.ts} +0 -0
  118. /package/src/{config-schema.ts → config/config-schema.ts} +0 -0
  119. /package/src/{status.ts → config/status.ts} +0 -0
  120. /package/src/{yaml-frontmatter.ts → config/yaml-frontmatter.ts} +0 -0
  121. /package/src/{system-prompt-sanitizer.ts → exposure/system-prompt-sanitizer.ts} +0 -0
  122. /package/src/{decision-audit.ts → logging/decision-audit.ts} +0 -0
  123. /package/src/{json-safe-stringify.ts → logging/json-safe-stringify.ts} +0 -0
  124. /package/src/{log-field-cap.ts → logging/log-field-cap.ts} +0 -0
  125. /package/src/{log-file-permissions.ts → logging/log-file-permissions.ts} +0 -0
  126. /package/src/{log-redaction.ts → logging/log-redaction.ts} +0 -0
  127. /package/src/{expand-home.ts → path/expand-home.ts} +0 -0
  128. /package/src/{node-modules-discovery.ts → path/node-modules-discovery.ts} +0 -0
  129. /package/src/{safe-system-paths.ts → path/safe-system-paths.ts} +0 -0
  130. /package/src/{restrictiveness.ts → policy/restrictiveness.ts} +0 -0
  131. /package/src/{permission-events.ts → service/permission-events.ts} +0 -0
  132. /package/src/{permission-ui-prompt.ts → service/permission-ui-prompt.ts} +0 -0
  133. /package/src/{active-agent.ts → session/active-agent.ts} +0 -0
  134. /package/src/{approval-grant.ts → session/approval-grant.ts} +0 -0
  135. /package/src/{session-approval-recorder.ts → session/session-approval-recorder.ts} +0 -0
  136. /package/src/{session-identity.ts → session/session-identity.ts} +0 -0
  137. /package/src/{tool-access-extractor-registry.ts → tool-input/tool-access-extractor-registry.ts} +0 -0
  138. /package/src/{tool-input-formatter-registry.ts → tool-input/tool-input-formatter-registry.ts} +0 -0
@@ -2,9 +2,9 @@ import {
2
2
  describeBashCommandContext,
3
3
  flaggedElements,
4
4
  valueLabel,
5
- } from "#src/presentation/fact-vocabulary";
6
- import { fitLinesToWidth } from "#src/presentation/line-fitting";
7
- import type { PromptPayload } from "#src/presentation/prompt-payload";
5
+ } from "./fact-vocabulary";
6
+ import { fitLinesToWidth } from "./line-fitting";
7
+ import type { PromptPayload } from "./prompt-payload";
8
8
 
9
9
  /**
10
10
  * Render a {@link PromptPayload} for a human deciding an ask (ADR 0011 §5).
@@ -1,8 +1,5 @@
1
- import {
2
- allEvidence,
3
- type PromptPayload,
4
- } from "#src/presentation/prompt-payload";
5
1
  import type { BashCommandContext } from "#src/types";
2
+ import { allEvidence, type PromptPayload } from "./prompt-payload";
6
3
 
7
4
  /**
8
5
  * The render vocabulary shared by every renderer over a {@link PromptPayload}.
@@ -1,8 +1,5 @@
1
1
  import type { ForwardedPermissionRequest } from "#src/authority/permission-forwarding";
2
- import type {
3
- PromptPayload,
4
- PromptRequester,
5
- } from "#src/presentation/prompt-payload";
2
+ import type { PromptPayload, PromptRequester } from "./prompt-payload";
6
3
 
7
4
  /**
8
5
  * Build the payload for an ask forwarded up from a subagent.
@@ -1,8 +1,5 @@
1
- import type {
2
- PromptEvidence,
3
- PromptPayload,
4
- } from "#src/presentation/prompt-payload";
5
- import { localRequester } from "#src/presentation/prompt-payload";
1
+ import type { PromptEvidence, PromptPayload } from "./prompt-payload";
2
+ import { localRequester } from "./prompt-payload";
6
3
 
7
4
  /** A displayed external path paired with its resolved target, when distinct. */
8
5
  export interface ExternalPathDisclosure {
@@ -1,10 +1,13 @@
1
+ import {
2
+ prefix,
3
+ stripBashCommentLines,
4
+ } from "#src/access-intent/bash/bash-arity";
1
5
  import {
2
6
  type CapabilityDirection,
3
7
  PATH_BEARING_TOOLS,
4
8
  surfaceFamilyOf,
5
- } from "./access-intent/path-surfaces";
6
- import type { ApprovalGrant } from "./approval-grant";
7
- import { prefix, stripBashCommentLines } from "./bash-arity";
9
+ } from "#src/access-intent/path-surfaces";
10
+ import type { ApprovalGrant } from "#src/session/approval-grant";
8
11
 
9
12
  /** The suggestion returned for a "Yes, for this session" dialog option. */
10
13
  export interface SessionApprovalSuggestion {
@@ -1,4 +1,4 @@
1
- import { classifyToolKind } from "./access-intent/tool-kind";
1
+ import { classifyToolKind } from "#src/access-intent/tool-kind";
2
2
 
3
3
  // NOTE: the ask prompts are now payload builders under src/presentation/, and
4
4
  // denial text is a render over the payload (presentation/agent-renderer.ts).
@@ -1,4 +1,4 @@
1
- import type { PromptPayload } from "#src/presentation/prompt-payload";
1
+ import type { PromptPayload } from "./prompt-payload";
2
2
 
3
3
  /**
4
4
  * The payload facts the permission review log persists (ADR 0011 §6).
@@ -1,6 +1,6 @@
1
- import type { PromptPayload } from "#src/presentation/prompt-payload";
2
- import { localRequester } from "#src/presentation/prompt-payload";
3
- import type { SkillPromptEntry } from "#src/skill-prompt-sanitizer";
1
+ import type { SkillPromptEntry } from "#src/exposure/skill-prompt-sanitizer";
2
+ import type { PromptPayload } from "./prompt-payload";
3
+ import { localRequester } from "./prompt-payload";
4
4
 
5
5
  /** A request to load a skill. */
6
6
  export function buildSkillAskPayload(
@@ -1,12 +1,9 @@
1
1
  import { classifyToolKind, isMcpCheck } from "#src/access-intent/tool-kind";
2
- import type {
3
- PromptEvidence,
4
- PromptPayload,
5
- } from "#src/presentation/prompt-payload";
6
- import { localRequester } from "#src/presentation/prompt-payload";
7
- import type { ToolPreviewFormatter } from "#src/tool-preview-formatter";
2
+ import type { ToolPreviewFormatter } from "#src/tool-input/tool-preview-formatter";
8
3
  import type { PermissionCheckResult } from "#src/types";
9
4
  import { getNonEmptyString, toRecord } from "#src/value-guards";
5
+ import type { PromptEvidence, PromptPayload } from "./prompt-payload";
6
+ import { localRequester } from "./prompt-payload";
10
7
 
11
8
  /** The facts the per-tool gate holds when it raises an ask. */
12
9
  export interface ToolAskFacts {
@@ -1,6 +1,6 @@
1
1
  import { parseBashCommandsSync } from "#src/access-intent/bash/sync-commands";
2
2
  import { resolveBashCommandCheck } from "#src/handlers/gates/bash-command";
3
- import type { ScopedPermissionResolver } from "#src/permission-resolver";
3
+ import type { ScopedPermissionResolver } from "#src/policy/permission-resolver";
4
4
  import type { PermissionCheckResult } from "#src/types";
5
5
 
6
6
  /**
@@ -1,21 +1,21 @@
1
- import type { AccessIntent } from "./access-intent/access-intent";
2
- import { buildAccessIntentForSurface } from "./access-intent/input-normalizer";
3
- import type { Authorizer } from "./authority/authorizer";
4
- import type { AuthorizerRegistrar } from "./authority/authorizer-registry";
5
- import { resolveBashAdvisoryCheck } from "./bash-advisory-check";
6
- import type { PathNormalizer } from "./path-normalizer";
7
- import type { PermissionsService } from "./service";
1
+ import type { AccessIntent } from "#src/access-intent/access-intent";
2
+ import { buildAccessIntentForSurface } from "#src/access-intent/input-normalizer";
3
+ import type { Authorizer } from "#src/authority/authorizer";
4
+ import type { AuthorizerRegistrar } from "#src/authority/authorizer-registry";
5
+ import type { PathNormalizer } from "#src/path/path-normalizer";
6
+ import type { PermissionsService } from "#src/service";
8
7
  import type {
9
8
  ToolAccessExtractor,
10
9
  ToolAccessExtractorLookup,
11
10
  ToolAccessExtractorRegistrar,
12
- } from "./tool-access-extractor-registry";
11
+ } from "#src/tool-input/tool-access-extractor-registry";
13
12
  import type {
14
13
  ToolInputFormatter,
15
14
  ToolInputFormatterLookup,
16
15
  ToolInputFormatterRegistrar,
17
- } from "./tool-input-formatter-registry";
18
- import type { PermissionCheckResult, PermissionState } from "./types";
16
+ } from "#src/tool-input/tool-input-formatter-registry";
17
+ import type { PermissionCheckResult, PermissionState } from "#src/types";
18
+ import { resolveBashAdvisoryCheck } from "./bash-advisory-check";
19
19
 
20
20
  /**
21
21
  * Resolution surface the service needs: answer a gate-style {@link AccessIntent}
@@ -1,13 +1,13 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
- import type { AdjudicationRole } from "./authority/authorizer-selection";
3
- import type { NodeIdentity } from "./authority/inherited-registrations";
4
- import { emitReadyEvent, type PermissionEventBus } from "./permission-events";
2
+ import type { AdjudicationRole } from "#src/authority/authorizer-selection";
3
+ import type { NodeIdentity } from "#src/authority/inherited-registrations";
5
4
  import {
6
5
  type PermissionsService,
7
6
  publishPermissionsService,
8
7
  unpublishPermissionsService,
9
- } from "./service";
10
- import { readSessionId } from "./session-identity";
8
+ } from "#src/service";
9
+ import { readSessionId } from "#src/session/session-identity";
10
+ import { emitReadyEvent, type PermissionEventBus } from "./permission-events";
11
11
 
12
12
  /** The session-scoped service lifecycle that the lifecycle handler drives. */
13
13
  export interface ServiceLifecycle {
package/src/service.ts CHANGED
@@ -18,15 +18,15 @@
18
18
  * ensures resilience across `/reload` and load-order edge cases.
19
19
  */
20
20
 
21
- import type { Authorizer } from "./authority/authorizer";
22
- import type { ToolAccessExtractor } from "./tool-access-extractor-registry";
23
- import type { ToolInputFormatter } from "./tool-input-formatter-registry";
21
+ import type { Authorizer } from "#src/authority/authorizer";
22
+ import type { ToolAccessExtractor } from "#src/tool-input/tool-access-extractor-registry";
23
+ import type { ToolInputFormatter } from "#src/tool-input/tool-input-formatter-registry";
24
24
  import type { PermissionCheckResult, PermissionState } from "./types";
25
25
 
26
26
  export type {
27
27
  Authorizer,
28
28
  AuthorizerVerdict,
29
- } from "./authority/authorizer";
29
+ } from "#src/authority/authorizer";
30
30
 
31
31
  /**
32
32
  * The narrow review-log seam handed to a chain link at `authorize` time
@@ -43,19 +43,7 @@ export interface AuthorizerLog {
43
43
  review(event: string, details?: Record<string, unknown>): void;
44
44
  debug(event: string, details?: Record<string, unknown>): void;
45
45
  }
46
- export type { PromptPermissionDetails } from "./authority/permission-prompter";
47
- export type {
48
- ForwardedPromptContext,
49
- PermissionDecisionEvent,
50
- PermissionsReadyEvent,
51
- PermissionUiPromptEvent,
52
- PermissionUiPromptSource,
53
- } from "./permission-events";
54
- export {
55
- PERMISSIONS_DECISION_CHANNEL,
56
- PERMISSIONS_READY_CHANNEL,
57
- PERMISSIONS_UI_PROMPT_CHANNEL,
58
- } from "./permission-events";
46
+ export type { PromptPermissionDetails } from "#src/authority/permission-prompter";
59
47
  // The declaration bundle already inlines these through `PromptPermissionDetails`
60
48
  // and `PermissionUiPromptEvent`; the named exports are what a consumer needs to
61
49
  // annotate a variable of their own.
@@ -66,7 +54,19 @@ export type {
66
54
  PromptPayloadKind,
67
55
  PromptRequester,
68
56
  PromptRequestFacts,
69
- } from "./presentation/prompt-payload";
57
+ } from "#src/presentation/prompt-payload";
58
+ export type {
59
+ ForwardedPromptContext,
60
+ PermissionDecisionEvent,
61
+ PermissionsReadyEvent,
62
+ PermissionUiPromptEvent,
63
+ PermissionUiPromptSource,
64
+ } from "#src/service/permission-events";
65
+ export {
66
+ PERMISSIONS_DECISION_CHANNEL,
67
+ PERMISSIONS_READY_CHANNEL,
68
+ PERMISSIONS_UI_PROMPT_CHANNEL,
69
+ } from "#src/service/permission-events";
70
70
  export type { PermissionCheckResult, PermissionState, ToolInputFormatter };
71
71
 
72
72
  /** Process-global key for the session-keyed service map (ADR 0012 decision 2). */
@@ -1,25 +1,29 @@
1
1
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { AuthorizerSelectionLifecycle } from "#src/authority/authorizer-selection";
2
3
  import type { ForwardingController } from "#src/authority/forwarding-manager";
4
+ import type { ShellToolsConfig } from "#src/config/config-schema";
5
+ import type { SessionConfigStore } from "#src/config/config-store";
6
+ import type { PermissionSystemExtensionConfig } from "#src/config/extension-config";
7
+ import type { ExtensionPaths } from "#src/config/extension-paths";
8
+ import type { SkillPromptEntry } from "#src/exposure/skill-prompt-sanitizer";
9
+ import {
10
+ ToolSurfaceBaseline,
11
+ type ToolSurfaceObservation,
12
+ type ToolSurfaceResolution,
13
+ } from "#src/exposure/tool-surface-baseline";
14
+ import type { ToolCallGateInputs } from "#src/handlers/gates/tool-call-gate-pipeline";
15
+ import type { PathFlavor } from "#src/path/path-flavor";
16
+ import { PathNormalizer } from "#src/path/path-normalizer";
17
+ import type { ScopedPermissionManager } from "#src/policy/permission-manager";
18
+ import {
19
+ resolveToolPreviewLimits,
20
+ type ToolPreviewFormatterOptions,
21
+ } from "#src/tool-input/tool-preview-formatter";
3
22
  import {
4
23
  getActiveAgentName,
5
24
  getActiveAgentNameFromSystemPrompt,
6
25
  } from "./active-agent";
7
- import type { AuthorizerSelectionLifecycle } from "./authority/authorizer-selection";
8
- import type { ShellToolsConfig } from "./config-schema";
9
- import type { SessionConfigStore } from "./config-store";
10
- import type { PermissionSystemExtensionConfig } from "./extension-config";
11
- import type { ExtensionPaths } from "./extension-paths";
12
- import type { ToolCallGateInputs } from "./handlers/gates/tool-call-gate-pipeline";
13
- import type { PathFlavor } from "./path/path-flavor";
14
- import { PathNormalizer } from "./path-normalizer";
15
- import type { ScopedPermissionManager } from "./permission-manager";
16
-
17
26
  import type { SessionRules } from "./session-rules";
18
- import type { SkillPromptEntry } from "./skill-prompt-sanitizer";
19
- import {
20
- resolveToolPreviewLimits,
21
- type ToolPreviewFormatterOptions,
22
- } from "./tool-preview-formatter";
23
27
 
24
28
  /**
25
29
  * Encapsulates all mutable session state and exposes operations instead of
@@ -40,6 +44,7 @@ export class PermissionSession implements ToolCallGateInputs {
40
44
  private skillEntries: SkillPromptEntry[] = [];
41
45
  private knownAgentName: string | null = null;
42
46
  private pathNormalizer: PathNormalizer;
47
+ private readonly toolSurfaceBaseline = new ToolSurfaceBaseline();
43
48
 
44
49
  constructor(
45
50
  private readonly paths: ExtensionPaths,
@@ -108,6 +113,7 @@ export class PermissionSession implements ToolCallGateInputs {
108
113
  projectTrusted ? ctx.cwd : undefined,
109
114
  );
110
115
  this.skillEntries = [];
116
+ this.toolSurfaceBaseline.reset();
111
117
  this.activate(ctx);
112
118
  }
113
119
 
@@ -118,6 +124,7 @@ export class PermissionSession implements ToolCallGateInputs {
118
124
  shutdown(): void {
119
125
  this.sessionRules.clear();
120
126
  this.skillEntries = [];
127
+ this.toolSurfaceBaseline.reset();
121
128
  this.deactivate();
122
129
  }
123
130
 
@@ -134,6 +141,23 @@ export class PermissionSession implements ToolCallGateInputs {
134
141
  projectTrusted ? this.context?.cwd : undefined,
135
142
  );
136
143
  this.skillEntries = [];
144
+ // The tool-surface baseline deliberately survives a reload: a reload is
145
+ // when a relaxed policy arrives, and reseeding from the already-filtered
146
+ // active set would strand the tool it just un-denied (#873).
147
+ }
148
+
149
+ // ── Tool surface ───────────────────────────────────────────────────────
150
+
151
+ /**
152
+ * Answer which tools the agent may see this turn, applying `isExposed` to
153
+ * the session's pre-filter tool surface rather than to the previous turn's
154
+ * filtered result.
155
+ */
156
+ resolveExposedTools(
157
+ observation: ToolSurfaceObservation,
158
+ isExposed: (toolName: string) => boolean,
159
+ ): ToolSurfaceResolution {
160
+ return this.toolSurfaceBaseline.resolveExposed(observation, isExposed);
137
161
  }
138
162
 
139
163
  // ── Skill entries ──────────────────────────────────────────────────────
@@ -1,9 +1,9 @@
1
+ import type { ForwardedSessionApproval } from "#src/authority/permission-forwarding";
1
2
  import {
2
3
  type ApprovalGrant,
3
4
  type SessionGrantWidth,
4
5
  widenGrant,
5
- } from "#src/approval-grant";
6
- import type { ForwardedSessionApproval } from "#src/authority/permission-forwarding";
6
+ } from "./approval-grant";
7
7
 
8
8
  /**
9
9
  * Value object for a session-scoped approval: one or more
@@ -1,5 +1,5 @@
1
1
  import { surfaceFamilyMembers } from "#src/access-intent/path-surfaces";
2
- import type { Ruleset } from "./rule";
2
+ import type { Ruleset } from "#src/policy/rule";
3
3
  import type { SessionApproval } from "./session-approval";
4
4
  import type { SessionApprovalRecorder } from "./session-approval-recorder";
5
5
 
@@ -5,12 +5,12 @@
5
5
  * through exactly the same path a third-party extension would use.
6
6
  */
7
7
 
8
+ import { toRecord } from "#src/value-guards";
8
9
  import type {
9
10
  ToolInputFormatter,
10
11
  ToolInputFormatterRegistry,
11
12
  } from "./tool-input-formatter-registry";
12
13
  import { truncateInlineText } from "./tool-input-preview";
13
- import { toRecord } from "./value-guards";
14
14
 
15
15
  /** Maximum total length of the generated argument summary (before "with " prefix). */
16
16
  const MCP_ARGS_SUMMARY_MAX_LENGTH = 160;
@@ -1,5 +1,5 @@
1
- import { safeJsonStringify } from "./json-safe-stringify";
2
- import { redactedJsonStringify } from "./log-redaction";
1
+ import { safeJsonStringify } from "#src/logging/json-safe-stringify";
2
+ import { redactedJsonStringify } from "#src/logging/log-redaction";
3
3
 
4
4
  export const TOOL_INPUT_PREVIEW_MAX_LENGTH = 200;
5
5
  export const TOOL_TEXT_SUMMARY_MAX_LENGTH = 80;
@@ -1,5 +1,5 @@
1
+ import { getNonEmptyString, toRecord } from "#src/value-guards";
1
2
  import { countTextLines, formatCount } from "./tool-input-preview";
2
- import { getNonEmptyString, toRecord } from "./value-guards";
3
3
 
4
4
  export function getPromptPath(input: Record<string, unknown>): string | null {
5
5
  return getNonEmptyString(input.path) ?? getNonEmptyString(input.file_path);
@@ -1,4 +1,6 @@
1
- import { classifyToolKind, isMcpCheck } from "./access-intent/tool-kind";
1
+ import { classifyToolKind, isMcpCheck } from "#src/access-intent/tool-kind";
2
+ import type { PermissionCheckResult } from "#src/types";
3
+ import { getNonEmptyString, toRecord } from "#src/value-guards";
2
4
  import type { ToolInputFormatterLookup } from "./tool-input-formatter-registry";
3
5
  import {
4
6
  serializeRedactedToolInputPreview,
@@ -13,8 +15,6 @@ import {
13
15
  formatWriteInputForPrompt,
14
16
  getPromptPath,
15
17
  } from "./tool-input-prompt-formatters";
16
- import type { PermissionCheckResult } from "./types";
17
- import { getNonEmptyString, toRecord } from "./value-guards";
18
18
 
19
19
  export interface ToolPreviewFormatterOptions {
20
20
  toolInputPreviewMaxLength: number;
package/src/types.ts CHANGED
@@ -3,8 +3,8 @@ import type {
3
3
  FlatPermissionConfig,
4
4
  PatternValue,
5
5
  PermissionState,
6
- } from "./config-schema";
7
- import type { RuleOrigin } from "./rule";
6
+ } from "#src/config/config-schema";
7
+ import type { RuleOrigin } from "#src/policy/rule";
8
8
 
9
9
  // The config-file shape types are derived from the zod schema
10
10
  // (config-schema.ts) — the single source of truth — and re-exported here so
File without changes
File without changes
File without changes