@unson/brainbase-mcp 0.6.0 → 0.8.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 (148) hide show
  1. package/contracts/foundation/graph-history.sql +634 -0
  2. package/contracts/judgment-value-proof/schema.json +43 -1
  3. package/dist/canonical-task-contract.d.ts +9 -0
  4. package/dist/canonical-task-contract.js +39 -0
  5. package/dist/canonical-task-principal.d.ts +16 -0
  6. package/dist/canonical-task-principal.js +36 -0
  7. package/dist/canonical-task-service.d.ts +251 -0
  8. package/dist/canonical-task-service.js +820 -0
  9. package/dist/cli.d.ts +2 -0
  10. package/dist/cli.js +107 -0
  11. package/dist/company-os-evaluation.d.ts +193 -0
  12. package/dist/company-os-evaluation.js +1150 -0
  13. package/dist/company-os-impact-review.d.ts +248 -0
  14. package/dist/company-os-impact-review.js +663 -0
  15. package/dist/company-os-learning-adoption.d.ts +288 -0
  16. package/dist/company-os-learning-adoption.js +944 -0
  17. package/dist/company-os-objectives.d.ts +63 -0
  18. package/dist/company-os-objectives.js +234 -0
  19. package/dist/company-os-receipt-adapter.d.ts +109 -0
  20. package/dist/company-os-receipt-adapter.js +636 -0
  21. package/dist/constraint-exception-store.d.ts +23 -0
  22. package/dist/constraint-exception-store.js +108 -0
  23. package/dist/constraint-resolution.d.ts +175 -0
  24. package/dist/constraint-resolution.js +922 -0
  25. package/dist/decision-adapter.d.ts +145 -0
  26. package/dist/decision-adapter.js +586 -0
  27. package/dist/durable-wait-http.d.ts +51 -0
  28. package/dist/durable-wait-http.js +497 -0
  29. package/dist/durable-waits.d.ts +234 -0
  30. package/dist/durable-waits.js +944 -0
  31. package/dist/execution-authority-http.d.ts +28 -0
  32. package/dist/execution-authority-http.js +359 -0
  33. package/dist/execution-authority.d.ts +201 -0
  34. package/dist/execution-authority.js +634 -0
  35. package/dist/foundation-authenticated-tools.d.ts +56 -0
  36. package/dist/foundation-authenticated-tools.js +347 -0
  37. package/dist/foundation-catalog.d.ts +26 -0
  38. package/dist/foundation-catalog.js +206 -0
  39. package/dist/foundation-constraint-store.d.ts +50 -0
  40. package/dist/foundation-constraint-store.js +215 -0
  41. package/dist/foundation-graph-http.d.ts +43 -0
  42. package/dist/foundation-graph-http.js +243 -0
  43. package/dist/foundation-graph-write.d.ts +90 -0
  44. package/dist/foundation-graph-write.js +447 -0
  45. package/dist/foundation-http.d.ts +90 -0
  46. package/dist/foundation-http.js +439 -0
  47. package/dist/foundation-public-provider.d.ts +140 -0
  48. package/dist/foundation-public-provider.js +192 -0
  49. package/dist/foundation-store.d.ts +132 -0
  50. package/dist/foundation-store.js +654 -0
  51. package/dist/graph-corrections.d.ts +157 -0
  52. package/dist/graph-corrections.js +620 -0
  53. package/dist/graph-foundation-reader.d.ts +60 -0
  54. package/dist/graph-foundation-reader.js +494 -0
  55. package/dist/graph-retrieval.d.ts +6 -1
  56. package/dist/graph-revision-reader.d.ts +80 -0
  57. package/dist/graph-revision-reader.js +246 -0
  58. package/dist/graph-web-http.d.ts +26 -0
  59. package/dist/graph-web-http.js +215 -0
  60. package/dist/graph-web.d.ts +364 -0
  61. package/dist/graph-web.js +639 -0
  62. package/dist/judgment-dag-composition.d.ts +224 -0
  63. package/dist/judgment-dag-composition.js +731 -0
  64. package/dist/judgment-dag.d.ts +2 -0
  65. package/dist/judgment-dag.js +1 -0
  66. package/dist/judgment-problem-snapshot.d.ts +213 -0
  67. package/dist/judgment-problem-snapshot.js +1073 -0
  68. package/dist/judgment-value-proof-review.d.ts +166 -0
  69. package/dist/judgment-value-proof-review.js +437 -0
  70. package/dist/judgment-value-proof.d.ts +28 -1
  71. package/dist/judgment-value-proof.js +53 -8
  72. package/dist/judgment-view-http.d.ts +22 -0
  73. package/dist/judgment-view-http.js +128 -0
  74. package/dist/judgment-view.d.ts +222 -0
  75. package/dist/judgment-view.js +627 -0
  76. package/dist/knowledge-adapter.d.ts +112 -0
  77. package/dist/knowledge-adapter.js +691 -0
  78. package/dist/knowledge-continuation.d.ts +127 -0
  79. package/dist/knowledge-continuation.js +446 -0
  80. package/dist/knowledge-lookup.d.ts +178 -0
  81. package/dist/knowledge-lookup.js +758 -0
  82. package/dist/local-web-fetch-bridge.d.ts +5 -0
  83. package/dist/local-web-fetch-bridge.js +37 -0
  84. package/dist/local-web-host.d.ts +109 -0
  85. package/dist/local-web-host.js +688 -0
  86. package/dist/local-web-security.d.ts +25 -0
  87. package/dist/local-web-security.js +95 -0
  88. package/dist/ontology-foundation.d.ts +209 -0
  89. package/dist/ontology-foundation.js +1000 -0
  90. package/dist/ontology.d.ts +13 -0
  91. package/dist/ontology.js +14 -0
  92. package/dist/organization-connection.d.ts +164 -0
  93. package/dist/organization-connection.js +428 -0
  94. package/dist/organization-graph.d.ts +15 -0
  95. package/dist/organization-graph.js +24 -4
  96. package/dist/personal-knowledge.d.ts +132 -0
  97. package/dist/personal-knowledge.js +779 -0
  98. package/dist/personal-memory-handover.d.ts +108 -0
  99. package/dist/personal-memory-handover.js +369 -0
  100. package/dist/philosophy-revision-reader.d.ts +85 -0
  101. package/dist/philosophy-revision-reader.js +241 -0
  102. package/dist/portable-graph.d.ts +24 -0
  103. package/dist/portable-graph.js +77 -0
  104. package/dist/problem-candidates.d.ts +149 -0
  105. package/dist/problem-candidates.js +898 -0
  106. package/dist/problem-selection.d.ts +238 -0
  107. package/dist/problem-selection.js +995 -0
  108. package/dist/resource-reservation-http.d.ts +31 -0
  109. package/dist/resource-reservation-http.js +371 -0
  110. package/dist/resource-reservations.d.ts +221 -0
  111. package/dist/resource-reservations.js +577 -0
  112. package/dist/server.d.ts +104 -2
  113. package/dist/server.js +186 -4
  114. package/dist/ssot.d.ts +6 -1
  115. package/dist/ssot.js +63 -5
  116. package/dist/streamable-http.d.ts +42 -0
  117. package/dist/streamable-http.js +288 -0
  118. package/dist/types.d.ts +20 -0
  119. package/dist/value-proof-review-http.d.ts +25 -0
  120. package/dist/value-proof-review-http.js +185 -0
  121. package/dist/world-model.d.ts +199 -0
  122. package/dist/world-model.js +955 -0
  123. package/package.json +230 -3
  124. package/ui/brainbase-tokens.css +56 -0
  125. package/ui/graph-own-share.js +367 -0
  126. package/ui/graph-projects-view.css +23 -0
  127. package/ui/graph-projects-view.js +730 -0
  128. package/ui/graph-registry-view.css +101 -0
  129. package/ui/graph-registry-view.js +804 -0
  130. package/ui/graph-view-shared.css +522 -0
  131. package/ui/graph-view-shared.js +1227 -0
  132. package/ui/judgment-view.css +312 -0
  133. package/ui/judgment-view.js +508 -0
  134. package/ui/local-web-shell.css +396 -0
  135. package/ui/local-web-shell.js +378 -0
  136. package/ui/objective-editor-http-port.js +154 -0
  137. package/ui/objective-editor.css +286 -0
  138. package/ui/objective-editor.js +1586 -0
  139. package/ui/outcome-knowledge.css +50 -14
  140. package/ui/outcome-knowledge.js +15 -1
  141. package/ui/outcome-mana.css +91 -14
  142. package/ui/outcome-mana.js +958 -61
  143. package/ui/value-proof-review.css +504 -0
  144. package/ui/value-proof-review.js +1104 -0
  145. package/ui/workspace-kit.css +485 -0
  146. package/ui/workspace-kit.js +229 -0
  147. package/ui/world-model-view.css +188 -0
  148. package/ui/world-model-view.js +486 -0
@@ -64,7 +64,8 @@ export function createOrganizationGraphClient(config) {
64
64
  return {
65
65
  search: (input) => searchOrganizationGraph(normalized, input),
66
66
  importPortableGraph: (bundle) => importPortableGraph(normalized, bundle),
67
- readPortableGraph: () => readPortableGraph(normalized)
67
+ readPortableGraph: () => readPortableGraph(normalized),
68
+ listPortableGraphs: () => listPortableGraphs(normalized)
68
69
  };
69
70
  }
70
71
  /** Forward the existing Graph retrieval input unchanged inside the request envelope. */
@@ -100,6 +101,21 @@ export async function readPortableGraph(config) {
100
101
  }
101
102
  return readback;
102
103
  }
104
+ /** List the token owner's snapshots. The organization decides the owner; no project or Graph ID is sent. */
105
+ export async function listPortableGraphs(config) {
106
+ const value = await requestJson(config, 'GET', route(config, 'list'));
107
+ const fields = ['graph_id', 'project_code', 'digest', 'created_at'];
108
+ if (!isRecord(value) || typeof value.truncated !== 'boolean' || !Array.isArray(value.bundles)
109
+ || value.bundles.some((entry) => !isRecord(entry) || fields.some((field) => typeof entry[field] !== 'string' || entry[field].trim() === ''))) {
110
+ throw new OrganizationGraphError('organization_graph_response_invalid', 'organization service returned an invalid bundle list');
111
+ }
112
+ return {
113
+ truncated: value.truncated,
114
+ bundles: value.bundles.map((entry) => ({
115
+ graphId: entry.graph_id, projectCode: entry.project_code, digest: entry.digest, createdAt: entry.created_at
116
+ }))
117
+ };
118
+ }
103
119
  /** Validate the privacy boundary before any upload leaves the local process. */
104
120
  export function assertPortableGraphBundle(bundle) {
105
121
  validatePortableGraph(bundle);
@@ -110,7 +126,7 @@ function parseGraphRetrievalResponse(value) {
110
126
  || (value.schemaVersion !== 1 && value.schemaVersion !== 2)
111
127
  || (value.status !== 'ok' && value.status !== 'migration_required')
112
128
  || typeof value.migrationRequired !== 'boolean'
113
- || value.authority !== 'organization_graph'
129
+ || (value.authority !== 'owner_private' && value.authority !== 'organization_graph')
114
130
  || typeof value.query !== 'string'
115
131
  || typeof value.asOf !== 'string'
116
132
  || !['semantic', 'lexical', 'seed'].includes(String(value.method))
@@ -135,7 +151,10 @@ function parseGraphRetrievalResponse(value) {
135
151
  || value.absenceConfirmed !== false) {
136
152
  throw new OrganizationGraphError('organization_graph_response_invalid', 'organization service returned a response outside the OSS GraphRetrievalResponse contract');
137
153
  }
138
- return value;
154
+ // This route searches only the token owner's own snapshot (the owner-private
155
+ // area), never the organization's shared Graph. A service from before the
156
+ // owner_private label answered organization_graph for the same area.
157
+ return { ...value, authority: 'owner_private' };
139
158
  }
140
159
  function parseImportResult(value) {
141
160
  if (!isRecord(value)
@@ -271,7 +290,8 @@ async function withTimeout(operation, controller, timeoutMs) {
271
290
  function route(config, suffix, query) {
272
291
  const base = new URL(config.url);
273
292
  const prefix = base.pathname.replace(/\/+$/u, '');
274
- const routePath = `${prefix}/api/info/graph/portable/${encodeURIComponent(config.graphId)}${suffix ? `/${suffix}` : ''}`;
293
+ const graphPath = suffix === 'list' ? '' : `/${encodeURIComponent(config.graphId)}${suffix ? `/${suffix}` : ''}`;
294
+ const routePath = `${prefix}/api/info/graph/portable${graphPath}`;
275
295
  const endpoint = new URL(routePath || '/', base.origin);
276
296
  for (const [key, value] of Object.entries(query ?? {}))
277
297
  endpoint.searchParams.set(key, value);
@@ -0,0 +1,132 @@
1
+ /** The context header used by the v1 register and search contracts. */
2
+ export declare const PERSONAL_KNOWLEDGE_CONTEXT_HEADER = "X-Brainbase-Personal-Context";
3
+ export declare const PERSONAL_KNOWLEDGE_CONTEXT_VERSION_HEADER = "X-Brainbase-Personal-Context-Version";
4
+ /** Short alias retained for consumers that call this a personal context header. */
5
+ export declare const PERSONAL_CONTEXT_HEADER = "X-Brainbase-Personal-Context";
6
+ export declare const PERSONAL_KNOWLEDGE_CONTRACT_VERSION: 1;
7
+ export declare const PERSONAL_KNOWLEDGE_LOCAL_DIRECTORY = "personal-knowledge-v1";
8
+ export type PersonalKnowledgeScope = 'personal_owned' | 'organization_private';
9
+ export type PersonalKnowledgeStorageMode = 'local' | 'managed_cloud';
10
+ export interface PersonalKnowledgeContext {
11
+ contract_version: typeof PERSONAL_KNOWLEDGE_CONTRACT_VERSION;
12
+ scope: PersonalKnowledgeScope;
13
+ owner_person_id: string;
14
+ organization_id: string | null;
15
+ source_id: string;
16
+ }
17
+ export declare class PersonalKnowledgeContextError extends Error {
18
+ readonly code: string;
19
+ readonly field?: string;
20
+ constructor(message: string, code?: string, field?: string);
21
+ }
22
+ /** Validate and return a copy of a strict v1 context object. */
23
+ export declare function validatePersonalKnowledgeContext(value: unknown): PersonalKnowledgeContext;
24
+ export declare const assertPersonalKnowledgeContext: typeof validatePersonalKnowledgeContext;
25
+ /** Encode a trusted expected context for `X-Brainbase-Personal-Context`. */
26
+ export declare function encodePersonalKnowledgeContextHeader(value: unknown): string;
27
+ export declare const encodeExpectedPersonalKnowledgeContextHeader: typeof encodePersonalKnowledgeContextHeader;
28
+ /** Decode and strictly validate a v1 context header. */
29
+ export declare function decodePersonalKnowledgeContextHeader(value: unknown): PersonalKnowledgeContext;
30
+ export declare const decodeExpectedPersonalKnowledgeContextHeader: typeof decodePersonalKnowledgeContextHeader;
31
+ /** Assert that two contexts identify exactly the same source of truth. */
32
+ export declare function assertPersonalKnowledgeContextMatch(expected: unknown, actual: unknown): PersonalKnowledgeContext;
33
+ export interface PersonalKnowledgeEvent {
34
+ event_id: string;
35
+ body: string;
36
+ body_hash: string;
37
+ occurred_at?: string;
38
+ captured_at?: string;
39
+ source?: unknown;
40
+ source_pointer?: unknown;
41
+ parent_episode_id?: string | null;
42
+ permission_snapshot?: Record<string, unknown>;
43
+ sensitivity?: string;
44
+ kind?: string;
45
+ type?: string;
46
+ tags?: string[];
47
+ metadata?: Record<string, unknown>;
48
+ [key: string]: unknown;
49
+ }
50
+ export type PersonalKnowledgeEventInput = Omit<PersonalKnowledgeEvent, 'body_hash'> & {
51
+ body_hash?: string;
52
+ content?: string;
53
+ };
54
+ /** Normalize a caller event without allowing caller-controlled identity fields. */
55
+ export declare function normalizePersonalKnowledgeEvent(value: unknown): PersonalKnowledgeEvent;
56
+ export declare function normalizePersonalKnowledgeSearchInput(query: string, limit?: number): {
57
+ query: string;
58
+ limit: number;
59
+ };
60
+ export interface PersonalKnowledgeContextEnvelope {
61
+ context: PersonalKnowledgeContext;
62
+ }
63
+ export interface PersonalKnowledgeRegisterEnvelope extends PersonalKnowledgeContextEnvelope {
64
+ event: PersonalKnowledgeEvent;
65
+ }
66
+ export interface PersonalKnowledgeSearchEnvelope extends PersonalKnowledgeContextEnvelope {
67
+ results: PersonalKnowledgeEvent[];
68
+ }
69
+ export interface PersonalKnowledgeStore {
70
+ readonly mode: 'local';
71
+ readonly dataDir: string;
72
+ getContext(): Promise<PersonalKnowledgeContextEnvelope>;
73
+ register(event: PersonalKnowledgeEventInput): Promise<PersonalKnowledgeRegisterEnvelope>;
74
+ search(query: string, limit?: number): Promise<PersonalKnowledgeSearchEnvelope>;
75
+ }
76
+ export interface PersonalKnowledgeStoreOptions {
77
+ /** Parent Personal OS directory. The v1 store always uses a child directory. */
78
+ dataDir?: string;
79
+ /** Trusted context from configuration; never a model-controlled MCP argument. */
80
+ context?: PersonalKnowledgeContext;
81
+ ownerPersonId?: string;
82
+ sourceId?: string;
83
+ }
84
+ export declare function createLocalPersonalKnowledgeStore(options?: PersonalKnowledgeStoreOptions): PersonalKnowledgeStore;
85
+ export declare const createPersonalKnowledgeStore: typeof createLocalPersonalKnowledgeStore;
86
+ export interface LocalPersonalKnowledgeSnapshot extends PersonalKnowledgeContextEnvelope {
87
+ events: PersonalKnowledgeEvent[];
88
+ }
89
+ /**
90
+ * Read the local v1 store without creating it. Returns undefined when the
91
+ * store has never been created; a half-created store is an error.
92
+ */
93
+ export declare function readLocalPersonalKnowledgeEvents(options?: {
94
+ dataDir?: string;
95
+ }): Promise<LocalPersonalKnowledgeSnapshot | undefined>;
96
+ /** True when the value is a timestamp the v1 event contract accepts. */
97
+ export declare function isPersonalKnowledgeTimestamp(value: unknown): value is string;
98
+ export interface PersonalKnowledgeClientOptions {
99
+ mode: PersonalKnowledgeStorageMode;
100
+ apiUrl: string;
101
+ expectedContext: PersonalKnowledgeContext;
102
+ token?: string;
103
+ getToken?: () => Promise<string>;
104
+ tokenManager?: {
105
+ getToken(): Promise<string>;
106
+ };
107
+ fetch?: FetchLike;
108
+ }
109
+ type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
110
+ export declare class PersonalKnowledgeClientError extends Error {
111
+ readonly status: number | null;
112
+ readonly responseBody: unknown;
113
+ constructor(message: string, options?: {
114
+ status?: number | null;
115
+ responseBody?: unknown;
116
+ });
117
+ }
118
+ export declare function normalizePersonalKnowledgeApiUrl(apiUrl: string, mode: PersonalKnowledgeStorageMode): string;
119
+ export declare class PersonalKnowledgeClient {
120
+ readonly mode: PersonalKnowledgeStorageMode;
121
+ readonly apiUrl: string;
122
+ readonly expectedContext: PersonalKnowledgeContext;
123
+ private readonly getToken;
124
+ private readonly fetchImpl;
125
+ constructor(options: PersonalKnowledgeClientOptions);
126
+ getContext(): Promise<PersonalKnowledgeContextEnvelope>;
127
+ register(input: PersonalKnowledgeEventInput): Promise<PersonalKnowledgeRegisterEnvelope>;
128
+ search(query: string, limit?: number): Promise<PersonalKnowledgeSearchEnvelope>;
129
+ private request;
130
+ }
131
+ export declare function createPersonalKnowledgeClient(options: PersonalKnowledgeClientOptions): PersonalKnowledgeClient;
132
+ export {};