@unson/brainbase-mcp 0.6.0 → 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 (80) hide show
  1. package/dist/canonical-task-contract.d.ts +9 -0
  2. package/dist/canonical-task-contract.js +39 -0
  3. package/dist/canonical-task-principal.d.ts +16 -0
  4. package/dist/canonical-task-principal.js +36 -0
  5. package/dist/canonical-task-service.d.ts +251 -0
  6. package/dist/canonical-task-service.js +809 -0
  7. package/dist/company-os-evaluation.d.ts +193 -0
  8. package/dist/company-os-evaluation.js +1150 -0
  9. package/dist/company-os-impact-review.d.ts +248 -0
  10. package/dist/company-os-impact-review.js +663 -0
  11. package/dist/company-os-learning-adoption.d.ts +288 -0
  12. package/dist/company-os-learning-adoption.js +944 -0
  13. package/dist/company-os-objectives.d.ts +52 -0
  14. package/dist/company-os-objectives.js +197 -0
  15. package/dist/company-os-receipt-adapter.d.ts +109 -0
  16. package/dist/company-os-receipt-adapter.js +636 -0
  17. package/dist/constraint-exception-store.d.ts +23 -0
  18. package/dist/constraint-exception-store.js +108 -0
  19. package/dist/constraint-resolution.d.ts +175 -0
  20. package/dist/constraint-resolution.js +922 -0
  21. package/dist/decision-adapter.d.ts +145 -0
  22. package/dist/decision-adapter.js +586 -0
  23. package/dist/durable-wait-http.d.ts +51 -0
  24. package/dist/durable-wait-http.js +497 -0
  25. package/dist/durable-waits.d.ts +234 -0
  26. package/dist/durable-waits.js +944 -0
  27. package/dist/execution-authority-http.d.ts +28 -0
  28. package/dist/execution-authority-http.js +359 -0
  29. package/dist/execution-authority.d.ts +201 -0
  30. package/dist/execution-authority.js +634 -0
  31. package/dist/foundation-catalog.d.ts +26 -0
  32. package/dist/foundation-catalog.js +206 -0
  33. package/dist/foundation-constraint-store.d.ts +50 -0
  34. package/dist/foundation-constraint-store.js +215 -0
  35. package/dist/foundation-http.d.ts +90 -0
  36. package/dist/foundation-http.js +439 -0
  37. package/dist/foundation-store.d.ts +132 -0
  38. package/dist/foundation-store.js +654 -0
  39. package/dist/judgment-dag-composition.d.ts +224 -0
  40. package/dist/judgment-dag-composition.js +731 -0
  41. package/dist/judgment-dag.d.ts +2 -0
  42. package/dist/judgment-dag.js +1 -0
  43. package/dist/judgment-problem-snapshot.d.ts +185 -0
  44. package/dist/judgment-problem-snapshot.js +777 -0
  45. package/dist/judgment-view-http.d.ts +22 -0
  46. package/dist/judgment-view-http.js +128 -0
  47. package/dist/judgment-view.d.ts +222 -0
  48. package/dist/judgment-view.js +627 -0
  49. package/dist/knowledge-adapter.d.ts +112 -0
  50. package/dist/knowledge-adapter.js +691 -0
  51. package/dist/ontology-foundation.d.ts +209 -0
  52. package/dist/ontology-foundation.js +1000 -0
  53. package/dist/ontology.d.ts +13 -0
  54. package/dist/ontology.js +14 -0
  55. package/dist/organization-connection.d.ts +164 -0
  56. package/dist/organization-connection.js +428 -0
  57. package/dist/personal-knowledge.d.ts +120 -0
  58. package/dist/personal-knowledge.js +750 -0
  59. package/dist/problem-candidates.d.ts +149 -0
  60. package/dist/problem-candidates.js +898 -0
  61. package/dist/problem-selection.d.ts +238 -0
  62. package/dist/problem-selection.js +995 -0
  63. package/dist/resource-reservation-http.d.ts +31 -0
  64. package/dist/resource-reservation-http.js +371 -0
  65. package/dist/resource-reservations.d.ts +221 -0
  66. package/dist/resource-reservations.js +577 -0
  67. package/dist/server.d.ts +97 -0
  68. package/dist/server.js +180 -1
  69. package/dist/ssot.d.ts +6 -1
  70. package/dist/ssot.js +63 -5
  71. package/dist/streamable-http.d.ts +42 -0
  72. package/dist/streamable-http.js +288 -0
  73. package/dist/types.d.ts +20 -0
  74. package/dist/world-model.d.ts +181 -0
  75. package/dist/world-model.js +873 -0
  76. package/package.json +139 -3
  77. package/ui/judgment-view.css +238 -0
  78. package/ui/judgment-view.js +508 -0
  79. package/ui/objective-editor.css +180 -0
  80. package/ui/objective-editor.js +1139 -0
@@ -0,0 +1,238 @@
1
+ /**
2
+ * Problem selection is the comparison boundary between evidence-sidecar
3
+ * candidates and a future JudgmentProblem.
4
+ *
5
+ * The module deliberately does not rank candidates, reserve resources, grant
6
+ * authority, or mutate an Objective. A caller supplies a versioned DAG
7
+ * composition evaluator. This module freezes the selection inputs, checks
8
+ * current candidate access and exact digests, validates the evaluator result,
9
+ * and stores an immutable SelectionRecord.
10
+ */
11
+ import type { FoundationAcl, FoundationRevision, FoundationScope } from './ontology-foundation.js';
12
+ import type { ProblemCandidateRecord, ProblemCandidateStore, ProblemCandidateStoreContext } from './problem-candidates.js';
13
+ import { type JudgmentDAGCompositionDefinition, type JudgmentDAGCompositionRunRequest, type JudgmentDAGProblemSnapshotReference } from './judgment-dag-composition.js';
14
+ export declare const PROBLEM_SELECTION_CONTRACT_VERSION: "problem-selection.v1";
15
+ export declare const PROBLEM_SELECTION_RECORD_VERSION: "problem-selection-record.v1";
16
+ export declare const PROBLEM_SELECTION_DIRECTORY: "problem-selections";
17
+ export type ProblemSelectionAction = 'start' | 'continue' | 'observe' | 'hold' | 'stop';
18
+ export type ProblemSelectionStatus = 'selected' | 'human_review_required';
19
+ export type ProblemSelectionAssessmentStatus = 'eligible' | 'incomparable' | 'unavailable' | 'unknown';
20
+ export interface ProblemSelectionKnown<T> {
21
+ readonly status: 'known';
22
+ readonly value: T;
23
+ }
24
+ export interface ProblemSelectionUnknown {
25
+ readonly status: 'unknown';
26
+ readonly reason: string;
27
+ }
28
+ /** Unknown is preserved; it is never converted to zero or an empty value. */
29
+ export type ProblemSelectionField<T> = ProblemSelectionKnown<T> | ProblemSelectionUnknown;
30
+ export interface ProblemSelectionCostTerms {
31
+ readonly switching: ProblemSelectionField<number>;
32
+ readonly opportunity: ProblemSelectionField<number>;
33
+ readonly exploration: ProblemSelectionField<number>;
34
+ }
35
+ export interface ProblemSelectionExplorationLimit {
36
+ readonly maxCandidates: number;
37
+ readonly maxExplorationCost: ProblemSelectionField<number>;
38
+ }
39
+ export interface ProblemSelectionFoundationReference extends FoundationRevision {
40
+ readonly digest: string;
41
+ }
42
+ export interface ProblemSelectionConditionalPreference {
43
+ readonly id: string;
44
+ readonly condition: string;
45
+ readonly preference: string;
46
+ }
47
+ export interface ProblemSelectionDelegatedJudgment {
48
+ readonly id: string;
49
+ readonly question: string;
50
+ readonly ownerId: string;
51
+ }
52
+ /** Conditions fixed by the selection meta Problem before comparison begins. */
53
+ export interface ProblemSelectionFixedConditions {
54
+ readonly objectiveRefs: readonly ProblemSelectionFoundationReference[];
55
+ readonly constraintRefs: readonly ProblemSelectionFoundationReference[];
56
+ readonly conditionalPreferences: readonly ProblemSelectionConditionalPreference[];
57
+ readonly delegatedJudgments: readonly ProblemSelectionDelegatedJudgment[];
58
+ readonly costs: ProblemSelectionCostTerms;
59
+ readonly explorationLimit: ProblemSelectionExplorationLimit;
60
+ readonly evaluatedAt: string;
61
+ }
62
+ export interface ProblemSelectionCandidateReference {
63
+ readonly candidateId: string;
64
+ /** Exact candidate payload identity, excluding mutable review status. */
65
+ readonly payloadDigest: string;
66
+ readonly ownerScope: FoundationScope;
67
+ }
68
+ export interface ProblemSelectionObjectiveConflict {
69
+ readonly objectiveIds: readonly string[];
70
+ readonly reason: string;
71
+ }
72
+ export interface ProblemSelectionCandidateInput {
73
+ readonly reference: ProblemSelectionCandidateReference;
74
+ readonly record: ProblemCandidateRecord;
75
+ }
76
+ export interface ProblemSelectionCandidateAssessment {
77
+ readonly reference: ProblemSelectionCandidateReference;
78
+ readonly status: ProblemSelectionAssessmentStatus;
79
+ readonly action?: ProblemSelectionAction;
80
+ readonly rationale: string;
81
+ readonly ownerId?: string;
82
+ readonly conditions: readonly string[];
83
+ readonly reviewAt?: string;
84
+ readonly costs: ProblemSelectionCostTerms;
85
+ readonly unknowns: readonly ProblemSelectionUnknown[];
86
+ readonly objectiveConflicts: readonly ProblemSelectionObjectiveConflict[];
87
+ }
88
+ /** Result returned by the versioned DAG composition evaluator. */
89
+ export interface ProblemSelectionEvaluationResult {
90
+ readonly status: ProblemSelectionStatus;
91
+ readonly selectedCandidateId?: string;
92
+ readonly action?: ProblemSelectionAction;
93
+ readonly reason: string;
94
+ readonly ownerId?: string;
95
+ readonly conditions?: readonly string[];
96
+ readonly reviewAt?: string;
97
+ readonly assessments?: readonly ProblemSelectionCandidateAssessment[];
98
+ readonly unknowns?: readonly ProblemSelectionUnknown[];
99
+ readonly objectiveConflicts?: readonly ProblemSelectionObjectiveConflict[];
100
+ }
101
+ export interface ProblemSelectionEvaluationRequest {
102
+ readonly selectionId: string;
103
+ readonly selectionProblem: JudgmentDAGProblemSnapshotReference;
104
+ readonly composition: JudgmentDAGCompositionDefinition;
105
+ readonly candidates: readonly ProblemSelectionCandidateInput[];
106
+ readonly fixedConditions: ProblemSelectionFixedConditions;
107
+ }
108
+ export interface ProblemSelectionEvaluationPort {
109
+ /** The port may call executeJudgmentDAGComposition; it owns DAG adapters. */
110
+ readonly evaluate: (request: ProblemSelectionEvaluationRequest) => ProblemSelectionEvaluationResult | Promise<ProblemSelectionEvaluationResult>;
111
+ }
112
+ export interface ProblemSelectionProblemCreationRequest {
113
+ readonly status: 'required';
114
+ readonly candidate: ProblemSelectionCandidateReference;
115
+ readonly action: 'start' | 'continue';
116
+ readonly requiredConditions: readonly string[];
117
+ /** The future Problem must complete its own exact snapshot before execution. */
118
+ readonly completeSnapshotRequired: true;
119
+ }
120
+ export interface ProblemSelectionDecision {
121
+ readonly status: ProblemSelectionStatus;
122
+ readonly candidate?: ProblemSelectionCandidateReference;
123
+ readonly action?: ProblemSelectionAction;
124
+ readonly reason: string;
125
+ readonly ownerId?: string;
126
+ readonly conditions: readonly string[];
127
+ readonly reviewAt?: string;
128
+ }
129
+ /** Immutable output of one meta-Problem selection run. */
130
+ export interface ProblemSelectionRecord {
131
+ readonly recordVersion: typeof PROBLEM_SELECTION_RECORD_VERSION;
132
+ readonly contractVersion: typeof PROBLEM_SELECTION_CONTRACT_VERSION;
133
+ readonly selectionId: string;
134
+ readonly selectionProblem: JudgmentDAGProblemSnapshotReference;
135
+ readonly selectionComposition: JudgmentDAGCompositionDefinition;
136
+ readonly ownerScope: FoundationScope;
137
+ readonly readPolicy: FoundationAcl;
138
+ readonly fixedConditions: ProblemSelectionFixedConditions;
139
+ readonly candidateRefs: readonly ProblemSelectionCandidateReference[];
140
+ readonly assessments: readonly ProblemSelectionCandidateAssessment[];
141
+ /** Conflicts are retained at record level even when the evaluator did not attach them to an assessment. */
142
+ readonly objectiveConflicts: readonly ProblemSelectionObjectiveConflict[];
143
+ /** All unresolved inputs are retained instead of being collapsed into a status string. */
144
+ readonly unknowns: readonly ProblemSelectionUnknown[];
145
+ readonly status: ProblemSelectionStatus;
146
+ readonly decision: ProblemSelectionDecision;
147
+ readonly problemCreationRequest?: ProblemSelectionProblemCreationRequest;
148
+ /** Selection never grants an execution or resource authority. */
149
+ readonly executionPermission: 'none';
150
+ readonly resourceAuthority: 'none';
151
+ /** Selection never changes the Objective definition. */
152
+ readonly objectiveChange: 'none';
153
+ readonly createdAt: string;
154
+ }
155
+ export type ProblemSelectionRecordId = `sha256:${string}`;
156
+ export interface ProblemSelectionRequest {
157
+ readonly selectionId: string;
158
+ readonly selectionProblem: JudgmentDAGProblemSnapshotReference;
159
+ readonly selectionComposition: JudgmentDAGCompositionDefinition;
160
+ readonly ownerScope: FoundationScope;
161
+ readonly readPolicy: FoundationAcl;
162
+ readonly fixedConditions: ProblemSelectionFixedConditions;
163
+ readonly candidateRefs: readonly ProblemSelectionCandidateReference[];
164
+ readonly candidateStore: ProblemCandidateStore;
165
+ readonly candidateContext: ProblemCandidateStoreContext;
166
+ readonly evaluator: ProblemSelectionEvaluationPort;
167
+ readonly createdAt?: string;
168
+ }
169
+ export interface ProblemSelectionAccessContext {
170
+ readonly principal: string;
171
+ readonly scope?: FoundationScope;
172
+ }
173
+ export type ProblemSelectionAccessOperation = 'save' | 'read';
174
+ export interface ProblemSelectionAccessProvider {
175
+ authorize(input: {
176
+ readonly operation: ProblemSelectionAccessOperation;
177
+ readonly context: ProblemSelectionAccessContext;
178
+ readonly record: ProblemSelectionRecord;
179
+ }): boolean | void | Promise<boolean | void>;
180
+ }
181
+ export interface SaveProblemSelectionRecordRequest {
182
+ readonly root: string;
183
+ readonly record: ProblemSelectionRecord;
184
+ readonly access?: ProblemSelectionAccessContext;
185
+ readonly accessProvider?: ProblemSelectionAccessProvider;
186
+ }
187
+ export interface LoadProblemSelectionRecordRequest {
188
+ readonly root: string;
189
+ readonly recordId: string;
190
+ readonly access: ProblemSelectionAccessContext;
191
+ readonly accessProvider?: ProblemSelectionAccessProvider;
192
+ }
193
+ export interface ProblemSelectionRecordReceipt {
194
+ readonly recordId: ProblemSelectionRecordId;
195
+ readonly recordVersion: typeof PROBLEM_SELECTION_RECORD_VERSION;
196
+ readonly selectionId: string;
197
+ readonly status: 'created' | 'existing';
198
+ }
199
+ export interface ProblemSelectionRecordStore {
200
+ save(record: ProblemSelectionRecord, access: ProblemSelectionAccessContext): Promise<ProblemSelectionRecordReceipt>;
201
+ read(recordId: string, access: ProblemSelectionAccessContext): Promise<ProblemSelectionRecord>;
202
+ }
203
+ export type ProblemSelectionErrorCode = 'invalid_request' | 'candidate_unavailable' | 'candidate_scope_violation' | 'candidate_revision_conflict' | 'comparison_unavailable' | 'access_denied' | 'not_found' | 'invalid_record' | 'integrity_mismatch' | 'storage_io_error';
204
+ export declare class ProblemSelectionError extends Error {
205
+ readonly code: ProblemSelectionErrorCode;
206
+ constructor(code: ProblemSelectionErrorCode, message: string);
207
+ }
208
+ /**
209
+ * Resolve candidates and create one immutable selection record. Candidate
210
+ * bodies are used only inside the evaluator call and are never copied into
211
+ * the record; the record keeps exact candidate references and digests.
212
+ */
213
+ export declare function createProblemSelection(request: ProblemSelectionRequest): Promise<ProblemSelectionRecord>;
214
+ /** Alias for callers that name the operation as a run. */
215
+ export declare const runProblemSelection: typeof createProblemSelection;
216
+ /** Alias for callers that name the operation as a selection. */
217
+ export declare const selectProblem: typeof createProblemSelection;
218
+ /**
219
+ * Adapter helper for a composition whose designated child returns the
220
+ * selection contract in its conclusion. The meta Problem remains the exact
221
+ * snapshot supplied to the composition request; a selected candidate still
222
+ * requires a later Problem creation request.
223
+ */
224
+ export declare function evaluateProblemSelectionWithComposition(input: {
225
+ readonly compositionRequest: JudgmentDAGCompositionRunRequest;
226
+ readonly resultInvocationId?: string;
227
+ }): Promise<ProblemSelectionEvaluationResult>;
228
+ export declare function computeProblemSelectionRecordId(record: ProblemSelectionRecord): ProblemSelectionRecordId;
229
+ export declare function saveProblemSelectionRecord(request: SaveProblemSelectionRecordRequest): Promise<ProblemSelectionRecordReceipt>;
230
+ export declare function loadProblemSelectionRecord(request: LoadProblemSelectionRecordRequest): Promise<ProblemSelectionRecord>;
231
+ export declare function createProblemSelectionRecordStore(options: {
232
+ readonly root: string;
233
+ readonly accessProvider?: ProblemSelectionAccessProvider;
234
+ }): ProblemSelectionRecordStore;
235
+ /** Compatibility aliases for consumers that use SelectionRecord terminology. */
236
+ export declare const saveSelectionRecord: typeof saveProblemSelectionRecord;
237
+ export declare const loadSelectionRecord: typeof loadProblemSelectionRecord;
238
+ export declare const computeSelectionRecordId: typeof computeProblemSelectionRecordId;