@inneranimalmedia/agentsam-sdk 2.6.8 → 2.6.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.
Files changed (203) hide show
  1. package/README.md +18 -0
  2. package/apps/README.md +25 -0
  3. package/apps/cad-creator/shared/cad/package.json +1 -1
  4. package/apps/client-cms-editor/backend/package.json +5 -7
  5. package/apps/client-cms-editor/frontend/package.json +5 -7
  6. package/apps/client-cms-editor/frontend/tsconfig.json +27 -8
  7. package/apps/client-cms-editor/package-lock.json +8 -8
  8. package/apps/client-cms-editor/package.json +1 -1
  9. package/apps/client-cms-editor/shared/cms/package.json +3 -5
  10. package/docs/LOCAL_ENGINE_COMPUTE_AUDIT_PLAN.md +299 -0
  11. package/docs/architecture/HOOKS-MODELS-SELF-HOSTING-PLAN.md +199 -0
  12. package/examples/hyperspace-demo/index.html +16 -0
  13. package/examples/hyperspace-demo/package.json +21 -0
  14. package/examples/hyperspace-demo/src/main.tsx +160 -0
  15. package/examples/hyperspace-demo/tsconfig.json +9 -0
  16. package/examples/hyperspace-demo/vite.config.ts +24 -0
  17. package/migrations/runtime/0005_agentsam_hooks.sql +87 -0
  18. package/package.json +37 -10
  19. package/packages/agentsam-brand/package.json +1 -1
  20. package/packages/agentsam-brand/src/core/v2/compile.js +1 -1
  21. package/packages/agentsam-brand/src/core/v2/schema.js +1 -1
  22. package/packages/agentsam-contracts/package.json +71 -20
  23. package/packages/agentsam-contracts/scripts/build.mjs +18 -0
  24. package/packages/agentsam-contracts/src/errors.ts +19 -10
  25. package/packages/agentsam-contracts/test/contracts.test.mjs +4 -1
  26. package/packages/agentsam-contracts/test/repository.test.mjs +4 -1
  27. package/packages/agentsam-contracts/tsconfig.build.json +10 -0
  28. package/packages/agentsam-errors/package.json +13 -4
  29. package/packages/agentsam-errors/protocol/agentsam.error.v2.schema.json +821 -0
  30. package/packages/agentsam-errors/protocol/error-catalog.json +3512 -0
  31. package/packages/agentsam-errors/src/envelope.js +63 -11
  32. package/packages/agentsam-errors/src/error.js +6 -0
  33. package/packages/agentsam-errors/src/fingerprint.js +9 -1
  34. package/packages/agentsam-errors/src/normalize.js +51 -6
  35. package/packages/agentsam-errors/src/recovery.js +9 -35
  36. package/packages/agentsam-errors/src/transport.js +6 -1
  37. package/packages/agentsam-errors/src/vocabulary.js +515 -126
  38. package/packages/agentsam-errors/test/catalog-v2.test.mjs +106 -0
  39. package/packages/agentsam-errors/types/index.d.ts +157 -0
  40. package/packages/agentsam-goap/package.json +2 -2
  41. package/packages/agentsam-hooks/README.md +206 -0
  42. package/packages/agentsam-hooks/bin/agentsam-hooks.mjs +64 -0
  43. package/packages/agentsam-hooks/bindings/go/command.go +55 -0
  44. package/packages/agentsam-hooks/bindings/go/errors_generated.go +402 -0
  45. package/packages/agentsam-hooks/bindings/go/go.mod +3 -0
  46. package/packages/agentsam-hooks/bindings/go/hooks.go +285 -0
  47. package/packages/agentsam-hooks/bindings/go/hooks_test.go +48 -0
  48. package/packages/agentsam-hooks/bindings/rust/Cargo.toml +11 -0
  49. package/packages/agentsam-hooks/bindings/rust/src/errors_generated.rs +396 -0
  50. package/packages/agentsam-hooks/bindings/rust/src/lib.rs +397 -0
  51. package/packages/agentsam-hooks/package.json +69 -0
  52. package/packages/agentsam-hooks/schema/manifest.json +54 -0
  53. package/packages/agentsam-hooks/scripts/clean-protocol.mjs +17 -0
  54. package/packages/agentsam-hooks/scripts/sync-protocol.mjs +27 -0
  55. package/packages/agentsam-hooks/src/adapters/agents.js +82 -0
  56. package/packages/agentsam-hooks/src/adapters/callback.js +4 -0
  57. package/packages/agentsam-hooks/src/adapters/capability.js +122 -0
  58. package/packages/agentsam-hooks/src/adapters/command.js +104 -0
  59. package/packages/agentsam-hooks/src/adapters/composite.js +31 -0
  60. package/packages/agentsam-hooks/src/adapters/http.js +58 -0
  61. package/packages/agentsam-hooks/src/adapters/lsp.js +116 -0
  62. package/packages/agentsam-hooks/src/adapters/mcp.js +76 -0
  63. package/packages/agentsam-hooks/src/adapters/provider.js +129 -0
  64. package/packages/agentsam-hooks/src/config.js +143 -0
  65. package/packages/agentsam-hooks/src/contracts.js +284 -0
  66. package/packages/agentsam-hooks/src/errors-generated.js +2732 -0
  67. package/packages/agentsam-hooks/src/index.d.ts +193 -0
  68. package/packages/agentsam-hooks/src/index.js +14 -0
  69. package/packages/agentsam-hooks/src/policy.js +34 -0
  70. package/packages/agentsam-hooks/src/runtime.js +312 -0
  71. package/packages/agentsam-hooks/src/store.js +264 -0
  72. package/packages/agentsam-hooks/test/adapters.test.mjs +216 -0
  73. package/packages/agentsam-hooks/test/runtime.test.mjs +258 -0
  74. package/packages/agentsam-knowledge/package.json +3 -2
  75. package/packages/agentsam-nav/package.json +1 -1
  76. package/packages/agentsam-queue-control/package.json +1 -1
  77. package/packages/agentsam-rapid-rust/src/main.rs +1 -0
  78. package/packages/agentsam-repository/package.json +3 -2
  79. package/packages/agentsam-vault/package.json +8 -5
  80. package/packages/agentsam-workbench/package.json +45 -18
  81. package/packages/connectors/cloudflare/package.json +1 -1
  82. package/packages/heuristic-theme/package.json +1 -1
  83. package/packages/identity/package.json +3 -2
  84. package/packages/identity/tests/lane1-packed-consumer.test.mjs +9 -1
  85. package/packages/providers/completeful/package.json +1 -1
  86. package/packages/theme-church-site/README.md +2 -2
  87. package/packages/theme-church-site/package.json +2 -3
  88. package/packages/theme-church-site/src/index.js +1 -1
  89. package/packages/theme-church-site/test/theme.test.mjs +1 -1
  90. package/packages/theme-companions-site/README.md +2 -2
  91. package/packages/theme-companions-site/package.json +2 -3
  92. package/packages/theme-companions-site/src/index.js +1 -1
  93. package/packages/theme-companions-site/test/theme.test.mjs +1 -1
  94. package/packages/theme-floors-site/README.md +2 -2
  95. package/packages/theme-floors-site/package.json +2 -3
  96. package/packages/theme-floors-site/src/index.js +1 -1
  97. package/packages/theme-floors-site/test/theme.test.mjs +1 -1
  98. package/packages/theme-fuelnfree-site/README.md +2 -2
  99. package/packages/theme-fuelnfree-site/package.json +2 -3
  100. package/packages/theme-fuelnfree-site/src/index.js +1 -1
  101. package/packages/theme-fuelnfree-site/test/theme.test.mjs +1 -1
  102. package/packages/theme-handyman-site/README.md +2 -2
  103. package/packages/theme-handyman-site/package.json +2 -3
  104. package/packages/theme-handyman-site/src/index.js +1 -1
  105. package/packages/theme-handyman-site/test/theme.test.mjs +1 -1
  106. package/packages/theme-insurance-site/README.md +2 -2
  107. package/packages/theme-insurance-site/package.json +2 -3
  108. package/packages/theme-insurance-site/src/index.js +1 -1
  109. package/packages/theme-insurance-site/test/theme.test.mjs +1 -1
  110. package/packages/theme-scenes/package.json +1 -1
  111. package/packages/theme-shinshu-site/README.md +2 -2
  112. package/packages/theme-shinshu-site/package.json +2 -3
  113. package/packages/theme-shinshu-site/src/index.js +1 -1
  114. package/packages/theme-shinshu-site/test/theme.test.mjs +1 -1
  115. package/packages/work-graph/package.json +3 -2
  116. package/protocol/apps/agentsam.app.v1.schema.json +1 -1
  117. package/protocol/apps/agentsam.host-install.v1.schema.json +1 -1
  118. package/protocol/assets/asset-record.v1.schema.json +1 -1
  119. package/protocol/brand/brandpack.v1.schema.json +1 -1
  120. package/protocol/capabilities/capability-manifest.schema.json +1 -1
  121. package/protocol/capabilities/knowledge-search-input.schema.json +1 -0
  122. package/protocol/credentials/issue.v1.schema.json +1 -1
  123. package/protocol/database/agentsam.schema-pack.v1.schema.json +1 -1
  124. package/protocol/database/connection.v1.schema.json +1 -1
  125. package/protocol/embeddings/embedding-profile.v1.schema.json +1 -1
  126. package/protocol/errors/README.md +36 -0
  127. package/protocol/errors/agentsam.error.v2.schema.json +821 -0
  128. package/protocol/errors/error-catalog.json +3506 -158
  129. package/protocol/errors/error-envelope.schema.json +195 -52
  130. package/protocol/errors/recovery.v1.schema.json +1 -1
  131. package/protocol/features/agentsam.feature.v1.schema.json +1 -1
  132. package/protocol/hooks/README.md +18 -0
  133. package/protocol/hooks/agentsam.hook.output.v1.schema.json +27 -0
  134. package/protocol/hooks/agentsam.hook.receipt.v1.schema.json +61 -0
  135. package/protocol/hooks/agentsam.hook.v1.schema.json +35 -0
  136. package/protocol/hooks/agentsam.hooks.config.v1.schema.json +78 -0
  137. package/protocol/local-engine/benchmark.v1.schema.json +14 -0
  138. package/protocol/local-engine/engine.v1.schema.json +17 -0
  139. package/protocol/models/model-inventory-v2.schema.json +1 -1
  140. package/protocol/models/provider-model-snapshot.v1.schema.json +22 -0
  141. package/protocol/rpc/v1/errors.proto +1 -0
  142. package/protocol/runtime/agentsam.runtime.v1.schema.json +1 -1
  143. package/protocol/runtime/workspace-fs.v1.schema.json +1 -1
  144. package/protocol/sam/activity.v1.schema.json +1 -1
  145. package/protocol/sam/answer.v1.schema.json +1 -1
  146. package/protocol/sam/calibration.v1.schema.json +1 -1
  147. package/protocol/sam/decision-receipt.v1.schema.json +1 -1
  148. package/protocol/sam/evaluation.v1.schema.json +1 -1
  149. package/protocol/sam/operation.schema.json +1 -1
  150. package/protocol/sam/outcome.v1.schema.json +1 -1
  151. package/protocol/sam/question.v1.schema.json +1 -1
  152. package/protocol/sam/result.schema.json +1 -1
  153. package/protocol/sam/state.v1.schema.json +1 -1
  154. package/protocol/scoring/scorecard.v1.schema.json +1 -1
  155. package/protocol/skills/agentsam.interaction.v1.schema.json +1 -1
  156. package/protocol/skills/agentsam.skill.v1.schema.json +1 -1
  157. package/protocol/theme-refinery/product-metadata.schema.json +1 -1
  158. package/protocol/theme-refinery/reconciliation-receipt.schema.json +1 -1
  159. package/protocol/ui/icon.v1.schema.json +1 -1
  160. package/python/README.md +20 -0
  161. package/python/agentsam_sdk/errors/__init__.py +4 -0
  162. package/python/agentsam_sdk/errors/vocabulary.py +2730 -0
  163. package/python/agentsam_sdk/hooks/__init__.py +32 -0
  164. package/python/agentsam_sdk/hooks/adapters.py +132 -0
  165. package/python/agentsam_sdk/hooks/contracts.py +121 -0
  166. package/python/agentsam_sdk/hooks/runtime.py +253 -0
  167. package/python/tests/test_hooks.py +115 -0
  168. package/src/agent/responses-runner.js +145 -1
  169. package/src/cli/command-catalog.js +2 -0
  170. package/src/cli.js +19 -0
  171. package/src/commands/app.js +10 -0
  172. package/src/commands/cheat-sheet.js +1 -0
  173. package/src/commands/engine.js +10 -0
  174. package/src/commands/hooks.js +260 -0
  175. package/src/commands/machine.js +71 -38
  176. package/src/commands/models.js +1 -1
  177. package/src/commands/package.js +10 -3
  178. package/src/commands/runtime.js +25 -10
  179. package/src/commands/setup.js +30 -6
  180. package/src/commands/shell.js +114 -9
  181. package/src/commands/terminal.js +20 -8
  182. package/src/errors/contract.js +4 -4
  183. package/src/errors/diagnostic.js +10 -10
  184. package/src/errors/index.js +1 -1
  185. package/src/index.js +52 -0
  186. package/src/indexing/ingest/materials.js +237 -30
  187. package/src/knowledge/service/grpc-codec.js +2 -0
  188. package/src/lib/setup/runtime.js +4 -2
  189. package/src/lib/slash-commands.js +1 -0
  190. package/src/local/runtime-store.js +46 -0
  191. package/src/local-engine/assets.js +37 -0
  192. package/src/local-engine/audit.js +133 -0
  193. package/src/local-engine/benchmark.js +26 -0
  194. package/src/local-engine/contracts.js +101 -0
  195. package/src/local-engine/engines.js +142 -0
  196. package/src/local-engine/index.js +18 -0
  197. package/src/local-engine/runtime.js +39 -0
  198. package/src/models/catalog.js +0 -49
  199. package/src/models/inventory-core.js +69 -0
  200. package/src/plugins/index.js +8 -1
  201. package/src/plugins/registry.js +56 -0
  202. package/src/rpc/generated/errors_pb.js +49 -1
  203. package/src/tools/runtime.js +13 -5
package/README.md CHANGED
@@ -95,6 +95,23 @@ Portal-hosted OAuth (Cloudflare’s own consent on `*.mcp.cloudflare.com`) is se
95
95
  from AgentSam’s CF connection token. Keep tokens in each client’s credential store;
96
96
  do not commit them.
97
97
 
98
+ ## Lifecycle hooks and portable agent adapters
99
+
100
+ `@inneranimalmedia/agentsam-hooks` and the SDK `/hooks` export provide a
101
+ provider-neutral `agentsam.hook.v1` lifecycle boundary. In-process JavaScript and
102
+ TypeScript callbacks use the same JSON envelope as Python, Go, Rust, command, and
103
+ HTTP hooks. Pre-tool/model policy fails closed by default; observational hooks
104
+ fail open with bounded, value-free receipts.
105
+
106
+ The package also supplies composable host ports for model providers, capabilities,
107
+ MCP tools, LSP requests, and bounded sub-agent delegation. `runAgentSamTurn({ hooks })`
108
+ instruments the existing autonomous tool loop directly, including capped
109
+ `agent_stop` continuation. No hook config depends on a particular username, home
110
+ directory plugin, model vendor, or operator account. `agentsam hooks status|list|executions`
111
+ shows code, project-config, and stored hooks through one ordered contract. The optional
112
+ schema pack uses opaque owner/scope keys rather than tenant/workspace dependencies. See
113
+ [`packages/agentsam-hooks/README.md`](packages/agentsam-hooks/README.md).
114
+
98
115
  ## Index an existing repository
99
116
 
100
117
  ```sh
@@ -161,6 +178,7 @@ read-only `repository.snapshot` composition primitive. See [Capabilities and pre
161
178
  | --- | --- | --- |
162
179
  | Capability registry + presets | `agentsam capabilities`, `/capabilities`, `/presets` | [Capabilities](docs/CAPABILITIES.md) |
163
180
  | Portable AgentSam skills | `agentsam skills`; `/skills` | [Skills](skills/README.md) |
181
+ | Lifecycle hooks + MCP/LSP/sub-agent adapters | `/hooks`; `agentsam-hooks` | [AgentSam Hooks](packages/agentsam-hooks/README.md) |
164
182
  | Canonical repository snapshot | `agentsam inspect --json`; `/repository` | [Capabilities](docs/CAPABILITIES.md) |
165
183
  | Git context and bridge client | `agentsam context --json`; `/git-context`, `/bridge-client` | [Portable context](docs/PORTABLE_CONTEXT.md) |
166
184
  | Identity contracts and adapters | `/identity`; `agentsam identity init` | [Identity](packages/identity/README.md) |
package/apps/README.md CHANGED
@@ -37,3 +37,28 @@ Rules:
37
37
  - The SDK root owns package/tooling release concerns; app workspace dependencies stay inside each app.
38
38
 
39
39
  Current product apps governed by the architecture test are `local-studio/`, `cad-creator/`, and `client-cms-editor/`. `frontend/` remains a public-site seed lane rather than a self-contained product workspace, and `_incoming/` is an import drop zone.
40
+
41
+ ## Portable packaging checklist
42
+
43
+ Run from the repository root before publishing an APP:
44
+
45
+ ```sh
46
+ npm run app:validate
47
+ npm run app:packaging
48
+ agentsam app package <app-id> --dry-run
49
+ ```
50
+
51
+ `app:packaging` audits every APP manifest in `apps/` and package-owned APP under `packages/`. It verifies the package name/manifest relationship, explicit npm `files` allowlists, app-owned lockfiles, CLI bins, frontend/backend package boundaries where declared, and excludes donor/reference/attachment payloads from packed artifacts. It does not download dependencies, build a frontend, deploy a Worker, or claim a release is ready.
52
+
53
+ For an app workspace, the release sequence is:
54
+
55
+ ```sh
56
+ cd apps/<app-id>
57
+ npm ci
58
+ npm run build
59
+ npm run typecheck --workspaces --if-present
60
+ npm test
61
+ npm pack --dry-run --json
62
+ ```
63
+
64
+ Frontend packages must publish compiled browser-safe assets only when they are intentionally public. Backend packages must keep secrets, `.dev.vars`, local databases, and host credentials out of `files`. Cloudflare Worker configuration remains backend-owned and is deployed separately from the npm tarball unless the app's package contract explicitly includes it.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inneranimalmedia/agentsam-cad-shared",
3
- "version": "2.6.7",
3
+ "version": "2.6.10",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inneranimalmedia/agentsam-cms-backend",
3
- "version": "2.6.7",
4
- "description": "Internal CMS backend bridge (bundled into @inneranimalmedia/client-cms-editor \u2014 not published separately).",
3
+ "version": "2.6.10",
4
+ "description": "Internal CMS backend bridge (bundled into @inneranimalmedia/client-cms-editor — not published separately).",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
@@ -14,14 +14,11 @@
14
14
  "typecheck": "tsc --noEmit -p tsconfig.json"
15
15
  },
16
16
  "dependencies": {
17
- "@inneranimalmedia/agentsam-cms-shared": "2.6.7"
17
+ "@inneranimalmedia/agentsam-cms-shared": "2.6.10"
18
18
  },
19
19
  "devDependencies": {
20
20
  "typescript": "^5.9.3"
21
21
  },
22
- "publishConfig": {
23
- "access": "public"
24
- },
25
22
  "repository": {
26
23
  "type": "git",
27
24
  "url": "git+https://github.com/SamPrimeaux/agentsam-sdk.git",
@@ -35,5 +32,6 @@
35
32
  "worker",
36
33
  "wrangler.jsonc"
37
34
  ]
38
- }
35
+ },
36
+ "private": true
39
37
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inneranimalmedia/agentsam-cms-frontend",
3
- "version": "2.6.7",
3
+ "version": "2.6.10",
4
4
  "description": "Internal CMS frontend (bundled into @inneranimalmedia/client-cms-editor — not published separately).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -15,8 +15,8 @@
15
15
  "test": "vitest run --passWithNoTests"
16
16
  },
17
17
  "dependencies": {
18
- "@inneranimalmedia/agentsam-cms-backend": "2.6.7",
19
- "@inneranimalmedia/agentsam-cms-shared": "2.6.7",
18
+ "@inneranimalmedia/agentsam-cms-backend": "2.6.10",
19
+ "@inneranimalmedia/agentsam-cms-shared": "2.6.10",
20
20
  "react": "^19.2.0",
21
21
  "react-dom": "^19.2.0"
22
22
  },
@@ -28,9 +28,6 @@
28
28
  "vite": "^6.4.3",
29
29
  "vitest": "^4.1.11"
30
30
  },
31
- "publishConfig": {
32
- "access": "public"
33
- },
34
31
  "repository": {
35
32
  "type": "git",
36
33
  "url": "git+https://github.com/SamPrimeaux/agentsam-sdk.git",
@@ -38,5 +35,6 @@
38
35
  },
39
36
  "files": [
40
37
  "src"
41
- ]
38
+ ],
39
+ "private": true
42
40
  }
@@ -20,17 +20,36 @@
20
20
  "preserveSymlinks": true,
21
21
  "baseUrl": ".",
22
22
  "paths": {
23
- "@inneranimalmedia/agentsam-cms-shared": ["../shared/cms/src/index.ts"],
24
- "@inneranimalmedia/agentsam-cms-shared/*": ["../shared/cms/src/*"],
25
- "@inneranimalmedia/agentsam-cms-backend/api": ["../backend/src/api/client.ts"],
26
- "@inneranimalmedia/agentsam-cms-backend/model": ["../backend/src/model.ts"],
27
- "@inneranimalmedia/agentsam-cms-backend/preview": ["../backend/src/preview/bridge.ts"],
28
- "@inneranimalmedia/agentsam-cms-backend/routing": ["../backend/src/routing/index.js"],
29
- "@inneranimalmedia/agentsam-cms-backend": ["../backend/src/index.ts"],
30
- "@inneranimalmedia/agentsam-cms-backend/*": ["../backend/src/*"]
23
+ "@inneranimalmedia/agentsam-cms-shared": [
24
+ "../shared/cms/src/index.ts"
25
+ ],
26
+ "@inneranimalmedia/agentsam-cms-shared/*": [
27
+ "../shared/cms/src/*"
28
+ ],
29
+ "@inneranimalmedia/agentsam-cms-backend/api": [
30
+ "../backend/src/api/client.ts"
31
+ ],
32
+ "@inneranimalmedia/agentsam-cms-backend/model": [
33
+ "../backend/src/model.ts"
34
+ ],
35
+ "@inneranimalmedia/agentsam-cms-backend/preview": [
36
+ "../backend/src/preview/bridge.ts"
37
+ ],
38
+ "@inneranimalmedia/agentsam-cms-backend/routing": [
39
+ "../backend/src/routing/index.js"
40
+ ],
41
+ "@inneranimalmedia/agentsam-cms-backend": [
42
+ "../backend/src/index.ts"
43
+ ],
44
+ "@inneranimalmedia/agentsam-cms-backend/*": [
45
+ "../backend/src/*"
46
+ ]
31
47
  }
32
48
  },
33
49
  "include": [
34
50
  "src"
51
+ ],
52
+ "exclude": [
53
+ "src/editor/legacy"
35
54
  ]
36
55
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@inneranimalmedia/client-cms-editor",
3
- "version": "0.1.0-alpha.0",
3
+ "version": "2.6.10",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@inneranimalmedia/client-cms-editor",
9
- "version": "0.1.0-alpha.0",
9
+ "version": "2.6.10",
10
10
  "license": "UNLICENSED",
11
11
  "workspaces": [
12
12
  "frontend",
@@ -37,9 +37,9 @@
37
37
  },
38
38
  "backend": {
39
39
  "name": "@inneranimalmedia/agentsam-cms-backend",
40
- "version": "0.1.0-alpha.0",
40
+ "version": "2.6.10",
41
41
  "dependencies": {
42
- "@inneranimalmedia/agentsam-cms-shared": "0.1.0-alpha.0"
42
+ "@inneranimalmedia/agentsam-cms-shared": "2.6.10"
43
43
  },
44
44
  "devDependencies": {
45
45
  "typescript": "^5.9.3"
@@ -47,10 +47,10 @@
47
47
  },
48
48
  "frontend": {
49
49
  "name": "@inneranimalmedia/agentsam-cms-frontend",
50
- "version": "0.1.0-alpha.0",
50
+ "version": "2.6.10",
51
51
  "dependencies": {
52
- "@inneranimalmedia/agentsam-cms-backend": "0.1.0-alpha.0",
53
- "@inneranimalmedia/agentsam-cms-shared": "0.1.0-alpha.0",
52
+ "@inneranimalmedia/agentsam-cms-backend": "2.6.10",
53
+ "@inneranimalmedia/agentsam-cms-shared": "2.6.10",
54
54
  "react": "^19.2.0",
55
55
  "react-dom": "^19.2.0"
56
56
  },
@@ -4662,7 +4662,7 @@
4662
4662
  },
4663
4663
  "shared/cms": {
4664
4664
  "name": "@inneranimalmedia/agentsam-cms-shared",
4665
- "version": "0.1.0-alpha.0",
4665
+ "version": "2.6.10",
4666
4666
  "devDependencies": {
4667
4667
  "typescript": "^5.9.3"
4668
4668
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inneranimalmedia/client-cms-editor",
3
- "version": "2.6.7",
3
+ "version": "2.6.10",
4
4
  "private": false,
5
5
  "description": "Reusable full-stack website + CMS kit with multi-page public sites, a protected authoring dashboard, local SQLite, starter/theme import, and pluggable auth, storage, and deployment adapters.",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inneranimalmedia/agentsam-cms-shared",
3
- "version": "2.6.7",
3
+ "version": "2.6.10",
4
4
  "description": "Internal CMS shared contracts (bundled into @inneranimalmedia/client-cms-editor — not published separately).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,9 +17,6 @@
17
17
  "devDependencies": {
18
18
  "typescript": "^5.9.3"
19
19
  },
20
- "publishConfig": {
21
- "access": "public"
22
- },
23
20
  "repository": {
24
21
  "type": "git",
25
22
  "url": "git+https://github.com/SamPrimeaux/agentsam-sdk.git",
@@ -27,5 +24,6 @@
27
24
  },
28
25
  "files": [
29
26
  "src"
30
- ]
27
+ ],
28
+ "private": true
31
29
  }
@@ -0,0 +1,299 @@
1
+ # AgentSam Local Engine & Compute Audit Plan
2
+
3
+ **Audit date:** 2026-10-02 (UTC)
4
+ **Repository:** `@inneranimalmedia/agentsam-sdk`
5
+ **Branch:** `arena/01a0fae5-agentsam-sdk`
6
+ **Scope:** Apple Silicon inventory, portable local-engine contract, benchmark harness, and model/cache governance.
7
+
8
+ This is an implementation plan grounded in the current checkout. It deliberately does not claim that the repository's build host is an Apple Silicon machine or that any local engine is installed: those are runtime facts that the future audit command must discover on the operator's machine.
9
+
10
+ ## 1. Executive assessment
11
+
12
+ AgentSam already has useful foundations, but not the requested universal local-engine layer.
13
+
14
+ ### Existing strengths
15
+
16
+ - Local-first runtime and user-space ownership are established conventions. `~/.agentsam` is already used for managed Machine and AgentSam runtimes, while project state remains under `.agentsam/`.
17
+ - The repository has a strong deterministic-machinery boundary in `AGENTSAM.md`: inspectable evidence owns facts; models may augment but must not override capability evidence.
18
+ - Hardware identity primitives exist in `src/lib/terminal/machine-identity.js` and can normalize platform, architecture, hostname, and hardware model without a host-specific path.
19
+ - A managed native Machine runtime exists under `native/agentsam-machine`, with portable resolution/install logic in `src/commands/machine-binary.js` and `src/commands/machine-runtime.js`.
20
+ - Ollama is the only meaningful local model integration today. `src/commands/ollama.js` supports local setup/status/list/pull and `/api/tags` plus `/api/show` probing. `src/providers/ollama-chat.js` supports chat, tool calls, usage events, continuation state, and compaction.
21
+ - Model discovery and credential-scoped inventory already exist in `src/models/inventory-core.js`, `src/models/discovery.js`, `src/indexing/ingest/discover-models.js`, and `src/commands/models.js`.
22
+ - Existing provider adapters and telemetry/receipt primitives can be reused rather than creating a second model-router stack.
23
+ - The test layout already separates deterministic release-blocking suites from live-daemon tests, which is the correct pattern for local engines.
24
+
25
+ ### Missing or incomplete capabilities
26
+
27
+ - No `agentsam.local-engine.v1` schema, TypeScript/JavaScript contract, registry, or capability negotiation layer exists.
28
+ - No unified `discover()`, `capabilities()`, `chat()`, `embed()`, and `unload()` interface spans Ollama, MLX-LM, and llama.cpp.
29
+ - MLX-LM and llama.cpp/`llama-server` discovery and adapters are absent.
30
+ - Current Ollama support is a provider-specific command/adapter, not an engine implementation behind a capability-driven router.
31
+ - No deterministic Apple hardware audit covers chip family, core counts, unified memory, Metal feature set, or OS/toolchain evidence.
32
+ - No benchmark protocol or persistence format exists for TTFT, tokens/sec, VRAM/unified-memory use, repeatability, or structured-output validity.
33
+ - No GBNF/JSON validity evaluator exists, and the current Ollama adapter does not expose streaming timestamps required for TTFT.
34
+ - No storage auditor inventories `~/.agentsam` model assets, detects duplicate weights, or records references/links without copying model files.
35
+ - The current `~/.agentsam` convention is not yet centralized for all future engine/model paths; the new layer should use an injected home/root resolver and `AGENTSAM_HOME`, not scattered `os.homedir()` calls.
36
+ - Engine-specific routing is not yet capability-driven. Existing model inventory/provider code should remain compatible, but local engine selection needs to move behind an engine registry and normalized capability cards.
37
+
38
+ ## 2. Current repository map and authorities
39
+
40
+ | Concern | Current authority | Reuse in the build |
41
+ |---|---|---|
42
+ | Public SDK exports | `src/index.js`, package `exports` | Add stable local-engine exports only after contract tests |
43
+ | CLI dispatch/help | `src/cli.js`, `src/cli/command-catalog.js` | Add `engine`/`benchmark` commands without changing existing `ollama` behavior abruptly |
44
+ | Local Ollama setup | `src/commands/ollama.js` | Refactor into an Ollama engine adapter while retaining compatibility wrapper |
45
+ | Ollama chat/tools | `src/providers/ollama-chat.js` | Adapt to normalized chat stream/result and structured-output evidence |
46
+ | Local model catalog | `src/models/catalog.js`, `src/models/index.js` | Keep hosted catalog separate; add runtime-discovered local records |
47
+ | Provider/model discovery | `src/models/inventory-core.js`, `src/models/discovery.js` | Extend with local engine inventory, never expose credentials |
48
+ | Machine identity | `src/lib/terminal/machine-identity.js` | Base platform/arch identity; add Apple-specific read-only probes |
49
+ | Managed user runtime | `src/commands/machine-runtime.js` | Follow its `AGENTSAM_HOME` and versioned runtime pattern |
50
+ | Deterministic capabilities | `src/capabilities/` and capability manifest | Register local audit/benchmark capabilities with schemas and receipts |
51
+ | Receipts/usage | `src/telemetry/`, runtime SQLite/migrations | Persist benchmark metadata/results, not raw prompts or weight data by default |
52
+ | Tests | `test/`, `test/cli/`, `test/integration/`, `test/terminal/` | Add pure fakes and explicit opt-in live Apple/engine tiers |
53
+ | Protocol schemas | `protocol/` | Add versioned JSON schemas and validate them in tests/verification |
54
+
55
+ ## 3. Target architecture
56
+
57
+ ```text
58
+ CLI / SDK
59
+ └─ LocalEngineRegistry
60
+ ├─ AppleComputeAudit (read-only host facts)
61
+ ├─ Engine adapters
62
+ │ ├─ OllamaEngine
63
+ │ ├─ MlxLmEngine
64
+ │ └─ LlamaCppEngine
65
+ ├─ CapabilityNegotiator / policy
66
+ ├─ EngineRouter (capabilities, not engine names)
67
+ ├─ BenchmarkRunner
68
+ │ ├─ timing + token accounting
69
+ │ ├─ resource sampler
70
+ │ └─ JSON/GBNF validator
71
+ └─ AssetGovernance
72
+ ├─ ~/.agentsam/models manifest
73
+ ├─ path/link/reference inventory
74
+ └─ duplicate-weight detector
75
+ ```
76
+
77
+ ### Non-negotiable boundaries
78
+
79
+ 1. **Read-only audit:** inventory probes may execute bounded version/info commands and read system APIs, but must not install, start, stop, unload, mutate model files, or transmit prompts.
80
+ 2. **User-space ownership:** managed binaries, manifests, logs, and optional caches live below `${AGENTSAM_HOME:-$HOME/.agentsam}`. Large weights remain where the engine already owns them; record canonical paths, inode/file IDs where available, symlink/clone relationships, and hashes only when explicitly requested.
81
+ 3. **Capability-first routing:** routers ask for capabilities such as `chat.streaming`, `chat.tools`, `output.json_schema`, `embedding`, `model.unload`, `metrics.memory`, and `format.gguf`; they do not branch on `provider === 'mlx'` in core execution code.
82
+ 4. **No implicit network:** local-engine discovery and benchmark commands default to loopback/local process probes. Any remote endpoint requires explicit configuration and is marked non-local in receipts.
83
+ 5. **Truthful unknowns:** unsupported metrics are `null` with an evidence/status reason, never guessed. Apple unified memory is not mislabeled as discrete VRAM.
84
+ 6. **Safe process control:** argv arrays, bounded timeouts, process-group cleanup, no shell interpolation, redacted errors, and explicit approval for launch/pull/unload actions.
85
+
86
+ ## 4. Contract proposal: `agentsam.local-engine.v1`
87
+
88
+ Add:
89
+
90
+ - `protocol/local-engine/engine.v1.schema.json`
91
+ - `protocol/local-engine/capability-card.v1.schema.json`
92
+ - `protocol/local-engine/chat-result.v1.schema.json`
93
+ - `protocol/local-engine/embed-result.v1.schema.json`
94
+ - `protocol/local-engine/inventory.v1.schema.json`
95
+ - `src/local-engine/contracts.js`
96
+ - `src/local-engine/registry.js`
97
+ - `src/local-engine/errors.js`
98
+
99
+ The JS contract should be dependency-light and usable from Node hosts; adapters can use Node process APIs behind the host boundary.
100
+
101
+ ```js
102
+ const engine = {
103
+ id: 'ollama',
104
+ version: '...',
105
+ discover: async ({ signal }) => inventory,
106
+ capabilities: async ({ model, signal }) => capabilityCard,
107
+ chat: async ({ model, messages, tools, responseFormat, stream, signal, onEvent }) => chatResult,
108
+ embed: async ({ model, inputs, signal }) => embedResult,
109
+ unload: async ({ model, signal }) => unloadResult,
110
+ };
111
+ ```
112
+
113
+ Every result includes `schema_version`, `engine_id`, `model`, `status`, `evidence`, and normalized error information. Capability cards should describe support and evidence, for example:
114
+
115
+ - `chat`, `chat.streaming`, `chat.tools`
116
+ - `embed`, `embed.batch`
117
+ - `output.json`, `output.json_schema`, `output.grammar`
118
+ - `model.unload`, `model.load`
119
+ - `metrics.ttft`, `metrics.tokens_per_second`, `metrics.memory`
120
+ - `format.gguf`, `format.safetensors`, `runtime.metal`, `runtime.mlx`
121
+
122
+ The contract must distinguish `supported`, `unsupported`, `unknown`, and `available_now`; an engine can support JSON schema in principle while a selected model/backend does not.
123
+
124
+ ## 5. Hardware and engine inventory implementation
125
+
126
+ ### 5.1 Cross-platform host audit
127
+
128
+ The compute audit is universal. Apple Silicon is a high-value specialization, not the host assumption. Implement platform modules behind one `auditHost()` dispatcher with injectable command/filesystem readers:
129
+
130
+ - **macOS:** Apple Silicon, unified memory, Metal, system profiler, and MLX evidence.
131
+ - **Linux:** distribution/kernel, CPU topology, system memory, NVIDIA/AMD accelerator discovery when vendor tools are present, and shell/runtime inventory.
132
+ - **Windows:** PowerShell or `pwsh`, WMI/CIM hardware facts, GPU controller discovery, system memory, and shell/runtime inventory.
133
+ - **Other platforms:** return normalized host identity and explicit unavailable fields; never emulate Apple/VRAM facts.
134
+
135
+ All platform implementations must report `vram_bytes: null` unless a vendor/API probe provides a defensible value. PowerShell, Bash, Zsh, and POSIX shell availability are inventory facts, not engine assumptions.
136
+
137
+ ### 5.2 Apple Silicon audit
138
+
139
+ Implement the macOS specialization with injectable command/filesystem readers. On macOS, collect only available facts using bounded probes:
140
+
141
+ - `uname`/Node OS facts: platform, kernel, architecture, Rosetta indicators.
142
+ - `sysctl`: `hw.model`, `hw.memsize`, CPU brand/core counts where available.
143
+ - `system_profiler SPHardwareDataType SPDisplaysDataType`: chip/GPU and display/Metal-adjacent evidence, parsed defensively.
144
+ - `ioreg` or supported system APIs only when needed and documented.
145
+ - Metal capability probe as a small signed/managed helper or native Machine extension, not an unbounded shell scrape.
146
+
147
+ Normalize to `chip_family`, `chip_generation`, `gpu_cores`, `performance_cores`, `efficiency_cores`, `unified_memory_bytes`, `metal_features`, and `evidence[]`. Mark memory as `unified_memory`, with `vram_bytes: null` unless a platform-specific measurement is genuinely available.
148
+
149
+ ### 5.2 Engine discovery
150
+
151
+ Each adapter gets a read-only `discover()` implementation:
152
+
153
+ - **Ollama:** binary/version, configured endpoint, `/api/version`, `/api/tags`, per-model `/api/show`; preserve current local-only endpoint semantics.
154
+ - **MLX-LM:** discover managed binary/module and PATH commands, version, model roots, server/listen endpoint if running, and whether Metal/MLX is importable. Do not assume a Python environment or install dependencies during discovery.
155
+ - **llama.cpp:** discover `llama-server`/`llama-cli`, version/help feature evidence, running server health, model path(s), GGUF metadata where readable. Keep command names configurable because package managers vary.
156
+
157
+ Discovery output must include `installed`, `reachable`, `version`, `models`, `capabilities`, `source`, `paths` (redacted/portable as appropriate), and `warnings`.
158
+
159
+ ## 6. Benchmark harness: `agentsam.engine.benchmark.v1`
160
+
161
+ Add a separate harness, not a hidden side effect of chat routing:
162
+
163
+ - `src/local-engine/benchmark/runner.js`
164
+ - `src/local-engine/benchmark/timing.js`
165
+ - `src/local-engine/benchmark/resources.js`
166
+ - `src/local-engine/benchmark/structured-output.js`
167
+ - `protocol/local-engine/benchmark.v1.schema.json`
168
+ - CLI: `agentsam engine benchmark <engine|all> [--model ...] [--json]`
169
+
170
+ ### Measurement rules
171
+
172
+ - Warmup runs are separate from measured runs and reported.
173
+ - Use a monotonic clock. TTFT is request-send to first non-empty model token/event; tokens/sec uses generated tokens and excludes setup time, with an explicit fallback when token counts are unavailable.
174
+ - Capture load time separately from generation time.
175
+ - Resource sampling is engine/platform-specific. On Apple Silicon, report unified-memory current/peak if measurable and `unknown` otherwise; do not call it VRAM without evidence.
176
+ - Capture engine/model revision, prompt fixture ID/hash, options, temperature/seed, run count, OS/hardware audit reference, and timestamp.
177
+ - Never persist full prompts or generated output by default. Store fixture IDs/hashes and validation summaries; allow an explicit `--include-output` diagnostic mode with redaction policy.
178
+ - Repeatability requires fixed seed/options where supported, isolated model state where possible, and a declared warm/cold mode.
179
+
180
+ ### Structured-output validity
181
+
182
+ Provide canonical fixtures for:
183
+
184
+ 1. plain JSON object,
185
+ 2. nested JSON with arrays and optional values,
186
+ 3. AgentSam tool-call envelope,
187
+ 4. invalid/truncated output.
188
+
189
+ Validate with JSON parsing plus JSON Schema (and grammar/GBNF enforcement evidence where the engine supports it). Report `valid`, `parse_error`, `schema_error`, `grammar_enforced`, and `tool_arguments_valid`. Do not infer GBNF enforcement from valid output alone.
190
+
191
+ ## 7. Cache and storage governance
192
+
193
+ Create a user-space asset manifest, for example `${AGENTSAM_HOME}/models/manifest.v1.json`, containing model identity, engine ownership, source URI/provider, revision/digest, format, size, canonical path, link/reference type, and last-seen timestamp.
194
+
195
+ Governance operations:
196
+
197
+ - `agentsam engine assets audit [--json]` — read-only inventory.
198
+ - `agentsam engine assets adopt <path>` — record an existing asset; never copy by default.
199
+ - `agentsam engine assets verify` — check existence/size/digest according to policy.
200
+ - `agentsam engine assets gc --plan` — produce a deletion plan only; deletion requires explicit confirmation.
201
+
202
+ Default search roots are engine-reported and user-configurable, not hardcoded host paths. Use `AGENTSAM_HOME`, XDG conventions where applicable, and engine APIs. Deduplication should prefer references/symlinks/engine-native stores; never duplicate multi-GB weight files merely to make them “managed.”
203
+
204
+ Security requirements: do not follow symlinks outside an approved root without explicit opt-in, avoid reading credential files, redact home paths in portable receipts unless `--verbose`, and hash incrementally with a bounded resource policy.
205
+
206
+ ## 8. Router and model integration plan
207
+
208
+ 1. Introduce `LocalEngineRegistry` and register Ollama first behind the new interface.
209
+ 2. Add a normalized local model record source to inventory; preserve current hosted `MODEL_CATALOG` semantics.
210
+ 3. Update model selection to filter by capability cards (`chat`, `embed`, tools, structured output, context limits), not engine-specific conditionals.
211
+ 4. Adapt `createOllamaChatAdapter` to implement the contract and preserve current telemetry/provider-state behavior.
212
+ 5. Add MLX-LM and llama.cpp adapters only after contract tests and subprocess safety utilities exist.
213
+ 6. Make the agent runner accept an engine-resolved adapter through dependency injection. Core routers must not import MLX, llama.cpp, or Ollama modules.
214
+ 7. Keep `agentsam ollama` as a compatibility command; add `agentsam engine status`, `agentsam engine audit`, and `agentsam engine benchmark` as the universal surface.
215
+
216
+ ## 9. Delivery sequence
217
+
218
+ ### Phase 0 — Contract and safety foundation
219
+
220
+ - Freeze schemas, error vocabulary, capability identifiers, home/path resolver, subprocess runner, redaction rules.
221
+ - Add schema fixtures and registry tests.
222
+ - Add an architecture guard that rejects absolute operator paths and engine imports from core routers.
223
+
224
+ ### Phase 1 — Inventory MVP
225
+
226
+ - Apple audit with mocked command fixtures and a real macOS smoke test that skips off macOS.
227
+ - Ollama adapter discovery migrated from existing code.
228
+ - `agentsam engine audit --json` with honest unavailable/unknown states.
229
+ - Asset manifest read-only audit.
230
+
231
+ ### Phase 2 — Unified Ollama execution
232
+
233
+ - Contract-backed chat/embed/unload behavior.
234
+ - Streaming event timestamps and normalized usage.
235
+ - JSON/tool-schema validation fixtures.
236
+ - Router injection and compatibility tests.
237
+
238
+ ### Phase 3 — MLX-LM and llama.cpp
239
+
240
+ - Read-only discovery first, then chat/embed adapters.
241
+ - Explicit format/model capability negotiation.
242
+ - Process lifecycle, unload, crash diagnostics, and model path governance.
243
+
244
+ ### Phase 4 — Benchmarks and receipts
245
+
246
+ - Warm/cold benchmark runner, resource samplers, structured-output suite.
247
+ - Versioned benchmark receipts and comparison command.
248
+ - Opt-in live tests on Apple Silicon and installed daemons; never release-blocking.
249
+
250
+ ### Phase 5 — Graduation and packaging
251
+
252
+ - Pack/clean-room consumer tests verify exports and CLI behavior.
253
+ - Full release gate: unit, CLI, mocked integration, terminal mock, workspaces, package/boundary/bootstrap/security checks.
254
+ - Document supported combinations truthfully; unsupported hosts/engines remain discoverable as unavailable, not silently emulated.
255
+
256
+ ## 10. Test matrix and acceptance criteria
257
+
258
+ ### Release-blocking deterministic tests
259
+
260
+ - contract/schema normalization and capability negotiation
261
+ - Apple parser fixtures for M1/M2/M3/M4 and non-Apple hosts
262
+ - subprocess argv, timeout, signal, redaction, and path portability
263
+ - fake Ollama/MLX/llama.cpp servers and process adapters
264
+ - chat/embed/unload lifecycle and error mapping
265
+ - JSON Schema/tool argument/GBNF evidence evaluation
266
+ - benchmark math using deterministic clocks and token/resource samples
267
+ - asset governance: no-copy adoption, duplicate detection, symlink boundaries, manifest migration
268
+ - CLI JSON/text snapshots and packed export checks
269
+
270
+ ### Explicit live tests
271
+
272
+ - macOS Apple Silicon hardware audit
273
+ - installed MLX-LM, `llama-server`, and Ollama discovery
274
+ - actual model generation/embedding and unload behavior
275
+ - memory sampling and Metal capability helper
276
+ - benchmark execution against user-selected models
277
+
278
+ ### Definition of done
279
+
280
+ - All new public schemas, exports, docs, CLI entries, and tests agree.
281
+ - `npm test` and the affected workspace/release gates pass without a local daemon or Apple host.
282
+ - Live engine tests are opt-in, clearly labeled, and skipped with an honest reason when unavailable.
283
+ - No absolute operator paths, credentials, model weights, or machine-specific assumptions enter source, fixtures, or shipped receipts.
284
+ - Core routers consume capability cards and injected engine adapters, with no hardcoded engine-specific branching.
285
+ - A clean-room packed install can run discovery/status without this monorepo, private paths, or pre-existing model files.
286
+
287
+ ## 11. Recommended first implementation slice
288
+
289
+ The safest first PR should be **Phase 0 + Phase 1**, limited to:
290
+
291
+ 1. versioned local-engine and inventory schemas;
292
+ 2. `LocalEngineRegistry` plus a fake engine;
293
+ 3. portable `AGENTSAM_HOME`/asset manifest utilities;
294
+ 4. Apple audit parser with fixtures and non-macOS skip behavior;
295
+ 5. Ollama discovery adapter wrapping current probes;
296
+ 6. `agentsam engine audit --json` and focused tests;
297
+ 7. this plan plus protocol README and support matrix.
298
+
299
+ Do not begin by installing MLX, downloading model weights, or changing the model router. Establish the contract and evidence model first; then each engine can be added without weakening portability or the release gate.