@hosty-sdk/app 0.49.0 → 0.50.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.
@@ -1,4 +1,4 @@
1
- import { type AgentAttachment, type AgentAttachmentChunk, type AgentAttachmentChunkReceipt, type AgentAuthorizer, type AgentAuthorizationRequest, type AgentCancelInput, type AgentCapabilities, type AgentConfigurationCreate, type AgentConnectionPage, type AgentConnectionUsage, type AgentControlReceipt, type AgentEvent, type AgentHistoryObservation, type AgentModelCatalog, type AgentOperation, type AgentPreparedRequest, type AgentProviderRef, type AgentResponseInput, type AgentRunControlInput, type AgentRunInput, type AgentRunSnapshot, type AgentSession, type AgentSessionCreate, type AgentSessionPage, type AgentWatchItem } from "./agent.js";
1
+ import { type AgentAttachment, type AgentAttachmentChunk, type AgentAttachmentChunkReceipt, type AgentAuthorizer, type AgentAuthorizationRequest, type AgentCancelInput, type AgentCapabilities, type AgentConfigurationCreate, type AgentConnectionPage, type AgentConnectionUsage, type AgentControlReceipt, type AgentEvent, type AgentHistoryObservation, type AgentHistorySessionState, type AgentModelCatalog, type AgentOperation, type AgentPreparedRequest, type AgentProviderRef, type AgentResponseInput, type AgentRunControlInput, type AgentRunInput, type AgentRunSnapshot, type AgentSession, type AgentSessionCreate, type AgentSessionPage, type AgentWatchItem } from "./agent.js";
2
2
  export type AgentClientOptions = {
3
3
  provider: AgentProviderRef;
4
4
  authorize: AgentAuthorizer;
@@ -87,8 +87,34 @@ export type AgentHistoryPage = {
87
87
  through: string;
88
88
  nextCursor: string | null;
89
89
  };
90
+ type HistoryPageOptions = {
91
+ through?: string;
92
+ limit?: number;
93
+ };
90
94
  /** Open one read-only installation subscription. Resume from the last durably applied position. */
91
95
  export declare function watchAgentHistory(options: AgentHistoryOptions): AsyncGenerator<AgentHistoryObservation>;
96
+ /** Subscribe at the provider's current boundary. Supply a previous cursor to validate archive ancestry. */
97
+ export declare function watchLiveAgentHistory(options: AgentHistoryOptions & {
98
+ onReady: (boundary: string) => void | Promise<void>;
99
+ }): AsyncGenerator<AgentHistoryObservation>;
100
+ export declare function readAgentHistoryStates(options: AgentHistoryOptions & HistoryPageOptions & {
101
+ afterSession?: string;
102
+ }): Promise<{
103
+ through: string;
104
+ sessions: AgentHistorySessionState[];
105
+ nextSession: string | null;
106
+ }>;
107
+ export declare function readAgentHistoryRange(options: AgentHistoryOptions & {
108
+ through: string;
109
+ sessionId: string;
110
+ epoch: string;
111
+ from: number;
112
+ to: number;
113
+ limit?: number;
114
+ }): Promise<{
115
+ observations: AgentHistoryObservation[];
116
+ nextPosition: number | null;
117
+ }>;
92
118
  /** Read a bounded page at a stable installation feed position. Pass through to subsequent pages. */
93
119
  export declare function readAgentHistoryPage(options: AgentHistoryOptions & {
94
120
  through?: string;
@@ -100,3 +126,4 @@ export declare function parseAgentSse(response: Pick<Response, "body">, maxBytes
100
126
  event: string;
101
127
  data: string;
102
128
  }>;
129
+ export {};
@@ -280,10 +280,18 @@ export class AgentClient {
280
280
  options.signal?.throwIfAborted();
281
281
  }
282
282
  }
283
- async function historyResponse(options, accept, page) {
283
+ async function historyResponse(options, accept, page, endpoint, parameters) {
284
284
  const url = new URL(options.url);
285
285
  if (!["https:", "http:"].includes(url.protocol) || url.username || url.password || url.search || url.hash || !options.token)
286
286
  throw new AgentApiError("authorization_invalid", "Invalid installation history binding.", 401);
287
+ if (endpoint) {
288
+ if (!url.pathname.endsWith("/history/events"))
289
+ throw new AgentApiError("authorization_invalid", "Expected an installation history events URL.", 401);
290
+ url.pathname = url.pathname.slice(0, -"events".length) + endpoint;
291
+ for (const [key, value] of Object.entries(parameters ?? {}))
292
+ if (value !== undefined)
293
+ url.searchParams.set(key, String(value));
294
+ }
287
295
  const after = agentReplayCursor(options.cursor);
288
296
  if (after)
289
297
  url.searchParams.set("after", after);
@@ -305,7 +313,9 @@ async function historyResponse(options, accept, page) {
305
313
  detail = JSON.parse(raw)?.error;
306
314
  }
307
315
  catch { /* Older providers may return a plain 404. */ }
308
- throw new AgentApiError(detail?.code ?? "provider_failed", detail?.message ?? `History request failed (${response.status}).`, response.status);
316
+ if (endpoint === "live" && (response.status === 404 || response.status === 422 && ["unsupported_operation", "unsupported_capability"].includes(detail?.code ?? "")))
317
+ throw new AgentApiError("history_live_unsupported", "The provider does not support live history recovery.", 404);
318
+ throw new AgentApiError(detail?.code ?? "provider_failed", detail?.message ?? `History request failed (${response.status}).`, response.status, detail?.retryable === true);
309
319
  }
310
320
  if (response.headers.get("content-type")?.split(";")[0]?.trim().toLowerCase() !== accept) {
311
321
  await response.body?.cancel();
@@ -316,12 +326,13 @@ async function historyResponse(options, accept, page) {
316
326
  function historyObject(value) {
317
327
  return typeof value === "object" && value !== null && !Array.isArray(value);
318
328
  }
329
+ const historyIdentity = (id) => typeof id === "string" && id.length > 0 && id.length <= 512;
330
+ const historyPosition = (n) => typeof n === "number" && Number.isSafeInteger(n) && n > 0;
319
331
  function historyObservation(value, cursor, provider) {
320
332
  if (!historyObject(value) || typeof cursor !== "string" || !agentReplayCursor(cursor))
321
333
  throw new AgentApiError("event_invalid", "The history observation is missing its cursor.", 502);
322
334
  const { sessionId, runId, generation, userId, principalId } = value;
323
- const identity = (id) => typeof id === "string" && id.length > 0 && id.length <= 512;
324
- if (!identity(sessionId) || !identity(runId) || !identity(generation) || !identity(userId) || !identity(principalId) || !historyObject(value.item))
335
+ if (!historyIdentity(sessionId) || !historyIdentity(runId) || !historyIdentity(generation) || !historyIdentity(userId) || !historyIdentity(principalId) || !historyObject(value.item))
325
336
  throw new AgentApiError("event_invalid", "The history observation is missing its identity.", 502);
326
337
  const raw = value.item;
327
338
  let item;
@@ -344,7 +355,12 @@ function historyObservation(value, cursor, provider) {
344
355
  if (snapshot && (snapshot.ref.id !== runId || snapshot.sessionId !== sessionId || snapshot.generation !== generation
345
356
  || provider && !sameProvider(provider, snapshot.ref.provider)))
346
357
  throw new AgentApiError("event_invalid", "History snapshot identity changed.", 502);
347
- return { sessionId, runId, generation, userId, principalId, item, cursor };
358
+ const { epoch, sessionPosition } = value;
359
+ if (value.sourceHistoryIncomplete !== undefined && value.sourceHistoryIncomplete !== true || epoch !== undefined && !historyIdentity(epoch) || sessionPosition !== undefined && (!epoch || !historyPosition(sessionPosition)))
360
+ throw new AgentApiError("event_invalid", "Invalid session history position.", 502);
361
+ return { sessionId, runId, generation, userId, principalId, item, cursor,
362
+ ...(epoch !== undefined ? { epoch } : {}), ...(sessionPosition !== undefined ? { sessionPosition } : {}),
363
+ ...(value.sourceHistoryIncomplete ? { sourceHistoryIncomplete: true } : {}) };
348
364
  }
349
365
  /** Open one read-only installation subscription. Resume from the last durably applied position. */
350
366
  export async function* watchAgentHistory(options) {
@@ -372,6 +388,89 @@ export async function* watchAgentHistory(options) {
372
388
  yield historyObservation(value, frame.id, options.provider);
373
389
  }
374
390
  }
391
+ /** Subscribe at the provider's current boundary. Supply a previous cursor to validate archive ancestry. */
392
+ export async function* watchLiveAgentHistory(options) {
393
+ const idle = options.idleTimeoutMs ?? 60000;
394
+ if (!Number.isSafeInteger(idle) || idle < 1 || idle > 2147483647)
395
+ throw new AgentApiError("invalid_input", "Invalid heartbeat timeout.", 400);
396
+ const response = await historyResponse(options, "text/event-stream", undefined, "live");
397
+ let ready = false;
398
+ try {
399
+ for await (const frame of parseAgentSse(response, MAX_BYTES + 32768, idle)) {
400
+ const value = JSON.parse(frame.data);
401
+ if (!ready) {
402
+ if (frame.event !== "ready" || !historyObject(value) || typeof value.through !== "string" || !agentReplayCursor(value.through))
403
+ throw new AgentApiError("event_invalid", "The provider did not establish a live history boundary.", 502);
404
+ ready = true;
405
+ await options.onOpen?.();
406
+ await options.onReady(value.through);
407
+ }
408
+ else {
409
+ if (frame.event !== "observation")
410
+ throw new AgentApiError("event_invalid", "Unexpected live history frame.", 502);
411
+ const observation = historyObservation(value, frame.id, options.provider);
412
+ const transient = observation.item.kind === "event" && ["message.delta", "tool.output"].includes(observation.item.event.type);
413
+ if (!observation.epoch || transient !== (observation.sessionPosition === undefined))
414
+ throw new AgentApiError("event_invalid", "Invalid live record position.", 502);
415
+ yield observation;
416
+ }
417
+ }
418
+ }
419
+ finally {
420
+ await response.body?.cancel().catch(() => { });
421
+ }
422
+ if (!ready)
423
+ throw new AgentApiError("stream_closed", "The stream closed before its live boundary.", 503, true);
424
+ }
425
+ export async function readAgentHistoryStates(options) {
426
+ const response = await historyResponse({ ...options, cursor: undefined }, "application/json", options, "states", { afterSession: options.afterSession });
427
+ const page = JSON.parse(await boundedText(response, 2 * MAX_BYTES + 32768));
428
+ if (!historyObject(page) || !isHistoryCursor(page.through) || options.through && page.through !== options.through
429
+ || !Array.isArray(page.sessions) || page.sessions.length > (options.limit ?? 100)
430
+ || !(page.nextSession === null || historyIdentity(page.nextSession)))
431
+ throw new AgentApiError("response_invalid", "Invalid provider history state page.", 502);
432
+ const sessions = [];
433
+ let previous = options.afterSession ?? "";
434
+ for (const state of page.sessions) {
435
+ if (!historyObject(state) || !historyIdentity(state.sessionId) || state.sessionId <= previous || !historyIdentity(state.userId)
436
+ || state.sourceHistoryIncomplete !== undefined && state.sourceHistoryIncomplete !== true || !historyIdentity(state.principalId) || !historyIdentity(state.epoch) || !historyPosition(state.head))
437
+ throw new AgentApiError("response_invalid", "Invalid provider session state.", 502);
438
+ validateAgentRunSnapshot(state.snapshot);
439
+ if (state.sessionId !== state.snapshot.sessionId || options.provider && !sameProvider(options.provider, state.snapshot.ref.provider))
440
+ throw new AgentApiError("response_invalid", "Provider session state identity changed.", 502);
441
+ previous = state.sessionId;
442
+ sessions.push({ sessionId: state.sessionId, userId: state.userId, principalId: state.principalId,
443
+ epoch: state.epoch, head: state.head, snapshot: state.snapshot, ...(state.sourceHistoryIncomplete ? { sourceHistoryIncomplete: true } : {}) });
444
+ }
445
+ if (page.nextSession !== null && (!sessions.length || page.nextSession !== previous))
446
+ throw new AgentApiError("response_invalid", "The history states page did not advance.", 502);
447
+ return { through: page.through, sessions, nextSession: page.nextSession };
448
+ }
449
+ function isHistoryCursor(value) {
450
+ return typeof value === "string" && Boolean(agentReplayCursor(value));
451
+ }
452
+ export async function readAgentHistoryRange(options) {
453
+ const { sessionId, epoch, from, to } = options;
454
+ if (!historyIdentity(sessionId) || !historyIdentity(epoch) || !isHistoryCursor(options.through)
455
+ || !historyPosition(from) || !historyPosition(to) || to < from)
456
+ throw new AgentApiError("invalid_input", "Invalid session history range.", 400);
457
+ const response = await historyResponse({ ...options, cursor: undefined }, "application/json", options, "range", { sessionId, epoch, from, to });
458
+ const page = JSON.parse(await boundedText(response, 2 * MAX_BYTES + 32768));
459
+ if (!historyObject(page) || !Array.isArray(page.observations) || !page.observations.length || page.observations.length > (options.limit ?? 100))
460
+ throw new AgentApiError("response_invalid", "Invalid session history range page.", 502);
461
+ const observations = page.observations.map((value, index) => {
462
+ const item = historyObservation(value, value?.cursor, options.provider);
463
+ if (item.sessionId !== sessionId || item.epoch !== epoch || item.sessionPosition !== from + index || item.sessionPosition > to
464
+ || item.item.kind === "event" && ["message.delta", "tool.output"].includes(item.item.event.type))
465
+ throw new AgentApiError("response_invalid", "Invalid durable session record or range ordering.", 502);
466
+ return item;
467
+ });
468
+ const next = from + observations.length;
469
+ const nextPosition = next <= to ? next : null;
470
+ if (page.nextPosition !== nextPosition)
471
+ throw new AgentApiError("response_invalid", "The session range page did not advance.", 502);
472
+ return { observations, nextPosition };
473
+ }
375
474
  /** Read a bounded page at a stable installation feed position. Pass through to subsequent pages. */
376
475
  export async function readAgentHistoryPage(options) {
377
476
  const response = await historyResponse(options, "application/json", options);
@@ -77,6 +77,13 @@ export const AGENT_SCHEMAS = {
77
77
  decisions: list(object({ decision: ref("PendingDecision"), state: { enum: ["pending", "resolved", "superseded", "unknown"] }, response: ref("DecisionResponse") }, ["decision", "state"]), 256),
78
78
  pendingContinuations: list(object({ requestId: uuid, run: ref("QualifiedRef"), state: { enum: ["pending", "awaiting_authorization", "admitted", "superseded"] } }), 256) }, ["ref", "sessionId", "generation", "revision", "state", "phase", "stopConfirmed", "freshness", "observedAt", "configurationRevision", "lastSequence", "cursor", "pending", "effects"], true),
79
79
  HistoryObservation: object(historyObservation),
80
+ LiveHistoryReady: object({ through: text(8192) }),
81
+ LiveHistoryObservation: object({ ...historyObservation, epoch: uuid, sessionPosition: positive, sourceHistoryIncomplete: { const: true } }, [...Object.keys(historyObservation), "epoch"]),
82
+ HistoryStates: object({ through: text(8192), nextSession: nullableText, sessions: list(object({
83
+ sessionId: id, userId: text(512), principalId: text(512), epoch: uuid, head: positive, snapshot: ref("RunSnapshot"), sourceHistoryIncomplete: { const: true },
84
+ }, ["sessionId", "userId", "principalId", "epoch", "head", "snapshot"]), 100) }),
85
+ HistoryRange: object({ nextPosition: { type: ["integer", "null"], minimum: 1, maximum: Number.MAX_SAFE_INTEGER },
86
+ observations: list(object({ ...historyObservation, cursor: text(8192), epoch: uuid, sessionPosition: positive, sourceHistoryIncomplete: { const: true } }, [...Object.keys(historyObservation), "cursor", "epoch", "sessionPosition"]), 100) }),
80
87
  HistoryPage: object({ observations: list(object({ ...historyObservation, cursor: text(8192) }), 100),
81
88
  through: text(8192), nextCursor: { type: ["string", "null"] } }),
82
89
  Session: object({ ref: ref("QualifiedRef"), revision, configurationRevision: revision, configurationDigest: digest,
@@ -114,9 +121,26 @@ function operation(operationId, response, input, pathParameters = [], statuses =
114
121
  return { operationId, security: [{ coreOperation: [] }], parameters: pathParameters.map(parameter), ...(input ? { requestBody: { required: true, content: { "application/json": { schema: ref(input) } } } } : {}),
115
122
  responses: { ...errors, ...Object.fromEntries(statuses.map(status => [String(status), { description: "Authorized durable result.", headers: { "Cache-Control": { schema: { const: "no-store" } } }, content: { "application/json": { schema: ref(response) } } }])) } };
116
123
  }
124
+ const historySecurity = [{ installationHistory: [] }];
125
+ const historyParam = (name, schema, required = false) => ({ name, in: "query", schema, required });
126
+ const pageLimit = historyParam("limit", { type: "integer", minimum: 1, maximum: 100 });
117
127
  export const AGENT_OPENAPI = {
118
128
  openapi: "3.1.0", info: { title: "Hosty Agent Execution API", version: "1.0.0", description: "Independent provider execution. Paths are relative to the current Core-declared interface base. Exact UTF-8 command bytes and stable mutation UUIDs are retained across retries. No Harness dependency or raw native session IDs." },
119
129
  paths: {
130
+ "/history/live": { get: { operationId: "history.live", security: historySecurity, parameters: [historyParam("after", text(8192))],
131
+ description: "Open a fresh live subscription. The optional previous cursor checks archive ancestry. The ready event returns the subscribed boundary. Subsequent observation events carry an SSE id and every durable record carries its session position.",
132
+ responses: { ...errors, "200": { description: "Ready boundary followed by live observations.", content: {
133
+ "text/event-stream": { schema: { type: "string" }, "x-event-schemas": { ready: ref("LiveHistoryReady"), observation: ref("LiveHistoryObservation") } },
134
+ } } } } },
135
+ "/history/states": { get: { operationId: "history.states", security: historySecurity,
136
+ parameters: [historyParam("through", text(8192)), historyParam("afterSession", id), pageLimit],
137
+ description: "List sessions with retained runs and their state and durable session head at the supplied or current installation boundary. Pass the returned boundary on later pages.",
138
+ responses: { ...errors, "200": { description: "States for the calling installation.", content: { "application/json": { schema: ref("HistoryStates") } } } } } },
139
+ "/history/range": { get: { operationId: "history.range", security: historySecurity,
140
+ parameters: [historyParam("through", text(8192), true), historyParam("sessionId", id, true), historyParam("epoch", uuid, true),
141
+ historyParam("from", positive, true), historyParam("to", positive, true), pageLimit],
142
+ description: "Read an inclusive interval of durable positions for one session and history epoch. nextPosition is the first unread position in the requested interval.",
143
+ responses: { ...errors, "200": { description: "Ordered durable session records.", content: { "application/json": { schema: ref("HistoryRange") } } } } } },
120
144
  "/history/events": { get: { operationId: "history.events", security: [{ installationHistory: [] }],
121
145
  parameters: [{ name: "after", in: "query", schema: text(8192) }, { name: "through", in: "query", schema: text(8192) }, { name: "limit", in: "query", schema: { type: "integer", minimum: 1, maximum: 100 } }],
122
146
  description: "Resumable, read-only installation history. Frames use event: observation with an opaque installation feed position in id. Commit each observation before saving this position.",
package/dist/agent.d.ts CHANGED
@@ -7,6 +7,7 @@ export declare const AGENT_API_VERSION: 1;
7
7
  export declare const AGENT_EVENT_VERSION: "agent-event.1";
8
8
  export declare const AGENT_CAPABILITIES: {
9
9
  readonly installationHistory: "installation-history";
10
+ readonly liveInstallationHistory: "installation-history.live";
10
11
  readonly resume: "session.resume";
11
12
  readonly configuration: "configuration.resume-compatible";
12
13
  readonly images: "input.images";
@@ -462,6 +463,18 @@ export type AgentHistoryObservation = {
462
463
  principalId: string;
463
464
  item: AgentWatchItem;
464
465
  cursor: string;
466
+ epoch?: string;
467
+ sessionPosition?: number;
468
+ sourceHistoryIncomplete?: true;
469
+ };
470
+ export type AgentHistorySessionState = {
471
+ sessionId: string;
472
+ userId: string;
473
+ principalId: string;
474
+ epoch: string;
475
+ head: number;
476
+ snapshot: AgentRunSnapshot;
477
+ sourceHistoryIncomplete?: true;
465
478
  };
466
479
  export type AgentErrorDetail = {
467
480
  code: string;
package/dist/agent.js CHANGED
@@ -2,6 +2,7 @@ export const AGENT_API_VERSION = 1;
2
2
  export const AGENT_EVENT_VERSION = "agent-event.1";
3
3
  export const AGENT_CAPABILITIES = {
4
4
  installationHistory: "installation-history",
5
+ liveInstallationHistory: "installation-history.live",
5
6
  resume: "session.resume", configuration: "configuration.resume-compatible", images: "input.images",
6
7
  noNativeTools: "native-tools.none", skills: "skills.catalog", exclusiveSkills: "skills.exclusive-selection",
7
8
  coreMcp: "mcp.core", externalMcp: "mcp.external", modelChange: "model.change-on-resume",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hosty-sdk/app",
3
- "version": "0.49.0",
3
+ "version": "0.50.0",
4
4
  "description": "Hosty app auth: session state machine, recovery bridge, Core revalidation, and the embedder responder.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -1787,6 +1787,301 @@
1787
1787
  ],
1788
1788
  "additionalProperties": false
1789
1789
  },
1790
+ "LiveHistoryReady": {
1791
+ "type": "object",
1792
+ "properties": {
1793
+ "through": {
1794
+ "type": "string",
1795
+ "minLength": 1,
1796
+ "maxLength": 8192
1797
+ }
1798
+ },
1799
+ "required": [
1800
+ "through"
1801
+ ],
1802
+ "additionalProperties": false
1803
+ },
1804
+ "LiveHistoryObservation": {
1805
+ "type": "object",
1806
+ "properties": {
1807
+ "sessionId": {
1808
+ "type": "string",
1809
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1810
+ },
1811
+ "runId": {
1812
+ "type": "string",
1813
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1814
+ },
1815
+ "generation": {
1816
+ "type": "string",
1817
+ "format": "uuid"
1818
+ },
1819
+ "principalId": {
1820
+ "type": "string",
1821
+ "minLength": 1,
1822
+ "maxLength": 512
1823
+ },
1824
+ "userId": {
1825
+ "type": "string",
1826
+ "minLength": 1,
1827
+ "maxLength": 512
1828
+ },
1829
+ "item": {
1830
+ "oneOf": [
1831
+ {
1832
+ "type": "object",
1833
+ "properties": {
1834
+ "kind": {
1835
+ "const": "snapshot"
1836
+ },
1837
+ "snapshot": {
1838
+ "$ref": "#/$defs/RunSnapshot"
1839
+ }
1840
+ },
1841
+ "required": [
1842
+ "kind",
1843
+ "snapshot"
1844
+ ],
1845
+ "additionalProperties": false
1846
+ },
1847
+ {
1848
+ "type": "object",
1849
+ "properties": {
1850
+ "kind": {
1851
+ "const": "event"
1852
+ },
1853
+ "event": {
1854
+ "$ref": "#/$defs/Event"
1855
+ },
1856
+ "cursor": {
1857
+ "type": "string",
1858
+ "minLength": 1,
1859
+ "maxLength": 8192
1860
+ }
1861
+ },
1862
+ "required": [
1863
+ "kind",
1864
+ "event",
1865
+ "cursor"
1866
+ ],
1867
+ "additionalProperties": false
1868
+ }
1869
+ ]
1870
+ },
1871
+ "epoch": {
1872
+ "type": "string",
1873
+ "format": "uuid"
1874
+ },
1875
+ "sessionPosition": {
1876
+ "type": "integer",
1877
+ "minimum": 1,
1878
+ "maximum": 9007199254740991
1879
+ },
1880
+ "sourceHistoryIncomplete": {
1881
+ "const": true
1882
+ }
1883
+ },
1884
+ "required": [
1885
+ "sessionId",
1886
+ "runId",
1887
+ "generation",
1888
+ "principalId",
1889
+ "userId",
1890
+ "item",
1891
+ "epoch"
1892
+ ],
1893
+ "additionalProperties": false
1894
+ },
1895
+ "HistoryStates": {
1896
+ "type": "object",
1897
+ "properties": {
1898
+ "through": {
1899
+ "type": "string",
1900
+ "minLength": 1,
1901
+ "maxLength": 8192
1902
+ },
1903
+ "nextSession": {
1904
+ "type": [
1905
+ "string",
1906
+ "null"
1907
+ ],
1908
+ "maxLength": 256
1909
+ },
1910
+ "sessions": {
1911
+ "type": "array",
1912
+ "maxItems": 100,
1913
+ "items": {
1914
+ "type": "object",
1915
+ "properties": {
1916
+ "sessionId": {
1917
+ "type": "string",
1918
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1919
+ },
1920
+ "userId": {
1921
+ "type": "string",
1922
+ "minLength": 1,
1923
+ "maxLength": 512
1924
+ },
1925
+ "principalId": {
1926
+ "type": "string",
1927
+ "minLength": 1,
1928
+ "maxLength": 512
1929
+ },
1930
+ "epoch": {
1931
+ "type": "string",
1932
+ "format": "uuid"
1933
+ },
1934
+ "head": {
1935
+ "type": "integer",
1936
+ "minimum": 1,
1937
+ "maximum": 9007199254740991
1938
+ },
1939
+ "snapshot": {
1940
+ "$ref": "#/$defs/RunSnapshot"
1941
+ },
1942
+ "sourceHistoryIncomplete": {
1943
+ "const": true
1944
+ }
1945
+ },
1946
+ "required": [
1947
+ "sessionId",
1948
+ "userId",
1949
+ "principalId",
1950
+ "epoch",
1951
+ "head",
1952
+ "snapshot"
1953
+ ],
1954
+ "additionalProperties": false
1955
+ }
1956
+ }
1957
+ },
1958
+ "required": [
1959
+ "through",
1960
+ "nextSession",
1961
+ "sessions"
1962
+ ],
1963
+ "additionalProperties": false
1964
+ },
1965
+ "HistoryRange": {
1966
+ "type": "object",
1967
+ "properties": {
1968
+ "nextPosition": {
1969
+ "type": [
1970
+ "integer",
1971
+ "null"
1972
+ ],
1973
+ "minimum": 1,
1974
+ "maximum": 9007199254740991
1975
+ },
1976
+ "observations": {
1977
+ "type": "array",
1978
+ "maxItems": 100,
1979
+ "items": {
1980
+ "type": "object",
1981
+ "properties": {
1982
+ "sessionId": {
1983
+ "type": "string",
1984
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1985
+ },
1986
+ "runId": {
1987
+ "type": "string",
1988
+ "pattern": "^[A-Za-z0-9_-]{1,256}$"
1989
+ },
1990
+ "generation": {
1991
+ "type": "string",
1992
+ "format": "uuid"
1993
+ },
1994
+ "principalId": {
1995
+ "type": "string",
1996
+ "minLength": 1,
1997
+ "maxLength": 512
1998
+ },
1999
+ "userId": {
2000
+ "type": "string",
2001
+ "minLength": 1,
2002
+ "maxLength": 512
2003
+ },
2004
+ "item": {
2005
+ "oneOf": [
2006
+ {
2007
+ "type": "object",
2008
+ "properties": {
2009
+ "kind": {
2010
+ "const": "snapshot"
2011
+ },
2012
+ "snapshot": {
2013
+ "$ref": "#/$defs/RunSnapshot"
2014
+ }
2015
+ },
2016
+ "required": [
2017
+ "kind",
2018
+ "snapshot"
2019
+ ],
2020
+ "additionalProperties": false
2021
+ },
2022
+ {
2023
+ "type": "object",
2024
+ "properties": {
2025
+ "kind": {
2026
+ "const": "event"
2027
+ },
2028
+ "event": {
2029
+ "$ref": "#/$defs/Event"
2030
+ },
2031
+ "cursor": {
2032
+ "type": "string",
2033
+ "minLength": 1,
2034
+ "maxLength": 8192
2035
+ }
2036
+ },
2037
+ "required": [
2038
+ "kind",
2039
+ "event",
2040
+ "cursor"
2041
+ ],
2042
+ "additionalProperties": false
2043
+ }
2044
+ ]
2045
+ },
2046
+ "cursor": {
2047
+ "type": "string",
2048
+ "minLength": 1,
2049
+ "maxLength": 8192
2050
+ },
2051
+ "epoch": {
2052
+ "type": "string",
2053
+ "format": "uuid"
2054
+ },
2055
+ "sessionPosition": {
2056
+ "type": "integer",
2057
+ "minimum": 1,
2058
+ "maximum": 9007199254740991
2059
+ },
2060
+ "sourceHistoryIncomplete": {
2061
+ "const": true
2062
+ }
2063
+ },
2064
+ "required": [
2065
+ "sessionId",
2066
+ "runId",
2067
+ "generation",
2068
+ "principalId",
2069
+ "userId",
2070
+ "item",
2071
+ "cursor",
2072
+ "epoch",
2073
+ "sessionPosition"
2074
+ ],
2075
+ "additionalProperties": false
2076
+ }
2077
+ }
2078
+ },
2079
+ "required": [
2080
+ "nextPosition",
2081
+ "observations"
2082
+ ],
2083
+ "additionalProperties": false
2084
+ },
1790
2085
  "HistoryPage": {
1791
2086
  "type": "object",
1792
2087
  "properties": {