@skillsmith/core 0.9.0 → 0.10.0
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 +12 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/src/api/client.d.ts.map +1 -1
- package/dist/src/api/client.js +6 -0
- package/dist/src/api/client.js.map +1 -1
- package/dist/src/api/client.test.d.ts +9 -0
- package/dist/src/api/client.test.d.ts.map +1 -0
- package/dist/src/api/client.test.js +81 -0
- package/dist/src/api/client.test.js.map +1 -0
- package/dist/src/exports/services.d.ts +3 -1
- package/dist/src/exports/services.d.ts.map +1 -1
- package/dist/src/exports/services.js +7 -1
- package/dist/src/exports/services.js.map +1 -1
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/install/agent-config-merge.json-array.d.ts +29 -0
- package/dist/src/install/agent-config-merge.json-array.d.ts.map +1 -0
- package/dist/src/install/agent-config-merge.json-array.js +100 -0
- package/dist/src/install/agent-config-merge.json-array.js.map +1 -0
- package/dist/src/install/agent-config-merge.json.d.ts +37 -0
- package/dist/src/install/agent-config-merge.json.d.ts.map +1 -0
- package/dist/src/install/agent-config-merge.json.js +134 -0
- package/dist/src/install/agent-config-merge.json.js.map +1 -0
- package/dist/src/install/agent-config-merge.toml-block.d.ts +48 -0
- package/dist/src/install/agent-config-merge.toml-block.d.ts.map +1 -0
- package/dist/src/install/agent-config-merge.toml-block.js +107 -0
- package/dist/src/install/agent-config-merge.toml-block.js.map +1 -0
- package/dist/src/install/agent-config-merge.types.d.ts +87 -0
- package/dist/src/install/agent-config-merge.types.d.ts.map +1 -0
- package/dist/src/install/agent-config-merge.types.js +83 -0
- package/dist/src/install/agent-config-merge.types.js.map +1 -0
- package/dist/src/install/agent-config-merge.yaml.d.ts +46 -0
- package/dist/src/install/agent-config-merge.yaml.d.ts.map +1 -0
- package/dist/src/install/agent-config-merge.yaml.js +133 -0
- package/dist/src/install/agent-config-merge.yaml.js.map +1 -0
- package/dist/src/install/agent-config-merge.yaml.test.d.ts +2 -0
- package/dist/src/install/agent-config-merge.yaml.test.d.ts.map +1 -0
- package/dist/src/install/agent-config-merge.yaml.test.js +210 -0
- package/dist/src/install/agent-config-merge.yaml.test.js.map +1 -0
- package/dist/src/install/agent-harness-targets.d.ts +98 -0
- package/dist/src/install/agent-harness-targets.d.ts.map +1 -0
- package/dist/src/install/agent-harness-targets.js +154 -0
- package/dist/src/install/agent-harness-targets.js.map +1 -0
- package/dist/src/install/agent-home-relocate.d.ts +29 -0
- package/dist/src/install/agent-home-relocate.d.ts.map +1 -0
- package/dist/src/install/agent-home-relocate.js +38 -0
- package/dist/src/install/agent-home-relocate.js.map +1 -0
- package/dist/src/install/agent-manifest-path-guard.d.ts +55 -0
- package/dist/src/install/agent-manifest-path-guard.d.ts.map +1 -0
- package/dist/src/install/agent-manifest-path-guard.js +109 -0
- package/dist/src/install/agent-manifest-path-guard.js.map +1 -0
- package/dist/src/install/agent-manifest-path-guard.test.d.ts +2 -0
- package/dist/src/install/agent-manifest-path-guard.test.d.ts.map +1 -0
- package/dist/src/install/agent-manifest-path-guard.test.js +72 -0
- package/dist/src/install/agent-manifest-path-guard.test.js.map +1 -0
- package/dist/src/install/agent-manifest.d.ts +58 -0
- package/dist/src/install/agent-manifest.d.ts.map +1 -0
- package/dist/src/install/agent-manifest.js +103 -0
- package/dist/src/install/agent-manifest.js.map +1 -0
- package/dist/src/install/agent-pack-installer.d.ts +39 -0
- package/dist/src/install/agent-pack-installer.d.ts.map +1 -0
- package/dist/src/install/agent-pack-installer.entry.d.ts +55 -0
- package/dist/src/install/agent-pack-installer.entry.d.ts.map +1 -0
- package/dist/src/install/agent-pack-installer.entry.js +90 -0
- package/dist/src/install/agent-pack-installer.entry.js.map +1 -0
- package/dist/src/install/agent-pack-installer.fs-helpers.d.ts +33 -0
- package/dist/src/install/agent-pack-installer.fs-helpers.d.ts.map +1 -0
- package/dist/src/install/agent-pack-installer.fs-helpers.js +59 -0
- package/dist/src/install/agent-pack-installer.fs-helpers.js.map +1 -0
- package/dist/src/install/agent-pack-installer.harness.d.ts +66 -0
- package/dist/src/install/agent-pack-installer.harness.d.ts.map +1 -0
- package/dist/src/install/agent-pack-installer.harness.js +310 -0
- package/dist/src/install/agent-pack-installer.harness.js.map +1 -0
- package/dist/src/install/agent-pack-installer.js +221 -0
- package/dist/src/install/agent-pack-installer.js.map +1 -0
- package/dist/src/install/agent-pack-installer.preserve.test.d.ts +11 -0
- package/dist/src/install/agent-pack-installer.preserve.test.d.ts.map +1 -0
- package/dist/src/install/agent-pack-installer.preserve.test.js +72 -0
- package/dist/src/install/agent-pack-installer.preserve.test.js.map +1 -0
- package/dist/src/install/agent-pack-installer.test.d.ts +2 -0
- package/dist/src/install/agent-pack-installer.test.d.ts.map +1 -0
- package/dist/src/install/agent-pack-installer.test.js +350 -0
- package/dist/src/install/agent-pack-installer.test.js.map +1 -0
- package/dist/src/install/agent-pack-installer.types.d.ts +51 -0
- package/dist/src/install/agent-pack-installer.types.d.ts.map +1 -0
- package/dist/src/install/agent-pack-installer.types.js +16 -0
- package/dist/src/install/agent-pack-installer.types.js.map +1 -0
- package/dist/src/install/agent-pack-uninstaller.d.ts +43 -0
- package/dist/src/install/agent-pack-uninstaller.d.ts.map +1 -0
- package/dist/src/install/agent-pack-uninstaller.js +113 -0
- package/dist/src/install/agent-pack-uninstaller.js.map +1 -0
- package/dist/src/install/agent-pack-uninstaller.test.d.ts +2 -0
- package/dist/src/install/agent-pack-uninstaller.test.d.ts.map +1 -0
- package/dist/src/install/agent-pack-uninstaller.test.js +212 -0
- package/dist/src/install/agent-pack-uninstaller.test.js.map +1 -0
- package/dist/src/install/index.d.ts +7 -0
- package/dist/src/install/index.d.ts.map +1 -1
- package/dist/src/install/index.js +7 -0
- package/dist/src/install/index.js.map +1 -1
- package/dist/src/install/paths.d.ts +1 -1
- package/dist/src/install/paths.d.ts.map +1 -1
- package/dist/src/install/paths.js +4 -0
- package/dist/src/install/paths.js.map +1 -1
- package/dist/src/install/paths.test.js +15 -0
- package/dist/src/install/paths.test.js.map +1 -1
- package/dist/src/journal/hash.d.ts +13 -0
- package/dist/src/journal/hash.d.ts.map +1 -0
- package/dist/src/journal/hash.js +16 -0
- package/dist/src/journal/hash.js.map +1 -0
- package/dist/src/journal/index.d.ts +15 -0
- package/dist/src/journal/index.d.ts.map +1 -0
- package/dist/src/journal/index.js +15 -0
- package/dist/src/journal/index.js.map +1 -0
- package/dist/src/journal/journal.test.d.ts +16 -0
- package/dist/src/journal/journal.test.d.ts.map +1 -0
- package/dist/src/journal/journal.test.js +171 -0
- package/dist/src/journal/journal.test.js.map +1 -0
- package/dist/src/journal/path.d.ts +44 -0
- package/dist/src/journal/path.d.ts.map +1 -0
- package/dist/src/journal/path.js +61 -0
- package/dist/src/journal/path.js.map +1 -0
- package/dist/src/journal/reader.d.ts +38 -0
- package/dist/src/journal/reader.d.ts.map +1 -0
- package/dist/src/journal/reader.js +93 -0
- package/dist/src/journal/reader.js.map +1 -0
- package/dist/src/journal/types.d.ts +87 -0
- package/dist/src/journal/types.d.ts.map +1 -0
- package/dist/src/journal/types.js +21 -0
- package/dist/src/journal/types.js.map +1 -0
- package/dist/src/journal/writer.d.ts +52 -0
- package/dist/src/journal/writer.d.ts.map +1 -0
- package/dist/src/journal/writer.js +125 -0
- package/dist/src/journal/writer.js.map +1 -0
- package/dist/src/paywall-triggers/index.d.ts +13 -0
- package/dist/src/paywall-triggers/index.d.ts.map +1 -0
- package/dist/src/paywall-triggers/index.js +13 -0
- package/dist/src/paywall-triggers/index.js.map +1 -0
- package/dist/src/paywall-triggers/path.d.ts +47 -0
- package/dist/src/paywall-triggers/path.d.ts.map +1 -0
- package/dist/src/paywall-triggers/path.js +73 -0
- package/dist/src/paywall-triggers/path.js.map +1 -0
- package/dist/src/paywall-triggers/store.d.ts +75 -0
- package/dist/src/paywall-triggers/store.d.ts.map +1 -0
- package/dist/src/paywall-triggers/store.js +122 -0
- package/dist/src/paywall-triggers/store.js.map +1 -0
- package/dist/src/paywall-triggers/store.test.d.ts +2 -0
- package/dist/src/paywall-triggers/store.test.d.ts.map +1 -0
- package/dist/src/paywall-triggers/store.test.js +121 -0
- package/dist/src/paywall-triggers/store.test.js.map +1 -0
- package/dist/src/paywall-triggers/types.d.ts +24 -0
- package/dist/src/paywall-triggers/types.d.ts.map +1 -0
- package/dist/src/paywall-triggers/types.js +13 -0
- package/dist/src/paywall-triggers/types.js.map +1 -0
- package/dist/src/security/scanner/SecurityScanner.compound.d.ts +13 -0
- package/dist/src/security/scanner/SecurityScanner.compound.d.ts.map +1 -0
- package/dist/src/security/scanner/SecurityScanner.compound.js +127 -0
- package/dist/src/security/scanner/SecurityScanner.compound.js.map +1 -0
- package/dist/src/security/scanner/SecurityScanner.d.ts.map +1 -1
- package/dist/src/security/scanner/SecurityScanner.js +10 -1
- package/dist/src/security/scanner/SecurityScanner.js.map +1 -1
- package/dist/src/security/scanner/SecurityScanner.pii.d.ts +23 -0
- package/dist/src/security/scanner/SecurityScanner.pii.d.ts.map +1 -0
- package/dist/src/security/scanner/SecurityScanner.pii.js +152 -0
- package/dist/src/security/scanner/SecurityScanner.pii.js.map +1 -0
- package/dist/src/security/scanner/SecurityScanner.scanners.d.ts +5 -12
- package/dist/src/security/scanner/SecurityScanner.scanners.d.ts.map +1 -1
- package/dist/src/security/scanner/SecurityScanner.scanners.js +63 -137
- package/dist/src/security/scanner/SecurityScanner.scanners.js.map +1 -1
- package/dist/src/security/scanner/patterns.d.ts +2 -0
- package/dist/src/security/scanner/patterns.d.ts.map +1 -1
- package/dist/src/security/scanner/patterns.js +79 -11
- package/dist/src/security/scanner/patterns.js.map +1 -1
- package/dist/src/security/scanner/types.d.ts +2 -0
- package/dist/src/security/scanner/types.d.ts.map +1 -1
- package/dist/src/services/agent-pack/agent-pack.test.d.ts +18 -0
- package/dist/src/services/agent-pack/agent-pack.test.d.ts.map +1 -0
- package/dist/src/services/agent-pack/agent-pack.test.js +344 -0
- package/dist/src/services/agent-pack/agent-pack.test.js.map +1 -0
- package/dist/src/services/agent-pack/hooks.d.ts +29 -0
- package/dist/src/services/agent-pack/hooks.d.ts.map +1 -0
- package/dist/src/services/agent-pack/hooks.js +139 -0
- package/dist/src/services/agent-pack/hooks.js.map +1 -0
- package/dist/src/services/agent-pack/index.d.ts +26 -0
- package/dist/src/services/agent-pack/index.d.ts.map +1 -0
- package/dist/src/services/agent-pack/index.js +109 -0
- package/dist/src/services/agent-pack/index.js.map +1 -0
- package/dist/src/services/agent-pack/prompt-source.d.ts +47 -0
- package/dist/src/services/agent-pack/prompt-source.d.ts.map +1 -0
- package/dist/src/services/agent-pack/prompt-source.js +182 -0
- package/dist/src/services/agent-pack/prompt-source.js.map +1 -0
- package/dist/src/services/agent-pack/shims.d.ts +40 -0
- package/dist/src/services/agent-pack/shims.d.ts.map +1 -0
- package/dist/src/services/agent-pack/shims.js +96 -0
- package/dist/src/services/agent-pack/shims.js.map +1 -0
- package/dist/src/services/agent-pack/skill-md.d.ts +35 -0
- package/dist/src/services/agent-pack/skill-md.d.ts.map +1 -0
- package/dist/src/services/agent-pack/skill-md.js +89 -0
- package/dist/src/services/agent-pack/skill-md.js.map +1 -0
- package/dist/src/services/agent-pack/types.d.ts +118 -0
- package/dist/src/services/agent-pack/types.d.ts.map +1 -0
- package/dist/src/services/agent-pack/types.js +61 -0
- package/dist/src/services/agent-pack/types.js.map +1 -0
- package/dist/src/services/agent-tool-profile.d.ts +59 -0
- package/dist/src/services/agent-tool-profile.d.ts.map +1 -0
- package/dist/src/services/agent-tool-profile.js +76 -0
- package/dist/src/services/agent-tool-profile.js.map +1 -0
- package/dist/src/services/agent-tool-profile.test.d.ts +2 -0
- package/dist/src/services/agent-tool-profile.test.d.ts.map +1 -0
- package/dist/src/services/agent-tool-profile.test.js +28 -0
- package/dist/src/services/agent-tool-profile.test.js.map +1 -0
- package/dist/src/services/bundled-sibling-scan.d.ts +111 -0
- package/dist/src/services/bundled-sibling-scan.d.ts.map +1 -0
- package/dist/src/services/bundled-sibling-scan.js +170 -0
- package/dist/src/services/bundled-sibling-scan.js.map +1 -0
- package/dist/src/services/skill-installation.io.d.ts +16 -5
- package/dist/src/services/skill-installation.io.d.ts.map +1 -1
- package/dist/src/services/skill-installation.io.js +44 -20
- package/dist/src/services/skill-installation.io.js.map +1 -1
- package/dist/src/services/skill-installation.policy.d.ts +96 -0
- package/dist/src/services/skill-installation.policy.d.ts.map +1 -0
- package/dist/src/services/skill-installation.policy.js +144 -0
- package/dist/src/services/skill-installation.policy.js.map +1 -0
- package/dist/src/services/skill-installation.service.d.ts.map +1 -1
- package/dist/src/services/skill-installation.service.js +9 -3
- package/dist/src/services/skill-installation.service.js.map +1 -1
- package/dist/src/sources/index.d.ts +1 -0
- package/dist/src/sources/index.d.ts.map +1 -1
- package/dist/src/sources/index.js +4 -0
- package/dist/src/sources/index.js.map +1 -1
- package/dist/src/sync/index.d.ts +1 -1
- package/dist/src/sync/index.d.ts.map +1 -1
- package/dist/src/sync/index.js +1 -1
- package/dist/src/sync/index.js.map +1 -1
- package/dist/src/sync/inventory-client.d.ts +16 -0
- package/dist/src/sync/inventory-client.d.ts.map +1 -1
- package/dist/src/sync/inventory-client.js +54 -0
- package/dist/src/sync/inventory-client.js.map +1 -1
- package/dist/src/sync/inventory-client.test.js +67 -1
- package/dist/src/sync/inventory-client.test.js.map +1 -1
- package/dist/src/sync/inventory-collector.d.ts.map +1 -1
- package/dist/src/sync/inventory-collector.js +32 -5
- package/dist/src/sync/inventory-collector.js.map +1 -1
- package/dist/src/sync/inventory-collector.test.js +50 -1
- package/dist/src/sync/inventory-collector.test.js.map +1 -1
- package/dist/src/sync/inventory-types.d.ts +9 -0
- package/dist/src/sync/inventory-types.d.ts.map +1 -1
- package/dist/src/sync/inventory-types.js +3 -0
- package/dist/src/sync/inventory-types.js.map +1 -1
- package/dist/src/telemetry/agent-marker.d.ts +137 -0
- package/dist/src/telemetry/agent-marker.d.ts.map +1 -0
- package/dist/src/telemetry/agent-marker.js +242 -0
- package/dist/src/telemetry/agent-marker.js.map +1 -0
- package/dist/src/telemetry/agent-marker.test.d.ts +13 -0
- package/dist/src/telemetry/agent-marker.test.d.ts.map +1 -0
- package/dist/src/telemetry/agent-marker.test.js +202 -0
- package/dist/src/telemetry/agent-marker.test.js.map +1 -0
- package/dist/src/telemetry/index.d.ts +2 -1
- package/dist/src/telemetry/index.d.ts.map +1 -1
- package/dist/src/telemetry/index.js +6 -1
- package/dist/src/telemetry/index.js.map +1 -1
- package/dist/src/telemetry/posthog.d.ts +10 -0
- package/dist/src/telemetry/posthog.d.ts.map +1 -1
- package/dist/src/telemetry/posthog.js +5 -1
- package/dist/src/telemetry/posthog.js.map +1 -1
- package/dist/src/telemetry/wrap.d.ts +28 -7
- package/dist/src/telemetry/wrap.d.ts.map +1 -1
- package/dist/src/telemetry/wrap.gate.test.d.ts +22 -0
- package/dist/src/telemetry/wrap.gate.test.d.ts.map +1 -0
- package/dist/src/telemetry/wrap.gate.test.js +197 -0
- package/dist/src/telemetry/wrap.gate.test.js.map +1 -0
- package/dist/src/telemetry/wrap.js +111 -26
- package/dist/src/telemetry/wrap.js.map +1 -1
- package/dist/src/telemetry/wrap.marker.test.d.ts +16 -0
- package/dist/src/telemetry/wrap.marker.test.d.ts.map +1 -0
- package/dist/src/telemetry/wrap.marker.test.js +185 -0
- package/dist/src/telemetry/wrap.marker.test.js.map +1 -0
- package/dist/src/telemetry/wrap.test.js +4 -0
- package/dist/src/telemetry/wrap.test.js.map +1 -1
- package/dist/tests/SecurityScanner.exec.test.js +60 -0
- package/dist/tests/SecurityScanner.exec.test.js.map +1 -1
- package/dist/tests/security/ContinuousSecurity.test.js +10 -4
- package/dist/tests/security/ContinuousSecurity.test.js.map +1 -1
- package/dist/tests/security/SecurityScanner.chmod-evasion.test.d.ts +2 -0
- package/dist/tests/security/SecurityScanner.chmod-evasion.test.d.ts.map +1 -0
- package/dist/tests/security/SecurityScanner.chmod-evasion.test.js +126 -0
- package/dist/tests/security/SecurityScanner.chmod-evasion.test.js.map +1 -0
- package/dist/tests/security/chmod-compound.test.d.ts +2 -0
- package/dist/tests/security/chmod-compound.test.d.ts.map +1 -0
- package/dist/tests/security/chmod-compound.test.js +188 -0
- package/dist/tests/security/chmod-compound.test.js.map +1 -0
- package/dist/tests/security/pii-detection.test.js +24 -0
- package/dist/tests/security/pii-detection.test.js.map +1 -1
- package/dist/tests/security/scanner-regression-guard.test.d.ts +23 -7
- package/dist/tests/security/scanner-regression-guard.test.d.ts.map +1 -1
- package/dist/tests/security/scanner-regression-guard.test.js +27 -11
- package/dist/tests/security/scanner-regression-guard.test.js.map +1 -1
- package/dist/tests/security/sensitive-path-fp.test.d.ts +2 -0
- package/dist/tests/security/sensitive-path-fp.test.d.ts.map +1 -0
- package/dist/tests/security/sensitive-path-fp.test.js +142 -0
- package/dist/tests/security/sensitive-path-fp.test.js.map +1 -0
- package/dist/tests/services/bundled-sibling-scan.test.d.ts +2 -0
- package/dist/tests/services/bundled-sibling-scan.test.d.ts.map +1 -0
- package/dist/tests/services/bundled-sibling-scan.test.js +139 -0
- package/dist/tests/services/bundled-sibling-scan.test.js.map +1 -0
- package/dist/tests/unit/services/skill-installation.io.test.js +166 -0
- package/dist/tests/unit/services/skill-installation.io.test.js.map +1 -1
- package/dist/tests/unit/services/skill-installation.policy.test.d.ts +8 -0
- package/dist/tests/unit/services/skill-installation.policy.test.d.ts.map +1 -0
- package/dist/tests/unit/services/skill-installation.policy.test.js +151 -0
- package/dist/tests/unit/services/skill-installation.policy.test.js.map +1 -0
- package/package.json +23 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inventory-types.js","sourceRoot":"","sources":["../../../src/sync/inventory-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;
|
|
1
|
+
{"version":3,"file":"inventory-types.js","sourceRoot":"","sources":["../../../src/sync/inventory-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA4EH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,GAAG;IACd,oBAAoB,EAAE,GAAG;IACzB,iBAAiB,EAAE,EAAE;IACrB,YAAY,EAAE,EAAE;IAChB,QAAQ,EAAE,EAAE;IACZ,eAAe,EAAE,EAAE;IACnB,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,GAAG;IACjB,WAAW,EAAE,EAAE;IACf,UAAU,EAAE,GAAG;IACf,UAAU,EAAE,GAAG;IACf,WAAW,EAAE,EAAE;IACf,cAAc,EAAE,GAAG;IACnB,gBAAgB,EAAE,GAAG;IACrB,kBAAkB,EAAE,EAAE;IACtB,iBAAiB,EAAE,EAAE;CACb,CAAA;AAEV,wEAAwE;AACxE,MAAM,CAAC,MAAM,yBAAyB,GAAqC;IACzE,MAAM;IACN,QAAQ;IACR,OAAO;CACC,CAAA"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-5456: Agent-mediation marker channel.
|
|
3
|
+
*
|
|
4
|
+
* Wave 1 needs to distinguish agent-mediated skill invocations from ambient
|
|
5
|
+
* ones so the mediation gate (≥25% agent-mediated share by day 30) is
|
|
6
|
+
* measurable. Two channels feed the three per-event telemetry fields
|
|
7
|
+
* (`agent_session`, `nudge_origin`, `trigger_id`) plus the per-harness
|
|
8
|
+
* `framework` attribution (via the vocabulary-validated `harness` hint —
|
|
9
|
+
* the mediation dashboard's per-harness denominator):
|
|
10
|
+
*
|
|
11
|
+
* 1. MCP `_meta` on the tool call (spec-clean; wins when present). No Tier-1
|
|
12
|
+
* harness can inject `_meta` on a genuine agent tool call today (Step-0
|
|
13
|
+
* spike (e)) — hooks only touch `arguments`, the model has no `_meta`
|
|
14
|
+
* schema affordance — so this is forward-looking infrastructure that
|
|
15
|
+
* activates the day a harness ships native support.
|
|
16
|
+
* 2. A session-scoped marker file written by a harness SessionStart hook
|
|
17
|
+
* under `~/.skillsmith/agent-markers/` (PRIMARY channel for Wave 1). The
|
|
18
|
+
* server treats these files as READ-ONLY: it never writes, updates, or
|
|
19
|
+
* deletes them (that is the hook's job at SessionEnd). Stale files that a
|
|
20
|
+
* crashed session left behind expire by a session TTL.
|
|
21
|
+
*
|
|
22
|
+
* A missing / corrupt / expired file is simply "no marker" — never an error.
|
|
23
|
+
*/
|
|
24
|
+
/** On-disk marker schema version — bump on a breaking shape change. */
|
|
25
|
+
export declare const AGENT_MARKER_SCHEMA_VERSION = 1;
|
|
26
|
+
/**
|
|
27
|
+
* Session TTL. A marker older than this (measured from its `started_at`) is
|
|
28
|
+
* ignored as stale.
|
|
29
|
+
*
|
|
30
|
+
* Rationale for 12h: the primary staleness control is the hook deleting its
|
|
31
|
+
* own file at SessionEnd; the TTL only backstops a session that crashed
|
|
32
|
+
* without cleanup. 12h comfortably spans a long interactive working day so a
|
|
33
|
+
* genuinely live session is never expired mid-flight, while still ensuring a
|
|
34
|
+
* marker abandoned by a crash cannot mislabel invocations a day or more later.
|
|
35
|
+
*/
|
|
36
|
+
export declare const AGENT_MARKER_TTL_MS: number;
|
|
37
|
+
/**
|
|
38
|
+
* Max bytes read from a single marker file.
|
|
39
|
+
*
|
|
40
|
+
* `readSessionMarker` runs synchronously on the MCP dispatch hot path (every
|
|
41
|
+
* tool call). A well-formed marker is a handful of scalar fields — a few
|
|
42
|
+
* hundred bytes; 16 KiB is generous headroom. Without this cap a corrupt or
|
|
43
|
+
* hostile file of unbounded size would block the event loop for the full
|
|
44
|
+
* synchronous `readFileSync` + `JSON.parse` on every single tool call until
|
|
45
|
+
* the hook cleans it up (or the TTL elapses, which only affects staleness,
|
|
46
|
+
* not the read cost). Oversized files are treated as corrupt: skipped, never
|
|
47
|
+
* thrown.
|
|
48
|
+
*/
|
|
49
|
+
export declare const AGENT_MARKER_MAX_FILE_BYTES: number;
|
|
50
|
+
/**
|
|
51
|
+
* Accepted `harness` vocabulary — the SMI-5012 wire format's `framework` enum
|
|
52
|
+
* (authoritative list: skill-invoke-telemetry-guide.md § Wire format) minus
|
|
53
|
+
* `'unknown'`. `'unknown'` is the extractor's absence fallback, not a value a
|
|
54
|
+
* marker may assert: accepting it would let a marker file overwrite a real
|
|
55
|
+
* extractor result with noise. Anything outside this set (junk from disk or
|
|
56
|
+
* `_meta`) resolves to `undefined` and never flows into telemetry.
|
|
57
|
+
*/
|
|
58
|
+
export declare const KNOWN_HARNESS_FRAMEWORKS: readonly ["claude-code", "cursor", "continue", "cline", "copilot", "windsurf", "codex", "vscode", "opencode", "hermes"];
|
|
59
|
+
/** A validated harness/framework value from the marker channel. */
|
|
60
|
+
export type HarnessFramework = (typeof KNOWN_HARNESS_FRAMEWORKS)[number];
|
|
61
|
+
/** The "no marker present" resolution — all fields at their neutral default. */
|
|
62
|
+
export declare const NO_AGENT_MARKER: AgentMarker;
|
|
63
|
+
/**
|
|
64
|
+
* Resolved marker — the three per-event fields threaded into the telemetry
|
|
65
|
+
* payload. Always fully populated (neutral defaults when no marker resolves).
|
|
66
|
+
*/
|
|
67
|
+
export interface AgentMarker {
|
|
68
|
+
/** True when the invocation is part of an agent-mediated session. */
|
|
69
|
+
agentSession: boolean;
|
|
70
|
+
/** True when the invocation originated from a nudge (job-9 onboarding). */
|
|
71
|
+
nudgeOrigin: boolean;
|
|
72
|
+
/** Paywall / nudge trigger id, or `null` when none applies. */
|
|
73
|
+
triggerId: string | null;
|
|
74
|
+
/**
|
|
75
|
+
* Validated harness identity from the marker channel (the file's `harness`
|
|
76
|
+
* hint or `_meta.harness`). Feeds the event's `framework` field when the
|
|
77
|
+
* per-call extractor has nothing better (see wrap.ts). Absent when the
|
|
78
|
+
* channel supplied no value or an out-of-vocabulary one.
|
|
79
|
+
*/
|
|
80
|
+
harness?: HarnessFramework;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* On-disk marker file shape (snake_case to match the telemetry wire format).
|
|
84
|
+
* Written by a harness SessionStart hook; only ever READ by the server.
|
|
85
|
+
*/
|
|
86
|
+
export interface AgentMarkerFile {
|
|
87
|
+
/** Schema version (see `AGENT_MARKER_SCHEMA_VERSION`). */
|
|
88
|
+
schema?: number;
|
|
89
|
+
/** Harness session identifier (the hook's `session_id`). */
|
|
90
|
+
session_id: string;
|
|
91
|
+
/** Epoch-ms session start; the TTL is measured from this. */
|
|
92
|
+
started_at: number;
|
|
93
|
+
/** Optional harness hint, e.g. `'claude-code'`, `'cursor'`, `'opencode'`. */
|
|
94
|
+
harness?: string;
|
|
95
|
+
/** Agent session? Defaults true for a valid marker; set false to opt out. */
|
|
96
|
+
agent_session?: boolean;
|
|
97
|
+
/** Nudge-originated? Defaults false. */
|
|
98
|
+
nudge_origin?: boolean;
|
|
99
|
+
/** Trigger id, or null. Defaults null. */
|
|
100
|
+
trigger_id?: string | null;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Read the freshest non-expired session marker from `~/.skillsmith/agent-markers/`.
|
|
104
|
+
*
|
|
105
|
+
* Wave-1 correlation note: the server cannot know its own harness session id,
|
|
106
|
+
* so it selects the most recently started live marker. Concurrent sessions on
|
|
107
|
+
* one machine may therefore observe each other's marker — an accepted,
|
|
108
|
+
* documented imprecision (the `_meta` channel is exact and wins when present).
|
|
109
|
+
*
|
|
110
|
+
* @returns the resolved marker, or null when no live marker exists.
|
|
111
|
+
*/
|
|
112
|
+
export declare function readSessionMarker(opts?: {
|
|
113
|
+
now?: number;
|
|
114
|
+
}): AgentMarker | null;
|
|
115
|
+
/**
|
|
116
|
+
* Defensively extract the marker fields from an MCP request's `_meta`.
|
|
117
|
+
*
|
|
118
|
+
* `_meta` is a loose passthrough schema (SDK 1.29.0), so junk keys and wrong
|
|
119
|
+
* types must be ignored. Keys are snake_case to match the wire format:
|
|
120
|
+
* `agent_session`, `nudge_origin`, `trigger_id`, `harness`. Only well-typed
|
|
121
|
+
* values are returned; everything else is dropped (`harness` additionally
|
|
122
|
+
* gated on the `KNOWN_HARNESS_FRAMEWORKS` vocabulary).
|
|
123
|
+
*/
|
|
124
|
+
export declare function extractMarkerMeta(meta: unknown): Partial<AgentMarker>;
|
|
125
|
+
/**
|
|
126
|
+
* Resolve the agent marker for a single tool call.
|
|
127
|
+
*
|
|
128
|
+
* Per-field precedence: a value present in `_meta` wins; otherwise the session
|
|
129
|
+
* marker file supplies it; otherwise the neutral default (`false`/`false`/`null`).
|
|
130
|
+
*
|
|
131
|
+
* @param meta - the MCP request's `_meta` object (or undefined).
|
|
132
|
+
* @param opts.now - injectable clock for tests.
|
|
133
|
+
*/
|
|
134
|
+
export declare function resolveAgentMarker(meta: unknown, opts?: {
|
|
135
|
+
now?: number;
|
|
136
|
+
}): AgentMarker;
|
|
137
|
+
//# sourceMappingURL=agent-marker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-marker.d.ts","sourceRoot":"","sources":["../../../src/telemetry/agent-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAUH,uEAAuE;AACvE,eAAO,MAAM,2BAA2B,IAAI,CAAA;AAE5C;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,QAAsB,CAAA;AAEtD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,2BAA2B,QAAY,CAAA;AAEpD;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,yHAW3B,CAAA;AAEV,mEAAmE;AACnE,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAA;AAWxE,gFAAgF;AAChF,eAAO,MAAM,eAAe,EAAE,WAI5B,CAAA;AAMF;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,qEAAqE;IACrE,YAAY,EAAE,OAAO,CAAA;IACrB,2EAA2E;IAC3E,WAAW,EAAE,OAAO,CAAA;IACpB,+DAA+D;IAC/D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB;;;;;OAKG;IACH,OAAO,CAAC,EAAE,gBAAgB,CAAA;CAC3B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4DAA4D;IAC5D,UAAU,EAAE,MAAM,CAAA;IAClB,6DAA6D;IAC7D,UAAU,EAAE,MAAM,CAAA;IAClB,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6EAA6E;IAC7E,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,wCAAwC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAkFD;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,WAAW,GAAG,IAAI,CAoBjF;AAMD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAWrE;AAMD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,WAAW,CAS1F"}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-5456: Agent-mediation marker channel.
|
|
3
|
+
*
|
|
4
|
+
* Wave 1 needs to distinguish agent-mediated skill invocations from ambient
|
|
5
|
+
* ones so the mediation gate (≥25% agent-mediated share by day 30) is
|
|
6
|
+
* measurable. Two channels feed the three per-event telemetry fields
|
|
7
|
+
* (`agent_session`, `nudge_origin`, `trigger_id`) plus the per-harness
|
|
8
|
+
* `framework` attribution (via the vocabulary-validated `harness` hint —
|
|
9
|
+
* the mediation dashboard's per-harness denominator):
|
|
10
|
+
*
|
|
11
|
+
* 1. MCP `_meta` on the tool call (spec-clean; wins when present). No Tier-1
|
|
12
|
+
* harness can inject `_meta` on a genuine agent tool call today (Step-0
|
|
13
|
+
* spike (e)) — hooks only touch `arguments`, the model has no `_meta`
|
|
14
|
+
* schema affordance — so this is forward-looking infrastructure that
|
|
15
|
+
* activates the day a harness ships native support.
|
|
16
|
+
* 2. A session-scoped marker file written by a harness SessionStart hook
|
|
17
|
+
* under `~/.skillsmith/agent-markers/` (PRIMARY channel for Wave 1). The
|
|
18
|
+
* server treats these files as READ-ONLY: it never writes, updates, or
|
|
19
|
+
* deletes them (that is the hook's job at SessionEnd). Stale files that a
|
|
20
|
+
* crashed session left behind expire by a session TTL.
|
|
21
|
+
*
|
|
22
|
+
* A missing / corrupt / expired file is simply "no marker" — never an error.
|
|
23
|
+
*/
|
|
24
|
+
import { existsSync, lstatSync, readFileSync, readdirSync } from 'node:fs';
|
|
25
|
+
import { join } from 'node:path';
|
|
26
|
+
import { getConfigDir } from '../config/index.js';
|
|
27
|
+
// ---------------------------------------------------------------------------
|
|
28
|
+
// Constants
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
/** On-disk marker schema version — bump on a breaking shape change. */
|
|
31
|
+
export const AGENT_MARKER_SCHEMA_VERSION = 1;
|
|
32
|
+
/**
|
|
33
|
+
* Session TTL. A marker older than this (measured from its `started_at`) is
|
|
34
|
+
* ignored as stale.
|
|
35
|
+
*
|
|
36
|
+
* Rationale for 12h: the primary staleness control is the hook deleting its
|
|
37
|
+
* own file at SessionEnd; the TTL only backstops a session that crashed
|
|
38
|
+
* without cleanup. 12h comfortably spans a long interactive working day so a
|
|
39
|
+
* genuinely live session is never expired mid-flight, while still ensuring a
|
|
40
|
+
* marker abandoned by a crash cannot mislabel invocations a day or more later.
|
|
41
|
+
*/
|
|
42
|
+
export const AGENT_MARKER_TTL_MS = 12 * 60 * 60 * 1000;
|
|
43
|
+
/**
|
|
44
|
+
* Max bytes read from a single marker file.
|
|
45
|
+
*
|
|
46
|
+
* `readSessionMarker` runs synchronously on the MCP dispatch hot path (every
|
|
47
|
+
* tool call). A well-formed marker is a handful of scalar fields — a few
|
|
48
|
+
* hundred bytes; 16 KiB is generous headroom. Without this cap a corrupt or
|
|
49
|
+
* hostile file of unbounded size would block the event loop for the full
|
|
50
|
+
* synchronous `readFileSync` + `JSON.parse` on every single tool call until
|
|
51
|
+
* the hook cleans it up (or the TTL elapses, which only affects staleness,
|
|
52
|
+
* not the read cost). Oversized files are treated as corrupt: skipped, never
|
|
53
|
+
* thrown.
|
|
54
|
+
*/
|
|
55
|
+
export const AGENT_MARKER_MAX_FILE_BYTES = 16 * 1024;
|
|
56
|
+
/**
|
|
57
|
+
* Accepted `harness` vocabulary — the SMI-5012 wire format's `framework` enum
|
|
58
|
+
* (authoritative list: skill-invoke-telemetry-guide.md § Wire format) minus
|
|
59
|
+
* `'unknown'`. `'unknown'` is the extractor's absence fallback, not a value a
|
|
60
|
+
* marker may assert: accepting it would let a marker file overwrite a real
|
|
61
|
+
* extractor result with noise. Anything outside this set (junk from disk or
|
|
62
|
+
* `_meta`) resolves to `undefined` and never flows into telemetry.
|
|
63
|
+
*/
|
|
64
|
+
export const KNOWN_HARNESS_FRAMEWORKS = [
|
|
65
|
+
'claude-code',
|
|
66
|
+
'cursor',
|
|
67
|
+
'continue',
|
|
68
|
+
'cline',
|
|
69
|
+
'copilot',
|
|
70
|
+
'windsurf',
|
|
71
|
+
'codex',
|
|
72
|
+
'vscode',
|
|
73
|
+
'opencode',
|
|
74
|
+
'hermes',
|
|
75
|
+
];
|
|
76
|
+
const KNOWN_HARNESS_SET = new Set(KNOWN_HARNESS_FRAMEWORKS);
|
|
77
|
+
/** Validate an untrusted harness value; anything not in the vocabulary → undefined. */
|
|
78
|
+
function validHarness(value) {
|
|
79
|
+
return typeof value === 'string' && KNOWN_HARNESS_SET.has(value)
|
|
80
|
+
? value
|
|
81
|
+
: undefined;
|
|
82
|
+
}
|
|
83
|
+
/** The "no marker present" resolution — all fields at their neutral default. */
|
|
84
|
+
export const NO_AGENT_MARKER = Object.freeze({
|
|
85
|
+
agentSession: false,
|
|
86
|
+
nudgeOrigin: false,
|
|
87
|
+
triggerId: null,
|
|
88
|
+
});
|
|
89
|
+
// ---------------------------------------------------------------------------
|
|
90
|
+
// Directory resolution (matches getCacheDir override convention, SMI-4577)
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
/**
|
|
93
|
+
* Resolve `~/.skillsmith/agent-markers/`.
|
|
94
|
+
*
|
|
95
|
+
* `SKILLSMITH_AGENT_MARKER_DIR` overrides the default — mirrors
|
|
96
|
+
* `SKILLSMITH_CACHE_DIR_OVERRIDE`, needed because macOS `os.homedir()`
|
|
97
|
+
* resolves via `getpwuid()` and ignores `process.env.HOME` mutations in tests.
|
|
98
|
+
*
|
|
99
|
+
* Read-only: this only computes the path, it never creates the directory.
|
|
100
|
+
*/
|
|
101
|
+
function getAgentMarkerDir() {
|
|
102
|
+
const override = process.env.SKILLSMITH_AGENT_MARKER_DIR;
|
|
103
|
+
return override && override.length > 0 ? override : join(getConfigDir(), 'agent-markers');
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Read + validate a single marker file. Returns null for anything that is not
|
|
107
|
+
* a well-formed, non-expired marker (corrupt JSON, wrong shape, missing/invalid
|
|
108
|
+
* `started_at`, empty `session_id`, past the TTL, not a regular file, or over
|
|
109
|
+
* `AGENT_MARKER_MAX_FILE_BYTES`). Never throws.
|
|
110
|
+
*/
|
|
111
|
+
function readMarkerFile(path, now) {
|
|
112
|
+
let raw;
|
|
113
|
+
try {
|
|
114
|
+
// `lstatSync` (not `stat`) so a symlink is rejected outright rather than
|
|
115
|
+
// followed — the directory is documented read-only server-side, so a
|
|
116
|
+
// symlink here is never something the reader itself created.
|
|
117
|
+
const stat = lstatSync(path);
|
|
118
|
+
if (!stat.isFile())
|
|
119
|
+
return null;
|
|
120
|
+
if (stat.size > AGENT_MARKER_MAX_FILE_BYTES)
|
|
121
|
+
return null;
|
|
122
|
+
raw = readFileSync(path, 'utf-8');
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
let data;
|
|
128
|
+
try {
|
|
129
|
+
data = JSON.parse(raw);
|
|
130
|
+
}
|
|
131
|
+
catch {
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
if (!data || typeof data !== 'object')
|
|
135
|
+
return null;
|
|
136
|
+
const file = data;
|
|
137
|
+
if (typeof file.session_id !== 'string' || file.session_id.length === 0)
|
|
138
|
+
return null;
|
|
139
|
+
const startedAt = file.started_at;
|
|
140
|
+
if (typeof startedAt !== 'number' || !Number.isFinite(startedAt) || startedAt <= 0)
|
|
141
|
+
return null;
|
|
142
|
+
// Expired: older than the TTL. A future timestamp (clock skew) is not stale.
|
|
143
|
+
if (now - startedAt > AGENT_MARKER_TTL_MS)
|
|
144
|
+
return null;
|
|
145
|
+
return { file: file, startedAt };
|
|
146
|
+
}
|
|
147
|
+
/** Map a validated on-disk file to the resolved marker fields. */
|
|
148
|
+
function markerFromFile(file) {
|
|
149
|
+
return {
|
|
150
|
+
// A valid marker means "agent session" by presence; honour an explicit opt-out.
|
|
151
|
+
agentSession: file.agent_session === false ? false : true,
|
|
152
|
+
nudgeOrigin: file.nudge_origin === true,
|
|
153
|
+
triggerId: typeof file.trigger_id === 'string' ? file.trigger_id : null,
|
|
154
|
+
// Vocabulary-gated: junk from disk must not flow into telemetry.
|
|
155
|
+
harness: validHarness(file.harness),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Read the freshest non-expired session marker from `~/.skillsmith/agent-markers/`.
|
|
160
|
+
*
|
|
161
|
+
* Wave-1 correlation note: the server cannot know its own harness session id,
|
|
162
|
+
* so it selects the most recently started live marker. Concurrent sessions on
|
|
163
|
+
* one machine may therefore observe each other's marker — an accepted,
|
|
164
|
+
* documented imprecision (the `_meta` channel is exact and wins when present).
|
|
165
|
+
*
|
|
166
|
+
* @returns the resolved marker, or null when no live marker exists.
|
|
167
|
+
*/
|
|
168
|
+
export function readSessionMarker(opts = {}) {
|
|
169
|
+
const now = opts.now ?? Date.now();
|
|
170
|
+
const dir = getAgentMarkerDir();
|
|
171
|
+
let names;
|
|
172
|
+
try {
|
|
173
|
+
if (!existsSync(dir))
|
|
174
|
+
return null;
|
|
175
|
+
names = readdirSync(dir).filter((n) => n.endsWith('.json'));
|
|
176
|
+
}
|
|
177
|
+
catch {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
let best = null;
|
|
181
|
+
for (const name of names) {
|
|
182
|
+
const parsed = readMarkerFile(join(dir, name), now);
|
|
183
|
+
if (!parsed)
|
|
184
|
+
continue;
|
|
185
|
+
if (!best || parsed.startedAt > best.startedAt)
|
|
186
|
+
best = parsed;
|
|
187
|
+
}
|
|
188
|
+
return best ? markerFromFile(best.file) : null;
|
|
189
|
+
}
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
// `_meta` extraction
|
|
192
|
+
// ---------------------------------------------------------------------------
|
|
193
|
+
/**
|
|
194
|
+
* Defensively extract the marker fields from an MCP request's `_meta`.
|
|
195
|
+
*
|
|
196
|
+
* `_meta` is a loose passthrough schema (SDK 1.29.0), so junk keys and wrong
|
|
197
|
+
* types must be ignored. Keys are snake_case to match the wire format:
|
|
198
|
+
* `agent_session`, `nudge_origin`, `trigger_id`, `harness`. Only well-typed
|
|
199
|
+
* values are returned; everything else is dropped (`harness` additionally
|
|
200
|
+
* gated on the `KNOWN_HARNESS_FRAMEWORKS` vocabulary).
|
|
201
|
+
*/
|
|
202
|
+
export function extractMarkerMeta(meta) {
|
|
203
|
+
if (!meta || typeof meta !== 'object')
|
|
204
|
+
return {};
|
|
205
|
+
const m = meta;
|
|
206
|
+
const out = {};
|
|
207
|
+
if (typeof m.agent_session === 'boolean')
|
|
208
|
+
out.agentSession = m.agent_session;
|
|
209
|
+
if (typeof m.nudge_origin === 'boolean')
|
|
210
|
+
out.nudgeOrigin = m.nudge_origin;
|
|
211
|
+
if (typeof m.trigger_id === 'string')
|
|
212
|
+
out.triggerId = m.trigger_id;
|
|
213
|
+
else if (m.trigger_id === null)
|
|
214
|
+
out.triggerId = null;
|
|
215
|
+
const metaHarness = validHarness(m.harness);
|
|
216
|
+
if (metaHarness !== undefined)
|
|
217
|
+
out.harness = metaHarness;
|
|
218
|
+
return out;
|
|
219
|
+
}
|
|
220
|
+
// ---------------------------------------------------------------------------
|
|
221
|
+
// Resolution (precedence: _meta wins per-field, else marker file, else default)
|
|
222
|
+
// ---------------------------------------------------------------------------
|
|
223
|
+
/**
|
|
224
|
+
* Resolve the agent marker for a single tool call.
|
|
225
|
+
*
|
|
226
|
+
* Per-field precedence: a value present in `_meta` wins; otherwise the session
|
|
227
|
+
* marker file supplies it; otherwise the neutral default (`false`/`false`/`null`).
|
|
228
|
+
*
|
|
229
|
+
* @param meta - the MCP request's `_meta` object (or undefined).
|
|
230
|
+
* @param opts.now - injectable clock for tests.
|
|
231
|
+
*/
|
|
232
|
+
export function resolveAgentMarker(meta, opts = {}) {
|
|
233
|
+
const fromFile = readSessionMarker(opts) ?? NO_AGENT_MARKER;
|
|
234
|
+
const fromMeta = extractMarkerMeta(meta);
|
|
235
|
+
return {
|
|
236
|
+
agentSession: fromMeta.agentSession ?? fromFile.agentSession,
|
|
237
|
+
nudgeOrigin: fromMeta.nudgeOrigin ?? fromFile.nudgeOrigin,
|
|
238
|
+
triggerId: fromMeta.triggerId !== undefined ? fromMeta.triggerId : fromFile.triggerId,
|
|
239
|
+
harness: fromMeta.harness ?? fromFile.harness,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=agent-marker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-marker.js","sourceRoot":"","sources":["../../../src/telemetry/agent-marker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;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AAyB,EAAE;IAC3E,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,eAAe,CAAA;IAC3D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;IACxC,OAAO;QACL,YAAY,EAAE,QAAQ,CAAC,YAAY,IAAI,QAAQ,CAAC,YAAY;QAC5D,WAAW,EAAE,QAAQ,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW;QACzD,SAAS,EAAE,QAAQ,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,SAAS;QACrF,OAAO,EAAE,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO;KAC9C,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-5456: Tests for the agent-mediation marker channel.
|
|
3
|
+
*
|
|
4
|
+
* Covers the P-5 shared-state invariants for the session marker file:
|
|
5
|
+
* - `_meta` wins over the marker file (per-field precedence)
|
|
6
|
+
* - marker file alone works
|
|
7
|
+
* - neither present ⇒ fields default false / false / null
|
|
8
|
+
* - stale (past-TTL) marker is ignored
|
|
9
|
+
* - corrupt / malformed marker file is ignored, never throws
|
|
10
|
+
* - `_meta` extraction is defensive (junk types dropped)
|
|
11
|
+
*/
|
|
12
|
+
export {};
|
|
13
|
+
//# sourceMappingURL=agent-marker.test.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-marker.test.d.ts","sourceRoot":"","sources":["../../../src/telemetry/agent-marker.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SMI-5456: Tests for the agent-mediation marker channel.
|
|
3
|
+
*
|
|
4
|
+
* Covers the P-5 shared-state invariants for the session marker file:
|
|
5
|
+
* - `_meta` wins over the marker file (per-field precedence)
|
|
6
|
+
* - marker file alone works
|
|
7
|
+
* - neither present ⇒ fields default false / false / null
|
|
8
|
+
* - stale (past-TTL) marker is ignored
|
|
9
|
+
* - corrupt / malformed marker file is ignored, never throws
|
|
10
|
+
* - `_meta` extraction is defensive (junk types dropped)
|
|
11
|
+
*/
|
|
12
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
13
|
+
import { mkdtempSync, writeFileSync, rmSync, symlinkSync } from 'node:fs';
|
|
14
|
+
import { tmpdir } from 'node:os';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { resolveAgentMarker, readSessionMarker, extractMarkerMeta, NO_AGENT_MARKER, AGENT_MARKER_TTL_MS, AGENT_MARKER_SCHEMA_VERSION, AGENT_MARKER_MAX_FILE_BYTES, } from './agent-marker.js';
|
|
17
|
+
let markerDir;
|
|
18
|
+
const NOW = 1_720_000_000_000; // fixed clock for deterministic TTL math
|
|
19
|
+
function writeMarker(name, file) {
|
|
20
|
+
writeFileSync(join(markerDir, name), JSON.stringify(file), 'utf-8');
|
|
21
|
+
}
|
|
22
|
+
function freshMarker(overrides = {}) {
|
|
23
|
+
return {
|
|
24
|
+
schema: AGENT_MARKER_SCHEMA_VERSION,
|
|
25
|
+
session_id: 'sess-1',
|
|
26
|
+
started_at: NOW - 1000,
|
|
27
|
+
harness: 'claude-code',
|
|
28
|
+
...overrides,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
beforeEach(() => {
|
|
32
|
+
markerDir = mkdtempSync(join(tmpdir(), 'skillsmith-marker-'));
|
|
33
|
+
process.env.SKILLSMITH_AGENT_MARKER_DIR = markerDir;
|
|
34
|
+
});
|
|
35
|
+
afterEach(() => {
|
|
36
|
+
delete process.env.SKILLSMITH_AGENT_MARKER_DIR;
|
|
37
|
+
rmSync(markerDir, { recursive: true, force: true });
|
|
38
|
+
});
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
// readSessionMarker
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
describe('readSessionMarker', () => {
|
|
43
|
+
it('returns null when the marker directory does not exist', () => {
|
|
44
|
+
rmSync(markerDir, { recursive: true, force: true });
|
|
45
|
+
expect(readSessionMarker({ now: NOW })).toBeNull();
|
|
46
|
+
});
|
|
47
|
+
it('reads a fresh marker file (presence ⇒ agent session, harness threaded)', () => {
|
|
48
|
+
writeMarker('a.json', freshMarker());
|
|
49
|
+
expect(readSessionMarker({ now: NOW })).toEqual({
|
|
50
|
+
agentSession: true,
|
|
51
|
+
nudgeOrigin: false,
|
|
52
|
+
triggerId: null,
|
|
53
|
+
harness: 'claude-code',
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
it('surfaces explicit nudge_origin + trigger_id from the file', () => {
|
|
57
|
+
writeMarker('a.json', freshMarker({ nudge_origin: true, trigger_id: 'T1' }));
|
|
58
|
+
expect(readSessionMarker({ now: NOW })).toEqual({
|
|
59
|
+
agentSession: true,
|
|
60
|
+
nudgeOrigin: true,
|
|
61
|
+
triggerId: 'T1',
|
|
62
|
+
harness: 'claude-code',
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
it('drops an out-of-vocabulary harness value but keeps the marker', () => {
|
|
66
|
+
writeMarker('a.json', freshMarker({ harness: 'my-cool-editor' }));
|
|
67
|
+
const resolved = readSessionMarker({ now: NOW });
|
|
68
|
+
expect(resolved?.agentSession).toBe(true);
|
|
69
|
+
expect(resolved?.harness).toBeUndefined();
|
|
70
|
+
});
|
|
71
|
+
it('drops a wrongly-typed harness value', () => {
|
|
72
|
+
writeMarker('a.json', freshMarker({ harness: 42 }));
|
|
73
|
+
expect(readSessionMarker({ now: NOW })?.harness).toBeUndefined();
|
|
74
|
+
});
|
|
75
|
+
it('honours an explicit agent_session:false opt-out', () => {
|
|
76
|
+
writeMarker('a.json', freshMarker({ agent_session: false }));
|
|
77
|
+
expect(readSessionMarker({ now: NOW })?.agentSession).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
it('ignores a marker past the TTL', () => {
|
|
80
|
+
writeMarker('a.json', freshMarker({ started_at: NOW - AGENT_MARKER_TTL_MS - 1 }));
|
|
81
|
+
expect(readSessionMarker({ now: NOW })).toBeNull();
|
|
82
|
+
});
|
|
83
|
+
it('keeps a marker exactly at the TTL boundary', () => {
|
|
84
|
+
writeMarker('a.json', freshMarker({ started_at: NOW - AGENT_MARKER_TTL_MS }));
|
|
85
|
+
expect(readSessionMarker({ now: NOW })?.agentSession).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
it('selects the freshest non-expired marker among several', () => {
|
|
88
|
+
writeMarker('old.json', freshMarker({ session_id: 'old', started_at: NOW - 5000 }));
|
|
89
|
+
writeMarker('new.json', freshMarker({ session_id: 'new', started_at: NOW - 100, trigger_id: 'T-NEW' }));
|
|
90
|
+
expect(readSessionMarker({ now: NOW })?.triggerId).toBe('T-NEW');
|
|
91
|
+
});
|
|
92
|
+
it('ignores corrupt JSON without throwing', () => {
|
|
93
|
+
writeFileSync(join(markerDir, 'bad.json'), '{ not valid json', 'utf-8');
|
|
94
|
+
expect(readSessionMarker({ now: NOW })).toBeNull();
|
|
95
|
+
});
|
|
96
|
+
it('ignores a marker missing session_id or started_at', () => {
|
|
97
|
+
writeMarker('no-session.json', { started_at: NOW - 100 });
|
|
98
|
+
writeMarker('no-time.json', { session_id: 'x' });
|
|
99
|
+
expect(readSessionMarker({ now: NOW })).toBeNull();
|
|
100
|
+
});
|
|
101
|
+
it('ignores non-.json files and falls back to a valid sibling', () => {
|
|
102
|
+
writeFileSync(join(markerDir, 'note.txt'), 'ignored', 'utf-8');
|
|
103
|
+
writeMarker('a.json', freshMarker({ trigger_id: 'T2' }));
|
|
104
|
+
expect(readSessionMarker({ now: NOW })?.triggerId).toBe('T2');
|
|
105
|
+
});
|
|
106
|
+
it('ignores a marker file over AGENT_MARKER_MAX_FILE_BYTES without throwing', () => {
|
|
107
|
+
// A well-formed marker is a few hundred bytes; pad `trigger_id` past the
|
|
108
|
+
// cap to simulate a corrupt/hostile oversized file on the hot read path.
|
|
109
|
+
const oversizedTriggerId = 'x'.repeat(AGENT_MARKER_MAX_FILE_BYTES + 1);
|
|
110
|
+
writeMarker('huge.json', freshMarker({ trigger_id: oversizedTriggerId }));
|
|
111
|
+
expect(readSessionMarker({ now: NOW })).toBeNull();
|
|
112
|
+
});
|
|
113
|
+
it('ignores a symlink instead of following it', () => {
|
|
114
|
+
// Target lives OUTSIDE markerDir and is otherwise perfectly valid — if the
|
|
115
|
+
// reader followed the symlink it would resolve `trigger_id: 'OUTSIDE'`.
|
|
116
|
+
// `lstat` must reject the symlink entry before `readFileSync` ever runs.
|
|
117
|
+
const outsideDir = mkdtempSync(join(tmpdir(), 'skillsmith-marker-outside-'));
|
|
118
|
+
const outsidePath = join(outsideDir, 'target.json');
|
|
119
|
+
writeFileSync(outsidePath, JSON.stringify(freshMarker({ trigger_id: 'OUTSIDE' })), 'utf-8');
|
|
120
|
+
symlinkSync(outsidePath, join(markerDir, 'link.json'));
|
|
121
|
+
expect(readSessionMarker({ now: NOW })).toBeNull();
|
|
122
|
+
rmSync(outsideDir, { recursive: true, force: true });
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
// ---------------------------------------------------------------------------
|
|
126
|
+
// extractMarkerMeta (defensive _meta validation)
|
|
127
|
+
// ---------------------------------------------------------------------------
|
|
128
|
+
describe('extractMarkerMeta', () => {
|
|
129
|
+
it('returns empty for non-object input', () => {
|
|
130
|
+
expect(extractMarkerMeta(undefined)).toEqual({});
|
|
131
|
+
expect(extractMarkerMeta(null)).toEqual({});
|
|
132
|
+
expect(extractMarkerMeta('nope')).toEqual({});
|
|
133
|
+
expect(extractMarkerMeta(42)).toEqual({});
|
|
134
|
+
});
|
|
135
|
+
it('extracts well-typed fields', () => {
|
|
136
|
+
expect(extractMarkerMeta({ agent_session: true, nudge_origin: false, trigger_id: 'T9' })).toEqual({ agentSession: true, nudgeOrigin: false, triggerId: 'T9' });
|
|
137
|
+
});
|
|
138
|
+
it('accepts an explicit null trigger_id', () => {
|
|
139
|
+
expect(extractMarkerMeta({ trigger_id: null })).toEqual({ triggerId: null });
|
|
140
|
+
});
|
|
141
|
+
it('drops junk / wrongly-typed values', () => {
|
|
142
|
+
expect(extractMarkerMeta({
|
|
143
|
+
agent_session: 'true', // string, not boolean
|
|
144
|
+
nudge_origin: 1, // number, not boolean
|
|
145
|
+
trigger_id: 123, // number, not string
|
|
146
|
+
harness: 'my-cool-editor', // string, but out of vocabulary
|
|
147
|
+
unrelated: 'ignored',
|
|
148
|
+
})).toEqual({});
|
|
149
|
+
});
|
|
150
|
+
it('accepts a vocabulary harness value', () => {
|
|
151
|
+
expect(extractMarkerMeta({ harness: 'opencode' })).toEqual({ harness: 'opencode' });
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
// ---------------------------------------------------------------------------
|
|
155
|
+
// resolveAgentMarker (precedence)
|
|
156
|
+
// ---------------------------------------------------------------------------
|
|
157
|
+
describe('resolveAgentMarker', () => {
|
|
158
|
+
it('returns the neutral default when neither _meta nor file is present', () => {
|
|
159
|
+
expect(resolveAgentMarker(undefined, { now: NOW })).toEqual(NO_AGENT_MARKER);
|
|
160
|
+
});
|
|
161
|
+
it('uses the marker file when _meta is absent', () => {
|
|
162
|
+
writeMarker('a.json', freshMarker({ nudge_origin: true, trigger_id: 'FILE' }));
|
|
163
|
+
expect(resolveAgentMarker(undefined, { now: NOW })).toEqual({
|
|
164
|
+
agentSession: true,
|
|
165
|
+
nudgeOrigin: true,
|
|
166
|
+
triggerId: 'FILE',
|
|
167
|
+
harness: 'claude-code',
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
it('lets _meta win over the marker file per field', () => {
|
|
171
|
+
writeMarker('a.json', freshMarker({ agent_session: true, nudge_origin: true, trigger_id: 'FILE' }));
|
|
172
|
+
const resolved = resolveAgentMarker({ agent_session: false, trigger_id: 'META' }, { now: NOW });
|
|
173
|
+
// agent_session + trigger_id come from _meta; nudge_origin + harness fall
|
|
174
|
+
// back to the file.
|
|
175
|
+
expect(resolved).toEqual({
|
|
176
|
+
agentSession: false,
|
|
177
|
+
nudgeOrigin: true,
|
|
178
|
+
triggerId: 'META',
|
|
179
|
+
harness: 'claude-code',
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
it('lets a _meta harness win over the file harness', () => {
|
|
183
|
+
writeMarker('a.json', freshMarker()); // file harness: claude-code
|
|
184
|
+
expect(resolveAgentMarker({ harness: 'cursor' }, { now: NOW })?.harness).toBe('cursor');
|
|
185
|
+
});
|
|
186
|
+
it('a junk _meta harness falls back to the file harness', () => {
|
|
187
|
+
writeMarker('a.json', freshMarker()); // file harness: claude-code
|
|
188
|
+
expect(resolveAgentMarker({ harness: 'my-cool-editor' }, { now: NOW })?.harness).toBe('claude-code');
|
|
189
|
+
});
|
|
190
|
+
it('lets _meta provide fields with no marker file at all', () => {
|
|
191
|
+
expect(resolveAgentMarker({ agent_session: true }, { now: NOW })).toEqual({
|
|
192
|
+
agentSession: true,
|
|
193
|
+
nudgeOrigin: false,
|
|
194
|
+
triggerId: null,
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
it('an expired file behaves as no file (falls through to _meta / default)', () => {
|
|
198
|
+
writeMarker('a.json', freshMarker({ started_at: NOW - AGENT_MARKER_TTL_MS - 1, trigger_id: 'STALE' }));
|
|
199
|
+
expect(resolveAgentMarker(undefined, { now: NOW })).toEqual(NO_AGENT_MARKER);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
//# sourceMappingURL=agent-marker.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-marker.test.js","sourceRoot":"","sources":["../../../src/telemetry/agent-marker.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AACpE,OAAO,EAAE,WAAW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,CAAC;YACxE,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,IAAI;SAChB,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,uEAAuE,EAAE,GAAG,EAAE;QAC/E,WAAW,CACT,QAAQ,EACR,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,GAAG,mBAAmB,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,CAChF,CAAA;QACD,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IAC9E,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -10,7 +10,8 @@ export { SkillsmithTracer, getTracer, initializeTracing, shutdownTracing, traced
|
|
|
10
10
|
export { MetricsRegistry, getMetrics, initializeMetrics, timeAsync, timeSync, LATENCY_BUCKETS, type MetricsConfig, type MetricLabels, type Counter, type Histogram, type Gauge, type MetricsSnapshot, } from './metrics.js';
|
|
11
11
|
export { exportToPrometheus, getPrometheusMetrics, createPrometheusHandler, type PrometheusExportOptions, } from './prometheus.js';
|
|
12
12
|
export { initializePostHog, shutdownPostHog, flushPostHog, trackEvent, trackSkillSearch, trackSkillView, trackSkillInstall, trackSkillInvoke, trackApiError, identifyUser, isFeatureFlagEnabled, getPostHog, isPostHogEnabled, ALLOWED_TRAITS, type PostHogConfig, type SkillsmithEventType, type SkillEventProperties, type TrackSkillInvokeParams, type AllowedUserTraits, } from './posthog.js';
|
|
13
|
-
export { withTelemetry, isTelemetered, setEmissionGate, type WithTelemetryOpts } from './wrap.js';
|
|
13
|
+
export { withTelemetry, isTelemetered, setEmissionGate, runWithEmissionGate, runWithMarkerContext, type WithTelemetryOpts, } from './wrap.js';
|
|
14
|
+
export { resolveAgentMarker, readSessionMarker, extractMarkerMeta, NO_AGENT_MARKER, AGENT_MARKER_TTL_MS, AGENT_MARKER_SCHEMA_VERSION, KNOWN_HARNESS_FRAMEWORKS, type HarnessFramework, type AgentMarker, type AgentMarkerFile, } from './agent-marker.js';
|
|
14
15
|
/**
|
|
15
16
|
* Initialize all telemetry (tracing + metrics)
|
|
16
17
|
* Call this at application startup
|