@anchrd/intel-api 0.6.7 → 0.9.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 (58) hide show
  1. package/README.md +63 -3
  2. package/dist/adapters/cloudflare/cloudflare.js +102 -37
  3. package/dist/adapters/cloudflare/cloudflare.types.d.ts +20 -0
  4. package/dist/adapters/content/content.d.ts +1 -1
  5. package/dist/adapters/db/db-flows.js +148 -20
  6. package/dist/adapters/db/db-grants.d.ts +13 -2
  7. package/dist/adapters/db/db-grants.js +25 -8
  8. package/dist/adapters/db/db-indexing.d.ts +2 -2
  9. package/dist/adapters/db/db-indexing.js +26 -19
  10. package/dist/adapters/db/db.d.ts +3 -3
  11. package/dist/adapters/db/db.js +442 -118
  12. package/dist/adapters/gate-applications/gate-applications.d.ts +23 -0
  13. package/dist/adapters/gate-applications/gate-applications.js +88 -0
  14. package/dist/adapters/index-queue/index-queue.d.ts +1 -1
  15. package/dist/adapters/index-queue/index-queue.js +2 -2
  16. package/dist/adapters/semantic-index/semantic-index.types.d.ts +2 -2
  17. package/dist/adapters/tool-delegation/tool-delegation.d.ts +22 -0
  18. package/dist/adapters/tool-delegation/tool-delegation.js +90 -0
  19. package/dist/agent-runtime/agent-runtime.d.ts +16 -0
  20. package/dist/agent-runtime/agent-runtime.js +150 -0
  21. package/dist/agent-runtime/agent-runtime.types.d.ts +122 -0
  22. package/dist/bundle/bundle.d.ts +4 -0
  23. package/dist/bundle/bundle.js +1048 -0
  24. package/dist/bundle/bundle.types.d.ts +33 -0
  25. package/dist/bundle/bundle.types.js +1 -0
  26. package/dist/cli/cli.js +10 -1
  27. package/dist/flows/flows.d.ts +8 -8
  28. package/dist/flows/flows.js +158 -42
  29. package/dist/flows/flows.types.d.ts +40 -7
  30. package/dist/http/http.d.ts +1 -0
  31. package/dist/http/http.js +348 -61
  32. package/dist/http/http.types.d.ts +6 -2
  33. package/dist/indexing/indexing.js +14 -2
  34. package/dist/indexing/indexing.types.d.ts +2 -2
  35. package/dist/intel/intel.js +12 -3
  36. package/dist/intel/intel.types.d.ts +6 -2
  37. package/dist/mcp/mcp.js +519 -124
  38. package/dist/mcp/mcp.types.d.ts +11 -2
  39. package/dist/nodes/nodes.d.ts +2 -0
  40. package/dist/nodes/nodes.js +1466 -0
  41. package/dist/nodes/nodes.types.d.ts +402 -0
  42. package/dist/nodes/nodes.types.js +1 -0
  43. package/dist/tools/tool-servers/tool-servers.d.ts +46 -0
  44. package/dist/tools/tool-servers/tool-servers.js +114 -0
  45. package/dist/tools/tools.js +190 -31
  46. package/dist/tools/tools.types.d.ts +23 -1
  47. package/migrations/0011_one_name_for_the_tree.sql +53 -0
  48. package/migrations/0012_table_snapshots.sql +29 -0
  49. package/migrations/0013_agents_in_the_tree.sql +76 -0
  50. package/migrations/0014_agent_applications.sql +25 -0
  51. package/migrations/0015_tools_delegated_from_a_connection.sql +15 -0
  52. package/package.json +3 -2
  53. package/dist/knowledge/knowledge.d.ts +0 -2
  54. package/dist/knowledge/knowledge.js +0 -761
  55. package/dist/knowledge/knowledge.types.d.ts +0 -198
  56. /package/dist/{knowledge/knowledge.types.js → agent-runtime/agent-runtime.types.js} +0 -0
  57. /package/dist/{knowledge → nodes}/document-links/document-links.d.ts +0 -0
  58. /package/dist/{knowledge → nodes}/document-links/document-links.js +0 -0
@@ -10,7 +10,7 @@ function indexText(mediaType, content) {
10
10
  catch (error) {
11
11
  // Immutable content never becomes parsable on a retry, so treating this as transient would
12
12
  // requeue the version until the queue gives up and would bury the real cause.
13
- throw new PermanentIndexingError(`Knowledge version content is not a valid BlockNote document: ${error instanceof Error ? error.message : "unknown parse failure"}`);
13
+ throw new PermanentIndexingError(`Node version content is not a valid BlockNote document: ${error instanceof Error ? error.message : "unknown parse failure"}`);
14
14
  }
15
15
  }
16
16
  async function readCanonical(deps, target) {
@@ -29,13 +29,25 @@ export function createIndexing(deps) {
29
29
  const target = await deps.repository.getTarget(versionId);
30
30
  if (!target)
31
31
  return;
32
+ // ⚠️ An agent's body is a definition, not something to read: node IDs, a cron line and a model
33
+ // name (ADR-0005 §4). Indexing it verbatim would fill the index with identifiers and, worse,
34
+ // put them into the passage a searcher is shown — the definition names nodes the searcher may
35
+ // have no access to, and a snippet is the one place their IDs would become visible without
36
+ // the tree being asked. What makes an agent findable is what a person wrote about it, so the
37
+ // text is its description, and the FTS table indexes the title on its own (#139).
38
+ if (target.kind === "agent") {
39
+ await deps.repository.replace(target, target.description ?? "");
40
+ await deps.semantic?.replace(target, target.description ?? "");
41
+ await deps.repository.markIndexed(versionId, deps.now().toISOString());
42
+ return;
43
+ }
32
44
  // An attachment is one object of bytes; text kinds may be several, because a table's content
33
45
  // is the join of its versions (#40). A missing segment fails the whole pass rather than
34
46
  // indexing a table with a hole in it.
35
47
  const canonical = await readCanonical(deps, target);
36
48
  if (canonical === null) {
37
49
  await deps.repository.markError(versionId, "content_missing", deps.now().toISOString());
38
- throw new Error("Knowledge version content is missing");
50
+ throw new Error("Node version content is missing");
39
51
  }
40
52
  try {
41
53
  const text = typeof canonical === "string"
@@ -1,8 +1,8 @@
1
1
  import type { DocumentConverter } from "../adapters/document-converter/document-converter.types.js";
2
2
  import type { SemanticIndex } from "../adapters/semantic-index/semantic-index.types.js";
3
- import type { ContentStore, KnowledgeIndexRepository } from "../knowledge/knowledge.types.js";
3
+ import type { ContentStore, NodeIndexRepository } from "../nodes/nodes.types.js";
4
4
  export interface IndexingDeps {
5
- repository: KnowledgeIndexRepository;
5
+ repository: NodeIndexRepository;
6
6
  content: ContentStore;
7
7
  semantic?: SemanticIndex | undefined;
8
8
  converter?: DocumentConverter | undefined;
@@ -1,7 +1,7 @@
1
1
  import { Hono } from "hono";
2
2
  import { createHttp } from "../http/http.js";
3
3
  import { handleMcp } from "../mcp/mcp.js";
4
- import { authorize, authorizeBearer } from "../shared/gate-authorization/gate-authorization.js";
4
+ import { authorize, authorizeBearer, bearer, } from "../shared/gate-authorization/gate-authorization.js";
5
5
  import { IntelError } from "../shared/intel-error/intel-error.js";
6
6
  import { problemDetails } from "../shared/problem-details/problem-details.js";
7
7
  import { reportUnexpectedError } from "../shared/report-unexpected-error/report-unexpected-error.js";
@@ -68,9 +68,11 @@ export function createIntel(deps) {
68
68
  }
69
69
  app.route("/api/v1", createHttp({
70
70
  gate: deps.gate,
71
- knowledge: deps.knowledge,
71
+ nodes: deps.nodes,
72
72
  flows: deps.flows,
73
73
  tools: deps.tools,
74
+ bundle: deps.bundle,
75
+ agents: deps.agents,
74
76
  resource,
75
77
  resourceMetadataUrl,
76
78
  ...(deps.auth ? { auth: deps.auth } : {}),
@@ -83,9 +85,16 @@ export function createIntel(deps) {
83
85
  }
84
86
  return await handleMcp(context.req.raw, {
85
87
  authorization,
88
+ // ⚠️ The very token this call was authorized with, so the agent tools reach the runtime as the
89
+ // caller and not as Intel. There is no cookie path on `/mcp`, so `bearer` is the same value
90
+ // `authorize` just used — read again rather than passed out of it, because a function that
91
+ // returned a credential beside its answer would be one somebody logs.
92
+ bearer: bearer(context.req.raw.headers) ?? "",
93
+ agents: deps.agents,
86
94
  flows: deps.flows,
87
- knowledge: deps.knowledge,
95
+ nodes: deps.nodes,
88
96
  tools: deps.tools,
97
+ bundle: deps.bundle,
89
98
  });
90
99
  });
91
100
  return app;
@@ -1,14 +1,18 @@
1
1
  import type { GateClient } from "@anchrd/gate-sdk";
2
+ import type { AgentRuntimeService } from "../agent-runtime/agent-runtime.types.js";
2
3
  import type { BrowserAuth } from "../auth/auth.types.js";
4
+ import type { BundleService } from "../bundle/bundle.types.js";
3
5
  import type { FlowService } from "../flows/flows.types.js";
4
- import type { KnowledgeService } from "../knowledge/knowledge.types.js";
6
+ import type { NodeService } from "../nodes/nodes.types.js";
5
7
  import type { ToolService } from "../tools/tools.types.js";
6
8
  export interface IntelDeps {
7
9
  baseUrl: string;
8
10
  gateUrl: string;
9
11
  gate: Pick<GateClient, "authorize">;
10
- knowledge: KnowledgeService;
12
+ nodes: NodeService;
11
13
  flows: FlowService;
12
14
  tools: ToolService;
15
+ bundle: BundleService;
16
+ agents: AgentRuntimeService;
13
17
  auth?: BrowserAuth;
14
18
  }