@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.
- package/CHANGELOG.md +23 -0
- package/dist/public.d.ts +15 -15
- package/docs/configuration.md +6 -2
- package/docs/cross-extension-api.md +1 -1
- package/docs/session-approvals.md +2 -2
- package/package.json +1 -1
- package/src/access-intent/access-intent.ts +1 -1
- package/src/access-intent/bash/bash-path-resolver.ts +11 -14
- package/src/access-intent/bash/command-enumeration.ts +6 -12
- package/src/access-intent/bash/msys-bash-tokens.ts +1 -1
- package/src/access-intent/bash/nested-execution.ts +1 -1
- package/src/access-intent/bash/node-text.ts +2 -2
- package/src/access-intent/bash/parser.ts +1 -1
- package/src/access-intent/bash/program.ts +4 -7
- package/src/access-intent/bash/redirect-analysis.ts +2 -2
- package/src/access-intent/bash/shell-variable-expansion.ts +1 -1
- package/src/access-intent/bash/sync-commands.ts +2 -5
- package/src/access-intent/bash/token-collection.ts +6 -9
- package/src/access-intent/bash/wrapper-analysis.ts +1 -1
- package/src/access-intent/input-normalizer.ts +2 -2
- package/src/access-intent/path-normalization.ts +1 -1
- package/src/access-intent/path-surfaces.ts +1 -1
- package/src/access-intent/tool-input-path.ts +1 -1
- package/src/access-intent/tool-kind.ts +1 -1
- package/src/authority/approval-escalator.ts +13 -13
- package/src/authority/authorizer-chain.ts +1 -1
- package/src/authority/authorizer-registry.ts +1 -1
- package/src/authority/authorizer-selection.ts +1 -1
- package/src/authority/authorizer.ts +9 -9
- package/src/authority/decision-resolution.ts +2 -5
- package/src/authority/denying-authorizer.ts +1 -1
- package/src/authority/forwarded-request-server.ts +21 -24
- package/src/authority/forwarder-context.ts +2 -2
- package/src/authority/forwarding-io.ts +14 -12
- package/src/authority/forwarding-liveness.ts +5 -8
- package/src/authority/forwarding-manager.ts +1 -1
- package/src/authority/inherited-registrations.ts +2 -2
- package/src/authority/local-user-authorizer.ts +13 -13
- package/src/authority/permission-dialog.ts +2 -2
- package/src/authority/permission-forwarding.ts +6 -3
- package/src/authority/permission-prompt-component.ts +12 -15
- package/src/authority/permission-prompt-decision.ts +2 -2
- package/src/authority/permission-prompter.ts +8 -8
- package/src/authority/subagent-context.ts +3 -3
- package/src/authority/subagent-detection.ts +3 -3
- package/src/{config-loader.ts → config/config-loader.ts} +3 -3
- package/src/{config-modal.ts → config/config-modal.ts} +1 -2
- package/src/{config-reporter.ts → config/config-reporter.ts} +1 -1
- package/src/{config-store.ts → config/config-store.ts} +1 -2
- package/src/{extension-config.ts → config/extension-config.ts} +4 -4
- package/src/{extension-paths.ts → config/extension-paths.ts} +1 -1
- package/src/{policy-loader.ts → config/policy-loader.ts} +2 -2
- package/src/{skill-prompt-sanitizer.ts → exposure/skill-prompt-sanitizer.ts} +2 -2
- package/src/{tool-registry.ts → exposure/tool-registry.ts} +1 -1
- package/src/exposure/tool-surface-baseline.ts +101 -0
- package/src/handlers/before-agent-start.ts +48 -21
- package/src/handlers/gates/bash-command.ts +2 -2
- package/src/handlers/gates/bash-external-directory.ts +3 -3
- package/src/handlers/gates/bash-path-extractor.ts +1 -1
- package/src/handlers/gates/bash-path.ts +4 -4
- package/src/handlers/gates/descriptor.ts +2 -2
- package/src/handlers/gates/external-directory-policy.ts +2 -2
- package/src/handlers/gates/external-directory.ts +4 -4
- package/src/handlers/gates/helpers.ts +1 -1
- package/src/handlers/gates/path.ts +4 -4
- package/src/handlers/gates/runner.ts +4 -4
- package/src/handlers/gates/skill-read.ts +3 -3
- package/src/handlers/gates/tool-call-gate-pipeline.ts +7 -7
- package/src/handlers/gates/tool.ts +3 -3
- package/src/handlers/lifecycle.ts +6 -7
- package/src/handlers/permission-gate-handler.ts +11 -11
- package/src/handlers/session-turn-prep.ts +1 -1
- package/src/handlers/tool-call-boundary.ts +3 -3
- package/src/index.ts +40 -39
- package/src/{decision-reporter.ts → logging/decision-reporter.ts} +1 -1
- package/src/{logging.ts → logging/logging.ts} +1 -1
- package/src/{session-logger.ts → logging/session-logger.ts} +14 -5
- package/src/path/approval-pattern.ts +1 -1
- package/src/path/canonicalize-path.ts +1 -1
- package/src/path/path-containment.ts +2 -2
- package/src/path/path-flavor.ts +1 -1
- package/src/{path-normalizer.ts → path/path-normalizer.ts} +6 -8
- package/src/path/pi-infrastructure-read.ts +3 -3
- package/src/{normalize.ts → policy/normalize.ts} +2 -2
- package/src/{permission-gate.ts → policy/permission-gate.ts} +1 -1
- package/src/{permission-manager.ts → policy/permission-manager.ts} +21 -15
- package/src/{permission-merge.ts → policy/permission-merge.ts} +1 -1
- package/src/{permission-resolver.ts → policy/permission-resolver.ts} +5 -5
- package/src/{rule.ts → policy/rule.ts} +3 -4
- package/src/{scope-merge.ts → policy/scope-merge.ts} +3 -3
- package/src/{synthesize.ts → policy/synthesize.ts} +1 -1
- package/src/{wildcard-matcher.ts → policy/wildcard-matcher.ts} +1 -1
- package/src/presentation/agent-renderer.ts +5 -5
- package/src/presentation/dialog-renderer.ts +3 -3
- package/src/presentation/fact-vocabulary.ts +1 -4
- package/src/presentation/forwarded-ask-payload.ts +1 -4
- package/src/presentation/path-ask-payload.ts +2 -5
- package/src/{pattern-suggest.ts → presentation/pattern-suggest.ts} +6 -3
- package/src/{permission-prompts.ts → presentation/permission-prompts.ts} +1 -1
- package/src/presentation/review-log-renderer.ts +1 -1
- package/src/presentation/skill-ask-payload.ts +3 -3
- package/src/presentation/tool-ask-payload.ts +3 -6
- package/src/{bash-advisory-check.ts → service/bash-advisory-check.ts} +1 -1
- package/src/{permissions-service.ts → service/permissions-service.ts} +10 -10
- package/src/{service-lifecycle.ts → service/service-lifecycle.ts} +5 -5
- package/src/service.ts +18 -18
- package/src/{permission-session.ts → session/permission-session.ts} +39 -15
- package/src/{session-approval.ts → session/session-approval.ts} +2 -2
- package/src/{session-rules.ts → session/session-rules.ts} +1 -1
- package/src/{builtin-tool-input-formatters.ts → tool-input/builtin-tool-input-formatters.ts} +1 -1
- package/src/{tool-input-preview.ts → tool-input/tool-input-preview.ts} +2 -2
- package/src/{tool-input-prompt-formatters.ts → tool-input/tool-input-prompt-formatters.ts} +1 -1
- package/src/{tool-preview-formatter.ts → tool-input/tool-preview-formatter.ts} +3 -3
- package/src/types.ts +2 -2
- /package/src/{async-cache.ts → access-intent/bash/async-cache.ts} +0 -0
- /package/src/{bash-arity.ts → access-intent/bash/bash-arity.ts} +0 -0
- /package/src/{config-paths.ts → config/config-paths.ts} +0 -0
- /package/src/{config-schema.ts → config/config-schema.ts} +0 -0
- /package/src/{status.ts → config/status.ts} +0 -0
- /package/src/{yaml-frontmatter.ts → config/yaml-frontmatter.ts} +0 -0
- /package/src/{system-prompt-sanitizer.ts → exposure/system-prompt-sanitizer.ts} +0 -0
- /package/src/{decision-audit.ts → logging/decision-audit.ts} +0 -0
- /package/src/{json-safe-stringify.ts → logging/json-safe-stringify.ts} +0 -0
- /package/src/{log-field-cap.ts → logging/log-field-cap.ts} +0 -0
- /package/src/{log-file-permissions.ts → logging/log-file-permissions.ts} +0 -0
- /package/src/{log-redaction.ts → logging/log-redaction.ts} +0 -0
- /package/src/{expand-home.ts → path/expand-home.ts} +0 -0
- /package/src/{node-modules-discovery.ts → path/node-modules-discovery.ts} +0 -0
- /package/src/{safe-system-paths.ts → path/safe-system-paths.ts} +0 -0
- /package/src/{restrictiveness.ts → policy/restrictiveness.ts} +0 -0
- /package/src/{permission-events.ts → service/permission-events.ts} +0 -0
- /package/src/{permission-ui-prompt.ts → service/permission-ui-prompt.ts} +0 -0
- /package/src/{active-agent.ts → session/active-agent.ts} +0 -0
- /package/src/{approval-grant.ts → session/approval-grant.ts} +0 -0
- /package/src/{session-approval-recorder.ts → session/session-approval-recorder.ts} +0 -0
- /package/src/{session-identity.ts → session/session-identity.ts} +0 -0
- /package/src/{tool-access-extractor-registry.ts → tool-input/tool-access-extractor-registry.ts} +0 -0
- /package/src/{tool-input-formatter-registry.ts → tool-input/tool-input-formatter-registry.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { capabilitySurfaceForTool } from "#src/access-intent/path-surfaces";
|
|
2
2
|
import { getToolInputPath } from "#src/access-intent/tool-input-path";
|
|
3
|
-
import type { PathNormalizer } from "#src/path-normalizer";
|
|
4
|
-
import type { ScopedPermissionResolver } from "#src/permission-resolver";
|
|
3
|
+
import type { PathNormalizer } from "#src/path/path-normalizer";
|
|
4
|
+
import type { ScopedPermissionResolver } from "#src/policy/permission-resolver";
|
|
5
5
|
import { buildExternalDirectoryAskPayload } from "#src/presentation/path-ask-payload";
|
|
6
|
-
import { SessionApproval } from "#src/session-approval";
|
|
7
|
-
import type { ToolAccessExtractorLookup } from "#src/tool-access-extractor-registry";
|
|
6
|
+
import { SessionApproval } from "#src/session/session-approval";
|
|
7
|
+
import type { ToolAccessExtractorLookup } from "#src/tool-input/tool-access-extractor-registry";
|
|
8
8
|
import type { GateResult } from "./descriptor";
|
|
9
9
|
import { resolveExternalDirectoryPolicy } from "./external-directory-policy";
|
|
10
10
|
import {
|
|
@@ -3,7 +3,7 @@ import type { ToolPathSource } from "#src/access-intent/tool-input-path";
|
|
|
3
3
|
import { classifyToolKind } from "#src/access-intent/tool-kind";
|
|
4
4
|
import type { ForwardedAccessFacts } from "#src/authority/permission-forwarding";
|
|
5
5
|
import type { PromptPermissionDetails } from "#src/authority/permission-prompter";
|
|
6
|
-
import type { PermissionDecisionResolution } from "#src/permission-events";
|
|
6
|
+
import type { PermissionDecisionResolution } from "#src/service/permission-events";
|
|
7
7
|
import type { PermissionCheckResult } from "#src/types";
|
|
8
8
|
import type { DecisionEventFacts } from "./descriptor";
|
|
9
9
|
import type { ToolCallContext } from "./types";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { capabilitySurfaceForTool } from "#src/access-intent/path-surfaces";
|
|
2
2
|
import { getToolInputPath } from "#src/access-intent/tool-input-path";
|
|
3
|
-
import type { PathNormalizer } from "#src/path-normalizer";
|
|
4
|
-
import type { ScopedPermissionResolver } from "#src/permission-resolver";
|
|
3
|
+
import type { PathNormalizer } from "#src/path/path-normalizer";
|
|
4
|
+
import type { ScopedPermissionResolver } from "#src/policy/permission-resolver";
|
|
5
5
|
import { buildPathAskPayload } from "#src/presentation/path-ask-payload";
|
|
6
|
-
import { SessionApproval } from "#src/session-approval";
|
|
7
|
-
import type { ToolAccessExtractorLookup } from "#src/tool-access-extractor-registry";
|
|
6
|
+
import { SessionApproval } from "#src/session/session-approval";
|
|
7
|
+
import type { ToolAccessExtractorLookup } from "#src/tool-input/tool-access-extractor-registry";
|
|
8
8
|
import type { GateDescriptor, GateResult } from "./descriptor";
|
|
9
9
|
import {
|
|
10
10
|
accessFactsFromPath,
|
|
@@ -2,16 +2,16 @@ import type { AskEscalator } from "#src/authority/authorizer-selection";
|
|
|
2
2
|
import { resolutionFor } from "#src/authority/decision-resolution";
|
|
3
3
|
import type { DecisionSource } from "#src/authority/decision-source";
|
|
4
4
|
import type { PermissionPromptDecision } from "#src/authority/permission-dialog";
|
|
5
|
-
import type { DecisionReporter } from "#src/decision-reporter";
|
|
6
|
-
import { applyPermissionGate } from "#src/permission-gate";
|
|
5
|
+
import type { DecisionReporter } from "#src/logging/decision-reporter";
|
|
7
6
|
import { createPermissionRequestId } from "#src/permission-request-id";
|
|
8
|
-
import
|
|
7
|
+
import { applyPermissionGate } from "#src/policy/permission-gate";
|
|
8
|
+
import type { ScopedPermissionResolver } from "#src/policy/permission-resolver";
|
|
9
9
|
import {
|
|
10
10
|
renderPolicyDenial,
|
|
11
11
|
renderRefusal,
|
|
12
12
|
} from "#src/presentation/agent-renderer";
|
|
13
13
|
import { renderReviewLogFacts } from "#src/presentation/review-log-renderer";
|
|
14
|
-
import type { SessionApprovalRecorder } from "#src/session-approval-recorder";
|
|
14
|
+
import type { SessionApprovalRecorder } from "#src/session/session-approval-recorder";
|
|
15
15
|
import type { PermissionCheckResult } from "#src/types";
|
|
16
16
|
import type {
|
|
17
17
|
DecisionEventFacts,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SkillPromptEntry } from "#src/exposure/skill-prompt-sanitizer";
|
|
2
|
+
import { findSkillPathMatch } from "#src/exposure/skill-prompt-sanitizer";
|
|
3
|
+
import type { PathNormalizer } from "#src/path/path-normalizer";
|
|
2
4
|
import { buildSkillPathAskPayload } from "#src/presentation/skill-ask-payload";
|
|
3
|
-
import type { SkillPromptEntry } from "#src/skill-prompt-sanitizer";
|
|
4
|
-
import { findSkillPathMatch } from "#src/skill-prompt-sanitizer";
|
|
5
5
|
import { toRecord } from "#src/value-guards";
|
|
6
6
|
import type { GateDescriptor } from "./descriptor";
|
|
7
7
|
import { accessFactsFromValue } from "./helpers";
|
|
@@ -4,16 +4,16 @@ import {
|
|
|
4
4
|
resolveShellInvocation,
|
|
5
5
|
type ShellInvocation,
|
|
6
6
|
} from "#src/access-intent/tool-kind";
|
|
7
|
-
import type { ShellToolsConfig } from "#src/config-schema";
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type { ToolAccessExtractorLookup } from "#src/tool-access-extractor-registry";
|
|
12
|
-
import type { ToolInputFormatterLookup } from "#src/tool-input-formatter-registry";
|
|
7
|
+
import type { ShellToolsConfig } from "#src/config/config-schema";
|
|
8
|
+
import type { SkillPromptEntry } from "#src/exposure/skill-prompt-sanitizer";
|
|
9
|
+
import type { PathNormalizer } from "#src/path/path-normalizer";
|
|
10
|
+
import type { ScopedPermissionResolver } from "#src/policy/permission-resolver";
|
|
11
|
+
import type { ToolAccessExtractorLookup } from "#src/tool-input/tool-access-extractor-registry";
|
|
12
|
+
import type { ToolInputFormatterLookup } from "#src/tool-input/tool-input-formatter-registry";
|
|
13
13
|
import {
|
|
14
14
|
ToolPreviewFormatter,
|
|
15
15
|
type ToolPreviewFormatterOptions,
|
|
16
|
-
} from "#src/tool-preview-formatter";
|
|
16
|
+
} from "#src/tool-input/tool-preview-formatter";
|
|
17
17
|
import type { PermissionCheckResult } from "#src/types";
|
|
18
18
|
import { resolveBashCommandCheck } from "./bash-command";
|
|
19
19
|
import { describeBashExternalDirectoryGate } from "./bash-external-directory";
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
suggestPathSessionPattern,
|
|
10
10
|
suggestSessionPattern,
|
|
11
|
-
} from "#src/pattern-suggest";
|
|
11
|
+
} from "#src/presentation/pattern-suggest";
|
|
12
12
|
import { buildToolAskPayload } from "#src/presentation/tool-ask-payload";
|
|
13
|
-
import { SessionApproval } from "#src/session-approval";
|
|
14
|
-
import type { ToolPreviewFormatter } from "#src/tool-preview-formatter";
|
|
13
|
+
import { SessionApproval } from "#src/session/session-approval";
|
|
14
|
+
import type { ToolPreviewFormatter } from "#src/tool-input/tool-preview-formatter";
|
|
15
15
|
import type { PermissionCheckResult } from "#src/types";
|
|
16
16
|
import type { GateDescriptor } from "./descriptor";
|
|
17
17
|
import {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
|
|
3
|
-
import type { DecisionSummaryWriter } from "#src/decision-audit";
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type { ServiceLifecycle } from "#src/service-lifecycle";
|
|
7
|
-
import type {
|
|
8
|
-
import { PERMISSION_SYSTEM_STATUS_KEY } from "#src/status";
|
|
2
|
+
import { PERMISSION_SYSTEM_STATUS_KEY } from "#src/config/status";
|
|
3
|
+
import type { DecisionSummaryWriter } from "#src/logging/decision-audit";
|
|
4
|
+
import type { SessionLogger } from "#src/logging/session-logger";
|
|
5
|
+
import type { PermissionResolver } from "#src/policy/permission-resolver";
|
|
6
|
+
import type { ServiceLifecycle } from "#src/service/service-lifecycle";
|
|
7
|
+
import type { PermissionSession } from "#src/session/permission-session";
|
|
9
8
|
|
|
10
9
|
/** Minimal subset of SessionStartEvent used by this handler. */
|
|
11
10
|
interface SessionStartPayload {
|
|
@@ -2,24 +2,24 @@ import type {
|
|
|
2
2
|
ExtensionContext,
|
|
3
3
|
InputEventResult,
|
|
4
4
|
} from "@earendil-works/pi-coding-agent";
|
|
5
|
-
import {
|
|
6
|
-
formatMissingToolNameReason,
|
|
7
|
-
formatUnknownToolReason,
|
|
8
|
-
} from "#src/permission-prompts";
|
|
9
|
-
import type { PermissionSession } from "#src/permission-session";
|
|
10
5
|
import {
|
|
11
6
|
checkRequestedToolRegistration,
|
|
12
7
|
getToolNameFromValue,
|
|
13
8
|
type ToolRegistry,
|
|
14
|
-
} from "#src/tool-registry";
|
|
15
|
-
import {
|
|
16
|
-
import type { GateRunner } from "./gates/runner";
|
|
9
|
+
} from "#src/exposure/tool-registry";
|
|
10
|
+
import type { GateRunner } from "#src/handlers/gates/runner";
|
|
17
11
|
import type {
|
|
18
12
|
GateNotifier,
|
|
19
13
|
SkillInputGatePipeline,
|
|
20
|
-
} from "
|
|
21
|
-
import type { ToolCallGatePipeline } from "
|
|
22
|
-
import type { GateOutcome, ToolCallContext } from "
|
|
14
|
+
} from "#src/handlers/gates/skill-input-gate-pipeline";
|
|
15
|
+
import type { ToolCallGatePipeline } from "#src/handlers/gates/tool-call-gate-pipeline";
|
|
16
|
+
import type { GateOutcome, ToolCallContext } from "#src/handlers/gates/types";
|
|
17
|
+
import {
|
|
18
|
+
formatMissingToolNameReason,
|
|
19
|
+
formatUnknownToolReason,
|
|
20
|
+
} from "#src/presentation/permission-prompts";
|
|
21
|
+
import type { PermissionSession } from "#src/session/permission-session";
|
|
22
|
+
import { toRecord } from "#src/value-guards";
|
|
23
23
|
|
|
24
24
|
/** Minimal subset of InputEvent used by handleInput. */
|
|
25
25
|
interface InputPayload {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type { ReadyAnnouncer } from "#src/service-lifecycle";
|
|
2
|
+
import type { ReadyAnnouncer } from "#src/service/service-lifecycle";
|
|
3
3
|
|
|
4
4
|
/** The session surface the turn-prep routine drives. */
|
|
5
5
|
export interface TurnPrepSession {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { GateOutcome } from "#src/handlers/gates/types";
|
|
3
|
+
import type { DecisionRecorder } from "#src/logging/decision-audit";
|
|
4
|
+
import type { DecisionReporter } from "#src/logging/decision-reporter";
|
|
4
5
|
import { createPermissionRequestId } from "#src/permission-request-id";
|
|
5
6
|
import { toRecord } from "#src/value-guards";
|
|
6
|
-
import type { GateOutcome } from "./gates/types";
|
|
7
7
|
|
|
8
8
|
/** The SDK-facing result shape for a `tool_call` handler. */
|
|
9
9
|
type ToolCallResult = { block?: true; reason?: string };
|
package/src/index.ts
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
|
|
2
2
|
import { getAgentDir, getPackageDir } from "@earendil-works/pi-coding-agent";
|
|
3
|
-
import { warmBashParser } from "
|
|
4
|
-
import { buildResolvedIntentFromMatchValues } from "
|
|
3
|
+
import { warmBashParser } from "#src/access-intent/bash/parser";
|
|
4
|
+
import { buildResolvedIntentFromMatchValues } from "#src/access-intent/input-normalizer";
|
|
5
5
|
import {
|
|
6
6
|
AuthorizerRegistry,
|
|
7
7
|
ObservedAuthorizerRegistrar,
|
|
8
|
-
} from "
|
|
9
|
-
import { AuthorizerSelection } from "
|
|
10
|
-
import { ChildNodeAudit } from "
|
|
8
|
+
} from "#src/authority/authorizer-registry";
|
|
9
|
+
import { AuthorizerSelection } from "#src/authority/authorizer-selection";
|
|
10
|
+
import { ChildNodeAudit } from "#src/authority/child-node-audit";
|
|
11
11
|
import {
|
|
12
12
|
ForwardedRequestServer,
|
|
13
13
|
type ServingPolicy,
|
|
14
|
-
} from "
|
|
14
|
+
} from "#src/authority/forwarded-request-server";
|
|
15
15
|
import {
|
|
16
16
|
ForwardingLivenessJudge,
|
|
17
17
|
ServingHeartbeatStore,
|
|
18
|
-
} from "
|
|
19
|
-
import { ForwardingManager } from "
|
|
18
|
+
} from "#src/authority/forwarding-liveness";
|
|
19
|
+
import { ForwardingManager } from "#src/authority/forwarding-manager";
|
|
20
20
|
import {
|
|
21
21
|
AncestorNodes,
|
|
22
22
|
InheritingToolAccessExtractorLookup,
|
|
23
23
|
InheritingToolInputFormatterLookup,
|
|
24
|
-
} from "
|
|
25
|
-
import { PERMISSION_FORWARDING_TIMEOUT_MS } from "
|
|
26
|
-
import { requestPermissionDecision } from "
|
|
27
|
-
import { PermissionPrompter } from "
|
|
24
|
+
} from "#src/authority/inherited-registrations";
|
|
25
|
+
import { PERMISSION_FORWARDING_TIMEOUT_MS } from "#src/authority/permission-forwarding";
|
|
26
|
+
import { requestPermissionDecision } from "#src/authority/permission-prompt-component";
|
|
27
|
+
import { PermissionPrompter } from "#src/authority/permission-prompter";
|
|
28
28
|
import {
|
|
29
29
|
composeServingAnnouncers,
|
|
30
30
|
getServingSessionRegistry,
|
|
31
|
-
} from "
|
|
32
|
-
import { SubagentDetection } from "
|
|
33
|
-
import { subscribeSubagentLifecycle } from "
|
|
34
|
-
import { getSubagentSessionRegistry } from "
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
31
|
+
} from "#src/authority/serving-registry";
|
|
32
|
+
import { SubagentDetection } from "#src/authority/subagent-detection";
|
|
33
|
+
import { subscribeSubagentLifecycle } from "#src/authority/subagent-lifecycle-events";
|
|
34
|
+
import { getSubagentSessionRegistry } from "#src/authority/subagent-registry";
|
|
35
|
+
import { registerPermissionSystemCommand } from "#src/config/config-modal";
|
|
36
|
+
import { getGlobalConfigPath } from "#src/config/config-paths";
|
|
37
|
+
import { ConfigStore } from "#src/config/config-store";
|
|
38
|
+
import { isYoloModeEnabled } from "#src/config/extension-config";
|
|
39
|
+
import { computeExtensionPaths } from "#src/config/extension-paths";
|
|
40
|
+
import { GateRunner } from "#src/handlers/gates/runner";
|
|
41
|
+
import { SkillInputGatePipeline } from "#src/handlers/gates/skill-input-gate-pipeline";
|
|
42
|
+
import { ToolCallGatePipeline } from "#src/handlers/gates/tool-call-gate-pipeline";
|
|
43
|
+
import { createFailClosedToolCall } from "#src/handlers/tool-call-boundary";
|
|
44
|
+
import { DecisionAudit } from "#src/logging/decision-audit";
|
|
45
|
+
import { GateDecisionReporter } from "#src/logging/decision-reporter";
|
|
46
|
+
import { PermissionSessionLogger } from "#src/logging/session-logger";
|
|
47
|
+
import { pathFlavorForPlatform } from "#src/path/path-flavor";
|
|
48
|
+
import { PermissionManager } from "#src/policy/permission-manager";
|
|
49
|
+
import { PermissionResolver } from "#src/policy/permission-resolver";
|
|
50
|
+
import { resolveRenderBudget } from "#src/presentation/dialog-renderer";
|
|
51
|
+
import { LocalPermissionsService } from "#src/service/permissions-service";
|
|
52
|
+
import { PermissionServiceLifecycle } from "#src/service/service-lifecycle";
|
|
53
|
+
import { PermissionSession } from "#src/session/permission-session";
|
|
54
|
+
import { SessionRules } from "#src/session/session-rules";
|
|
55
|
+
import { registerBuiltinToolInputFormatters } from "#src/tool-input/builtin-tool-input-formatters";
|
|
56
|
+
import { ToolAccessExtractorRegistry } from "#src/tool-input/tool-access-extractor-registry";
|
|
57
|
+
import { ToolInputFormatterRegistry } from "#src/tool-input/tool-input-formatter-registry";
|
|
43
58
|
import {
|
|
44
59
|
AgentPrepHandler,
|
|
45
60
|
PermissionGateHandler,
|
|
46
61
|
SessionLifecycleHandler,
|
|
47
62
|
SessionTurnPrep,
|
|
48
63
|
} from "./handlers";
|
|
49
|
-
import { GateRunner } from "./handlers/gates/runner";
|
|
50
|
-
import { SkillInputGatePipeline } from "./handlers/gates/skill-input-gate-pipeline";
|
|
51
|
-
import { ToolCallGatePipeline } from "./handlers/gates/tool-call-gate-pipeline";
|
|
52
|
-
import { createFailClosedToolCall } from "./handlers/tool-call-boundary";
|
|
53
|
-
import { pathFlavorForPlatform } from "./path/path-flavor";
|
|
54
|
-
import { PermissionManager } from "./permission-manager";
|
|
55
|
-
import { PermissionResolver } from "./permission-resolver";
|
|
56
|
-
import { PermissionSession } from "./permission-session";
|
|
57
|
-
import { LocalPermissionsService } from "./permissions-service";
|
|
58
|
-
import { resolveRenderBudget } from "./presentation/dialog-renderer";
|
|
59
64
|
import { getPermissionsService, type PermissionsService } from "./service";
|
|
60
|
-
import { PermissionServiceLifecycle } from "./service-lifecycle";
|
|
61
|
-
import { PermissionSessionLogger } from "./session-logger";
|
|
62
|
-
import { SessionRules } from "./session-rules";
|
|
63
|
-
import { ToolAccessExtractorRegistry } from "./tool-access-extractor-registry";
|
|
64
|
-
import { ToolInputFormatterRegistry } from "./tool-input-formatter-registry";
|
|
65
65
|
|
|
66
66
|
export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
|
|
67
67
|
const agentDir = getAgentDir();
|
|
@@ -318,6 +318,7 @@ export default function piPermissionSystemExtension(pi: ExtensionAPI): void {
|
|
|
318
318
|
session,
|
|
319
319
|
resolver,
|
|
320
320
|
toolRegistry,
|
|
321
|
+
logger,
|
|
321
322
|
);
|
|
322
323
|
|
|
323
324
|
const gateRunner = new GateRunner(
|
|
@@ -3,7 +3,7 @@ import { appendFileSync } from "node:fs";
|
|
|
3
3
|
import {
|
|
4
4
|
EXTENSION_ID,
|
|
5
5
|
type PermissionSystemExtensionConfig,
|
|
6
|
-
} from "
|
|
6
|
+
} from "#src/config/extension-config";
|
|
7
7
|
import { capLogFieldWidths, resolveReviewLogFieldWidth } from "./log-field-cap";
|
|
8
8
|
import {
|
|
9
9
|
OWNER_ONLY_FILE_MODE,
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DEBUG_LOG_FILENAME,
|
|
4
|
+
REVIEW_LOG_FILENAME,
|
|
5
|
+
} from "#src/config/config-paths";
|
|
3
6
|
import {
|
|
4
7
|
ensurePermissionSystemLogsDirectory,
|
|
5
8
|
type PermissionSystemExtensionConfig,
|
|
6
|
-
} from "
|
|
9
|
+
} from "#src/config/extension-config";
|
|
7
10
|
import {
|
|
8
11
|
createPermissionSystemLogger,
|
|
9
12
|
type PermissionSystemLogger,
|
|
@@ -18,13 +21,19 @@ export interface ReviewLogger {
|
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
|
-
*
|
|
22
|
-
* Injected into `
|
|
24
|
+
* Narrowest logging seam — consumers that only write debug-log entries.
|
|
25
|
+
* Injected into `AgentPrepHandler`.
|
|
23
26
|
*/
|
|
24
|
-
export interface
|
|
27
|
+
export interface DebugLogger {
|
|
25
28
|
debug(event: string, details?: Record<string, unknown>): void;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Logging seam for consumers that write both debug and review entries.
|
|
33
|
+
* Injected into `ConfigStore`, `ParentAuthorizer`, and `ForwardedRequestServer`.
|
|
34
|
+
*/
|
|
35
|
+
export interface DebugReviewLogger extends ReviewLogger, DebugLogger {}
|
|
36
|
+
|
|
28
37
|
/**
|
|
29
38
|
* Unified logging + notification surface for handler deps.
|
|
30
39
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PathFlavor } from "
|
|
2
|
-
import { isSafeSystemPath } from "
|
|
1
|
+
import type { PathFlavor } from "./path-flavor";
|
|
2
|
+
import { isSafeSystemPath } from "./safe-system-paths";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Pure geometry: is `canonicalPath` outside `canonicalCwd`?
|
package/src/path/path-flavor.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
type BashTokenShape,
|
|
6
6
|
classifyWin32BashToken,
|
|
7
7
|
} from "#src/access-intent/bash/msys-bash-tokens";
|
|
8
|
-
import type { WildcardMatchOptions } from "#src/wildcard-matcher";
|
|
8
|
+
import type { WildcardMatchOptions } from "#src/policy/wildcard-matcher";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* The resolved product of the single win32-vs-POSIX platform decision: the
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { lstatSync } from "node:fs";
|
|
2
|
-
|
|
3
|
-
import type { PathFlavor } from "#src/path/path-flavor";
|
|
4
|
-
|
|
5
|
-
import { AccessPath } from "./access-intent/access-path";
|
|
2
|
+
import { AccessPath } from "#src/access-intent/access-path";
|
|
6
3
|
import {
|
|
7
4
|
canonicalNormalizePathForComparison,
|
|
8
5
|
normalizePathForComparison,
|
|
9
6
|
normalizePathPolicyLiteral,
|
|
10
|
-
} from "
|
|
11
|
-
import { deriveApprovalPattern } from "./
|
|
12
|
-
import { isPathOutsideWorkingDirectory } from "./path
|
|
13
|
-
import {
|
|
7
|
+
} from "#src/access-intent/path-normalization";
|
|
8
|
+
import { deriveApprovalPattern } from "./approval-pattern";
|
|
9
|
+
import { isPathOutsideWorkingDirectory } from "./path-containment";
|
|
10
|
+
import type { PathFlavor } from "./path-flavor";
|
|
11
|
+
import { isPiInfrastructureRead } from "./pi-infrastructure-read";
|
|
14
12
|
|
|
15
13
|
/**
|
|
16
14
|
* The interpreted effect of a literal `cd` target on the effective base, under
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
2
|
import { READ_ONLY_PATH_BEARING_TOOLS } from "#src/access-intent/path-surfaces";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
3
|
+
import { wildcardMatch } from "#src/policy/wildcard-matcher";
|
|
4
|
+
import { expandHomePath } from "./expand-home";
|
|
5
|
+
import type { PathFlavor } from "./path-flavor";
|
|
6
6
|
|
|
7
7
|
function containsGlobChars(value: string): boolean {
|
|
8
8
|
return value.includes("*") || value.includes("?");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { surfaceFamilyMembers } from "#src/access-intent/path-surfaces";
|
|
2
|
+
import type { FlatPermissionConfig, PatternValue } from "#src/types";
|
|
3
|
+
import { isDenyWithReason, isPermissionState } from "#src/types";
|
|
2
4
|
import type { Rule, Ruleset } from "./rule";
|
|
3
|
-
import type { FlatPermissionConfig, PatternValue } from "./types";
|
|
4
|
-
import { isDenyWithReason, isPermissionState } from "./types";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A surface's value in a flat permission config: a catch-all or a pattern map.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { SessionGrantWidth } from "#src/approval-grant";
|
|
2
1
|
import type { DecisionSource } from "#src/authority/decision-source";
|
|
3
2
|
import type { PermissionPromptDecision } from "#src/authority/permission-dialog";
|
|
3
|
+
import type { SessionGrantWidth } from "#src/session/approval-grant";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Result of applying the permission gate.
|
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
import { join } from "node:path";
|
|
2
|
-
import type { ResolvedAccessIntent } from "
|
|
3
|
-
import { normalizeInput } from "
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import type { ResolvedAccessIntent } from "#src/access-intent/access-intent";
|
|
3
|
+
import { normalizeInput } from "#src/access-intent/input-normalizer";
|
|
4
|
+
import {
|
|
5
|
+
PATH_SURFACES,
|
|
6
|
+
surfaceFamilyOf,
|
|
7
|
+
} from "#src/access-intent/path-surfaces";
|
|
8
|
+
import { classifyToolKind } from "#src/access-intent/tool-kind";
|
|
6
9
|
import {
|
|
7
10
|
getGlobalConfigPath,
|
|
8
11
|
getProjectAgentsDir,
|
|
9
12
|
getProjectConfigPath,
|
|
10
|
-
} from "
|
|
11
|
-
import { normalizeFlatConfig } from "./normalize";
|
|
12
|
-
import { type PathFlavor, posixPathFlavor } from "./path/path-flavor";
|
|
13
|
+
} from "#src/config/config-paths";
|
|
13
14
|
import {
|
|
14
15
|
FilePolicyLoader,
|
|
15
16
|
type PolicyLoader,
|
|
16
17
|
type PolicyLoaderOptions,
|
|
17
18
|
type ResolvedPolicyPaths,
|
|
18
|
-
} from "
|
|
19
|
+
} from "#src/config/policy-loader";
|
|
20
|
+
import { type PathFlavor, posixPathFlavor } from "#src/path/path-flavor";
|
|
21
|
+
import type {
|
|
22
|
+
FlatPermissionConfig,
|
|
23
|
+
PermissionCheckResult,
|
|
24
|
+
PermissionState,
|
|
25
|
+
} from "#src/types";
|
|
26
|
+
import { isPermissionState } from "#src/types";
|
|
27
|
+
import { normalizeFlatConfig } from "./normalize";
|
|
19
28
|
import type { Rule, RuleOrigin, Ruleset } from "./rule";
|
|
20
29
|
import {
|
|
21
30
|
evaluate,
|
|
@@ -31,12 +40,6 @@ import {
|
|
|
31
40
|
synthesizeBaseline,
|
|
32
41
|
synthesizeDefaults,
|
|
33
42
|
} from "./synthesize";
|
|
34
|
-
import type {
|
|
35
|
-
FlatPermissionConfig,
|
|
36
|
-
PermissionCheckResult,
|
|
37
|
-
PermissionState,
|
|
38
|
-
} from "./types";
|
|
39
|
-
import { isPermissionState } from "./types";
|
|
40
43
|
|
|
41
44
|
const SPECIAL_PERMISSION_KEYS = new Set(["external_directory", "path"]);
|
|
42
45
|
|
|
@@ -448,4 +451,7 @@ function deriveSource(
|
|
|
448
451
|
}
|
|
449
452
|
|
|
450
453
|
// Re-export types that external modules import from this file.
|
|
451
|
-
export type {
|
|
454
|
+
export type {
|
|
455
|
+
PolicyLoader,
|
|
456
|
+
ResolvedPolicyPaths,
|
|
457
|
+
} from "#src/config/policy-loader";
|
|
@@ -2,14 +2,14 @@ import type {
|
|
|
2
2
|
AccessIntent,
|
|
3
3
|
PathValuesAccessIntent,
|
|
4
4
|
ResolvedAccessIntent,
|
|
5
|
-
} from "
|
|
6
|
-
import { surfaceFamilyMembers } from "
|
|
5
|
+
} from "#src/access-intent/access-intent";
|
|
6
|
+
import { surfaceFamilyMembers } from "#src/access-intent/path-surfaces";
|
|
7
|
+
import type { SkillPermissionChecker } from "#src/exposure/skill-prompt-sanitizer";
|
|
8
|
+
import type { SessionRules } from "#src/session/session-rules";
|
|
9
|
+
import type { PermissionCheckResult, PermissionState } from "#src/types";
|
|
7
10
|
import type { ScopedPermissionManager } from "./permission-manager";
|
|
8
11
|
import { mostRestrictiveOf } from "./restrictiveness";
|
|
9
12
|
import type { Rule } from "./rule";
|
|
10
|
-
import type { SessionRules } from "./session-rules";
|
|
11
|
-
import type { SkillPermissionChecker } from "./skill-prompt-sanitizer";
|
|
12
|
-
import type { PermissionCheckResult, PermissionState } from "./types";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* Answers an {@link AccessIntent} a gate emits, applying the current session
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { PATH_SURFACES } from "#src/access-intent/path-surfaces";
|
|
2
|
+
import { expandHomePath } from "#src/path/expand-home";
|
|
1
3
|
import type { PathFlavor } from "#src/path/path-flavor";
|
|
2
|
-
|
|
3
|
-
import { PATH_SURFACES } from "./access-intent/path-surfaces";
|
|
4
|
-
import { expandHomePath } from "./expand-home";
|
|
5
|
-
import type { PermissionState } from "./types";
|
|
4
|
+
import type { PermissionState } from "#src/types";
|
|
6
5
|
import { type WildcardMatchOptions, wildcardMatch } from "./wildcard-matcher";
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { expandDirectionalSugar } from "#src/normalize";
|
|
2
|
-
import { mergeFlatPermissions } from "#src/permission-merge";
|
|
3
|
-
import type { RuleOrigin } from "#src/rule";
|
|
4
1
|
import type { FlatPermissionConfig, ScopeConfig } from "#src/types";
|
|
2
|
+
import { expandDirectionalSugar } from "./normalize";
|
|
3
|
+
import { mergeFlatPermissions } from "./permission-merge";
|
|
4
|
+
import type { RuleOrigin } from "./rule";
|
|
5
5
|
|
|
6
6
|
/** Surface → (pattern → originating scope). */
|
|
7
7
|
type OriginMap = Map<string, Map<string, RuleOrigin>>;
|
|
@@ -2,19 +2,19 @@ import {
|
|
|
2
2
|
type DecisionSource,
|
|
3
3
|
effectiveDecider,
|
|
4
4
|
} from "#src/authority/decision-source";
|
|
5
|
-
import { EXTENSION_ID } from "#src/extension-config";
|
|
6
|
-
import {
|
|
5
|
+
import { EXTENSION_ID } from "#src/config/extension-config";
|
|
6
|
+
import type { BashCommandContext } from "#src/types";
|
|
7
|
+
import { DEFAULT_RENDER_BUDGET } from "./dialog-renderer";
|
|
7
8
|
import {
|
|
8
9
|
describeBashCommandContext,
|
|
9
10
|
flaggedElementLabel,
|
|
10
11
|
flaggedElements,
|
|
11
|
-
} from "
|
|
12
|
+
} from "./fact-vocabulary";
|
|
12
13
|
import {
|
|
13
14
|
allEvidence,
|
|
14
15
|
findEvidence,
|
|
15
16
|
type PromptPayload,
|
|
16
|
-
} from "
|
|
17
|
-
import type { BashCommandContext } from "#src/types";
|
|
17
|
+
} from "./prompt-payload";
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* The agent-facing render of a refused permission ask (ADR 0011 §7).
|