@inneranimalmedia/agentsam-sdk 2.0.0 → 2.2.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/README.md +28 -15
- package/docs/CAPABILITIES.md +93 -0
- package/docs/DEPLOY_RECEIPTS.md +83 -0
- package/docs/RECON.md +165 -0
- package/docs/RELEASES.md +4 -3
- package/docs/portable-knowledge.md +4 -4
- package/docs/sdk-2.0-release.md +19 -21
- package/package.json +8 -1
- package/packages/identity/package.json +1 -1
- package/packages/identity/src/frontend/auth-portal/README.md +1 -1
- package/packages/identity/src/index.js +2 -0
- package/protocol/capabilities/capability-manifest.schema.json +36 -0
- package/protocol/capabilities/manifest.json +179 -0
- package/protocol/capabilities/repository-audit-input.schema.json +14 -0
- package/protocol/capabilities/repository-audit.schema.json +30 -0
- package/protocol/capabilities/repository-snapshot-input.schema.json +11 -0
- package/protocol/capabilities/repository-snapshot.schema.json +20 -0
- package/protocol/knowledge/chunk.schema.json +15 -73
- package/protocol/knowledge/document.schema.json +10 -48
- package/protocol/knowledge/index-config.schema.json +2 -2
- package/protocol/knowledge/repository.schema.json +11 -52
- package/protocol/knowledge/retrieval-query.schema.json +13 -63
- package/protocol/knowledge/source.schema.json +9 -43
- package/protocol/presets/catalog.json +48 -0
- package/protocol/recon/README.md +19 -0
- package/protocol/recon/finding-report.schema.json +46 -0
- package/protocol/recon/task-packet.schema.json +79 -0
- package/python/agentsam_sdk/knowledge/models.py +19 -7
- package/python/agentsam_sdk/repository/__main__.py +2 -2
- package/python/agentsam_sdk/repository/recon/__init__.py +28 -0
- package/python/agentsam_sdk/repository/recon/__main__.py +3 -0
- package/python/agentsam_sdk/repository/recon/cli.py +178 -0
- package/python/agentsam_sdk/repository/recon/packet.py +294 -0
- package/python/agentsam_sdk/repository/recon/validate.py +76 -0
- package/python/tests/test_knowledge_models.py +6 -2
- package/python/tests/test_recon.py +257 -0
- package/src/agent/capability-adapter.js +50 -0
- package/src/agent/index.js +2 -0
- package/src/agent/repository-audit.js +188 -0
- package/src/capabilities/index.js +7 -0
- package/src/capabilities/manifest.js +22 -0
- package/src/capabilities/repository-snapshot.js +180 -0
- package/src/cli.js +68 -8
- package/src/commands/deploy-receipt.js +129 -0
- package/src/commands/deploy.js +0 -1
- package/src/commands/knowledge.js +5 -6
- package/src/commands/product.js +119 -0
- package/src/commands/recon.js +71 -0
- package/src/index.js +17 -0
- package/src/knowledge/config.js +12 -6
- package/src/knowledge/contracts.js +1 -1
- package/src/knowledge/engine.js +1 -1
- package/src/knowledge/service/server.js +2 -2
- package/src/lib/deploy-receipt/index.js +246 -0
- package/src/lib/git-context.js +3 -1
- package/src/presets/index.js +20 -0
- package/src/repository/index.js +4 -0
- package/test/agent-capabilities.test.mjs +67 -0
- package/test/capabilities.test.mjs +84 -0
- package/test/deploy-receipt.test.mjs +91 -0
- package/test/portable-context.test.mjs +11 -1
package/README.md
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
# AgentSam SDK
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
A deterministic-first application and agent toolkit: reusable repository, knowledge, integrity,
|
|
4
|
+
security, identity, scaffolding, and delivery capabilities with optional AgentSam/LLM composition.
|
|
5
|
+
CLI/TUI surfaces make those same primitives easy to use without making a model part of the implementation.
|
|
5
6
|
|
|
6
7
|
**npm:** `@inneranimalmedia/agentsam-sdk` · **Source:** [GitHub](https://github.com/SamPrimeaux/agentsam-sdk)
|
|
7
8
|
|
|
@@ -24,19 +25,23 @@ or use local scaffolding/indexing.
|
|
|
24
25
|
## Create a local application
|
|
25
26
|
|
|
26
27
|
```sh
|
|
27
|
-
agentsam
|
|
28
|
+
agentsam create my-agent --preset fullstack
|
|
28
29
|
cd my-agent
|
|
29
30
|
npm install
|
|
30
31
|
npm run smoke
|
|
31
|
-
|
|
32
|
+
agentsam dev
|
|
32
33
|
```
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
Presets are deterministic configuration bundles, not model prompts. Available starting presets are
|
|
36
|
+
`fullstack`, `cms`, `prototype`, and `data`; they select an existing scaffold lane plus explicit feature
|
|
37
|
+
and capability IDs. They do not silently provision cloud resources. The older
|
|
38
|
+
`agentsam init --name my-agent --yes` scaffold entry point remains available for compatibility.
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
The generated project contains a Git repository, local SQLite database, environment templates, a Node
|
|
41
|
+
API, and terminal commands. Local setup does not require an IAM account, cloud credentials, a model, or
|
|
42
|
+
a tunnel. Use `agentsam add <feature>` to record an explicit feature selection and its capability set.
|
|
43
|
+
|
|
44
|
+
Without a global install, use `npx @inneranimalmedia/agentsam-sdk create my-agent --preset fullstack`.
|
|
40
45
|
|
|
41
46
|
## Index an existing repository
|
|
42
47
|
|
|
@@ -57,16 +62,23 @@ The JavaScript/TypeScript parser records syntactic relationships, not a fully re
|
|
|
57
62
|
semantic call graph. Model/dimension changes create a distinct embedding profile.
|
|
58
63
|
Python-backed snapshots capture repository composition and Git churn.
|
|
59
64
|
|
|
60
|
-
##
|
|
65
|
+
## Capability discovery and available kits
|
|
66
|
+
|
|
67
|
+
The canonical machine-readable capability registry is available through `agentsam capabilities --json`
|
|
68
|
+
and `@inneranimalmedia/agentsam-sdk/capabilities`. `agentsam inspect --json` runs the canonical
|
|
69
|
+
read-only `repository.snapshot` composition primitive. See [Capabilities and presets](docs/CAPABILITIES.md).
|
|
61
70
|
|
|
62
71
|
| Capability | Entry point | Guide |
|
|
63
72
|
| --- | --- | --- |
|
|
73
|
+
| Capability registry + presets | `agentsam capabilities`, `/capabilities`, `/presets` | [Capabilities](docs/CAPABILITIES.md) |
|
|
74
|
+
| Canonical repository snapshot | `agentsam inspect --json`; `/repository` | [Capabilities](docs/CAPABILITIES.md) |
|
|
64
75
|
| Git context and bridge client | `agentsam context --json`; `/git-context`, `/bridge-client` | [Portable context](docs/PORTABLE_CONTEXT.md) |
|
|
65
76
|
| Identity contracts and adapters | `/identity`; `agentsam identity init` | [Identity](packages/identity/README.md) |
|
|
66
77
|
| Repository knowledge | `agentsam index`, `search`, `repo`; `/knowledge` | [Knowledge](docs/portable-knowledge.md) |
|
|
67
78
|
| File integrity | `agentsam merkle`; `/merkle` | [Merkle](docs/MERKLE.md) |
|
|
68
79
|
| Dependency health and repair | `agentsam security`; `/security` | [Security](docs/SECURITY.md) |
|
|
69
80
|
| Mini prototypes | `agentsam mini`; `/mini` | [Mini](docs/MINI.md) |
|
|
81
|
+
| Recon bounded-worker packets | `agentsam recon pack\|validate` | [Recon](docs/RECON.md) |
|
|
70
82
|
| Local containers | `agentsam dockerize`; `/dockerize` | [Dockerize](docs/DOCKERIZE.md) |
|
|
71
83
|
| Background indexing service | Docker `knowledge_service`; `/knowledge-service-client` | [Knowledge service](docs/knowledge-service.md) |
|
|
72
84
|
| Local status, DB, terminal UI | `agentsam status`, `db`, `tui`, `start-local` | [Terminal UI](docs/CLI_SHELL.md) |
|
|
@@ -92,11 +104,12 @@ authorizes its caller. Other local tooling uses Node APIs.
|
|
|
92
104
|
|
|
93
105
|
## Host integration and ownership
|
|
94
106
|
|
|
95
|
-
The root `AgentSam` helper supplies
|
|
96
|
-
tool execution policy, provider credentials,
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
Deterministic SDK capabilities remain useful without a model. The root `AgentSam` helper supplies an
|
|
108
|
+
optional routing/session wrapper, while model orchestration, tool execution policy, provider credentials,
|
|
109
|
+
actor/account authorization, workflow durability, approvals, jobs, and production application records
|
|
110
|
+
belong to the consuming host application. Git/repository identity never proves actor authority, and the SDK
|
|
111
|
+
does not create a second platform tools database. The old `scaffoldProject()` export is deprecated; use
|
|
112
|
+
`agentsam create` or the local scaffold commands.
|
|
100
113
|
|
|
101
114
|
This repository owns portable code once. Applications import it and provide adapters;
|
|
102
115
|
they do not mirror SDK trees. [Ownership protocol](protocol/README.md).
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Deterministic capabilities and product presets
|
|
2
|
+
|
|
3
|
+
AgentSam SDK treats useful mechanics as deterministic capabilities first. Model/agent orchestration is an optional consumer of those capabilities, not a prerequisite for using them.
|
|
4
|
+
|
|
5
|
+
## Contract
|
|
6
|
+
|
|
7
|
+
A capability has a stable ID, kind, runtime, side-effect class, CLI/library entry point where applicable, and explicit model requirement. The canonical data SSOT is `protocol/capabilities/manifest.json`; `src/capabilities/manifest.js` is only its runtime reader. Presets follow the same rule through `protocol/presets/catalog.json`.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import { getCapabilityManifest, repositorySnapshot } from '@inneranimalmedia/agentsam-sdk/capabilities';
|
|
11
|
+
import { getPresetCatalog } from '@inneranimalmedia/agentsam-sdk/presets';
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Raw machine-readable data is also shipped through the `/capability-manifest` and `/preset-catalog` package subpaths.
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
agentsam capabilities
|
|
18
|
+
agentsam capabilities repository.snapshot --json
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This registry is intended to drive CLI/TUI discovery, AgentSam/MCP tool selection, docs, verification, and workflow capability resolution. It is deliberately not a second hosted tools database.
|
|
22
|
+
|
|
23
|
+
## repository.snapshot
|
|
24
|
+
|
|
25
|
+
`repository.snapshot` is the first canonical composition primitive. It performs one read-only evidence collection pass over the current checkout and combines existing SDK mechanics:
|
|
26
|
+
|
|
27
|
+
- Git resource identity and revision
|
|
28
|
+
- Python repository intelligence
|
|
29
|
+
- Merkle root and tree statistics
|
|
30
|
+
- package/manifests
|
|
31
|
+
- local knowledge/index generation when configured
|
|
32
|
+
- last trusted local deployment receipt when available
|
|
33
|
+
- a content hash over the collected evidence
|
|
34
|
+
|
|
35
|
+
It does **not** call an LLM, mutate source, index the repository, provision cloud resources, or invent platform account/workspace authority.
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
agentsam inspect --json
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { repositorySnapshot } from '@inneranimalmedia/agentsam-sdk/repository';
|
|
43
|
+
const snapshot = await repositorySnapshot({ cwd: process.cwd() });
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The timestamp is not included in the content hash, so unchanged evidence produces the same `content_hash` and `snapshot_id`.
|
|
47
|
+
|
|
48
|
+
## Optional AgentSam/LLM composition
|
|
49
|
+
|
|
50
|
+
`repository.audit` is intentionally a different kind of manifest entry: an `agent_primitive`, not a deterministic evidence collector. It accepts a certified `repository.snapshot`, builds a bounded read-only evidence packet, and requires the caller to inject a `reasoner(packet)` function. The SDK does not choose a provider or model.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import { createCapabilityAdapter, runRepositoryAudit } from '@inneranimalmedia/agentsam-sdk/agent';
|
|
54
|
+
|
|
55
|
+
const audit = await runRepositoryAudit({
|
|
56
|
+
snapshot,
|
|
57
|
+
reasoner: async packet => myModelAnalyze(packet),
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
The audit validator rejects mutation-oriented output keys such as jobs, executions, commits, deployments, mutations, and patches. A host Workflow may later turn validated findings/routes into plans or proposed jobs; that durable process remains outside the SDK.
|
|
62
|
+
|
|
63
|
+
`createCapabilityAdapter()` converts the same canonical manifest into a small executable tool surface. Built-in `repository.snapshot` is available without a model; `repository.audit` becomes available only when a reasoner is supplied; other capability handlers can be injected explicitly by a host. This is the intended search-and-execute boundary rather than exposing every SDK command to every agent turn.
|
|
64
|
+
|
|
65
|
+
## Product UX and power-user UX
|
|
66
|
+
|
|
67
|
+
Product entry points are intentionally small:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
agentsam create myapp --preset fullstack
|
|
71
|
+
agentsam add knowledge
|
|
72
|
+
agentsam dev
|
|
73
|
+
agentsam inspect
|
|
74
|
+
agentsam deploy
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Power-user primitives remain available:
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
agentsam repo snapshot
|
|
81
|
+
agentsam index ...
|
|
82
|
+
agentsam search ...
|
|
83
|
+
agentsam merkle ...
|
|
84
|
+
agentsam recon ...
|
|
85
|
+
agentsam security ...
|
|
86
|
+
agentsam deploy-receipt ...
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Presets select a coherent starting configuration; they do not silently provision remote services. `agentsam add` records an explicit feature selection in `.agentsam/features.json`; feature-specific commands continue to own real mutations until an additive handler can satisfy the complete feature contract safely.
|
|
90
|
+
|
|
91
|
+
## Ownership boundary
|
|
92
|
+
|
|
93
|
+
The SDK owns portable deterministic implementations and contracts. A host platform owns actor authorization, account ownership, workflow durability, approvals, job materialization, provider credentials, and application records. Portable repository capabilities must never infer actor authority from Git, workspace, or tenant labels.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Deployment receipts and checkpoints
|
|
2
|
+
|
|
3
|
+
Agent Sam's Merkle tree answers a source identity question: **what exact file tree exists right now?**
|
|
4
|
+
|
|
5
|
+
The deploy-receipt lifecycle adds a second question: **what changed since the last state we trusted?**
|
|
6
|
+
|
|
7
|
+
The runtime checkpoint belongs under `.agentsam/deploy-merkle/` by default and is deliberately excluded from the captured source tree. It is cache/checkpoint state, not application source. Committing it would make deployment bookkeeping mutate Git and feed back into the next hash.
|
|
8
|
+
|
|
9
|
+
## CLI
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
agentsam deploy-receipt capture . --project my-app --json
|
|
13
|
+
# run any deployment provider here
|
|
14
|
+
agentsam deploy-receipt success . --deployment-id dep_123 --worker-version worker_v1 --json
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
If deployment fails:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
agentsam deploy-receipt failure . --deployment-id dep_123 --json
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
A successful finalize promotes `latest.snapshot.json` and `latest.receipt.json`. A failed finalize writes failure history but does **not** advance the trusted baseline.
|
|
24
|
+
|
|
25
|
+
An external durable snapshot (R2, S3, GCS, artifact store, etc.) can be restored before capture and supplied explicitly:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
agentsam deploy-receipt capture . \
|
|
29
|
+
--baseline /tmp/last-success.snapshot.json \
|
|
30
|
+
--baseline-source r2 \
|
|
31
|
+
--project my-app \
|
|
32
|
+
--json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Provider storage stays an adapter. The Merkle tree, diff, receipt contract, local checkpoint state, Git metadata, dirty-tree observation, and success/failure promotion semantics live in the SDK.
|
|
36
|
+
|
|
37
|
+
## Programmatic API
|
|
38
|
+
|
|
39
|
+
```js
|
|
40
|
+
import {
|
|
41
|
+
captureDeployReceipt,
|
|
42
|
+
finalizeDeployReceipt,
|
|
43
|
+
} from '@inneranimalmedia/agentsam-sdk/deploy-receipt';
|
|
44
|
+
|
|
45
|
+
const capture = await captureDeployReceipt({
|
|
46
|
+
root: process.cwd(),
|
|
47
|
+
project: 'my-app',
|
|
48
|
+
baselineSnapshot: restoredSnapshotPath,
|
|
49
|
+
baselineSource: 'r2',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
try {
|
|
53
|
+
const deployment = await deploy();
|
|
54
|
+
const completed = await finalizeDeployReceipt({
|
|
55
|
+
root: process.cwd(),
|
|
56
|
+
status: 'success',
|
|
57
|
+
deploymentId: deployment.id,
|
|
58
|
+
workerVersionId: deployment.versionId,
|
|
59
|
+
});
|
|
60
|
+
await persistSnapshotAndReceipt(completed);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
await finalizeDeployReceipt({
|
|
63
|
+
root: process.cwd(),
|
|
64
|
+
status: 'failed',
|
|
65
|
+
});
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The same primitive is exported as `captureCheckpoint()` / `promoteCheckpoint()` for long-running agent work. That enables a loop to checkpoint a trusted tree, execute a batch, inspect the exact Merkle delta, run verification, and only promote the new checkpoint when the batch is accepted.
|
|
71
|
+
|
|
72
|
+
## Receipt shape
|
|
73
|
+
|
|
74
|
+
A capture includes compact metadata such as:
|
|
75
|
+
|
|
76
|
+
- Git SHA, branch, repository remote, and dirty-tree state
|
|
77
|
+
- current Merkle root and previous trusted root
|
|
78
|
+
- added / modified / removed counts
|
|
79
|
+
- exact changed paths (capped for receipt size)
|
|
80
|
+
- file / directory / byte statistics
|
|
81
|
+
- baseline provenance
|
|
82
|
+
|
|
83
|
+
Full file trees remain Merkle snapshots. Deployment ledgers should store the compact receipt metadata rather than the complete manifest.
|
package/docs/RECON.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Recon: bounded-worker harness (aka "MiniCodeScout")
|
|
2
|
+
|
|
3
|
+
A cheap or local model (Ollama/Qwen-class, a mini-tier hosted model, whatever's
|
|
4
|
+
cheapest that week) can be useful as a **reconnaissance subagent** — but only once
|
|
5
|
+
the evidence handed to it is already disambiguated. Live investigation on the
|
|
6
|
+
`feat/workflow-runtime-v2` worktree found the actual failure mode wasn't missing
|
|
7
|
+
ceilings, it was mixed-signal evidence: a flat `rg 'workspace_id'` sweep conflates
|
|
8
|
+
a JS member access (`authUser?.workspace_id`), an object key (`workspace_id: ctx.workspaceId`),
|
|
9
|
+
and a SQL template literal (`` `AND workspace_id = ?` ``) into one undifferentiated
|
|
10
|
+
hit list. That's why a Qwen-class mini guessed — not because it lacked a schema.
|
|
11
|
+
|
|
12
|
+
**Current status:** the mini-worker step is benched for this sprint (decision:
|
|
13
|
+
`workflows-v2:ollama-benched`; follow-up tracked as backlog P3). Deterministic
|
|
14
|
+
search alone (`rg` and `ast-grep`, both installed on the primary dev machine) is
|
|
15
|
+
already answering the questions that matter, faster and for free. This kit ships
|
|
16
|
+
as reusable infra ahead of need — it isn't on the critical path for Workflows v2,
|
|
17
|
+
and nothing here should be read as "go delegate to Ollama now." `ast-grep` stays
|
|
18
|
+
recon-only: no `sgconfig.yml`, no `--fix`/`--update-all`/`--interactive` on target
|
|
19
|
+
files until well after v2 lands — those are what turn it from search into a write
|
|
20
|
+
action.
|
|
21
|
+
|
|
22
|
+
## Where recon actually starts
|
|
23
|
+
|
|
24
|
+
Recon is the last two stages of a longer pipeline, not the whole thing:
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
lexical search (rg) "where is this text?" — do this first, always
|
|
28
|
+
|
|
|
29
|
+
structural search (ast-grep)
|
|
30
|
+
| "where is this shape, and which kind?"
|
|
31
|
+
v
|
|
32
|
+
raw hits: {path, line, kind?}
|
|
33
|
+
|
|
|
34
|
+
v
|
|
35
|
+
agentsam_sdk.repository.recon.from_matches(...)
|
|
36
|
+
| groups by file, windows context lines,
|
|
37
|
+
| chunks into packets of <=5 files each
|
|
38
|
+
v
|
|
39
|
+
ReconTaskPacket(s) (protocol/recon/task-packet.schema.json)
|
|
40
|
+
|
|
|
41
|
+
v
|
|
42
|
+
mini worker (only if/when actually delegated -- never given rg)
|
|
43
|
+
|
|
|
44
|
+
v
|
|
45
|
+
ReconFindingReport (protocol/recon/finding-report.schema.json)
|
|
46
|
+
|
|
|
47
|
+
v
|
|
48
|
+
agentsam_sdk.repository.recon.validate_report(...)
|
|
49
|
+
|
|
|
50
|
+
v
|
|
51
|
+
capable agent (verifies, edits, git, tests, PR)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Hand-picked slices still work too — `build_task_packet()` takes an explicit slice
|
|
55
|
+
list directly when you already know exactly which 5 files matter and don't have a
|
|
56
|
+
raw hit list to chunk.
|
|
57
|
+
|
|
58
|
+
## Rules the worker operates under
|
|
59
|
+
|
|
60
|
+
- **One question, not a subsystem audit.** "Does this file still read
|
|
61
|
+
`workspace_id`?" — not "audit the workflow runtime."
|
|
62
|
+
- **≤5 file slices per packet, supplied — never discovered.** The worker doesn't
|
|
63
|
+
run its own `rg`/`ast-grep`/`find`/`ls`; the controller already ran search and
|
|
64
|
+
chunked the results before the worker ever sees anything. "Do not give Qwen rg."
|
|
65
|
+
- **≤2 follow-up reads**, each still inside the packet's ceilings.
|
|
66
|
+
- **Read-only diagnostics only**, and only ones the controller pre-approved
|
|
67
|
+
(`allowed_diagnostics` in the packet) — `git status`/`diff`/`log`/`show`, a
|
|
68
|
+
syntax check, a single named test. Never `git add|commit|reset|push`, never a
|
|
69
|
+
migration, never a full build or deploy, never `ast-grep --fix`/`sg --update-all`
|
|
70
|
+
on the target files.
|
|
71
|
+
- **No branch ownership.** The worker's only output is a `ReconFindingReport`. It
|
|
72
|
+
never calls `write_file` against the repository.
|
|
73
|
+
- **Never guess.** If the supplied slices don't answer the question, the worker
|
|
74
|
+
returns `status: "needs_context"` with `reason` and `missing` — not a
|
|
75
|
+
fabricated finding. `validate_report` rejects any `answered` report that cites
|
|
76
|
+
a file outside the packet's slices, so a worker can't paper over a gap with
|
|
77
|
+
invented evidence either.
|
|
78
|
+
- **A slice's `kind` (when present) is a controller-verified structural label,
|
|
79
|
+
not a hint the worker should second-guess.** `sql_string` and `member` are not
|
|
80
|
+
the same finding even when the literal text matches.
|
|
81
|
+
|
|
82
|
+
## Where each half lives
|
|
83
|
+
|
|
84
|
+
| Half | Module | Notes |
|
|
85
|
+
| --- | --- | --- |
|
|
86
|
+
| rg adapter | `agentsam_sdk.repository.recon.from_ripgrep` | Parses `rg --json` NDJSON into hits. No `kind` — lexical only. Runs no search itself. |
|
|
87
|
+
| ast-grep adapter | `agentsam_sdk.repository.recon.from_ast_grep` | Parses `sg`/`ast-grep --json=compact` array output into hits, tagged with a caller-supplied `kind` (one invocation = one shape). Runs no search itself. |
|
|
88
|
+
| Chunker | `agentsam_sdk.repository.recon.from_matches` | Takes hits from either adapter (or hand-built), groups by file, windows context lines, chunks anything over 5 files into multiple packets. |
|
|
89
|
+
| Controller (hand-picked packets) | `agentsam_sdk.repository.recon.build_task_packet` | For when you already know the exact ≤5 files/lines — no hit list to chunk. |
|
|
90
|
+
| Validator (gate reports) | `agentsam_sdk.repository.recon.validate_report` | Structural check + the "never guess" rule + citation check (findings can't reference files the worker was never given). Raises `ReportError`; callers must discard, not patch, a rejected report. |
|
|
91
|
+
| Contracts | `protocol/recon/task-packet.schema.json`, `protocol/recon/finding-report.schema.json` | Provider-neutral; usable from the CLI, the MCP surface, or a Worker. |
|
|
92
|
+
| CLI | `agentsam recon pack \| validate` (Node, thin passthrough) or `python -m agentsam_sdk.repository.recon pack \| validate` | Hand-picked slices only. Same `ToolInput`/`ToolResult` contract as every other `agentsam_sdk` tool on the Python side — read-only by default, gets a receipt. |
|
|
93
|
+
|
|
94
|
+
This kit intentionally stops at the report. Model orchestration — which model
|
|
95
|
+
answers a packet, retries, cost routing, whether delegation happens at all — is
|
|
96
|
+
host policy, same as the rest of the SDK's "host integration and ownership"
|
|
97
|
+
boundary in the root README. A future `bounded-mutation` contract (a worker
|
|
98
|
+
allowed to perform one specific, proven-safe transform, e.g. "rename import path
|
|
99
|
+
A → B") is a separate, narrower protocol, not an extension of recon's read-only
|
|
100
|
+
contract. `ast-grep` structural classification (splitting hits by node kind) is a
|
|
101
|
+
separate layer with its own hard rule — recon only, never `sgconfig.yml`/`--fix`
|
|
102
|
+
on target files — and `from_ast_grep()`/`from_matches()` carry its `kind` labels
|
|
103
|
+
through into packets without needing a schema change.
|
|
104
|
+
|
|
105
|
+
## Example
|
|
106
|
+
|
|
107
|
+
`from_ripgrep()` and `from_ast_grep()` parse the two tools' real output shapes directly
|
|
108
|
+
-- no hand-rolled JSON parsing needed. `from_ast_grep()` takes a `kind` label because one
|
|
109
|
+
`sg`/`ast-grep` invocation is one pattern or rule, i.e. one structural shape; `from_ripgrep()`
|
|
110
|
+
never sets `kind` since lexical hits carry no structural classification on their own.
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import subprocess
|
|
114
|
+
from agentsam_sdk.repository import recon
|
|
115
|
+
|
|
116
|
+
def run(*args):
|
|
117
|
+
return subprocess.run(args, capture_output=True, text=True).stdout
|
|
118
|
+
|
|
119
|
+
matches = []
|
|
120
|
+
matches += recon.from_ast_grep(
|
|
121
|
+
run("sg", "-p", "$X.workspace_id", "-l", "js", "--json=compact",
|
|
122
|
+
"backend/workflows", "backend/http/workflows"),
|
|
123
|
+
kind="member",
|
|
124
|
+
)
|
|
125
|
+
matches += recon.from_ast_grep(
|
|
126
|
+
run("sg", "-p", "$X.workspaceId", "-l", "js", "--json=compact",
|
|
127
|
+
"backend/workflows", "backend/http/workflows"),
|
|
128
|
+
kind="member_camel",
|
|
129
|
+
)
|
|
130
|
+
matches += recon.from_ast_grep(
|
|
131
|
+
run("sg", "scan", "--inline-rules",
|
|
132
|
+
"id: sql-ws\nlanguage: JavaScript\nrule:\n kind: template_string\n regex: workspace_id",
|
|
133
|
+
"backend/workflows", "backend/http/workflows", "--json=compact"),
|
|
134
|
+
kind="sql_string",
|
|
135
|
+
)
|
|
136
|
+
|
|
137
|
+
packets = recon.from_matches(
|
|
138
|
+
".",
|
|
139
|
+
question="Does this file still depend on removed workspace-scoped columns?",
|
|
140
|
+
matches=matches,
|
|
141
|
+
task_id_prefix="workflow-v2-runtime-audit",
|
|
142
|
+
)
|
|
143
|
+
# classified hits across N files -> packets of <=5 files each, ready to hand to a
|
|
144
|
+
# capable model for direct classification, or to a delegated worker later. Files
|
|
145
|
+
# with more than one kind in their hit set come back with slice.kind omitted --
|
|
146
|
+
# genuinely mixed evidence is a real signal, not something to flatten.
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Also usable from the shell directly for hand-picked slices, no Python needed:
|
|
150
|
+
|
|
151
|
+
```sh
|
|
152
|
+
agentsam recon pack --repo-root . --question "..." \
|
|
153
|
+
--slice backend/workflows/repository.js:1-180 --out /tmp/packet.json
|
|
154
|
+
agentsam recon validate --packet /tmp/packet.json --report /tmp/report.json
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`agentsam recon` is a thin passthrough to the same Python module (`python -m
|
|
158
|
+
agentsam_sdk.repository.recon`), for hand-picked slices only -- `from_matches`,
|
|
159
|
+
`from_ripgrep`, and `from_ast_grep` are Python-only since raw hit shapes vary by tool
|
|
160
|
+
and don't have a stable CLI surface yet.
|
|
161
|
+
|
|
162
|
+
See [`REPOSITORY_INTELLIGENCE.md`](REPOSITORY_INTELLIGENCE.md) for the git-level
|
|
163
|
+
evidence layer (hotspots/churn) that can help decide *which* files to search in
|
|
164
|
+
the first place, and [`protocol/README.md`](../protocol/README.md) (rule 6) for
|
|
165
|
+
the read-only, no-hardcoded-identity law this module follows.
|
package/docs/RELEASES.md
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# `@inneranimalmedia/agentsam-sdk` release receipts
|
|
2
2
|
|
|
3
|
-
**2.
|
|
4
|
-
|
|
5
|
-
publish the private identity workspace or create a `v2.0.0` release tag.
|
|
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.
|
|
6
5
|
|
|
7
6
|
| npm version | Published (UTC) | IAM git SHA (40) | Notes |
|
|
8
7
|
|-------------|-----------------|------------------|-------|
|
|
8
|
+
| 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
|
+
| 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. |
|
|
9
10
|
| 2.0.0-alpha.identity.5 | _(pending npm)_ | `df064114eb7f8888f163e4a07dfddf19035b7169` | Password reset service, `registerFinalizeInboundOAuth`, IAM live proof. |
|
|
10
11
|
| 2.0.0-alpha.identity.4 | 2026-08-22 | `df064114eb7f8888f163e4a07dfddf19035b7169` | IAM auth portal sync: signup→`/api/auth/signup`, `company-branding.js`, preview stubs. SDK git `d7498ca`. |
|
|
11
12
|
| 2.0.0-alpha.identity.3 | 2026-08-22 | `559bc37267f76790136004f5fa94a2bb3cd6a721` | `company` table + `GET/PATCH /api/company` branding SSOT. |
|
|
@@ -12,7 +12,7 @@ agentsam search "snapshot integrity"
|
|
|
12
12
|
agentsam index show
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
Bare `agentsam init` detects an existing Git repository and offers a setup wizard. `agentsam init --name new-project` retains the scaffold workflow. Setup creates `.agentsam/knowledge.json` exclusively and preserves existing source/configuration. The config's `repository_id` is generated once
|
|
15
|
+
Bare `agentsam init` detects an existing Git repository and offers a setup wizard. `agentsam init --name new-project` retains the scaffold workflow. Setup creates `.agentsam/knowledge.json` exclusively and preserves existing source/configuration. The config's `repository_id` is generated once and is the portable knowledge identity. New configs do not require or create a workspace identifier. Legacy configs that already contain `workspace_id` remain readable and retain their previous cache/generation namespace for compatibility. Commit this non-secret config to share identity across checkouts. Use a distinct repository ID when the same source must represent a different repository corpus.
|
|
16
16
|
|
|
17
17
|
Scope entries are literal relative files/directories, comma-separated on the CLI, not glob expressions. Supported AST languages are JS/JSX/TS/TSX including `.mjs`, `.cjs`, `.mts`, `.cts`; Markdown/MDX, SQL and JSON are bounded text chunks, not AST parsers. Imports, re-exports and call expressions are syntactic observations marked `resolved: false`, not a type-resolved cross-file call graph. Syntax errors abort publication.
|
|
18
18
|
|
|
@@ -36,7 +36,7 @@ Limits count unique uncached inputs and content characters, not total billable a
|
|
|
36
36
|
## Incremental and history guarantees
|
|
37
37
|
|
|
38
38
|
- Structural parse cache keys include source content, language, parser version and chunking policy.
|
|
39
|
-
- Vector keys include
|
|
39
|
+
- Vector keys include the repository namespace, model, revision, dimensions, parameters, input-format version and actual chunk content. Legacy configs with `workspace_id` preserve their prior workspace-qualified namespace so existing cached vectors remain readable. Paths/commit IDs are retrieval metadata, so a pure move reuses vectors.
|
|
40
40
|
- Scope expansion rechecks the complete selected inventory. Named scopes have separate active generations. Different customers/repositories do not share caches.
|
|
41
41
|
- An unchanged run performs zero embedding requests. An edit embeds only changed chunks; changing the profile creates a separate embedding space.
|
|
42
42
|
- A run stages completed cache work, rechecks source hashes, then atomically publishes a generation with compare-and-swap protection. Provider failure, invalid dimensions, concurrent publication or mid-run source edits leave the previous active generation intact.
|
|
@@ -59,14 +59,14 @@ This wraps the existing bundled Python repository-intelligence module (Python 3.
|
|
|
59
59
|
## Backend Postgres / Supabase
|
|
60
60
|
|
|
61
61
|
```sh
|
|
62
|
-
agentsam init . --yes --include backend/feature --target production
|
|
62
|
+
agentsam init . --yes --include backend/feature --target production
|
|
63
63
|
# Supply AGENTSAM_DATABASE_URL through a secret manager.
|
|
64
64
|
agentsam index setup-store
|
|
65
65
|
agentsam index plan
|
|
66
66
|
agentsam index run
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
Production selects the storage destination; execution still runs from this checkout. Review [`postgres.sql`](../src/knowledge/stores/postgres.sql) before `setup-store`, which explicitly applies it to the configured database. Init/plan/search never migrate a database. Use a dedicated backend connection with TLS appropriate to your environment. The private `agentsam_knowledge` schema is not intended for browser access or Supabase's exposed REST schemas; tenant authorization belongs in the host.
|
|
69
|
+
Production selects the storage destination; execution still runs from this checkout. Review [`postgres.sql`](../src/knowledge/stores/postgres.sql) before `setup-store`, which explicitly applies it to the configured database. Init/plan/search never migrate a database. Use a dedicated backend connection with TLS appropriate to your environment. The private `agentsam_knowledge` schema is not intended for browser access or Supabase's exposed REST schemas; account/tenant authorization belongs in the host. Repository ID plus named scope isolates portable knowledge generations; it is resource identity, not actor authentication.
|
|
70
70
|
|
|
71
71
|
SQLite stores cache entries plus immutable generation/observation payloads locally under `.agentsam/knowledge/`, excluded from Git. Postgres stores the same versioned facts in JSONB and embeddings in native pgvector, with exact cosine ranking restricted to the selected generation's vector keys. This first slice uses exact search, not an ANN index; large indexes need per-profile partitions/indexes and benchmarks. The unconstrained vector column permits multiple dimensional profiles, but queries never mix them. Retention/garbage collection is intentionally absent so initial history is preserved; configure a retention policy before large production backfills.
|
|
72
72
|
|
package/docs/sdk-2.0-release.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# AgentSam SDK 2.0.0 release
|
|
2
2
|
|
|
3
|
-
Status:
|
|
3
|
+
Status: published to npm as `@inneranimalmedia/agentsam-sdk@2.0.0`; npm `latest` points to 2.0.0.
|
|
4
4
|
|
|
5
5
|
## Product boundaries
|
|
6
6
|
|
|
@@ -32,8 +32,8 @@ automatic retention, multi-user authorization and production routing remain host
|
|
|
32
32
|
|
|
33
33
|
## Changes from 1.9 and the identity alphas
|
|
34
34
|
|
|
35
|
-
-
|
|
36
|
-
2.0.0-alpha.identity.12
|
|
35
|
+
- npm `latest` advanced from 1.9.0 to 2.0.0. The alpha tag remains
|
|
36
|
+
2.0.0-alpha.identity.12 for the final identity prerelease line.
|
|
37
37
|
- Node 22.5+ is required. Python 3.10+ is required for Python repository intelligence;
|
|
38
38
|
Docker is required only when actually building/running containers.
|
|
39
39
|
- In an existing repository, `agentsam init` configures repository knowledge. Use
|
|
@@ -43,36 +43,34 @@ automatic retention, multi-user authorization and production routing remain host
|
|
|
43
43
|
- Knowledge and Docker features from PRs #20 and #21 are integrated in main.
|
|
44
44
|
- Publication runs the installed-tarball consumer proof, Python tests, and dependency scan
|
|
45
45
|
in addition to the existing SDK, identity, bootstrap and package checks.
|
|
46
|
-
- The legacy alpha workflow refuses stable versions. Stable npm publication
|
|
46
|
+
- The legacy alpha workflow refuses stable versions. Stable npm publication remains manual.
|
|
47
47
|
|
|
48
|
-
##
|
|
48
|
+
## Publication receipt
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
bash scripts/npm-publish-preflight.sh
|
|
56
|
-
npm publish --tag latest --access public
|
|
50
|
+
Version 2.0.0 was published on 2026-09-03 at `2026-09-03T02:21:44.857Z` from SDK git SHA
|
|
51
|
+
`ed629869e701809d2bf4c61bd56d05d8d8d1e183`. npm recorded this integrity value:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
sha512-lXnBp8GR1iduKWxxHSRHSd9Q1fjTUZvX1UecwtS8xdDxMdZRd2BSHtDygm0OMNYchrtUP1nR6g0t3MqZTkE5HA==
|
|
57
55
|
```
|
|
58
56
|
|
|
59
|
-
The `prepublishOnly` hook
|
|
60
|
-
identity suites, package/bootstrap checks, installed-tarball fixtures, Python
|
|
61
|
-
complete dependency scan. The
|
|
62
|
-
|
|
63
|
-
with `--workspaces`: identity and shell-kit workspaces remain private.
|
|
57
|
+
The `prepublishOnly` hook ran `npm run verify:release` before upload. That verification ran
|
|
58
|
+
the SDK and identity suites, package/bootstrap checks, installed-tarball fixtures, Python
|
|
59
|
+
tests and the complete dependency scan. The private identity and shell-kit workspaces were
|
|
60
|
+
not published separately.
|
|
64
61
|
|
|
65
|
-
|
|
62
|
+
Verify the live registry state with:
|
|
66
63
|
|
|
67
64
|
```sh
|
|
68
|
-
npm view @inneranimalmedia/agentsam-sdk@2.0.0 version dist.integrity
|
|
65
|
+
npm view @inneranimalmedia/agentsam-sdk@2.0.0 version gitHead dist.integrity
|
|
69
66
|
npm view @inneranimalmedia/agentsam-sdk dist-tags --json
|
|
70
67
|
npm install -g @inneranimalmedia/agentsam-sdk@2.0.0
|
|
71
68
|
agentsam --version
|
|
72
69
|
```
|
|
73
70
|
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
The publication receipt is recorded in `docs/RELEASES.md`. Git tag `v2.0.0` identifies the
|
|
72
|
+
exact npm `gitHead`. A published npm name/version cannot be overwritten; subsequent package
|
|
73
|
+
changes require a new version.
|
|
76
74
|
|
|
77
75
|
## Branch consolidation
|
|
78
76
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inneranimalmedia/agentsam-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Portable AgentSam SDK and CLI kits for local scaffolding, repository intelligence, incremental indexing, identity adapters, and verified dependency maintenance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -12,8 +12,15 @@
|
|
|
12
12
|
"./dockerize": "./src/lib/dockerize.js",
|
|
13
13
|
"./mini": "./src/lib/mini/index.js",
|
|
14
14
|
"./merkle": "./src/lib/merkle/index.js",
|
|
15
|
+
"./deploy-receipt": "./src/lib/deploy-receipt/index.js",
|
|
15
16
|
"./knowledge": "./src/knowledge/index.js",
|
|
16
17
|
"./knowledge-service-client": "./src/knowledge/service/client.js",
|
|
18
|
+
"./capabilities": "./src/capabilities/index.js",
|
|
19
|
+
"./capability-manifest": "./protocol/capabilities/manifest.json",
|
|
20
|
+
"./repository": "./src/repository/index.js",
|
|
21
|
+
"./agent": "./src/agent/index.js",
|
|
22
|
+
"./presets": "./src/presets/index.js",
|
|
23
|
+
"./preset-catalog": "./protocol/presets/catalog.json",
|
|
17
24
|
"./identity": "./packages/identity/src/index.js",
|
|
18
25
|
"./identity/providers": "./packages/identity/src/providers/index.js",
|
|
19
26
|
"./identity/providers/google": "./packages/identity/src/providers/google/index.js",
|
|
@@ -11,7 +11,7 @@ Pages copied **verbatim** from IAM `static/pages/auth/*` — reorganize only.
|
|
|
11
11
|
| Colors | `:root { --auth-bg, ... }` | theme tokens — **no JS changes** |
|
|
12
12
|
| OAuth labels | button text | HTML only |
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
The CLI can now scaffold the reusable identity app surfaces directly with `agentsam identity init --name <project> --brand "App Name"`. This copies the portal, Worker adapter, and migrations into a standalone app layout. Use `portal.brand` at `createIdentityClient` init for programmatic configuration, or `agentsam identity preview` for the local preview server.
|
|
15
15
|
|
|
16
16
|
## Source map
|
|
17
17
|
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
listIdentityProviders,
|
|
18
18
|
GoogleProvider,
|
|
19
19
|
GithubProvider,
|
|
20
|
+
IamProvider,
|
|
20
21
|
GcpProvider,
|
|
21
22
|
EmailProvider,
|
|
22
23
|
} from './providers/index.js';
|
|
@@ -34,6 +35,7 @@ export {
|
|
|
34
35
|
listIdentityProviders,
|
|
35
36
|
GoogleProvider,
|
|
36
37
|
GithubProvider,
|
|
38
|
+
IamProvider,
|
|
37
39
|
GcpProvider,
|
|
38
40
|
EmailProvider,
|
|
39
41
|
};
|