fuli-context 0.20.0-beta.13 → 0.20.0-beta.14

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 (49) hide show
  1. package/dist/web/assets/{index-DvkJiX-L.js → index-BDCkW4Ii.js} +1 -1
  2. package/dist/web/index.html +1 -1
  3. package/graph-provider/fuli_graph/app.py +16 -11
  4. package/graph-provider/fuli_graph/graph_query.py +30 -2
  5. package/graph-provider/fuli_graph/knowledge_audit.py +9 -1
  6. package/graph-provider/fuli_graph/knowledge_item_routes.py +10 -6
  7. package/graph-provider/fuli_graph/knowledge_item_view.py +41 -12
  8. package/graph-provider/fuli_graph/knowledge_item_view_models.py +3 -3
  9. package/graph-provider/fuli_graph/knowledge_review.py +47 -10
  10. package/graph-provider/fuli_graph/knowledge_search.py +18 -22
  11. package/graph-provider/fuli_graph/knowledge_session_migration.py +14 -4
  12. package/graph-provider/fuli_graph/knowledge_session_migration_models.py +2 -2
  13. package/graph-provider/fuli_graph/knowledge_tag_routes.py +7 -5
  14. package/graph-provider/fuli_graph/knowledge_tags.py +8 -4
  15. package/graph-provider/fuli_graph/knowledge_visibility.py +195 -0
  16. package/graph-provider/fuli_graph/models.py +12 -2
  17. package/graph-provider/fuli_graph/preference_conflicts.py +50 -4
  18. package/graph-provider/fuli_graph/publication_source_copies.py +36 -0
  19. package/graph-provider/fuli_graph/session_records.py +33 -13
  20. package/graph-provider/fuli_graph/session_records_models.py +4 -2
  21. package/graph-provider/fuli_graph/store_knowledge.py +5 -1
  22. package/graph-provider/fuli_graph/store_publication.py +70 -12
  23. package/graph-provider/pyproject.toml +1 -1
  24. package/native/win32/fuli-win-helper.exe +0 -0
  25. package/npm-shrinkwrap.json +2 -2
  26. package/package.json +1 -1
  27. package/src/agent-tools/graph-definitions.js +4 -4
  28. package/src/agent-tools/interface-definitions.js +2 -1
  29. package/src/agents/turn-receipt.js +15 -8
  30. package/src/graphiti/federated-application.js +49 -60
  31. package/src/graphiti/human-review-channel.js +9 -5
  32. package/src/graphiti/knowledge-item-edit.js +7 -4
  33. package/src/graphiti/knowledge-reader.js +46 -0
  34. package/src/graphiti/knowledge-tags.js +12 -1
  35. package/src/graphiti/provider-client.js +13 -21
  36. package/src/graphiti/publication-draft-capture.js +28 -0
  37. package/src/graphiti/session-knowledge-migration.js +7 -3
  38. package/src/graphiti/session-records.js +26 -15
  39. package/src/graphiti/turn-receipt-delivery.js +5 -2
  40. package/src/graphiti/writing-taste-profile-workflow.js +13 -7
  41. package/src/http/api-router.js +2 -1
  42. package/src/http/graph-api-router.js +13 -10
  43. package/src/http/knowledge-item-api-router.js +17 -4
  44. package/src/http/knowledge-tags-api-router.js +21 -9
  45. package/src/http/session-records-api-router.js +7 -3
  46. package/src/knowledge-owner-reads/console-port.js +51 -0
  47. package/src/knowledge-tags/console-port.js +3 -2
  48. package/src/presence/windows-helper-pin.js +1 -1
  49. package/src/server.js +8 -1
@@ -1,5 +1,6 @@
1
1
  import { ApplicationError } from '../app/application-error.js';
2
2
  import { activeAgentRequestSignal } from '../app/agent-request-context.js';
3
+ import { graphReadPath, preferenceConflictsPath, publicationDraftsPath } from './knowledge-reader.js';
3
4
  import { preferenceTaskSession } from './preference-task-scope.js';
4
5
  import { afterProjectWrite, sharedProjectList } from './shared-project-list.js';
5
6
 
@@ -637,10 +638,8 @@ export class GraphitiProviderClient {
637
638
  method: 'POST', body: { personal_space_id: personalSpaceId }
638
639
  });
639
640
  }
640
- // rec#20: authoritative item views and a turn's receipt.
641
- readKnowledgeItemView(input) {
642
- return this.#request('/v1/knowledge/item-views', { method: 'POST', body: input });
643
- }
641
+ // rec#20: a turn's receipt as an Agent reads it (knowledge-reader.js). The
642
+ // console's item views and full reads use its own port (src/knowledge-owner-reads).
644
643
  readTurnReceipt(input) {
645
644
  return this.#request('/v1/knowledge/turn-receipts', { method: 'POST', body: input });
646
645
  }
@@ -648,8 +647,10 @@ export class GraphitiProviderClient {
648
647
  readSessionRecords(input) {
649
648
  return this.#request('/v1/session-records', { method: 'POST', body: input });
650
649
  }
651
- // rec#20 part 2: what a session's temporary project holds. Scope writes go
652
- // through the console's human-review channel (src/knowledge-scope).
650
+ // rec#20 part 2: what a session's temporary project holds, as an Agent's
651
+ // offer reads it (knowledge-reader.js). The console's page reads it through
652
+ // its own port (src/knowledge-owner-reads); scope writes go through the
653
+ // console's human-review channel (src/knowledge-scope).
653
654
  previewSessionMigration(input) {
654
655
  return this.#request('/v1/knowledge/session-migrations/preview', { method: 'POST', body: input });
655
656
  }
@@ -669,9 +670,7 @@ export class GraphitiProviderClient {
669
670
  return this.#request('/v1/publication-drafts', { method: 'POST', body: input });
670
671
  }
671
672
  listPublicationDrafts(personalSpaceId, status = 'pending', { metadataOnly = false, ...options } = {}) {
672
- const query = new URLSearchParams({ personal_space_id: personalSpaceId, status });
673
- if (metadataOnly) query.set('metadata_only', 'true');
674
- return this.#request(`/v1/publication-drafts?${query}`, options);
673
+ return this.#request(publicationDraftsPath(personalSpaceId, { status, metadataOnly }), options);
675
674
  }
676
675
  getPublicationDraft(personalSpaceId, draftId) {
677
676
  const query = new URLSearchParams({ personal_space_id: personalSpaceId });
@@ -864,14 +863,9 @@ export class GraphitiProviderClient {
864
863
  method: 'POST', body: input
865
864
  });
866
865
  }
866
+ // An Agent's read, as a plain session; the console's full list uses its own port (src/knowledge-owner-reads).
867
867
  listPreferenceConflicts(personalSpaceId, status = null, limit = 500, offset = 0) {
868
- const query = new URLSearchParams({
869
- personal_space_id: personalSpaceId,
870
- limit: String(limit)
871
- });
872
- if (status) query.set('status', status);
873
- if (offset) query.set('offset', String(offset));
874
- return this.#request(`/v1/preference-conflicts?${query}`);
868
+ return this.#request(preferenceConflictsPath(personalSpaceId, { status, limit, offset }));
875
869
  }
876
870
  resolvePreferenceConflict(conflictId, input) {
877
871
  return this.#request(
@@ -939,11 +933,9 @@ export class GraphitiProviderClient {
939
933
  }
940
934
  return this.#request(`/v1/collaboration-preferences?${query}`);
941
935
  }
942
- graph(spaceId, limit = 500, personalProjectId = null, offset = null) {
943
- const query = new URLSearchParams({ limit: String(limit) });
944
- if (personalProjectId) query.set('personal_project_id', personalProjectId);
945
- if (offset !== null) query.set('offset', String(offset));
946
- return this.#request(`/v1/spaces/${encodeURIComponent(spaceId)}/graph?${query}`);
936
+ // An Agent's read (knowledge-reader.js): reader names its FLA, or null for a plain session.
937
+ graph(spaceId, limit = 500, personalProjectId = null, offset = null, reader = null) {
938
+ return this.#request(graphReadPath(spaceId, { limit, personalProjectId, offset, reader }));
947
939
  }
948
940
 
949
941
  // A long-running client (an MCP server) outlives a token rotation, for
@@ -0,0 +1,28 @@
1
+ import { receiptConsoleUrl } from '../agents/identity-receipt.js';
2
+ import { ProviderRequestError } from './provider-client.js';
3
+
4
+ // A capture for a team project waits as a local pre-review draft until the
5
+ // person submits it from the console's publish queue. The Provider answers a
6
+ // create that meets an existing draft this caller may not read exactly as a
7
+ // missing draft (0.20.1): a team-only draft is the person's alone, and a
8
+ // self-reported source is no proof that it is the same create. A 404 here
9
+ // proves nothing either way (a retry after a lost reply, or any other miss),
10
+ // so the capture is reported unconfirmed: neither saved nor lost, no cause guessed.
11
+ const UNCONFIRMED = 'Cannot confirm whether this capture was saved; check the publish queue in the FULI console.';
12
+
13
+ export async function queuePublicationDraft(application, { input, workspace, episode }) {
14
+ const queued = { route: 'personal_review', projectId: input.spaceId, providerUrl: workspace.providerUrl };
15
+ try {
16
+ const draft = await application.personal.createPublicationDraft({
17
+ personal_space_id: application.config.personal.spaceId,
18
+ target_project_id: input.spaceId,
19
+ provider_url: workspace.providerUrl,
20
+ episode
21
+ });
22
+ return { ...queued, status: draft.status, draftId: draft.id };
23
+ } catch (error) {
24
+ if (!(error instanceof ProviderRequestError && error.status === 404)) throw error;
25
+ return { ...queued, status: 'unconfirmed', message: UNCONFIRMED,
26
+ reviewUrl: `${receiptConsoleUrl(application)}/public-projects` };
27
+ }
28
+ }
@@ -1,6 +1,7 @@
1
1
  import { ApplicationError, ApplicationErrorCode } from '../app/application-error.js';
2
2
  import { receiptConsoleUrl } from '../agents/identity-receipt.js';
3
3
  import { requiredString } from '../validation/values.js';
4
+ import { providerReaderFields, taskKnowledgeReader } from './knowledge-reader.js';
4
5
  import { isTemporaryProjectId } from './temporary-project-scope.js';
5
6
 
6
7
  // rec#20 part 2: what a host session saved while nobody chose where it applies
@@ -20,10 +21,12 @@ const MAX_PROJECT_ID = 128;
20
21
  const MAX_ITEMS = 100;
21
22
 
22
23
  // One page of the held items, oldest first; offset is where the page starts.
23
- export function readSessionMigration(application, input) {
24
+ // ownerReads: the console's port (src/knowledge-owner-reads), so the person's
25
+ // page lists and counts every FLA's held items.
26
+ export function readSessionMigration(application, ownerReads, input) {
24
27
  const offset = input.offset === null || input.offset === undefined || input.offset === '' ? 0 : Number(input.offset);
25
28
  if (!Number.isInteger(offset) || offset < 0) invalid('offset must be where a page of held items starts');
26
- return application.personal.previewSessionMigration({ ...target(application, input), include_items: true, offset });
29
+ return ownerReads.sessionMigration({ ...target(application, input), include_items: true, offset });
27
30
  }
28
31
 
29
32
  // scopeConsole: the console port that sends it on the human-review channel (src/knowledge-scope).
@@ -56,11 +59,12 @@ export function sessionMigrationLine(application, task, { heldCount = null } = {
56
59
  }
57
60
 
58
61
  // The entry's offer once a session links to a formal project; never blocks the entry.
62
+ // It reads as the task's FLA or plain session, so another FLA's held items are not counted.
59
63
  export async function sessionMigrationOffer(application, task) {
60
64
  if (!formalTask(task)) return null;
61
65
  try {
62
66
  const pending = await application.personal.previewSessionMigration({ ...providerTarget(application, task),
63
- include_items: false });
67
+ include_items: false, ...providerReaderFields(taskKnowledgeReader(task)) });
64
68
  if (!(pending?.held_count > 0) || pending.linked_task_count > 1) return null;
65
69
  return sessionMigrationLine(application, task, { heldCount: pending.held_count });
66
70
  } catch {
@@ -3,6 +3,7 @@ import { receiptSummary, receiptText, sessionRecordsUrl } from '../agents/identi
3
3
  import { CATEGORY, CONFIRMATION } from '../agents/turn-receipt.js';
4
4
  import { notRecordedReason } from '../conversations/transcript-capture-gap.js';
5
5
  import { localClockTime } from '../text/clock-time.js';
6
+ import { providerReaderFields, taskKnowledgeReader } from './knowledge-reader.js';
6
7
  import { requiredString } from '../validation/values.js';
7
8
 
8
9
  // "本会话记了什么" (rec#5 C6): one host session's records in three groups,
@@ -13,10 +14,12 @@ import { requiredString } from '../validation/values.js';
13
14
  // nothing was recorded (paused, stopped or otherwise off) are shown as
14
15
  // "HH:mm~HH:mm 暂停记录" / "未记录" and hold no record.
15
16
  //
16
- // The console is the person's own view and lists everything. An Agent reads
17
- // only its own session, and only what that session wrote while in the
18
- // Agent's own project (C6-5): records a turn wrote in another project never
19
- // enter this project's context, not even as a count.
17
+ // The console is the person's own view and lists everything, read through
18
+ // its human-review port (ownerReads). An Agent reads only its own session,
19
+ // only what that session wrote while in the Agent's own project (C6-5), and
20
+ // as its task's FLA or plain session, so the Provider leaves out every other
21
+ // FLA's knowledge: records a turn wrote in another project never enter this
22
+ // project's context, not even as a count.
20
23
 
21
24
  const GROUPS = Object.freeze(['transcript', 'knowledge', 'preference_evidence']);
22
25
  const MAX_SESSION_ID = 256;
@@ -24,13 +27,13 @@ const MAX_CLIENT = 32;
24
27
 
25
28
  // sourceApplication may be left out: a receipt's short link names only the
26
29
  // session, and the Provider finds its client (or says two clients share it).
27
- export async function readSessionRecords(application, { personalSpaceId, sourceApplication = null, sessionId }) {
30
+ export async function readSessionRecords(application, ownerReads, { personalSpaceId, sourceApplication = null, sessionId }) {
28
31
  if (personalSpaceId !== application.config.personal.spaceId) {
29
32
  invalid('Session records are read in the active personal space');
30
33
  }
31
34
  const sessionIdValue = requiredString(sessionId, 'sessionId', MAX_SESSION_ID);
32
35
  const read = await providerRead(application, { sessionId: sessionIdValue,
33
- sourceApplication: sourceApplication ? client(sourceApplication) : null });
36
+ sourceApplication: sourceApplication ? client(sourceApplication) : null }, ownerReads.sessionRecords);
34
37
  return sessionRecordsView(application, { sourceApplication: read.source_application ?? null, sessionId: sessionIdValue }, read);
35
38
  }
36
39
 
@@ -41,15 +44,17 @@ export async function readOwnSessionRecords(application, { taskContextToken, sou
41
44
  const task = await application.taskContextRegistry.context(requiredString(taskContextToken, 'taskContextToken', 160),
42
45
  client(sourceApplication));
43
46
  const session = { sourceApplication: task.sourceApplication, sessionId: task.sessionId };
44
- const read = await providerRead(application, session);
45
- const view = sessionRecordsView(application, session, withinProject(read, task.personalProjectId ?? null));
47
+ const reader = providerReaderFields(taskKnowledgeReader(task));
48
+ const read = await providerRead(application, session,
49
+ body => application.personal.readSessionRecords({ ...body, ...reader }));
50
+ const view = sessionRecordsView(application, session, withinReader(read, task));
46
51
  // The numbered lines carry every entry once; the same entries again as
47
52
  // data would only double what the answer costs.
48
53
  return { total: view.total, truncated: view.truncated, url: view.session.url, markdown: sessionRecordsMarkdown(view) };
49
54
  }
50
55
 
51
- async function providerRead(application, session) {
52
- const read = await application.personal.readSessionRecords({ personal_space_id: application.config.personal.spaceId,
56
+ async function providerRead(application, session, readRecords) {
57
+ const read = await readRecords({ personal_space_id: application.config.personal.spaceId,
53
58
  source_application: session.sourceApplication, session_id: session.sessionId });
54
59
  if (!Array.isArray(read?.turns) || !Array.isArray(read?.items)) {
55
60
  throw new TypeError('Provider did not return the session records');
@@ -62,12 +67,18 @@ async function providerRead(application, session) {
62
67
  // turns hold is left out too: even its times are that project's.
63
68
  // An item is kept when one of its sources is this project's, shown through
64
69
  // the first such source, so another project's earlier citation never hides
65
- // this project's own evidence.
66
- function withinProject(read, projectId) {
70
+ // this project's own evidence. A turn is also the reader's only when it worked
71
+ // under the task's own FLA (or, for a plain session, under none): the Provider
72
+ // already leaves out every other FLA's turns, and this checks it again.
73
+ function withinReader(read, task) {
74
+ const projectId = task.personalProjectId ?? null;
75
+ const agentId = task.projectAgentId ?? null;
67
76
  const visible = id => (id ?? null) === projectId;
68
- const turns = read.turns.map(turn => visible(turn.personal_project_id) ? turn
69
- : { ...turn, hidden: true, messages: [] });
70
- const items = read.items.map(item => ({ ...item, sources: itemSources(item).filter(source => visible(source.origin_project_id)) }))
77
+ const own = turn => visible(turn.personal_project_id) && (turn.project_agent_id ?? null) === agentId;
78
+ const turns = read.turns.map(turn => own(turn) ? turn : { ...turn, hidden: true, messages: [] });
79
+ const hiddenTasks = new Set(turns.filter(turn => turn.hidden).map(turn => turn.task_id));
80
+ const items = read.items.map(item => ({ ...item, sources: itemSources(item)
81
+ .filter(source => visible(source.origin_project_id) && !hiddenTasks.has(source.task_id)) }))
71
82
  .filter(item => item.sources.length).map(item => ({ ...item, ...item.sources[0] }));
72
83
  return { ...read, turns, items, projects: (read.projects ?? []).filter(project => project.id === projectId) };
73
84
  }
@@ -1,6 +1,7 @@
1
1
  import { deferredTurnReceipt, MAX_LIST_EPISODES, readEpisodeReceipts, readTurnReceipt, renderTurnReceipt, savedEpisodeIds }
2
2
  from '../agents/turn-receipt.js';
3
3
  import { withReceiptLines, withTurnReceipt } from '../agents/identity-receipt.js';
4
+ import { taskKnowledgeReader } from './knowledge-reader.js';
4
5
  import { formalTask, sessionMigrationLine, sessionMigrationOffer } from './session-knowledge-migration.js';
5
6
 
6
7
  // When a turn's receipt reaches a reply, exactly once (rec#20). The Provider
@@ -29,7 +30,8 @@ export async function checkpointTurnReceipt(application, task, { memory = null,
29
30
  async function savedTurnReceipt(application, task, results, { memory, agentName }) {
30
31
  if (!savedEpisodeIds(results).length) return memory ? readTurnReceipt(application, [], { memory, agentName }) : null;
31
32
  try {
32
- const receipt = await readTurnReceipt(application, results, { memory, agentName, session: taskSession(task) });
33
+ const receipt = await readTurnReceipt(application, results, { memory, agentName, session: taskSession(task),
34
+ reader: taskKnowledgeReader(task) });
33
35
  if (await application.taskContextRegistry.claimTurnReceipt(task.token, task.sourceApplication)) return receipt;
34
36
  // A later entry already showed these items; never repeat them.
35
37
  return memory ? readTurnReceipt(application, [], { memory, agentName }) : null;
@@ -60,7 +62,8 @@ async function unreadTurnReceipt(application, task) {
60
62
  try {
61
63
  const read = [];
62
64
  for (const item of unread) {
63
- read.push({ item, entries: (await readEpisodeReceipts(application, savedEpisodeIds(item.capture_results))).entries });
65
+ read.push({ item, entries: (await readEpisodeReceipts(application, savedEpisodeIds(item.capture_results),
66
+ { reader: taskKnowledgeReader(task) })).entries });
64
67
  }
65
68
  const claimed = new Set(await application.taskContextRegistry.claimUnreadTurnReceipts(task.token,
66
69
  unread.map(item => item.receipt_id), task.sourceApplication));
@@ -2,14 +2,17 @@ import { buildWritingTasteProfile } from './writing-taste-profile.js';
2
2
 
3
3
  const MAX_GRAPH_PAGES = 20;
4
4
 
5
+ // ownerReads: the console's human-review port, so the person's profile keeps
6
+ // the preferences given to one FLA and their conflicts; without it the graph
7
+ // and the conflicts read as an Agent.
5
8
  export async function getWritingTasteProfile(application, {
6
9
  personalSpaceId,
7
10
  personalProjectId = null,
8
11
  limit = 500
9
- } = {}) {
12
+ } = {}, ownerReads = null) {
10
13
  const [graph, conflictRecords] = await Promise.all([
11
- readPersonalGraph(application, { personalSpaceId, limit }),
12
- readPreferenceConflicts(application, personalSpaceId)
14
+ readPersonalGraph(application, { personalSpaceId, limit }, ownerReads),
15
+ readPreferenceConflicts(application, personalSpaceId, ownerReads)
13
16
  ]);
14
17
  return buildWritingTasteProfile({
15
18
  graph,
@@ -19,11 +22,14 @@ export async function getWritingTasteProfile(application, {
19
22
  });
20
23
  }
21
24
 
22
- async function readPreferenceConflicts(application, personalSpaceId) {
25
+ async function readPreferenceConflicts(application, personalSpaceId, ownerReads) {
23
26
  const records = new Map();
24
27
  const pageSize = 500;
28
+ const read = ownerReads
29
+ ? offset => ownerReads.preferenceConflicts({ personalSpaceId, status: 'ai_pending', limit: pageSize, offset })
30
+ : offset => application.personal.listPreferenceConflicts(personalSpaceId, 'ai_pending', pageSize, offset);
25
31
  for (let page = 0; page < MAX_GRAPH_PAGES; page++) {
26
- const items = await application.personal.listPreferenceConflicts(personalSpaceId, 'ai_pending', pageSize, page * pageSize);
32
+ const items = await read(page * pageSize);
27
33
  if (!Array.isArray(items)) throw new Error('Invalid writing taste conflict history');
28
34
  const size = records.size;
29
35
  for (const item of items) records.set(item.id, item);
@@ -36,7 +42,7 @@ async function readPreferenceConflicts(application, personalSpaceId) {
36
42
  // Writing-taste maturity counts every durable rule, so a truncated first page
37
43
  // would understate readiness forever. Follow the provider offset cursor until
38
44
  // it stops, keeping the read bounded by MAX_GRAPH_PAGES.
39
- async function readPersonalGraph(application, { personalSpaceId, limit }) {
45
+ async function readPersonalGraph(application, { personalSpaceId, limit }, ownerReads) {
40
46
  const nodes = [];
41
47
  const edges = [];
42
48
  const seenNodes = new Set();
@@ -49,7 +55,7 @@ async function readPersonalGraph(application, { personalSpaceId, limit }) {
49
55
  spaceId: personalSpaceId,
50
56
  limit,
51
57
  offset
52
- });
58
+ }, ownerReads);
53
59
  appendUnique(nodes, seenNodes, result?.nodes);
54
60
  appendUnique(edges, seenEdges, result?.edges);
55
61
  truncated = Boolean(result?.truncated);
@@ -29,6 +29,7 @@ export async function handleApiRequest({
29
29
  dataFormatMigrations = null,
30
30
  knowledgeHardDelete = null,
31
31
  knowledgeScope = null,
32
+ knowledgeOwnerReads = null,
32
33
  knowledgeTags = null,
33
34
  modelRoleSettings = null,
34
35
  readModelEvaluation = null,
@@ -181,7 +182,7 @@ export async function handleApiRequest({
181
182
  await handleKnowledgeTagsRequest({ request, response, url, app, tagsConsole: knowledgeTags }) ||
182
183
  await handleJudgmentApiRequest({ request, response, url, app, undoConsole: judgmentUndo }) ||
183
184
  await handleEmployeeApiRequest({ request, response, url, app }) ||
184
- await handleGraphApiRequest({ request, response, url, app });
185
+ await handleGraphApiRequest({ request, response, url, app, ownerReads: knowledgeOwnerReads });
185
186
  if (system?.withGraphRuntimeLease && (
186
187
  url.pathname.startsWith('/api/') || url.pathname.startsWith('/employee-workspaces/')
187
188
  )) {
@@ -16,7 +16,10 @@ export async function handleGraphApiRequest({
16
16
  request,
17
17
  response,
18
18
  url,
19
- app
19
+ app,
20
+ // The console's human-review port for the person's full knowledge reads
21
+ // (src/knowledge-owner-reads); without it these routes read as an Agent.
22
+ ownerReads = null
20
23
  }) {
21
24
  if (await handleAgentAttentionRequest({ request, response, url, app })) return true;
22
25
  if (await handleTaskEventsRequest({ request, response, url, app })) return true;
@@ -24,8 +27,8 @@ export async function handleGraphApiRequest({
24
27
  if (await handleOccupationRequest({ request, response, url, app })) return true;
25
28
  if (await handleTopicProposalsRequest({ request, response, url, app })) return true;
26
29
  if (await handleAgentScoreCardRequest({ request, response, url, app })) return true;
27
- if (await handleKnowledgeItemRequest({ request, response, url, app })) return true;
28
- if (await handleSessionRecordsRequest({ request, response, url, app })) return true;
30
+ if (await handleKnowledgeItemRequest({ request, response, url, app, ownerReads })) return true;
31
+ if (await handleSessionRecordsRequest({ request, response, url, app, ownerReads })) return true;
29
32
  if (await handleCaptureChangeRequest({ request, response, url, app })) return true;
30
33
  if (await handleCaptureOnboardingRequest({ request, response, url, app })) return true;
31
34
  if (url.pathname === '/api/agent-conversations/query' && request.method === 'POST') {
@@ -93,7 +96,7 @@ export async function handleGraphApiRequest({
93
96
  personalProjectId: url.searchParams.get('personalProjectId'),
94
97
  limit: numberParam(url, 'limit', 500),
95
98
  offset: nonNegativeNumberParam(url, 'offset', null)
96
- }));
99
+ }, ownerReads));
97
100
  return true;
98
101
  }
99
102
  if (url.pathname === '/api/writing-taste-profile' && request.method === 'GET') {
@@ -101,7 +104,7 @@ export async function handleGraphApiRequest({
101
104
  personalSpaceId: url.searchParams.get('personalSpaceId'),
102
105
  personalProjectId: url.searchParams.get('personalProjectId'),
103
106
  limit: numberParam(url, 'limit', 500)
104
- }));
107
+ }, ownerReads));
105
108
  return true;
106
109
  }
107
110
  if (url.pathname === '/api/preference-conflicts' && request.method === 'GET') {
@@ -109,7 +112,7 @@ export async function handleGraphApiRequest({
109
112
  personalSpaceId: url.searchParams.get('personalSpaceId'),
110
113
  status: url.searchParams.get('status'),
111
114
  limit: numberParam(url, 'limit', 500)
112
- }));
115
+ }, ownerReads));
113
116
  return true;
114
117
  }
115
118
  if (
@@ -119,7 +122,7 @@ export async function handleGraphApiRequest({
119
122
  sendJson(response, 200, await app.deferPreferenceConflict({
120
123
  ...(await readJson(request)),
121
124
  operationActor: 'agent'
122
- }));
125
+ }, ownerReads));
123
126
  return true;
124
127
  }
125
128
  const completedPreferenceConflict = url.pathname.match(
@@ -130,7 +133,7 @@ export async function handleGraphApiRequest({
130
133
  ...(await readJson(request)),
131
134
  conflictId: decodeURIComponent(completedPreferenceConflict[1]),
132
135
  operationActor: 'human'
133
- }));
136
+ }, ownerReads));
134
137
  return true;
135
138
  }
136
139
  const assignment = url.pathname.match(
@@ -644,7 +647,7 @@ export async function handleGraphApiRequest({
644
647
  sendJson(response, 200, await app.listPersonalReviewQueue({
645
648
  personalSpaceId: url.searchParams.get('personalSpaceId'),
646
649
  status: url.searchParams.get('status') ?? 'pending'
647
- }));
650
+ }, ownerReads));
648
651
  return true;
649
652
  }
650
653
  const personalDecision = url.pathname.match(/^\/api\/personal-review\/([^/]+)\/decision$/);
@@ -653,7 +656,7 @@ export async function handleGraphApiRequest({
653
656
  sendJson(response, 200, await app.reviewPersonalDraft(parsePersonalDraftDecision({
654
657
  decision: body?.decision,
655
658
  draftId: decodeURIComponent(personalDecision[1])
656
- })));
659
+ }), ownerReads));
657
660
  return true;
658
661
  }
659
662
  if (url.pathname === '/api/review' && request.method === 'GET') {
@@ -10,17 +10,22 @@ const ITEM_PATH = /^\/api\/knowledge\/(entity|relationship)\/([^/]+)$/;
10
10
  // Content edits and deactivation use the existing item PATCH with the version
11
11
  // the page read; tags use the tag vocabulary routes; scope writes are the
12
12
  // person's own (knowledge-scope-api-router.js).
13
- export async function handleKnowledgeItemRequest({ request, response, url, app }) {
13
+ // ownerReads: the console's human-review port. The item view, a turn's full
14
+ // list and a session's held items show every FLA's items, so they are read
15
+ // only through it.
16
+ export async function handleKnowledgeItemRequest({ request, response, url, app, ownerReads = null }) {
14
17
  if (request.method !== 'GET') return false;
15
18
  if (url.pathname === '/api/knowledge/turn-receipt') {
16
- sendJson(response, 200, await readTurnReceiptItems(app, {
19
+ if (!ownerReads) return ownerReadsUnavailable(response);
20
+ sendJson(response, 200, await readTurnReceiptItems(app, ownerReads, {
17
21
  personalSpaceId: url.searchParams.get('personalSpaceId'),
18
22
  episodeIds: (url.searchParams.get('episodes') ?? '').split(',').filter(Boolean) }));
19
23
  return true;
20
24
  }
21
25
  if (url.pathname === '/api/knowledge/session-migration') {
26
+ if (!ownerReads) return ownerReadsUnavailable(response);
22
27
  response.setHeader('Cache-Control', 'no-store');
23
- sendJson(response, 200, await readSessionMigration(app, {
28
+ sendJson(response, 200, await readSessionMigration(app, ownerReads, {
24
29
  personalSpaceId: url.searchParams.get('personalSpaceId'), sourceApplication: url.searchParams.get('client'),
25
30
  sessionId: url.searchParams.get('sessionId'), projectId: url.searchParams.get('projectId'),
26
31
  offset: url.searchParams.get('offset') }));
@@ -28,9 +33,17 @@ export async function handleKnowledgeItemRequest({ request, response, url, app }
28
33
  }
29
34
  const match = url.pathname.match(ITEM_PATH);
30
35
  if (!match) return false;
36
+ if (!ownerReads) return ownerReadsUnavailable(response);
31
37
  const queryTags = url.searchParams.has('query_tags') ? JSON.parse(url.searchParams.get('query_tags')) : undefined;
32
38
  if (queryTags !== undefined) assertJsonObject(queryTags, 'query_tags');
33
- sendJson(response, 200, await readKnowledgeItem(app, { itemKind: match[1], itemId: decodeURIComponent(match[2]),
39
+ sendJson(response, 200, await readKnowledgeItem(app, ownerReads, { itemKind: match[1], itemId: decodeURIComponent(match[2]),
34
40
  personalSpaceId: url.searchParams.get('personalSpaceId'), ...(queryTags === undefined ? {} : { queryTags }) }));
35
41
  return true;
36
42
  }
43
+
44
+ // Without a local installation's human-review channel there is no full read;
45
+ // the console's knowledge pages answer this instead of a partial view.
46
+ export function ownerReadsUnavailable(response) {
47
+ sendJson(response, 503, { error: 'Reading knowledge in full needs a local FULI installation' });
48
+ return true;
49
+ }
@@ -1,7 +1,7 @@
1
1
  import { readJson, sendJson } from './response.js';
2
2
  import { refuseRemoteDecision } from './request-policy.js';
3
3
  import { nonEmptyText, positiveInteger } from '../validation/values.js';
4
- import { applyTagGovernance, personKnowledgeTagChange } from '../graphiti/knowledge-tags.js';
4
+ import { applyTagGovernance, personKnowledgeTagChange, readTagsAcrossProjects } from '../graphiti/knowledge-tags.js';
5
5
 
6
6
  const TAGS_PATH = /^\/api\/knowledge-tags(?:\/(metrics|vocabulary|detail|governance\/preview|governance))?$/;
7
7
  const MAX_RESOLVE_LIMIT = 20;
@@ -22,12 +22,13 @@ export async function handleKnowledgeTagsRequest({ request, response, url, app,
22
22
  const route = match[1] ?? '';
23
23
  const scope = { personalSpaceId: url.searchParams.get('personalSpaceId'),
24
24
  personalProjectId: nonEmptyText(url.searchParams.get('personalProjectId')) };
25
- if (request.method === 'GET') return read(route, { response, url, app, scope });
25
+ if (request.method === 'GET') return read(route, { response, url, app, scope, tagsConsole });
26
26
  if (request.method !== 'POST' || !['', 'governance', 'governance/preview'].includes(route)) return false;
27
27
  response.setHeader('Cache-Control', 'no-store');
28
28
  if (route === 'governance/preview') {
29
- sendJson(response, 200, await app.knowledgeTags('governance_preview', { ...(await readJson(request)),
30
- allProjects: true }));
29
+ if (!tagsConsole) return acrossProjectsUnavailable(response);
30
+ sendJson(response, 200, await readTagsAcrossProjects(app, tagsConsole, 'governance_preview',
31
+ await readJson(request)));
31
32
  return true;
32
33
  }
33
34
  if (refuseRemoteDecision(request, response, 'Tags are changed by the person only on this computer')) return true;
@@ -42,19 +43,25 @@ export async function handleKnowledgeTagsRequest({ request, response, url, app,
42
43
  return true;
43
44
  }
44
45
 
45
- async function read(route, { response, url, app, scope }) {
46
+ // The owner's reads across every project count every FLA's links, so they go
47
+ // on the console's human-review channel (readTagsAcrossProjects).
48
+ async function read(route, { response, url, app, scope, tagsConsole }) {
46
49
  const query = url.searchParams;
50
+ const acrossProjects = route === 'vocabulary' || route === 'detail'
51
+ || (route === 'metrics' && query.get('allProjects') === 'true');
52
+ if (acrossProjects && !tagsConsole) return acrossProjectsUnavailable(response);
47
53
  if (route === 'metrics') {
48
- sendJson(response, 200, await app.knowledgeTags('metrics', { ...scope,
49
- allProjects: query.get('allProjects') === 'true', ...numberParam(url, 'days', MAX_METRIC_DAYS) }));
54
+ const input = { ...scope, ...numberParam(url, 'days', MAX_METRIC_DAYS) };
55
+ sendJson(response, 200, acrossProjects ? await readTagsAcrossProjects(app, tagsConsole, 'metrics', input)
56
+ : await app.knowledgeTags('metrics', { ...input, allProjects: false }));
50
57
  } else if (route === 'vocabulary') {
51
- sendJson(response, 200, await app.knowledgeTags('vocabulary', { ...scope, allProjects: true,
58
+ sendJson(response, 200, await readTagsAcrossProjects(app, tagsConsole, 'vocabulary', { ...scope,
52
59
  query: nonEmptyText(query.get('q')), namespace: choice(query.get('namespace'), NAMESPACES, 'namespace'),
53
60
  status: choice(query.get('status'), STATUSES, 'status'), ...numberParam(url, 'limit', MAX_VOCABULARY_PAGE),
54
61
  ...(query.get('offset') && query.get('offset') !== '0'
55
62
  ? numberParam(url, 'offset', MAX_VOCABULARY_OFFSET) : {}) }));
56
63
  } else if (route === 'detail') {
57
- sendJson(response, 200, await app.knowledgeTags('detail', { ...scope, allProjects: true,
64
+ sendJson(response, 200, await readTagsAcrossProjects(app, tagsConsole, 'detail', { ...scope,
58
65
  tagId: query.get('tagId') }));
59
66
  } else if (route === '') {
60
67
  sendJson(response, 200, await app.knowledgeTags('resolve', { ...scope,
@@ -65,6 +72,11 @@ async function read(route, { response, url, app, scope }) {
65
72
  return true;
66
73
  }
67
74
 
75
+ function acrossProjectsUnavailable(response) {
76
+ sendJson(response, 503, { error: 'Reading tags across every project needs a local FULI installation' });
77
+ return true;
78
+ }
79
+
68
80
  function choice(value, allowed, name) {
69
81
  if (value === null || value === '') return undefined;
70
82
  if (!allowed.has(value)) throw new TypeError(`${name} is not one of ${[...allowed].join(', ')}`);
@@ -1,11 +1,15 @@
1
1
  import { sendJson } from './response.js';
2
+ import { ownerReadsUnavailable } from './knowledge-item-api-router.js';
2
3
  import { readSessionRecords } from '../graphiti/session-records.js';
3
4
 
4
5
  // The console's list of what one host session recorded (rec#5 C6). The link
5
- // grants nothing: the Provider authorizes the read for the person.
6
- export async function handleSessionRecordsRequest({ request, response, url, app }) {
6
+ // grants nothing: the Provider authorizes the read for the person, who sees
7
+ // every FLA's items there, so it goes through ownerReads, the console's
8
+ // human-review port.
9
+ export async function handleSessionRecordsRequest({ request, response, url, app, ownerReads = null }) {
7
10
  if (url.pathname !== '/api/session-records' || request.method !== 'GET') return false;
8
- sendJson(response, 200, await readSessionRecords(app, {
11
+ if (!ownerReads) return ownerReadsUnavailable(response);
12
+ sendJson(response, 200, await readSessionRecords(app, ownerReads, {
9
13
  personalSpaceId: url.searchParams.get('personalSpaceId'),
10
14
  sourceApplication: url.searchParams.get('sourceApplication'),
11
15
  sessionId: url.searchParams.get('sessionId') }));
@@ -0,0 +1,51 @@
1
+ import { personalHumanReviewChannel, providerRefusal } from '../graphiti/human-review-channel.js';
2
+ import { graphReadPath, preferenceConflictsPath, publicationDraftsPath } from '../graphiti/knowledge-reader.js';
3
+
4
+ // The person's own full reads of personal knowledge, from the local console:
5
+ // the graph, one item's view, a turn's full receipt, a session's records and
6
+ // what it holds for a migration, the preference conflicts and the publication
7
+ // drafts; and the person's defer and completion of a conflict, which answer as
8
+ // missing to a reader that may not see its items. Knowledge an FLA wrote, and
9
+ // a preference given to one FLA, is that FLA's; the provider shows it to any
10
+ // other reader only with the human-review token this port sends
11
+ // (human-review-channel.js). Without it the provider
12
+ // reads as an Agent and hides it; a wrong token is refused. That proves the
13
+ // local console, not a person's presence (same OS account, as in D-21). Only
14
+ // the console's loopback routes use this module; no MCP or Agent tool module
15
+ // imports it (test/knowledge-owner-reads.test.js).
16
+
17
+ export function knowledgeOwnerReads(dataDir, { send = personalHumanReviewChannel(dataDir) } = {}) {
18
+ const request = async (path, body, method = 'POST', { timeoutMs } = {}) => {
19
+ const { ok, status, payload } = await send(path, body, { review: true, method, ...(timeoutMs ? { timeoutMs } : {}) });
20
+ if (ok) return payload;
21
+ throw providerRefusal(status, payload);
22
+ };
23
+ const draftPath = (personalSpaceId, draftId, suffix = '') => `/v1/publication-drafts/${encodeURIComponent(draftId)}${
24
+ suffix}?${new URLSearchParams({ personal_space_id: personalSpaceId })}`;
25
+ return {
26
+ graph: ({ spaceId, limit, personalProjectId, offset }) =>
27
+ request(graphReadPath(spaceId, { limit, personalProjectId, offset }), null, 'GET'),
28
+ itemView: (body) => request('/v1/knowledge/item-views', body),
29
+ turnReceipt: (body) => request('/v1/knowledge/turn-receipts', body),
30
+ sessionRecords: (body) => request('/v1/session-records', body),
31
+ sessionMigration: (body) => request('/v1/knowledge/session-migrations/preview', body),
32
+ preferenceConflicts: ({ personalSpaceId, status, limit, offset }) =>
33
+ request(preferenceConflictsPath(personalSpaceId, { status, limit, offset }), null, 'GET'),
34
+ publicationDrafts: ({ personalSpaceId, status }) =>
35
+ request(publicationDraftsPath(personalSpaceId, { status }), null, 'GET'),
36
+ // The person's drafts as their submission and its reconciliation read and decide them (the
37
+ // provider client's shape). A draft whose source is not positively plain work (an FLA's, erased,
38
+ // or never recorded here, as a capture made only for a team) is the person's alone, its source
39
+ // and attempt too, so only this channel reads, submits and settles it.
40
+ submissions: {
41
+ listPublicationDrafts: (personalSpaceId, status, { metadataOnly = false } = {}) =>
42
+ request(publicationDraftsPath(personalSpaceId, { status, metadataOnly }), null, 'GET'),
43
+ getPublicationDraft: (personalSpaceId, draftId) => request(draftPath(personalSpaceId, draftId), null, 'GET'),
44
+ decidePublicationDraft: (personalSpaceId, draftId, body, { timeoutMs } = {}) =>
45
+ request(draftPath(personalSpaceId, draftId, '/decision'), body, 'POST', { timeoutMs })
46
+ },
47
+ deferPreferenceConflict: (body) => request('/v1/preference-conflicts/defer', body),
48
+ completePreferenceConflict: (conflictId, body) =>
49
+ request(`/v1/preference-conflicts/${encodeURIComponent(conflictId)}/complete`, body)
50
+ };
51
+ }
@@ -2,8 +2,9 @@ import { personalHumanReviewChannel, providerRefusal } from '../graphiti/human-r
2
2
 
3
3
  // The person's tag changes from the local console (rec#11 D-07 part 2): their
4
4
  // own create, alias, attach and detach, and the governance only they apply
5
- // (approve, merge, split, retire, relations, undo). The Provider records these
6
- // as the person's, so they take the human-review token this port sends
5
+ // (approve, merge, split, retire, relations, undo), and the owner's reads
6
+ // across every project, which count every FLA's links (0.20.1). The Provider
7
+ // records the changes as the person's, so they take the human-review token this port sends
7
8
  // (human-review-channel.js); an Agent's access token alone is refused. That
8
9
  // proves the local console, not a person's presence (same OS account, as in
9
10
  // D-21/D-22). Only the console's loopback routes use this module; no MCP or
@@ -3,4 +3,4 @@
3
3
  // and writes its digest here before publishing (scripts/pin-win-helper.js); a
4
4
  // source checkout has no helper and no pin, so Windows Hello is unavailable there.
5
5
  // The helper is not Authenticode-signed: this digest is its only integrity check.
6
- export const WIN_HELPER_SHA256 = 'efb80b147cd08bb4d699929ead285cec1d60b6384c73a5c0b04afebf917f574e';
6
+ export const WIN_HELPER_SHA256 = '73983fd1843f3ca7bbac0c5722c414fea5da47a6bb08e597423008f7b8ad6e6a';