@m8t-stack/api-contract 0.1.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 (75) hide show
  1. package/README.md +9 -0
  2. package/dist/cjs/a2a-card.js +33 -0
  3. package/dist/cjs/a2a-card.js.map +1 -0
  4. package/dist/cjs/binding.js +45 -0
  5. package/dist/cjs/binding.js.map +1 -0
  6. package/dist/cjs/brain-eval.js +58 -0
  7. package/dist/cjs/brain-eval.js.map +1 -0
  8. package/dist/cjs/brain-link.js +52 -0
  9. package/dist/cjs/brain-link.js.map +1 -0
  10. package/dist/cjs/errors.js +57 -0
  11. package/dist/cjs/errors.js.map +1 -0
  12. package/dist/cjs/inbound-envelope.js +3 -0
  13. package/dist/cjs/inbound-envelope.js.map +1 -0
  14. package/dist/cjs/index.js +37 -0
  15. package/dist/cjs/index.js.map +1 -0
  16. package/dist/cjs/me.js +3 -0
  17. package/dist/cjs/me.js.map +1 -0
  18. package/dist/cjs/package.json +1 -0
  19. package/dist/cjs/reasons.js +8 -0
  20. package/dist/cjs/reasons.js.map +1 -0
  21. package/dist/cjs/response.js +19 -0
  22. package/dist/cjs/response.js.map +1 -0
  23. package/dist/cjs/service-bus.js +3 -0
  24. package/dist/cjs/service-bus.js.map +1 -0
  25. package/dist/cjs/team.js +13 -0
  26. package/dist/cjs/team.js.map +1 -0
  27. package/dist/esm/a2a-card.d.ts +23 -0
  28. package/dist/esm/a2a-card.d.ts.map +1 -0
  29. package/dist/esm/a2a-card.js +28 -0
  30. package/dist/esm/a2a-card.js.map +1 -0
  31. package/dist/esm/binding.d.ts +106 -0
  32. package/dist/esm/binding.d.ts.map +1 -0
  33. package/dist/esm/binding.js +40 -0
  34. package/dist/esm/binding.js.map +1 -0
  35. package/dist/esm/brain-eval.d.ts +295 -0
  36. package/dist/esm/brain-eval.d.ts.map +1 -0
  37. package/dist/esm/brain-eval.js +54 -0
  38. package/dist/esm/brain-eval.js.map +1 -0
  39. package/dist/esm/brain-link.d.ts +49 -0
  40. package/dist/esm/brain-link.d.ts.map +1 -0
  41. package/dist/esm/brain-link.js +45 -0
  42. package/dist/esm/brain-link.js.map +1 -0
  43. package/dist/esm/errors.d.ts +39 -0
  44. package/dist/esm/errors.d.ts.map +1 -0
  45. package/dist/esm/errors.js +45 -0
  46. package/dist/esm/errors.js.map +1 -0
  47. package/dist/esm/inbound-envelope.d.ts +43 -0
  48. package/dist/esm/inbound-envelope.d.ts.map +1 -0
  49. package/dist/esm/inbound-envelope.js +2 -0
  50. package/dist/esm/inbound-envelope.js.map +1 -0
  51. package/dist/esm/index.d.ts +14 -0
  52. package/dist/esm/index.d.ts.map +1 -0
  53. package/dist/esm/index.js +12 -0
  54. package/dist/esm/index.js.map +1 -0
  55. package/dist/esm/me.d.ts +25 -0
  56. package/dist/esm/me.d.ts.map +1 -0
  57. package/dist/esm/me.js +2 -0
  58. package/dist/esm/me.js.map +1 -0
  59. package/dist/esm/reasons.d.ts +12 -0
  60. package/dist/esm/reasons.d.ts.map +1 -0
  61. package/dist/esm/reasons.js +7 -0
  62. package/dist/esm/reasons.js.map +1 -0
  63. package/dist/esm/response.d.ts +27 -0
  64. package/dist/esm/response.d.ts.map +1 -0
  65. package/dist/esm/response.js +16 -0
  66. package/dist/esm/response.js.map +1 -0
  67. package/dist/esm/service-bus.d.ts +15 -0
  68. package/dist/esm/service-bus.d.ts.map +1 -0
  69. package/dist/esm/service-bus.js +2 -0
  70. package/dist/esm/service-bus.js.map +1 -0
  71. package/dist/esm/team.d.ts +57 -0
  72. package/dist/esm/team.d.ts.map +1 -0
  73. package/dist/esm/team.js +9 -0
  74. package/dist/esm/team.js.map +1 -0
  75. package/package.json +42 -0
@@ -0,0 +1,295 @@
1
+ export type EvalDecision = "promote" | "reject" | "needs_review";
2
+ export type EvalJudgeStatus = "ok" | "skipped" | "unavailable";
3
+ export interface EvalFinding {
4
+ code: string;
5
+ severity: "hard" | "soft";
6
+ message: string;
7
+ locus?: string | null;
8
+ }
9
+ export interface EvalJudgeResult {
10
+ overallScore: number;
11
+ critique: string;
12
+ model: string;
13
+ flags?: {
14
+ behavioralRisk: "pass" | "fail";
15
+ collision: boolean;
16
+ /** Per-tag provenance: true = the tag was absent/malformed in the critique and the
17
+ * effective value above is a default. Any defaulted tag forces needs_review. */
18
+ defaulted?: {
19
+ safety: boolean;
20
+ collision: boolean;
21
+ };
22
+ } | null;
23
+ keyPoints?: string[] | null;
24
+ }
25
+ export interface Verdict {
26
+ candidatePath: string;
27
+ decision: EvalDecision;
28
+ rationale: string;
29
+ findings: EvalFinding[];
30
+ judge?: EvalJudgeResult | null;
31
+ judgeStatus: EvalJudgeStatus;
32
+ evaluatedAt: string;
33
+ evalVersion: string;
34
+ }
35
+ export type ArmState = "off" | "live" | {
36
+ pinned: string;
37
+ } | {
38
+ imported: string;
39
+ };
40
+ export interface ArmSpec {
41
+ brain: string;
42
+ state: ArmState;
43
+ profile?: string;
44
+ }
45
+ export interface RunAssertion {
46
+ text: string;
47
+ passed: boolean;
48
+ evidence: string;
49
+ tagDefaulted?: boolean;
50
+ }
51
+ export interface MemoryReadEvent {
52
+ path?: string;
53
+ spanRef?: string;
54
+ tool?: "get_file_contents" | "search_code";
55
+ query?: string;
56
+ }
57
+ export type ReadVsApply = "never_read" | "index_seen_not_opened" | "read_not_applied" | "degraded";
58
+ export interface ReadDiagnostic {
59
+ assertionId: string;
60
+ recallTarget?: string;
61
+ label: ReadVsApply;
62
+ }
63
+ export interface ConsolidationOutcome {
64
+ status: "ran" | "no_consolidation" | "not_runnable";
65
+ receipt?: string;
66
+ producedSha?: string;
67
+ reason?: string;
68
+ }
69
+ export interface RunCost {
70
+ tokens: number | null;
71
+ promptTokens?: number | null;
72
+ completionTokens?: number | null;
73
+ durationMs: number;
74
+ }
75
+ export interface RunResult {
76
+ taskId: string;
77
+ arm: ArmSpec;
78
+ rep: number;
79
+ runId: string;
80
+ assertions: RunAssertion[];
81
+ implicitClaims?: {
82
+ claim: string;
83
+ verified: boolean;
84
+ }[];
85
+ observe?: MemoryReadEvent[];
86
+ consolidation?: ConsolidationOutcome;
87
+ responseId?: string;
88
+ conversationId?: string;
89
+ readDiagnostics?: ReadDiagnostic[];
90
+ cost: RunCost;
91
+ runError?: {
92
+ reason: "content_filter" | "auth" | "not_found" | "rate_limit" | "transient" | "void" | "unknown";
93
+ message: string;
94
+ };
95
+ }
96
+ export type ExamType = "impact" | "dream_delta" | "tournament" | "continuity" | "recall_pr" | "forgetting" | "skill_abstraction";
97
+ export type ExamRunStatus = "ok" | "partial" | "inconclusive_judge_error";
98
+ export type ExamVerdictValue = "improved" | "no_detectable_change" | "regressed";
99
+ /** One grader suite-critique line, attributed to the run's task AT THE SOURCE (DESIGN §7.6).
100
+ * `text` may quote the sealed assertion TEXT verbatim and name NO taskId — so redaction MUST drop
101
+ * by `taskId`, not by substring-matching the taskId inside `text` (the Law-1 sealed-text leak fix).
102
+ * `taskId` is "" for suite-level entries that belong to no single task (e.g. a judge-outage note). */
103
+ export interface SuiteCritiqueEntry {
104
+ taskId: string;
105
+ text: string;
106
+ }
107
+ export interface RecallMetrics {
108
+ precisionInterference: number;
109
+ recall: number;
110
+ staleWithholdRate: number;
111
+ privacyWithholdRate: number;
112
+ tp: number;
113
+ fp: number;
114
+ fn: number;
115
+ tn: number;
116
+ nPositive: number;
117
+ nNegInterference: number;
118
+ nNegStale: number;
119
+ nNegPrivacy: number;
120
+ }
121
+ export interface ArmAggregate {
122
+ arm: ArmSpec;
123
+ passRate: number;
124
+ stddev: number;
125
+ n: number;
126
+ runs: RunResult[];
127
+ recallMetrics?: RecallMetrics;
128
+ }
129
+ export interface ArmComparison {
130
+ baseline: ArmSpec;
131
+ candidate: ArmSpec;
132
+ flips: {
133
+ taskId: string;
134
+ direction: "gain" | "loss";
135
+ lowConfidence?: boolean;
136
+ }[];
137
+ nDiscordant: number;
138
+ nGain: number;
139
+ nLoss: number;
140
+ pValue: number;
141
+ significant: boolean;
142
+ delta: number;
143
+ }
144
+ export interface StatTestConfig {
145
+ test: "exact_sign";
146
+ alpha: number;
147
+ targetPower: number;
148
+ sided: "two";
149
+ repAggregation: "majority_vote";
150
+ significanceFloorDiscordant: 6;
151
+ }
152
+ export interface ExamVerdict {
153
+ examType: ExamType;
154
+ taskSetVersion: string;
155
+ rubricVersion: string;
156
+ evalVersion: string;
157
+ statTest: StatTestConfig;
158
+ runStatus: ExamRunStatus;
159
+ arms: ArmAggregate[];
160
+ comparisons?: ArmComparison[];
161
+ verdict: ExamVerdictValue | null;
162
+ powerNote: string;
163
+ suiteCritique: SuiteCritiqueEntry[];
164
+ evaluatedAt: string;
165
+ loaderSha?: string;
166
+ judgeDeployment?: string;
167
+ }
168
+ export interface RedactedArmAggregate {
169
+ arm: ArmSpec;
170
+ passRate: number;
171
+ stddev: number;
172
+ n: number;
173
+ runsRedacted: true;
174
+ recallMetrics?: RecallMetrics;
175
+ }
176
+ export interface RedactedExamVerdict extends Omit<ExamVerdict, "arms"> {
177
+ arms: RedactedArmAggregate[];
178
+ redacted: true;
179
+ }
180
+ export type TaskSlice = "dev" | "sealed";
181
+ export type TaskShape = "single_shot" | "episode";
182
+ export type AssertionPolarity = "must_hold" | "must_not_hold";
183
+ export type PairingClass = "impact" | "dream_delta" | "control" | "recall_negative";
184
+ export type SignoffStatus = "draft" | "proposed" | "approved" | "retired";
185
+ export interface TaskAssertion {
186
+ id: string;
187
+ text: string;
188
+ polarity: AssertionPolarity;
189
+ recallTarget?: string;
190
+ negativeClass?: "interference" | "stale" | "privacy";
191
+ }
192
+ export interface SeedFile {
193
+ path: string;
194
+ content: string;
195
+ }
196
+ export type ConsolidationEdit = {
197
+ op: "capture";
198
+ path: string;
199
+ content: string;
200
+ evidence: string;
201
+ } | {
202
+ op: "supersede";
203
+ path: string;
204
+ content: string;
205
+ supersedes: string;
206
+ evidence: string;
207
+ } | {
208
+ op: "retract";
209
+ path: string;
210
+ reason: string;
211
+ evidence: string;
212
+ };
213
+ export interface ExamTask {
214
+ taskId: string;
215
+ taskSetVersion: string;
216
+ title: string;
217
+ slice: TaskSlice;
218
+ shape: TaskShape;
219
+ probe?: {
220
+ turn: string;
221
+ };
222
+ episode?: {
223
+ seedTurns: {
224
+ role: "user" | "assistant";
225
+ text: string;
226
+ }[];
227
+ consolidate: boolean;
228
+ probeTurns: {
229
+ role: "user" | "assistant";
230
+ text: string;
231
+ }[];
232
+ consolidationEffect?: ConsolidationEdit[];
233
+ };
234
+ seed?: {
235
+ files: SeedFile[];
236
+ };
237
+ armsApplicability: {
238
+ requires: string[];
239
+ appliesTo: string[];
240
+ pairingClass: PairingClass;
241
+ };
242
+ assertions: TaskAssertion[];
243
+ provenance: {
244
+ source: "transcript" | "spike_probe" | "synthetic";
245
+ sourceRefs: string[];
246
+ derivedBy: string;
247
+ contentFilterChecked: boolean;
248
+ };
249
+ signoff: {
250
+ status: SignoffStatus;
251
+ approvedBy?: string;
252
+ approvedAt?: string;
253
+ approvalRef?: string;
254
+ };
255
+ }
256
+ export interface TaskSetManifest {
257
+ taskSetVersion: string;
258
+ worker: string;
259
+ createdAt: string;
260
+ basedOnSpike?: string;
261
+ slices: {
262
+ dev: string[];
263
+ sealed: string[];
264
+ };
265
+ signoffRollup: {
266
+ approved: number;
267
+ pending: number;
268
+ };
269
+ calibrationTargets?: {
270
+ taskId: string;
271
+ spikeProbe: string;
272
+ expectedFlip: string;
273
+ }[];
274
+ }
275
+ /** The single exam grader-prose constant (DESIGN §7.6). Distinct from the gate's `f1.x` line.
276
+ * Bump on ANY grader-prose change (criteria text, input builders, suite-critique prompt,
277
+ * parser semantics); a bump resets the exam-side validation window. Pinned into
278
+ * ExamVerdict.evalVersion on every verdict. */
279
+ export declare const EXAM_EVAL_VERSION = "exam-f2.0";
280
+ /**
281
+ * The ONLY permitted producer of an E1-facing feed from a full ExamVerdict (DESIGN §7.6 #1).
282
+ * Pure + total. Sealed-task runs collapse to aggregates; dev-only verdicts pass through
283
+ * UNCHANGED (identity). Strips ALL sealed-task TEXT (assertions, evidence, raw turns,
284
+ * implicitClaims, the runs[] array) AND drops any suiteCritique entry attributed to a
285
+ * sealed taskId — BY ID, not by substring-matching the taskId inside the text. A grader
286
+ * FEEDBACK line quotes the sealed assertion TEXT and may name no taskId at all, so a
287
+ * substring scan leaks it; id-based attribution (set on the entry at the source) closes
288
+ * the leak (the Law-1 sealed-text fix). KEEPS the version provenance
289
+ * (rubricVersion / evalVersion / loaderSha / judgeDeployment) — they name THAT something
290
+ * changed, not WHAT, and are public-safe (§7.6 #2). comparisons[].flips keep
291
+ * direction + taskId so per-task flip counts survive for the sign test.
292
+ * Returns RedactedExamVerdict iff ANY arm contains a sealed task, else the verdict unchanged.
293
+ */
294
+ export declare function redactForFeed(verdict: ExamVerdict, sealedTaskIds: Set<string>): ExamVerdict | RedactedExamVerdict;
295
+ //# sourceMappingURL=brain-eval.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brain-eval.d.ts","sourceRoot":"","sources":["../../src/brain-eval.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,QAAQ,GAAG,cAAc,CAAC;AACjE,MAAM,MAAM,eAAe,GAAG,IAAI,GAAG,SAAS,GAAG,aAAa,CAAC;AAE/D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE;QACN,cAAc,EAAE,MAAM,GAAG,MAAM,CAAC;QAChC,SAAS,EAAE,OAAO,CAAC;QACnB;yFACiF;QACjF,SAAS,CAAC,EAAE;YAAE,MAAM,EAAE,OAAO,CAAC;YAAC,SAAS,EAA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,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,kBAAkB,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACrF;AAED;;;gDAGgD;AAChD,eAAO,MAAM,iBAAiB,cAAc,CAAC;AAE7C;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,WAAW,EACpB,aAAa,EAAE,GAAG,CAAC,MAAM,CAAC,GACzB,WAAW,GAAG,mBAAmB,CA+BnC"}
@@ -0,0 +1,54 @@
1
+ // Brain Faculties Evaluation — wire shapes emitted by the Python brain-eval core (camelCase JSON).
2
+ // Mirror of the Brain Faculties Evaluation EPIC §6. The Python dataclasses are authoritative for the
3
+ // running core; these are the typed view consumers (the brain-F3 librarian, future sinks) read.
4
+ /** The single exam grader-prose constant (DESIGN §7.6). Distinct from the gate's `f1.x` line.
5
+ * Bump on ANY grader-prose change (criteria text, input builders, suite-critique prompt,
6
+ * parser semantics); a bump resets the exam-side validation window. Pinned into
7
+ * ExamVerdict.evalVersion on every verdict. */
8
+ export const EXAM_EVAL_VERSION = "exam-f2.0";
9
+ /**
10
+ * The ONLY permitted producer of an E1-facing feed from a full ExamVerdict (DESIGN §7.6 #1).
11
+ * Pure + total. Sealed-task runs collapse to aggregates; dev-only verdicts pass through
12
+ * UNCHANGED (identity). Strips ALL sealed-task TEXT (assertions, evidence, raw turns,
13
+ * implicitClaims, the runs[] array) AND drops any suiteCritique entry attributed to a
14
+ * sealed taskId — BY ID, not by substring-matching the taskId inside the text. A grader
15
+ * FEEDBACK line quotes the sealed assertion TEXT and may name no taskId at all, so a
16
+ * substring scan leaks it; id-based attribution (set on the entry at the source) closes
17
+ * the leak (the Law-1 sealed-text fix). KEEPS the version provenance
18
+ * (rubricVersion / evalVersion / loaderSha / judgeDeployment) — they name THAT something
19
+ * changed, not WHAT, and are public-safe (§7.6 #2). comparisons[].flips keep
20
+ * direction + taskId so per-task flip counts survive for the sign test.
21
+ * Returns RedactedExamVerdict iff ANY arm contains a sealed task, else the verdict unchanged.
22
+ */
23
+ export function redactForFeed(verdict, sealedTaskIds) {
24
+ // Redact if ANY sealed reference exists — a sealed run in an arm OR a sealed-attributed suiteCritique
25
+ // entry. The latter guard means a sealed critique can never slip through via the identity path.
26
+ const hasSealedRun = verdict.arms.some((a) => a.runs.some((r) => sealedTaskIds.has(r.taskId)));
27
+ const hasSealedCritique = verdict.suiteCritique.some((c) => sealedTaskIds.has(c.taskId));
28
+ if (!hasSealedRun && !hasSealedCritique)
29
+ return verdict; // dev-only -> identity pass-through (total + cheap)
30
+ const redactedArms = verdict.arms.map((a) => {
31
+ const ra = {
32
+ arm: a.arm,
33
+ passRate: a.passRate,
34
+ stddev: a.stddev,
35
+ n: a.n,
36
+ runsRedacted: true,
37
+ };
38
+ if (a.recallMetrics !== undefined)
39
+ ra.recallMetrics = a.recallMetrics; // F3 §5.4: aggregate → feed-safe
40
+ return ra;
41
+ });
42
+ // Drop any suiteCritique entry attributed to a sealed task — BY ID (not substring): the entry's
43
+ // `text` may quote the sealed assertion verbatim and name no taskId, so id attribution is the
44
+ // only sound drop (the Law-1 sealed-text leak fix).
45
+ const cleanedCritique = verdict.suiteCritique.filter((c) => !sealedTaskIds.has(c.taskId));
46
+ const { arms: _arms, suiteCritique: _sc, ...rest } = verdict;
47
+ return {
48
+ ...rest,
49
+ arms: redactedArms,
50
+ suiteCritique: cleanedCritique,
51
+ redacted: true,
52
+ };
53
+ }
54
+ //# sourceMappingURL=brain-eval.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brain-eval.js","sourceRoot":"","sources":["../../src/brain-eval.ts"],"names":[],"mappings":"AAAA,mGAAmG;AACnG,qGAAqG;AACrG,gGAAgG;AAgQhG;;;gDAGgD;AAChD,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAE7C;;;;;;;;;;;;;GA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,EAAE,aAAa,EAAE,GAAG,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC7D,OAAO;QACL,GAAG,IAAI;QACP,IAAI,EAAE,YAAY;QAClB,aAAa,EAAE,eAAe;QAC9B,QAAQ,EAAE,IAAI;KACf,CAAC;AACJ,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The worker↔repo link record. Stored on the Foundry agent under
3
+ * `metadata.brain` as a JSON STRING (Foundry metadata is a flat
4
+ * Record<string,string>).
5
+ *
6
+ * F1 shipped this in plugins/m8t-stack/server/src/brain-link.ts. F2 promotes
7
+ * it here so the CLI + gateway + plugin all import from one place. The
8
+ * plugin server file becomes a thin re-export for back-compat.
9
+ *
10
+ * F1↔F2 distinction:
11
+ * - PAT mode (F1): installationId absent. Connection holds a static PAT.
12
+ * - App mode (F2): installationId present. Connection holds an App-minted
13
+ * installation token, rotated lazily on every invoke.
14
+ */
15
+ export interface BrainLink {
16
+ repo: string;
17
+ branch: string;
18
+ topology: "per-worker" | "shared";
19
+ schemaVersion: string;
20
+ /**
21
+ * Foundry project-connection name holding the GitHub credential.
22
+ * Special value: `"in-container"` is the hosted-worker sentinel — the token
23
+ * is minted INSIDE the container (no Foundry connection exists). Invoke-path
24
+ * rotation MUST skip links with this value.
25
+ */
26
+ credentialRef: string;
27
+ installationId?: string;
28
+ instanceFolder?: string;
29
+ }
30
+ /**
31
+ * Parse the brain link from Foundry agent metadata. Defensive: absent or
32
+ * malformed returns undefined and never throws — discovery must not break on
33
+ * a hand-written or partial `metadata.brain`.
34
+ */
35
+ export declare function parseBrainLink(metadata: Record<string, string> | undefined): BrainLink | undefined;
36
+ /** True when the link uses GitHub App authentication (F2 mode). A type guard so
37
+ * callers that mint with the installation id narrow it to a present string. */
38
+ export declare function isAppMode(link: BrainLink): link is BrainLink & {
39
+ installationId: string;
40
+ };
41
+ /** Sentinel credentialRef for hosted workers: the token is minted INSIDE the
42
+ * container (no Foundry connection). Invoke-path rotation must skip these. */
43
+ export declare const IN_CONTAINER_CREDENTIAL_REF = "in-container";
44
+ /** True when the link is a hosted/in-container brain (token minted in-sandbox;
45
+ * there is NO Foundry connection to rotate). */
46
+ export declare function isInContainer(link: BrainLink): boolean;
47
+ /** Serialize a BrainLink to the Foundry-metadata JSON string. */
48
+ export declare function serializeBrainLink(link: BrainLink): string;
49
+ //# sourceMappingURL=brain-link.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brain-link.d.ts","sourceRoot":"","sources":["../../src/brain-link.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,YAAY,GAAG,QAAQ,CAAC;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,GAC3C,SAAS,GAAG,SAAS,CAmBvB;AAED;gFACgF;AAChF,wBAAgB,SAAS,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,IAAI,SAAS,GAAG;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,CAEzF;AAED;+EAC+E;AAC/E,eAAO,MAAM,2BAA2B,iBAAiB,CAAC;AAE1D;iDACiD;AACjD,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,GAAG,OAAO,CAEtD;AAED,iEAAiE;AACjE,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,CAE1D"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Parse the brain link from Foundry agent metadata. Defensive: absent or
3
+ * malformed returns undefined and never throws — discovery must not break on
4
+ * a hand-written or partial `metadata.brain`.
5
+ */
6
+ export function parseBrainLink(metadata) {
7
+ const raw = metadata?.brain;
8
+ if (!raw)
9
+ return undefined;
10
+ try {
11
+ const obj = JSON.parse(raw);
12
+ if (!obj || typeof obj.repo !== "string" || obj.repo.length === 0)
13
+ return undefined;
14
+ return {
15
+ repo: obj.repo,
16
+ branch: typeof obj.branch === "string" && obj.branch ? obj.branch : "main",
17
+ topology: obj.topology === "shared" ? "shared" : "per-worker",
18
+ schemaVersion: typeof obj.schemaVersion === "string" && obj.schemaVersion ? obj.schemaVersion : "1",
19
+ credentialRef: typeof obj.credentialRef === "string" ? obj.credentialRef : "",
20
+ ...(typeof obj.installationId === "string" ? { installationId: obj.installationId } : {}),
21
+ ...(typeof obj.instanceFolder === "string" ? { instanceFolder: obj.instanceFolder } : {}),
22
+ };
23
+ }
24
+ catch {
25
+ return undefined;
26
+ }
27
+ }
28
+ /** True when the link uses GitHub App authentication (F2 mode). A type guard so
29
+ * callers that mint with the installation id narrow it to a present string. */
30
+ export function isAppMode(link) {
31
+ return typeof link.installationId === "string" && link.installationId.length > 0;
32
+ }
33
+ /** Sentinel credentialRef for hosted workers: the token is minted INSIDE the
34
+ * container (no Foundry connection). Invoke-path rotation must skip these. */
35
+ export const IN_CONTAINER_CREDENTIAL_REF = "in-container";
36
+ /** True when the link is a hosted/in-container brain (token minted in-sandbox;
37
+ * there is NO Foundry connection to rotate). */
38
+ export function isInContainer(link) {
39
+ return link.credentialRef === IN_CONTAINER_CREDENTIAL_REF;
40
+ }
41
+ /** Serialize a BrainLink to the Foundry-metadata JSON string. */
42
+ export function serializeBrainLink(link) {
43
+ return JSON.stringify(link);
44
+ }
45
+ //# sourceMappingURL=brain-link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brain-link.js","sourceRoot":"","sources":["../../src/brain-link.ts"],"names":[],"mappings":"AA8BA;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,QAA4C;IAE5C,MAAM,GAAG,GAAG,QAA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;AAChF,MAAM,UAAU,SAAS,CAAC,IAAe;IACvC,OAAO,OAAO,IAAI,CAAC,cAAc,KAAK,QAAQ,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC;AACnF,CAAC;AAED;+EAC+E;AAC/E,MAAM,CAAC,MAAM,2BAA2B,GAAG,cAAc,CAAC;AAE1D;iDACiD;AACjD,MAAM,UAAU,aAAa,CAAC,IAAe;IAC3C,OAAO,IAAI,CAAC,aAAa,KAAK,2BAA2B,CAAC;AAC5D,CAAC;AAED,iEAAiE;AACjE,MAAM,UAAU,kBAAkB,CAAC,IAAe;IAChD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,39 @@
1
+ export declare abstract class ApiError extends Error {
2
+ abstract readonly code: string;
3
+ abstract readonly status: number;
4
+ readonly details?: unknown;
5
+ constructor(message: string, details?: unknown);
6
+ }
7
+ export declare class UnauthenticatedError extends ApiError {
8
+ readonly code = "UNAUTHENTICATED";
9
+ readonly status = 401;
10
+ }
11
+ export declare class ForbiddenError extends ApiError {
12
+ readonly code = "FORBIDDEN";
13
+ readonly status = 403;
14
+ }
15
+ export declare class BadRequestError extends ApiError {
16
+ readonly code = "BAD_REQUEST";
17
+ readonly status = 400;
18
+ }
19
+ export declare class NotFoundError extends ApiError {
20
+ readonly code = "NOT_FOUND";
21
+ readonly status = 404;
22
+ }
23
+ export declare class ConflictError extends ApiError {
24
+ readonly code = "CONFLICT";
25
+ readonly status = 409;
26
+ }
27
+ export declare class RateLimitedError extends ApiError {
28
+ readonly code = "RATE_LIMITED";
29
+ readonly status = 429;
30
+ }
31
+ export declare class UpstreamError extends ApiError {
32
+ readonly code = "UPSTREAM_FAILED";
33
+ readonly status = 502;
34
+ }
35
+ export declare class InternalError extends ApiError {
36
+ readonly code = "INTERNAL";
37
+ readonly status = 500;
38
+ }
39
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+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(message);
5
+ this.name = this.constructor.name;
6
+ this.details = details;
7
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- V8-specific API absent in non-Node environments; typed as always-present in @types/node but runtime presence is not guaranteed
8
+ if (Error.captureStackTrace) {
9
+ Error.captureStackTrace(this, this.constructor);
10
+ }
11
+ }
12
+ }
13
+ export class UnauthenticatedError extends ApiError {
14
+ code = "UNAUTHENTICATED";
15
+ status = 401;
16
+ }
17
+ export class ForbiddenError extends ApiError {
18
+ code = "FORBIDDEN";
19
+ status = 403;
20
+ }
21
+ export class BadRequestError extends ApiError {
22
+ code = "BAD_REQUEST";
23
+ status = 400;
24
+ }
25
+ export class NotFoundError extends ApiError {
26
+ code = "NOT_FOUND";
27
+ status = 404;
28
+ }
29
+ export class ConflictError extends ApiError {
30
+ code = "CONFLICT";
31
+ status = 409;
32
+ }
33
+ export class RateLimitedError extends ApiError {
34
+ code = "RATE_LIMITED";
35
+ status = 429;
36
+ }
37
+ export class UpstreamError extends ApiError {
38
+ code = "UPSTREAM_FAILED";
39
+ status = 502;
40
+ }
41
+ export class InternalError extends ApiError {
42
+ code = "INTERNAL";
43
+ status = 500;
44
+ }
45
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,QAAS,SAAQ,KAAK;IAGjC,OAAO,CAAW;IAE3B,YAAY,OAAe,EAAE,OAAiB;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,yMAAyM;QACzM,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,QAAQ;IACvC,IAAI,GAAG,iBAAiB,CAAC;IACzB,MAAM,GAAG,GAAG,CAAC;CACvB;AAED,MAAM,OAAO,cAAe,SAAQ,QAAQ;IACjC,IAAI,GAAG,WAAW,CAAC;IACnB,MAAM,GAAG,GAAG,CAAC;CACvB;AAED,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAClC,IAAI,GAAG,aAAa,CAAC;IACrB,MAAM,GAAG,GAAG,CAAC;CACvB;AAED,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAChC,IAAI,GAAG,WAAW,CAAC;IACnB,MAAM,GAAG,GAAG,CAAC;CACvB;AAED,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAChC,IAAI,GAAG,UAAU,CAAC;IAClB,MAAM,GAAG,GAAG,CAAC;CACvB;AAED,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IACnC,IAAI,GAAG,cAAc,CAAC;IACtB,MAAM,GAAG,GAAG,CAAC;CACvB;AAED,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAChC,IAAI,GAAG,iBAAiB,CAAC;IACzB,MAAM,GAAG,GAAG,CAAC;CACvB;AAED,MAAM,OAAO,aAAc,SAAQ,QAAQ;IAChC,IAAI,GAAG,UAAU,CAAC;IAClB,MAAM,GAAG,GAAG,CAAC;CACvB"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * The normalized inbound-message shape every channel adapter produces.
3
+ *
4
+ * Locked per EPIC §7.1. Workers consume only this; adapter parsing is the
5
+ * sole channel-specific concern. Adding fields is additive (workers ignore
6
+ * unknown fields); removing or renaming requires an epic-level revision.
7
+ *
8
+ * F4 originally shipped this at apps/web/lib/channels/_core/envelope.ts.
9
+ * F5 moves it here so both the webhook dispatcher (apps/web) and the SB
10
+ * wire-contract (this package) can import from a single source. F04's
11
+ * original path becomes a re-export.
12
+ */
13
+ export interface InboundEnvelope {
14
+ /** Stable channel discriminator: "telegram" | "slack" | "teams" | ... */
15
+ channel: string;
16
+ /** The binding this message was routed to — resolved from the webhook URL path. */
17
+ bindingId: string;
18
+ /** Sender's native ID on the channel — TeamMembers authz lookup key. */
19
+ channelUserId: string;
20
+ /** Best-effort display name from the channel payload, for Foundry metadata + logs. */
21
+ userDisplayName?: string;
22
+ /** Chat surface's native ID — used for Conversation thread routing. */
23
+ channelChatId: string;
24
+ /** Plain text ready to pass as `responses.create` input. */
25
+ messageText: string;
26
+ /** Channel-native message ID, used for idempotency. */
27
+ messageId: string;
28
+ /** ISO 8601 timestamp when the webhook was received. */
29
+ receivedAt: string;
30
+ /**
31
+ * Opaque, channel-specific blob the adapter needs back at reply time.
32
+ * Telegram: { chatId, replyToMessageId }
33
+ * Slack: { channelId, threadTs }
34
+ * Teams: { serviceUrl, conversationId }
35
+ *
36
+ * Serialized into Service Bus messages; deserialized on the worker side
37
+ * and passed back to the adapter's sendReply / sendTypingIndicator.
38
+ */
39
+ replyHandle: unknown;
40
+ /** Adapter-side pre-filter (e.g. DM-only check in Telegram MVP). */
41
+ shouldHandle: boolean;
42
+ }
43
+ //# sourceMappingURL=inbound-envelope.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound-envelope.d.ts","sourceRoot":"","sources":["../../src/inbound-envelope.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B,yEAAyE;IACzE,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,aAAa,EAAE,MAAM,CAAC;IACtB,sFAAsF;IACtF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uEAAuE;IACvE,aAAa,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB,uDAAuD;IACvD,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC;IACnB;;;;;;;;OAQG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB,oEAAoE;IACpE,YAAY,EAAE,OAAO,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inbound-envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound-envelope.js","sourceRoot":"","sources":["../../src/inbound-envelope.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ export * from "./response.js";
2
+ export * from "./errors.js";
3
+ export * from "./reasons.js";
4
+ export * from "./team.js";
5
+ export * from "./me.js";
6
+ export * from "./binding.js";
7
+ export * from "./inbound-envelope.js";
8
+ export * from "./service-bus.js";
9
+ export type { BrainLink } from "./brain-link.js";
10
+ export { parseBrainLink, isAppMode, serializeBrainLink, isInContainer, IN_CONTAINER_CREDENTIAL_REF } from "./brain-link.js";
11
+ export type { A2aCard } from "./a2a-card.js";
12
+ export { serializeA2aCard, parseA2aCard, A2A_CARD_MAX_CHARS } from "./a2a-card.js";
13
+ export * from "./brain-eval.js";
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AACjC,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC5H,YAAY,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnF,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from "./response.js";
2
+ export * from "./errors.js";
3
+ export * from "./reasons.js";
4
+ export * from "./team.js";
5
+ export * from "./me.js";
6
+ export * from "./binding.js";
7
+ export * from "./inbound-envelope.js";
8
+ export * from "./service-bus.js";
9
+ export { parseBrainLink, isAppMode, serializeBrainLink, isInContainer, IN_CONTAINER_CREDENTIAL_REF } from "./brain-link.js";
10
+ export { serializeA2aCard, parseA2aCard, A2A_CARD_MAX_CHARS } from "./a2a-card.js";
11
+ export * from "./brain-eval.js";
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,kBAAkB,EAAE,aAAa,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE5H,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnF,cAAc,iBAAiB,CAAC"}