@inneranimalmedia/agentsam-sdk 2.6.3 → 2.6.4
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/AGENTSAM.md +6 -0
- package/README.md +16 -1
- package/bin/agentsam +16 -1
- package/docs/BRAND_INTELLIGENCE.md +1 -1
- package/docs/architecture/AGENTSAM_DISTRIBUTION_OWNERSHIP.md +176 -0
- package/docs/architecture/AGENTSAM_GO_RUNTIME.md +282 -0
- package/docs/architecture/CODEBASEINDEX_GUIDED_PATH.md +202 -0
- package/docs/architecture/FS_E2E_CLOSURE_RECEIPT.md +59 -0
- package/docs/architecture/LOCAL_FS_AUTHORITY.md +38 -0
- package/docs/architecture/LOCAL_STUDIO_CLOUDFLARE_OAUTH.md +28 -0
- package/docs/architecture/PLAN_CLI_AND_LOCAL_STUDIO_DESKTOP.md +96 -0
- package/docs/architecture/SAM_ACTIVITY_RECOVERY_RECEIPT.md +39 -0
- package/docs/architecture/SAM_DECISION_WORK_RECEIPT.md +54 -0
- package/docs/architecture/SAM_KERNEL.md +181 -0
- package/docs/architecture/SAM_MACHINE_NORMALIZATION_PRECOMMIT_REPORT.md +208 -0
- package/docs/architecture/SLASH_SKILLS_PORTABLE.md +116 -0
- package/docs/architecture/fs-e2e-receipt.latest.json +42 -0
- package/docs/architecture/previews/codebaseindex-guided-path/CODEBASEINDEX_GUIDED_PATH.md +202 -0
- package/docs/architecture/previews/codebaseindex-guided-path/index.html +321 -0
- package/migrations/d1/0010_portable_tickets_memory.sql +140 -0
- package/migrations/d1/0011_agentsam_skill_v2.sql +185 -0
- package/migrations/d1/0011b_agentsam_skill_v2_cutover.sql +22 -0
- package/migrations/d1/0011c_agentsam_skill_v2_backfill.sql +76 -0
- package/migrations/d1/0011d_agentsam_skill_v2_retrieval_revisions.sql +50 -0
- package/migrations/d1/0012_agentsam_tools_required_seed.sql +67 -0
- package/migrations/d1/0013_identity_oauth_states.sql +15 -0
- package/migrations/d1/0014_auth_event_log.sql +20 -0
- package/migrations/d1/0015_identity_oauth_state_app_id.sql +3 -0
- package/migrations/d1/README_PORTABLE_CONTROL_PLANE.md +16 -0
- package/migrations/sqlite/agentsam_skill_retrieval.portable.sql +42 -0
- package/package.json +19 -4
- package/packages/agentsam-contracts/src/errors.ts +16 -0
- package/packages/agentsam-errors/src/envelope.js +53 -0
- package/packages/agentsam-errors/src/index.js +1 -0
- package/packages/agentsam-errors/src/recovery.js +301 -0
- package/packages/agentsam-knowledge/src/providers/index.js +18 -6
- package/packages/connectors/cloudflare/src/routes.js +9 -0
- package/packages/connectors/cloudflare/tests/connector.test.mjs +26 -1
- package/packages/identity/.agentsam/features/oauth-login-portal/agentsam.feature.json +1 -1
- package/packages/identity/.agentsam/features/oauth-login-portal/routes.json +11 -2
- package/packages/identity/docs/PORTABLE_IDENTITY_ARCHITECTURE.md +50 -0
- package/packages/identity/migrations/D1_SCHEMA_MAPPING.md +31 -0
- package/packages/identity/migrations/sqlite/001_identity_core.sql +99 -0
- package/packages/identity/migrations/sqlite/002_identity_oauth_client.sql +38 -0
- package/packages/identity/migrations/sqlite/003_identity_oauth_server.sql +64 -0
- package/packages/identity/package.json +2 -2
- package/packages/identity/src/adapters/cloudflare-d1/index.js +122 -22
- package/packages/identity/src/adapters/sqlite/index.js +319 -0
- package/packages/identity/src/app/verify-app.js +95 -0
- package/packages/identity/src/contracts/identity-store.js +115 -0
- package/packages/identity/src/contracts/route-ids.js +30 -0
- package/packages/identity/src/contracts/route-projection.js +218 -0
- package/packages/identity/src/contracts/routes.js +11 -0
- package/packages/identity/src/core/browser-paths.js +4 -5
- package/packages/identity/src/core/constants.js +13 -8
- package/packages/identity/src/core/session-policy.js +32 -0
- package/packages/identity/src/frontend/auth-portal/pages/login.html +10 -10
- package/packages/identity/src/frontend/auth-portal/pages/reset.html +3 -3
- package/packages/identity/src/frontend/auth-portal/pages/signup.html +3 -3
- package/packages/identity/src/frontend/auth-portal/preview/dashboard-stub.html +1 -1
- package/packages/identity/src/index.js +25 -0
- package/packages/identity/src/oauth/README.md +10 -4
- package/packages/identity/src/oauth/credentials.js +20 -13
- package/packages/identity/src/oauth/finalize-inbound.js +1 -1
- package/packages/identity/src/oauth/iam-platform.js +8 -7
- package/packages/identity/src/oauth/redirect-paths.js +27 -36
- package/packages/identity/src/server/identity-service.js +30 -13
- package/packages/identity/src/server/mount-policy.js +30 -0
- package/packages/identity/src/server/post-auth.js +79 -0
- package/packages/identity/src/server/worker-router.js +104 -72
- package/packages/identity/tests/finalize-inbound-oauth.test.mjs +6 -6
- package/packages/identity/tests/iam-provider.test.mjs +1 -1
- package/packages/identity/tests/identity-service.test.mjs +36 -5
- package/packages/identity/tests/oauth-credentials.test.mjs +3 -1
- package/packages/identity/tests/portable-identity-architecture.test.mjs +157 -0
- package/packages/identity/tests/session-routes-policy.test.mjs +21 -0
- package/packages/theme-church-site/package.json +2 -1
- package/packages/theme-church-site/src/index.js +1 -0
- package/packages/theme-companions-site/package.json +2 -1
- package/packages/theme-companions-site/src/index.js +1 -0
- package/packages/theme-floors-site/package.json +2 -1
- package/packages/theme-floors-site/src/index.js +1 -0
- package/packages/theme-fuelnfree-site/package.json +2 -1
- package/packages/theme-fuelnfree-site/src/index.js +1 -0
- package/packages/theme-handyman-site/package.json +2 -1
- package/packages/theme-handyman-site/src/index.js +1 -0
- package/packages/theme-insurance-site/package.json +2 -1
- package/packages/theme-insurance-site/src/index.js +1 -0
- package/packages/theme-shinshu-site/package.json +2 -1
- package/packages/theme-shinshu-site/src/index.js +1 -0
- package/protocol/apps/agentsam.app.v1.schema.json +51 -0
- package/protocol/brand/brandpack.v1.schema.json +43 -0
- package/protocol/credentials/issue.v1.schema.json +38 -0
- package/protocol/database/connection.v1.schema.json +41 -0
- package/protocol/embeddings/embedding-profile.v1.schema.json +20 -0
- package/protocol/errors/error-envelope.schema.json +135 -1
- package/protocol/errors/recovery.v1.schema.json +50 -0
- package/protocol/runtime/workspace-fs.v1.schema.json +71 -0
- package/protocol/sam/activity.v1.schema.json +48 -0
- package/protocol/sam/answer.v1.schema.json +35 -0
- package/protocol/sam/calibration.v1.schema.json +21 -0
- package/protocol/sam/decision-receipt.v1.schema.json +29 -0
- package/protocol/sam/evaluation.v1.schema.json +19 -0
- package/protocol/sam/operation.schema.json +66 -0
- package/protocol/sam/outcome.v1.schema.json +36 -0
- package/protocol/sam/question.v1.schema.json +26 -0
- package/protocol/sam/registry.seed.json +153 -0
- package/protocol/sam/result.schema.json +53 -0
- package/protocol/sam/state.v1.schema.json +23 -0
- package/protocol/skills/agentsam.interaction.v1.schema.json +50 -0
- package/protocol/skills/agentsam.skill.v1.schema.json +57 -0
- package/protocol/ui/icon-registry.mjs +226 -0
- package/protocol/ui/icon.v1.schema.json +51 -0
- package/skills/README.md +22 -9
- package/skills/agentsam-codebaseindex/SKILL.md +225 -0
- package/skills/catalog.json +14 -0
- package/src/cli/command-catalog.js +130 -0
- package/src/cli/dispatch.js +48 -0
- package/src/cli.js +43 -1
- package/src/commands/api-key.js +244 -0
- package/src/commands/app.js +60 -28
- package/src/commands/brand.js +17 -19
- package/src/commands/codebaseindex.js +688 -0
- package/src/commands/env.js +152 -25
- package/src/commands/go.js +366 -53
- package/src/commands/interaction-clack.js +115 -0
- package/src/commands/models.js +1 -1
- package/src/commands/providers.js +62 -14
- package/src/commands/shell.js +43 -2
- package/src/commands/skill.js +248 -0
- package/src/commands/skills.js +1 -1
- package/src/commands/start-local.js +4 -0
- package/src/commands/whoami.js +90 -18
- package/src/go/build.js +229 -39
- package/src/go/cloudflare.js +506 -105
- package/src/go/container.js +120 -0
- package/src/go/contract.js +9 -4
- package/src/go/discover.js +149 -33
- package/src/go/index.js +15 -3
- package/src/go/native-probe-runner.mjs +119 -0
- package/src/go/{registry.js → official-registry.js} +64 -7
- package/src/go/official-release.js +10 -0
- package/src/go/receipts.js +77 -10
- package/src/go/verify.js +9 -2
- package/src/index.js +27 -0
- package/src/indexing/ingest/discover-models.js +298 -0
- package/src/indexing/ingest/inventory.js +243 -0
- package/src/indexing/ingest/job-graph.js +181 -0
- package/src/indexing/ingest/materials.js +210 -0
- package/src/lib/provider-credentials.js +63 -21
- package/src/lib/slash-commands.js +1 -0
- package/src/local-fs/capability.js +121 -0
- package/src/local-fs/freshness.js +75 -0
- package/src/local-fs/index.js +385 -0
- package/src/local-fs/paths.js +100 -0
- package/src/local-pty/server.js +295 -19
- package/src/mcp/client.js +2 -2
- package/src/models/ai-access-onboarding.js +112 -0
- package/src/models/discovery.js +10 -2
- package/src/models/inventory-core.js +9 -1
- package/src/sam/activity/index.js +183 -0
- package/src/sam/client.js +252 -0
- package/src/sam/decision/calibration.js +109 -0
- package/src/sam/decision/confidence.js +126 -0
- package/src/sam/decision/evaluate.js +157 -0
- package/src/sam/decision/evaluators/deterministic.js +341 -0
- package/src/sam/decision/evaluators/heuristic.js +61 -0
- package/src/sam/decision/evaluators/select.js +50 -0
- package/src/sam/decision/evaluators/semantic.js +149 -0
- package/src/sam/decision/hierarchical.js +61 -0
- package/src/sam/decision/index.js +53 -0
- package/src/sam/decision/policy.js +86 -0
- package/src/sam/decision/questions.js +120 -0
- package/src/sam/decision/receipt.js +148 -0
- package/src/sam/decision/state.js +117 -0
- package/src/sam/decision/types.js +22 -0
- package/src/sam/decision/validate.js +200 -0
- package/src/sam/define.js +51 -0
- package/src/sam/index.js +65 -0
- package/src/sam/operations/brand-scan.js +62 -0
- package/src/sam/operations/cad-blender-inspect.js +36 -0
- package/src/sam/operations/codebaseindex-ingest.js +49 -0
- package/src/sam/operations/decision-evaluate.js +59 -0
- package/src/sam/operations/planning-astar.js +77 -0
- package/src/sam/operations/planning-goap.js +60 -0
- package/src/sam/operations/repository-inspect.js +72 -0
- package/src/sam/operations/security-scan.js +33 -0
- package/src/sam/operations/terminal-exec.js +29 -0
- package/src/sam/planning/astar.js +311 -0
- package/src/sam/planning/goap.js +177 -0
- package/src/sam/planning/index.js +21 -0
- package/src/sam/planning/state.js +84 -0
- package/src/sam/registry.js +48 -0
- package/src/sam/result.js +77 -0
- package/src/sam/seed.js +44 -0
- package/src/sam/types.js +91 -0
- package/src/skills/catalog.js +64 -0
- package/src/skills/content-resolver.js +124 -0
- package/src/skills/hosted-store.js +37 -0
- package/src/skills/index.js +29 -64
- package/src/skills/interaction.js +102 -0
- package/src/skills/local-store.js +228 -0
- package/src/skills/manifest.js +104 -0
- package/src/skills/metrics.js +31 -0
- package/src/skills/registry.js +184 -0
- package/src/skills/runtime.js +287 -0
- package/src/skills/slash.js +44 -0
- package/src/ui/cli/help.js +94 -101
- package/test/cli/api-key-env-whoami.test.mjs +129 -0
- package/test/cli/codebaseindex-plan-ux.test.mjs +37 -0
- package/test/cli/go.test.mjs +62 -5
- package/test/cli/skill-npm-and-env.test.mjs +52 -0
- package/test/cli/wireframes-go-registry.test.mjs +87 -2
- package/test/go/build-source-identity.test.mjs +31 -0
- package/test/go/cloudflare-probe.test.mjs +274 -10
- package/test/go/distribution.test.mjs +28 -0
- package/test/integration/ai-access-onboarding.test.mjs +47 -0
- package/test/integration/cli-help.test.mjs +1 -1
- package/test/integration/cms-site-tenancy-contract.test.mjs +6 -6
- package/test/integration/codebaseindex-ingest.test.mjs +166 -0
- package/test/integration/icon-registry.test.mjs +67 -0
- package/test/integration/ingest-discover-models.test.mjs +30 -0
- package/test/integration/install-script.test.mjs +12 -9
- package/test/integration/local-fs.test.mjs +113 -0
- package/test/integration/provider-env-cli.test.mjs +2 -1
- package/test/integration/sam-activity-recovery.test.mjs +147 -0
- package/test/integration/sam-decision.test.mjs +584 -0
- package/test/integration/sam-kernel.test.mjs +99 -0
- package/test/integration/sam-planning-astar.test.mjs +279 -0
- package/test/integration/skill-runtime.test.mjs +240 -0
- package/test/integration/studio-fs-pty-e2e.test.mjs +294 -0
- package/test/models.test.mjs +14 -7
- package/test/shell.test.mjs +4 -4
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# Codebaseindex Guided Path — Template Lanes + Inventory-First UX
|
|
2
|
+
|
|
3
|
+
**Status:** PLAN · LOCKED intent (2026-09-25)
|
|
4
|
+
**Product:** AgentSam · pipeline `sam.codebaseindex.index.run` · operation `codebaseindex.ingest`
|
|
5
|
+
**Audience:** SDK CLI/TUI, Local Studio, future customer “bring your own vector lane” templates
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 1. Host SSOT today — Supabase tables (Gemini @ 1536)
|
|
10
|
+
|
|
11
|
+
Owner IAM path: **Gemini Embedding 2 → 1536-d → Supabase pgvector**, written via **node-api** edge (`POST /codebase/ingest`, vector RPCs). D1 owns control/structure; Postgres owns vectors.
|
|
12
|
+
|
|
13
|
+
### Live code-intelligence projections (`agentsam` schema)
|
|
14
|
+
|
|
15
|
+
| Table | Role |
|
|
16
|
+
|-------|------|
|
|
17
|
+
| `agentsam.agentsam_codebase_chunks_gemini_embedding_2_1536` | Chunk-level retrieval vectors (primary ANN for code Q&A) |
|
|
18
|
+
| `agentsam.agentsam_codebase_files_gemini_embedding_2_1536` | File-level vectors |
|
|
19
|
+
| `agentsam.agentsam_codebase_ast_symbols_gemini_embedding_2_1536` | Symbol ANN |
|
|
20
|
+
|
|
21
|
+
### Related semantic / twin tables (same embed family, different corpora)
|
|
22
|
+
|
|
23
|
+
| Table | Role |
|
|
24
|
+
|-------|------|
|
|
25
|
+
| `agentsam.agentsam_gemini_semantic_embeddings_1536` | Unified semantic authority (memory + code symbol projections by `corpus_type` / `record_kind`) |
|
|
26
|
+
| `agentsam.agentsam_documents_gemini_embedding_2_1536` | Document ingest twin (node-api `/vectors/ingest`) |
|
|
27
|
+
|
|
28
|
+
### Retired (do not write for new runs)
|
|
29
|
+
|
|
30
|
+
| Table | Note |
|
|
31
|
+
|-------|------|
|
|
32
|
+
| `agentsam.agentsam_codebase_*_oai3large_1536` | Legacy OpenAI code lanes |
|
|
33
|
+
|
|
34
|
+
### Control plane (D1 — not Supabase, but paired)
|
|
35
|
+
|
|
36
|
+
| Table | Role |
|
|
37
|
+
|-------|------|
|
|
38
|
+
| `code_repositories` | Account-owned repo identity |
|
|
39
|
+
| `agentsam_code_index_job` / `agentsam_code_index_job_file` | Run progress (`cidxrun_*`) |
|
|
40
|
+
| `codebase_ast_nodes` / `codebase_dep_edges` | Structural units + deps |
|
|
41
|
+
| `agentsam_pgvector_lane_registry` | Purpose → live PG table + model + dims |
|
|
42
|
+
| `agentsam_fs_merkle_snapshots` | Merkle evidence receipts |
|
|
43
|
+
| `agentsam_codebase_index_health` | Staleness / weekly health |
|
|
44
|
+
|
|
45
|
+
**I/O path (owner):** Worker / SDK → **node-api** (Deno edge) → Hyperdrive / session pooler → Supabase PG.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 2. End goal — templateable vector lanes
|
|
50
|
+
|
|
51
|
+
Owner setup is already live. Customers should get the **same harness**, parameterized:
|
|
52
|
+
|
|
53
|
+
```text
|
|
54
|
+
codebaseindex.ingest (guided)
|
|
55
|
+
│
|
|
56
|
+
┌───────────────┼───────────────┐
|
|
57
|
+
▼ ▼ ▼
|
|
58
|
+
local_exact supabase_pgvector cloudflare_vectorize
|
|
59
|
+
(SQLite) (+ node-api edge) (CF binding)
|
|
60
|
+
│ │ │
|
|
61
|
+
Ollama/paid Gemini@1536 project Vectorize
|
|
62
|
+
on this machine BYO Supabase BYO index/model
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Lane | Who runs compute | Where vectors live | When to offer |
|
|
66
|
+
|------|------------------|--------------------|---------------|
|
|
67
|
+
| **Local** | User machine | `.agentsam/knowledge/index.sqlite` | Default; Ollama free embed OK |
|
|
68
|
+
| **Supabase + node-api** | Their edge (template of IAM node-api) | Their `agentsam.*` PG tables | They opt into hosted ANN |
|
|
69
|
+
| **CF Vectorize** | Worker/plugin binding | Their Vectorize index | They already live on CF |
|
|
70
|
+
|
|
71
|
+
**Template rule:** ship **contracts + migrations + edge stubs**, not a shared multi-tenant dump of IAM tables into customer projects. Owner IAM remains the reference implementation.
|
|
72
|
+
|
|
73
|
+
Same-model law still holds per generation: vectors written with profile `P` are only queried with profile `P` (fingerprint of provider/model/dims/params).
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## 3. Guided path (inventory first — LOCK this UX)
|
|
78
|
+
|
|
79
|
+
One option at a time. Plan/dry-run is **not** “skip inventory.”
|
|
80
|
+
|
|
81
|
+
```text
|
|
82
|
+
① Provider / connection
|
|
83
|
+
↓
|
|
84
|
+
② Scan → file map inventory (Merkle + facet view)
|
|
85
|
+
↓
|
|
86
|
+
③ Include / exclude against the map
|
|
87
|
+
▼
|
|
88
|
+
④ Embedding model + dimensions (discovered, not hardcoded)
|
|
89
|
+
↓
|
|
90
|
+
⑤ Vector lane / data source
|
|
91
|
+
· local SQLite
|
|
92
|
+
· Supabase + node-api (Hyperdrive)
|
|
93
|
+
· Cloudflare Vectorize
|
|
94
|
+
↓
|
|
95
|
+
⑥ Dry-run / plan receipt (work-graph stages)
|
|
96
|
+
↓
|
|
97
|
+
⑦ Confirm → run (progress on Gantt + CLI)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### CLI / TUI (lightweight)
|
|
101
|
+
|
|
102
|
+
| Step | Interaction |
|
|
103
|
+
|------|-------------|
|
|
104
|
+
| ① | `select` configured providers + optional `agentsam providers` deep-link; Ollama online badge from `ollama list` |
|
|
105
|
+
| ② | Run `repository.inspect` / Merkle; print compact tree + counts; `--json` for Studio |
|
|
106
|
+
| ③ | `text` include / exclude; optional local chat assist; never invent denylist |
|
|
107
|
+
| ④ | `select` from **discovered** embed models only |
|
|
108
|
+
| ⑤ | `select` lane; if Supabase → collect URL/env names + offer node-api scaffold; if Vectorize → binding/index |
|
|
109
|
+
| ⑥ | `plan` emits work-graph JSON + pretty plan card |
|
|
110
|
+
| ⑦ | `confirm` then run; stream stage events |
|
|
111
|
+
|
|
112
|
+
Terminal aesthetic: short notes, one clack prompt per step, `tip: use skill agentsam-codebaseindex`, no wall of presets.
|
|
113
|
+
|
|
114
|
+
### Studio / localhost Gantt
|
|
115
|
+
|
|
116
|
+
Work-graph is the **source of truth** for the job; Gantt/timeline are projections.
|
|
117
|
+
|
|
118
|
+
Example stages (bars):
|
|
119
|
+
|
|
120
|
+
1. `connect` — providers resolved
|
|
121
|
+
2. `inventory` — file map / merkle
|
|
122
|
+
3. `scope` — include/exclude locked
|
|
123
|
+
4. `embed_profile` — model + dims
|
|
124
|
+
5. `lane` — local | supabase | vectorize
|
|
125
|
+
6. `plan` — dry-run receipt
|
|
126
|
+
7. `index` — parse / chunk / embed
|
|
127
|
+
8. `activate` — verify + ready
|
|
128
|
+
|
|
129
|
+
Local Studio (or this preview) polls `agentsam_code_index_job` / local generation receipts and feeds `createGanttModel(graph)`.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## 4. Supabase + node-api customer path (what “template” means)
|
|
134
|
+
|
|
135
|
+
When the user picks **Supabase / Hyperdrive**:
|
|
136
|
+
|
|
137
|
+
1. Scaffold edge from IAM `supabase/functions/node-api` **pattern** (ingest + account-scoped vector query RPCs).
|
|
138
|
+
2. Apply PG migrations that create **their** `agentsam.agentsam_codebase_*` (or lane-registry–driven table names).
|
|
139
|
+
3. Wire `AGENTSAM_DATABASE_URL` / Hyperdrive binding names into knowledge `lane.backend = supabase_pgvector`.
|
|
140
|
+
4. Register row in **their** `agentsam_pgvector_lane_registry` (or SDK lane config) pointing at table + model + dims.
|
|
141
|
+
5. Runs still use `codebaseindex.ingest` / `sam.codebaseindex.index.run` — only the **provider adapter** changes.
|
|
142
|
+
|
|
143
|
+
Owner machine: skip scaffold; credentials and node-api already exist → wizard jumps to inventory.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 5. CF Vectorize path (valid peer, not code-index SSOT for IAM)
|
|
148
|
+
|
|
149
|
+
IAM host law keeps **code index vectors off Vectorize**. Customer template may still choose Vectorize for **their** product:
|
|
150
|
+
|
|
151
|
+
- Plugin scope: binding + index + model + dims
|
|
152
|
+
- Knowledge `lane.backend = cloudflare_vectorize`
|
|
153
|
+
- Same guided steps ①–⑦; stage `lane` records Vectorize target in the receipt
|
|
154
|
+
|
|
155
|
+
Do not silently redirect owner IAM full-index onto Vectorize.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## 6. Local Ollama value (strategic I/O)
|
|
160
|
+
|
|
161
|
+
| Use | How |
|
|
162
|
+
|-----|-----|
|
|
163
|
+
| Free semantic search | `agentsam search --semantic` against local generation |
|
|
164
|
+
| Pre-filter before paid chat | Retrieve top-k chunks → pass only those to hosted model |
|
|
165
|
+
| Offline agent turns | Shell/agent retrieve while Ollama is up |
|
|
166
|
+
| Scope assist | Chat model (e.g. `qwen2.5-coder`) suggests include/exclude only |
|
|
167
|
+
|
|
168
|
+
Query must use **same** embed profile as write (e.g. `mxbai-embed-large:latest` @ 1024).
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 7. Implementation slices (ordered)
|
|
173
|
+
|
|
174
|
+
| Slice | Deliverable |
|
|
175
|
+
|-------|-------------|
|
|
176
|
+
| **A** | Reframe CLI wizard to ①→⑦ (inventory before scope); `plan` prints work-graph stages |
|
|
177
|
+
| **B** | Emit `codebaseindex.job.graph.v1` JSON consumed by work-graph Gantt |
|
|
178
|
+
| **C** | Local Studio / preview page binding graph → Gantt (this doc’s companion HTML) |
|
|
179
|
+
| **D** | Lane picker adapters: local (done-ish), supabase+node-api scaffold stub, vectorize scope probe |
|
|
180
|
+
| **E** | Customer template pack: migrations + edge stub + README (no IAM secrets) |
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## 8. Acceptance checks
|
|
185
|
+
|
|
186
|
+
- [ ] Wizard never jumps to embed/lane before an inventory receipt exists (or user explicitly skips with `--skip-inventory`).
|
|
187
|
+
- [ ] Exclude is user-authored (blank = none).
|
|
188
|
+
- [ ] Embed options come only from credentials + live Ollama tags.
|
|
189
|
+
- [ ] Plan/dry-run produces work-graph JSON + human card.
|
|
190
|
+
- [ ] Gantt shows the same stage ids as CLI.
|
|
191
|
+
- [ ] Choosing Supabase does not mutate owner IAM tables when running as a customer template.
|
|
192
|
+
- [ ] Semantic retrieve fails closed on embedding-profile mismatch.
|
|
193
|
+
|
|
194
|
+
---
|
|
195
|
+
|
|
196
|
+
## Related
|
|
197
|
+
|
|
198
|
+
- Host SSOT: `inneranimalmedia/docs/platform/codebase-index-ssot-2026-07.md`
|
|
199
|
+
- SAM kernel: `docs/architecture/SAM_KERNEL.md`
|
|
200
|
+
- Skill: `skills/agentsam-codebaseindex/SKILL.md`
|
|
201
|
+
- Work-graph: `packages/work-graph` (`createGanttModel`)
|
|
202
|
+
- Preview: `docs/architecture/previews/codebaseindex-guided-path/`
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<title>Codebaseindex Guided Path — Preview</title>
|
|
7
|
+
<style>
|
|
8
|
+
:root {
|
|
9
|
+
color-scheme: light;
|
|
10
|
+
--bg: #f4f1ea;
|
|
11
|
+
--ink: #1a1c1e;
|
|
12
|
+
--muted: #5c6370;
|
|
13
|
+
--panel: #fffcf7;
|
|
14
|
+
--line: #d8d0c4;
|
|
15
|
+
--accent: #2f6f4e;
|
|
16
|
+
--accent-2: #b45309;
|
|
17
|
+
--bar: #3d7a5a;
|
|
18
|
+
--bar-done: #2f6f4e;
|
|
19
|
+
--bar-run: #c27803;
|
|
20
|
+
--bar-wait: #9aa3af;
|
|
21
|
+
--mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
|
|
22
|
+
--sans: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
|
|
23
|
+
--display: "Fraunces", Georgia, serif;
|
|
24
|
+
}
|
|
25
|
+
* { box-sizing: border-box; }
|
|
26
|
+
body {
|
|
27
|
+
margin: 0;
|
|
28
|
+
font: 16px/1.5 var(--sans);
|
|
29
|
+
color: var(--ink);
|
|
30
|
+
background:
|
|
31
|
+
radial-gradient(1200px 600px at 10% -10%, #e8efe8 0%, transparent 55%),
|
|
32
|
+
radial-gradient(900px 500px at 100% 0%, #f3e6d4 0%, transparent 50%),
|
|
33
|
+
var(--bg);
|
|
34
|
+
}
|
|
35
|
+
main { max-width: 1080px; margin: 0 auto; padding: 40px 24px 80px; }
|
|
36
|
+
h1 {
|
|
37
|
+
font-family: var(--display);
|
|
38
|
+
font-weight: 550;
|
|
39
|
+
font-size: clamp(1.8rem, 3vw, 2.4rem);
|
|
40
|
+
margin: 0 0 8px;
|
|
41
|
+
letter-spacing: -0.02em;
|
|
42
|
+
}
|
|
43
|
+
.sub { color: var(--muted); margin: 0 0 28px; max-width: 62ch; }
|
|
44
|
+
.pill {
|
|
45
|
+
display: inline-block;
|
|
46
|
+
font: 12px/1 var(--mono);
|
|
47
|
+
padding: 5px 9px;
|
|
48
|
+
border: 1px solid var(--line);
|
|
49
|
+
border-radius: 999px;
|
|
50
|
+
margin-right: 6px;
|
|
51
|
+
background: var(--panel);
|
|
52
|
+
}
|
|
53
|
+
section {
|
|
54
|
+
background: var(--panel);
|
|
55
|
+
border: 1px solid var(--line);
|
|
56
|
+
border-radius: 4px;
|
|
57
|
+
padding: 20px 22px;
|
|
58
|
+
margin: 0 0 18px;
|
|
59
|
+
}
|
|
60
|
+
section h2 {
|
|
61
|
+
margin: 0 0 12px;
|
|
62
|
+
font-size: 0.95rem;
|
|
63
|
+
text-transform: uppercase;
|
|
64
|
+
letter-spacing: 0.06em;
|
|
65
|
+
color: var(--muted);
|
|
66
|
+
font-weight: 650;
|
|
67
|
+
}
|
|
68
|
+
ol.steps {
|
|
69
|
+
list-style: none;
|
|
70
|
+
margin: 0;
|
|
71
|
+
padding: 0;
|
|
72
|
+
display: grid;
|
|
73
|
+
gap: 8px;
|
|
74
|
+
}
|
|
75
|
+
ol.steps li {
|
|
76
|
+
display: grid;
|
|
77
|
+
grid-template-columns: 36px 1fr;
|
|
78
|
+
gap: 12px;
|
|
79
|
+
align-items: start;
|
|
80
|
+
padding: 10px 12px;
|
|
81
|
+
border: 1px solid transparent;
|
|
82
|
+
border-radius: 4px;
|
|
83
|
+
}
|
|
84
|
+
ol.steps li.active {
|
|
85
|
+
border-color: var(--accent);
|
|
86
|
+
background: #eef6f1;
|
|
87
|
+
}
|
|
88
|
+
ol.steps .n {
|
|
89
|
+
font: 700 14px/36px var(--mono);
|
|
90
|
+
width: 36px; height: 36px;
|
|
91
|
+
text-align: center;
|
|
92
|
+
border-radius: 50%;
|
|
93
|
+
background: #e7ece7;
|
|
94
|
+
color: var(--accent);
|
|
95
|
+
}
|
|
96
|
+
ol.steps li.active .n { background: var(--accent); color: #fff; }
|
|
97
|
+
ol.steps strong { display: block; }
|
|
98
|
+
ol.steps span { color: var(--muted); font-size: 0.92rem; }
|
|
99
|
+
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
|
|
100
|
+
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
|
|
101
|
+
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
|
|
102
|
+
code { font-family: var(--mono); font-size: 0.84em; }
|
|
103
|
+
.lanes {
|
|
104
|
+
display: grid;
|
|
105
|
+
grid-template-columns: repeat(3, 1fr);
|
|
106
|
+
gap: 12px;
|
|
107
|
+
}
|
|
108
|
+
@media (max-width: 800px) { .lanes { grid-template-columns: 1fr; } }
|
|
109
|
+
.lane {
|
|
110
|
+
border: 1px solid var(--line);
|
|
111
|
+
border-radius: 4px;
|
|
112
|
+
padding: 14px;
|
|
113
|
+
min-height: 140px;
|
|
114
|
+
}
|
|
115
|
+
.lane h3 { margin: 0 0 6px; font-size: 1rem; }
|
|
116
|
+
.lane p { margin: 0; color: var(--muted); font-size: 0.9rem; }
|
|
117
|
+
.lane.pick { outline: 2px solid var(--accent); background: #f3faf6; }
|
|
118
|
+
.gantt { display: grid; gap: 8px; margin-top: 8px; }
|
|
119
|
+
.gantt-row {
|
|
120
|
+
display: grid;
|
|
121
|
+
grid-template-columns: 140px 1fr 72px;
|
|
122
|
+
gap: 10px;
|
|
123
|
+
align-items: center;
|
|
124
|
+
}
|
|
125
|
+
.gantt-row .label { font: 12px/1.2 var(--mono); }
|
|
126
|
+
.track {
|
|
127
|
+
height: 18px;
|
|
128
|
+
background: #ece7df;
|
|
129
|
+
border-radius: 3px;
|
|
130
|
+
position: relative;
|
|
131
|
+
overflow: hidden;
|
|
132
|
+
}
|
|
133
|
+
.bar {
|
|
134
|
+
position: absolute;
|
|
135
|
+
top: 0; bottom: 0;
|
|
136
|
+
border-radius: 3px;
|
|
137
|
+
background: var(--bar-wait);
|
|
138
|
+
}
|
|
139
|
+
.bar.done { background: var(--bar-done); }
|
|
140
|
+
.bar.run { background: var(--bar-run); }
|
|
141
|
+
.bar.wait { background: var(--bar-wait); opacity: 0.55; }
|
|
142
|
+
.status { font: 11px/1 var(--mono); color: var(--muted); text-align: right; }
|
|
143
|
+
.cli {
|
|
144
|
+
font: 13px/1.55 var(--mono);
|
|
145
|
+
background: #1b1f24;
|
|
146
|
+
color: #d7e0ea;
|
|
147
|
+
padding: 14px 16px;
|
|
148
|
+
border-radius: 4px;
|
|
149
|
+
white-space: pre-wrap;
|
|
150
|
+
}
|
|
151
|
+
.cli .dim { color: #8b95a5; }
|
|
152
|
+
.cli .ok { color: #6dcea2; }
|
|
153
|
+
.cli .tip { color: #e0b35a; }
|
|
154
|
+
a.doc { color: var(--accent); }
|
|
155
|
+
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
|
|
156
|
+
button {
|
|
157
|
+
font: 13px/1 var(--sans);
|
|
158
|
+
padding: 9px 12px;
|
|
159
|
+
border: 1px solid var(--line);
|
|
160
|
+
background: #fff;
|
|
161
|
+
border-radius: 4px;
|
|
162
|
+
cursor: pointer;
|
|
163
|
+
}
|
|
164
|
+
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
|
|
165
|
+
</style>
|
|
166
|
+
</head>
|
|
167
|
+
<body>
|
|
168
|
+
<main>
|
|
169
|
+
<p>
|
|
170
|
+
<span class="pill">plan preview</span>
|
|
171
|
+
<span class="pill">sam.codebaseindex.index.run</span>
|
|
172
|
+
<span class="pill">codebaseindex.ingest</span>
|
|
173
|
+
</p>
|
|
174
|
+
<h1>Codebaseindex guided path</h1>
|
|
175
|
+
<p class="sub">
|
|
176
|
+
Inventory first, then scope, then vector lane. Owner IAM already runs Gemini@1536 → Supabase via node-api;
|
|
177
|
+
customers get the same harness as a template (local · Supabase+edge · CF Vectorize).
|
|
178
|
+
Spec:
|
|
179
|
+
<a class="doc" href="./CODEBASEINDEX_GUIDED_PATH.md">CODEBASEINDEX_GUIDED_PATH.md</a>
|
|
180
|
+
</p>
|
|
181
|
+
|
|
182
|
+
<section>
|
|
183
|
+
<h2>Wizard · one option at a time</h2>
|
|
184
|
+
<ol class="steps" id="steps"></ol>
|
|
185
|
+
<div class="actions">
|
|
186
|
+
<button type="button" id="prev">Back</button>
|
|
187
|
+
<button type="button" class="primary" id="next">Next step</button>
|
|
188
|
+
<button type="button" id="reset">Reset</button>
|
|
189
|
+
</div>
|
|
190
|
+
</section>
|
|
191
|
+
|
|
192
|
+
<section>
|
|
193
|
+
<h2>Vector lane choices</h2>
|
|
194
|
+
<div class="lanes">
|
|
195
|
+
<div class="lane" data-lane="local">
|
|
196
|
+
<h3>Local SQLite</h3>
|
|
197
|
+
<p>Ollama / paid embed on this machine. Free semantic search offline. Default for SDK.</p>
|
|
198
|
+
</div>
|
|
199
|
+
<div class="lane" data-lane="supabase">
|
|
200
|
+
<h3>Supabase + node-api</h3>
|
|
201
|
+
<p>BYO edge (IAM node-api template) → Hyperdrive/PG. Host SSOT pattern for Gemini@1536.</p>
|
|
202
|
+
</div>
|
|
203
|
+
<div class="lane" data-lane="vectorize">
|
|
204
|
+
<h3>CF Vectorize</h3>
|
|
205
|
+
<p>Valid customer lane via binding/index. Not IAM host code-index SSOT.</p>
|
|
206
|
+
</div>
|
|
207
|
+
</div>
|
|
208
|
+
</section>
|
|
209
|
+
|
|
210
|
+
<section>
|
|
211
|
+
<h2>Job Gantt · work-graph projection</h2>
|
|
212
|
+
<p class="sub" style="margin-bottom:12px">Same stage ids the CLI should emit in <code>codebaseindex.job.graph.v1</code>.</p>
|
|
213
|
+
<div class="gantt" id="gantt"></div>
|
|
214
|
+
</section>
|
|
215
|
+
|
|
216
|
+
<section>
|
|
217
|
+
<h2>Supabase tables (host code index)</h2>
|
|
218
|
+
<table>
|
|
219
|
+
<thead><tr><th>Table</th><th>Role</th></tr></thead>
|
|
220
|
+
<tbody>
|
|
221
|
+
<tr><td><code>agentsam.agentsam_codebase_chunks_gemini_embedding_2_1536</code></td><td>Chunk ANN</td></tr>
|
|
222
|
+
<tr><td><code>agentsam.agentsam_codebase_files_gemini_embedding_2_1536</code></td><td>File vectors</td></tr>
|
|
223
|
+
<tr><td><code>agentsam.agentsam_codebase_ast_symbols_gemini_embedding_2_1536</code></td><td>Symbol ANN</td></tr>
|
|
224
|
+
<tr><td><code>agentsam.agentsam_gemini_semantic_embeddings_1536</code></td><td>Unified semantic authority</td></tr>
|
|
225
|
+
<tr><td><code>agentsam.agentsam_documents_gemini_embedding_2_1536</code></td><td>Documents twin</td></tr>
|
|
226
|
+
</tbody>
|
|
227
|
+
</table>
|
|
228
|
+
</section>
|
|
229
|
+
|
|
230
|
+
<section>
|
|
231
|
+
<h2>CLI/TUI sketch</h2>
|
|
232
|
+
<div class="cli" id="cli"></div>
|
|
233
|
+
</section>
|
|
234
|
+
</main>
|
|
235
|
+
<script type="module">
|
|
236
|
+
const STEPS = [
|
|
237
|
+
{ id: 'connect', title: 'Provider / connection', detail: 'Discover credentials + Ollama. Owner skips scaffold.' },
|
|
238
|
+
{ id: 'inventory', title: 'Scan → file map', detail: 'repository.inspect / Merkle inventory before any exclude.' },
|
|
239
|
+
{ id: 'scope', title: 'Include / exclude', detail: 'User-authored paths; optional local chat assist.' },
|
|
240
|
+
{ id: 'embed', title: 'Model + dimensions', detail: 'Discovered only — e.g. mxbai-embed-large:latest @ 1024.' },
|
|
241
|
+
{ id: 'lane', title: 'Vector data source', detail: 'local · supabase+node-api · cloudflare_vectorize' },
|
|
242
|
+
{ id: 'plan', title: 'Dry-run / plan', detail: 'Work-graph receipt — not a silent jump to write.' },
|
|
243
|
+
{ id: 'run', title: 'Confirm → run', detail: 'Progress events feed this Gantt + terminal.' },
|
|
244
|
+
];
|
|
245
|
+
|
|
246
|
+
const GANTT = [
|
|
247
|
+
{ id: 'connect', start: 0, end: 10, status: 'done' },
|
|
248
|
+
{ id: 'inventory', start: 10, end: 28, status: 'done' },
|
|
249
|
+
{ id: 'scope', start: 28, end: 40, status: 'done' },
|
|
250
|
+
{ id: 'embed_profile', start: 40, end: 48, status: 'run' },
|
|
251
|
+
{ id: 'lane', start: 48, end: 58, status: 'wait' },
|
|
252
|
+
{ id: 'plan', start: 58, end: 70, status: 'wait' },
|
|
253
|
+
{ id: 'index', start: 70, end: 92, status: 'wait' },
|
|
254
|
+
{ id: 'activate', start: 92, end: 100, status: 'wait' },
|
|
255
|
+
];
|
|
256
|
+
|
|
257
|
+
let step = 1;
|
|
258
|
+
let lane = 'local';
|
|
259
|
+
|
|
260
|
+
const stepsEl = document.getElementById('steps');
|
|
261
|
+
const ganttEl = document.getElementById('gantt');
|
|
262
|
+
const cliEl = document.getElementById('cli');
|
|
263
|
+
|
|
264
|
+
function renderSteps() {
|
|
265
|
+
stepsEl.innerHTML = STEPS.map((s, i) => `
|
|
266
|
+
<li class="${i === step ? 'active' : ''}">
|
|
267
|
+
<div class="n">${i + 1}</div>
|
|
268
|
+
<div><strong>${s.title}</strong><span>${s.detail}</span></div>
|
|
269
|
+
</li>`).join('');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function renderGantt() {
|
|
273
|
+
ganttEl.innerHTML = GANTT.map((row) => `
|
|
274
|
+
<div class="gantt-row">
|
|
275
|
+
<div class="label">${row.id}</div>
|
|
276
|
+
<div class="track"><div class="bar ${row.status}" style="left:${row.start}%;width:${row.end - row.start}%"></div></div>
|
|
277
|
+
<div class="status">${row.status}</div>
|
|
278
|
+
</div>`).join('');
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function renderCli() {
|
|
282
|
+
const s = STEPS[step];
|
|
283
|
+
cliEl.innerHTML = [
|
|
284
|
+
`<span class="dim">agentsam codebaseindex</span>`,
|
|
285
|
+
`<span class="tip">tip: use skill agentsam-codebaseindex</span>`,
|
|
286
|
+
``,
|
|
287
|
+
`<span class="ok">✓</span> step ${step + 1}/${STEPS.length} · ${s.id}`,
|
|
288
|
+
` ${s.title}`,
|
|
289
|
+
` lane preference: <span class="ok">${lane}</span>`,
|
|
290
|
+
``,
|
|
291
|
+
step === 1 ? ` inventory: merkle_root=ab12… files=482 facets ready` : ` <span class="dim">(advance to see inventory framing)</span>`,
|
|
292
|
+
step >= 4 ? ` embed: discovered ollama|mxbai-embed-large:latest|1024` : '',
|
|
293
|
+
step >= 5 ? ` data source → ${lane === 'supabase' ? 'node-api → agentsam.agentsam_codebase_chunks_…' : lane}` : '',
|
|
294
|
+
step >= 6 ? ` plan receipt → codebaseindex.job.graph.v1` : '',
|
|
295
|
+
].filter(Boolean).join('\n');
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
function renderLanes() {
|
|
299
|
+
document.querySelectorAll('.lane').forEach((el) => {
|
|
300
|
+
el.classList.toggle('pick', el.dataset.lane === lane);
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function paint() {
|
|
305
|
+
renderSteps();
|
|
306
|
+
renderGantt();
|
|
307
|
+
renderCli();
|
|
308
|
+
renderLanes();
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
document.getElementById('next').onclick = () => { step = Math.min(STEPS.length - 1, step + 1); paint(); };
|
|
312
|
+
document.getElementById('prev').onclick = () => { step = Math.max(0, step - 1); paint(); };
|
|
313
|
+
document.getElementById('reset').onclick = () => { step = 0; lane = 'local'; paint(); };
|
|
314
|
+
document.querySelectorAll('.lane').forEach((el) => {
|
|
315
|
+
el.addEventListener('click', () => { lane = el.dataset.lane; paint(); });
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
paint();
|
|
319
|
+
</script>
|
|
320
|
+
</body>
|
|
321
|
+
</html>
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
-- 0010_portable_tickets_memory.sql
|
|
2
|
+
-- Portable GOAP / ticket + memory spine for new AgentSam projects (local SQLite or D1).
|
|
3
|
+
-- Account-owned tickets — NOT Inner Animal Media's shared platform DB.
|
|
4
|
+
-- Every write path MUST populate account_id and repository_id (NULL = broken implementation).
|
|
5
|
+
|
|
6
|
+
CREATE TABLE IF NOT EXISTS agentsam_tickets (
|
|
7
|
+
id TEXT PRIMARY KEY,
|
|
8
|
+
title TEXT NOT NULL,
|
|
9
|
+
status TEXT NOT NULL
|
|
10
|
+
CHECK (status IN ('backlog', 'active', 'blocked', 'in_review', 'shipped', 'abandoned')),
|
|
11
|
+
status_reason TEXT,
|
|
12
|
+
project TEXT,
|
|
13
|
+
subsystem TEXT,
|
|
14
|
+
tags TEXT,
|
|
15
|
+
priority TEXT,
|
|
16
|
+
doc_path TEXT,
|
|
17
|
+
blocks TEXT,
|
|
18
|
+
blocked_by TEXT,
|
|
19
|
+
supersedes TEXT,
|
|
20
|
+
created_at INTEGER NOT NULL,
|
|
21
|
+
updated_at INTEGER NOT NULL,
|
|
22
|
+
closed_at INTEGER,
|
|
23
|
+
dedup_key TEXT,
|
|
24
|
+
consecutive_pass_count INTEGER,
|
|
25
|
+
last_gate_run_id INTEGER,
|
|
26
|
+
last_gate_ok_at INTEGER,
|
|
27
|
+
required_pass_count INTEGER,
|
|
28
|
+
description TEXT,
|
|
29
|
+
client_id TEXT,
|
|
30
|
+
due_at INTEGER,
|
|
31
|
+
surface TEXT NOT NULL DEFAULT 'platform',
|
|
32
|
+
start_at INTEGER,
|
|
33
|
+
estimated_minutes INTEGER,
|
|
34
|
+
percent_complete INTEGER NOT NULL DEFAULT 0,
|
|
35
|
+
owner_kind TEXT NOT NULL DEFAULT 'unassigned',
|
|
36
|
+
owner_ref TEXT,
|
|
37
|
+
parent_ticket_id TEXT,
|
|
38
|
+
agent_run_id TEXT,
|
|
39
|
+
worktree TEXT,
|
|
40
|
+
linked_commit TEXT,
|
|
41
|
+
source TEXT NOT NULL DEFAULT 'manual',
|
|
42
|
+
account_id TEXT NOT NULL,
|
|
43
|
+
repository_id TEXT NOT NULL
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
CREATE INDEX IF NOT EXISTS idx_agentsam_tickets_account_repository
|
|
47
|
+
ON agentsam_tickets(account_id, repository_id, updated_at DESC);
|
|
48
|
+
|
|
49
|
+
CREATE INDEX IF NOT EXISTS idx_agentsam_tickets_status
|
|
50
|
+
ON agentsam_tickets(account_id, status, updated_at DESC);
|
|
51
|
+
|
|
52
|
+
CREATE TABLE IF NOT EXISTS agentsam_ticket_events (
|
|
53
|
+
id TEXT PRIMARY KEY,
|
|
54
|
+
ticket_id TEXT NOT NULL REFERENCES agentsam_tickets(id) ON DELETE CASCADE,
|
|
55
|
+
event_type TEXT NOT NULL,
|
|
56
|
+
from_status TEXT,
|
|
57
|
+
to_status TEXT,
|
|
58
|
+
detail TEXT,
|
|
59
|
+
commit_sha TEXT,
|
|
60
|
+
created_at INTEGER NOT NULL,
|
|
61
|
+
actor_type TEXT,
|
|
62
|
+
actor_id TEXT,
|
|
63
|
+
media_asset_id TEXT,
|
|
64
|
+
account_id TEXT NOT NULL,
|
|
65
|
+
repository_id TEXT NOT NULL
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
CREATE INDEX IF NOT EXISTS idx_agentsam_ticket_events_ticket
|
|
69
|
+
ON agentsam_ticket_events(ticket_id, created_at);
|
|
70
|
+
|
|
71
|
+
CREATE TABLE IF NOT EXISTS agentsam_memory (
|
|
72
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
73
|
+
account_id TEXT NOT NULL,
|
|
74
|
+
repository_id TEXT NOT NULL,
|
|
75
|
+
project_id TEXT,
|
|
76
|
+
memory_key TEXT NOT NULL,
|
|
77
|
+
memory_type TEXT NOT NULL
|
|
78
|
+
CHECK (memory_type IN (
|
|
79
|
+
'fact', 'preference', 'decision', 'policy', 'state', 'procedure'
|
|
80
|
+
)),
|
|
81
|
+
title TEXT,
|
|
82
|
+
content TEXT NOT NULL,
|
|
83
|
+
summary TEXT,
|
|
84
|
+
importance INTEGER NOT NULL DEFAULT 5
|
|
85
|
+
CHECK (importance BETWEEN 1 AND 10),
|
|
86
|
+
tags TEXT NOT NULL DEFAULT '[]',
|
|
87
|
+
status TEXT NOT NULL DEFAULT 'active'
|
|
88
|
+
CHECK (status IN ('active', 'archived', 'deleted')),
|
|
89
|
+
is_pinned INTEGER NOT NULL DEFAULT 0,
|
|
90
|
+
content_hash TEXT NOT NULL,
|
|
91
|
+
source TEXT,
|
|
92
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
93
|
+
updated_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
94
|
+
revision INTEGER NOT NULL DEFAULT 1,
|
|
95
|
+
semantic_hash TEXT,
|
|
96
|
+
sensitivity TEXT NOT NULL DEFAULT 'normal'
|
|
97
|
+
CHECK (sensitivity IN ('normal','internal','confidential','secret')),
|
|
98
|
+
source_client TEXT,
|
|
99
|
+
source_ref TEXT,
|
|
100
|
+
supersedes_id TEXT,
|
|
101
|
+
expires_at INTEGER,
|
|
102
|
+
scope_type TEXT,
|
|
103
|
+
scope_id TEXT,
|
|
104
|
+
idempotency_key TEXT,
|
|
105
|
+
metadata_json TEXT NOT NULL DEFAULT '{}'
|
|
106
|
+
CHECK (json_valid(metadata_json)),
|
|
107
|
+
UNIQUE(account_id, memory_key)
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
CREATE INDEX IF NOT EXISTS idx_agentsam_memory_account_repo
|
|
111
|
+
ON agentsam_memory(account_id, repository_id, updated_at DESC);
|
|
112
|
+
|
|
113
|
+
CREATE TABLE IF NOT EXISTS agentsam_memory_outbox (
|
|
114
|
+
id TEXT PRIMARY KEY NOT NULL,
|
|
115
|
+
memory_id TEXT NOT NULL,
|
|
116
|
+
account_id TEXT NOT NULL,
|
|
117
|
+
repository_id TEXT NOT NULL,
|
|
118
|
+
revision INTEGER NOT NULL,
|
|
119
|
+
content_hash TEXT NOT NULL,
|
|
120
|
+
semantic_hash TEXT NOT NULL,
|
|
121
|
+
operation TEXT NOT NULL DEFAULT 'upsert'
|
|
122
|
+
CHECK (operation IN ('upsert','deactivate','delete')),
|
|
123
|
+
projection_target TEXT NOT NULL DEFAULT 'node_api_pgvector'
|
|
124
|
+
CHECK (projection_target = 'node_api_pgvector'),
|
|
125
|
+
payload_json TEXT NOT NULL DEFAULT '{}'
|
|
126
|
+
CHECK (json_valid(payload_json)),
|
|
127
|
+
status TEXT NOT NULL DEFAULT 'pending'
|
|
128
|
+
CHECK (status IN ('pending','processing','completed','failed')),
|
|
129
|
+
attempts INTEGER NOT NULL DEFAULT 0,
|
|
130
|
+
next_attempt_at INTEGER,
|
|
131
|
+
locked_at INTEGER,
|
|
132
|
+
last_error TEXT,
|
|
133
|
+
created_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
134
|
+
updated_at INTEGER NOT NULL DEFAULT (unixepoch()),
|
|
135
|
+
UNIQUE(memory_id, revision, operation)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
CREATE INDEX IF NOT EXISTS idx_agentsam_memory_outbox_pending
|
|
139
|
+
ON agentsam_memory_outbox(status, next_attempt_at)
|
|
140
|
+
WHERE status IN ('pending','failed');
|