@inneranimalmedia/agentsam-sdk 2.4.1 → 2.6.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.
Files changed (233) hide show
  1. package/AGENTSAM.md +55 -0
  2. package/README.md +17 -12
  3. package/bin/agentsam +2 -0
  4. package/docs/AGENTSAM_ASTRA_OPENAI_INTEGRATION.md +1363 -0
  5. package/docs/AGENTSAM_WORKBENCH.md +30 -0
  6. package/docs/AUTH_IDENTITY_CONTRACT.md +52 -0
  7. package/docs/CAPABILITIES.md +5 -3
  8. package/docs/CLI_SHELL.md +167 -80
  9. package/docs/CMS_STUDIO.md +101 -0
  10. package/docs/CONTEXT.md +170 -0
  11. package/docs/LOCAL_OLLAMA.md +58 -0
  12. package/docs/MERKLE.md +19 -19
  13. package/docs/PORTABLE_CONTEXT.md +4 -3
  14. package/docs/PROJECT_CONFIG.md +72 -0
  15. package/docs/RELEASES.md +35 -2
  16. package/docs/REPOSITORY_INTELLIGENCE.md +1 -1
  17. package/docs/REPOSITORY_KNOWLEDGE.md +114 -0
  18. package/docs/SDK_WORKER.md +86 -0
  19. package/docs/SECURITY.md +59 -22
  20. package/docs/client-cms-editor.md +15 -0
  21. package/docs/local-studio/WORKMODE_DONOR_NOTES.md +485 -0
  22. package/package.json +35 -10
  23. package/packages/connectors/cloudflare/package.json +10 -0
  24. package/packages/connectors/cloudflare/src/index.js +127 -0
  25. package/packages/connectors/cloudflare/src/owner.js +76 -0
  26. package/packages/connectors/cloudflare/src/routes.js +223 -0
  27. package/packages/connectors/cloudflare/src/vault.js +80 -0
  28. package/packages/connectors/cloudflare/tests/connector.test.mjs +44 -0
  29. package/packages/identity/package.json +10 -1
  30. package/packages/identity/src/contracts/auth-config.js +109 -0
  31. package/packages/identity/src/index.js +1 -0
  32. package/packages/identity/src/oauth/README.md +2 -2
  33. package/packages/identity/src/oauth/credentials.js +11 -4
  34. package/packages/identity/src/oauth/iam-platform.js +3 -3
  35. package/packages/identity/src/providers/iam/index.js +7 -7
  36. package/packages/identity/src/providers/iam/oauth.js +6 -4
  37. package/packages/identity/src/providers/iam/profile.js +5 -5
  38. package/packages/identity/tests/auth-config.test.mjs +61 -0
  39. package/packages/identity/tests/oauth-credentials.test.mjs +13 -2
  40. package/protocol/FILEMETA_V1.md +95 -0
  41. package/protocol/INSPECT_VIEWS_V1.md +40 -0
  42. package/protocol/MERKLE_PERSISTENCE_V1.md +50 -0
  43. package/protocol/MERKLE_V1.md +3 -1
  44. package/protocol/README.md +1 -0
  45. package/protocol/capabilities/cloudflare-cpu-audit-input.schema.json +19 -0
  46. package/protocol/capabilities/cloudflare-cpu-profile-input.schema.json +13 -0
  47. package/protocol/capabilities/cloudflare-wrangler-native-input.schema.json +19 -0
  48. package/protocol/capabilities/manifest.json +79 -3
  49. package/protocol/capabilities/repository-snapshot.schema.json +1 -0
  50. package/protocol/context/context-budget.schema.json +36 -0
  51. package/protocol/context/context-item.schema.json +19 -0
  52. package/protocol/context/resolved-context-pack.schema.json +47 -0
  53. package/protocol/context/result-policy.schema.json +17 -0
  54. package/protocol/knowledge/context-pack.schema.json +33 -0
  55. package/protocol/knowledge/retrieval-query.schema.json +68 -13
  56. package/protocol/models/README.md +373 -0
  57. package/protocol/models/model-inventory-v2.schema.json +212 -0
  58. package/python/README.md +15 -7
  59. package/python/agentsam_sdk/cli.py +0 -21
  60. package/python/agentsam_sdk/tui/README.md +17 -12
  61. package/python/agentsam_sdk/tui/bootstrap.py +2 -2
  62. package/python/agentsam_sdk/tui/demo.py +25 -10
  63. package/python/agentsam_sdk/tui/onboarding.py +208 -0
  64. package/python/tests/test_tui_cli.py +7 -6
  65. package/skills/README.md +21 -0
  66. package/skills/agentsam-app-fundamentals/SKILL.md +165 -0
  67. package/skills/agentsam-app-fundamentals/references/graphs-contracts-ast-merkle.md +89 -0
  68. package/skills/agentsam-app-fundamentals/references/trust-credentials-and-destinations.md +99 -0
  69. package/skills/agentsam-cloudflare-workers/SKILL.md +53 -0
  70. package/skills/agentsam-cloudflare-workers/references/cpu-profiling.md +16 -0
  71. package/skills/agentsam-cloudflare-workers/references/errors-and-observability.md +29 -0
  72. package/skills/agentsam-cloudflare-workers/references/wrangler-native-map.md +28 -0
  73. package/skills/agentsam-jr-dev/SKILL.md +232 -0
  74. package/skills/agentsam-jr-dev/references/real-application-logic.md +156 -0
  75. package/skills/agentsam-jr-dev/references/web-application-fundamentals.md +240 -0
  76. package/skills/agentsam-progression-guard/SKILL.md +197 -0
  77. package/skills/agentsam-progression-guard/references/checkpoint-chain.md +111 -0
  78. package/skills/agentsam-progression-guard/references/hooks-operational-io.md +96 -0
  79. package/skills/catalog.json +71 -0
  80. package/src/agent/capability-adapter.js +25 -13
  81. package/src/agent/index.js +1 -0
  82. package/src/agent/responses-runner.js +325 -0
  83. package/src/capabilities/index.js +7 -0
  84. package/src/capabilities/repository-snapshot-view.js +238 -0
  85. package/src/capabilities/repository-snapshot.js +28 -14
  86. package/src/cli.js +198 -76
  87. package/src/cloudflare/cpu-profile.js +115 -0
  88. package/src/cloudflare/index.js +14 -0
  89. package/src/cloudflare/wrangler.js +132 -0
  90. package/src/commands/account-auth.js +47 -0
  91. package/src/commands/cloudflare.js +58 -0
  92. package/src/commands/connections.js +93 -0
  93. package/src/commands/context-economics.js +114 -0
  94. package/src/commands/context.js +14 -2
  95. package/src/commands/db.js +4 -7
  96. package/src/commands/deploy.js +54 -32
  97. package/src/commands/eval.js +63 -0
  98. package/src/commands/interactive.js +18 -0
  99. package/src/commands/knowledge.js +27 -4
  100. package/src/commands/merkle-persist.js +118 -0
  101. package/src/commands/merkle.js +32 -17
  102. package/src/commands/models.js +152 -0
  103. package/src/commands/ollama.js +259 -0
  104. package/src/commands/preferences.js +144 -0
  105. package/src/commands/product.js +86 -16
  106. package/src/commands/resume.js +67 -0
  107. package/src/commands/security.js +8 -6
  108. package/src/commands/shell.js +405 -100
  109. package/src/commands/skills.js +66 -0
  110. package/src/commands/start-local.js +1 -1
  111. package/src/commands/tunnel.js +5 -4
  112. package/src/commands/whoami.js +86 -0
  113. package/src/context/budget.js +120 -0
  114. package/src/context/compact.js +28 -0
  115. package/src/context/index.js +7 -0
  116. package/src/context/rehydrate.js +35 -0
  117. package/src/context/resolve.js +116 -0
  118. package/src/context/result-policy.js +66 -0
  119. package/src/errors/diagnostic.js +160 -0
  120. package/src/errors/index.js +9 -0
  121. package/src/eval/context.js +191 -0
  122. package/src/eval/index.js +1 -0
  123. package/src/index.js +70 -0
  124. package/src/indexing/execution-boundary.js +144 -0
  125. package/src/indexing/index.js +8 -0
  126. package/src/indexing/provider.js +41 -0
  127. package/src/knowledge/config.js +2 -2
  128. package/src/knowledge/context-pack.js +12 -1
  129. package/src/knowledge/contracts.js +9 -4
  130. package/src/knowledge/engine.js +7 -3
  131. package/src/knowledge/service/server.js +1 -1
  132. package/src/lib/account-session.js +98 -0
  133. package/src/lib/agent-instructions.js +73 -0
  134. package/src/lib/auth.js +4 -0
  135. package/src/lib/bridge-client.js +7 -5
  136. package/src/lib/cli-preferences.js +78 -0
  137. package/src/lib/core-client.js +8 -8
  138. package/src/lib/deploy/git-guard.js +69 -0
  139. package/src/lib/deploy/health.js +57 -0
  140. package/src/lib/deploy/local-studio.js +283 -0
  141. package/src/lib/deploy/secret-scan.js +65 -0
  142. package/src/lib/deploy-receipt/index.js +5 -2
  143. package/src/lib/detect-context.js +6 -5
  144. package/src/lib/execution-approvals.js +59 -0
  145. package/src/lib/identity-scaffold.js +1 -1
  146. package/src/lib/local-scaffold.js +35 -33
  147. package/src/lib/local-sessions.js +127 -0
  148. package/src/lib/local-status.js +9 -17
  149. package/src/lib/merkle/cloudflare-persistence.js +321 -0
  150. package/src/lib/merkle/filemeta.js +43 -0
  151. package/src/lib/merkle/git-ignore.js +24 -0
  152. package/src/lib/merkle/hash.js +1 -0
  153. package/src/lib/merkle/index.js +22 -0
  154. package/src/lib/merkle/persistence.js +72 -0
  155. package/src/lib/merkle/semantic.js +359 -0
  156. package/src/lib/merkle/snapshot.js +9 -3
  157. package/src/lib/merkle/tree.js +11 -6
  158. package/src/lib/project-config.js +227 -0
  159. package/src/lib/project-rules.js +68 -0
  160. package/src/lib/provider-credentials.js +83 -0
  161. package/src/lib/save-sdk-token.js +1 -1
  162. package/src/lib/scaffold/templates/worker-api/index.js +101 -20
  163. package/src/lib/scaffold/wizards/worker-api.js +27 -11
  164. package/src/lib/slash-commands.js +22 -15
  165. package/src/lib/tools.js +11 -5
  166. package/src/models/catalog.js +135 -0
  167. package/src/models/index.js +7 -0
  168. package/src/providers/index.js +5 -0
  169. package/src/providers/openai-responses.js +275 -0
  170. package/src/security/index.js +1 -0
  171. package/src/security/inventory.js +4 -1
  172. package/src/security/process.js +35 -9
  173. package/src/security/render.js +27 -5
  174. package/src/security/scan.js +24 -9
  175. package/src/security/trust-boundary.js +24 -0
  176. package/src/skills/index.js +64 -0
  177. package/src/telemetry/contracts.js +203 -0
  178. package/src/telemetry/events.js +48 -0
  179. package/src/telemetry/index.js +8 -0
  180. package/src/tools/hydrate.js +35 -0
  181. package/src/tools/index.js +2 -0
  182. package/src/tools/search.js +70 -0
  183. package/src/ui/ansi.js +1 -1
  184. package/src/ui/boot.js +54 -0
  185. package/src/ui/merkle/render.js +1 -0
  186. package/src/ui/runtime-activity.js +192 -0
  187. package/src/ui/theme.js +19 -18
  188. package/test/account-session.test.mjs +36 -0
  189. package/test/app-building-skills.test.mjs +61 -0
  190. package/test/apps-scaffold-contract.test.mjs +56 -0
  191. package/test/capabilities.test.mjs +53 -4
  192. package/test/cli-preferences.test.mjs +46 -0
  193. package/test/cloudflare-connector.test.mjs +96 -0
  194. package/test/cloudflare-runtime.test.mjs +75 -0
  195. package/test/context.test.mjs +144 -0
  196. package/test/deploy-health-scan.test.mjs +67 -0
  197. package/test/error-diagnostics.test.mjs +59 -0
  198. package/test/eval-context.test.mjs +37 -0
  199. package/test/execution-approvals.test.mjs +27 -0
  200. package/test/indexing-provider.test.mjs +29 -0
  201. package/test/jr-dev-skill.test.mjs +26 -0
  202. package/test/knowledge-context-pack.test.mjs +19 -0
  203. package/test/knowledge.test.mjs +1 -1
  204. package/test/local-sessions.test.mjs +42 -0
  205. package/test/local-studio-deploy.test.mjs +83 -0
  206. package/test/merkle-persistence.test.mjs +91 -0
  207. package/test/merkle.test.mjs +77 -3
  208. package/test/model-catalog.test.mjs +43 -0
  209. package/test/models.test.mjs +51 -0
  210. package/test/npm10-lock.test.mjs +29 -0
  211. package/test/ollama.test.mjs +94 -0
  212. package/test/openai-responses.test.mjs +95 -0
  213. package/test/project-config.test.mjs +81 -0
  214. package/test/project-rules.test.mjs +44 -0
  215. package/test/provider-credentials.test.mjs +52 -0
  216. package/test/rehydrate.test.mjs +25 -0
  217. package/test/release-hygiene.test.mjs +34 -0
  218. package/test/repository-snapshot-view.test.mjs +112 -0
  219. package/test/responses-runner.test.mjs +148 -0
  220. package/test/runtime-activity.test.mjs +98 -0
  221. package/test/sdk-worker-contract.test.mjs +68 -0
  222. package/test/security.test.mjs +46 -0
  223. package/test/shell.test.mjs +55 -21
  224. package/test/skills.test.mjs +22 -0
  225. package/test/smoke.mjs +5 -2
  226. package/test/telemetry.test.mjs +79 -0
  227. package/test/theme-portability.test.mjs +14 -0
  228. package/test/tools-search.test.mjs +40 -0
  229. package/test/whoami-resume.test.mjs +56 -0
  230. package/examples/agentsam-tui-ansi.mjs +0 -149
  231. package/src/commands/tui.js +0 -120
  232. package/src/ui/splash-xterm.js +0 -290
  233. package/src/ui/splash.js +0 -426
@@ -0,0 +1,170 @@
1
+ # Agent Sam context contracts
2
+
3
+ Agent Sam treats context as a bounded evidence pack, not as a place to dump every available index, tool, file, or prior message.
4
+
5
+ ## Project rules
6
+
7
+ Generated projects include a committed `.agentsamrules` file. It is the repository-level instruction surface, similar in spirit to `.cursorrules`.
8
+
9
+ ```text
10
+ repo/
11
+ ├── .agentsam/config.json portable project identity/defaults
12
+ ├── .agentsamrules committed project instructions
13
+ └── .agentsam/cli.json machine/user preferences; gitignored
14
+ ```
15
+
16
+ `loadProjectRules()` searches upward from the active cwd, hashes the source, and bounds loaded content before it can enter system context. The portable default ceiling is 24,000 characters; a host may choose a lower ceiling through its context budget.
17
+
18
+ `.agentsamrules` is for durable repository instructions and conventions. It is not a place for secrets, account IDs, active runs, task state, model history, terminal sessions, or Merkle roots.
19
+
20
+ ## Result policy
21
+
22
+ Every result-producing capability should have a result policy. Absence of a custom policy means the bounded SDK default:
23
+
24
+ ```json
25
+ {
26
+ "max_items": 8,
27
+ "max_chars": 24000,
28
+ "detail": "excerpt"
29
+ }
30
+ ```
31
+
32
+ A caller may request less. Asking for more items, more characters, or a higher detail class requires the explicit `higher-detail` operation.
33
+
34
+ Progressive detail is ordered as:
35
+
36
+ ```text
37
+ metadata
38
+ ↓
39
+ card
40
+ ↓
41
+ excerpt
42
+ ↓
43
+ range
44
+ ↓
45
+ full
46
+ ```
47
+
48
+ `normalizeResultPolicy()` enforces the ceiling. Built-in SDK tool cards inherit the bounded default rather than silently behaving as unlimited.
49
+
50
+ ## Context budget
51
+
52
+ `createContextBudget()` derives per-class ceilings from the selected model's context window. The default operating ratios are:
53
+
54
+ ```text
55
+ target active input 60%
56
+ emergency hard line 85%
57
+ ```
58
+
59
+ The remaining window is deliberate headroom for additional retrieval, tool iterations, reasoning, user input, and output.
60
+
61
+ A budget owns separate ceilings for:
62
+
63
+ ```text
64
+ system / project rules
65
+ tool schemas
66
+ retrieved evidence
67
+ single file reads
68
+ cumulative file reads per turn
69
+ tool results
70
+ ```
71
+
72
+ For example:
73
+
74
+ ```js
75
+ import { createContextBudget } from '@inneranimalmedia/agentsam-sdk/context';
76
+
77
+ const budget = createContextBudget({
78
+ windowTokens: 250_000,
79
+ });
80
+ ```
81
+
82
+ The resulting budget tracks both tokens and deterministic character ceilings.
83
+
84
+ ## Context items
85
+
86
+ Portable context evidence uses the following shape:
87
+
88
+ ```ts
89
+ interface ContextItem {
90
+ ref: string;
91
+ kind: 'file' | 'symbol' | 'memory' | 'tool_result' | 'repo' | 'artifact';
92
+ chars: number;
93
+ hash?: string;
94
+ priority: number;
95
+ content?: string;
96
+ }
97
+ ```
98
+
99
+ `resolveContext()` sorts candidate evidence by priority, applies kind-specific and cumulative limits, and returns only the selected items.
100
+
101
+ `resolveProjectContext()` does the same while automatically loading `.agentsamrules` within the system-context ceiling.
102
+
103
+ Every resolved pack includes a receipt:
104
+
105
+ ```json
106
+ {
107
+ "chars": 18422,
108
+ "evidence_chars": 17769,
109
+ "system_chars": 653,
110
+ "estimated_tokens": 4606,
111
+ "sources_considered": 73,
112
+ "sources_included": 6,
113
+ "sources_deferred": 67,
114
+ "deferred_refs": []
115
+ }
116
+ ```
117
+
118
+ The existing knowledge `ContextPack` now uses the same receipt vocabulary for retrieval hits.
119
+
120
+ ### Consumed tool results
121
+
122
+ `compactConsumedToolResult()` defaults to 4,000 characters for evidence that has already had its high-fidelity pass. It preserves the item ref/hash/priority so later turns can expand the source again instead of replaying the original dump.
123
+
124
+ ## Index law
125
+
126
+ > An index is a retrieval substrate, never prompt content.
127
+
128
+ The active prompt should receive a compact repository/index status plus selected evidence references. It should not receive an entire repository tree, symbol graph, embedding set, tool catalog, or hundreds of search results.
129
+
130
+ Prefer evidence in this order whenever possible:
131
+
132
+ ```text
133
+ exact structural evidence
134
+ ↓
135
+ bounded lexical/search evidence
136
+ ↓
137
+ semantic retrieval
138
+ ↓
139
+ explicit larger range/full object only when required
140
+ ```
141
+
142
+ ## Tool discovery
143
+
144
+ `searchToolCards()` supports cards-first discovery. It accepts a host/tool catalog and returns compact cards without full input schemas:
145
+
146
+ ```json
147
+ {
148
+ "tool": "code.retrieve",
149
+ "summary": "Find symbols, callers, and semantic code matches.",
150
+ "risk": "read",
151
+ "required": ["query"],
152
+ "result_class": "bounded_evidence"
153
+ }
154
+ ```
155
+
156
+ A host can hydrate the selected tool's full schema only after selection. This keeps the portable contract compatible with small local catalogs and large hosted catalogs without injecting all schemas at turn zero.
157
+
158
+ ## Subagent handoff law
159
+
160
+ A child agent should return a compact work receipt rather than its entire prompt/tool history:
161
+
162
+ ```text
163
+ conclusion
164
+ evidence refs
165
+ changed files
166
+ commands/tests
167
+ uncertainty
168
+ ```
169
+
170
+ The parent can expand an evidence ref when needed.
@@ -0,0 +1,58 @@
1
+ # Local Ollama development kit
2
+
3
+ AgentSam supports Ollama as an **opt-in local development runtime**. Ollama stays on the developer's machine; the `agentsam-sdk` Cloudflare Worker does not receive an Ollama binding and does not run an Ollama model at the edge.
4
+
5
+ Canonical local defaults:
6
+
7
+ ```text
8
+ OLLAMA_BASE_URL=http://127.0.0.1:11434
9
+ OLLAMA_MODEL=qwen2.5-coder
10
+ OLLAMA_EMBED_MODEL=mxbai-embed-large
11
+ ```
12
+
13
+ ## Setup
14
+
15
+ ```sh
16
+ agentsam ollama setup
17
+ ```
18
+
19
+ That writes the three values into the current project's `.env` and, when `.agentsam/config.json` exists, records only portable `models.local` metadata (provider + environment variable names). Machine URLs and chosen model values stay in `.env` / `.agentsam/cli.json`, not the committed project manifest. It does **not** silently install software or download models.
20
+
21
+ Explicit opt-ins are available:
22
+
23
+ ```sh
24
+ agentsam ollama setup --install
25
+ agentsam ollama setup --start
26
+ agentsam ollama setup --pull
27
+ agentsam ollama setup --install --start --pull
28
+ ```
29
+
30
+ Automatic installation uses Homebrew on macOS/Linux when available, or `winget` on Windows. Hosts without a supported local package manager receive a clear manual-install message instead of running an opaque remote install script.
31
+
32
+ Model management:
33
+
34
+ ```sh
35
+ agentsam ollama status
36
+ agentsam ollama list
37
+ agentsam ollama pull
38
+ agentsam ollama pull qwen2.5-coder
39
+ ```
40
+
41
+ `ollama pull` with no model pulls the configured chat and embedding models.
42
+
43
+ ## Local tunnel boundary
44
+
45
+ For a remote AgentSam session, use the existing **user-hosted terminal tunnel** to execute `agentsam ollama ...` on the user's machine. The local CLI then reaches `127.0.0.1:11434` from that machine.
46
+
47
+ ```text
48
+ remote agent
49
+ │
50
+ │ existing terminal tunnel
51
+ ▼
52
+ local AgentSam CLI
53
+ │
54
+ └── http://127.0.0.1:11434
55
+ local Ollama process
56
+ ```
57
+
58
+ This avoids exposing Ollama's HTTP API to the public internet and avoids pretending that a Cloudflare Worker can reach the developer's loopback interface. A deliberately configured HTTP tunnel can still be supplied with `--base-url`, but it is not the default product path.
package/docs/MERKLE.md CHANGED
@@ -1,16 +1,16 @@
1
- # Merkle CLI and terminal explorer
1
+ # Merkle CLI and interactive explorer
2
2
 
3
3
  ```bash
4
4
  agentsam merkle root .
5
5
  agentsam merkle root . --include dist
6
- agentsam merkle snapshot . --out .agentsam/merkle.json
6
+ agentsam merkle snapshot . --semantic --out .agentsam/merkle.json
7
7
  agentsam merkle verify .agentsam/merkle.json
8
- agentsam merkle diff ./copy-a ./copy-b --tui
8
+ agentsam merkle diff ./copy-a ./copy-b --interactive
9
9
  agentsam merkle inspect .
10
- agentsam tui merkle .
10
+ agentsam merkle explore .
11
11
  ```
12
12
 
13
- The commands work on ordinary folders, including a mini prototype. Git, cloud accounts, databases, and containers are not required. Only `snapshot` writes files. There is no synchronization/restore command or background watcher in this version.
13
+ The commands work on ordinary folders. Git, cloud accounts, databases, and containers are not required. Only `snapshot` writes files. There is no synchronization/restore command or background watcher in this version.
14
14
 
15
15
  ## Commands
16
16
 
@@ -21,50 +21,50 @@ The commands work on ordinary folders, including a mini prototype. Git, cloud ac
21
21
  | `verify <snapshot>` | Rescans the recorded root and reports unchanged, modified, added, and removed files/links. |
22
22
  | `diff <a> <b>` | Compares directories, snapshots, or one of each. No files are copied. |
23
23
  | `inspect [path]` | Prints the full tree/hash breakdown; also accepts a snapshot. |
24
- | `tui [path]` | Opens the keyboard-driven explorer. Alias: `agentsam tui merkle [path]`. |
24
+ | `explore [path]` | Opens the keyboard-driven terminal explorer. |
25
25
 
26
- `--tui` also works with root, inspect, verify, and diff. Up/down or j/k select an entry; Enter/right expands a directory; left collapses it. `c` filters changes, `r` rescans, and q/Esc/Ctrl+C exits. The UI uses real scan counts, honors `NO_COLOR`, adapts to terminal resize, wraps the selected hash on narrow screens, and restores the cursor and terminal mode on exit. `r` does not update a saved baseline. Failed rescans remain visible and exit as an error.
26
+ `--semantic` works with root, snapshot, and directory inspection. It adds deterministic `agentsam-filemeta` package/system/category/layer metadata plus JavaScript/TypeScript AST symbols/imports while leaving the v1 content root unchanged. Semantic snapshots validate both roots when reloaded.
27
27
 
28
- With piped output or `TERM=dumb`, the TUI prints once and exits. `--json` always bypasses interactive mode. Root JSON contains `rootPath`, `rootHash`, `stats`, and `policy`; verify/diff JSON contains `equal`, roots, counts, and the changed entries. Inspect/snapshot output contains the full manifest (snapshot adds `output`).
28
+ `--interactive` works with root, inspect, verify, and diff. Up/down or j/k select an entry; Enter/right expands a directory; left collapses it. `c` filters changes, `r` rescans, and q/Esc/Ctrl+C exits. The explorer uses real scan counts, honors `NO_COLOR`, adapts to terminal resize, wraps the selected hash on narrow screens, and restores cursor/terminal mode on exit. `r` does not update a saved baseline.
29
+
30
+ With piped output or `TERM=dumb`, the explorer prints once and exits. `--json` always bypasses interactive mode. Root JSON contains `rootPath`, `rootHash`, `policyHash`, `stats`, and `policy`; with `--semantic` it also contains `metadataRoot`, `classifier`, and `semanticStats`; verify/diff JSON contains `equal`, roots, counts, and changed entries.
29
31
 
30
32
  Exit codes: **0** success/match, **1** differences, **2** invalid input/scan error, **130** interrupted non-interactive scan. Interactive quit after a completed comparison retains its match/difference exit code.
31
33
 
32
34
  ## Comparing machines and preserving baselines
33
35
 
34
- Copy a manifest to another machine, then explicitly select that machine's checkout:
35
-
36
36
  ```bash
37
- agentsam merkle verify ./baseline.json --root ./local-copy --tui
37
+ agentsam merkle verify ./baseline.json --root ./local-copy --interactive
38
38
  ```
39
39
 
40
- Verification uses the saved include/exclude policy. Roots are independent of absolute paths, timestamps, permissions, and creation order. Matching roots mean the **included relative names, file bytes, and literal symlink targets** match, subject to SHA-256 collision resistance. Empty directories are omitted. Line endings, Unicode filename normalization, and symlink target spelling are not normalized.
40
+ Verification uses the saved include/exclude policy. Content roots are independent of absolute paths, timestamps, permissions, and creation order. Permission `mode` may still be recorded as metadata and, when semantic enrichment is enabled, contributes to the separate metadata root.
41
41
 
42
- Snapshots are baselines, not signatures or attestations of who created them. Protect a trusted baseline separately. For a consistent scan, avoid editing the directory while hashing it; detectable changes/read errors fail the scan, but this is not an atomic filesystem snapshot.
42
+ Snapshots are baselines, not signatures or attestations. Protect a trusted baseline separately. Avoid editing a directory while hashing it; detectable changes/read errors fail the scan, but this is not an atomic filesystem snapshot.
43
43
 
44
- Existing snapshot files are not overwritten without `--force`. Snapshot output is excluded from its own tree. The manifest records a custom output exclusion when necessary. Save multiple historical snapshots under `.agentsam/merkle/`, which is ignored by default:
44
+ Existing snapshot files are not overwritten without `--force`. Snapshot output is excluded from its own tree. Save historical snapshots under `.agentsam/merkle/`, which is ignored by default:
45
45
 
46
46
  ```bash
47
47
  agentsam merkle snapshot . --out .agentsam/merkle/before.json
48
48
  agentsam merkle snapshot . --out .agentsam/merkle/after.json
49
- agentsam merkle diff .agentsam/merkle/before.json .agentsam/merkle/after.json --tui
49
+ agentsam merkle diff .agentsam/merkle/before.json .agentsam/merkle/after.json --interactive
50
50
  ```
51
51
 
52
52
  ## Ignore rules
53
53
 
54
54
  Default ignored names: `.git`, `node_modules`, `dist`, `.DS_Store`. Default ignored root subtrees/files: `.agentsam/cache`, `.agentsam/merkle`, `.agentsam/merkle.json`.
55
55
 
56
- `--include dist` disables that default rule. Repeat `--include` for additional default rules. `--exclude generated` ignores that name at any depth; `--exclude assets/cache` ignores that exact relative subtree. Rules are literal paths, not globs or `.gitignore` patterns. Explicit exclusions take precedence. Comparing snapshots with different policies is refused; a directory compared with a snapshot uses the snapshot's policy.
56
+ `--include dist` disables that default rule. Repeat `--include` for additional default rules. `--exclude generated` ignores that name at any depth; `--exclude assets/cache` ignores that exact relative subtree. Rules are literal paths, not globs or `.gitignore` patterns. Explicit exclusions take precedence.
57
57
 
58
- The scanner hashes symlink target strings without following them. Special files (sockets, pipes, devices), unrepresentable filenames, unreadable files, and directory depths over 256 produce errors instead of silently weakening the tree.
58
+ The scanner hashes symlink target strings without following them. Special files, unrepresentable filenames, unreadable files, and directory depths over 256 produce errors instead of silently weakening the tree.
59
59
 
60
60
  ## Reusable Node library
61
61
 
62
62
  ```js
63
- import { buildMerkleTree, saveSnapshot, readSnapshot, diffTrees } from '@inneranimalmedia/agentsam-sdk/merkle';
63
+ import { buildMerkleTree, readSnapshot, diffTrees } from '@inneranimalmedia/agentsam-sdk/merkle';
64
64
 
65
65
  const baseline = await readSnapshot('./baseline.json');
66
66
  const current = await buildMerkleTree('./checkout', { policy: baseline.policy });
67
67
  const comparison = diffTrees(baseline, current);
68
68
  ```
69
69
 
70
- The library is local filesystem tooling. It adds no Worker bindings, user/workspace identity, network calls, or package dependencies. The interoperable hash format is specified in [MERKLE_V1](../protocol/MERKLE_V1.md).
70
+ The library is local filesystem tooling. It adds no Worker bindings, user/workspace identity, or network calls. The interoperable content hash format is specified in [MERKLE_V1](../protocol/MERKLE_V1.md), and semantic identity in [FILEMETA_V1](../protocol/FILEMETA_V1.md).
@@ -44,13 +44,14 @@ For trusted operator/service calls, configure one secret:
44
44
  export AGENTSAM_BRIDGE_KEY='...'
45
45
  ```
46
46
 
47
- Optional base URL overrides:
47
+ Canonical IAM/platform origin:
48
48
 
49
49
  ```bash
50
- export AGENTSAM_BASE_URL='https://agentsam.example.com'
51
- # AGENTSAM_CORE_URL and IAM_CORE_URL are also supported.
50
+ export IAM_ORIGIN='https://agentsam.example.com'
52
51
  ```
53
52
 
53
+ `AGENTSAM_BASE_URL`, `AGENTSAM_CORE_URL`, and `IAM_CORE_URL` remain compatibility-only read fallbacks during the migration window.
54
+
54
55
  Programmatic API:
55
56
 
56
57
  ```js
@@ -0,0 +1,72 @@
1
+ # `.agentsam/config.json` — portable project manifest
2
+
3
+ `.agentsam/config.json` is the small committed handshake that tells Agent Sam what project it is operating in and which portable defaults apply. It is **not** a runtime journal.
4
+
5
+ Current schema:
6
+
7
+ ```json
8
+ {
9
+ "schema_version": 2,
10
+ "project": {
11
+ "name": "agentsam-sdk"
12
+ },
13
+ "repository": {
14
+ "id": "github:samprimeaux/agentsam-sdk",
15
+ "remote": "origin"
16
+ },
17
+ "product": {
18
+ "preset": null,
19
+ "features": [],
20
+ "capabilities": []
21
+ },
22
+ "defaults": {
23
+ "mode": "agent",
24
+ "profile": "default",
25
+ "runtime": "local",
26
+ "model": "auto",
27
+ "deploy_target": null
28
+ },
29
+ "merkle": {
30
+ "enabled": true,
31
+ "semantic": true,
32
+ "persistence": "auto"
33
+ },
34
+ "rules": {
35
+ "file": ".agentsamrules"
36
+ },
37
+ "knowledge": {
38
+ "config": ".agentsam/knowledge.json"
39
+ },
40
+ "local": {
41
+ "database": ".agentsam/data/agentsam.sqlite",
42
+ "schema": "db/schema.sql"
43
+ },
44
+ "sdk": {
45
+ "created_with": "2.5.0"
46
+ }
47
+ }
48
+ ```
49
+
50
+ ## Ownership boundaries
51
+
52
+ ```text
53
+ .agentsam/config.json committed portable project identity + defaults
54
+ .agentsamrules committed repository instructions; bounded when loaded
55
+ .agentsam/knowledge.json repository index / retrieval configuration
56
+ .agentsam/cli.json local user's terminal/runtime/model preference; gitignored
57
+ D1 / runtime stores runs, plans, tasks, executions, model history, subagents
58
+ Merkle snapshot store filesystem evidence and snapshot lineage
59
+ Git source-control authority
60
+ ```
61
+
62
+ Do **not** add account/user/tenant/workspace identity, current run IDs, active task state, PTY/session/connection IDs, current Merkle roots, provider credentials, deployment receipts, model history, or subagent execution records to the project manifest.
63
+
64
+ `repository.id` is the portable repository authority for Agent Sam surfaces. Existing `knowledge.json.repository_id` remains readable during migration, but when both files exist the IDs must agree. Git remote discovery is fallback/adoption evidence rather than a second persistent identity.
65
+
66
+ For a repository already hosted on a known Git provider, IDs use the portable form such as `github:owner/repo`. Repositories without a provider identity receive a durable `local:<uuid>` ID.
67
+
68
+ Project defaults are intentionally different from machine preferences. A project can say `defaults.model = "auto"`; a developer can independently prefer an Ollama model on one laptop in `.agentsam/cli.json` without changing the repository contract.
69
+
70
+ ## Project instructions
71
+
72
+ Generated projects include `.agentsamrules` as the human-editable repository instruction surface. The manifest only points to it; the instructions themselves stay outside JSON so teams can maintain them like other repository documentation. Runtime loaders hash and bound the file before it enters context.
package/docs/RELEASES.md CHANGED
@@ -1,10 +1,43 @@
1
1
  # `@inneranimalmedia/agentsam-sdk` release receipts
2
2
 
3
- **2.1.0 is published on npm and is the `latest` dist-tag.** The private identity workspace
4
- continues to ship through the root SDK exports and is not published separately.
3
+ **2.6.0 is the current release candidate on `main`; it is not published yet.**
4
+ The npm `latest` dist-tag is **2.5.0**. The private identity workspace continues to
5
+ ship through root SDK exports and is not published separately.
6
+
7
+ Release-candidate base: `2643c164b0a745d0772f1aa9808c03bbe3873c94`. The final tagged publish commit will be recorded
8
+ here after release. Publishing remains manual and `prepublishOnly` runs
9
+ `npm run verify:release`.
10
+
11
+ ## 2.6.0 candidate highlights
12
+
13
+ - Interactive AgentSam now has persistent machine-local account/session identity with explicit `login`, `logout`, `whoami`, and `resume` flows.
14
+ - `/models` and model-selection UX bind to the canonical model inventory v2 contract instead of maintaining a second CLI catalog.
15
+ - Provider credentials and account BYOK resolution are scoped, source-aware, and reusable across interactive, deploy, and tunnel flows without storing secrets in project state.
16
+ - Runtime receipts now model account-owned runs, provider usage, approvals, and terminal jobs with stable lineage and no tenant/workspace/user ownership aliases.
17
+ - Cloudflare diagnostics, context economics, repository evidence, and security/indexing contracts accumulated after 2.5.0 are included in the same verified release lineage.
18
+
19
+ ## 2.5.0 highlights
20
+
21
+ - `agentsam` is the interactive product entrypoint; renderer selection is internal, and live thinking/activity scenes now run automatically around real Agent Sam work.
22
+ - Portable project authority is `.agentsam/config.json` + `.agentsamrules`; local CLI preferences remain non-authoritative.
23
+ - Public SDK seams include `/context`, `/tools`, `/indexing`, `/repository`, `/knowledge`, and `/skills`.
24
+ - Context resolution is bounded by independent budgets and result policies; consumed tool results compact to evidence-preserving receipts.
25
+ - Tool discovery is cards-first rather than full-schema catalog injection.
26
+ - `RepositoryKnowledgeProvider` keeps local, hosted, and custom repository-intelligence implementations behind one contract.
27
+ - Portable skills now include `agentsam-jr-dev`, `agentsam-app-fundamentals` (`quick-bytes`), and `agentsam-progression-guard` (`no-regress`), with deeper references loaded on demand and CLI discovery through `agentsam skills`.
28
+ - Local model inventory/Ollama support remains preference-only and does not become a second routing authority.
29
+ - Merkle/repository evidence, knowledge receipts, and project identity share the same portable repository identity.
30
+ - `agentsam security scan` now combines OSV/dependency evidence with Merkle-bound AST execution trust-boundary contradictions; `agentsam inspect` exposes the same bounded analysis and mechanical repair actions.
5
31
 
6
32
  | npm version | Published (UTC) | IAM git SHA (40) | Notes |
7
33
  |-------------|-----------------|------------------|-------|
34
+ | 2.6.0 | _(pending)_ | _(tag at publish)_ | Release candidate; interactive model/session SSOT and account-scoped runtime receipts. |
35
+ | 2.5.0 | 2026-09-11T21:27:11.516Z | `da28623dc4808025b77605ed09aa16217b1db607` | Published package; registry `gitHead` receipt. |
36
+ | 2.4.1 | 2026-09-11T05:45:03.622Z | `a256ababededd904da555e7898bc8afd753737d2` | Latest published package before 2.5.0. |
37
+ | 2.4.0 | 2026-09-11T05:29:02.811Z | `81c8659977953bed53c2adb0a341ce7382be4794` | Published 2.4 line. |
38
+ | 2.3.0 | 2026-09-11T05:09:40.046Z | `b517a720fb9b90f35c26f9ef87a84abd60d7ee01` | Published 2.3 line. |
39
+ | 2.2.1 | 2026-09-11T04:08:18.238Z | `fefb587312df4fd4e177e839c5374c9621e7463d` | Published 2.2 patch. |
40
+ | 2.2.0 | 2026-09-11T02:48:47.291Z | `06539ba3d3c2238b08201192dbec33d0e8df4b8a` | Published 2.2 line. |
8
41
  | 2.1.0 | 2026-09-09 (UTC, approx) | `a2570afdf1ae99542565fa3937abd7dbf95d121f` | Recon bounded-worker protocol: `protocol/recon/*` schemas, `python/agentsam_sdk/repository/recon` (packet/validate + `from_ripgrep`/`from_ast_grep` adapters), `agentsam recon pack\|validate` CLI (#27, #28). SDK-native change — no corresponding IAM platform-repo mirror SHA. |
9
42
  | 2.0.0 | 2026-09-03T02:21:44.857Z | `ed629869e701809d2bf4c61bd56d05d8d8d1e183` | Stable SDK 2.0.0; npm `latest`; identity bundled through root exports; release verification and dependency scan passed before publish. |
10
43
  | 2.0.0-alpha.identity.5 | _(pending npm)_ | `df064114eb7f8888f163e4a07dfddf19035b7169` | Password reset service, `registerFinalizeInboundOAuth`, IAM live proof. |
@@ -10,7 +10,7 @@ python -m agentsam_sdk.repository.intelligence --repo-root ..
10
10
  python -m agentsam_sdk.repository.intelligence --repo-root .. --json
11
11
  ```
12
12
 
13
- The snapshot is deterministic evidence suitable for CLI/TUI presentation or downstream agent reasoning. Scores are relative within a snapshot, not quality grades:
13
+ The snapshot is deterministic evidence suitable for CLI/terminal UI presentation or downstream agent reasoning. Scores are relative within a snapshot, not quality grades:
14
14
 
15
15
  - **density** — code/file concentration
16
16
  - **activity** — recent changed lines and commit touches
@@ -0,0 +1,114 @@
1
+ # Repository knowledge provider contract
2
+
3
+ The SDK does not define the InnerAnimal production code index as the universal implementation.
4
+
5
+ The npm package defines the portable capability contract. A host chooses how to satisfy it.
6
+
7
+ ```text
8
+ Agent Sam repository understanding
9
+ │
10
+ ┌───────┼────────┐
11
+ │ │ │
12
+ ▼ ▼ ▼
13
+ Local Hosted Existing
14
+ SDK AgentSam system
15
+ │ │ │
16
+ lightweight full Sourcegraph /
17
+ local slice platform Qdrant /
18
+ custom service
19
+ ```
20
+
21
+ ## Provider surface
22
+
23
+ A `RepositoryKnowledgeProvider` supplies:
24
+
25
+ ```text
26
+ status()
27
+ refresh()
28
+ findSymbol()
29
+ graph()
30
+ retrieve()
31
+ snapshot()
32
+ ```
33
+
34
+ The SDK intentionally does not prescribe D1 tables, pgvector schemas, parser processes, queues, or embedding providers behind those calls.
35
+
36
+ ```js
37
+ import {
38
+ createRepositoryKnowledgeClient,
39
+ describeRepositoryKnowledgeProvider,
40
+ } from '@inneranimalmedia/agentsam-sdk/indexing';
41
+ ```
42
+
43
+ A provider should describe actual capabilities rather than relying on stale prose metadata:
44
+
45
+ ```js
46
+ describeRepositoryKnowledgeProvider({
47
+ provider: 'inneranimal-platform',
48
+ structure: 'tree-sitter',
49
+ lexical: true,
50
+ semantic: true,
51
+ graph: true,
52
+ history: true,
53
+ evidence: 'merkle',
54
+ });
55
+ ```
56
+
57
+ ## User-facing concepts
58
+
59
+ The terminal/UI should normally present only:
60
+
61
+ ```text
62
+ Code map where things are and how they connect
63
+ Search exact/lexical search + optional semantic search
64
+ History generations, Git evidence, and Merkle checkpoints
65
+ ```
66
+
67
+ Parser technology, dimensions, vector tables, queue topology, generation internals, and storage adapters belong under advanced/debug surfaces.
68
+
69
+ ## Local SDK implementation
70
+
71
+ The current SDK contains a portable/local knowledge slice with deterministic repository intelligence, lightweight JS/TS structural parsing, bounded chunks, local SQLite, optional Postgres/pgvector, optional embeddings, generations, and Merkle evidence.
72
+
73
+ That is useful as a standalone implementation. It is not presented as the architecture of every Agent Sam host.
74
+
75
+ ## InnerAnimal production implementation
76
+
77
+ The InnerAnimal platform is a separate host implementation with a broader code-intelligence pipeline: repository/index generations, a dedicated Tree-sitter parsing service, D1 structural nodes/edges, structural-first graph retrieval, semantic projections, and bounded hydration.
78
+
79
+ That implementation should plug into the provider contract rather than be copied into npm.
80
+
81
+ The same rule applies to the platform's logical RAG lanes (`code`, `schema`, `memory`, `docs`, `media`, `archive`), generic knowledge ingestion pipeline, and memory/experience systems. Those are specialized host infrastructure behind portable Agent Sam capability contracts.
82
+
83
+ ## Existing/custom systems
84
+
85
+ A customer does not need to reproduce Agent Sam's internal storage model. They can implement the provider surface around their own system.
86
+
87
+ Examples:
88
+
89
+ ```text
90
+ Sourcegraph
91
+ Elasticsearch
92
+ Postgres / pgvector
93
+ Qdrant
94
+ Weaviate
95
+ custom Tree-sitter service
96
+ homegrown RAG / graph service
97
+ ```
98
+
99
+ The common contract lets Agent Sam ask for status, refresh, symbols, graph evidence, retrieval, and snapshots while the implementation remains the customer's authority.
100
+
101
+ ## Evidence lineage
102
+
103
+ Provider results should carry stable evidence references when possible:
104
+
105
+ ```text
106
+ repository_id
107
+ index generation
108
+ Merkle snapshot_id / root hash
109
+ Git revision
110
+ path + span
111
+ provider receipt
112
+ ```
113
+
114
+ That lets context packs select evidence without copying the entire underlying index into the prompt.