@anchrd/intel-api 0.3.1 → 0.3.3

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.
@@ -57,6 +57,9 @@ export default {
57
57
  assertConfigured(env);
58
58
  const now = () => new Date();
59
59
  const semantic = env.AI && env.SEARCH ? createSemanticIndex({ ai: env.AI, index: env.SEARCH }) : undefined;
60
+ // Built before Knowledge because Knowledge has to ask it one question: who calls into a folder
61
+ // from outside it. The repository knows no service, so this stays one direction of dependency.
62
+ const flowRepository = createFlowRepository({ db: env.DB, now });
60
63
  const knowledge = createKnowledge({
61
64
  repository: createKnowledgeRepository({ db: env.DB, now }),
62
65
  content: createContentStore(env.CONTENT),
@@ -64,6 +67,8 @@ export default {
64
67
  now,
65
68
  indexing: createIndexQueue(env.INDEXING),
66
69
  semantic,
70
+ externalFlowCallers: async (who, folderId) => await flowRepository.externalCallers(who, folderId),
71
+ flowKnowledgeReferences: async (who, folderId) => await flowRepository.knowledgeReferences(who, folderId),
67
72
  hash: async (content) => {
68
73
  const source = typeof content === "string"
69
74
  ? new TextEncoder().encode(content)
@@ -128,22 +133,16 @@ export default {
128
133
  },
129
134
  });
130
135
  const flows = createFlows({
131
- repository: createFlowRepository({ db: env.DB, now }),
136
+ repository: flowRepository,
132
137
  runtime: createFlowRuntime(env.FLOWS),
133
138
  id: ulid,
134
139
  now,
135
- knowledgeExists: async (actor, resourceId) => {
136
- try {
137
- await knowledge.get(actor, resourceId);
138
- return true;
139
- }
140
- catch (error) {
141
- if (error instanceof IntelError && error.status === 404)
142
- return false;
143
- throw error;
144
- }
145
- },
146
140
  folderAccess: async (actor, folderId) => await knowledge.folderAccess(actor, folderId),
141
+ knowledgeChildren: async (actor, folderId, limit) => await knowledge.childrenBounded(actor, { parentId: folderId, limit }),
142
+ // Knowledge's own visibility lookup, unchanged on the way through: the relation graph, the
143
+ // requirements list and every Knowledge step of every run read this one answer, so none of
144
+ // them can be kinder than the others.
145
+ visibleKnowledge: async (actor, nodeId) => await knowledge.visibleNode(actor, nodeId),
147
146
  toolFingerprint: async (actor, toolName) => {
148
147
  const catalog = await tools
149
148
  .catalog({ id: actor.id, email: actor.email, canExecute: true })