@anchrd/intel-api 0.13.0 → 0.15.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 (57) hide show
  1. package/dist/adapters/cloudflare/cloudflare.js +1 -68
  2. package/dist/adapters/cloudflare/cloudflare.types.d.ts +0 -39
  3. package/dist/adapters/db/db-flows.js +1 -1
  4. package/dist/adapters/db/db-grants.js +1 -1
  5. package/dist/adapters/db/db-indexing.js +79 -0
  6. package/dist/adapters/db/db.js +81 -139
  7. package/dist/adapters/semantic-index/semantic-index.js +97 -17
  8. package/dist/adapters/semantic-index/semantic-index.types.d.ts +20 -1
  9. package/dist/bundle/bundle.js +42 -134
  10. package/dist/cli/cli.js +3 -9
  11. package/dist/http/http.js +5 -206
  12. package/dist/http/http.types.d.ts +0 -8
  13. package/dist/indexing/indexing.js +133 -55
  14. package/dist/indexing/indexing.types.d.ts +1 -0
  15. package/dist/intel/intel.js +4 -9
  16. package/dist/intel/intel.types.d.ts +0 -6
  17. package/dist/mcp/mcp.js +33 -308
  18. package/dist/mcp/mcp.types.d.ts +2 -7
  19. package/dist/nodes/document-links/document-links.d.ts +6 -8
  20. package/dist/nodes/document-links/document-links.js +8 -31
  21. package/dist/nodes/nodes.js +92 -826
  22. package/dist/nodes/nodes.types.d.ts +57 -158
  23. package/dist/tools/tools.js +37 -148
  24. package/dist/tools/tools.types.d.ts +0 -21
  25. package/migrations/0009_no_context_policy.sql +15 -0
  26. package/migrations/0017_a_vector_per_card.sql +38 -0
  27. package/migrations/0018_no_context_policy_at_last.sql +97 -0
  28. package/migrations/0019_one_name_for_the_grants.sql +52 -0
  29. package/package.json +2 -2
  30. package/dist/adapters/cloudflare-api/cloudflare-api.d.ts +0 -22
  31. package/dist/adapters/cloudflare-api/cloudflare-api.js +0 -214
  32. package/dist/adapters/cloudflare-api/cloudflare-api.types.d.ts +0 -64
  33. package/dist/adapters/cloudflare-api/cloudflare-api.types.js +0 -1
  34. package/dist/adapters/gate-applications/gate-applications.d.ts +0 -23
  35. package/dist/adapters/gate-applications/gate-applications.js +0 -88
  36. package/dist/adapters/tool-delegation/tool-delegation.d.ts +0 -22
  37. package/dist/adapters/tool-delegation/tool-delegation.js +0 -90
  38. package/dist/agent-costs/agent-costs.d.ts +0 -16
  39. package/dist/agent-costs/agent-costs.js +0 -105
  40. package/dist/agent-costs/agent-costs.types.d.ts +0 -30
  41. package/dist/agent-costs/agent-costs.types.js +0 -1
  42. package/dist/agent-runtime/agent-runtime.d.ts +0 -16
  43. package/dist/agent-runtime/agent-runtime.js +0 -150
  44. package/dist/agent-runtime/agent-runtime.types.d.ts +0 -122
  45. package/dist/agent-runtime/agent-runtime.types.js +0 -1
  46. package/dist/model-catalog/model-catalog.d.ts +0 -2
  47. package/dist/model-catalog/model-catalog.js +0 -99
  48. package/dist/model-catalog/model-catalog.types.d.ts +0 -15
  49. package/dist/model-catalog/model-catalog.types.js +0 -1
  50. package/dist/nodes/board/board.d.ts +0 -59
  51. package/dist/nodes/board/board.js +0 -528
  52. package/dist/nodes/board/board.types.d.ts +0 -31
  53. package/dist/nodes/board/board.types.js +0 -1
  54. package/migrations/0013_agents_in_the_tree.sql +0 -76
  55. package/migrations/0014_agent_applications.sql +0 -25
  56. package/migrations/0015_tools_delegated_from_a_connection.sql +0 -15
  57. package/migrations/0016_boards_in_the_tree.sql +0 -80
@@ -1,15 +0,0 @@
1
- -- #208 (D30): an agent's tools are whole MCP servers its owner delegated from the owner's own
2
- -- portal connection. Nothing about that selection is stored here — it lives in the agent's
3
- -- definition, versioned in R2 like the rest of the document.
4
- --
5
- -- What this file adds is the one lookup the run path needs and `0014` did not provide: a call
6
- -- arrives authenticated as a Gate Application, and Intel has to answer "which agent is that"
7
- -- before it may read anybody's portal token. `0014` indexed `node_id` only (it is the primary
8
- -- key), so the reverse question was a table scan on every delegated tool call.
9
- --
10
- -- ⚠️ UNIQUE, not just an index. Two agents sharing one Application would make the lookup ambiguous
11
- -- and would hand one agent the other's delegation — the same class of hole `AGENT_APPLICATION_KEYS`
12
- -- refuses a doubly listed id for (D27). The constraint is what makes "one Application per agent"
13
- -- a fact of the database rather than a promise of the code that writes it.
14
- CREATE UNIQUE INDEX agent_applications_application_idx
15
- ON agent_applications(application_id);
@@ -1,80 +0,0 @@
1
- -- #285: a sixth kind in the shared tree — `board`. It is a node like the other five: same
2
- -- `parent_id`, same folder grants, same immutable `node_versions` rows, same R2 body (ADR-0004 §1).
3
- -- Its body happens to be a JSON project board rather than prose, which the schema neither knows nor
4
- -- needs to: nothing here creates a second content model, only the CHECK has to learn the word.
5
- --
6
- -- A board's tasks live INSIDE that one body and get no table of their own. That is the decision the
7
- -- ticket makes: a board with three hundred tasks is one node in the tree, not three hundred, and
8
- -- nothing about the tree has to behave differently because a board is filed in it.
9
- --
10
- -- SQLite cannot alter a CHECK constraint, so the table is rebuilt — the same rebuild 0005 and 0013
11
- -- performed for `table` and `agent`, written the same long way round for the same two reasons. Both
12
- -- detours below are copied from a file that earned them against a real database, not from caution.
13
- --
14
- -- ⚠️ First detour: the new table is created under the final name rather than built beside the old
15
- -- one and renamed over it. `DROP TABLE` on a parent runs an implicit `DELETE FROM` first, so the
16
- -- moment the old `nodes` goes, every row of `node_versions`, `tree_grants` and `flows` pointing at a
17
- -- node is a foreign-key violation. `defer_foreign_keys` postpones the complaint to COMMIT but does
18
- -- not withdraw it, and `ALTER TABLE ... RENAME` does not settle it either: a rename puts the name
19
- -- back, not the rows. Only inserting the nodes again, under the name the children have referenced
20
- -- all along, does. This is also why the self-reference below reads `REFERENCES nodes(id)` — the
21
- -- final name — which is lesson 2 of the three recorded in `0009_no_context_policy.sql`.
22
- --
23
- -- ⚠️ Second detour: `node_links` is the only child of `nodes` declared ON DELETE CASCADE, so that
24
- -- same implicit delete does not merely flag its rows, it removes them — the migration would commit
25
- -- with every relationship between two documents quietly gone. The rows are carried out of the way
26
- -- first and put back afterwards. That is a rescue, not a decision about the data: nothing is
27
- -- dropped, rewritten or reinterpreted here.
28
- --
29
- -- ⚠️ On an empty database neither detour is visible, because nothing points at anything. That is
30
- -- exactly how 0005's first version passed a green suite and then failed against the first database
31
- -- with content in it, and why the proof for this file is a row count of every referencing table
32
- -- before and after rather than a migration that merely ran.
33
- --
34
- -- `context_policy` is carried over unchanged and still NOT NULL. It is dead for every consumer
35
- -- (#76) and only D1's refusal to drop a column a CHECK names keeps it here; removing it is #86 and
36
- -- deliberately not smuggled into this rebuild.
37
- PRAGMA defer_foreign_keys = TRUE;
38
-
39
- -- Plain holding tables on purpose: no keys, no CHECKs, no foreign keys, and the column set taken
40
- -- from whatever the live table has. Anything enforced here would only be enforced a second time on
41
- -- the way back in, and a holding table that can reject a row is a holding table that can lose one.
42
- CREATE TABLE nodes_carry AS SELECT * FROM nodes;
43
- CREATE TABLE node_links_carry AS SELECT * FROM node_links;
44
-
45
- DROP TABLE nodes;
46
-
47
- CREATE TABLE nodes (
48
- id TEXT PRIMARY KEY NOT NULL,
49
- parent_id TEXT REFERENCES nodes(id),
50
- kind TEXT NOT NULL CHECK (kind IN ('folder', 'document', 'attachment', 'table', 'agent', 'board')),
51
- title TEXT NOT NULL CHECK (length(title) BETWEEN 1 AND 240),
52
- description TEXT CHECK (description IS NULL OR length(description) <= 2000),
53
- context_policy TEXT NOT NULL CHECK (context_policy IN ('pinned', 'relevant', 'explicit')),
54
- owner_id TEXT NOT NULL,
55
- current_version_id TEXT,
56
- created_at TEXT NOT NULL,
57
- updated_at TEXT NOT NULL,
58
- archived_at TEXT
59
- );
60
-
61
- INSERT INTO nodes (
62
- id, parent_id, kind, title, description, context_policy, owner_id,
63
- current_version_id, created_at, updated_at, archived_at
64
- )
65
- SELECT
66
- id, parent_id, kind, title, description, context_policy, owner_id,
67
- current_version_id, created_at, updated_at, archived_at
68
- FROM nodes_carry;
69
-
70
- -- `OR IGNORE` because whether the cascade above actually fired is SQLite's business, not this
71
- -- migration's: if it did, this puts the rows back; if it did not, each one is already present under
72
- -- the same primary key and this is a no-op. Either way `node_links` ends up holding exactly what it
73
- -- held before, which is the only outcome this statement is permitted to have.
74
- INSERT OR IGNORE INTO node_links SELECT * FROM node_links_carry;
75
-
76
- DROP TABLE nodes_carry;
77
- DROP TABLE node_links_carry;
78
-
79
- CREATE INDEX nodes_parent_idx ON nodes(parent_id, archived_at, title);
80
- CREATE INDEX nodes_owner_idx ON nodes(owner_id, archived_at);