@lesliechan721/aw 0.1.0-beta.10
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/dist/authoring/assets/aw-config.d.mts +51 -0
- package/dist/authoring/assets/aw-config.mjs +1025 -0
- package/dist/authoring/assets/aw-config.mjs.map +1 -0
- package/dist/authoring/scripts/add-skill.d.mts +2 -0
- package/dist/authoring/scripts/add-skill.mjs +355 -0
- package/dist/authoring/scripts/add-skill.mjs.map +1 -0
- package/dist/authoring/scripts/init-plugin.d.mts +2 -0
- package/dist/authoring/scripts/init-plugin.mjs +487 -0
- package/dist/authoring/scripts/init-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.d.mts +4 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs +261 -0
- package/dist/authoring/scripts/lib/javascript-import-scanner.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-root.d.mts +26 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs +125 -0
- package/dist/authoring/scripts/lib/plugin-root.mjs.map +1 -0
- package/dist/authoring/scripts/lib/plugin-version-check.d.mts +69 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs +563 -0
- package/dist/authoring/scripts/lib/plugin-version-check.mjs.map +1 -0
- package/dist/authoring/scripts/lib/semver.d.mts +9 -0
- package/dist/authoring/scripts/lib/semver.mjs +63 -0
- package/dist/authoring/scripts/lib/semver.mjs.map +1 -0
- package/dist/authoring/scripts/lib/skill-scaffold.d.mts +111 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs +353 -0
- package/dist/authoring/scripts/lib/skill-scaffold.mjs.map +1 -0
- package/dist/authoring/scripts/plugin-status.d.mts +2 -0
- package/dist/authoring/scripts/plugin-status.mjs +93 -0
- package/dist/authoring/scripts/plugin-status.mjs.map +1 -0
- package/dist/authoring/scripts/remove-plugin.d.mts +2 -0
- package/dist/authoring/scripts/remove-plugin.mjs +367 -0
- package/dist/authoring/scripts/remove-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-plugin.d.mts +2 -0
- package/dist/authoring/scripts/validate-plugin.mjs +3465 -0
- package/dist/authoring/scripts/validate-plugin.mjs.map +1 -0
- package/dist/authoring/scripts/validate-skill.d.mts +2 -0
- package/dist/authoring/scripts/validate-skill.mjs +126 -0
- package/dist/authoring/scripts/validate-skill.mjs.map +1 -0
- package/dist/authoring/templates/aw-config-runtime.d.mts +2 -0
- package/dist/authoring/templates/aw-config-runtime.mjs +407 -0
- package/dist/authoring/templates/aw-config-runtime.mjs.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -0
- package/dist/scripts/aw-skill-eval-materializer.d.ts +24 -0
- package/dist/scripts/aw-skill-eval-materializer.js +309 -0
- package/dist/scripts/aw-skill-eval-materializer.js.map +1 -0
- package/dist/scripts/bundle-plugins.d.ts +17 -0
- package/dist/scripts/bundle-plugins.js +126 -0
- package/dist/scripts/bundle-plugins.js.map +1 -0
- package/dist/scripts/plugin-staging.d.ts +26 -0
- package/dist/scripts/plugin-staging.js +76 -0
- package/dist/scripts/plugin-staging.js.map +1 -0
- package/dist/scripts/test-plugin-scripts.d.ts +7 -0
- package/dist/scripts/test-plugin-scripts.js +610 -0
- package/dist/scripts/test-plugin-scripts.js.map +1 -0
- package/dist/src/adapters/helpers.d.ts +44 -0
- package/dist/src/adapters/helpers.js +95 -0
- package/dist/src/adapters/helpers.js.map +1 -0
- package/dist/src/authoring/workspace-commands.d.ts +70 -0
- package/dist/src/authoring/workspace-commands.js +158 -0
- package/dist/src/authoring/workspace-commands.js.map +1 -0
- package/dist/src/commands/aw-capabilities.d.ts +78 -0
- package/dist/src/commands/aw-capabilities.js +254 -0
- package/dist/src/commands/aw-capabilities.js.map +1 -0
- package/dist/src/commands/catalog-dev-source.d.ts +120 -0
- package/dist/src/commands/catalog-dev-source.js +434 -0
- package/dist/src/commands/catalog-dev-source.js.map +1 -0
- package/dist/src/commands/catalog-generation.d.ts +16 -0
- package/dist/src/commands/catalog-generation.js +9 -0
- package/dist/src/commands/catalog-generation.js.map +1 -0
- package/dist/src/commands/catalog-publication-inspection.d.ts +138 -0
- package/dist/src/commands/catalog-publication-inspection.js +711 -0
- package/dist/src/commands/catalog-publication-inspection.js.map +1 -0
- package/dist/src/commands/catalog-publication-journal.d.ts +56 -0
- package/dist/src/commands/catalog-publication-journal.js +215 -0
- package/dist/src/commands/catalog-publication-journal.js.map +1 -0
- package/dist/src/commands/catalog-publication-target.d.ts +18 -0
- package/dist/src/commands/catalog-publication-target.js +95 -0
- package/dist/src/commands/catalog-publication-target.js.map +1 -0
- package/dist/src/commands/catalog-publish.d.ts +103 -0
- package/dist/src/commands/catalog-publish.js +804 -0
- package/dist/src/commands/catalog-publish.js.map +1 -0
- package/dist/src/commands/catalog-source.d.ts +134 -0
- package/dist/src/commands/catalog-source.js +377 -0
- package/dist/src/commands/catalog-source.js.map +1 -0
- package/dist/src/commands/catalog-status.d.ts +56 -0
- package/dist/src/commands/catalog-status.js +217 -0
- package/dist/src/commands/catalog-status.js.map +1 -0
- package/dist/src/commands/catalog-store.d.ts +80 -0
- package/dist/src/commands/catalog-store.js +348 -0
- package/dist/src/commands/catalog-store.js.map +1 -0
- package/dist/src/commands/catalog-workspace-resolution.d.ts +13 -0
- package/dist/src/commands/catalog-workspace-resolution.js +42 -0
- package/dist/src/commands/catalog-workspace-resolution.js.map +1 -0
- package/dist/src/commands/console.d.ts +3 -0
- package/dist/src/commands/console.js +44 -0
- package/dist/src/commands/console.js.map +1 -0
- package/dist/src/commands/dependency-operation-plan.d.ts +58 -0
- package/dist/src/commands/dependency-operation-plan.js +261 -0
- package/dist/src/commands/dependency-operation-plan.js.map +1 -0
- package/dist/src/commands/init.d.ts +25 -0
- package/dist/src/commands/init.js +42 -0
- package/dist/src/commands/init.js.map +1 -0
- package/dist/src/commands/offline-cleanup-evidence.d.ts +59 -0
- package/dist/src/commands/offline-cleanup-evidence.js +163 -0
- package/dist/src/commands/offline-cleanup-evidence.js.map +1 -0
- package/dist/src/commands/operation-plan.d.ts +126 -0
- package/dist/src/commands/operation-plan.js +47 -0
- package/dist/src/commands/operation-plan.js.map +1 -0
- package/dist/src/commands/operation-planner.d.ts +46 -0
- package/dist/src/commands/operation-planner.js +139 -0
- package/dist/src/commands/operation-planner.js.map +1 -0
- package/dist/src/commands/options.d.ts +70 -0
- package/dist/src/commands/options.js +194 -0
- package/dist/src/commands/options.js.map +1 -0
- package/dist/src/commands/plugin-capabilities.d.ts +22 -0
- package/dist/src/commands/plugin-capabilities.js +159 -0
- package/dist/src/commands/plugin-capabilities.js.map +1 -0
- package/dist/src/commands/rebuild-command.d.ts +88 -0
- package/dist/src/commands/rebuild-command.js +3626 -0
- package/dist/src/commands/rebuild-command.js.map +1 -0
- package/dist/src/commands/rebuild-integration.d.ts +190 -0
- package/dist/src/commands/rebuild-integration.js +4439 -0
- package/dist/src/commands/rebuild-integration.js.map +1 -0
- package/dist/src/commands/rebuild-operations.d.ts +100 -0
- package/dist/src/commands/rebuild-operations.js +625 -0
- package/dist/src/commands/rebuild-operations.js.map +1 -0
- package/dist/src/commands/reconcile-operation-plan.d.ts +26 -0
- package/dist/src/commands/reconcile-operation-plan.js +28 -0
- package/dist/src/commands/reconcile-operation-plan.js.map +1 -0
- package/dist/src/commands/review-publication.d.ts +99 -0
- package/dist/src/commands/review-publication.js +904 -0
- package/dist/src/commands/review-publication.js.map +1 -0
- package/dist/src/commands/runtime.d.ts +172 -0
- package/dist/src/commands/runtime.js +720 -0
- package/dist/src/commands/runtime.js.map +1 -0
- package/dist/src/commands/skill-eval.d.ts +33 -0
- package/dist/src/commands/skill-eval.js +363 -0
- package/dist/src/commands/skill-eval.js.map +1 -0
- package/dist/src/commands/status-v6.d.ts +206 -0
- package/dist/src/commands/status-v6.js +2175 -0
- package/dist/src/commands/status-v6.js.map +1 -0
- package/dist/src/commands/sync-command.d.ts +23 -0
- package/dist/src/commands/sync-command.js +242 -0
- package/dist/src/commands/sync-command.js.map +1 -0
- package/dist/src/commands/wizard.d.ts +56 -0
- package/dist/src/commands/wizard.js +58 -0
- package/dist/src/commands/wizard.js.map +1 -0
- package/dist/src/commands/write-commands.d.ts +7 -0
- package/dist/src/commands/write-commands.js +190 -0
- package/dist/src/commands/write-commands.js.map +1 -0
- package/dist/src/constants.d.ts +31 -0
- package/dist/src/constants.js +32 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/eval/manifest-v1.d.ts +67 -0
- package/dist/src/eval/manifest-v1.js +347 -0
- package/dist/src/eval/manifest-v1.js.map +1 -0
- package/dist/src/generators/agents.d.ts +3 -0
- package/dist/src/generators/agents.js +46 -0
- package/dist/src/generators/agents.js.map +1 -0
- package/dist/src/generators/hooks.d.ts +15 -0
- package/dist/src/generators/hooks.js +76 -0
- package/dist/src/generators/hooks.js.map +1 -0
- package/dist/src/generators/instructions.d.ts +13 -0
- package/dist/src/generators/instructions.js +66 -0
- package/dist/src/generators/instructions.js.map +1 -0
- package/dist/src/generators/local-plugin.d.ts +56 -0
- package/dist/src/generators/local-plugin.js +1373 -0
- package/dist/src/generators/local-plugin.js.map +1 -0
- package/dist/src/generators/permissions.d.ts +10 -0
- package/dist/src/generators/permissions.js +37 -0
- package/dist/src/generators/permissions.js.map +1 -0
- package/dist/src/generators/shared.d.ts +2 -0
- package/dist/src/generators/shared.js +15 -0
- package/dist/src/generators/shared.js.map +1 -0
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.js +3327 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/output/command-receipt.d.ts +87 -0
- package/dist/src/output/command-receipt.js +302 -0
- package/dist/src/output/command-receipt.js.map +1 -0
- package/dist/src/output/debug-log.d.ts +4 -0
- package/dist/src/output/debug-log.js +97 -0
- package/dist/src/output/debug-log.js.map +1 -0
- package/dist/src/output/equivalent-command.d.ts +9 -0
- package/dist/src/output/equivalent-command.js +39 -0
- package/dist/src/output/equivalent-command.js.map +1 -0
- package/dist/src/output/model.d.ts +76 -0
- package/dist/src/output/model.js +2 -0
- package/dist/src/output/model.js.map +1 -0
- package/dist/src/output/rebuild-progress.d.ts +21 -0
- package/dist/src/output/rebuild-progress.js +128 -0
- package/dist/src/output/rebuild-progress.js.map +1 -0
- package/dist/src/output/redact.d.ts +3 -0
- package/dist/src/output/redact.js +39 -0
- package/dist/src/output/redact.js.map +1 -0
- package/dist/src/output/reporter.d.ts +9 -0
- package/dist/src/output/reporter.js +133 -0
- package/dist/src/output/reporter.js.map +1 -0
- package/dist/src/portable/commands.d.ts +124 -0
- package/dist/src/portable/commands.js +557 -0
- package/dist/src/portable/commands.js.map +1 -0
- package/dist/src/portable/materializer.d.ts +50 -0
- package/dist/src/portable/materializer.js +462 -0
- package/dist/src/portable/materializer.js.map +1 -0
- package/dist/src/portable/skills-cli.d.ts +43 -0
- package/dist/src/portable/skills-cli.js +148 -0
- package/dist/src/portable/skills-cli.js.map +1 -0
- package/dist/src/tui/catalog-freshness.d.ts +1 -0
- package/dist/src/tui/catalog-freshness.js +2 -0
- package/dist/src/tui/catalog-freshness.js.map +1 -0
- package/dist/src/tui/catalog-generation.d.ts +21 -0
- package/dist/src/tui/catalog-generation.js +116 -0
- package/dist/src/tui/catalog-generation.js.map +1 -0
- package/dist/src/tui/catalog-sources/projection.d.ts +4 -0
- package/dist/src/tui/catalog-sources/projection.js +17 -0
- package/dist/src/tui/catalog-sources/projection.js.map +1 -0
- package/dist/src/tui/catalog-sources/review.d.ts +3 -0
- package/dist/src/tui/catalog-sources/review.js +13 -0
- package/dist/src/tui/catalog-sources/review.js.map +1 -0
- package/dist/src/tui/catalog-sources/screens.d.ts +12 -0
- package/dist/src/tui/catalog-sources/screens.js +33 -0
- package/dist/src/tui/catalog-sources/screens.js.map +1 -0
- package/dist/src/tui/catalog-sources/session.d.ts +22 -0
- package/dist/src/tui/catalog-sources/session.js +225 -0
- package/dist/src/tui/catalog-sources/session.js.map +1 -0
- package/dist/src/tui/catalog-sources/types.d.ts +41 -0
- package/dist/src/tui/catalog-sources/types.js +2 -0
- package/dist/src/tui/catalog-sources/types.js.map +1 -0
- package/dist/src/tui/components.d.ts +102 -0
- package/dist/src/tui/components.js +184 -0
- package/dist/src/tui/components.js.map +1 -0
- package/dist/src/tui/console-app-v4.d.ts +20 -0
- package/dist/src/tui/console-app-v4.js +5066 -0
- package/dist/src/tui/console-app-v4.js.map +1 -0
- package/dist/src/tui/controller-runtime.d.ts +23 -0
- package/dist/src/tui/controller-runtime.js +2011 -0
- package/dist/src/tui/controller-runtime.js.map +1 -0
- package/dist/src/tui/controller.d.ts +557 -0
- package/dist/src/tui/controller.js +2120 -0
- package/dist/src/tui/controller.js.map +1 -0
- package/dist/src/tui/diagnostics.d.ts +30 -0
- package/dist/src/tui/diagnostics.js +71 -0
- package/dist/src/tui/diagnostics.js.map +1 -0
- package/dist/src/tui/index.d.ts +17 -0
- package/dist/src/tui/index.js +17 -0
- package/dist/src/tui/index.js.map +1 -0
- package/dist/src/tui/input-display.d.ts +8 -0
- package/dist/src/tui/input-display.js +36 -0
- package/dist/src/tui/input-display.js.map +1 -0
- package/dist/src/tui/keys.d.ts +12 -0
- package/dist/src/tui/keys.js +22 -0
- package/dist/src/tui/keys.js.map +1 -0
- package/dist/src/tui/layout.d.ts +12 -0
- package/dist/src/tui/layout.js +19 -0
- package/dist/src/tui/layout.js.map +1 -0
- package/dist/src/tui/model.d.ts +424 -0
- package/dist/src/tui/model.js +1493 -0
- package/dist/src/tui/model.js.map +1 -0
- package/dist/src/tui/operation-review-planner.d.ts +21 -0
- package/dist/src/tui/operation-review-planner.js +622 -0
- package/dist/src/tui/operation-review-planner.js.map +1 -0
- package/dist/src/tui/prompt.d.ts +8 -0
- package/dist/src/tui/prompt.js +231 -0
- package/dist/src/tui/prompt.js.map +1 -0
- package/dist/src/tui/router.d.ts +206 -0
- package/dist/src/tui/router.js +137 -0
- package/dist/src/tui/router.js.map +1 -0
- package/dist/src/tui/runner.d.ts +11 -0
- package/dist/src/tui/runner.js +71 -0
- package/dist/src/tui/runner.js.map +1 -0
- package/dist/src/tui/source-ref-presets.d.ts +3 -0
- package/dist/src/tui/source-ref-presets.js +11 -0
- package/dist/src/tui/source-ref-presets.js.map +1 -0
- package/dist/src/tui/theme.d.ts +26 -0
- package/dist/src/tui/theme.js +28 -0
- package/dist/src/tui/theme.js.map +1 -0
- package/dist/src/tui/viewport.d.ts +20 -0
- package/dist/src/tui/viewport.js +29 -0
- package/dist/src/tui/viewport.js.map +1 -0
- package/dist/src/tui/views.d.ts +57 -0
- package/dist/src/tui/views.js +201 -0
- package/dist/src/tui/views.js.map +1 -0
- package/dist/src/tui/wizard.d.ts +11 -0
- package/dist/src/tui/wizard.js +323 -0
- package/dist/src/tui/wizard.js.map +1 -0
- package/dist/src/types.d.ts +474 -0
- package/dist/src/types.js +34 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/agent-version.d.ts +19 -0
- package/dist/src/utils/agent-version.js +205 -0
- package/dist/src/utils/agent-version.js.map +1 -0
- package/dist/src/utils/artifact-plan.d.ts +27 -0
- package/dist/src/utils/artifact-plan.js +453 -0
- package/dist/src/utils/artifact-plan.js.map +1 -0
- package/dist/src/utils/artifact-renderer.d.ts +129 -0
- package/dist/src/utils/artifact-renderer.js +400 -0
- package/dist/src/utils/artifact-renderer.js.map +1 -0
- package/dist/src/utils/artifact-request.d.ts +16 -0
- package/dist/src/utils/artifact-request.js +42 -0
- package/dist/src/utils/artifact-request.js.map +1 -0
- package/dist/src/utils/artifact-sources.d.ts +8 -0
- package/dist/src/utils/artifact-sources.js +10 -0
- package/dist/src/utils/artifact-sources.js.map +1 -0
- package/dist/src/utils/aw-home-mutation-lock.d.ts +11 -0
- package/dist/src/utils/aw-home-mutation-lock.js +83 -0
- package/dist/src/utils/aw-home-mutation-lock.js.map +1 -0
- package/dist/src/utils/bundle-integrity.d.ts +2 -0
- package/dist/src/utils/bundle-integrity.js +63 -0
- package/dist/src/utils/bundle-integrity.js.map +1 -0
- package/dist/src/utils/bundle-layout.d.ts +4 -0
- package/dist/src/utils/bundle-layout.js +531 -0
- package/dist/src/utils/bundle-layout.js.map +1 -0
- package/dist/src/utils/catalog-digests.d.ts +18 -0
- package/dist/src/utils/catalog-digests.js +156 -0
- package/dist/src/utils/catalog-digests.js.map +1 -0
- package/dist/src/utils/catalog-generation-control-snapshot.d.ts +11 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js +45 -0
- package/dist/src/utils/catalog-generation-control-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-generation-error.d.ts +16 -0
- package/dist/src/utils/catalog-generation-error.js +30 -0
- package/dist/src/utils/catalog-generation-error.js.map +1 -0
- package/dist/src/utils/catalog-generation-resolver.d.ts +32 -0
- package/dist/src/utils/catalog-generation-resolver.js +251 -0
- package/dist/src/utils/catalog-generation-resolver.js.map +1 -0
- package/dist/src/utils/catalog-generation-service.d.ts +161 -0
- package/dist/src/utils/catalog-generation-service.js +1237 -0
- package/dist/src/utils/catalog-generation-service.js.map +1 -0
- package/dist/src/utils/catalog-generation-state.d.ts +22 -0
- package/dist/src/utils/catalog-generation-state.js +192 -0
- package/dist/src/utils/catalog-generation-state.js.map +1 -0
- package/dist/src/utils/catalog-generation-store.d.ts +57 -0
- package/dist/src/utils/catalog-generation-store.js +397 -0
- package/dist/src/utils/catalog-generation-store.js.map +1 -0
- package/dist/src/utils/catalog-manifest-v7.d.ts +5 -0
- package/dist/src/utils/catalog-manifest-v7.js +98 -0
- package/dist/src/utils/catalog-manifest-v7.js.map +1 -0
- package/dist/src/utils/catalog-operation-context.d.ts +20 -0
- package/dist/src/utils/catalog-operation-context.js +141 -0
- package/dist/src/utils/catalog-operation-context.js.map +1 -0
- package/dist/src/utils/catalog-public-error.d.ts +19 -0
- package/dist/src/utils/catalog-public-error.js +100 -0
- package/dist/src/utils/catalog-public-error.js.map +1 -0
- package/dist/src/utils/catalog-runtime-projection.d.ts +33 -0
- package/dist/src/utils/catalog-runtime-projection.js +77 -0
- package/dist/src/utils/catalog-runtime-projection.js.map +1 -0
- package/dist/src/utils/catalog-snapshot.d.ts +10 -0
- package/dist/src/utils/catalog-snapshot.js +20 -0
- package/dist/src/utils/catalog-snapshot.js.map +1 -0
- package/dist/src/utils/catalog-source-identity.d.ts +5 -0
- package/dist/src/utils/catalog-source-identity.js +137 -0
- package/dist/src/utils/catalog-source-identity.js.map +1 -0
- package/dist/src/utils/catalog-source-impact.d.ts +20 -0
- package/dist/src/utils/catalog-source-impact.js +222 -0
- package/dist/src/utils/catalog-source-impact.js.map +1 -0
- package/dist/src/utils/catalog-source-presentation.d.ts +1 -0
- package/dist/src/utils/catalog-source-presentation.js +32 -0
- package/dist/src/utils/catalog-source-presentation.js.map +1 -0
- package/dist/src/utils/catalog-source-references.d.ts +66 -0
- package/dist/src/utils/catalog-source-references.js +1180 -0
- package/dist/src/utils/catalog-source-references.js.map +1 -0
- package/dist/src/utils/catalog-sources.d.ts +53 -0
- package/dist/src/utils/catalog-sources.js +456 -0
- package/dist/src/utils/catalog-sources.js.map +1 -0
- package/dist/src/utils/codex-config.d.ts +126 -0
- package/dist/src/utils/codex-config.js +1032 -0
- package/dist/src/utils/codex-config.js.map +1 -0
- package/dist/src/utils/codex-manager.d.ts +81 -0
- package/dist/src/utils/codex-manager.js +810 -0
- package/dist/src/utils/codex-manager.js.map +1 -0
- package/dist/src/utils/codex-marketplace-path.d.ts +5 -0
- package/dist/src/utils/codex-marketplace-path.js +45 -0
- package/dist/src/utils/codex-marketplace-path.js.map +1 -0
- package/dist/src/utils/codex-native-observation.d.ts +16 -0
- package/dist/src/utils/codex-native-observation.js +22 -0
- package/dist/src/utils/codex-native-observation.js.map +1 -0
- package/dist/src/utils/codex-native-render-receipt.d.ts +40 -0
- package/dist/src/utils/codex-native-render-receipt.js +205 -0
- package/dist/src/utils/codex-native-render-receipt.js.map +1 -0
- package/dist/src/utils/codex-reconciler.d.ts +128 -0
- package/dist/src/utils/codex-reconciler.js +294 -0
- package/dist/src/utils/codex-reconciler.js.map +1 -0
- package/dist/src/utils/codex-roles.d.ts +71 -0
- package/dist/src/utils/codex-roles.js +257 -0
- package/dist/src/utils/codex-roles.js.map +1 -0
- package/dist/src/utils/codex-shared-native.d.ts +63 -0
- package/dist/src/utils/codex-shared-native.js +142 -0
- package/dist/src/utils/codex-shared-native.js.map +1 -0
- package/dist/src/utils/codex-skill-staging.d.ts +11 -0
- package/dist/src/utils/codex-skill-staging.js +8 -0
- package/dist/src/utils/codex-skill-staging.js.map +1 -0
- package/dist/src/utils/codex-surface-analysis.d.ts +45 -0
- package/dist/src/utils/codex-surface-analysis.js +245 -0
- package/dist/src/utils/codex-surface-analysis.js.map +1 -0
- package/dist/src/utils/config-value.d.ts +3 -0
- package/dist/src/utils/config-value.js +23 -0
- package/dist/src/utils/config-value.js.map +1 -0
- package/dist/src/utils/dynamic-skill-tree.d.ts +36 -0
- package/dist/src/utils/dynamic-skill-tree.js +466 -0
- package/dist/src/utils/dynamic-skill-tree.js.map +1 -0
- package/dist/src/utils/file-rules.d.ts +1 -0
- package/dist/src/utils/file-rules.js +2 -0
- package/dist/src/utils/file-rules.js.map +1 -0
- package/dist/src/utils/git-catalog-provider.d.ts +22 -0
- package/dist/src/utils/git-catalog-provider.js +497 -0
- package/dist/src/utils/git-catalog-provider.js.map +1 -0
- package/dist/src/utils/hooks-contract.d.ts +1 -0
- package/dist/src/utils/hooks-contract.js +2 -0
- package/dist/src/utils/hooks-contract.js.map +1 -0
- package/dist/src/utils/json.d.ts +4 -0
- package/dist/src/utils/json.js +29 -0
- package/dist/src/utils/json.js.map +1 -0
- package/dist/src/utils/local-marketplace.d.ts +41 -0
- package/dist/src/utils/local-marketplace.js +316 -0
- package/dist/src/utils/local-marketplace.js.map +1 -0
- package/dist/src/utils/manifest.d.ts +11 -0
- package/dist/src/utils/manifest.js +33 -0
- package/dist/src/utils/manifest.js.map +1 -0
- package/dist/src/utils/marketplace.d.ts +3 -0
- package/dist/src/utils/marketplace.js +76 -0
- package/dist/src/utils/marketplace.js.map +1 -0
- package/dist/src/utils/multi-source-catalog.d.ts +66 -0
- package/dist/src/utils/multi-source-catalog.js +345 -0
- package/dist/src/utils/multi-source-catalog.js.map +1 -0
- package/dist/src/utils/native-cli.d.ts +118 -0
- package/dist/src/utils/native-cli.js +518 -0
- package/dist/src/utils/native-cli.js.map +1 -0
- package/dist/src/utils/orphan-marketplace-cleanup.d.ts +18 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js +198 -0
- package/dist/src/utils/orphan-marketplace-cleanup.js.map +1 -0
- package/dist/src/utils/ownership.d.ts +194 -0
- package/dist/src/utils/ownership.js +723 -0
- package/dist/src/utils/ownership.js.map +1 -0
- package/dist/src/utils/path-catalog-provider.d.ts +7 -0
- package/dist/src/utils/path-catalog-provider.js +74 -0
- package/dist/src/utils/path-catalog-provider.js.map +1 -0
- package/dist/src/utils/paths.d.ts +40 -0
- package/dist/src/utils/paths.js +137 -0
- package/dist/src/utils/paths.js.map +1 -0
- package/dist/src/utils/platform-entries.d.ts +1 -0
- package/dist/src/utils/platform-entries.js +2 -0
- package/dist/src/utils/platform-entries.js.map +1 -0
- package/dist/src/utils/platform-support.d.ts +1 -0
- package/dist/src/utils/platform-support.js +2 -0
- package/dist/src/utils/platform-support.js.map +1 -0
- package/dist/src/utils/plugin-config-write.d.ts +110 -0
- package/dist/src/utils/plugin-config-write.js +773 -0
- package/dist/src/utils/plugin-config-write.js.map +1 -0
- package/dist/src/utils/plugin-config.d.ts +389 -0
- package/dist/src/utils/plugin-config.js +1642 -0
- package/dist/src/utils/plugin-config.js.map +1 -0
- package/dist/src/utils/plugin-dependencies.d.ts +12 -0
- package/dist/src/utils/plugin-dependencies.js +162 -0
- package/dist/src/utils/plugin-dependencies.js.map +1 -0
- package/dist/src/utils/plugin-intent-state.d.ts +34 -0
- package/dist/src/utils/plugin-intent-state.js +289 -0
- package/dist/src/utils/plugin-intent-state.js.map +1 -0
- package/dist/src/utils/plugin-script-contract.d.ts +1 -0
- package/dist/src/utils/plugin-script-contract.js +2 -0
- package/dist/src/utils/plugin-script-contract.js.map +1 -0
- package/dist/src/utils/plugin-scripts.d.ts +101 -0
- package/dist/src/utils/plugin-scripts.js +253 -0
- package/dist/src/utils/plugin-scripts.js.map +1 -0
- package/dist/src/utils/process-lock.d.ts +47 -0
- package/dist/src/utils/process-lock.js +532 -0
- package/dist/src/utils/process-lock.js.map +1 -0
- package/dist/src/utils/process-tree.d.ts +2 -0
- package/dist/src/utils/process-tree.js +2 -0
- package/dist/src/utils/process-tree.js.map +1 -0
- package/dist/src/utils/project-boundary.d.ts +9 -0
- package/dist/src/utils/project-boundary.js +67 -0
- package/dist/src/utils/project-boundary.js.map +1 -0
- package/dist/src/utils/rendered-contract.d.ts +8 -0
- package/dist/src/utils/rendered-contract.js +134 -0
- package/dist/src/utils/rendered-contract.js.map +1 -0
- package/dist/src/utils/runtime-skill-closure.d.ts +13 -0
- package/dist/src/utils/runtime-skill-closure.js +863 -0
- package/dist/src/utils/runtime-skill-closure.js.map +1 -0
- package/dist/src/utils/safe-fs.d.ts +21 -0
- package/dist/src/utils/safe-fs.js +111 -0
- package/dist/src/utils/safe-fs.js.map +1 -0
- package/dist/src/utils/skill-authoring.d.ts +1 -0
- package/dist/src/utils/skill-authoring.js +2 -0
- package/dist/src/utils/skill-authoring.js.map +1 -0
- package/dist/src/utils/skill-validation.d.ts +37 -0
- package/dist/src/utils/skill-validation.js +326 -0
- package/dist/src/utils/skill-validation.js.map +1 -0
- package/dist/src/utils/slash-commands.d.ts +1 -0
- package/dist/src/utils/slash-commands.js +2 -0
- package/dist/src/utils/slash-commands.js.map +1 -0
- package/dist/src/utils/state-paths.d.ts +14 -0
- package/dist/src/utils/state-paths.js +139 -0
- package/dist/src/utils/state-paths.js.map +1 -0
- package/dist/src/utils/target-eligibility.d.ts +13 -0
- package/dist/src/utils/target-eligibility.js +35 -0
- package/dist/src/utils/target-eligibility.js.map +1 -0
- package/dist/src/utils/target-order.d.ts +7 -0
- package/dist/src/utils/target-order.js +10 -0
- package/dist/src/utils/target-order.js.map +1 -0
- package/dist/src/utils/template-engine.d.ts +1 -0
- package/dist/src/utils/template-engine.js +2 -0
- package/dist/src/utils/template-engine.js.map +1 -0
- package/dist/src/utils/test-path-fence.d.ts +12 -0
- package/dist/src/utils/test-path-fence.js +31 -0
- package/dist/src/utils/test-path-fence.js.map +1 -0
- package/dist/vitest.config.d.ts +2 -0
- package/dist/vitest.config.js +16 -0
- package/dist/vitest.config.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import { promises as nodeFs } from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
import { atomicReplaceSafeFile } from './safe-fs.js';
|
|
6
|
+
export const SKILL_OWNER_MARKER = '.agent-workflows-owner.json';
|
|
7
|
+
export const OWNED_TEXT_HEADER_PREFIX = '# agent-workflows-owner: ';
|
|
8
|
+
export const SHARED_OWNER_TOKEN_PREFIX = 'aw-owner-v3:';
|
|
9
|
+
export function createSharedOwnerToken(identity) {
|
|
10
|
+
validateOwnerIdentity(identity);
|
|
11
|
+
return `${SHARED_OWNER_TOKEN_PREFIX}${Buffer.from(createSkillOwnerMarkerContent(identity)).toString('base64url')}`;
|
|
12
|
+
}
|
|
13
|
+
export function parseSharedOwnerToken(value) {
|
|
14
|
+
if (!value.startsWith(SHARED_OWNER_TOKEN_PREFIX))
|
|
15
|
+
return null;
|
|
16
|
+
let parsed;
|
|
17
|
+
try {
|
|
18
|
+
parsed = JSON.parse(Buffer.from(value.slice(SHARED_OWNER_TOKEN_PREFIX.length), 'base64url').toString('utf8'));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
throw new Error('Shared owner token is invalid.');
|
|
22
|
+
}
|
|
23
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)
|
|
24
|
+
|| parsed.schemaVersion !== 3) {
|
|
25
|
+
throw new Error('Shared owner token must contain schema 3 identity.');
|
|
26
|
+
}
|
|
27
|
+
return parseOwnerIdentity(parsed, 'Shared owner token');
|
|
28
|
+
}
|
|
29
|
+
class OwnershipSymlinkError extends Error {
|
|
30
|
+
}
|
|
31
|
+
function isMissing(error) {
|
|
32
|
+
const code = error.code;
|
|
33
|
+
return code === 'ENOENT' || code === 'ENOTDIR';
|
|
34
|
+
}
|
|
35
|
+
function errorMessage(error) {
|
|
36
|
+
return error instanceof Error ? error.message : String(error);
|
|
37
|
+
}
|
|
38
|
+
export function assertSafeOwnershipSegment(value, label) {
|
|
39
|
+
if (typeof value !== 'string' ||
|
|
40
|
+
value === '.' ||
|
|
41
|
+
value === '..' ||
|
|
42
|
+
value.endsWith('.') ||
|
|
43
|
+
!/^[A-Za-z0-9][A-Za-z0-9._-]*$/u.test(value)) {
|
|
44
|
+
throw new Error(`${label} 必须是安全的单一路径 segment:${JSON.stringify(value)}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function validateOwnerIdentity(identity) {
|
|
48
|
+
if (identity.owner !== 'agent-workflows') {
|
|
49
|
+
throw new Error('Owner identity.owner 必须是 "agent-workflows"。');
|
|
50
|
+
}
|
|
51
|
+
assertSafeOwnershipSegment(identity.plugin, 'Owner identity.plugin');
|
|
52
|
+
assertSafeOwnershipSegment(identity.artifactKey, 'Owner identity.artifactKey');
|
|
53
|
+
const sourceFields = [identity.sourceId, identity.pluginId];
|
|
54
|
+
if (sourceFields.some((value) => value !== undefined)) {
|
|
55
|
+
if (sourceFields.some((value) => typeof value !== 'string' || value.length === 0)) {
|
|
56
|
+
throw new Error('Owner identity source fields must be present together.');
|
|
57
|
+
}
|
|
58
|
+
assertSafeOwnershipSegment(identity.sourceId, 'Owner identity.sourceId');
|
|
59
|
+
if (identity.pluginId !== `${identity.sourceId}/${identity.plugin}`) {
|
|
60
|
+
throw new Error('Owner identity.pluginId must be the canonical sourceId/plugin name.');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (identity.platform !== 'codex' && identity.platform !== 'claude') {
|
|
64
|
+
throw new Error(`Owner identity.platform 无效:${String(identity.platform)}`);
|
|
65
|
+
}
|
|
66
|
+
if (identity.scope !== 'user' && identity.scope !== 'project') {
|
|
67
|
+
throw new Error(`Owner identity.scope 无效:${String(identity.scope)}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function identitiesEqual(left, right) {
|
|
71
|
+
return left.owner === right.owner &&
|
|
72
|
+
left.sourceId === right.sourceId &&
|
|
73
|
+
left.pluginId === right.pluginId &&
|
|
74
|
+
left.plugin === right.plugin &&
|
|
75
|
+
left.artifactKey === right.artifactKey &&
|
|
76
|
+
left.platform === right.platform &&
|
|
77
|
+
left.scope === right.scope;
|
|
78
|
+
}
|
|
79
|
+
function markerFromIdentity(identity) {
|
|
80
|
+
validateOwnerIdentity(identity);
|
|
81
|
+
return {
|
|
82
|
+
schemaVersion: 3,
|
|
83
|
+
owner: identity.owner,
|
|
84
|
+
sourceId: identity.sourceId,
|
|
85
|
+
pluginId: identity.pluginId,
|
|
86
|
+
plugin: identity.plugin,
|
|
87
|
+
artifactKey: identity.artifactKey,
|
|
88
|
+
platform: identity.platform,
|
|
89
|
+
scope: identity.scope,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function parseOwnerIdentity(value, label) {
|
|
93
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
94
|
+
throw new Error(`${label} 必须是 object。`);
|
|
95
|
+
}
|
|
96
|
+
const record = value;
|
|
97
|
+
const allowedKeys = new Set([
|
|
98
|
+
'schemaVersion',
|
|
99
|
+
'owner',
|
|
100
|
+
'sourceId',
|
|
101
|
+
'pluginId',
|
|
102
|
+
'plugin',
|
|
103
|
+
'artifactKey',
|
|
104
|
+
'platform',
|
|
105
|
+
'scope',
|
|
106
|
+
]);
|
|
107
|
+
if (Object.keys(record).some((key) => !allowedKeys.has(key))) {
|
|
108
|
+
throw new Error(`${label} 包含未知字段。`);
|
|
109
|
+
}
|
|
110
|
+
if (record.schemaVersion !== 3 || (typeof record.sourceId !== 'string'
|
|
111
|
+
|| typeof record.pluginId !== 'string')) {
|
|
112
|
+
throw new Error(`${label} must use schema 3 stable plugin identity. This beta hard cut requires a new AW_HOME, or cleanup with the old CLI first.`);
|
|
113
|
+
}
|
|
114
|
+
const identity = {
|
|
115
|
+
owner: record.owner,
|
|
116
|
+
sourceId: record.sourceId,
|
|
117
|
+
pluginId: record.pluginId,
|
|
118
|
+
plugin: record.plugin,
|
|
119
|
+
artifactKey: record.artifactKey,
|
|
120
|
+
platform: record.platform,
|
|
121
|
+
scope: record.scope,
|
|
122
|
+
};
|
|
123
|
+
validateOwnerIdentity(identity);
|
|
124
|
+
return identity;
|
|
125
|
+
}
|
|
126
|
+
export function createSkillOwnerMarkerContent(identity) {
|
|
127
|
+
return `${JSON.stringify(markerFromIdentity(identity), null, 2)}\n`;
|
|
128
|
+
}
|
|
129
|
+
function assertPathBoundary(allowedRoot, candidatePath) {
|
|
130
|
+
const root = path.resolve(allowedRoot);
|
|
131
|
+
const candidate = path.resolve(candidatePath);
|
|
132
|
+
const relative = path.relative(root, candidate);
|
|
133
|
+
if (relative === '' || relative === '..' || relative.startsWith(`..${path.sep}`) || path.isAbsolute(relative)) {
|
|
134
|
+
throw new Error(`Ownership 路径越界:${candidate} 不在 ${root} 的子路径中。`);
|
|
135
|
+
}
|
|
136
|
+
return { root, candidate };
|
|
137
|
+
}
|
|
138
|
+
async function assertNoSymlinkInPath(allowedRoot, candidatePath) {
|
|
139
|
+
const { root, candidate } = assertPathBoundary(allowedRoot, candidatePath);
|
|
140
|
+
const relativeSegments = path.relative(root, candidate).split(path.sep);
|
|
141
|
+
const paths = [root];
|
|
142
|
+
let current = root;
|
|
143
|
+
for (const segment of relativeSegments) {
|
|
144
|
+
current = path.join(current, segment);
|
|
145
|
+
paths.push(current);
|
|
146
|
+
}
|
|
147
|
+
for (const currentPath of paths) {
|
|
148
|
+
const stats = await fs.lstat(currentPath).catch((error) => {
|
|
149
|
+
if (isMissing(error))
|
|
150
|
+
return null;
|
|
151
|
+
throw error;
|
|
152
|
+
});
|
|
153
|
+
if (stats?.isSymbolicLink()) {
|
|
154
|
+
throw new OwnershipSymlinkError(`Ownership 路径不能包含符号链接:${currentPath}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async function atomicReplaceFile(options) {
|
|
159
|
+
await atomicReplaceSafeFile({
|
|
160
|
+
filePath: options.path,
|
|
161
|
+
allowedRoot: options.allowedRoot,
|
|
162
|
+
content: options.content,
|
|
163
|
+
mode: 0o666,
|
|
164
|
+
label: 'Ownership path',
|
|
165
|
+
temporaryTag: 'owner',
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
export async function assertOwnedSkillPath(options) {
|
|
169
|
+
validateOwnerIdentity(options.identity);
|
|
170
|
+
assertSafeOwnershipSegment(path.basename(options.skillRoot), 'Skill 目录名');
|
|
171
|
+
if (path.basename(options.skillRoot) !== options.identity.artifactKey) {
|
|
172
|
+
throw new Error('Skill 目录名必须与 owner artifactKey 一致。');
|
|
173
|
+
}
|
|
174
|
+
await assertNoSymlinkInPath(options.allowedRoot, options.skillRoot);
|
|
175
|
+
}
|
|
176
|
+
export async function writeSkillOwnerMarker(options) {
|
|
177
|
+
await assertOwnedSkillPath(options);
|
|
178
|
+
const stats = await fs.lstat(options.skillRoot).catch((error) => {
|
|
179
|
+
if (isMissing(error))
|
|
180
|
+
return null;
|
|
181
|
+
throw error;
|
|
182
|
+
});
|
|
183
|
+
if (!stats?.isDirectory()) {
|
|
184
|
+
throw new Error(`Skill owner marker 目标必须是真实目录:${options.skillRoot}`);
|
|
185
|
+
}
|
|
186
|
+
const markerPath = path.join(options.skillRoot, SKILL_OWNER_MARKER);
|
|
187
|
+
await atomicReplaceFile({
|
|
188
|
+
path: markerPath,
|
|
189
|
+
allowedRoot: options.allowedRoot,
|
|
190
|
+
content: createSkillOwnerMarkerContent(options.identity),
|
|
191
|
+
});
|
|
192
|
+
return markerPath;
|
|
193
|
+
}
|
|
194
|
+
async function readMarkerAt(markerPath) {
|
|
195
|
+
let raw;
|
|
196
|
+
try {
|
|
197
|
+
raw = await fs.readFile(markerPath, 'utf8');
|
|
198
|
+
}
|
|
199
|
+
catch (error) {
|
|
200
|
+
if (isMissing(error))
|
|
201
|
+
return null;
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
let parsed;
|
|
205
|
+
try {
|
|
206
|
+
parsed = JSON.parse(raw);
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
throw new Error(`Skill owner marker 不是有效 JSON:${markerPath}`);
|
|
210
|
+
}
|
|
211
|
+
return markerFromIdentity(parseOwnerIdentity(parsed, 'Skill owner marker'));
|
|
212
|
+
}
|
|
213
|
+
export async function readSkillOwnerMarker(options) {
|
|
214
|
+
if (options.expectedIdentity) {
|
|
215
|
+
await assertOwnedSkillPath({
|
|
216
|
+
skillRoot: options.skillRoot,
|
|
217
|
+
allowedRoot: options.allowedRoot,
|
|
218
|
+
identity: options.expectedIdentity,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
assertSafeOwnershipSegment(path.basename(options.skillRoot), 'Skill 目录名');
|
|
223
|
+
await assertNoSymlinkInPath(options.allowedRoot, options.skillRoot);
|
|
224
|
+
}
|
|
225
|
+
const markerPath = path.join(options.skillRoot, SKILL_OWNER_MARKER);
|
|
226
|
+
await assertNoSymlinkInPath(options.allowedRoot, markerPath);
|
|
227
|
+
const marker = await readMarkerAt(markerPath);
|
|
228
|
+
if (!marker)
|
|
229
|
+
return null;
|
|
230
|
+
if (marker.artifactKey !== path.basename(options.skillRoot)) {
|
|
231
|
+
throw new Error('Skill owner marker artifactKey 与目录名不一致。');
|
|
232
|
+
}
|
|
233
|
+
if (options.expectedIdentity && !identitiesEqual(marker, options.expectedIdentity)) {
|
|
234
|
+
throw new Error('Skill owner marker identity 与目标 identity 不匹配。');
|
|
235
|
+
}
|
|
236
|
+
return marker;
|
|
237
|
+
}
|
|
238
|
+
function ownerHeader(identity) {
|
|
239
|
+
return `${OWNED_TEXT_HEADER_PREFIX}${JSON.stringify(markerFromIdentity(identity))}`;
|
|
240
|
+
}
|
|
241
|
+
function frontmatterHeaderIndex(content) {
|
|
242
|
+
if (!content.startsWith('---\n'))
|
|
243
|
+
return 0;
|
|
244
|
+
const end = content.indexOf('\n---\n', 4);
|
|
245
|
+
if (end === -1) {
|
|
246
|
+
throw new Error('Owner header 目标包含未闭合的 YAML frontmatter。');
|
|
247
|
+
}
|
|
248
|
+
return end + '\n---\n'.length;
|
|
249
|
+
}
|
|
250
|
+
export function renderOwnedTextFile(content, identity) {
|
|
251
|
+
validateOwnerIdentity(identity);
|
|
252
|
+
const normalized = content.replace(/\r\n/gu, '\n');
|
|
253
|
+
const index = frontmatterHeaderIndex(normalized);
|
|
254
|
+
return `${normalized.slice(0, index)}${ownerHeader(identity)}\n${normalized.slice(index)}`;
|
|
255
|
+
}
|
|
256
|
+
export function parseOwnedTextHeader(content, expectedIdentity) {
|
|
257
|
+
const normalized = content.replace(/\r\n/gu, '\n');
|
|
258
|
+
const index = frontmatterHeaderIndex(normalized);
|
|
259
|
+
const lineEnd = normalized.indexOf('\n', index);
|
|
260
|
+
const headerLine = normalized.slice(index, lineEnd === -1 ? normalized.length : lineEnd);
|
|
261
|
+
const occurrences = normalized.split('\n').filter((line) => line.startsWith(OWNED_TEXT_HEADER_PREFIX));
|
|
262
|
+
if (!headerLine.startsWith(OWNED_TEXT_HEADER_PREFIX)) {
|
|
263
|
+
if (occurrences.length > 0)
|
|
264
|
+
throw new Error('Owner header 不在允许的位置。');
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
267
|
+
if (occurrences.length !== 1)
|
|
268
|
+
throw new Error('Owner header 必须且只能出现一次。');
|
|
269
|
+
let parsed;
|
|
270
|
+
try {
|
|
271
|
+
parsed = JSON.parse(headerLine.slice(OWNED_TEXT_HEADER_PREFIX.length));
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
throw new Error('Owner header 不是有效 JSON。');
|
|
275
|
+
}
|
|
276
|
+
const identity = parseOwnerIdentity(parsed, 'Owner header');
|
|
277
|
+
if (expectedIdentity && !identitiesEqual(identity, expectedIdentity)) {
|
|
278
|
+
throw new Error('Owner header identity 与目标 identity 不匹配。');
|
|
279
|
+
}
|
|
280
|
+
const contentStart = lineEnd === -1 ? normalized.length : lineEnd + 1;
|
|
281
|
+
return {
|
|
282
|
+
identity,
|
|
283
|
+
content: normalized.slice(0, index) + normalized.slice(contentStart),
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
export async function writeOwnedTextFile(options) {
|
|
287
|
+
validateOwnerIdentity(options.identity);
|
|
288
|
+
await atomicReplaceFile({
|
|
289
|
+
path: options.path,
|
|
290
|
+
allowedRoot: options.allowedRoot,
|
|
291
|
+
content: renderOwnedTextFile(options.content, options.identity),
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
async function inspectPathAt(component, actualPath, canonicalPath, executor) {
|
|
295
|
+
try {
|
|
296
|
+
await assertNoSymlinkInPath(component.allowedRoot, actualPath);
|
|
297
|
+
}
|
|
298
|
+
catch (error) {
|
|
299
|
+
if (error instanceof OwnershipSymlinkError)
|
|
300
|
+
return foreignProbe(component, 'typeMismatch');
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
const stats = await fs.lstat(actualPath).catch((error) => {
|
|
304
|
+
if (isMissing(error))
|
|
305
|
+
return null;
|
|
306
|
+
throw error;
|
|
307
|
+
});
|
|
308
|
+
if (!stats)
|
|
309
|
+
return { state: 'absent' };
|
|
310
|
+
if (component.kind === 'skill-directory') {
|
|
311
|
+
if (!stats.isDirectory())
|
|
312
|
+
return foreignProbe(component, 'typeMismatch');
|
|
313
|
+
const markerPath = path.join(actualPath, SKILL_OWNER_MARKER);
|
|
314
|
+
try {
|
|
315
|
+
await assertNoSymlinkInPath(component.allowedRoot, markerPath);
|
|
316
|
+
}
|
|
317
|
+
catch (error) {
|
|
318
|
+
if (error instanceof OwnershipSymlinkError)
|
|
319
|
+
return foreignProbe(component, 'typeMismatch');
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
let marker;
|
|
323
|
+
try {
|
|
324
|
+
marker = await readMarkerAt(markerPath);
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
if (error.code)
|
|
328
|
+
throw error;
|
|
329
|
+
return foreignProbe(component, 'unownedContent');
|
|
330
|
+
}
|
|
331
|
+
if (!marker) {
|
|
332
|
+
const pristine = component.pristineTree && executor?.skillDirectoryMatchesPristineTree
|
|
333
|
+
? await executor.skillDirectoryMatchesPristineTree({
|
|
334
|
+
actualPath,
|
|
335
|
+
files: component.pristineTree,
|
|
336
|
+
})
|
|
337
|
+
: false;
|
|
338
|
+
return pristine
|
|
339
|
+
? { state: 'absent' }
|
|
340
|
+
: foreignProbe(component, 'unownedContent');
|
|
341
|
+
}
|
|
342
|
+
if (!identitiesEqual(marker, component.identity)) {
|
|
343
|
+
return foreignProbe(component, 'ownerMismatch', publicOwner(marker));
|
|
344
|
+
}
|
|
345
|
+
if (canonicalPath && path.basename(actualPath) !== component.identity.artifactKey) {
|
|
346
|
+
return foreignProbe(component, 'ownerMismatch', publicOwner(marker));
|
|
347
|
+
}
|
|
348
|
+
return { state: 'present' };
|
|
349
|
+
}
|
|
350
|
+
if (!stats.isFile())
|
|
351
|
+
return foreignProbe(component, 'typeMismatch');
|
|
352
|
+
let raw;
|
|
353
|
+
try {
|
|
354
|
+
raw = await fs.readFile(actualPath, 'utf8');
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
if (isMissing(error))
|
|
358
|
+
return { state: 'absent' };
|
|
359
|
+
throw error;
|
|
360
|
+
}
|
|
361
|
+
try {
|
|
362
|
+
const parsed = parseOwnedTextHeader(raw);
|
|
363
|
+
if (!parsed)
|
|
364
|
+
return foreignProbe(component, 'unownedContent');
|
|
365
|
+
return identitiesEqual(parsed.identity, component.identity)
|
|
366
|
+
? { state: 'present' }
|
|
367
|
+
: foreignProbe(component, 'ownerMismatch', publicOwner(parsed.identity));
|
|
368
|
+
}
|
|
369
|
+
catch {
|
|
370
|
+
return foreignProbe(component, 'unownedContent');
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function publicOwner(identity) {
|
|
374
|
+
return identity.pluginId ?? identity.plugin;
|
|
375
|
+
}
|
|
376
|
+
function forceArtifactBasenameMatches(component) {
|
|
377
|
+
const basename = path.basename(component.path);
|
|
378
|
+
if (component.kind === 'skill-directory')
|
|
379
|
+
return basename === component.identity.artifactKey;
|
|
380
|
+
const stem = basename.replace(/\.[^.]+$/u, '');
|
|
381
|
+
const slug = (value) => value.trim().toLowerCase()
|
|
382
|
+
.replace(/[^a-z0-9]+/gu, '-')
|
|
383
|
+
.replace(/^-+|-+$/gu, '');
|
|
384
|
+
return stem === component.identity.artifactKey
|
|
385
|
+
|| stem === `aw-${slug(component.identity.plugin)}-${slug(component.identity.artifactKey)}`;
|
|
386
|
+
}
|
|
387
|
+
async function inspectForceExclusivePathAt(component, actualPath, canonicalPath) {
|
|
388
|
+
validateOwnerIdentity(component.identity);
|
|
389
|
+
if (canonicalPath && !forceArtifactBasenameMatches(component)) {
|
|
390
|
+
return foreignProbe(component, 'ownerMismatch');
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
await assertNoSymlinkInPath(component.allowedRoot, actualPath);
|
|
394
|
+
}
|
|
395
|
+
catch (error) {
|
|
396
|
+
if (error instanceof OwnershipSymlinkError)
|
|
397
|
+
return foreignProbe(component, 'typeMismatch');
|
|
398
|
+
throw error;
|
|
399
|
+
}
|
|
400
|
+
const stats = await fs.lstat(actualPath).catch((error) => {
|
|
401
|
+
if (isMissing(error))
|
|
402
|
+
return null;
|
|
403
|
+
throw error;
|
|
404
|
+
});
|
|
405
|
+
if (!stats)
|
|
406
|
+
return { state: 'absent' };
|
|
407
|
+
if (component.kind === 'skill-directory') {
|
|
408
|
+
if (!stats.isDirectory())
|
|
409
|
+
return foreignProbe(component, 'typeMismatch');
|
|
410
|
+
const markerPath = path.join(actualPath, SKILL_OWNER_MARKER);
|
|
411
|
+
try {
|
|
412
|
+
await assertNoSymlinkInPath(component.allowedRoot, markerPath);
|
|
413
|
+
}
|
|
414
|
+
catch (error) {
|
|
415
|
+
if (error instanceof OwnershipSymlinkError)
|
|
416
|
+
return foreignProbe(component, 'typeMismatch');
|
|
417
|
+
throw error;
|
|
418
|
+
}
|
|
419
|
+
try {
|
|
420
|
+
const marker = await readMarkerAt(markerPath);
|
|
421
|
+
if (!marker)
|
|
422
|
+
return { state: 'present' };
|
|
423
|
+
return identitiesEqual(marker, component.identity)
|
|
424
|
+
? { state: 'present' }
|
|
425
|
+
: foreignProbe(component, 'ownerMismatch', publicOwner(marker));
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
if (error.code)
|
|
429
|
+
throw error;
|
|
430
|
+
return { state: 'present' };
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
if (!stats.isFile())
|
|
434
|
+
return foreignProbe(component, 'typeMismatch');
|
|
435
|
+
const raw = await fs.readFile(actualPath, 'utf8').catch((error) => {
|
|
436
|
+
if (isMissing(error))
|
|
437
|
+
return null;
|
|
438
|
+
throw error;
|
|
439
|
+
});
|
|
440
|
+
if (raw === null)
|
|
441
|
+
return { state: 'absent' };
|
|
442
|
+
try {
|
|
443
|
+
const parsed = parseOwnedTextHeader(raw);
|
|
444
|
+
if (!parsed)
|
|
445
|
+
return { state: 'present' };
|
|
446
|
+
return identitiesEqual(parsed.identity, component.identity)
|
|
447
|
+
? { state: 'present' }
|
|
448
|
+
: foreignProbe(component, 'ownerMismatch', publicOwner(parsed.identity));
|
|
449
|
+
}
|
|
450
|
+
catch {
|
|
451
|
+
return { state: 'present' };
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
function foreignProbe(component, reason, actualOwner) {
|
|
455
|
+
return {
|
|
456
|
+
state: 'foreign',
|
|
457
|
+
collision: {
|
|
458
|
+
reason,
|
|
459
|
+
artifactKind: component.kind,
|
|
460
|
+
artifactKey: component.identity.artifactKey,
|
|
461
|
+
expectedOwner: publicOwner(component.identity),
|
|
462
|
+
...(actualOwner ? { actualOwner } : {}),
|
|
463
|
+
},
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
function componentLabel(component) {
|
|
467
|
+
if ('path' in component)
|
|
468
|
+
return component.path;
|
|
469
|
+
if (component.kind === 'native-plugin')
|
|
470
|
+
return component.pluginId;
|
|
471
|
+
return component.label;
|
|
472
|
+
}
|
|
473
|
+
function validateNativePlugin(component) {
|
|
474
|
+
validateOwnerIdentity(component.identity);
|
|
475
|
+
const prefix = `${component.identity.plugin}@aw`;
|
|
476
|
+
if (component.pluginId !== prefix
|
|
477
|
+
&& (!component.pluginId.startsWith(`${prefix}-`)
|
|
478
|
+
|| !/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(component.pluginId.slice(`${prefix}-`.length)))) {
|
|
479
|
+
throw new Error(`Native plugin identity 必须使用 ${prefix} marketplace namespace。`);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
async function inspectComponent(component, nativeProbe, executor) {
|
|
483
|
+
validateOwnerIdentity(component.identity);
|
|
484
|
+
if ('path' in component)
|
|
485
|
+
return inspectPathAt(component, component.path, true, executor);
|
|
486
|
+
if (component.kind === 'native-plugin') {
|
|
487
|
+
validateNativePlugin(component);
|
|
488
|
+
if (!nativeProbe)
|
|
489
|
+
throw new Error('Native ownership inspection 缺少 nativeProbe。');
|
|
490
|
+
const state = await nativeProbe(component);
|
|
491
|
+
return state === 'foreign' ? foreignProbe(component, 'ownerMismatch') : { state };
|
|
492
|
+
}
|
|
493
|
+
if (!executor)
|
|
494
|
+
throw new Error('Shared ownership inspection 缺少 executor。');
|
|
495
|
+
const state = await executor.inspectShared(component);
|
|
496
|
+
return state === 'foreign' ? foreignProbe(component, 'ownerMismatch') : { state };
|
|
497
|
+
}
|
|
498
|
+
export async function inspectOwnedComponents(options) {
|
|
499
|
+
const components = [];
|
|
500
|
+
const errors = [];
|
|
501
|
+
for (const component of options.components) {
|
|
502
|
+
const label = componentLabel(component);
|
|
503
|
+
try {
|
|
504
|
+
const result = await (options.forceExclusive && 'path' in component
|
|
505
|
+
? inspectForceExclusivePathAt(component, component.path, true)
|
|
506
|
+
: inspectComponent(component, options.nativeProbe, options.executor));
|
|
507
|
+
let probe = result.state;
|
|
508
|
+
let healthDiagnostic;
|
|
509
|
+
if (options.verifyHealth
|
|
510
|
+
&& probe === 'present'
|
|
511
|
+
&& component.kind === 'skill-directory'
|
|
512
|
+
&& component.validateHealth === true) {
|
|
513
|
+
try {
|
|
514
|
+
if (!options.executor?.validateSkillDirectory) {
|
|
515
|
+
throw new Error('Skill health inspection 缺少 executor。');
|
|
516
|
+
}
|
|
517
|
+
await options.executor.validateSkillDirectory(component);
|
|
518
|
+
}
|
|
519
|
+
catch (error) {
|
|
520
|
+
probe = 'partial';
|
|
521
|
+
healthDiagnostic = errorMessage(error);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
components.push({
|
|
525
|
+
component,
|
|
526
|
+
state: probe,
|
|
527
|
+
...(result.collision ? { collision: result.collision } : {}),
|
|
528
|
+
...(probe === 'foreign'
|
|
529
|
+
? { diagnostic: `存在 foreign collision:${label}` }
|
|
530
|
+
: healthDiagnostic
|
|
531
|
+
? { diagnostic: healthDiagnostic }
|
|
532
|
+
: probe === 'partial'
|
|
533
|
+
? { diagnostic: `组件归属有效但内容或启用状态不完整:${label}` }
|
|
534
|
+
: {}),
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
catch (error) {
|
|
538
|
+
const message = errorMessage(error);
|
|
539
|
+
components.push({ component, state: 'error', diagnostic: message });
|
|
540
|
+
errors.push({ label, message });
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
const state = errors.length > 0
|
|
544
|
+
? 'error'
|
|
545
|
+
: components.length === 0 || components.every((entry) => (entry.state === 'absent' || entry.state === 'foreign'))
|
|
546
|
+
? 'absent'
|
|
547
|
+
: components.every((entry) => entry.state === 'present')
|
|
548
|
+
? 'present'
|
|
549
|
+
: 'partial';
|
|
550
|
+
return { state, components, errors };
|
|
551
|
+
}
|
|
552
|
+
function pushUnique(values, value) {
|
|
553
|
+
if (!values.includes(value))
|
|
554
|
+
values.push(value);
|
|
555
|
+
}
|
|
556
|
+
async function cleanupPathComponent(options) {
|
|
557
|
+
const { component, result } = options;
|
|
558
|
+
const label = componentLabel(component);
|
|
559
|
+
const quarantinePath = path.join(path.resolve(component.allowedRoot), `.agent-workflows-quarantine-${process.pid}-${crypto.randomUUID()}`);
|
|
560
|
+
try {
|
|
561
|
+
await assertNoSymlinkInPath(component.allowedRoot, component.path);
|
|
562
|
+
assertPathBoundary(component.allowedRoot, quarantinePath);
|
|
563
|
+
await nodeFs.rename(component.path, quarantinePath);
|
|
564
|
+
}
|
|
565
|
+
catch (error) {
|
|
566
|
+
result.failures.push({ label, phase: 'mutation', message: errorMessage(error) });
|
|
567
|
+
pushUnique(result.residual, label);
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
try {
|
|
571
|
+
await options.afterQuarantine?.(component, quarantinePath);
|
|
572
|
+
}
|
|
573
|
+
catch (error) {
|
|
574
|
+
result.failures.push({
|
|
575
|
+
label,
|
|
576
|
+
phase: 'verify',
|
|
577
|
+
message: errorMessage(error),
|
|
578
|
+
quarantinePath,
|
|
579
|
+
});
|
|
580
|
+
pushUnique(result.quarantined, quarantinePath);
|
|
581
|
+
pushUnique(result.residual, label);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
let verified;
|
|
585
|
+
try {
|
|
586
|
+
verified = (await (options.forceExclusive
|
|
587
|
+
? inspectForceExclusivePathAt(component, quarantinePath, false)
|
|
588
|
+
: inspectPathAt(component, quarantinePath, false, options.executor))).state;
|
|
589
|
+
}
|
|
590
|
+
catch (error) {
|
|
591
|
+
result.failures.push({
|
|
592
|
+
label,
|
|
593
|
+
phase: 'verify',
|
|
594
|
+
message: errorMessage(error),
|
|
595
|
+
quarantinePath,
|
|
596
|
+
});
|
|
597
|
+
// Never restore automatically after verification starts. The canonical path can now belong to
|
|
598
|
+
// a concurrent foreign writer; the exact quarantine path is returned for manual recovery.
|
|
599
|
+
pushUnique(result.quarantined, quarantinePath);
|
|
600
|
+
pushUnique(result.residual, label);
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
if (verified !== 'present') {
|
|
604
|
+
result.failures.push({
|
|
605
|
+
label,
|
|
606
|
+
phase: 'verify',
|
|
607
|
+
message: 'Quarantine 对象的 type/owner 与目标 identity 不匹配。',
|
|
608
|
+
quarantinePath,
|
|
609
|
+
});
|
|
610
|
+
pushUnique(result.quarantined, quarantinePath);
|
|
611
|
+
pushUnique(result.residual, label);
|
|
612
|
+
return;
|
|
613
|
+
}
|
|
614
|
+
// A matching marker/header is deletion authorization. Content drift is intentionally out of scope.
|
|
615
|
+
try {
|
|
616
|
+
await fs.remove(quarantinePath);
|
|
617
|
+
}
|
|
618
|
+
catch (error) {
|
|
619
|
+
result.failures.push({
|
|
620
|
+
label,
|
|
621
|
+
phase: 'remove',
|
|
622
|
+
message: errorMessage(error),
|
|
623
|
+
quarantinePath,
|
|
624
|
+
});
|
|
625
|
+
if (await fs.pathExists(quarantinePath))
|
|
626
|
+
pushUnique(result.quarantined, quarantinePath);
|
|
627
|
+
pushUnique(result.residual, label);
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
try {
|
|
631
|
+
const after = await inspectComponent(component, undefined, options.executor);
|
|
632
|
+
if (after.state === 'absent')
|
|
633
|
+
pushUnique(result.removed, label);
|
|
634
|
+
else
|
|
635
|
+
pushUnique(result.residual, label);
|
|
636
|
+
}
|
|
637
|
+
catch (error) {
|
|
638
|
+
result.failures.push({ label, phase: 'post-probe', message: errorMessage(error) });
|
|
639
|
+
pushUnique(result.residual, label);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
export async function cleanupOwnedComponents(options) {
|
|
643
|
+
const result = {
|
|
644
|
+
removed: [],
|
|
645
|
+
absent: [],
|
|
646
|
+
residual: [],
|
|
647
|
+
quarantined: [],
|
|
648
|
+
failures: [],
|
|
649
|
+
};
|
|
650
|
+
const probes = new Map();
|
|
651
|
+
for (const component of options.components) {
|
|
652
|
+
const label = componentLabel(component);
|
|
653
|
+
try {
|
|
654
|
+
const probe = (await (options.forceExclusive && 'path' in component
|
|
655
|
+
? inspectForceExclusivePathAt(component, component.path, true)
|
|
656
|
+
: inspectComponent(component, options.nativeProbe, options.executor))).state;
|
|
657
|
+
probes.set(component, probe);
|
|
658
|
+
if (probe === 'absent')
|
|
659
|
+
pushUnique(result.absent, label);
|
|
660
|
+
if (probe === 'foreign' || probe === 'partial')
|
|
661
|
+
pushUnique(result.residual, label);
|
|
662
|
+
}
|
|
663
|
+
catch (error) {
|
|
664
|
+
result.failures.push({ label, phase: 'probe', message: errorMessage(error) });
|
|
665
|
+
pushUnique(result.residual, label);
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
for (const component of options.components) {
|
|
669
|
+
if (probes.get(component) !== 'present')
|
|
670
|
+
continue;
|
|
671
|
+
const label = componentLabel(component);
|
|
672
|
+
try {
|
|
673
|
+
await options.beforeMutation?.(component);
|
|
674
|
+
}
|
|
675
|
+
catch (error) {
|
|
676
|
+
result.failures.push({ label, phase: 'mutation', message: errorMessage(error) });
|
|
677
|
+
pushUnique(result.residual, label);
|
|
678
|
+
continue;
|
|
679
|
+
}
|
|
680
|
+
if ('path' in component) {
|
|
681
|
+
await cleanupPathComponent({
|
|
682
|
+
component,
|
|
683
|
+
result,
|
|
684
|
+
afterQuarantine: options.afterQuarantine,
|
|
685
|
+
executor: options.executor,
|
|
686
|
+
forceExclusive: options.forceExclusive,
|
|
687
|
+
});
|
|
688
|
+
continue;
|
|
689
|
+
}
|
|
690
|
+
try {
|
|
691
|
+
if (component.kind === 'native-plugin') {
|
|
692
|
+
validateNativePlugin(component);
|
|
693
|
+
if (!options.nativeRemove || !options.nativeProbe) {
|
|
694
|
+
throw new Error('Native ownership cleanup 缺少 nativeProbe/nativeRemove。');
|
|
695
|
+
}
|
|
696
|
+
await options.nativeRemove(component);
|
|
697
|
+
}
|
|
698
|
+
else {
|
|
699
|
+
if (!options.executor)
|
|
700
|
+
throw new Error('Shared ownership cleanup 缺少 executor。');
|
|
701
|
+
await options.executor.removeShared(component);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
catch (error) {
|
|
705
|
+
result.failures.push({ label, phase: 'remove', message: errorMessage(error) });
|
|
706
|
+
pushUnique(result.residual, label);
|
|
707
|
+
continue;
|
|
708
|
+
}
|
|
709
|
+
try {
|
|
710
|
+
const after = await inspectComponent(component, options.nativeProbe, options.executor);
|
|
711
|
+
if (after.state === 'absent')
|
|
712
|
+
pushUnique(result.removed, label);
|
|
713
|
+
else
|
|
714
|
+
pushUnique(result.residual, label);
|
|
715
|
+
}
|
|
716
|
+
catch (error) {
|
|
717
|
+
result.failures.push({ label, phase: 'post-probe', message: errorMessage(error) });
|
|
718
|
+
pushUnique(result.residual, label);
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return result;
|
|
722
|
+
}
|
|
723
|
+
//# sourceMappingURL=ownership.js.map
|