@vibefield/rosetta-protocol 0.1.1 → 0.1.2

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/client.d.ts CHANGED
@@ -1,5 +1,8 @@
1
1
  export { PROTOCOL_VERSION } from "./protocol-version.mjs";
2
2
  import type { TimelineEntryResponse } from "./generated/TimelineEntryResponse.js";
3
+ import type { Ingestion } from "./generated/Ingestion.js";
4
+ import type { IngestionConflict } from "./generated/IngestionConflict.js";
5
+ import type { IngestionControlRequest } from "./generated/IngestionControlRequest.js";
3
6
  import type { ApiError } from "./generated/ApiError.js";
4
7
  import type { ImageVariant } from "./generated/ImageVariant.js";
5
8
  import type { AssetRef } from "./generated/AssetRef.js";
@@ -69,10 +72,16 @@ export interface RosettaClientOptions {
69
72
  /** Presented on every request and upgrade; see {@link RosettaCredential}. */
70
73
  credential?: RosettaCredential;
71
74
  }
75
+ /** Pin these values for the lifetime of one user intent, including retries. */
76
+ export interface IngestionCommand extends IngestionControlRequest {
77
+ readonly indexId: string;
78
+ readonly idempotencyKey: string;
79
+ }
72
80
  export declare class ApiRequestError extends Error {
73
81
  readonly status: number;
74
82
  readonly code: ErrorCode | null;
75
- constructor(status: number, code: ErrorCode | null, message: string);
83
+ readonly details: IngestionConflict | null;
84
+ constructor(status: number, code: ErrorCode | null, message: string, details?: IngestionConflict | null);
76
85
  }
77
86
  /** The bound watermark no longer matches: refetch from the head. */
78
87
  export declare class CursorExpiredError extends ApiRequestError {
@@ -131,6 +140,13 @@ export declare class RosettaClient {
131
140
  private response;
132
141
  private request;
133
142
  status(signal?: AbortSignal): Promise<StatusResponse>;
143
+ /** Finite cold runs; live-watcher controls are a separate capability. */
144
+ readonly ingestions: {
145
+ get: (id: string, signal?: AbortSignal) => Promise<Ingestion>;
146
+ pause: (id: string, command: IngestionCommand, signal?: AbortSignal) => Promise<Ingestion>;
147
+ resume: (id: string, command: IngestionCommand, signal?: AbortSignal) => Promise<Ingestion>;
148
+ };
149
+ private ingestionCommand;
134
150
  /** The roll call's census — what discovery found, content-free. */
135
151
  discoveries(signal?: AbortSignal): Promise<DiscoveriesResponse>;
136
152
  /** Consent: enroll the chosen agent kinds. Grantable exactly once, while
package/dist/client.js CHANGED
@@ -44,11 +44,13 @@ export function webSocketProtocols(credential) {
44
44
  export class ApiRequestError extends Error {
45
45
  status;
46
46
  code;
47
- constructor(status, code, message) {
47
+ details;
48
+ constructor(status, code, message, details = null) {
48
49
  super(message);
49
50
  this.name = "ApiRequestError";
50
51
  this.status = status;
51
52
  this.code = code;
53
+ this.details = details;
52
54
  }
53
55
  }
54
56
  /** The bound watermark no longer matches: refetch from the head. */
@@ -175,11 +177,13 @@ export class RosettaClient {
175
177
  }
176
178
  if (!response.ok) {
177
179
  let code = null;
180
+ let details = null;
178
181
  let message = `${response.status} on ${path}`;
179
182
  try {
180
183
  const body = (await response.json());
181
184
  if (body.error) {
182
185
  code = body.error.code;
186
+ details = body.error.details ?? null;
183
187
  message = body.error.message;
184
188
  }
185
189
  }
@@ -189,7 +193,7 @@ export class RosettaClient {
189
193
  if (code === "cursor_expired") {
190
194
  throw new CursorExpiredError(message);
191
195
  }
192
- throw new ApiRequestError(response.status, code, message);
196
+ throw new ApiRequestError(response.status, code, message, details);
193
197
  }
194
198
  return response;
195
199
  }
@@ -199,6 +203,20 @@ export class RosettaClient {
199
203
  status(signal) {
200
204
  return this.request("/api/status", withSignal(signal));
201
205
  }
206
+ /** Finite cold runs; live-watcher controls are a separate capability. */
207
+ ingestions = {
208
+ get: (id, signal) => this.request(`/api/ingestions/${encodeURIComponent(id)}`, withSignal(signal)),
209
+ pause: (id, command, signal) => this.ingestionCommand(id, "pause", command, signal),
210
+ resume: (id, command, signal) => this.ingestionCommand(id, "resume", command, signal),
211
+ };
212
+ ingestionCommand(id, action, command, signal) {
213
+ return this.request(`/api/ingestions/${encodeURIComponent(id)}/${action}`, {
214
+ method: "POST", ...withSignal(signal),
215
+ headers: { "content-type": "application/json", "x-rosetta-index-id": command.indexId,
216
+ "idempotency-key": command.idempotencyKey },
217
+ body: JSON.stringify({ expected_revision: command.expected_revision }),
218
+ });
219
+ }
202
220
  /** The roll call's census — what discovery found, content-free. */
203
221
  discoveries(signal) {
204
222
  return this.request("/api/discoveries", withSignal(signal));
@@ -325,6 +343,7 @@ export class RosettaClient {
325
343
  const response = await this.response(path, withSignal(signal));
326
344
  return new Uint8Array(await response.arrayBuffer());
327
345
  }
346
+ // @atlas step search-query.client
328
347
  search(request, signal) {
329
348
  return this.request(`/api/search${queryString({
330
349
  q: request.q,
@@ -1,5 +1,7 @@
1
1
  import type { ErrorCode } from "./ErrorCode.js";
2
+ import type { IngestionConflict } from "./IngestionConflict.js";
2
3
  export type ApiError = {
3
4
  code: ErrorCode;
4
5
  message: string;
6
+ details?: IngestionConflict;
5
7
  };
@@ -13,6 +13,14 @@ export type DiscoveryRow = {
13
13
  */
14
14
  installed: boolean;
15
15
  files: number;
16
+ /**
17
+ * Content-free session estimate: one per authoritative transcript file,
18
+ * including child sessions. May differ from the admitted session count.
19
+ * Null for layouts without a file-based estimate or a truncated census;
20
+ * zero when a complete supported census finds no transcripts. Older
21
+ * daemons omit this field; consumers must treat absence as unknown too.
22
+ */
23
+ sessions?: number | null;
16
24
  bytes: number;
17
25
  newest_modified_ms: number;
18
26
  /**
@@ -1 +1 @@
1
- export type ErrorCode = "incompatible_protocol" | "not_found" | "bad_request" | "not_ready" | "cursor_expired" | "internal";
1
+ export type ErrorCode = "incompatible_protocol" | "not_found" | "bad_request" | "not_ready" | "cursor_expired" | "index_changed" | "revision_conflict" | "idempotency_conflict" | "invalid_transition" | "publication_in_progress" | "control_capacity" | "shutting_down" | "internal";
@@ -1,9 +1,10 @@
1
1
  /**
2
2
  * Where the daemon's ingest is in its life. `AwaitingConsent` means the
3
3
  * census is on the board and nothing has been read — the USER decides
4
- * which runtimes enroll. `MetadataReady` is the exact phase boundary where
5
- * every bounded skim has committed but no complete source record has been
6
- * streamed. `Live` means the watch loop owns the store and the cold backfill
7
- * is history.
4
+ * which runtimes enroll. `MetadataReady` is the audit phase after every
5
+ * bounded skim has committed, before complete-record streaming begins.
6
+ * Parallel cold starts may already be streaming at that boundary; use
7
+ * [`IngestProgress::metadata_ready_at`] to observe it in any phase. `Live`
8
+ * means the watch loop owns the store and the cold backfill is history.
8
9
  */
9
10
  export type IngestPhase = "discovering" | "awaiting_consent" | "backfilling" | "metadata_ready" | "restoring" | "finalizing" | "publishing" | "live";
@@ -1,11 +1,27 @@
1
1
  import type { IngestPhase } from "./IngestPhase.js";
2
+ import type { Ingestion } from "./Ingestion.js";
2
3
  import type { ProjectBackfill } from "./ProjectBackfill.js";
3
4
  import type { RuntimeBackfill } from "./RuntimeBackfill.js";
4
5
  /**
5
- * The ingest block on [`DaemonStatus`]: phase plus per-runtime meters.
6
+ * The ingest block on [`DaemonStatus`]: phase, first-pass boundary, and meters.
6
7
  */
7
8
  export type IngestProgress = {
8
9
  phase: IngestPhase;
10
+ /**
11
+ * Cold-run controls and execution state, independent of work phase.
12
+ * Absent on older daemons, static readers, and metadata-audit mode.
13
+ */
14
+ run?: Ingestion | null;
15
+ /**
16
+ * Unix milliseconds when this process finished publishing the first
17
+ * bounded metadata pass for all active runtimes. Sessions and projects
18
+ * can be listed; transcript, aggregate, and search readiness are separate.
19
+ * Sticky through later phases and live work, even when streaming began
20
+ * before the last skim. A restart establishes a new stamp after its own
21
+ * metadata pass, including on warm starts. Null until that boundary;
22
+ * older daemons omit the field, which means the boundary is unknown.
23
+ */
24
+ metadata_ready_at?: number | null;
9
25
  /**
10
26
  * Installed runtimes in serve order.
11
27
  */
@@ -0,0 +1,27 @@
1
+ import type { IngestionAction } from "./IngestionAction.js";
2
+ import type { IngestionPhase } from "./IngestionPhase.js";
3
+ import type { IngestionState } from "./IngestionState.js";
4
+ /**
5
+ * One auto-started cold run. The same resource is returned by the control
6
+ * routes and `daemon.ingest.run`. Ordinary progress stays in that existing
7
+ * ingest block; it is not persisted in the control receipt.
8
+ */
9
+ export type Ingestion = {
10
+ id: string;
11
+ /**
12
+ * Stable logical-index identity; pin it when creating a command.
13
+ */
14
+ index_id: string;
15
+ revision: number;
16
+ state: IngestionState;
17
+ phase: IngestionPhase | null;
18
+ created_at: number;
19
+ updated_at: number;
20
+ /**
21
+ * Changes whenever recovery resets the RAM progress baseline.
22
+ */
23
+ progress_epoch: string;
24
+ runtime_ids: Array<string>;
25
+ allowed_actions: Array<IngestionAction>;
26
+ error: string | null;
27
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export type IngestionAction = "pause" | "resume";
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,4 @@
1
+ export type IngestionConflict = {
2
+ ingestion_id: string;
3
+ current_revision: number;
4
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,3 @@
1
+ export type IngestionControlRequest = {
2
+ expected_revision: number;
3
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1 @@
1
+ export type IngestionPhase = "discovering" | "restoring" | "capturing" | "finalizing" | "publishing";
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1 @@
1
+ export type IngestionState = "running" | "pausing" | "paused" | "succeeded" | "failed";
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export type * from "./generated/Ingestion.js";
2
+ export type * from "./generated/IngestionState.js";
3
+ export type * from "./generated/IngestionPhase.js";
4
+ export type * from "./generated/IngestionAction.js";
5
+ export type * from "./generated/IngestionControlRequest.js";
6
+ export type * from "./generated/IngestionConflict.js";
1
7
  export type * from "./generated/ApiError.js";
2
8
  export type * from "./generated/AssetRef.js";
3
9
  export type * from "./generated/CanonicalText.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibefield/rosetta-protocol",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",