@unson/brainbase-mcp 0.7.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.
- package/contracts/foundation/graph-history.sql +634 -0
- package/contracts/judgment-value-proof/schema.json +43 -1
- package/dist/canonical-task-service.js +16 -5
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +107 -0
- package/dist/company-os-objectives.d.ts +11 -0
- package/dist/company-os-objectives.js +84 -47
- package/dist/foundation-authenticated-tools.d.ts +56 -0
- package/dist/foundation-authenticated-tools.js +347 -0
- package/dist/foundation-graph-http.d.ts +43 -0
- package/dist/foundation-graph-http.js +243 -0
- package/dist/foundation-graph-write.d.ts +90 -0
- package/dist/foundation-graph-write.js +447 -0
- package/dist/foundation-public-provider.d.ts +140 -0
- package/dist/foundation-public-provider.js +192 -0
- package/dist/graph-corrections.d.ts +157 -0
- package/dist/graph-corrections.js +620 -0
- package/dist/graph-foundation-reader.d.ts +60 -0
- package/dist/graph-foundation-reader.js +494 -0
- package/dist/graph-retrieval.d.ts +6 -1
- package/dist/graph-revision-reader.d.ts +80 -0
- package/dist/graph-revision-reader.js +246 -0
- package/dist/graph-web-http.d.ts +26 -0
- package/dist/graph-web-http.js +215 -0
- package/dist/graph-web.d.ts +364 -0
- package/dist/graph-web.js +639 -0
- package/dist/judgment-problem-snapshot.d.ts +30 -2
- package/dist/judgment-problem-snapshot.js +302 -6
- package/dist/judgment-value-proof-review.d.ts +166 -0
- package/dist/judgment-value-proof-review.js +437 -0
- package/dist/judgment-value-proof.d.ts +28 -1
- package/dist/judgment-value-proof.js +53 -8
- package/dist/knowledge-continuation.d.ts +127 -0
- package/dist/knowledge-continuation.js +446 -0
- package/dist/knowledge-lookup.d.ts +178 -0
- package/dist/knowledge-lookup.js +758 -0
- package/dist/local-web-fetch-bridge.d.ts +5 -0
- package/dist/local-web-fetch-bridge.js +37 -0
- package/dist/local-web-host.d.ts +109 -0
- package/dist/local-web-host.js +688 -0
- package/dist/local-web-security.d.ts +25 -0
- package/dist/local-web-security.js +95 -0
- package/dist/organization-graph.d.ts +15 -0
- package/dist/organization-graph.js +24 -4
- package/dist/personal-knowledge.d.ts +12 -0
- package/dist/personal-knowledge.js +29 -0
- package/dist/personal-memory-handover.d.ts +108 -0
- package/dist/personal-memory-handover.js +369 -0
- package/dist/philosophy-revision-reader.d.ts +85 -0
- package/dist/philosophy-revision-reader.js +241 -0
- package/dist/portable-graph.d.ts +24 -0
- package/dist/portable-graph.js +77 -0
- package/dist/server.d.ts +7 -2
- package/dist/server.js +9 -6
- package/dist/value-proof-review-http.d.ts +25 -0
- package/dist/value-proof-review-http.js +185 -0
- package/dist/world-model.d.ts +21 -3
- package/dist/world-model.js +94 -12
- package/package.json +94 -3
- package/ui/brainbase-tokens.css +56 -0
- package/ui/graph-own-share.js +367 -0
- package/ui/graph-projects-view.css +23 -0
- package/ui/graph-projects-view.js +730 -0
- package/ui/graph-registry-view.css +101 -0
- package/ui/graph-registry-view.js +804 -0
- package/ui/graph-view-shared.css +522 -0
- package/ui/graph-view-shared.js +1227 -0
- package/ui/judgment-view.css +119 -45
- package/ui/local-web-shell.css +396 -0
- package/ui/local-web-shell.js +378 -0
- package/ui/objective-editor-http-port.js +154 -0
- package/ui/objective-editor.css +180 -74
- package/ui/objective-editor.js +490 -43
- package/ui/outcome-knowledge.css +50 -14
- package/ui/outcome-knowledge.js +15 -1
- package/ui/outcome-mana.css +91 -14
- package/ui/outcome-mana.js +958 -61
- package/ui/value-proof-review.css +504 -0
- package/ui/value-proof-review.js +1104 -0
- package/ui/workspace-kit.css +485 -0
- package/ui/workspace-kit.js +229 -0
- package/ui/world-model-view.css +188 -0
- package/ui/world-model-view.js +486 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
export declare function nodeRequestToFetch(request: IncomingMessage, options: {
|
|
3
|
+
readonly limitBytes: number;
|
|
4
|
+
}): Promise<Request>;
|
|
5
|
+
export declare function writeFetchResponse(response: ServerResponse, fetchResponse: Response): Promise<void>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readBoundedBody } from './local-web-security.js';
|
|
2
|
+
/**
|
|
3
|
+
* Minimal bridge between a Node `http` request and a Fetch-style handler such
|
|
4
|
+
* as `createFoundationHttpRouter().handle`. Only the headers those handlers
|
|
5
|
+
* read are forwarded; the Host, Origin and token were already checked on the
|
|
6
|
+
* Node request, which stays the security boundary.
|
|
7
|
+
*/
|
|
8
|
+
const FORWARDED_HEADERS = ['accept', 'content-type', 'if-match'];
|
|
9
|
+
export async function nodeRequestToFetch(request, options) {
|
|
10
|
+
const method = (request.method ?? 'GET').toUpperCase();
|
|
11
|
+
const headers = new Headers();
|
|
12
|
+
for (const name of FORWARDED_HEADERS) {
|
|
13
|
+
const value = request.headers[name];
|
|
14
|
+
if (typeof value === 'string')
|
|
15
|
+
headers.set(name, value);
|
|
16
|
+
}
|
|
17
|
+
const url = new URL(request.url ?? '/', 'http://localhost');
|
|
18
|
+
if (method === 'GET' || method === 'HEAD')
|
|
19
|
+
return new Request(url, { method, headers });
|
|
20
|
+
// The body is read here with the host's limit so an oversized request is
|
|
21
|
+
// rejected before the whole stream is buffered by the Fetch handler.
|
|
22
|
+
const body = await readBoundedBody(request, options.limitBytes);
|
|
23
|
+
return new Request(url, { method, headers, body: new Uint8Array(body) });
|
|
24
|
+
}
|
|
25
|
+
export async function writeFetchResponse(response, fetchResponse) {
|
|
26
|
+
if (response.headersSent)
|
|
27
|
+
return;
|
|
28
|
+
response.statusCode = fetchResponse.status;
|
|
29
|
+
for (const name of ['content-type', 'allow']) {
|
|
30
|
+
const value = fetchResponse.headers.get(name);
|
|
31
|
+
if (value !== null)
|
|
32
|
+
response.setHeader(name, value);
|
|
33
|
+
}
|
|
34
|
+
response.setHeader('Cache-Control', 'no-store');
|
|
35
|
+
response.setHeader('X-Content-Type-Options', 'nosniff');
|
|
36
|
+
response.end(Buffer.from(await fetchResponse.arrayBuffer()));
|
|
37
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type IncomingMessage, type Server, type ServerResponse } from 'node:http';
|
|
2
|
+
import { type ObjectiveDefinitionBuilder } from './foundation-http.js';
|
|
3
|
+
/**
|
|
4
|
+
* General local single-owner Web host (`brainbase web:serve`).
|
|
5
|
+
*
|
|
6
|
+
* One loopback server carries every local screen. The host owns the
|
|
7
|
+
* protections, the trusted principal and the static allowlist; each screen's
|
|
8
|
+
* server side is a `LocalWebModule`. To add a screen, add its module to
|
|
9
|
+
* `defaultLocalWebModules()` and its nav entry to `LOCAL_WEB_SCREENS` in
|
|
10
|
+
* `ui/local-web-shell.js`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const LOCAL_WEB_HOST_VERSION: "local-web-host.v1";
|
|
13
|
+
/** One per-launch token guards every write on this host, including value-proof feedback. */
|
|
14
|
+
export declare const LOCAL_WEB_TOKEN_HEADER = "x-brainbase-review-token";
|
|
15
|
+
export declare const LOCAL_WEB_DEFAULT_PORT = 31080;
|
|
16
|
+
/** Onboarding registers the owner as `self`; a graph without an owner id uses the same principal. */
|
|
17
|
+
export declare const LOCAL_WEB_DEFAULT_OWNER_ID = "self";
|
|
18
|
+
export declare const LOCAL_WEB_STATUS_PATH = "/api/local/status";
|
|
19
|
+
export declare const LOCAL_WEB_WORLD_MODEL_PREFIX = "/api/world-model";
|
|
20
|
+
export declare const LOCAL_WEB_GRAPH_PREFIX = "/api/graph";
|
|
21
|
+
/**
|
|
22
|
+
* An Objective is a few KB of text and criteria. 64 KiB leaves room for long
|
|
23
|
+
* Japanese text (about 20k characters) while keeping a loopback request that
|
|
24
|
+
* holds the SSOT lock far below the Fetch router's 1 MiB default.
|
|
25
|
+
*/
|
|
26
|
+
export declare const LOCAL_WEB_FOUNDATION_BODY_LIMIT_BYTES: number;
|
|
27
|
+
export declare const LOCAL_WEB_PROVENANCE_SOURCE_ID = "brainbase-local-web";
|
|
28
|
+
export type LocalGraphStatus = 'ready' | 'migration_required' | 'not_initialized' | 'unreadable';
|
|
29
|
+
export interface LocalGraphState {
|
|
30
|
+
readonly status: LocalGraphStatus;
|
|
31
|
+
readonly format: 'v1' | 'v2' | null;
|
|
32
|
+
/** Trusted principal for Foundation/World Model access. Never read from the browser. */
|
|
33
|
+
readonly ownerId: string | null;
|
|
34
|
+
readonly message?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface LocalWebModuleContext {
|
|
37
|
+
readonly dataDir: string;
|
|
38
|
+
readonly journalRoot: string;
|
|
39
|
+
readonly token: string;
|
|
40
|
+
readonly now: () => Date;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Server side of one screen. The host has already rejected a non-loopback
|
|
44
|
+
* Host and every non-GET request without the launch token and same origin
|
|
45
|
+
* before `handle` runs. `handle` returns false for a path it does not own.
|
|
46
|
+
*/
|
|
47
|
+
export interface LocalWebModule {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
/** Packaged `ui/` file names the screen loads. Only listed files are served. */
|
|
50
|
+
readonly uiFiles: readonly string[];
|
|
51
|
+
handle(request: IncomingMessage, response: ServerResponse): Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
export interface LocalWebHostOptions {
|
|
54
|
+
/** Personal OS data directory. Defaults to `BRAINBASE_PERSONAL_OS_DIR` or `~/.brainbase/personal-os`. */
|
|
55
|
+
readonly dataDir?: string;
|
|
56
|
+
/** Judgment journal root. Defaults to the journal inside the data directory. */
|
|
57
|
+
readonly journalRoot?: string;
|
|
58
|
+
readonly token?: string;
|
|
59
|
+
/** Directory containing the packaged `ui/` files. */
|
|
60
|
+
readonly uiDir?: string;
|
|
61
|
+
readonly now?: () => Date;
|
|
62
|
+
}
|
|
63
|
+
export interface LocalWebHost {
|
|
64
|
+
readonly server: Server;
|
|
65
|
+
readonly token: string;
|
|
66
|
+
readonly dataDir: string;
|
|
67
|
+
readonly journalRoot: string;
|
|
68
|
+
}
|
|
69
|
+
/** True only for a write that carries the launch token from this origin. */
|
|
70
|
+
export declare function isTrustedLocalWrite(request: IncomingMessage, token: string): boolean;
|
|
71
|
+
/** Reads the Graph format and owner without creating or migrating anything. */
|
|
72
|
+
export declare function readLocalGraphState(dataDir: string): Promise<LocalGraphState>;
|
|
73
|
+
export declare function createLocalStatusModule(context: LocalWebModuleContext): LocalWebModule;
|
|
74
|
+
export declare function createValueProofModule(context: LocalWebModuleContext): LocalWebModule;
|
|
75
|
+
/**
|
|
76
|
+
* Trusted authority fields for a single owner. The owner writes through the
|
|
77
|
+
* launch-token browser session, so a new Objective is private to the owner,
|
|
78
|
+
* scoped to the owner, and usable for drafting, judgment and evaluation. It is
|
|
79
|
+
* never authorized for execution from the Web. Updates keep every authority
|
|
80
|
+
* field byte-identical to the current revision.
|
|
81
|
+
*/
|
|
82
|
+
export declare function createLocalObjectiveDefinitionBuilder(now: () => Date): ObjectiveDefinitionBuilder;
|
|
83
|
+
/**
|
|
84
|
+
* Objective routes of `createObjectiveFoundationRoute`, wired to the local
|
|
85
|
+
* Graph. The principal is the Graph owner; the CSRF verifier is the host's
|
|
86
|
+
* token and same-origin check on the original Node request. Constraint links
|
|
87
|
+
* are read-only because no OSS writer can replace them.
|
|
88
|
+
*/
|
|
89
|
+
export declare function createObjectiveFoundationModule(context: LocalWebModuleContext): LocalWebModule;
|
|
90
|
+
/**
|
|
91
|
+
* Read-only World Model routes. Writes (observations, corrections, model
|
|
92
|
+
* adoption) are not on the Web in v1. Without an approval reader an approved
|
|
93
|
+
* adoption cannot be verified, so only the adoptions route reports
|
|
94
|
+
* `approval_reference_unresolved`; the other routes stay readable.
|
|
95
|
+
*/
|
|
96
|
+
export declare function createWorldModelReadModule(context: LocalWebModuleContext): LocalWebModule;
|
|
97
|
+
/**
|
|
98
|
+
* 「プロジェクトと関係者」 and 「情報と関係」: the local Graph read and correction
|
|
99
|
+
* routes under `/api/graph`. Graph v1 and a missing data set are answered by
|
|
100
|
+
* the handler itself (`migration_required` / `not_initialized`), never as zero
|
|
101
|
+
* items. The host has already required the launch token and the same origin
|
|
102
|
+
* for every write; the handler checks both again before it reads a body, so a
|
|
103
|
+
* correction is never saved through a path that skipped the host check.
|
|
104
|
+
*/
|
|
105
|
+
export declare function createGraphWebModule(context: LocalWebModuleContext): LocalWebModule;
|
|
106
|
+
/** 今日 (value proofs), 目的と現状 (objectives + world model), プロジェクトと関係者 and 情報と関係 (Graph). */
|
|
107
|
+
export declare function defaultLocalWebModules(context: LocalWebModuleContext): LocalWebModule[];
|
|
108
|
+
/** Local single-owner host. The caller owns `listen()` and must bind to a loopback address. */
|
|
109
|
+
export declare function createLocalWebHost(options?: LocalWebHostOptions): LocalWebHost;
|