@unson/brainbase-mcp 0.4.0 → 0.5.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/README.md +146 -471
- package/contracts/judgment-dag/digest.json +4 -4
- package/contracts/judgment-dag/source-lock.json +65 -1
- package/contracts/judgment-value-proof/fixture.json +54 -0
- package/contracts/judgment-value-proof/schema.json +163 -0
- package/contracts/public-message-candidate.schema.json +143 -0
- package/dist/cli.js +46 -6
- package/dist/embedding-provider.d.ts +72 -0
- package/dist/embedding-provider.js +391 -0
- package/dist/graph-retrieval.d.ts +94 -0
- package/dist/graph-retrieval.js +443 -0
- package/dist/judgment-autonomy.d.ts +62 -0
- package/dist/judgment-autonomy.js +301 -0
- package/dist/judgment-dag-artifact-store.d.ts +29 -0
- package/dist/judgment-dag-artifact-store.js +416 -0
- package/dist/judgment-dag-replay-evaluation.d.ts +108 -0
- package/dist/judgment-dag-replay-evaluation.js +424 -0
- package/dist/judgment-dag-runner.d.ts +70 -0
- package/dist/judgment-dag-runner.js +325 -0
- package/dist/judgment-dag.d.ts +6 -0
- package/dist/judgment-dag.js +3 -0
- package/dist/judgment-host.d.ts +21 -0
- package/dist/judgment-host.js +180 -0
- package/dist/judgment-value-proof.d.ts +92 -0
- package/dist/judgment-value-proof.js +229 -0
- package/dist/organization-graph.d.ts +76 -0
- package/dist/organization-graph.js +331 -0
- package/dist/portable-graph.d.ts +39 -0
- package/dist/portable-graph.js +240 -0
- package/dist/server.d.ts +42 -3
- package/dist/server.js +52 -7
- package/docs/management/judgment-dag-milestones.md +31 -1
- package/package.json +20 -4
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export type JudgmentValueProofIntentState = 'captured' | 'executing' | 'waiting_human' | 'outcome_verified' | 'blocked' | 'unconfirmed';
|
|
2
|
+
export type JudgmentValueProofResolution = 'not_applicable' | 'continued_without_human' | 'human_required';
|
|
3
|
+
export type JudgmentValueProofEvidenceKind = 'judgment_receipt' | 'autonomy_receipt' | 'tool_event' | 'artifact' | 'canonical_readback' | 'human_feedback';
|
|
4
|
+
export interface JudgmentValueProofEvidenceRef {
|
|
5
|
+
kind: JudgmentValueProofEvidenceKind;
|
|
6
|
+
ref: string;
|
|
7
|
+
status: 'verified' | 'unconfirmed';
|
|
8
|
+
label?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface JudgmentValueProofArtifactRef {
|
|
11
|
+
kind: string;
|
|
12
|
+
ref: string;
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface JudgmentValueProofBasis {
|
|
16
|
+
entity_id: string;
|
|
17
|
+
application: string;
|
|
18
|
+
}
|
|
19
|
+
export interface JudgmentValueProofHumanOption {
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
impact: string;
|
|
23
|
+
}
|
|
24
|
+
export interface JudgmentValueProof {
|
|
25
|
+
schema_version: 'brainbase-judgment-value-proof-v1';
|
|
26
|
+
intent_id: string;
|
|
27
|
+
decision_attempt_id: string;
|
|
28
|
+
recorded_at: string;
|
|
29
|
+
state: JudgmentValueProofIntentState;
|
|
30
|
+
interruption: {
|
|
31
|
+
resolution: JudgmentValueProofResolution;
|
|
32
|
+
question_display_text: string | null;
|
|
33
|
+
question_digest: string | null;
|
|
34
|
+
reason_code: string | null;
|
|
35
|
+
human_reason: string | null;
|
|
36
|
+
};
|
|
37
|
+
decision: {
|
|
38
|
+
summary: string | null;
|
|
39
|
+
work_impact: string | null;
|
|
40
|
+
basis: JudgmentValueProofBasis[];
|
|
41
|
+
prior_learning_reused: boolean | 'unconfirmed';
|
|
42
|
+
};
|
|
43
|
+
execution: {
|
|
44
|
+
status: 'not_started' | 'executing' | 'completed' | 'blocked';
|
|
45
|
+
summary: string | null;
|
|
46
|
+
artifact_refs: JudgmentValueProofArtifactRef[];
|
|
47
|
+
};
|
|
48
|
+
outcome: {
|
|
49
|
+
status: 'outcome_verified' | 'unconfirmed' | 'not_applicable';
|
|
50
|
+
summary: string | null;
|
|
51
|
+
evidence_refs: JudgmentValueProofEvidenceRef[];
|
|
52
|
+
};
|
|
53
|
+
human_decision: {
|
|
54
|
+
question: string;
|
|
55
|
+
why_human: string;
|
|
56
|
+
options: JudgmentValueProofHumanOption[];
|
|
57
|
+
} | null;
|
|
58
|
+
feedback: {
|
|
59
|
+
status: 'none' | 'pending' | 'accepted' | 'corrected' | 'next_time_ask' | 'reverted';
|
|
60
|
+
summary: string | null;
|
|
61
|
+
evidence_ref: JudgmentValueProofEvidenceRef | null;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export interface JudgmentValueProofPlacement {
|
|
65
|
+
agent_progress: 'silent' | 'show';
|
|
66
|
+
agent_completion: 'silent' | 'show';
|
|
67
|
+
companion_attention: 'none' | 'human_decision' | 'blocked' | 'outcome_unconfirmed' | 'feedback_requested';
|
|
68
|
+
web_surface: 'none';
|
|
69
|
+
weekly_digest: 'exclude' | 'include';
|
|
70
|
+
}
|
|
71
|
+
export interface JudgmentValueProofCompanionItem {
|
|
72
|
+
schema_version: 'brainbase-judgment-value-proof-attention-v1';
|
|
73
|
+
intent_id: string;
|
|
74
|
+
decision_attempt_id: string;
|
|
75
|
+
kind: Exclude<JudgmentValueProofPlacement['companion_attention'], 'none'>;
|
|
76
|
+
title: string;
|
|
77
|
+
summary: string;
|
|
78
|
+
suggested_actions: string[];
|
|
79
|
+
}
|
|
80
|
+
export interface JudgmentValueProofWeeklyDigestInput {
|
|
81
|
+
period_label: string;
|
|
82
|
+
coverage: 'complete' | 'partial' | 'unavailable';
|
|
83
|
+
proofs: JudgmentValueProof[];
|
|
84
|
+
representative_limit?: number;
|
|
85
|
+
}
|
|
86
|
+
export declare function validateJudgmentValueProof(proof: JudgmentValueProof): JudgmentValueProof;
|
|
87
|
+
export declare function placeJudgmentValueProof(proof: JudgmentValueProof): JudgmentValueProofPlacement;
|
|
88
|
+
export declare function renderJudgmentValueProofProgress(proof: JudgmentValueProof): string | null;
|
|
89
|
+
export declare function renderJudgmentValueProofCompletion(proof: JudgmentValueProof): string | null;
|
|
90
|
+
export declare function renderJudgmentHumanDecisionRequest(proof: JudgmentValueProof): string | null;
|
|
91
|
+
export declare function projectJudgmentValueProofAttention(proof: JudgmentValueProof): JudgmentValueProofCompanionItem | null;
|
|
92
|
+
export declare function renderJudgmentValueProofWeeklyDigest(input: JudgmentValueProofWeeklyDigestInput): string;
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
function requiredText(value, field) {
|
|
2
|
+
const normalized = value.trim();
|
|
3
|
+
if (!normalized)
|
|
4
|
+
throw new TypeError(`${field} must be a non-empty string`);
|
|
5
|
+
return normalized;
|
|
6
|
+
}
|
|
7
|
+
function optionalText(value) {
|
|
8
|
+
if (value === null)
|
|
9
|
+
return null;
|
|
10
|
+
const normalized = value.trim();
|
|
11
|
+
return normalized || null;
|
|
12
|
+
}
|
|
13
|
+
function outcomeStatusLabel(status) {
|
|
14
|
+
if (status === 'outcome_verified')
|
|
15
|
+
return '成果確認済み';
|
|
16
|
+
if (status === 'unconfirmed')
|
|
17
|
+
return '結果未確認';
|
|
18
|
+
return '成果確認の対象外';
|
|
19
|
+
}
|
|
20
|
+
function evidenceLabel(evidence) {
|
|
21
|
+
const label = evidence.label?.trim() || evidence.kind;
|
|
22
|
+
return `${label} (${evidence.status === 'verified' ? '確認済み' : '未確認'})`;
|
|
23
|
+
}
|
|
24
|
+
export function validateJudgmentValueProof(proof) {
|
|
25
|
+
if (proof?.schema_version !== 'brainbase-judgment-value-proof-v1') {
|
|
26
|
+
throw new TypeError('unsupported judgment value proof schema');
|
|
27
|
+
}
|
|
28
|
+
requiredText(proof.intent_id, 'intent_id');
|
|
29
|
+
requiredText(proof.decision_attempt_id, 'decision_attempt_id');
|
|
30
|
+
requiredText(proof.recorded_at, 'recorded_at');
|
|
31
|
+
if (proof.interruption.resolution === 'continued_without_human') {
|
|
32
|
+
if (!optionalText(proof.decision.summary)) {
|
|
33
|
+
throw new TypeError('continued_without_human requires decision.summary');
|
|
34
|
+
}
|
|
35
|
+
if (!optionalText(proof.interruption.question_display_text)
|
|
36
|
+
&& !optionalText(proof.interruption.question_digest)) {
|
|
37
|
+
throw new TypeError('continued_without_human requires a redacted question or digest');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
if (proof.interruption.resolution === 'human_required') {
|
|
41
|
+
if (!proof.human_decision) {
|
|
42
|
+
throw new TypeError('human_required requires human_decision');
|
|
43
|
+
}
|
|
44
|
+
requiredText(proof.human_decision.question, 'human_decision.question');
|
|
45
|
+
requiredText(proof.human_decision.why_human, 'human_decision.why_human');
|
|
46
|
+
for (const option of proof.human_decision.options) {
|
|
47
|
+
requiredText(option.id, 'human_decision.options[].id');
|
|
48
|
+
requiredText(option.label, 'human_decision.options[].label');
|
|
49
|
+
requiredText(option.impact, 'human_decision.options[].impact');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (proof.outcome.status === 'outcome_verified') {
|
|
53
|
+
if (!optionalText(proof.outcome.summary)) {
|
|
54
|
+
throw new TypeError('outcome_verified requires outcome.summary');
|
|
55
|
+
}
|
|
56
|
+
if (!proof.outcome.evidence_refs.some((entry) => entry.status === 'verified')) {
|
|
57
|
+
throw new TypeError('outcome_verified requires verified evidence');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (proof.feedback.status !== 'none' && proof.feedback.status !== 'pending'
|
|
61
|
+
&& !proof.feedback.evidence_ref) {
|
|
62
|
+
throw new TypeError('recorded feedback requires evidence_ref');
|
|
63
|
+
}
|
|
64
|
+
return proof;
|
|
65
|
+
}
|
|
66
|
+
export function placeJudgmentValueProof(proof) {
|
|
67
|
+
validateJudgmentValueProof(proof);
|
|
68
|
+
let companionAttention = 'none';
|
|
69
|
+
if (proof.interruption.resolution === 'human_required') {
|
|
70
|
+
companionAttention = 'human_decision';
|
|
71
|
+
}
|
|
72
|
+
else if (proof.state === 'blocked' || proof.execution.status === 'blocked') {
|
|
73
|
+
companionAttention = 'blocked';
|
|
74
|
+
}
|
|
75
|
+
else if (proof.outcome.status === 'unconfirmed' && proof.execution.status === 'completed') {
|
|
76
|
+
companionAttention = 'outcome_unconfirmed';
|
|
77
|
+
}
|
|
78
|
+
else if (proof.feedback.status === 'pending') {
|
|
79
|
+
companionAttention = 'feedback_requested';
|
|
80
|
+
}
|
|
81
|
+
const behaviorChanged = proof.interruption.resolution === 'continued_without_human';
|
|
82
|
+
const completed = proof.execution.status === 'completed';
|
|
83
|
+
return {
|
|
84
|
+
agent_progress: behaviorChanged && proof.execution.status === 'executing' ? 'show' : 'silent',
|
|
85
|
+
agent_completion: behaviorChanged && completed ? 'show' : 'silent',
|
|
86
|
+
companion_attention: companionAttention,
|
|
87
|
+
web_surface: 'none',
|
|
88
|
+
weekly_digest: proof.interruption.resolution === 'not_applicable'
|
|
89
|
+
&& proof.feedback.status === 'none'
|
|
90
|
+
&& proof.state !== 'blocked'
|
|
91
|
+
&& proof.outcome.status === 'not_applicable'
|
|
92
|
+
? 'exclude'
|
|
93
|
+
: 'include'
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
export function renderJudgmentValueProofProgress(proof) {
|
|
97
|
+
const placement = placeJudgmentValueProof(proof);
|
|
98
|
+
if (placement.agent_progress === 'silent')
|
|
99
|
+
return null;
|
|
100
|
+
const decision = requiredText(proof.decision.summary ?? '', 'decision.summary');
|
|
101
|
+
const execution = optionalText(proof.execution.summary) ?? '作業を続行しています';
|
|
102
|
+
return `Brainbaseが判断を代行:${decision}。確認で止めず、${execution}。`;
|
|
103
|
+
}
|
|
104
|
+
export function renderJudgmentValueProofCompletion(proof) {
|
|
105
|
+
const placement = placeJudgmentValueProof(proof);
|
|
106
|
+
if (placement.agent_completion === 'silent')
|
|
107
|
+
return null;
|
|
108
|
+
const result = optionalText(proof.outcome.summary)
|
|
109
|
+
?? optionalText(proof.execution.summary)
|
|
110
|
+
?? '実行は完了しましたが、結果の要約はありません';
|
|
111
|
+
const decision = requiredText(proof.decision.summary ?? '', 'decision.summary');
|
|
112
|
+
const impact = optionalText(proof.decision.work_impact) ?? '確認による中断を避けて作業を継続';
|
|
113
|
+
const basis = proof.decision.basis.length > 0
|
|
114
|
+
? proof.decision.basis.map((entry) => entry.application).join(' / ')
|
|
115
|
+
: '適用根拠は未確認';
|
|
116
|
+
const evidence = proof.outcome.evidence_refs.length > 0
|
|
117
|
+
? proof.outcome.evidence_refs.map(evidenceLabel).join(' / ')
|
|
118
|
+
: '成果証跡なし';
|
|
119
|
+
return [
|
|
120
|
+
'Brainbase判断レシート',
|
|
121
|
+
`結果: ${result}`,
|
|
122
|
+
`判断: ${decision}`,
|
|
123
|
+
`仕事への影響: ${impact}`,
|
|
124
|
+
`根拠: ${basis}`,
|
|
125
|
+
`状態: ${outcomeStatusLabel(proof.outcome.status)}`,
|
|
126
|
+
`証拠: ${evidence}`,
|
|
127
|
+
'修正する場合: 「判断を修正: …」または「次回は確認」と返信'
|
|
128
|
+
].join('\n');
|
|
129
|
+
}
|
|
130
|
+
export function renderJudgmentHumanDecisionRequest(proof) {
|
|
131
|
+
validateJudgmentValueProof(proof);
|
|
132
|
+
if (proof.interruption.resolution !== 'human_required' || !proof.human_decision)
|
|
133
|
+
return null;
|
|
134
|
+
const options = proof.human_decision.options.length > 0
|
|
135
|
+
? proof.human_decision.options.map((option) => (`${option.id}. ${option.label}\n 影響: ${option.impact}`)).join('\n')
|
|
136
|
+
: '選択肢はまだ整理できていません';
|
|
137
|
+
return [
|
|
138
|
+
'人間判断が必要です',
|
|
139
|
+
`判断: ${proof.human_decision.question}`,
|
|
140
|
+
`AIで決めない理由: ${proof.human_decision.why_human}`,
|
|
141
|
+
'選択肢:',
|
|
142
|
+
options
|
|
143
|
+
].join('\n');
|
|
144
|
+
}
|
|
145
|
+
export function projectJudgmentValueProofAttention(proof) {
|
|
146
|
+
const placement = placeJudgmentValueProof(proof);
|
|
147
|
+
const kind = placement.companion_attention;
|
|
148
|
+
if (kind === 'none')
|
|
149
|
+
return null;
|
|
150
|
+
if (kind === 'human_decision' && proof.human_decision) {
|
|
151
|
+
return {
|
|
152
|
+
schema_version: 'brainbase-judgment-value-proof-attention-v1',
|
|
153
|
+
intent_id: proof.intent_id,
|
|
154
|
+
decision_attempt_id: proof.decision_attempt_id,
|
|
155
|
+
kind,
|
|
156
|
+
title: '人間判断が必要',
|
|
157
|
+
summary: `${proof.human_decision.question} — ${proof.human_decision.why_human}`,
|
|
158
|
+
suggested_actions: proof.human_decision.options.map((option) => `${option.id}: ${option.label}`)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
if (kind === 'blocked') {
|
|
162
|
+
return {
|
|
163
|
+
schema_version: 'brainbase-judgment-value-proof-attention-v1',
|
|
164
|
+
intent_id: proof.intent_id,
|
|
165
|
+
decision_attempt_id: proof.decision_attempt_id,
|
|
166
|
+
kind,
|
|
167
|
+
title: '作業が停止しています',
|
|
168
|
+
summary: optionalText(proof.execution.summary) ?? '停止理由は未確認です',
|
|
169
|
+
suggested_actions: ['停止理由を確認', '再実行条件を決める']
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
if (kind === 'outcome_unconfirmed') {
|
|
173
|
+
return {
|
|
174
|
+
schema_version: 'brainbase-judgment-value-proof-attention-v1',
|
|
175
|
+
intent_id: proof.intent_id,
|
|
176
|
+
decision_attempt_id: proof.decision_attempt_id,
|
|
177
|
+
kind,
|
|
178
|
+
title: '実行結果を確認できていません',
|
|
179
|
+
summary: optionalText(proof.execution.summary) ?? '実行は完了しました',
|
|
180
|
+
suggested_actions: ['正本を読み戻す', '結果未確認のまま保持']
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
schema_version: 'brainbase-judgment-value-proof-attention-v1',
|
|
185
|
+
intent_id: proof.intent_id,
|
|
186
|
+
decision_attempt_id: proof.decision_attempt_id,
|
|
187
|
+
kind: 'feedback_requested',
|
|
188
|
+
title: '判断へのフィードバックが必要',
|
|
189
|
+
summary: optionalText(proof.decision.summary) ?? '判断内容を確認してください',
|
|
190
|
+
suggested_actions: ['正しい', '判断を修正', '次回は確認']
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export function renderJudgmentValueProofWeeklyDigest(input) {
|
|
194
|
+
const periodLabel = requiredText(input.period_label, 'period_label');
|
|
195
|
+
if (input.coverage === 'unavailable') {
|
|
196
|
+
return `${periodLabel}のBrainbase判断実績は取得できませんでした。0件としては扱いません。`;
|
|
197
|
+
}
|
|
198
|
+
const proofs = input.proofs.map(validateJudgmentValueProof);
|
|
199
|
+
const included = proofs.filter((proof) => placeJudgmentValueProof(proof).weekly_digest === 'include');
|
|
200
|
+
const verified = included.filter((proof) => proof.outcome.status === 'outcome_verified').length;
|
|
201
|
+
const humanRequired = included.filter((proof) => proof.interruption.resolution === 'human_required').length;
|
|
202
|
+
const corrected = included.filter((proof) => proof.feedback.status === 'corrected'
|
|
203
|
+
|| proof.feedback.status === 'reverted'
|
|
204
|
+
|| proof.feedback.status === 'next_time_ask').length;
|
|
205
|
+
const unconfirmed = included.filter((proof) => proof.outcome.status === 'unconfirmed').length;
|
|
206
|
+
const blocked = included.filter((proof) => proof.state === 'blocked'
|
|
207
|
+
|| proof.execution.status === 'blocked').length;
|
|
208
|
+
const continued = included.filter((proof) => proof.interruption.resolution === 'continued_without_human').length;
|
|
209
|
+
const coverage = input.coverage === 'partial' ? '(一部データのみ)' : '';
|
|
210
|
+
const representativeLimit = Math.max(0, Math.floor(input.representative_limit ?? 3));
|
|
211
|
+
const examples = included
|
|
212
|
+
.filter((proof) => proof.decision.summary || proof.outcome.summary)
|
|
213
|
+
.slice(0, representativeLimit)
|
|
214
|
+
.map((proof, index) => {
|
|
215
|
+
const decision = optionalText(proof.decision.summary) ?? '人間判断';
|
|
216
|
+
const result = optionalText(proof.outcome.summary) ?? outcomeStatusLabel(proof.outcome.status);
|
|
217
|
+
return `${index + 1}. ${decision}\n → ${result}`;
|
|
218
|
+
});
|
|
219
|
+
return [
|
|
220
|
+
`${periodLabel}、Brainbaseが仕事をどう前に進めたか${coverage}`,
|
|
221
|
+
`確認せず続行した判断: ${continued}件`,
|
|
222
|
+
`成果確認まで完了: ${verified}件`,
|
|
223
|
+
`人間判断が必要: ${humanRequired}件`,
|
|
224
|
+
`判断の訂正・取消: ${corrected}件`,
|
|
225
|
+
`結果未確認: ${unconfirmed}件`,
|
|
226
|
+
`停止中: ${blocked}件`,
|
|
227
|
+
...(examples.length > 0 ? ['', '代表例', ...examples] : [])
|
|
228
|
+
].join('\n');
|
|
229
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { type PortableGraphBundle } from './portable-graph.js';
|
|
2
|
+
import type { GraphRetrievalInput, GraphRetrievalResponse } from './graph-retrieval.js';
|
|
3
|
+
/** The organization adapter is opt-in and never falls back after configuration. */
|
|
4
|
+
export declare const ORGANIZATION_GRAPH_DEFAULT_TIMEOUT_MS = 10000;
|
|
5
|
+
export declare const ORGANIZATION_GRAPH_MAX_RESPONSE_BYTES = 9000000;
|
|
6
|
+
export interface OrganizationGraphConfig {
|
|
7
|
+
/** Organization service base URL, without credentials or query parameters. */
|
|
8
|
+
readonly url: string;
|
|
9
|
+
/** Bearer token. Never include this value in a returned error or receipt. */
|
|
10
|
+
readonly token: string;
|
|
11
|
+
readonly projectCode: string;
|
|
12
|
+
readonly graphId: string;
|
|
13
|
+
readonly fetch?: OrganizationGraphFetch;
|
|
14
|
+
readonly timeoutMs?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface OrganizationGraphFetchResponse {
|
|
17
|
+
readonly status: number;
|
|
18
|
+
readonly headers?: {
|
|
19
|
+
get(name: string): string | null;
|
|
20
|
+
} | Map<string, string> | Record<string, string | undefined>;
|
|
21
|
+
readonly body?: {
|
|
22
|
+
getReader(): {
|
|
23
|
+
read(): Promise<{
|
|
24
|
+
done: boolean;
|
|
25
|
+
value?: Uint8Array;
|
|
26
|
+
}>;
|
|
27
|
+
cancel?(reason?: unknown): Promise<void>;
|
|
28
|
+
};
|
|
29
|
+
} | null;
|
|
30
|
+
text?(): Promise<string>;
|
|
31
|
+
json?(): Promise<unknown>;
|
|
32
|
+
}
|
|
33
|
+
export type OrganizationGraphFetch = (input: string, init: {
|
|
34
|
+
method: 'GET' | 'POST';
|
|
35
|
+
headers: Record<string, string>;
|
|
36
|
+
body?: string;
|
|
37
|
+
redirect: 'error';
|
|
38
|
+
signal: AbortSignal;
|
|
39
|
+
}) => Promise<OrganizationGraphFetchResponse>;
|
|
40
|
+
export interface PortableGraphReadback {
|
|
41
|
+
readonly bundle: unknown;
|
|
42
|
+
readonly digest: string;
|
|
43
|
+
}
|
|
44
|
+
export interface PortableGraphImportResult {
|
|
45
|
+
readonly status: 'imported' | 'unchanged';
|
|
46
|
+
readonly digest: string;
|
|
47
|
+
}
|
|
48
|
+
export declare class OrganizationGraphConfigError extends Error {
|
|
49
|
+
readonly code = "organization_config_invalid";
|
|
50
|
+
constructor(message: string);
|
|
51
|
+
}
|
|
52
|
+
export declare class OrganizationGraphError extends Error {
|
|
53
|
+
readonly code: string;
|
|
54
|
+
constructor(code: string, message: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Read the four organization settings as one all-or-nothing configuration.
|
|
58
|
+
* With no settings, OSS keeps its existing local-first behavior. A partial
|
|
59
|
+
* configuration is an error so a typo cannot silently select another store.
|
|
60
|
+
*/
|
|
61
|
+
export declare function createOrganizationGraphConfig(env?: Record<string, string | undefined>): OrganizationGraphConfig | undefined;
|
|
62
|
+
/** Create a client without making a network request. */
|
|
63
|
+
export declare function createOrganizationGraphClient(config: OrganizationGraphConfig): OrganizationGraphClient;
|
|
64
|
+
export interface OrganizationGraphClient {
|
|
65
|
+
search(input: GraphRetrievalInput): Promise<GraphRetrievalResponse>;
|
|
66
|
+
importPortableGraph(bundle: unknown): Promise<PortableGraphImportResult>;
|
|
67
|
+
readPortableGraph(): Promise<PortableGraphReadback>;
|
|
68
|
+
}
|
|
69
|
+
/** Forward the existing Graph retrieval input unchanged inside the request envelope. */
|
|
70
|
+
export declare function searchOrganizationGraph(config: OrganizationGraphConfig, input: GraphRetrievalInput): Promise<GraphRetrievalResponse>;
|
|
71
|
+
/** Import is explicit; merely configuring the remote backend never uploads data. */
|
|
72
|
+
export declare function importPortableGraph(config: OrganizationGraphConfig, bundle: unknown): Promise<PortableGraphImportResult>;
|
|
73
|
+
/** Read and verify the complete organization-side bundle and its digest. */
|
|
74
|
+
export declare function readPortableGraph(config: OrganizationGraphConfig): Promise<PortableGraphReadback>;
|
|
75
|
+
/** Validate the privacy boundary before any upload leaves the local process. */
|
|
76
|
+
export declare function assertPortableGraphBundle(bundle: unknown): asserts bundle is PortableGraphBundle;
|