@unson/brainbase-mcp 0.48.3 → 0.49.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/dist/entity-indexer.d.ts +291 -0
- package/dist/entity-indexer.js +288 -0
- package/dist/judgment-frame.d.ts +24 -0
- package/dist/judgment-frame.js +45 -3
- package/dist/judgment-history.d.ts +1 -1
- package/dist/judgment-history.js +1 -0
- package/dist/worker-judgment-emit-cli.d.ts +18 -0
- package/dist/worker-judgment-emit-cli.js +98 -0
- package/dist/worker-judgment-emitter.d.ts +136 -0
- package/dist/worker-judgment-emitter.js +457 -0
- package/package.json +6 -2
- package/ui/brainbase-tokens.css +10 -0
- package/ui/graph-registry-view.js +2 -2
- package/ui/inbox.css +1 -1
- package/ui/inbox.js +4 -4
- package/ui/local-web-shell.css +1 -1
- package/ui/people-and-companies-view.css +0 -11
- package/ui/project-workspace.js +3 -2
- package/ui/workspace-kit.css +26 -6
- package/ui/workspace-kit.js +119 -5
- package/ui/world/world-canvas-ui.css +2 -2
package/dist/judgment-frame.js
CHANGED
|
@@ -26,7 +26,7 @@ const MAX_NOTE = 2_000;
|
|
|
26
26
|
const MAX_SELECTIONS = 24;
|
|
27
27
|
const MAX_OPTIONS = 8;
|
|
28
28
|
const MAX_USES = 32;
|
|
29
|
-
const MAX_PUBLIC_FRAME_TEXT = 2_000;
|
|
29
|
+
export const MAX_PUBLIC_FRAME_TEXT = 2_000;
|
|
30
30
|
const isRecord = (value) => Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
31
31
|
const text = (value) => typeof value === 'string' && value.trim() ? value.trim() : undefined;
|
|
32
32
|
const nonEmpty = (value, max) => typeof value === 'string' && value.trim().length > 0 && value.length <= max;
|
|
@@ -42,7 +42,7 @@ function canonicalJson(value) {
|
|
|
42
42
|
}
|
|
43
43
|
return JSON.stringify(value);
|
|
44
44
|
}
|
|
45
|
-
const PUBLIC_FRAME_KEYS = ['summary', 'reason'];
|
|
45
|
+
export const PUBLIC_FRAME_KEYS = ['summary', 'reason'];
|
|
46
46
|
const PUBLIC_FRAME_SECRET_PATTERNS = [
|
|
47
47
|
/(?:^|[\s([{])Bearer\s+[A-Za-z0-9._~+\/-]{8,}(?=$|[\s)\]}.,;])/iu,
|
|
48
48
|
/\b(?:sk-[A-Za-z0-9_-]{16,}|gh[pousr]_[A-Za-z0-9_-]{16,}|github_pat_[A-Za-z0-9_-]{16,}|xox[baprs]-[A-Za-z0-9-]{16,}|AIza[A-Za-z0-9_-]{16,}|AKIA[0-9A-Z]{16})\b/u,
|
|
@@ -55,6 +55,48 @@ const PUBLIC_FRAME_CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]/u;
|
|
|
55
55
|
export function containsJudgmentFrameCredential(value) {
|
|
56
56
|
return PUBLIC_FRAME_SECRET_PATTERNS.some((pattern) => pattern.test(value));
|
|
57
57
|
}
|
|
58
|
+
/** True when text carries control characters that must never reach a public projection. */
|
|
59
|
+
export function publicFrameTextHasControlCharacters(value) {
|
|
60
|
+
return PUBLIC_FRAME_CONTROL_CHARACTERS.test(value);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Validate a standalone explicit public frame with the exact acceptance
|
|
64
|
+
* boundary enforced inside a frame record: only the `summary`/`reason` keys,
|
|
65
|
+
* each a non-empty string of at most MAX_PUBLIC_FRAME_TEXT characters, free of
|
|
66
|
+
* control characters and credential-like values. A missing or empty frame is
|
|
67
|
+
* reported as `frame_public_absent` so a caller can keep "nothing recorded"
|
|
68
|
+
* distinct from "recorded but invalid". The value is never trimmed, stripped,
|
|
69
|
+
* or rewritten; an unusable frame is rejected, not repaired.
|
|
70
|
+
*/
|
|
71
|
+
export function checkJudgmentPublicFrame(value) {
|
|
72
|
+
if (value === undefined || value === null) {
|
|
73
|
+
return { ok: false, code: 'frame_public_absent', detail: 'public_frame was not recorded' };
|
|
74
|
+
}
|
|
75
|
+
if (!isRecord(value)) {
|
|
76
|
+
return { ok: false, code: 'frame_public_invalid', detail: 'public_frame must be an object with summary and reason' };
|
|
77
|
+
}
|
|
78
|
+
if (Object.keys(value).length === 0) {
|
|
79
|
+
return { ok: false, code: 'frame_public_absent', detail: 'public_frame was empty' };
|
|
80
|
+
}
|
|
81
|
+
for (const key of Object.keys(value)) {
|
|
82
|
+
if (!PUBLIC_FRAME_KEYS.includes(key)) {
|
|
83
|
+
return { ok: false, code: 'frame_public_invalid', detail: `public_frame contains an unknown field: ${key}` };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
for (const key of PUBLIC_FRAME_KEYS) {
|
|
87
|
+
const candidate = value[key];
|
|
88
|
+
if (!nonEmpty(candidate, MAX_PUBLIC_FRAME_TEXT)) {
|
|
89
|
+
return { ok: false, code: 'frame_public_invalid', detail: `${key} must be a non-empty string of at most ${MAX_PUBLIC_FRAME_TEXT} characters` };
|
|
90
|
+
}
|
|
91
|
+
if (publicFrameTextHasControlCharacters(candidate)) {
|
|
92
|
+
return { ok: false, code: 'frame_public_invalid', detail: `${key} contains control characters` };
|
|
93
|
+
}
|
|
94
|
+
if (containsJudgmentFrameCredential(candidate)) {
|
|
95
|
+
return { ok: false, code: 'frame_public_invalid', detail: `${key} contains a credential-like value` };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return { ok: true, frame: { summary: value.summary, reason: value.reason } };
|
|
99
|
+
}
|
|
58
100
|
function publicFrameRecord(value) {
|
|
59
101
|
return {
|
|
60
102
|
record_version: value.record_version,
|
|
@@ -251,7 +293,7 @@ export function validateJudgmentFrameRecord(value, catalog, outcomes = new Map()
|
|
|
251
293
|
issue('frame_public_invalid', `public_frame.${key}`, `${key} must be a non-empty string of at most ${MAX_PUBLIC_FRAME_TEXT} characters`);
|
|
252
294
|
continue;
|
|
253
295
|
}
|
|
254
|
-
if (
|
|
296
|
+
if (publicFrameTextHasControlCharacters(candidate)) {
|
|
255
297
|
issue('frame_public_invalid', `public_frame.${key}`, `${key} contains control characters`);
|
|
256
298
|
}
|
|
257
299
|
if (containsJudgmentFrameCredential(candidate)) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
export declare const JUDGMENT_HISTORY_RECORD_SCHEMA: "brainbase-judgment-history-record-v1";
|
|
3
3
|
export declare const JUDGMENT_HISTORY_CONTRACT_VERSION: "brainbase.judgment-history.v1";
|
|
4
4
|
export declare const JUDGMENT_HISTORY_FEEDBACK_SCHEMA: "brainbase-judgment-history-feedback-v1";
|
|
5
|
-
export declare const JUDGMENT_HISTORY_ENTRYPOINTS: readonly ["codex", "claude_code", "mana", "company_os", "unknown"];
|
|
5
|
+
export declare const JUDGMENT_HISTORY_ENTRYPOINTS: readonly ["codex", "claude_code", "opencode", "mana", "company_os", "unknown"];
|
|
6
6
|
export type JudgmentHistoryEntrypoint = typeof JUDGMENT_HISTORY_ENTRYPOINTS[number];
|
|
7
7
|
export type JudgmentHistoryStatus = 'available' | 'partial' | 'unavailable';
|
|
8
8
|
export type JudgmentHistoryStorage = 'local' | 'server';
|
package/dist/judgment-history.js
CHANGED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/** The pair of write sinks the CLI uses, injectable so a test never touches real process streams. */
|
|
3
|
+
export interface WorkerJudgmentEmitCliIo {
|
|
4
|
+
readonly stdout: {
|
|
5
|
+
write(chunk: string): unknown;
|
|
6
|
+
};
|
|
7
|
+
readonly stderr: {
|
|
8
|
+
write(chunk: string): unknown;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Run one emission from an already-read stdin string. Pure over its inputs: it
|
|
13
|
+
* writes only to the injected io and returns the exit code, so it is tested
|
|
14
|
+
* without spawning a process or reading real streams. Error reports are
|
|
15
|
+
* input-free on purpose — a rejected turn descriptor may still carry a
|
|
16
|
+
* credential, so the raw input and parser messages are never echoed.
|
|
17
|
+
*/
|
|
18
|
+
export declare function runWorkerJudgmentEmitCli(raw: string, io: WorkerJudgmentEmitCliIo, env?: Record<string, string | undefined>): Promise<number>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* RQ-119 S1 CLI. A Worker adapter (Claude Code hook, opencode plugin) invokes
|
|
4
|
+
* this as a built node script — `node dist/worker-judgment-emit-cli.js` — never
|
|
5
|
+
* `npx tsx` (§3.2: Claude hooks that call `npx tsx` fail in runner/worktree).
|
|
6
|
+
*
|
|
7
|
+
* It reads one JSON turn descriptor from stdin, writes the receipt to the local
|
|
8
|
+
* outbox through the common port, and prints a safe summary. The OSS build
|
|
9
|
+
* injects no transport, so the judgment is only written locally. The judgment
|
|
10
|
+
* body, prompt, response, and any credential never appear on argv, in the
|
|
11
|
+
* output, or in a skip marker.
|
|
12
|
+
*/
|
|
13
|
+
import { emitWorkerJudgment, WorkerJudgmentEmitterError } from './worker-judgment-emitter.js';
|
|
14
|
+
/**
|
|
15
|
+
* Fixed, input-free Japanese details keyed by the emitter's stable error codes.
|
|
16
|
+
* The underlying exception message is never echoed: a corrupt-outbox or
|
|
17
|
+
* conflict error carries the outbox path (which embeds `journalRoot`, possibly a
|
|
18
|
+
* secret), so only a short constant string may reach the log.
|
|
19
|
+
*/
|
|
20
|
+
const CLI_ERROR_DETAIL = {
|
|
21
|
+
worker_judgment_input_invalid: '入力が不正です',
|
|
22
|
+
worker_judgment_entrypoint_invalid: 'entrypoint が不正です',
|
|
23
|
+
worker_judgment_effective_after_invalid: '有効化境界の時刻が不正です',
|
|
24
|
+
worker_judgment_journal_root_required: 'outbox の保存先が指定されていません',
|
|
25
|
+
worker_judgment_receipt_conflict: '同じ判断に別の内容が既に保存されています',
|
|
26
|
+
worker_judgment_outbox_corrupt: '保存済みの outbox が壊れています',
|
|
27
|
+
worker_judgment_transport_error: '送信に失敗しました'
|
|
28
|
+
};
|
|
29
|
+
async function readStdin() {
|
|
30
|
+
const chunks = [];
|
|
31
|
+
for await (const chunk of process.stdin)
|
|
32
|
+
chunks.push(chunk);
|
|
33
|
+
return Buffer.concat(chunks).toString('utf8');
|
|
34
|
+
}
|
|
35
|
+
function isRecord(value) {
|
|
36
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Run one emission from an already-read stdin string. Pure over its inputs: it
|
|
40
|
+
* writes only to the injected io and returns the exit code, so it is tested
|
|
41
|
+
* without spawning a process or reading real streams. Error reports are
|
|
42
|
+
* input-free on purpose — a rejected turn descriptor may still carry a
|
|
43
|
+
* credential, so the raw input and parser messages are never echoed.
|
|
44
|
+
*/
|
|
45
|
+
export async function runWorkerJudgmentEmitCli(raw, io, env = process.env) {
|
|
46
|
+
let payload;
|
|
47
|
+
try {
|
|
48
|
+
const parsed = JSON.parse(raw);
|
|
49
|
+
if (!isRecord(parsed) || !isRecord(parsed.input))
|
|
50
|
+
throw new Error('payload shape');
|
|
51
|
+
payload = parsed;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
io.stderr.write(`${JSON.stringify({ error: 'worker_judgment_cli_input_invalid', detail: 'stdin は { input, journalRoot?, effectiveAfter? } の JSON オブジェクトである必要があります' })}\n`);
|
|
55
|
+
return 2;
|
|
56
|
+
}
|
|
57
|
+
const journalRoot = payload.journalRoot ?? env.BRAINBASE_WORKER_JUDGMENT_JOURNAL_DIR;
|
|
58
|
+
const effectiveAfter = payload.effectiveAfter ?? env.BRAINBASE_WORKER_JUDGMENT_EFFECTIVE_AFTER;
|
|
59
|
+
if (!journalRoot || !effectiveAfter) {
|
|
60
|
+
io.stderr.write(`${JSON.stringify({ error: 'worker_judgment_cli_config_missing', detail: 'journalRoot と effectiveAfter が必要です(payload か env で指定)' })}\n`);
|
|
61
|
+
return 2;
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
const result = await emitWorkerJudgment(payload.input, { journalRoot, effectiveAfter });
|
|
65
|
+
// Print only hashed identifiers and status — never the public frame, and
|
|
66
|
+
// never the absolute outbox path (it embeds the possibly-secret journalRoot).
|
|
67
|
+
// The outbox is addressed by its resolution_id alone.
|
|
68
|
+
const summary = result.outcome === 'skipped'
|
|
69
|
+
? { outcome: result.outcome, reason_code: result.reason_code }
|
|
70
|
+
: {
|
|
71
|
+
outcome: result.outcome,
|
|
72
|
+
status: result.status,
|
|
73
|
+
resolution_id: result.receipt.resolution_id,
|
|
74
|
+
turn_ref: result.receipt.turn_ref,
|
|
75
|
+
deduped: result.deduped
|
|
76
|
+
};
|
|
77
|
+
io.stdout.write(`${JSON.stringify(summary)}\n`);
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
// Report only a stable error code and a fixed Japanese detail. The exception
|
|
82
|
+
// message is never echoed — it can carry the outbox path (and journalRoot).
|
|
83
|
+
const code = error instanceof WorkerJudgmentEmitterError ? error.code : 'worker_judgment_cli_error';
|
|
84
|
+
const detail = CLI_ERROR_DETAIL[code] ?? 'ターンを emit できませんでした';
|
|
85
|
+
io.stderr.write(`${JSON.stringify({ error: code, detail })}\n`);
|
|
86
|
+
return 1;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async function main() {
|
|
90
|
+
return runWorkerJudgmentEmitCli(await readStdin(), { stdout: process.stdout, stderr: process.stderr }, process.env);
|
|
91
|
+
}
|
|
92
|
+
// Only run when invoked as the process entrypoint, not when imported by a test.
|
|
93
|
+
if (process.argv[1] && import.meta.url === new URL(`file://${process.argv[1]}`).href) {
|
|
94
|
+
main().then((code) => { process.exitCode = code; }).catch(() => {
|
|
95
|
+
process.stderr.write(`${JSON.stringify({ error: 'worker_judgment_cli_error', detail: 'the turn could not be emitted' })}\n`);
|
|
96
|
+
process.exitCode = 1;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { type JudgmentFramePublicFrame } from './judgment-frame.js';
|
|
2
|
+
/**
|
|
3
|
+
* RQ-119 Story S1: the common emission port that turns a Worker turn into the
|
|
4
|
+
* shared judgment receipt contract, derives its idempotency keys, and writes it
|
|
5
|
+
* to a local outbox before any delivery. Delivery is an injected transport; the
|
|
6
|
+
* OSS default is local-only (nothing is sent). Tool-specific adapters (S2/S3),
|
|
7
|
+
* the organization transport and receiving endpoint (S4), and retry/visibility
|
|
8
|
+
* (S5) are intentionally out of this module.
|
|
9
|
+
*/
|
|
10
|
+
export declare const WORKER_JUDGMENT_RECEIPT_SCHEMA: "brainbase-worker-judgment-receipt-v1";
|
|
11
|
+
export declare const WORKER_JUDGMENT_OUTBOX_SCHEMA: "brainbase-worker-judgment-outbox-v1";
|
|
12
|
+
export declare const WORKER_JUDGMENT_SKIP_SCHEMA: "brainbase-worker-judgment-skip-v1";
|
|
13
|
+
/** The presence of a `<resolution_id>.json.sent` marker is the authoritative "delivered" signal; the outbox body is never rewritten on success. */
|
|
14
|
+
export declare const WORKER_JUDGMENT_SENT_SCHEMA: "brainbase-worker-judgment-sent-v1";
|
|
15
|
+
/** Only Worker tools emit through this port. `opencode` is the shared enum value for DeepSeek via opencode. */
|
|
16
|
+
export declare const WORKER_JUDGMENT_ENTRYPOINTS: readonly ["claude_code", "opencode"];
|
|
17
|
+
export type WorkerJudgmentEntrypoint = typeof WORKER_JUDGMENT_ENTRYPOINTS[number];
|
|
18
|
+
/** Delivery states shared with §7. S1 only ever writes `pending` locally; a transport may advance it. */
|
|
19
|
+
export type WorkerJudgmentDeliveryStatus = 'pending' | 'saved' | 'already_saved' | 'blocked_credential' | 'failed';
|
|
20
|
+
/** Reason codes left in the outbox when a turn is deliberately not sent. The judgment body is never stored. */
|
|
21
|
+
export type WorkerJudgmentSkipReason = 'worker_public_frame_absent' | 'frame_public_invalid' | 'worker_meta_invalid' | 'worker_project_code_invalid' | 'worker_resolved_at_missing' | 'worker_resolved_at_invalid' | 'worker_resolved_at_before_boundary';
|
|
22
|
+
/** Execution metadata kept beside a judgment. The real model name lives here, never in the entrypoint. */
|
|
23
|
+
export interface WorkerJudgmentMeta {
|
|
24
|
+
/** Real model name, e.g. `deepseek/deepseek-flash`. Never a secret value. */
|
|
25
|
+
readonly model?: string;
|
|
26
|
+
/** The acting agent member id (agent subject), kept as metadata only. */
|
|
27
|
+
readonly agent_member_id?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface WorkerJudgmentInput {
|
|
30
|
+
readonly entrypoint: WorkerJudgmentEntrypoint;
|
|
31
|
+
readonly session_id: string;
|
|
32
|
+
readonly turn_id: string;
|
|
33
|
+
/** ISO time the judgment was resolved. The §8 boundary is decided by this, not by delivery time. */
|
|
34
|
+
readonly resolved_at: string;
|
|
35
|
+
readonly project_code?: string | null;
|
|
36
|
+
/** The explicitly recorded public frame. Absent/empty means the turn is not sent. */
|
|
37
|
+
readonly public_frame?: unknown;
|
|
38
|
+
readonly meta?: WorkerJudgmentMeta;
|
|
39
|
+
}
|
|
40
|
+
/** The deterministic receipt shape shared with the organization `judgment_receipts` projection (§4.3). */
|
|
41
|
+
export interface WorkerJudgmentReceipt {
|
|
42
|
+
readonly schema_version: typeof WORKER_JUDGMENT_RECEIPT_SCHEMA;
|
|
43
|
+
readonly resolution_id: string;
|
|
44
|
+
readonly entrypoint: WorkerJudgmentEntrypoint;
|
|
45
|
+
readonly turn_ref: string;
|
|
46
|
+
readonly project_code: string | null;
|
|
47
|
+
readonly resolved_at: string;
|
|
48
|
+
readonly public_frame: JudgmentFramePublicFrame;
|
|
49
|
+
readonly content_digest: `sha256:${string}`;
|
|
50
|
+
readonly meta: {
|
|
51
|
+
readonly model: string | null;
|
|
52
|
+
readonly agent_member_id: string | null;
|
|
53
|
+
};
|
|
54
|
+
/** sha256 of the canonical JSON of every field above; the §6 conflict check compares this. */
|
|
55
|
+
readonly receipt_digest: string;
|
|
56
|
+
}
|
|
57
|
+
export type WorkerJudgmentBuild = {
|
|
58
|
+
readonly outcome: 'receipt';
|
|
59
|
+
readonly receipt: WorkerJudgmentReceipt;
|
|
60
|
+
} | {
|
|
61
|
+
readonly outcome: 'skipped';
|
|
62
|
+
readonly reason_code: WorkerJudgmentSkipReason;
|
|
63
|
+
readonly detail: string;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* A delivery transport. The OSS build injects none, so judgments stay local.
|
|
67
|
+
* The organization build injects one that records to `judgment_receipts` (S4).
|
|
68
|
+
*/
|
|
69
|
+
export interface WorkerJudgmentTransport {
|
|
70
|
+
send(receipt: WorkerJudgmentReceipt): Promise<WorkerJudgmentTransportResult> | WorkerJudgmentTransportResult;
|
|
71
|
+
}
|
|
72
|
+
export type WorkerJudgmentTransportResult = {
|
|
73
|
+
readonly status: 'saved' | 'already_saved';
|
|
74
|
+
} | {
|
|
75
|
+
readonly status: 'blocked_credential' | 'failed';
|
|
76
|
+
readonly reason_code: string;
|
|
77
|
+
};
|
|
78
|
+
export interface WorkerJudgmentEmitterOptions {
|
|
79
|
+
/** Worker journal root. Receipts live under `<sha256(session)>/<sha256(turn)>/`. */
|
|
80
|
+
readonly journalRoot: string;
|
|
81
|
+
/** ISO activation boundary; judgments resolved before it are not sent (§8, no backfill). */
|
|
82
|
+
readonly effectiveAfter: string;
|
|
83
|
+
/** Injected delivery port. Omitted in OSS; the receipt is only written locally. */
|
|
84
|
+
readonly transport?: WorkerJudgmentTransport;
|
|
85
|
+
readonly now?: () => Date;
|
|
86
|
+
/** How far ahead of `now` a `resolved_at` may be before it is rejected as invalid. */
|
|
87
|
+
readonly maxFutureSkewMs?: number;
|
|
88
|
+
}
|
|
89
|
+
export type WorkerJudgmentEmission = {
|
|
90
|
+
readonly outcome: 'emitted';
|
|
91
|
+
readonly status: WorkerJudgmentDeliveryStatus;
|
|
92
|
+
readonly receipt: WorkerJudgmentReceipt;
|
|
93
|
+
readonly path: string;
|
|
94
|
+
/** True when an identical receipt was already on disk (idempotent re-emit). */
|
|
95
|
+
readonly deduped: boolean;
|
|
96
|
+
readonly last_error_code?: string;
|
|
97
|
+
} | {
|
|
98
|
+
readonly outcome: 'skipped';
|
|
99
|
+
readonly reason_code: WorkerJudgmentSkipReason;
|
|
100
|
+
readonly path: string;
|
|
101
|
+
};
|
|
102
|
+
export declare class WorkerJudgmentEmitterError extends Error {
|
|
103
|
+
readonly code: string;
|
|
104
|
+
constructor(code: string, message: string);
|
|
105
|
+
}
|
|
106
|
+
/** Raised when the same resolution id is already stored with a different receipt (§6 conflict). We never overwrite. */
|
|
107
|
+
export declare class WorkerJudgmentConflictError extends WorkerJudgmentEmitterError {
|
|
108
|
+
readonly resolution_id: string;
|
|
109
|
+
constructor(resolutionId: string);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Build the deterministic receipt from a turn, or decide not to send it.
|
|
113
|
+
* Pure: the same input and `effectiveAfter` always yield the same receipt and
|
|
114
|
+
* the same `resolution_id`. `now` only bounds how far into the future a
|
|
115
|
+
* `resolved_at` may sit; it never enters the receipt.
|
|
116
|
+
*/
|
|
117
|
+
export declare function buildWorkerJudgmentReceipt(input: WorkerJudgmentInput, config: {
|
|
118
|
+
readonly effectiveAfter: string;
|
|
119
|
+
readonly now?: () => Date;
|
|
120
|
+
readonly maxFutureSkewMs?: number;
|
|
121
|
+
}): WorkerJudgmentBuild;
|
|
122
|
+
/** Resolve the per-turn outbox directory. Session and turn are hashed so neither raw id reaches the path. */
|
|
123
|
+
export declare function resolveWorkerJudgmentTurnDir(journalRoot: string, sessionId: string, turnId: string): string;
|
|
124
|
+
/** Raised when a stored outbox file exists but is corrupt. We never re-send or overwrite over corruption (§ fail loudly). */
|
|
125
|
+
export declare class WorkerJudgmentOutboxCorruptError extends WorkerJudgmentEmitterError {
|
|
126
|
+
constructor(path: string, detail: string);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Turn a Worker turn into a receipt and write it to the local outbox, then —
|
|
130
|
+
* only if a transport is injected — attempt a single delivery and record its
|
|
131
|
+
* status. With no transport the receipt stays `pending` locally. Re-emitting
|
|
132
|
+
* the identical turn is idempotent; a different receipt under the same
|
|
133
|
+
* resolution id is a loud conflict. Nothing here writes the raw session/turn
|
|
134
|
+
* ids, the prompt, the response, or any credential.
|
|
135
|
+
*/
|
|
136
|
+
export declare function emitWorkerJudgment(input: WorkerJudgmentInput, options: WorkerJudgmentEmitterOptions): Promise<WorkerJudgmentEmission>;
|