@jini-ai/http-kit 0.3.2 → 0.3.6

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/adapter.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Express } from 'express';
2
+ import { type ApiError } from '@jini-ai/protocol';
2
3
  import { type OriginContext } from './origin.js';
3
4
  import type { JsonRouteSpec } from './types.js';
4
5
  export interface AdapterInternalErrorContext {
@@ -21,6 +22,31 @@ export interface AdapterContext extends OriginContext {
21
22
  */
22
23
  readonly onInternalError?: (context: AdapterInternalErrorContext) => void;
23
24
  }
25
+ /**
26
+ * Thrown by a route's `handle` — or by anything it calls, at any depth — to bypass the SEC-005
27
+ * redaction below with an `ApiError` the throwing code has already decided is safe for the caller
28
+ * to see. This is the general-purpose version of a carve-out every consuming module of this catch
29
+ * otherwise hand-rolls for itself: `attachments.ts`'s `AttachmentRejectedError`/
30
+ * `respondToUploadFailure`, and `delegated-tools.ts`'s `errorKind: 'validation'` split on
31
+ * `ToolExecutionResult`, both exist because nothing at THIS layer distinguished "the code that threw
32
+ * already classified this as caller-safe" from "something unanticipated happened" — so a route with
33
+ * no such local carve-out has no way to disclose even a deliberately-safe failure, and everything it
34
+ * throws redacts identically to a stray filesystem or driver error.
35
+ *
36
+ * Prefer returning `err(apiError)` from `handle` when the failure is anticipated at that point —
37
+ * that path already reaches the caller with full fidelity and never touches this catch at all. This
38
+ * class exists for the same kind of failure discovered a level deeper: inside an awaited call
39
+ * `handle` itself did not (or could not) wrap in its own `try`.
40
+ *
41
+ * Not a way to defeat SEC-005: the only way to reach the branch that reads this class is for code to
42
+ * construct one itself, naming the exact `ApiError` — code and message — it is choosing to disclose.
43
+ * Any thrown value that is not this class (including a plain `Error` with an actionable-looking
44
+ * message) still redacts exactly as before; nothing here widens what a route can leak by accident.
45
+ */
46
+ export declare class ClientFacingError extends Error {
47
+ readonly apiError: ApiError;
48
+ constructor(apiError: ApiError);
49
+ }
24
50
  /**
25
51
  * Identity function that pins a route spec's generic parameters at the definition site so
26
52
  * callers do not have to repeat them. The returned spec is consumed by `mountJsonRoute` (live)
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,OAAO,EAAqB,MAAM,SAAS,CAAC;AAI1D,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,WAAW,2BAA2B;IAC1C,oDAAoD;IACpD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,wHAAwH;IACxH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;CACzB;AAED,oFAAoF;AACpF,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC;CAC3E;AAOD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EACjD,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,GACvC,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAEpC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAChD,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EACxC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,cAAc,GACtB,IAAI,CA4DN"}
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources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c,GACtB,IAAI,CAmEN"}
package/dist/adapter.js CHANGED
@@ -12,6 +12,35 @@ function defaultInternalErrorSink(context) {
12
12
  // eslint-disable-next-line no-console
13
13
  console.error(`[@jini-ai/http-kit] internal error (${context.method.toUpperCase()} ${context.path}, correlationId=${context.correlationId})`, context.error);
14
14
  }
15
+ /**
16
+ * Thrown by a route's `handle` — or by anything it calls, at any depth — to bypass the SEC-005
17
+ * redaction below with an `ApiError` the throwing code has already decided is safe for the caller
18
+ * to see. This is the general-purpose version of a carve-out every consuming module of this catch
19
+ * otherwise hand-rolls for itself: `attachments.ts`'s `AttachmentRejectedError`/
20
+ * `respondToUploadFailure`, and `delegated-tools.ts`'s `errorKind: 'validation'` split on
21
+ * `ToolExecutionResult`, both exist because nothing at THIS layer distinguished "the code that threw
22
+ * already classified this as caller-safe" from "something unanticipated happened" — so a route with
23
+ * no such local carve-out has no way to disclose even a deliberately-safe failure, and everything it
24
+ * throws redacts identically to a stray filesystem or driver error.
25
+ *
26
+ * Prefer returning `err(apiError)` from `handle` when the failure is anticipated at that point —
27
+ * that path already reaches the caller with full fidelity and never touches this catch at all. This
28
+ * class exists for the same kind of failure discovered a level deeper: inside an awaited call
29
+ * `handle` itself did not (or could not) wrap in its own `try`.
30
+ *
31
+ * Not a way to defeat SEC-005: the only way to reach the branch that reads this class is for code to
32
+ * construct one itself, naming the exact `ApiError` — code and message — it is choosing to disclose.
33
+ * Any thrown value that is not this class (including a plain `Error` with an actionable-looking
34
+ * message) still redacts exactly as before; nothing here widens what a route can leak by accident.
35
+ */
36
+ export class ClientFacingError extends Error {
37
+ apiError;
38
+ constructor(apiError) {
39
+ super(apiError.message);
40
+ this.name = 'ClientFacingError';
41
+ this.apiError = apiError;
42
+ }
43
+ }
15
44
  /**
16
45
  * Identity function that pins a route spec's generic parameters at the definition site so
17
46
  * callers do not have to repeat them. The returned spec is consumed by `mountJsonRoute` (live)
@@ -72,6 +101,13 @@ export function mountJsonRoute(app, spec, deps, adapter) {
72
101
  sendJson(res, spec.successStatus ?? 200, result.value);
73
102
  }
74
103
  catch (e) {
104
+ // A route (or something it called) already classified this failure as safe to disclose —
105
+ // see `ClientFacingError`'s own doc. Sent verbatim, at its own status; never routed to the
106
+ // SEC-005 sink below, because nothing unanticipated happened.
107
+ if (e instanceof ClientFacingError) {
108
+ sendApiError(res, statusForError(e.apiError), e.apiError);
109
+ return;
110
+ }
75
111
  // SEC-005. This catch exists for exceptions no route anticipated, which makes it precisely
76
112
  // the path most likely to be holding something private: a driver error naming a database
77
113
  // file, a connection string, a credential a provider echoed back. Serializing `e.message`
@@ -1 +1 @@
1
- {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,eAAe,EAAsB,MAAM,aAAa,CAAC;AAyBlE,SAAS,wBAAwB,CAAC,OAAoC;IACpE,sCAAsC;IACtC,OAAO,CAAC,KAAK,CAAC,uCAAuC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,IAAI,mBAAmB,OAAO,CAAC,aAAa,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/J,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,IAAwC;IAExC,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,GAAY,EACZ,IAAwC,EACxC,IAAU,EACV,OAAuB;IAEvB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,GAAY,EAAE,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C9D,IAAI,CAAC,YAAY,iBAAiB,EAAE,CAAC;gBACnC,YAAY,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;gBAC1D,OAAO;YACT,CAAC;YACD,2FAA2F;YAC3F,yFAAyF;YACzF,0FAA0F;YAC1F,4FAA4F;YAC5F,8FAA8F;YAC9F,6FAA6F;YAC7F,uFAAuF;YACvF,MAAM,aAAa,GAAG,UAAU,EAAE,CAAC;YACnC,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,IAAI,wBAAwB,CAAC;YACjE,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YACxE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,CAAC,gBAAgB,EAAE,4BAA4B,EAAE,EAAE,SAAS,EAAE,aAAa,EAAE,CAAC,CAAC,CAAC;QACvH,CAAC;gBAAS,CAAC;YACT,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QACtC,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
package/dist/agents.d.ts CHANGED
@@ -37,7 +37,8 @@ export interface AgentSummary {
37
37
  readonly supportsCustomModel?: boolean;
38
38
  readonly diagnostic?: string;
39
39
  /**
40
- * Whether this runtime can receive external MCP servers (Tovu/Jini tools) at all, per
40
+ * Whether this runtime can receive external MCP servers (the host application's or this engine's
41
+ * own tools) at all, per
41
42
  * `@jini-ai/agent-runtime`'s `runtimeSupportsExternalTools(def)` — the def-level source of
42
43
  * truth. `undefined` means the host did not populate this field (pre-existing hosts on an older
43
44
  * `@jini-ai/http-kit` continue to omit it); a UI gating on this should treat `undefined` the same
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts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AAoB;IAC1B,iBAAiB,EAAE,IAAI;IACvB,KAAK,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC;IAC1B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,CAAC;CAC/F,CAAC,CAAC;AAEH,kEAAkE;AAClE,MAAM,UAAU,mBAAmB,CAAC,GAAY,EAAE,IAAoB,EAAE,OAAuB;IAC7F,cAAc,CAAC,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACnD,cAAc,CAAC,GAAG,EAAE,gBAAgB,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AACvD,CAAC"}
@@ -97,9 +97,78 @@ export interface AttachmentStore {
97
97
  name: string;
98
98
  kind: StoredAttachment['kind'];
99
99
  size: number;
100
+ /** See `AttachmentRecord.ownerId`'s own doc. Omitted by a host with no owner concept. */
101
+ ownerId?: string;
100
102
  }) => Promise<StoredAttachment>;
101
103
  /** Exchanges capability ids for real paths, exactly once, binding them to `runId`. */
102
104
  claim: (attachments: readonly StoredAttachment[], runId: string) => Promise<AttachmentClaim>;
105
+ /**
106
+ * Resolves ONE still-known attachment to its real path for `runId`, without the "exactly once
107
+ * across the whole batch" shape `claim()` has — the read-side counterpart for a caller that wants
108
+ * to look up a single attachment it may or may not already own, rather than atomically reserving a
109
+ * batch at run start.
110
+ *
111
+ * `ref` accepts either identifier a caller may actually be holding: the opaque `attachment:<uuid>`
112
+ * capability id `register()` returned, or the real absolute path this run was already told about.
113
+ * Both resolve to the same record. This dual form exists because `@jini-ai/daemon`'s
114
+ * `image-prompt-delivery.ts` narrates the resolved PATH into the run's prompt text for an
115
+ * already-claimed attachment — never the id — so a caller built from that prompt has the path, not
116
+ * the id; a caller with the id (from the original upload response) can still use it directly.
117
+ *
118
+ * Ownership is enforced here, which is new: an attachment nobody has claimed yet is claimed for
119
+ * `runId` on this call (identical effect to `claim()`, same integrity re-check); an attachment
120
+ * already claimed BY `runId` is simply re-verified and returned again (idempotent — a run may look
121
+ * this up more than once); an attachment claimed by any OTHER run throws the same
122
+ * `'attachment-unknown-or-claimed'` rejection `claim()` uses for a genuinely unknown id, so a
123
+ * caller cannot distinguish "no such attachment" from "a different run owns this" — the same
124
+ * non-disclosure `claim()` already practices for its own rejections. This is the run-ownership
125
+ * check `claim()`'s own FIRST reservation does not have (see this module's trust-model doc on the
126
+ * deliberate capability-bearer model for a brand-new claim); `resolveForRun` adds it for every
127
+ * lookup made through this method, so a second run/session on this same daemon can never read an
128
+ * attachment already bound to someone else's run by calling this method with a guessed or
129
+ * overheard `ref`.
130
+ *
131
+ * Returns `undefined` only for a `ref` this store has never heard of (never uploaded, or its
132
+ * record was already deleted by `cleanupRun`/`pruneExpired`/`dispose`).
133
+ */
134
+ resolveForRun: (ref: string, runId: string) => Promise<StoredAttachment | undefined>;
135
+ /**
136
+ * Lists every still-unclaimed attachment registered with `ownerId` — the discovery counterpart to
137
+ * `resolveForRun`'s single-lookup: a caller that does not yet hold a specific ref at all (an
138
+ * attachment uploaded in an earlier turn, never named in this run's prompt) has no id to look up
139
+ * with `resolveForRun` in the first place. This is what makes that attachment findable.
140
+ *
141
+ * **This is the one method in this port that widens the trust model documented at the top of this
142
+ * file.** `register()`/`claim()`/`resolveForRun` all work from a caller-supplied opaque id or path
143
+ * — the "you must already hold the unguessable capability" property that makes an unauthenticated
144
+ * `claim()` first-reservation safe. A listing necessarily hands back ids the caller never held, so
145
+ * it can only be safe if it is scoped to something the caller is actually entitled to — here, the
146
+ * same principal id a host recorded via `register()`'s `ownerId` for the ORIGINAL upload request.
147
+ *
148
+ * Two things make that scoping real rather than decorative:
149
+ * - an attachment registered with NO `ownerId` (a host that never wired `resolveOwnerId`, or any
150
+ * attachment from before this method existed) is excluded from every caller's results, never
151
+ * just "unscoped" — this method is not callable with `ownerId: undefined`, so there is no input
152
+ * that could accidentally match an ownerless record;
153
+ * - a claimed attachment is excluded outright, whether or not this caller's own `runId` claimed
154
+ * it, so this method can never be used to re-discover something already handed to a run — the
155
+ * same "runs, not listings, are the reach here" boundary `resolveForRun` draws for a single ref.
156
+ *
157
+ * What this does NOT scope by: batch, conversation, or run — none of those are recorded on an
158
+ * `AttachmentRecord` today. Two different conversations run by the SAME `ownerId` will each see
159
+ * the other's pending attachments through this method. A host for whom that is too wide needs a
160
+ * finer-grained id than `ownerId` to pass into `register()` — this method does not itself assume
161
+ * `ownerId` means "one admin account" rather than "one conversation, one composer, one browser
162
+ * tab"; it only assumes the host's `ownerId` is something the CALLER of this method is authorized
163
+ * to see everything under.
164
+ *
165
+ * Sorted oldest-first (`createdAt` ascending) — arrival order, matching how a person would expect
166
+ * to review what is waiting.
167
+ *
168
+ * @complexity O(n) in the number of tracked records (bounded by `maxStoredAttachments`), matching
169
+ * every other method on this port.
170
+ */
171
+ listPendingForOwner: (ownerId: string) => Promise<PendingAttachmentSummary[]>;
103
172
  /** Deletes the named still-unclaimed uploads, then the batch directory if it is now empty. */
104
173
  deleteUnclaimed: (batchId: string, paths: readonly string[]) => Promise<void>;
105
174
  /** Deletes everything `runId` claimed. Safe to call for a run that claimed nothing. */
@@ -122,7 +191,34 @@ export interface CreateDiskAttachmentStoreOptions {
122
191
  readonly maxStoredBytes?: number;
123
192
  /** How long an unclaimed upload survives `pruneExpired`. Defaults to one hour. */
124
193
  readonly retentionMs?: number;
194
+ /**
195
+ * Adopts the uploads a previous process left behind instead of emptying the directory on
196
+ * construction, so an attachment staged seconds before a restart is still there — and still
197
+ * listable — afterwards.
198
+ *
199
+ * **Defaults to `false`, which is exactly this pack's pre-existing behavior.** Opting in is a
200
+ * one-word change at the call site and reverting is deleting it; nothing about a store
201
+ * constructed without this option differs in any way from before the option existed.
202
+ *
203
+ * Adoption is authenticated, not blind: see {@link loadPersistedAttachments}.
204
+ */
205
+ readonly retainAcrossRestarts?: boolean;
125
206
  }
207
+ /**
208
+ * `true` when `body` opens with an ISO-BMFF `ftyp` box whose major brand or compatible-brand list
209
+ * names AVIF. This is a line-for-line mirror of `@jini-ai/cms`'s `content-type-sniffer.ts`
210
+ * `isAvif` (no shared dependency exists between `@jini-ai/http-kit` and `@jini-ai/cms` today — see
211
+ * this module's handoff notes on whether extracting one is worth it): the major brand alone is not
212
+ * sufficient, because a great many real AVIF files declare the generic `mif1` (HEIF image) major
213
+ * brand and name `avif` only in the compatible-brand list, so both are checked. HEIC declares
214
+ * neither and is therefore never matched here — deliberate; nothing downstream of this attachment
215
+ * store has confirmed it can render a HEIC as an `<img>`, so labelling one `'image'` would risk the
216
+ * same "sniffed as a type the surface cannot actually display" failure this whole fix addresses.
217
+ *
218
+ * Must run before any generic `ftyp` check: {@link hasIsoBmffFtypTag} alone cannot tell AVIF, HEIC,
219
+ * and MP4 apart, so a brand-blind caller would misclassify every ISO-BMFF file it sees as one type.
220
+ */
221
+ export declare function hasAvifSignature(body: Uint8Array): boolean;
126
222
  export interface AttachmentRecord {
127
223
  id: string;
128
224
  filePath: string;
@@ -135,6 +231,26 @@ export interface AttachmentRecord {
135
231
  ino: number;
136
232
  createdAt: number;
137
233
  claimedRunId?: string;
234
+ /**
235
+ * The principal a host's `AttachmentsHttpDeps.resolveOwnerId` reported for the request that
236
+ * registered this attachment. Absent when the host supplies no `resolveOwnerId` (this pack's
237
+ * behavior before ownership existed), which is why `listPendingForOwner` treats an absent
238
+ * `ownerId` as "cannot be scoped" rather than as a wildcard match — see that method's own doc.
239
+ */
240
+ ownerId?: string;
241
+ }
242
+ /**
243
+ * What `listPendingForOwner` hands back for one still-unclaimed attachment: enough for a caller to
244
+ * show a person what is waiting, and to name it again (`ref`) to `claim()`/`resolveForRun`.
245
+ */
246
+ export interface PendingAttachmentSummary {
247
+ /** The same opaque `attachment:<uuid>` id `register()` returned over the wire. */
248
+ ref: string;
249
+ name: string;
250
+ kind: StoredAttachment['kind'];
251
+ size: number;
252
+ /** `Date.now()` at registration — when the file arrived, not when it was looked up. */
253
+ createdAt: number;
138
254
  }
139
255
  /** What registration recorded about a file, as `isUnchangedAttachment` needs it. */
140
256
  export interface RecordedAttachmentIdentity {
@@ -219,7 +335,10 @@ export declare function hasGifSignature(body: Uint8Array): boolean;
219
335
  export declare function hasWebpSignature(body: Uint8Array): boolean;
220
336
  /**
221
337
  * Infers `'image'` from the leading bytes rather than from a renderer-controlled MIME type or file
222
- * extension. PNG, JPEG, GIF87a/89a, and WEBP are recognized; everything else is `'file'`.
338
+ * extension. PNG, JPEG, GIF87a/89a, WEBP, and AVIF (brand-checked ISO-BMFF, see
339
+ * {@link hasAvifSignature}) are recognized; everything else is `'file'` — including a plain MP4 or
340
+ * other non-AVIF ISO-BMFF file, which shares AVIF's `ftyp` tag but is deliberately NOT matched here
341
+ * (see {@link hasIsoBmffFtypTag}'s doc for why a brand-blind `ftyp` check would be wrong).
223
342
  *
224
343
  * `kind` decides whether a path is later passed to `AgentExecutor.run()`'s `imagePaths`, so letting
225
344
  * a renderer assert it would let a renderer choose how the agent runtime parses the bytes.
@@ -242,6 +361,91 @@ export declare function writeBoundedAttachmentBody({ request, filePath, maxBytes
242
361
  size: number;
243
362
  signature: Uint8Array;
244
363
  }>;
364
+ /**
365
+ * One attachment as it is written to its sidecar — `AttachmentRecord` minus two fields, both
366
+ * omitted deliberately:
367
+ *
368
+ * - **`batchDirectory`**, because it is re-derived from the upload root on read rather than trusted.
369
+ * A sidecar is a file on disk; if it could name the directory a claim later hands to an agent, a
370
+ * forged one would turn this store into an arbitrary-file-read primitive. Re-deriving it through
371
+ * the same `BATCH_ID_PATTERN` + `resolve` containment argument `resolveBatchDirectory` uses means
372
+ * a forged sidecar can only ever point inside the upload root.
373
+ * - **`claimedRunId`**, because no run survives the process that owned it. Everything adopted comes
374
+ * back unclaimed; a file whose run died is re-listable to its own uploader (never to anyone else
375
+ * — `claim`/`resolveForRun` still demand the unguessable id or path) and expires on the normal
376
+ * TTL. See {@link loadPersistedAttachments} for the retention consequence that carries.
377
+ */
378
+ export interface PersistedAttachmentRecord {
379
+ readonly id: string;
380
+ readonly filePath: string;
381
+ readonly name: string;
382
+ readonly kind: StoredAttachment['kind'];
383
+ readonly size: number;
384
+ readonly batchId: string;
385
+ readonly dev: number;
386
+ readonly ino: number;
387
+ readonly createdAt: number;
388
+ readonly ownerId?: string;
389
+ }
390
+ /**
391
+ * Turns one sidecar's parsed JSON back into an `AttachmentRecord`, or `undefined` for anything that
392
+ * is not a well-formed record naming a file inside its own batch directory.
393
+ *
394
+ * `batchDirectory` is re-derived here and `filePath`'s containment is re-checked against it with
395
+ * the same parent-equality test `register` uses — the two checks that make an adopted record no
396
+ * more trusted than one this process registered itself. Pure and exported so both can be exercised
397
+ * against hostile input directly, without staging files on disk.
398
+ */
399
+ export declare function parsePersistedAttachment(raw: unknown, canonicalUploadDirectory: string): AttachmentRecord | undefined;
400
+ /**
401
+ * Sidecar filename for a record id. Reduces the id to the same `[a-zA-Z0-9-]` allowlist
402
+ * `BATCH_ID_PATTERN` uses before appending the extension, so no id — however this store's own id
403
+ * format later changes — can put a `/`, a `..`, or a second extension into the path. Ids are
404
+ * `attachment:<uuid>`, so the reduction stays injective in practice: the UUID is what makes it
405
+ * unique and the UUID survives unchanged.
406
+ */
407
+ export declare function attachmentSidecarFileName(id: string): string;
408
+ /**
409
+ * Rebuilds the record map from the sidecar directory, adopting only records that are (a) well
410
+ * formed and contained, (b) still within the retention window, and (c) still backed by the exact
411
+ * file registration accepted. Anything failing any of those is deleted — sidecar first, then the
412
+ * file it named, and the file ONLY when containment passed, so an unparseable sidecar can never
413
+ * make this an arbitrary-file-delete primitive for whatever the daemon can unlink.
414
+ *
415
+ * **The retention consequence, stated rather than assumed harmless.** Because `claimedRunId` is not
416
+ * persisted (see {@link PersistedAttachmentRecord}), a file claimed by a run that died with the
417
+ * process is adopted as unclaimed instead of being wiped, so it now occupies disk and quota for up
418
+ * to `retentionMs` rather than until the next start. Bounded by the same `maxStoredAttachments` /
419
+ * `maxStoredBytes` quotas as any live upload, and cleared by the `pruneExpired` every upload
420
+ * already runs — but it is a real change in when that disk comes back.
421
+ *
422
+ * @complexity O(n) in sidecars present, each costing one read and one `lstat`/`realpath` pair.
423
+ */
424
+ export declare function loadPersistedAttachments({ canonicalUploadDirectory, retentionMs, now, }: {
425
+ readonly canonicalUploadDirectory: string;
426
+ readonly retentionMs: number;
427
+ readonly now?: number;
428
+ }): Promise<Map<string, AttachmentRecord>>;
429
+ /**
430
+ * Removes every upload the sidecar pass did not adopt. Without this, a file whose sidecar was lost
431
+ * (or was never written, because it predates this option) would survive forever with nothing
432
+ * tracking it — trading the wipe's data loss for unbounded disk growth, which is not a trade worth
433
+ * making. This is what keeps "never wipe on construction" bounded.
434
+ */
435
+ export declare function removeUnadoptedUploads(canonicalUploadDirectory: string, adopted: ReadonlyMap<string, AttachmentRecord>): Promise<void>;
436
+ /**
437
+ * Decides what a newly-constructed store starts holding: nothing (the default — empty the directory
438
+ * outright, this pack's behavior before `retainAcrossRestarts` existed), or the authenticated
439
+ * survivors of the previous process.
440
+ *
441
+ * Exported so the whole restart decision can be exercised without standing a store up around it.
442
+ */
443
+ export declare function prepareAttachmentStorage({ canonicalUploadDirectory, retainAcrossRestarts, retentionMs, now, }: {
444
+ readonly canonicalUploadDirectory: string;
445
+ readonly retainAcrossRestarts: boolean;
446
+ readonly retentionMs: number;
447
+ readonly now?: number;
448
+ }): Promise<Map<string, AttachmentRecord>>;
245
449
  /**
246
450
  * The disk-backed `AttachmentStore` this package ships. Every default matches what a chat composer
247
451
  * needs out of the box; a host that wants different quotas passes them rather than reimplementing
@@ -250,7 +454,7 @@ export declare function writeBoundedAttachmentBody({ request, filePath, maxBytes
250
454
  * @complexity `register`/`claim` are O(n) in the number of tracked records (a small bounded number
251
455
  * — `maxStoredAttachments`), which is what keeps the quota decision synchronous; see `register`.
252
456
  */
253
- export declare function createDiskAttachmentStore({ uploadDirectory, maxAttachments, maxBatchBytes, maxStoredAttachments, maxStoredBytes, retentionMs, }: CreateDiskAttachmentStoreOptions): Promise<AttachmentStore>;
457
+ export declare function createDiskAttachmentStore({ uploadDirectory, maxAttachments, maxBatchBytes, maxStoredAttachments, maxStoredBytes, retentionMs, retainAcrossRestarts, }: CreateDiskAttachmentStoreOptions): Promise<AttachmentStore>;
254
458
  /**
255
459
  * Diagnostic detail for an internal-error response the public API deliberately does not disclose
256
460
  * (SEC-005), matching `MediaInternalErrorContext`'s precedent.
@@ -286,6 +490,19 @@ export interface AttachmentsHttpDeps {
286
490
  readonly requireSameOrigin?: boolean;
287
491
  /** Host-owned sink for the real exception behind a generic `INTERNAL_ERROR` (SEC-005). Defaults to `console.error`. */
288
492
  readonly onInternalError?: (context: AttachmentsInternalErrorContext) => void;
493
+ /**
494
+ * Resolves the principal id that owns this upload, if any, passed through to `store.register()`'s
495
+ * `ownerId` (see that field's own doc, and `AttachmentStore.listPendingForOwner`). Optional: a
496
+ * host with no owner concept omits it and every attachment registers ownerless, matching this
497
+ * pack's behavior before ownership existed — `listPendingForOwner` simply never returns those.
498
+ *
499
+ * A host is expected to read this from a header/context IT ALREADY TRUSTS (e.g. a reverse proxy's
500
+ * own session-verified principal header, asserted only downstream of that proxy's auth gate) —
501
+ * this pack has no session concept of its own and never authenticates `req` itself. Returning a
502
+ * caller-controlled value here (an inbound header nothing has verified) would let any uploader
503
+ * assert an arbitrary `ownerId` and make its files discoverable by whoever that id names.
504
+ */
505
+ readonly resolveOwnerId?: (req: Request) => string | undefined;
289
506
  }
290
507
  export declare const ATTACHMENTS_ROUTE_PATH = "/api/attachments";
291
508
  export interface AttachmentUploadResponse {
@@ -1 +1 @@
1
- {"version":3,"file":"attachments.d.ts","sourceRoot":"","sources":["../src/attachments.ts"],"names":[],"mappings":"AAqFA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAA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