@anchrd/intel-api 0.6.6 → 0.7.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 (51) hide show
  1. package/README.md +44 -3
  2. package/dist/adapters/cloudflare/cloudflare.js +50 -16
  3. package/dist/adapters/cloudflare/cloudflare.types.d.ts +11 -0
  4. package/dist/adapters/content/content.d.ts +1 -1
  5. package/dist/adapters/db/db-flows.js +161 -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 +448 -119
  12. package/dist/adapters/gate-applications/gate-applications.d.ts +23 -0
  13. package/dist/adapters/gate-applications/gate-applications.js +66 -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/agent-runtime/agent-runtime.d.ts +16 -0
  18. package/dist/agent-runtime/agent-runtime.js +76 -0
  19. package/dist/agent-runtime/agent-runtime.types.d.ts +57 -0
  20. package/dist/bundle/bundle.d.ts +4 -0
  21. package/dist/bundle/bundle.js +1035 -0
  22. package/dist/bundle/bundle.types.d.ts +33 -0
  23. package/dist/bundle/bundle.types.js +1 -0
  24. package/dist/cli/cli.js +10 -1
  25. package/dist/flows/flows.d.ts +8 -8
  26. package/dist/flows/flows.js +158 -42
  27. package/dist/flows/flows.types.d.ts +40 -7
  28. package/dist/http/http.d.ts +1 -0
  29. package/dist/http/http.js +329 -63
  30. package/dist/http/http.types.d.ts +6 -2
  31. package/dist/indexing/indexing.js +14 -2
  32. package/dist/indexing/indexing.types.d.ts +2 -2
  33. package/dist/intel/intel.js +12 -3
  34. package/dist/intel/intel.types.d.ts +6 -2
  35. package/dist/mcp/mcp.js +483 -124
  36. package/dist/mcp/mcp.types.d.ts +11 -2
  37. package/dist/nodes/nodes.d.ts +2 -0
  38. package/dist/nodes/nodes.js +1337 -0
  39. package/dist/nodes/nodes.types.d.ts +314 -0
  40. package/dist/nodes/nodes.types.js +1 -0
  41. package/migrations/0011_one_name_for_the_tree.sql +53 -0
  42. package/migrations/0012_table_snapshots.sql +29 -0
  43. package/migrations/0013_agents_in_the_tree.sql +76 -0
  44. package/migrations/0014_agent_applications.sql +25 -0
  45. package/package.json +3 -2
  46. package/dist/knowledge/knowledge.d.ts +0 -2
  47. package/dist/knowledge/knowledge.js +0 -761
  48. package/dist/knowledge/knowledge.types.d.ts +0 -198
  49. /package/dist/{knowledge/knowledge.types.js → agent-runtime/agent-runtime.types.js} +0 -0
  50. /package/dist/{knowledge → nodes}/document-links/document-links.d.ts +0 -0
  51. /package/dist/{knowledge → nodes}/document-links/document-links.js +0 -0
@@ -1,198 +0,0 @@
1
- import type { AppendKnowledgeTableRowsInput, AppendKnowledgeTableRowsResult, ArchiveKnowledgeNodeInput, CreateKnowledgeNodeInput, DefineKnowledgeTableInput, KnowledgeAttachment, KnowledgeCitation, KnowledgeDocument, KnowledgeGraph, KnowledgeGraphInput, KnowledgeLink, KnowledgeNode, KnowledgeTable, KnowledgeVersion, ListKnowledgeNodesInput, ResolveKnowledgeLinksInput, ResolveKnowledgeLinksResult, ResourceGrant, ResourceGrantList, ResourceVerb, RevokeKnowledgeGrantInput, SaveKnowledgeAttachmentInput, SaveKnowledgeVersionInput, SearchKnowledgeInput, ShareKnowledgeInput, ShareKnowledgeResult, UpdateKnowledgeNodeInput } from "@anchrd/intel-contract";
2
- import type { SemanticIndex } from "../adapters/semantic-index/semantic-index.types.js";
3
- export interface Actor {
4
- id: string;
5
- email: string;
6
- isAdmin?: boolean;
7
- }
8
- export interface NewKnowledgeNode {
9
- node: KnowledgeNode;
10
- actorId: string;
11
- idempotencyKey: string;
12
- auditId: string;
13
- }
14
- export interface NewKnowledgeVersion {
15
- version: KnowledgeVersion;
16
- actorId: string;
17
- baseVersionId: string | null;
18
- idempotencyKey: string;
19
- auditId: string;
20
- }
21
- export interface NewKnowledgeTableVersion {
22
- version: Omit<KnowledgeVersion, "sequence">;
23
- actorId: string;
24
- idempotencyKey: string;
25
- auditId: string;
26
- }
27
- export interface KnowledgeRepository {
28
- listVisible(actor: Actor, input: ListKnowledgeNodesInput): Promise<{
29
- items: KnowledgeNode[];
30
- withChildren: string[];
31
- }>;
32
- listVisibleBounded(actor: Actor, input: {
33
- parentId: string | null;
34
- limit: number;
35
- }): Promise<BoundedChildren>;
36
- getVisible(actor: Actor, nodeId: string): Promise<KnowledgeNode | null>;
37
- can(actor: Actor, nodeId: string, verb: ResourceVerb): Promise<boolean>;
38
- findIdempotentNode(actorId: string, operation: "knowledge.create" | "knowledge.save" | "knowledge.append" | "knowledge.update" | "knowledge.archive" | "knowledge.share" | "knowledge.revoke", idempotencyKey: string): Promise<string | null>;
39
- findIdempotentRevocation(actorId: string, idempotencyKey: string): Promise<boolean | null>;
40
- insertNode(input: NewKnowledgeNode): Promise<KnowledgeNode>;
41
- getVersion(versionId: string): Promise<KnowledgeVersion | null>;
42
- appendVersion(input: NewKnowledgeVersion): Promise<"saved" | "conflict">;
43
- appendTableVersion(input: NewKnowledgeTableVersion): Promise<KnowledgeVersion>;
44
- listVersionContentKeys(nodeId: string): Promise<string[]>;
45
- firstVersionContentKey(nodeId: string): Promise<string | null>;
46
- listVersions(nodeId: string): Promise<KnowledgeVersion[]>;
47
- updateNode(input: {
48
- node: KnowledgeNode;
49
- baseUpdatedAt: string;
50
- actorId: string;
51
- idempotencyKey: string;
52
- auditId: string;
53
- }): Promise<"cycle" | "conflict" | KnowledgeNode>;
54
- archiveNode(input: {
55
- nodeId: string;
56
- baseUpdatedAt: string;
57
- archivedAt: string | null;
58
- updatedAt: string;
59
- actorId: string;
60
- idempotencyKey: string;
61
- auditId: string;
62
- }): Promise<"conflict" | KnowledgeNode>;
63
- listGrants(resourceId: string): Promise<ResourceGrant[]>;
64
- organizationExecuteReaches(nodeId: string, exceptGrantId: string): Promise<boolean>;
65
- listLinksVisible(actor: Actor, nodeId: string): Promise<KnowledgeLink[]>;
66
- resolveVisibleTitles(actor: Actor, nodeIds: string[]): Promise<Array<{
67
- nodeId: string;
68
- title: string;
69
- }>>;
70
- replaceTextLinks(input: {
71
- sourceNodeId: string;
72
- links: Array<{
73
- id: string;
74
- targetNodeId: string;
75
- }>;
76
- actorId: string;
77
- auditId: string;
78
- occurredAt: string;
79
- }): Promise<void>;
80
- graphVisible(actor: Actor, input: KnowledgeGraphInput): Promise<KnowledgeGraph>;
81
- setGrant(input: {
82
- grant: ResourceGrant;
83
- actorId: string;
84
- idempotencyKey: string;
85
- auditId: string;
86
- }): Promise<ResourceGrant>;
87
- revokeGrant(input: {
88
- resourceId: string;
89
- grantId: string;
90
- actorId: string;
91
- idempotencyKey: string;
92
- auditId: string;
93
- occurredAt: string;
94
- }): Promise<boolean>;
95
- searchVisible(actor: Actor, input: SearchKnowledgeInput): Promise<KnowledgeCitation[]>;
96
- hydrateVisibleCitations(actor: Actor, nodeIds: string[]): Promise<KnowledgeCitation[]>;
97
- listCurrentVersionIds(input: {
98
- after: string | null;
99
- limit: number;
100
- }): Promise<string[]>;
101
- }
102
- export interface ContentStore {
103
- get(key: string): Promise<string | null>;
104
- getBytes(key: string): Promise<ArrayBuffer | null>;
105
- getStream(key: string): Promise<ReadableStream<Uint8Array> | null>;
106
- put(key: string, content: string, mediaType: string): Promise<void>;
107
- putBytes(key: string, content: ArrayBuffer, mediaType: string): Promise<void>;
108
- delete(key: string): Promise<void>;
109
- }
110
- export interface KnowledgeAttachmentBody {
111
- attachment: KnowledgeAttachment;
112
- body: ReadableStream<Uint8Array>;
113
- }
114
- export interface KnowledgeDeps {
115
- repository: KnowledgeRepository;
116
- content: ContentStore;
117
- id(): string;
118
- now(): Date;
119
- externalFlowCallers(actor: Actor, folderId: string): Promise<{
120
- visible: string[];
121
- hidden: number;
122
- }>;
123
- flowKnowledgeReferences(actor: Actor, folderId: string): Promise<string[]>;
124
- hash(content: string | Uint8Array): Promise<string>;
125
- indexing: {
126
- enqueue(versionId: string): Promise<void>;
127
- };
128
- semantic?: SemanticIndex | undefined;
129
- }
130
- export type FolderAccess = "ok" | "missing" | "not-a-folder" | "forbidden";
131
- export interface BoundedChildren {
132
- items: KnowledgeNode[];
133
- total: number;
134
- }
135
- export interface KnowledgeService {
136
- list(actor: Actor, input: ListKnowledgeNodesInput): Promise<{
137
- items: KnowledgeNode[];
138
- }>;
139
- /**
140
- * One level of the tree as this actor may see it, bounded: at most `limit` current children, and
141
- * `total` for how many there are. Its caller is the relation graph, which draws a bounded picture
142
- * and must not read a folder of a thousand documents to do it (#30).
143
- *
144
- * ⚠️ `total` counts what passed the visibility predicate and nothing else, or the size a picture
145
- * reports would become a way of learning that something is filed here.
146
- */
147
- childrenBounded(actor: Actor, input: {
148
- parentId: string | null;
149
- limit: number;
150
- }): Promise<BoundedChildren>;
151
- get(actor: Actor, nodeId: string): Promise<KnowledgeDocument>;
152
- folderAccess(actor: Actor, folderId: string): Promise<FolderAccess>;
153
- create(actor: Actor, input: CreateKnowledgeNodeInput): Promise<KnowledgeNode>;
154
- save(actor: Actor, input: SaveKnowledgeVersionInput): Promise<KnowledgeDocument>;
155
- saveAttachment(actor: Actor, input: SaveKnowledgeAttachmentInput): Promise<KnowledgeDocument>;
156
- getTable(actor: Actor, nodeId: string): Promise<KnowledgeTable>;
157
- defineTable(actor: Actor, input: DefineKnowledgeTableInput): Promise<KnowledgeTable>;
158
- appendTableRows(actor: Actor, input: AppendKnowledgeTableRowsInput): Promise<AppendKnowledgeTableRowsResult>;
159
- getAttachment(actor: Actor, nodeId: string): Promise<KnowledgeAttachment>;
160
- readAttachment(actor: Actor, nodeId: string): Promise<KnowledgeAttachmentBody>;
161
- listVersions(actor: Actor, nodeId: string): Promise<{
162
- items: KnowledgeVersion[];
163
- }>;
164
- update(actor: Actor, input: UpdateKnowledgeNodeInput): Promise<KnowledgeNode>;
165
- archive(actor: Actor, input: ArchiveKnowledgeNodeInput): Promise<KnowledgeNode>;
166
- listGrants(actor: Actor, resourceId: string): Promise<ResourceGrantList>;
167
- listLinks(actor: Actor, nodeId: string): Promise<{
168
- items: KnowledgeLink[];
169
- }>;
170
- resolveLinks(actor: Actor, input: ResolveKnowledgeLinksInput): Promise<ResolveKnowledgeLinksResult>;
171
- graph(actor: Actor, input: KnowledgeGraphInput): Promise<KnowledgeGraph>;
172
- visibleNode(actor: Actor, nodeId: string): Promise<KnowledgeNode | null>;
173
- share(actor: Actor, input: ShareKnowledgeInput): Promise<ShareKnowledgeResult>;
174
- revokeGrant(actor: Actor, input: RevokeKnowledgeGrantInput): Promise<{
175
- revoked: boolean;
176
- }>;
177
- search(actor: Actor, input: SearchKnowledgeInput): Promise<{
178
- items: KnowledgeCitation[];
179
- }>;
180
- reindex(actor: Actor): Promise<{
181
- queued: number;
182
- }>;
183
- }
184
- export interface KnowledgeIndexTarget {
185
- nodeId: string;
186
- versionId: string;
187
- title: string;
188
- contentKeys: string[];
189
- mediaType: string;
190
- kind: "document" | "attachment" | "table";
191
- updatedAt: string;
192
- }
193
- export interface KnowledgeIndexRepository {
194
- getTarget(versionId: string): Promise<KnowledgeIndexTarget | null>;
195
- replace(target: KnowledgeIndexTarget, content: string): Promise<void>;
196
- markIndexed(versionId: string, occurredAt: string): Promise<void>;
197
- markError(versionId: string, message: string, occurredAt: string): Promise<void>;
198
- }