@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
@@ -0,0 +1,199 @@
1
+ import { type FoundationDefinition, type FoundationAcl, type FoundationAdoptionState, type FoundationEpistemicState, type FoundationPeriod, type FoundationProvenance, type FoundationRevision, type FoundationUse, type FoundationValidationResult, type DecisionRevision, type ModelDefinition, type VariableDefinition } from './ontology-foundation.js';
2
+ /**
3
+ * The world-model helpers are deliberately independent of storage. Definitions
4
+ * belong to the shared foundation catalog; observations and adoption records are
5
+ * values that reference an exact definition revision. A caller can therefore
6
+ * pass these records through the canonical SSOT transaction without introducing
7
+ * a second lock or definition authority.
8
+ */
9
+ export declare const WORLD_MODEL_CONTRACT_VERSION: "0.1.0";
10
+ export declare const WORLD_MODEL_RECORD_CATALOG_VERSION: 1;
11
+ /** Evidence records are sidecar data committed with the canonical aggregate. */
12
+ export declare const WORLD_MODEL_EVIDENCE_SIDECAR: "evidence/world-model.json";
13
+ export type WorldModelScalar = string | number | boolean;
14
+ export type WorldModelValue = WorldModelScalar | readonly WorldModelValue[] | {
15
+ readonly [key: string]: WorldModelValue;
16
+ };
17
+ export interface WorldModelObservationInput {
18
+ id: string;
19
+ variableRef: FoundationRevision;
20
+ subjectId: string;
21
+ value: WorldModelValue;
22
+ /** When the observed event happened. */
23
+ occurredAt: string;
24
+ /** The interval for which the value is valid, which may differ from occurredAt. */
25
+ period: FoundationPeriod;
26
+ /** When Brainbase recorded the observation. */
27
+ recordedAt: string;
28
+ sourceRef: FoundationProvenance;
29
+ /** A correction creates a new observation and points at the old one. */
30
+ supersedes?: string;
31
+ }
32
+ export interface WorldModelObservation extends WorldModelObservationInput {
33
+ readonly id: string;
34
+ readonly variableRef: FoundationRevision;
35
+ readonly subjectId: string;
36
+ readonly value: WorldModelValue;
37
+ readonly occurredAt: string;
38
+ readonly period: FoundationPeriod;
39
+ readonly recordedAt: string;
40
+ readonly sourceRef: FoundationProvenance;
41
+ readonly supersedes?: string;
42
+ }
43
+ export type WorldModelValidationIssueCode = 'MISSING_FIELD' | 'INVALID_FIELD' | 'INVALID_TIMESTAMP' | 'INVALID_PERIOD' | 'INVALID_VARIABLE_REFERENCE' | 'VARIABLE_VALUE_KIND_MISMATCH' | 'OBSERVATION_SCOPE_MISMATCH' | 'OBSERVATION_PERIOD_MISMATCH' | 'RECORDED_BEFORE_OCCURRED' | 'INVALID_CORRECTION_REFERENCE' | 'MISSING_SOURCE' | 'MODEL_CONTRACT_INVALID' | 'MISSING_APPROVAL_REFERENCE' | 'INVALID_APPROVAL_REFERENCE' | 'MODEL_DIGEST_MISMATCH';
44
+ export interface WorldModelValidationIssue {
45
+ readonly code: WorldModelValidationIssueCode;
46
+ readonly path: string;
47
+ readonly message: string;
48
+ }
49
+ export interface WorldModelValidationResult {
50
+ readonly valid: boolean;
51
+ readonly status: 'valid' | 'invalid';
52
+ readonly issues: readonly WorldModelValidationIssue[];
53
+ }
54
+ /**
55
+ * A candidate snapshot is intentionally not a FoundationDefinition. It
56
+ * captures the candidate-store state at the moment a model is proposed so that
57
+ * adopting a model never overwrites the original hypothesis or ACL.
58
+ */
59
+ export interface CandidateModelSnapshot {
60
+ readonly candidateId: string;
61
+ readonly hypothesis: string;
62
+ readonly evidenceIds: readonly string[];
63
+ readonly acl: FoundationAcl;
64
+ readonly epistemicState: Extract<FoundationEpistemicState, 'unverified' | 'hypothesis'>;
65
+ }
66
+ export interface ModelAdoptionInput {
67
+ readonly adoptionId: string;
68
+ readonly modelRef: FoundationRevision;
69
+ readonly candidate: CandidateModelSnapshot;
70
+ readonly adoptionState: Extract<FoundationAdoptionState, 'proposed' | 'approved'>;
71
+ readonly authorizedUse: FoundationUse;
72
+ readonly adoptedAt: string;
73
+ /** Digest of the exact Model definition used for this adoption. */
74
+ readonly modelDigest?: string;
75
+ readonly approvalRef?: DecisionRevision;
76
+ }
77
+ export interface ModelAdoptionRecord extends Omit<ModelAdoptionInput, 'modelDigest'> {
78
+ readonly modelRef: FoundationRevision;
79
+ readonly candidate: CandidateModelSnapshot;
80
+ readonly adoptionState: Extract<FoundationAdoptionState, 'proposed' | 'approved'>;
81
+ readonly authorizedUse: FoundationUse;
82
+ readonly adoptedAt: string;
83
+ readonly modelDigest: string;
84
+ readonly approvalRef?: DecisionRevision;
85
+ }
86
+ /**
87
+ * This is an evidence-sidecar catalog, not part of the canonical Graph
88
+ * aggregate. Variable and Model definitions continue to be resolved by the
89
+ * foundation catalog, while this catalog holds immutable observations and
90
+ * candidate adoption references that point back to exact definition revisions.
91
+ */
92
+ export interface WorldModelRecordCatalog {
93
+ readonly version: typeof WORLD_MODEL_RECORD_CATALOG_VERSION;
94
+ readonly observations: readonly WorldModelObservation[];
95
+ readonly adoptions: readonly ModelAdoptionRecord[];
96
+ }
97
+ export interface WorldModelStoreContext {
98
+ /** Identity resolved by the trusted auth boundary. */
99
+ readonly principal: string;
100
+ }
101
+ export interface WorldModelFoundationRecord {
102
+ readonly definition: FoundationDefinition;
103
+ readonly digest: string;
104
+ }
105
+ /**
106
+ * Structural contract implemented by the shared FoundationRevisionStore. It
107
+ * is local to this module so world-model can depend on the small public store
108
+ * surface without introducing a second definition catalog. Transactional
109
+ * foundation resolution is implemented below from the aggregate already held
110
+ * by mutatePersonalOsWithSidecar; the normal read method must not be
111
+ * re-entered while that lock is held.
112
+ */
113
+ export interface WorldModelFoundationStore {
114
+ create(definition: FoundationDefinition, context: WorldModelStoreContext): Promise<FoundationRevision & {
115
+ readonly digest: string;
116
+ }>;
117
+ read(reference: FoundationRevision, context: WorldModelStoreContext): Promise<WorldModelFoundationRecord | null>;
118
+ }
119
+ /**
120
+ * Approval resolution is the world-model adapter for the existing
121
+ * constraint-resolution DecisionRevisionReader contract. The adapter must
122
+ * resolve the exact decision revision, verify that it actually approves the
123
+ * exact Model revision, and enforce the current authorization boundary. A
124
+ * mere decision-existence check is not sufficient to return true here.
125
+ */
126
+ export interface WorldModelApprovalReader {
127
+ isApproved(request: {
128
+ readonly approvalRef: DecisionRevision;
129
+ readonly modelRef: FoundationRevision;
130
+ readonly context: WorldModelStoreContext;
131
+ }): Promise<boolean>;
132
+ }
133
+ export interface WorldModelObservationQuery {
134
+ readonly variableRef?: FoundationRevision;
135
+ readonly subjectId?: string;
136
+ readonly supersedes?: string;
137
+ }
138
+ export type ModelAdoptionStoreInput = Omit<ModelAdoptionInput, 'candidate' | 'modelRef'>;
139
+ export type WorldModelStoreErrorCode = 'invalid_input' | 'not_found' | 'revision_conflict' | 'authorization_denied' | 'unsupported_graph' | 'corrupt_record' | 'readback_mismatch' | 'approval_reference_unresolved';
140
+ export declare class WorldModelStoreError extends Error {
141
+ readonly code: WorldModelStoreErrorCode;
142
+ constructor(code: WorldModelStoreErrorCode, message: string);
143
+ }
144
+ export interface WorldModelRecordStore {
145
+ createVariable(variable: VariableDefinition, context: WorldModelStoreContext): Promise<FoundationRevision & {
146
+ readonly digest: string;
147
+ }>;
148
+ createModel(model: ModelDefinition, context: WorldModelStoreContext): Promise<FoundationRevision & {
149
+ readonly digest: string;
150
+ }>;
151
+ readModel(reference: FoundationRevision, context: WorldModelStoreContext): Promise<ModelDefinition | null>;
152
+ saveObservation(input: WorldModelObservationInput, context: WorldModelStoreContext): Promise<WorldModelObservation>;
153
+ readObservation(id: string, context: WorldModelStoreContext): Promise<WorldModelObservation | null>;
154
+ listObservations(query: WorldModelObservationQuery | undefined, context: WorldModelStoreContext): Promise<readonly WorldModelObservation[]>;
155
+ saveModelAdoption(candidate: CandidateModelSnapshot, modelRef: FoundationRevision, adoption: ModelAdoptionStoreInput, context: WorldModelStoreContext): Promise<ModelAdoptionRecord>;
156
+ readModelAdoption(adoptionId: string, context: WorldModelStoreContext): Promise<ModelAdoptionRecord | null>;
157
+ listModelAdoptions(context: WorldModelStoreContext): Promise<readonly ModelAdoptionRecord[]>;
158
+ }
159
+ export declare class WorldModelValidationError extends Error {
160
+ readonly issues: readonly WorldModelValidationIssue[];
161
+ constructor(issues: readonly WorldModelValidationIssue[]);
162
+ }
163
+ /**
164
+ * Validates and clones an observation before it crosses a storage boundary.
165
+ * The returned value is deeply frozen, while the input remains untouched.
166
+ */
167
+ export declare function normalizeWorldModelObservation(input: WorldModelObservationInput): WorldModelObservation;
168
+ /**
169
+ * Checks whether an already normalized observation is compatible with the
170
+ * exact Variable definition it references. This does not infer a value or
171
+ * upgrade an observation from inferred to observed.
172
+ */
173
+ export declare function validateWorldModelObservation(observation: WorldModelObservation, variable: VariableDefinition): WorldModelValidationResult;
174
+ /**
175
+ * Delegates Model validation to the shared ontology contract. The wrapper
176
+ * keeps world-model callers from importing ontology internals while retaining
177
+ * the contract's distinction between draft, judgment, evaluation, and
178
+ * execution use.
179
+ */
180
+ export declare function validateWorldModelModel(model: ModelDefinition, use?: FoundationUse): FoundationValidationResult;
181
+ /**
182
+ * Creates a durable adoption record without mutating the candidate or Model.
183
+ * A candidate may only produce an unverified/hypothesis Model record; adopting
184
+ * it cannot silently turn it into a verified claim.
185
+ */
186
+ export declare function retainCandidateModel(candidate: CandidateModelSnapshot, model: ModelDefinition, adoption: Omit<ModelAdoptionInput, 'candidate' | 'modelRef'> & {
187
+ modelRef?: FoundationRevision;
188
+ }): ModelAdoptionRecord;
189
+ /**
190
+ * Creates a world-model record store over the existing canonical aggregate.
191
+ * Foundation definitions are delegated to the shared revision store. The
192
+ * observation/adoption evidence catalog is committed as a sidecar in the same
193
+ * SSOT transaction, so the canonical Graph remains definition-only.
194
+ */
195
+ export declare function createWorldModelStore(options: {
196
+ dataDir: string;
197
+ foundationStore: WorldModelFoundationStore;
198
+ approvalReader?: WorldModelApprovalReader;
199
+ }): WorldModelRecordStore;