@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,9 @@
1
+ export declare const CANONICAL_TASK_STATUSES: readonly ["pending", "in_progress", "waiting", "completed", "cancelled"];
2
+ export type CanonicalTaskStatus = typeof CANONICAL_TASK_STATUSES[number];
3
+ export declare const CANONICAL_TASK_PRIORITIES: readonly ["low", "medium", "high", "urgent"];
4
+ export type CanonicalTaskPriority = typeof CANONICAL_TASK_PRIORITIES[number];
5
+ export declare function isCanonicalTaskStatus(value: unknown): value is CanonicalTaskStatus;
6
+ export declare function isCanonicalTaskPriority(value: unknown): value is CanonicalTaskPriority;
7
+ export declare function normalizeCanonicalTaskProjectCodes(value: unknown): string[];
8
+ export declare function hasInvalidCanonicalTaskProjectCode(value: unknown): boolean;
9
+ export declare function canTransitionCanonicalTaskStatus(from: unknown, to: unknown): boolean;
@@ -0,0 +1,39 @@
1
+ export const CANONICAL_TASK_STATUSES = [
2
+ 'pending',
3
+ 'in_progress',
4
+ 'waiting',
5
+ 'completed',
6
+ 'cancelled',
7
+ ];
8
+ export const CANONICAL_TASK_PRIORITIES = ['low', 'medium', 'high', 'urgent'];
9
+ const STATUS_SET = new Set(CANONICAL_TASK_STATUSES);
10
+ const PRIORITY_SET = new Set(CANONICAL_TASK_PRIORITIES);
11
+ const TRANSITIONS = Object.freeze({
12
+ pending: new Set(['in_progress', 'waiting', 'completed', 'cancelled']),
13
+ in_progress: new Set(['waiting', 'completed', 'cancelled']),
14
+ waiting: new Set(['in_progress', 'completed', 'cancelled']),
15
+ completed: new Set(),
16
+ cancelled: new Set(['pending']),
17
+ });
18
+ export function isCanonicalTaskStatus(value) {
19
+ return typeof value === 'string' && STATUS_SET.has(value);
20
+ }
21
+ export function isCanonicalTaskPriority(value) {
22
+ return typeof value === 'string' && PRIORITY_SET.has(value);
23
+ }
24
+ export function normalizeCanonicalTaskProjectCodes(value) {
25
+ const values = Array.isArray(value) ? value : (value == null ? [] : [value]);
26
+ return [...new Set(values.flatMap((item) => String(item).split(','))
27
+ .map((item) => item.trim())
28
+ .filter(Boolean))];
29
+ }
30
+ export function hasInvalidCanonicalTaskProjectCode(value) {
31
+ const values = Array.isArray(value) ? value : (value == null ? [] : [value]);
32
+ return values.some((item) => typeof item !== 'string'
33
+ || item.split(',').some((code) => !code.trim() || code.trim().length > 100));
34
+ }
35
+ export function canTransitionCanonicalTaskStatus(from, to) {
36
+ return isCanonicalTaskStatus(from)
37
+ && isCanonicalTaskStatus(to)
38
+ && TRANSITIONS[from].has(to);
39
+ }
@@ -0,0 +1,16 @@
1
+ export type CanonicalTaskPrincipalType = 'person' | 'service' | 'internal';
2
+ export type CanonicalTaskPrincipal = Readonly<{
3
+ type: CanonicalTaskPrincipalType;
4
+ id: string;
5
+ }>;
6
+ export declare function normalizeCanonicalTaskPrincipal(principal: {
7
+ type?: unknown;
8
+ id?: unknown;
9
+ } | null | undefined): CanonicalTaskPrincipal;
10
+ export declare function createCanonicalTaskPrincipal({ authSource, personId, serviceId, internalId, }?: {
11
+ authSource?: string;
12
+ personId?: string;
13
+ serviceId?: string;
14
+ internalId?: string;
15
+ }): CanonicalTaskPrincipal;
16
+ export declare function principalNamespace(principal: CanonicalTaskPrincipal): string;
@@ -0,0 +1,36 @@
1
+ const ALLOWED_TYPES = new Set(['person', 'service', 'internal']);
2
+ const TRUSTED_AUTH_SOURCES = new Set(['bearer', 'service-token', 'internal']);
3
+ function normalizePart(value, label) {
4
+ const normalized = String(value || '').normalize('NFC');
5
+ if (!normalized)
6
+ throw new Error(`Canonical Task principal ${label} is required`);
7
+ if (/\p{Cc}/u.test(normalized))
8
+ throw new Error(`Canonical Task principal ${label} contains control characters`);
9
+ return normalized;
10
+ }
11
+ export function normalizeCanonicalTaskPrincipal(principal) {
12
+ const type = String(principal?.type || '').toLowerCase();
13
+ if (!ALLOWED_TYPES.has(type))
14
+ throw new Error('Canonical Task principal type is invalid');
15
+ return Object.freeze({ type, id: normalizePart(principal?.id, 'id') });
16
+ }
17
+ export function createCanonicalTaskPrincipal({ authSource, personId, serviceId, internalId, } = {}) {
18
+ if (personId && ['bearer', 'session'].includes(authSource ?? '')) {
19
+ return normalizeCanonicalTaskPrincipal({ type: 'person', id: personId });
20
+ }
21
+ if (!TRUSTED_AUTH_SOURCES.has(authSource ?? '')) {
22
+ throw new Error('Canonical Task principal requires trusted authentication');
23
+ }
24
+ if (authSource === 'service-token') {
25
+ return normalizeCanonicalTaskPrincipal({ type: 'service', id: serviceId });
26
+ }
27
+ if (authSource === 'internal') {
28
+ return normalizeCanonicalTaskPrincipal({ type: 'internal', id: internalId });
29
+ }
30
+ return normalizeCanonicalTaskPrincipal({ type: 'person', id: personId });
31
+ }
32
+ export function principalNamespace(principal) {
33
+ const normalized = normalizeCanonicalTaskPrincipal(principal);
34
+ const payload = JSON.stringify({ type: normalized.type, id: normalized.id });
35
+ return `v1.${Buffer.from(payload, 'utf8').toString('base64url')}`;
36
+ }
@@ -0,0 +1,251 @@
1
+ import { type CanonicalTaskPriority, type CanonicalTaskStatus } from './canonical-task-contract.js';
2
+ import { type CanonicalTaskPrincipal } from './canonical-task-principal.js';
3
+ type JsonRecord = Record<string, unknown>;
4
+ export type CanonicalTaskAction = 'list' | 'search' | 'read' | 'create' | 'update' | 'transition' | 'delete';
5
+ export type CanonicalTaskAuditAction = 'canonical_task.created' | 'canonical_task.updated' | 'canonical_task.transitioned' | 'canonical_task.deleted';
6
+ export interface CanonicalTaskContext extends JsonRecord {
7
+ principal: CanonicalTaskPrincipal;
8
+ authSource?: string | null;
9
+ auditPrincipal?: CanonicalTaskPrincipal | null;
10
+ auditAuthSource?: string | null;
11
+ idempotencyKey?: string | null;
12
+ }
13
+ export interface CanonicalTaskRecord extends JsonRecord {
14
+ id: string;
15
+ version: number;
16
+ title: string;
17
+ description?: string | null;
18
+ status: CanonicalTaskStatus;
19
+ priority: CanonicalTaskPriority;
20
+ assignee_person_id?: string | null;
21
+ assignee_display_name?: string | null;
22
+ due_at?: string | null;
23
+ waiting_on?: string | null;
24
+ review_at?: string | null;
25
+ completed_at?: string | null;
26
+ source_refs?: unknown[];
27
+ project_codes?: string[];
28
+ created_at?: string | null;
29
+ updated_at?: string | null;
30
+ web_url?: string | null;
31
+ }
32
+ export interface CanonicalTaskCreateInput extends JsonRecord {
33
+ title: string;
34
+ description?: string | null;
35
+ priority?: CanonicalTaskPriority | string | null;
36
+ assignee_person_id?: string | null;
37
+ due_at?: string | null;
38
+ waiting_on?: string | null;
39
+ review_at?: string | null;
40
+ source_refs?: unknown[];
41
+ project_codes?: unknown;
42
+ }
43
+ export interface CanonicalTaskUpdateInput extends JsonRecord {
44
+ title?: string;
45
+ description?: string | null;
46
+ priority?: CanonicalTaskPriority | string | null;
47
+ assignee_person_id?: string | null;
48
+ due_at?: string | null;
49
+ waiting_on?: string | null;
50
+ review_at?: string | null;
51
+ source_refs?: unknown[];
52
+ project_codes?: unknown;
53
+ }
54
+ export interface CanonicalTaskListFilters extends JsonRecord {
55
+ statuses?: unknown;
56
+ status?: unknown;
57
+ priorities?: unknown;
58
+ priority?: unknown;
59
+ projectCodes?: unknown;
60
+ projectCode?: unknown;
61
+ project_code?: unknown;
62
+ assigneePersonId?: string | null;
63
+ dueAfter?: string | null;
64
+ dueBefore?: string | null;
65
+ limit?: number | string | null;
66
+ cursor?: string | null;
67
+ }
68
+ export interface CanonicalTaskSearchFilters extends CanonicalTaskListFilters {
69
+ q?: string | null;
70
+ query?: string | null;
71
+ }
72
+ export interface CanonicalTaskPage {
73
+ items: CanonicalTaskRecord[];
74
+ totalCount?: number | null;
75
+ countStatus?: string | null;
76
+ nextCursor?: string | null;
77
+ readStatus?: string | null;
78
+ total_count?: number | null;
79
+ count_status?: string | null;
80
+ next_cursor?: string | null;
81
+ read_status?: string | null;
82
+ has_more?: boolean;
83
+ as_of?: string;
84
+ warnings?: string[];
85
+ [key: string]: unknown;
86
+ }
87
+ export interface CanonicalTaskSearchPage extends CanonicalTaskPage {
88
+ query: string;
89
+ }
90
+ export interface CanonicalTaskAuditEntry extends JsonRecord {
91
+ id: string;
92
+ actor: CanonicalTaskPrincipal;
93
+ actor_id: string;
94
+ actor_type: CanonicalTaskPrincipal['type'];
95
+ actor_principal: CanonicalTaskPrincipal;
96
+ actor_namespace: string;
97
+ auth_source: string | null;
98
+ action: CanonicalTaskAuditAction;
99
+ target_type: 'canonical_task';
100
+ target_id: string;
101
+ changes: JsonRecord;
102
+ source_refs: unknown[];
103
+ }
104
+ export interface CanonicalTaskRepository {
105
+ list(filters: CanonicalTaskListFilters): Promise<CanonicalTaskPage>;
106
+ search(filters: CanonicalTaskSearchFilters): Promise<CanonicalTaskPage>;
107
+ get(taskId: string): Promise<CanonicalTaskRecord | null>;
108
+ findByIdempotencyKey(key: string): Promise<CanonicalTaskRecord | null>;
109
+ create(input: JsonRecord): Promise<CanonicalTaskRecord>;
110
+ update(taskId: string, patch: JsonRecord): Promise<CanonicalTaskRecord>;
111
+ delete(taskId: string, expectedVersion: number): Promise<void>;
112
+ }
113
+ export interface CanonicalTaskAuditRepository {
114
+ upsertAuditLog(entry: CanonicalTaskAuditEntry): Promise<void>;
115
+ }
116
+ export interface CanonicalTaskAuthorizationRequest {
117
+ action: CanonicalTaskAction;
118
+ context: CanonicalTaskContext;
119
+ task?: CanonicalTaskRecord | null;
120
+ input?: unknown;
121
+ }
122
+ export interface CanonicalTaskPolicy {
123
+ normalizeContext?(context: CanonicalTaskContext): CanonicalTaskContext | Promise<CanonicalTaskContext>;
124
+ authorize(request: CanonicalTaskAuthorizationRequest): void | Promise<void>;
125
+ scopeFilters?(input: {
126
+ operation: 'list' | 'search';
127
+ context: CanonicalTaskContext;
128
+ filters: CanonicalTaskListFilters | CanonicalTaskSearchFilters;
129
+ }): Partial<CanonicalTaskListFilters | CanonicalTaskSearchFilters> | void | Promise<Partial<CanonicalTaskListFilters | CanonicalTaskSearchFilters> | void>;
130
+ }
131
+ export type CanonicalTaskClock = () => Date;
132
+ export type CanonicalTaskBaseUrl = string | (() => string | null | undefined);
133
+ export interface CanonicalTaskOperationRequest<T> {
134
+ scope: string;
135
+ operationKey: string;
136
+ fingerprint: string;
137
+ /**
138
+ * Persist only the stable reference needed to resume an operation. The
139
+ * coordinator must not need to serialize the complete Task payload.
140
+ */
141
+ projectResult?: (result: T) => unknown;
142
+ /**
143
+ * Inspect durable state after a caller or coordinator restart. A recovery
144
+ * result is deliberately explicit so a missing record is not mistaken for
145
+ * a successful replay.
146
+ */
147
+ recover?: () => Promise<CanonicalTaskOperationRecovery<T>>;
148
+ run: () => Promise<T>;
149
+ }
150
+ export interface CanonicalTaskOperationRecovery<T> {
151
+ recovered: boolean;
152
+ result?: T;
153
+ }
154
+ export interface CanonicalTaskPreparedDeleteRequest<T> {
155
+ scope?: string;
156
+ operationKey: string;
157
+ fingerprint: string;
158
+ /** Fingerprint for the task-version claim paired with the delete intent. */
159
+ versionFingerprint: string;
160
+ versionClaimKey: string;
161
+ principalNamespace: string;
162
+ prepare: () => Promise<{
163
+ result: T;
164
+ task?: CanonicalTaskRecord | null;
165
+ authorizationSnapshot?: JsonRecord;
166
+ }>;
167
+ findTask: () => Promise<CanonicalTaskRecord | null>;
168
+ removeTask: (task?: CanonicalTaskRecord) => Promise<void>;
169
+ projectResult?: (result: T) => unknown;
170
+ recover?: () => Promise<CanonicalTaskOperationRecovery<T>>;
171
+ }
172
+ export interface CanonicalTaskOperationRepository {
173
+ execute<T>(request: CanonicalTaskOperationRequest<T>): Promise<T>;
174
+ executePreparedDelete?<T>(request: CanonicalTaskPreparedDeleteRequest<T>): Promise<T>;
175
+ }
176
+ export interface CanonicalTaskServiceOptions {
177
+ repository: CanonicalTaskRepository;
178
+ auditRepository?: CanonicalTaskAuditRepository;
179
+ policy?: CanonicalTaskPolicy;
180
+ operationRepository?: CanonicalTaskOperationRepository;
181
+ clock?: CanonicalTaskClock;
182
+ baseUrl?: CanonicalTaskBaseUrl;
183
+ }
184
+ export declare class CanonicalTaskError extends Error {
185
+ readonly code: string;
186
+ readonly status: number;
187
+ readonly details: JsonRecord;
188
+ readonly fieldErrors: Record<string, string[]>;
189
+ readonly currentTask?: CanonicalTaskRecord;
190
+ constructor(code: string, message: string, status?: number, details?: JsonRecord, options?: {
191
+ fieldErrors?: Record<string, string[]>;
192
+ currentTask?: CanonicalTaskRecord;
193
+ });
194
+ }
195
+ export declare class CanonicalTaskService {
196
+ private readonly repository;
197
+ private readonly auditRepository?;
198
+ private readonly policy;
199
+ private readonly operationRepository?;
200
+ private readonly clock;
201
+ private readonly baseUrl?;
202
+ constructor(options: CanonicalTaskServiceOptions);
203
+ listTasks(filters: CanonicalTaskListFilters | undefined, context: CanonicalTaskContext): Promise<CanonicalTaskPage>;
204
+ searchTasks(filters: CanonicalTaskSearchFilters | undefined, context: CanonicalTaskContext): Promise<CanonicalTaskSearchPage>;
205
+ getTask(taskId: string, context: CanonicalTaskContext): Promise<CanonicalTaskRecord>;
206
+ createTask(input: CanonicalTaskCreateInput, context: CanonicalTaskContext): Promise<CanonicalTaskRecord>;
207
+ updateTask(taskId: string, input: CanonicalTaskUpdateInput & {
208
+ expected_version?: number;
209
+ }, expectedVersion: number, context: CanonicalTaskContext): Promise<CanonicalTaskRecord>;
210
+ updateTask(taskId: string, input: CanonicalTaskUpdateInput & {
211
+ expected_version?: number;
212
+ }, context: CanonicalTaskContext): Promise<CanonicalTaskRecord>;
213
+ transitionTask(taskId: string, status: unknown, expectedVersion: number, context: CanonicalTaskContext, input?: {
214
+ waitingOn?: unknown;
215
+ reviewAt?: unknown;
216
+ }): Promise<CanonicalTaskRecord>;
217
+ transitionTask(taskId: string, input: {
218
+ to_status?: unknown;
219
+ expected_version?: number;
220
+ waiting_on?: unknown;
221
+ review_at?: unknown;
222
+ }, context: CanonicalTaskContext): Promise<CanonicalTaskRecord>;
223
+ deleteTask(taskId: string, expectedVersion: number, context: CanonicalTaskContext): Promise<{
224
+ task_id: string;
225
+ deleted: true;
226
+ version: number;
227
+ }>;
228
+ deleteTask(taskId: string, input: {
229
+ expected_version?: number;
230
+ }, context: CanonicalTaskContext): Promise<{
231
+ task_id: string;
232
+ deleted: true;
233
+ version: number;
234
+ }>;
235
+ private versionedMutation;
236
+ private normalizeCreateInput;
237
+ private normalizeUpdateInput;
238
+ private normalizeListFilters;
239
+ private normalizeSearchFilters;
240
+ private normalizeContext;
241
+ private authorize;
242
+ private scopeFilters;
243
+ private requireIdempotencyKey;
244
+ private requireExpectedVersion;
245
+ private assertVersion;
246
+ private executeOperation;
247
+ private audit;
248
+ private read;
249
+ private normalizeResponse;
250
+ }
251
+ export {};