@nklisch/pi-enhanced 0.1.2 → 0.1.4
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 +7 -0
- package/README.md +3 -2
- package/node_modules/@nklisch/pi-clearance/README.md +10 -5
- package/node_modules/@nklisch/pi-clearance/docs/ARCHITECTURE.md +12 -7
- package/node_modules/@nklisch/pi-clearance/docs/CONFIGURATION.md +25 -35
- package/node_modules/@nklisch/pi-clearance/docs/DEVELOPER_GUIDE.md +30 -30
- package/node_modules/@nklisch/pi-clearance/docs/PACK_AUTHORING.md +5 -4
- package/node_modules/@nklisch/pi-clearance/docs/PRINCIPLES.md +14 -10
- package/node_modules/@nklisch/pi-clearance/docs/REFERENCE_PATTERNS.md +1 -1
- package/node_modules/@nklisch/pi-clearance/docs/REVIEWER_PROMPTS.md +12 -8
- package/node_modules/@nklisch/pi-clearance/docs/RULE_PACKS.md +1 -1
- package/node_modules/@nklisch/pi-clearance/docs/SPEC.md +7 -6
- package/node_modules/@nklisch/pi-clearance/docs/TUNE.md +2 -2
- package/node_modules/@nklisch/pi-clearance/docs/USER_GUIDE.md +7 -3
- package/node_modules/@nklisch/pi-clearance/docs/VISION.md +3 -3
- package/node_modules/@nklisch/pi-clearance/native/clearance-core.darwin-arm64.node +0 -0
- package/node_modules/@nklisch/pi-clearance/native/clearance-core.darwin-x64.node +0 -0
- package/node_modules/@nklisch/pi-clearance/native/clearance-core.linux-arm64-gnu.node +0 -0
- package/node_modules/@nklisch/pi-clearance/native/clearance-core.linux-x64-gnu.node +0 -0
- package/node_modules/@nklisch/pi-clearance/native/clearance-core.win32-arm64-msvc.node +0 -0
- package/node_modules/@nklisch/pi-clearance/native/clearance-core.win32-x64-msvc.node +0 -0
- package/node_modules/@nklisch/pi-clearance/package.json +9 -5
- package/node_modules/@nklisch/pi-clearance/src/config/config-command-plans.ts +79 -3
- package/node_modules/@nklisch/pi-clearance/src/config/config-command-writer.ts +7 -1
- package/node_modules/@nklisch/pi-clearance/src/config/defaults.ts +42 -0
- package/node_modules/@nklisch/pi-clearance/src/config/gated-tools.ts +7 -0
- package/node_modules/@nklisch/pi-clearance/src/config/loader.ts +7 -1
- package/node_modules/@nklisch/pi-clearance/src/config/pack-enablement-writer.ts +1 -0
- package/node_modules/@nklisch/pi-clearance/src/config/paths.ts +14 -3
- package/node_modules/@nklisch/pi-clearance/src/config/persistence.ts +135 -0
- package/node_modules/@nklisch/pi-clearance/src/config/schema.ts +74 -26
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialCase.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialCaseCategory.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialCaseExpectation.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialCaseResult.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialCaseResultOutcome.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialCaseSource.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialValidationReport.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/AdversarialValidationStatus.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashBlock.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashCommandShape.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashConditionalArm.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashControlConstruct.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashFlag.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashForLoopKeywordSpans.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashIteratorEntry.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashIteratorEntryKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashListOperator.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashLoopVariableReference.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashPathFact.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashPathFactContext.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashPathFactProvenance.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashPathFactProvenanceEntry.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashPathFacts.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashPipeline.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashStage.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BashStageProgram.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/BlockOperator.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CapturedOutcome.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CommandFamilyKey.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CommandFamilySummary.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CompileError.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CompositionOperator.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CompoundBodyReason.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CompoundFeatureReason.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CompoundForm.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CompoundIteratorReason.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusEntry.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusExpectedLabel.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusFidelity.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusQueryModel.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusQuerySummary.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusQuerySummarySnapshot.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusRecord.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CorpusSource.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/CountByLabel.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/Decision.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/DecisionEffect.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/DecisionProvenance.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/DecisionSource.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/DiagnosticSeverity.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/EffectivePolicy.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/EmbeddedShellProjection.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/EnvironmentAssignment.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/IteratorSourceKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/LoopQuoteKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/LoopVariableUnknownReason.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/MatcherExpr.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/MutationShapeKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/MutationTrustBoundaryClassification.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/MutationTrustBoundaryKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PackCompileResult.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PackWarningLevel.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ParsedEvidence.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ParsedShapeSummary.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathAccess.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathFactProjectScope.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathFactsRequirement.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathFactsResolvedConfig.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathNormalization.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathScope.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathScopeMatcherExpr.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathScopeMatcherMode.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathUnknownReason.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PathUsageKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PiBuiltinToolOperation.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PiBuiltinToolPathInput.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PiBuiltinToolShape.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PiBuiltinToolSpec.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PiFileMutationToolName.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PiToolMutationFacts.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PolicyPack.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PolicyPackDocLink.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PolicyPackExample.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PolicyPackMetadata.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PolicyPackWarning.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/PolicyRule.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ProposalNotRunReason.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ProposalNotRunSeverity.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/QuoteKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/Redirect.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/RedirectStream.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/RedirectTargetKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayCorpus.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDelta.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDeltaBlockedSummary.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDeltaChangedRecord.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDeltaFamily.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDeltaImprovement.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDeltaRegression.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDeltaStatus.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayDeltaTransitionCount.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayPathFacts.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayReviewerMode.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayReviewerOutcome.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayStatus.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ReplayedDecision.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ShapeDiagnostic.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/SourceFidelity.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/SourceSpan.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/Substitution.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/SubstitutionKind.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ToolCallIdentity.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ToolPathAccess.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ToolPathFact.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ToolPathFactContext.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ToolPathFacts.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ToolPathUsage.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/ToolShape.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/UnknownPathBehavior.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/UnknownToolShape.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/contracts/index.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/index.ts +33 -2
- package/node_modules/@nklisch/pi-clearance/src/native/loader.ts +29 -42
- package/node_modules/@nklisch/pi-clearance/src/replay/reviewer-config-proposals.ts +7 -4
- package/node_modules/@nklisch/pi-clearance/src/runtime/allow-request-message.ts +21 -0
- package/node_modules/@nklisch/pi-clearance/src/runtime/auto-reviewer-read-models.ts +165 -8
- package/node_modules/@nklisch/pi-clearance/src/runtime/command-registry.ts +1 -1
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/allow.ts +26 -2
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/packs.ts +6 -6
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/scope.ts +5 -5
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/actions.ts +11 -0
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/dispatcher.ts +274 -1
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/model-options.ts +52 -0
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/native-ui.ts +54 -67
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/panels/reviewer.ts +19 -3
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/panels/scope.ts +2 -11
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/panels.ts +10 -1
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings/read-model.ts +47 -13
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/settings.ts +32 -37
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/status.ts +3 -0
- package/node_modules/@nklisch/pi-clearance/src/runtime/config-commands/types.ts +14 -5
- package/node_modules/@nklisch/pi-clearance/src/runtime/handler.ts +36 -0
- package/node_modules/@nklisch/pi-clearance/src/runtime/mode-prompt.ts +0 -1
- package/node_modules/@nklisch/pi-clearance/src/runtime/model-adapter.ts +5 -1
- package/node_modules/@nklisch/pi-clearance/src/runtime/reviewer-context.ts +73 -10
- package/node_modules/@nklisch/pi-clearance/src/runtime/reviewer-prompts.ts +186 -175
- package/node_modules/@nklisch/pi-clearance/src/runtime/reviewer.ts +26 -6
- package/node_modules/@nklisch/pi-plugins/dist/infrastructure/state/local-lock-filesystem.d.ts +23 -1
- package/node_modules/@nklisch/pi-plugins/dist/infrastructure/state/local-lock-filesystem.js +46 -50
- package/node_modules/@nklisch/pi-plugins/dist/infrastructure/state/local-lock-filesystem.js.map +1 -1
- package/node_modules/@nklisch/pi-plugins/dist/runtime/mcp/pi-mcp-adapter-package.js +2 -2
- package/node_modules/@nklisch/pi-plugins/dist/runtime/mcp/pi-mcp-adapter-runtime.js +2 -2
- package/node_modules/@nklisch/pi-plugins/dist/runtime/subagents/pi-subagents-lifecycle.js +1 -1
- package/node_modules/@nklisch/pi-plugins/dist/runtime/subagents/pi-subagents-package.js +2 -2
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/README.md +41 -31
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/dist/public.d.ts +2 -1
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/FORK-MAINTENANCE.md +17 -11
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/VISION.md +14 -7
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/architecture/architecture.md +11 -19
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/docs/comparison-with-upstream.md +58 -53
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/package.json +2 -2
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/config/agent-type-resolution.ts +43 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/config/agent-types.ts +11 -6
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/config/custom-agents.ts +13 -6
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/config/default-agents.ts +0 -52
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/config/thinking-levels.ts +12 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/handlers/interrupt.ts +5 -2
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/handlers/lifecycle.ts +3 -3
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/index.ts +7 -6
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/lifecycle/create-subagent-session.ts +7 -2
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/lifecycle/parent-snapshot.ts +11 -3
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/lifecycle/subagent-manager.ts +26 -56
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/lifecycle/subagent-session.ts +48 -9
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/lifecycle/subagent-state.ts +32 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/lifecycle/subagent.ts +105 -17
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/observation/composite-subagent-observer.ts +4 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/observation/notification.ts +50 -46
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/observation/renderer.ts +1 -1
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/observation/subagent-events-observer.ts +15 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/runtime.ts +2 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/service/service-adapter.ts +35 -6
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/service/service.ts +1 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/session/model-label.ts +19 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/session/prompts.ts +24 -1
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/session/session-config.ts +11 -6
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/settings.ts +70 -3
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/agent-tool.ts +27 -10
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/background-spawner.ts +6 -2
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/foreground-runner.ts +12 -3
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/get-result-report.ts +17 -3
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/get-result-tool.ts +13 -20
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/result-renderer.ts +6 -1
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/spawn-config.ts +16 -16
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/tools/steer-tool.ts +12 -4
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/types.ts +2 -2
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/ui/agent-widget.ts +24 -11
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/ui/display.ts +10 -7
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/ui/glyphs.ts +7 -0
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/ui/session-navigation.ts +34 -25
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/ui/session-navigator.ts +30 -10
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/ui/subagents-settings.ts +58 -13
- package/node_modules/@nklisch/pi-plugins/node_modules/@nklisch/pi-subagents/src/ui/widget-renderer.ts +32 -19
- package/node_modules/@nklisch/pi-plugins/package.json +3 -3
- package/package.json +1 -1
- package/test/verify-bundle.mjs +28 -1
|
@@ -1,77 +1,82 @@
|
|
|
1
1
|
# Comparison with upstream
|
|
2
2
|
|
|
3
|
-
`@
|
|
4
|
-
The original design — autonomous subagent dispatch, the live widget, the conversation viewer, custom agent types — is the foundation everything here builds on.
|
|
3
|
+
`@nklisch/pi-subagents` is a maintained fork of `@gotgenes/pi-subagents`, which began as a hard fork of [`@tintinweb/pi-subagents`](https://github.com/tintinweb/pi-subagents). This page explains which ideas this fork preserves, adapts, or leaves upstream.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
It follows its own architecture, does not track upstream as a merge target, and cherry-picks upstream fixes only when they fit its scope.
|
|
8
|
-
This document compares the fork against the current upstream release so you can choose between them.
|
|
5
|
+
The source tree was reviewed against `@gotgenes/pi-subagents` 19.2.1 and `@tintinweb/pi-subagents` 0.14.3 plus its unreleased changelog. The local package version remains independently managed; see [Fork maintenance](./FORK-MAINTENANCE.md) for provenance and release rules.
|
|
9
6
|
|
|
10
|
-
|
|
7
|
+
## Shared core
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
All three implementations provide in-process foreground and background agents, custom agent definitions, concurrency control, steering, result retrieval, session resume, model selection, thinking control, and completion notifications.
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
| --------------- | ------------------------------- | --------------------------------------- |
|
|
16
|
-
| Philosophy | Minimal, composable core | Batteries-included, all-in-one |
|
|
17
|
-
| Pi peer scope | `@earendil-works/pi-*` (>=0.75) | `@earendil-works/pi-*` (>=0.74) |
|
|
18
|
-
| Spawn tool name | `subagent` | `Agent` |
|
|
19
|
-
| Runtime deps | `@sinclair/typebox` | `@sinclair/typebox`, `croner`, `nanoid` |
|
|
20
|
-
| License | MIT | MIT |
|
|
11
|
+
The direct `gotgenes` lineage and this fork also share a focused-core architecture:
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
- typed cross-extension service access;
|
|
14
|
+
- child-session lifecycle events;
|
|
15
|
+
- workspace and permission integration through companion packages;
|
|
16
|
+
- native read-only session transcripts;
|
|
17
|
+
- no built-in scheduling, memory, worktrees, or event RPC.
|
|
24
18
|
|
|
25
|
-
##
|
|
19
|
+
## What this fork preserves beyond direct upstream
|
|
26
20
|
|
|
27
|
-
|
|
21
|
+
This fork retains several contracts that must survive selective upstream ports:
|
|
28
22
|
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
-
|
|
23
|
+
- ordered lifecycle interception for prompt, result, and continuation decisions;
|
|
24
|
+
- exact `provider/id` and elapsed or final runtime on every operator status surface;
|
|
25
|
+
- a typed service and deterministic child-session lifecycle;
|
|
26
|
+
- only `general-purpose` and `Explore` as built-in agents;
|
|
27
|
+
- model runtime inheritance for runtime-registered providers and authentication;
|
|
28
|
+
- inherited extension tools through a registration-open denylist, with recursive orchestration tools excluded;
|
|
29
|
+
- provider terminal failures reported as failures instead of successful empty or stale results.
|
|
33
30
|
|
|
34
|
-
|
|
31
|
+
A mechanical rebase is unsafe because direct upstream may change or remove these surfaces.
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
It keeps several subsystems built in that this fork deliberately removed or delegated:
|
|
33
|
+
## Reliability changes adapted from direct upstream
|
|
38
34
|
|
|
39
|
-
|
|
40
|
-
| ----------------------- | ------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
-
| Tool restrictions | `disallowed_tools` frontmatter (denylist) | Delegated — `permission:` via [`@gotgenes/pi-permission-system`](https://github.com/gotgenes/pi-packages/tree/main/packages/pi-permission-system) |
|
|
42
|
-
| Worktree isolation | Built-in | Delegated — [`@gotgenes/pi-subagents-worktrees`](https://github.com/gotgenes/pi-packages/tree/main/packages/pi-subagents-worktrees) |
|
|
43
|
-
| Persistent agent memory | `memory:` frontmatter (project / local / user) | Removed |
|
|
44
|
-
| Skill preloading | `skills:` frontmatter (preload named skills) | Removed — children always inherit the parent's skills |
|
|
45
|
-
| Scheduling | Cron / interval / one-shot subagents (`schedule`) | Removed |
|
|
46
|
-
| Cross-extension control | `subagents:rpc:*` event RPC | Replaced by a typed service (below) |
|
|
47
|
-
| Model-scope enforcement | `enabledModels` allowlist validation | Not included |
|
|
48
|
-
| Notifications | Smart group-join consolidation | Individual per-agent notifications |
|
|
35
|
+
This fork selectively carries the useful 18.1–19.2 reliability work:
|
|
49
36
|
|
|
50
|
-
|
|
37
|
+
- queued and resumed runs are awaitable through the current record promise;
|
|
38
|
+
- interrupting `get_subagent_result(wait: true)` ends only the wait;
|
|
39
|
+
- queued stops follow the terminal lifecycle and state that no work started;
|
|
40
|
+
- consumption-aware retention keeps terminal records for the parent session while releasing heavy live sessions on separate consumed and unconsumed windows;
|
|
41
|
+
- completion notifications wait for the parent `agent_settled` boundary and recheck consumption;
|
|
42
|
+
- parent ESC abort-all behavior is configurable;
|
|
43
|
+
- resumed turns emit `subagents:resumed`;
|
|
44
|
+
- contradictory inherited cwd footer text is removed for workspace-backed children;
|
|
45
|
+
- terminal glyphs and XML escaping are safe across common terminal and structured-message contexts.
|
|
51
46
|
|
|
52
|
-
|
|
47
|
+
These changes require `@earendil-works/pi-coding-agent >=0.80.5`.
|
|
53
48
|
|
|
54
|
-
|
|
55
|
-
- **Child-session lifecycle events** — `subagents:child:spawning` / `session-created` / `completed` / `disposed`, with `session-created` firing synchronously before `bindExtensions()` so consumers can register the child session deterministically.
|
|
56
|
-
- **`<active_agent>` system-prompt tag** — lets [`@gotgenes/pi-permission-system`](https://github.com/gotgenes/pi-packages/tree/main/packages/pi-permission-system) resolve per-agent `permission:` frontmatter (allow / ask / deny — richer than a binary denylist) inside the child session.
|
|
57
|
-
- **Companion packages** — permission policy and worktree isolation live in dedicated packages rather than the core.
|
|
58
|
-
- **Re-architected codebase** — decomposed into seven domains behind a typed public API boundary, backed by ~994 tests.
|
|
49
|
+
## Ideas adapted from the original upstream
|
|
59
50
|
|
|
60
|
-
|
|
51
|
+
The original `tintinweb` project remains the broader product laboratory. This fork adapted a narrow subset that fits its focused-core direction:
|
|
61
52
|
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
- final assistant `stopReason` classification for provider errors and empty output-limit failures;
|
|
54
|
+
- modern parent `ModelRuntime` forwarding;
|
|
55
|
+
- the `max` thinking level in model-facing and human-facing descriptions;
|
|
56
|
+
- optional fail-closed unknown-agent resolution;
|
|
57
|
+
- `.agents/agents` as a read-only shared project discovery tier.
|
|
64
58
|
|
|
65
|
-
|
|
59
|
+
## Capabilities intentionally left upstream
|
|
66
60
|
|
|
67
|
-
|
|
61
|
+
| Capability | `@tintinweb/pi-subagents` | This fork |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| Nested subagent delegation | Available or under active development | Excluded; recursion remains disabled |
|
|
64
|
+
| Scheduling | Cron, interval, and one-shot jobs | Separate extension concern |
|
|
65
|
+
| Persistent agent memory | Built in | Excluded |
|
|
66
|
+
| Worktree isolation | Built in | Companion workspace provider |
|
|
67
|
+
| Tool permission policy | Built-in selectors and denylist | Companion permission layer plus built-in denylist |
|
|
68
|
+
| Fleet/editor UI | Broad agent management UI | Narrow widget, settings, and native transcript viewer |
|
|
69
|
+
| Cross-extension RPC | Event RPC | Typed service contract |
|
|
70
|
+
| Transcript opt-out | Sidecar output control | Not adopted; this fork uses official persisted Pi sessions |
|
|
68
71
|
|
|
69
|
-
|
|
72
|
+
These are product choices, not missing parity work. Adopting one requires a new architectural decision and a concrete consumer need.
|
|
70
73
|
|
|
71
|
-
|
|
74
|
+
## Choosing an implementation
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
2. Post-`bindExtensions` active-tool re-filter — [tintinweb/pi-subagents#72](https://github.com/tintinweb/pi-subagents/pull/72).
|
|
75
|
-
3. `<active_agent>` system-prompt tag — [tintinweb/pi-subagents#73](https://github.com/tintinweb/pi-subagents/pull/73).
|
|
76
|
+
Use `@tintinweb/pi-subagents` when you want a batteries-included extension with scheduling, memory, nested delegation, worktrees, and its full management UI.
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
Use `@gotgenes/pi-subagents` when you want the direct focused-core lineage without this fork's lifecycle interception and status-display guarantees.
|
|
79
|
+
|
|
80
|
+
Use `@nklisch/pi-subagents` when companion extensions need deterministic lifecycle decisions, inherited runtime and extension tooling, exact model/runtime visibility, and the selective reliability contracts described above.
|
|
81
|
+
|
|
82
|
+
Tool names and configuration are not drop-in portable across all three projects. Review agent definitions and orchestration prompts before switching packages.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nklisch/pi-subagents",
|
|
3
|
-
"version": "18.0
|
|
3
|
+
"version": "18.1.0-nklisch.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@earendil-works/pi-ai": ">=0.75.0",
|
|
55
|
-
"@earendil-works/pi-coding-agent": ">=0.
|
|
55
|
+
"@earendil-works/pi-coding-agent": ">=0.80.5",
|
|
56
56
|
"@earendil-works/pi-tui": ">=0.75.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { AgentTypeRegistry } from "#src/config/agent-types";
|
|
2
|
+
|
|
3
|
+
export interface AgentTypeResolution {
|
|
4
|
+
type: string;
|
|
5
|
+
requestedType: string;
|
|
6
|
+
fellBack: boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type AgentTypeResolutionResult = AgentTypeResolution | { error: string };
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Resolve caller-supplied agent identity once, before prompt/model/tool policy.
|
|
13
|
+
* Unknown names follow the configured fallback; disabled or ambiguous names do
|
|
14
|
+
* not silently acquire another agent's identity.
|
|
15
|
+
*/
|
|
16
|
+
export function resolveDispatchAgentType(
|
|
17
|
+
requestedType: string,
|
|
18
|
+
registry: AgentTypeRegistry,
|
|
19
|
+
fallback: string | false | undefined,
|
|
20
|
+
): AgentTypeResolutionResult {
|
|
21
|
+
const resolved = registry.resolveType(requestedType);
|
|
22
|
+
if (resolved) {
|
|
23
|
+
if (!registry.isValidType(resolved)) return { error: `Agent type "${resolved}" is disabled` };
|
|
24
|
+
return { type: resolved, requestedType, fellBack: false };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (registry.isCaseAmbiguous(requestedType)) {
|
|
28
|
+
return { error: `Agent type "${requestedType}" is ambiguous. Use exact casing.` };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (fallback === false) {
|
|
32
|
+
return {
|
|
33
|
+
error: `Unknown agent type "${requestedType}". Available types: ${registry.getAvailableTypes().join(", ")}`,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const fallbackName = fallback ?? "general-purpose";
|
|
38
|
+
const resolvedFallback = registry.resolveType(fallbackName);
|
|
39
|
+
if (!resolvedFallback || !registry.isValidType(resolvedFallback)) {
|
|
40
|
+
return { error: `Configured fallback agent "${fallbackName}" is unknown or disabled` };
|
|
41
|
+
}
|
|
42
|
+
return { type: resolvedFallback, requestedType, fellBack: true };
|
|
43
|
+
}
|
|
@@ -31,8 +31,8 @@ export interface AgentConfigLookup {
|
|
|
31
31
|
export class AgentTypeRegistry implements AgentConfigLookup {
|
|
32
32
|
private agents = new Map<string, AgentConfig>();
|
|
33
33
|
|
|
34
|
-
/** The
|
|
35
|
-
static readonly DEFAULT_AGENT_NAMES = ["general-purpose", "Explore"
|
|
34
|
+
/** The two embedded default agent names. */
|
|
35
|
+
static readonly DEFAULT_AGENT_NAMES = ["general-purpose", "Explore"] as const;
|
|
36
36
|
|
|
37
37
|
constructor(private loadUserAgents: () => Map<string, AgentConfig>) {
|
|
38
38
|
this.reload();
|
|
@@ -83,6 +83,13 @@ export class AgentTypeRegistry implements AgentConfigLookup {
|
|
|
83
83
|
.map(([name]) => name);
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
/** Whether a non-exact case-insensitive lookup has more than one candidate. */
|
|
87
|
+
isCaseAmbiguous(type: string): boolean {
|
|
88
|
+
if (this.agents.has(type)) return false;
|
|
89
|
+
const lower = type.toLowerCase();
|
|
90
|
+
return [...this.agents.keys()].filter((key) => key.toLowerCase() === lower).length > 1;
|
|
91
|
+
}
|
|
92
|
+
|
|
86
93
|
/** Check if a type is valid and enabled (case-insensitive). */
|
|
87
94
|
isValidType(type: string): boolean {
|
|
88
95
|
const key = this.resolveKey(type);
|
|
@@ -122,10 +129,8 @@ export class AgentTypeRegistry implements AgentConfigLookup {
|
|
|
122
129
|
private resolveKey(name: string): string | undefined {
|
|
123
130
|
if (this.agents.has(name)) return name;
|
|
124
131
|
const lower = name.toLowerCase();
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
return undefined;
|
|
132
|
+
const matches = [...this.agents.keys()].filter((key) => key.toLowerCase() === lower);
|
|
133
|
+
return matches.length === 1 ? matches[0] : undefined;
|
|
129
134
|
}
|
|
130
135
|
}
|
|
131
136
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* custom-agents.ts — Load user-defined agents from project
|
|
2
|
+
* custom-agents.ts — Load user-defined agents from global, shared project, and Pi project locations.
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
@@ -12,24 +12,31 @@ import type { AgentConfig, ThinkingLevel } from "#src/types";
|
|
|
12
12
|
/**
|
|
13
13
|
* Scan for custom agent .md files from multiple locations.
|
|
14
14
|
* Discovery hierarchy (higher priority wins):
|
|
15
|
-
* 1.
|
|
16
|
-
* 2.
|
|
15
|
+
* 1. Pi project: <cwd>/.pi/agents/*.md
|
|
16
|
+
* 2. Shared project: <cwd>/.agents/agents/*.md
|
|
17
|
+
* 3. Global: $PI_CODING_AGENT_DIR/agents/*.md
|
|
17
18
|
*
|
|
18
19
|
* Project-level agents override global ones with the same name.
|
|
19
20
|
* Any name is allowed — names matching defaults (e.g. "Explore") override them.
|
|
20
21
|
*/
|
|
21
22
|
export function loadCustomAgents(cwd: string): Map<string, AgentConfig> {
|
|
22
23
|
const globalDir = join(getAgentDir(), "agents");
|
|
24
|
+
const sharedProjectDir = join(cwd, ".agents", "agents");
|
|
23
25
|
const projectDir = join(cwd, ".pi", "agents");
|
|
24
26
|
|
|
25
27
|
const agents = new Map<string, AgentConfig>();
|
|
26
|
-
loadFromDir(globalDir, agents, "global");
|
|
27
|
-
loadFromDir(
|
|
28
|
+
loadFromDir(globalDir, agents, "global");
|
|
29
|
+
loadFromDir(sharedProjectDir, agents, "shared-project");
|
|
30
|
+
loadFromDir(projectDir, agents, "project");
|
|
28
31
|
return agents;
|
|
29
32
|
}
|
|
30
33
|
|
|
31
34
|
/** Load agent configs from a directory into the map. */
|
|
32
|
-
function loadFromDir(
|
|
35
|
+
function loadFromDir(
|
|
36
|
+
dir: string,
|
|
37
|
+
agents: Map<string, AgentConfig>,
|
|
38
|
+
source: "project" | "shared-project" | "global",
|
|
39
|
+
): void {
|
|
33
40
|
if (!existsSync(dir)) return;
|
|
34
41
|
|
|
35
42
|
let files: string[];
|
|
@@ -65,56 +65,4 @@ Use Bash ONLY for read-only operations: ls, git status, git log, git diff, find,
|
|
|
65
65
|
isDefault: true,
|
|
66
66
|
},
|
|
67
67
|
],
|
|
68
|
-
[
|
|
69
|
-
"Plan",
|
|
70
|
-
{
|
|
71
|
-
name: "Plan",
|
|
72
|
-
displayName: "Plan",
|
|
73
|
-
description: "Software architect for implementation planning (read-only)",
|
|
74
|
-
toolGuideline: "- Use Plan for architecture and implementation planning.",
|
|
75
|
-
builtinToolNames: READ_ONLY_TOOLS,
|
|
76
|
-
systemPrompt: `# CRITICAL: READ-ONLY MODE - NO FILE MODIFICATIONS
|
|
77
|
-
You are a software architect and planning specialist.
|
|
78
|
-
Your role is EXCLUSIVELY to explore the codebase and design implementation plans.
|
|
79
|
-
You do NOT have access to file editing tools — attempting to edit files will fail.
|
|
80
|
-
|
|
81
|
-
You are STRICTLY PROHIBITED from:
|
|
82
|
-
- Creating new files
|
|
83
|
-
- Modifying existing files
|
|
84
|
-
- Deleting files
|
|
85
|
-
- Moving or copying files
|
|
86
|
-
- Creating temporary files anywhere, including /tmp
|
|
87
|
-
- Using redirect operators (>, >>, |) or heredocs to write to files
|
|
88
|
-
- Running ANY commands that change system state
|
|
89
|
-
|
|
90
|
-
# Planning Process
|
|
91
|
-
1. Understand requirements
|
|
92
|
-
2. Explore thoroughly (read files, find patterns, understand architecture)
|
|
93
|
-
3. Design solution based on your assigned perspective
|
|
94
|
-
4. Detail the plan with step-by-step implementation strategy
|
|
95
|
-
|
|
96
|
-
# Requirements
|
|
97
|
-
- Consider trade-offs and architectural decisions
|
|
98
|
-
- Identify dependencies and sequencing
|
|
99
|
-
- Anticipate potential challenges
|
|
100
|
-
- Follow existing patterns where appropriate
|
|
101
|
-
|
|
102
|
-
# Tool Usage
|
|
103
|
-
- Use the find tool for file pattern matching (NOT the bash find command)
|
|
104
|
-
- Use the grep tool for content search (NOT bash grep/rg command)
|
|
105
|
-
- Use the read tool for reading files (NOT bash cat/head/tail)
|
|
106
|
-
- Use Bash ONLY for read-only operations
|
|
107
|
-
|
|
108
|
-
# Output Format
|
|
109
|
-
- Use absolute file paths
|
|
110
|
-
- Do not use emojis
|
|
111
|
-
- End your response with:
|
|
112
|
-
|
|
113
|
-
### Critical Files for Implementation
|
|
114
|
-
List 3-5 files most critical for implementing this plan:
|
|
115
|
-
- /absolute/path/to/file.ts - [Brief reason]`,
|
|
116
|
-
promptMode: "replace",
|
|
117
|
-
isDefault: true,
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
68
|
]);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Host-supported thinking levels advertised by every pi-subagents surface. */
|
|
2
|
+
export const THINKING_LEVELS = [
|
|
3
|
+
"off",
|
|
4
|
+
"minimal",
|
|
5
|
+
"low",
|
|
6
|
+
"medium",
|
|
7
|
+
"high",
|
|
8
|
+
"xhigh",
|
|
9
|
+
"max",
|
|
10
|
+
] as const;
|
|
11
|
+
|
|
12
|
+
export const THINKING_LEVELS_DESCRIPTION = THINKING_LEVELS.join(", ");
|
|
@@ -29,7 +29,10 @@ export class InterruptHandler {
|
|
|
29
29
|
private latched?: AbortSignal;
|
|
30
30
|
private detach?: () => void;
|
|
31
31
|
|
|
32
|
-
constructor(
|
|
32
|
+
constructor(
|
|
33
|
+
private readonly manager: InterruptManager,
|
|
34
|
+
private readonly shouldAbortAll: () => boolean = () => true,
|
|
35
|
+
) {}
|
|
33
36
|
|
|
34
37
|
handleTurnStart(ctx: InterruptCtx): void {
|
|
35
38
|
const signal = ctx.signal;
|
|
@@ -41,7 +44,7 @@ export class InterruptHandler {
|
|
|
41
44
|
if (!signal) return;
|
|
42
45
|
|
|
43
46
|
const onAbort = (): void => {
|
|
44
|
-
this.manager.abortAll();
|
|
47
|
+
if (this.shouldAbortAll()) this.manager.abortAll();
|
|
45
48
|
};
|
|
46
49
|
signal.addEventListener("abort", onAbort, { once: true });
|
|
47
50
|
this.detach = () => signal.removeEventListener("abort", onAbort);
|
|
@@ -49,14 +49,14 @@ export class SessionLifecycleHandler {
|
|
|
49
49
|
// Cleanup order matters:
|
|
50
50
|
// 1. Unpublish service — prevent new cross-extension calls
|
|
51
51
|
// 2. Clear session context — no more session state
|
|
52
|
-
// 3.
|
|
53
|
-
// 4.
|
|
52
|
+
// 3. Dispose notifications — prevent terminal transitions from enqueueing follow-ups
|
|
53
|
+
// 4. Abort all agents — stop running and queued work
|
|
54
54
|
// 5. Dispose manager — final cleanup
|
|
55
55
|
handleSessionShutdown(): Promise<void> {
|
|
56
56
|
this.unpublishService();
|
|
57
57
|
this.runtime.clearSessionContext();
|
|
58
|
-
this.manager.abortAll();
|
|
59
58
|
this.disposeNotifications();
|
|
59
|
+
this.manager.abortAll();
|
|
60
60
|
this.manager.dispose();
|
|
61
61
|
return Promise.resolve();
|
|
62
62
|
}
|
|
@@ -62,6 +62,8 @@ export default function (pi: ExtensionAPI) {
|
|
|
62
62
|
const notifications = new NotificationManager(
|
|
63
63
|
(msg, opts) => pi.sendMessage(msg, opts),
|
|
64
64
|
);
|
|
65
|
+
pi.on("agent_start", () => notifications.onParentAgentStart());
|
|
66
|
+
pi.on("agent_settled", () => notifications.onParentAgentSettled());
|
|
65
67
|
|
|
66
68
|
// Settings: owns all three in-memory values and handles load/save/emit.
|
|
67
69
|
// onMaxConcurrentChanged is wired to the limiter directly (closure captures by reference).
|
|
@@ -118,7 +120,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
118
120
|
|
|
119
121
|
// Typed service published via Symbol.for() for cross-extension access.
|
|
120
122
|
// Consumers: const { getSubagentsService } = await import("@gotgenes/pi-subagents");
|
|
121
|
-
const service = new SubagentsServiceAdapter(manager, resolveModel, runtime);
|
|
123
|
+
const service = new SubagentsServiceAdapter(manager, resolveModel, runtime, registry, settings);
|
|
122
124
|
publishSubagentsService(service);
|
|
123
125
|
|
|
124
126
|
const lifecycle = new SessionLifecycleHandler(
|
|
@@ -142,7 +144,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
142
144
|
pi.on("tool_execution_start", (event, ctx) => toolStart.handleToolExecutionStart(event, ctx));
|
|
143
145
|
|
|
144
146
|
// Abort all subagents when the parent agent loop is interrupted (ESC).
|
|
145
|
-
const interrupt = new InterruptHandler(manager);
|
|
147
|
+
const interrupt = new InterruptHandler(manager, () => settings.abortAllOnInterrupt);
|
|
146
148
|
pi.on("turn_start", (_event, ctx) => interrupt.handleTurnStart(ctx));
|
|
147
149
|
|
|
148
150
|
// ---- Agent tool ----
|
|
@@ -151,7 +153,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
151
153
|
|
|
152
154
|
// ---- get_subagent_result tool ----
|
|
153
155
|
|
|
154
|
-
pi.registerTool(new GetResultTool(manager,
|
|
156
|
+
pi.registerTool(new GetResultTool(manager, registry).toToolDefinition());
|
|
155
157
|
|
|
156
158
|
// ---- steer_subagent tool ----
|
|
157
159
|
|
|
@@ -159,10 +161,10 @@ export default function (pi: ExtensionAPI) {
|
|
|
159
161
|
|
|
160
162
|
// ---- /subagents:settings command ----
|
|
161
163
|
|
|
162
|
-
const subagentsSettings = new SubagentsSettingsHandler(settings);
|
|
164
|
+
const subagentsSettings = new SubagentsSettingsHandler(settings, registry);
|
|
163
165
|
|
|
164
166
|
pi.registerCommand("subagents:settings", {
|
|
165
|
-
description: "Configure subagent
|
|
167
|
+
description: "Configure subagent concurrency, retention, interrupts, and fallback policy",
|
|
166
168
|
handler: async (_args, ctx) => {
|
|
167
169
|
await subagentsSettings.handle({ ui: ctx.ui });
|
|
168
170
|
},
|
|
@@ -178,7 +180,6 @@ export default function (pi: ExtensionAPI) {
|
|
|
178
180
|
await sessionNavigator.handle({
|
|
179
181
|
ui: ctx.ui,
|
|
180
182
|
agents: manager.listAgents(),
|
|
181
|
-
evicted: manager.listEvicted(),
|
|
182
183
|
registry,
|
|
183
184
|
cwd: ctx.cwd,
|
|
184
185
|
readFile: (path) => readFileSync(path, "utf8"),
|
|
@@ -72,9 +72,13 @@ export interface CreateSessionOptions {
|
|
|
72
72
|
agentDir: string;
|
|
73
73
|
sessionManager: SessionManagerLike;
|
|
74
74
|
settingsManager: SettingsManager;
|
|
75
|
+
/** Legacy Pi compatibility input; modern Pi consumes modelRuntime. */
|
|
75
76
|
modelRegistry: unknown;
|
|
77
|
+
/** Parent model/auth runtime so child sessions preserve runtime registrations. */
|
|
78
|
+
modelRuntime?: unknown;
|
|
76
79
|
model?: unknown;
|
|
77
|
-
|
|
80
|
+
/** Denylist keeps extension-tool registration open, including late registration. */
|
|
81
|
+
excludeTools: string[];
|
|
78
82
|
resourceLoader: ResourceLoaderLike;
|
|
79
83
|
thinkingLevel?: ThinkingLevel;
|
|
80
84
|
}
|
|
@@ -205,8 +209,9 @@ export async function createSubagentSession(
|
|
|
205
209
|
sessionManager,
|
|
206
210
|
settingsManager: deps.io.createSettingsManager(cfg.effectiveCwd, agentDir),
|
|
207
211
|
modelRegistry: snapshot.modelRegistry,
|
|
212
|
+
modelRuntime: snapshot.modelRuntime,
|
|
208
213
|
model: cfg.model,
|
|
209
|
-
|
|
214
|
+
excludeTools: [...new Set([...cfg.excludedBuiltinToolNames, ...EXCLUDED_TOOL_NAMES])],
|
|
210
215
|
resourceLoader: loader,
|
|
211
216
|
thinkingLevel: cfg.thinkingLevel,
|
|
212
217
|
});
|
|
@@ -16,11 +16,13 @@ export interface ParentSnapshot {
|
|
|
16
16
|
systemPrompt: string;
|
|
17
17
|
/** Parent's current model instance (fallback when agent config has no model). */
|
|
18
18
|
model: unknown;
|
|
19
|
-
/** Model registry
|
|
19
|
+
/** Model registry compatibility facade used for synchronous model lookup. */
|
|
20
20
|
modelRegistry: {
|
|
21
21
|
find(provider: string, modelId: string): unknown;
|
|
22
22
|
getAvailable?(): Array<{ provider: string; id: string }>;
|
|
23
23
|
};
|
|
24
|
+
/** Canonical parent model/auth runtime, when exposed by the host Pi version. */
|
|
25
|
+
modelRuntime?: unknown;
|
|
24
26
|
/** Pre-built parent conversation text (when inheritContext was requested). */
|
|
25
27
|
parentContext?: string;
|
|
26
28
|
}
|
|
@@ -36,12 +38,18 @@ export function buildParentSnapshot(
|
|
|
36
38
|
inheritContext?: boolean,
|
|
37
39
|
): ParentSnapshot {
|
|
38
40
|
const parentContext = inheritContext ? buildParentContext(ctx) : undefined;
|
|
41
|
+
const modelRegistry = ctx.modelRegistry!;
|
|
42
|
+
// Pi exposes ModelRegistry as a compatibility facade. Modern createAgentSession
|
|
43
|
+
// consumes its underlying ModelRuntime; carrying that same runtime preserves
|
|
44
|
+
// extension-registered providers and in-memory auth state in child sessions.
|
|
45
|
+
const modelRuntime = (modelRegistry as unknown as { runtime?: unknown }).runtime;
|
|
46
|
+
|
|
39
47
|
return {
|
|
40
48
|
cwd: ctx.cwd,
|
|
41
49
|
systemPrompt: ctx.getSystemPrompt(),
|
|
42
50
|
model: ctx.model,
|
|
43
|
-
|
|
44
|
-
|
|
51
|
+
modelRegistry,
|
|
52
|
+
modelRuntime,
|
|
45
53
|
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- || intentional: converts empty string to undefined as well as null/undefined
|
|
46
54
|
parentContext: parentContext || undefined,
|
|
47
55
|
};
|