@lionhummer/constellation 0.1.3 → 0.3.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
- /** Durable request client. No provider credentials or agent definitions live here. */
1
+ /** Shared execution wire types and client mechanics. Authentication belongs to each client. */
2
2
  export type Json = null | boolean | number | string | Json[] | {
3
3
  [key: string]: Json;
4
4
  };
@@ -56,25 +56,23 @@ type RequestFields = {
56
56
  isolationKey?: string;
57
57
  };
58
58
  };
59
- /** An agent always supplies its first complete step at admission. Later steps use prepare_step. */
60
- export type RequestInput = RequestFields & ({
61
- kind: "generate";
62
- tools?: never;
63
- prepareStep?: boolean;
64
- } | {
65
- kind: "run";
66
- prepareStep?: boolean;
67
- } | {
68
- kind: "agent";
69
- prepareStep?: true;
70
- });
59
+ export type RequestEventModes = {
60
+ beforeModel?: "off" | "notify" | "wait";
61
+ afterModel?: "off" | "notify" | "wait";
62
+ afterStep?: "off" | "notify" | "wait";
63
+ outputDelta?: "off" | "notify";
64
+ terminal?: "off" | "notify";
65
+ };
66
+ /** One execution protocol; events determine where the caller participates. */
67
+ export type RequestInput = RequestFields & {
68
+ events?: RequestEventModes;
69
+ };
71
70
  export type Status = "queued" | "running" | "waiting" | "completed" | "failed" | "cancelled";
72
71
  export type RequestRecord = {
73
72
  id: string;
74
73
  externalId: string | null;
75
74
  workspaceId: string;
76
75
  userId: string | null;
77
- kind: "generate" | "run" | "agent";
78
76
  requestedModel: string;
79
77
  virtualModel: boolean;
80
78
  planId: string | null;
@@ -157,28 +155,16 @@ export type PreparedStep = {
157
155
  maxOutputTokens: number;
158
156
  cache: RequestInput["cache"] | null;
159
157
  };
160
- export type CallerReview = {
161
- stage: "after_model" | "after_tools";
162
- stepId: string;
163
- toolCalls?: ToolCall[];
164
- toolResults?: Message["toolResults"];
165
- usage?: Json;
166
- customerCost?: string | null;
167
- supplierCost?: string | null;
168
- customerPrice?: Json;
169
- output?: Json;
170
- };
171
158
  export type PendingInput = {
172
159
  id: string;
173
160
  requestId: string;
174
161
  stepId: string | null;
175
- kind: "tool" | "prepare_step" | "caller_review" | "user_input";
162
+ kind: "tool" | "user_input" | "before_model" | "after_model" | "after_step";
176
163
  payload: {
177
164
  providerCallId?: string;
178
165
  name?: string;
179
166
  arguments?: Json;
180
167
  validationError?: string | null;
181
- stage?: CallerReview["stage"];
182
168
  toolCalls?: ToolCall[];
183
169
  toolResults?: Message["toolResults"];
184
170
  usage?: Json;
@@ -268,26 +254,20 @@ export type InputResponse = {
268
254
  claimId?: string;
269
255
  result?: Json;
270
256
  isError?: boolean;
271
- instructions?: string;
272
- tools?: Tool[];
273
257
  stepInput?: PreparedStep;
274
- action?: "continue" | "refresh_context" | "wait_for_user" | "complete" | "fail";
258
+ action?: "continue" | "wait_for_user" | "wait" | "complete" | "fail";
275
259
  };
276
260
  export type InputHandlers = {
261
+ checkpoints?: Partial<Record<"beforeModel" | "afterModel" | "afterStep", (payload: PendingInput["payload"], state: Inspection, context: {
262
+ inputId: string;
263
+ parentSpanId: string;
264
+ signal: AbortSignal;
265
+ }) => Promise<InputResponse>>>;
277
266
  tools?: Record<string, (args: Json, context: {
278
267
  inputId: string;
279
268
  requestId: string;
280
269
  signal?: AbortSignal;
281
270
  }) => Promise<Json>>;
282
- prepareStep?: (state: Inspection, context: {
283
- inputId: string;
284
- parentSpanId: string;
285
- signal: AbortSignal;
286
- }) => Promise<Pick<InputResponse, "instructions" | "tools" | "stepInput" | "action">>;
287
- callerReview?: (review: CallerReview, state: Inspection, context: {
288
- inputId: string;
289
- signal: AbortSignal;
290
- }) => Promise<Pick<InputResponse, "action" | "result">>;
291
271
  userInput?: (state: Inspection, context: {
292
272
  inputId: string;
293
273
  signal: AbortSignal;
@@ -297,8 +277,6 @@ export type InputHandlers = {
297
277
  toolTimeoutMs?: number;
298
278
  onUpdate?: (state: Inspection) => void;
299
279
  };
300
- /** @deprecated Use InputHandlers. */
301
- export type DriveOptions = InputHandlers;
302
280
  export type RequestEvent = {
303
281
  seq: number;
304
282
  type: string;
@@ -331,11 +309,11 @@ export type ModelResolution = ModelScope & {
331
309
  export type WebhookEvent = {
332
310
  requestId: string;
333
311
  inputId: string;
334
- kind: "tool" | "prepare_step" | "caller_review" | "user_input";
312
+ kind: PendingInput["kind"];
335
313
  payload: Record<string, Json>;
336
314
  } | {
337
315
  requestId: string;
338
- kind: "request.model_events";
316
+ kind: "request.events";
339
317
  afterSeq: number;
340
318
  events: Json[];
341
319
  } | {
@@ -349,108 +327,53 @@ export declare class ConstellationError extends Error {
349
327
  constructor(status: number, code: string, message: string);
350
328
  }
351
329
  export declare function uuid7(): string;
352
- export declare class Constellation {
353
- private options;
354
- private fetcher;
355
- constructor(options: {
356
- baseUrl: string;
357
- apiKey?: string;
358
- apiPrefix?: "/v1" | "/internal";
359
- fetch?: typeof fetch;
360
- timeoutMs?: number;
361
- });
362
- private url;
363
- private call;
364
- submit(input: RequestInput, signal?: AbortSignal): Promise<{
365
- id: string;
366
- }>;
367
- inspect(id: string, signal?: AbortSignal): Promise<Inspection>;
368
- /** Canonical API timeline shared with the console. Derived rows disclose their timestamp basis. */
369
- timeline(id: string, options?: {
370
- requestId?: string;
371
- signal?: AbortSignal;
372
- }): Promise<Timeline>;
373
- /** Request context without loading historical telemetry. Fetch records by page. */
374
- inspectSummary(id: string, signal?: AbortSignal): Promise<Inspection>;
375
- records<K extends keyof RecordTypes>(id: string, kind: K, query?: {
376
- id?: string;
377
- q?: string;
378
- level?: Log["level"];
379
- offset?: number;
380
- limit?: number;
381
- }, signal?: AbortSignal): Promise<{
382
- items: RecordTypes[K][];
383
- total: number;
384
- offset: number;
385
- limit: number;
386
- }>;
387
- resolve(input: RequestInput, signal?: AbortSignal): Promise<{
388
- revision: number;
389
- resolution: Record<string, Json>;
390
- rules: Record<string, Json>;
391
- allowed: boolean;
392
- dispatched: false;
393
- }>;
394
- list(query?: {
395
- q?: string;
396
- requestId?: string;
397
- requestIdNot?: string;
398
- externalId?: string;
399
- externalIdNot?: string;
400
- externalIdContains?: string;
401
- externalIdNotContains?: string;
402
- workspaceId?: string;
403
- workspaceIdNot?: string;
404
- userId?: string;
405
- userIdNot?: string;
406
- status?: Status;
407
- statusNot?: Status;
408
- requestedModel?: string;
409
- requestedModelNot?: string;
410
- requestedModelContains?: string;
411
- requestedModelNotContains?: string;
412
- limit?: number;
413
- offset?: number;
414
- }, signal?: AbortSignal): Promise<{
415
- items: RequestRecord[];
416
- total: number;
417
- offset: number;
418
- limit: number;
419
- }>;
420
- cancel(id: string, signal?: AbortSignal): Promise<void>;
421
- claim(id: string, inputId: string, claimId: string, signal?: AbortSignal): Promise<void>;
330
+ export type RequestRecordsQuery = {
331
+ id?: string;
332
+ q?: string;
333
+ level?: Log["level"];
334
+ offset?: number;
335
+ limit?: number;
336
+ };
337
+ export type RequestListQuery = {
338
+ q?: string;
339
+ requestId?: string;
340
+ requestIdNot?: string;
341
+ externalId?: string;
342
+ externalIdNot?: string;
343
+ externalIdContains?: string;
344
+ externalIdNotContains?: string;
345
+ workspaceId?: string;
346
+ workspaceIdNot?: string;
347
+ userId?: string;
348
+ userIdNot?: string;
349
+ status?: Status;
350
+ statusNot?: Status;
351
+ requestedModel?: string;
352
+ requestedModelNot?: string;
353
+ requestedModelContains?: string;
354
+ requestedModelNotContains?: string;
355
+ limit?: number;
356
+ offset?: number;
357
+ };
358
+ export type StartSpanOptions = {
359
+ stepId?: string;
360
+ attemptId?: string;
361
+ inputId?: string;
362
+ parentSpanId?: string;
363
+ startedAt?: string;
364
+ attributes?: Record<string, Json>;
365
+ };
366
+ type ClientOptions = {
367
+ baseUrl: string;
368
+ apiPrefix?: "/v1" | "/internal";
369
+ fetch?: typeof fetch;
370
+ timeoutMs?: number;
371
+ };
372
+ export declare class RequestClient {
373
+ #private;
374
+ constructor(options: ClientOptions);
422
375
  /** Agent claims are leases. Keep one alive while a caller handler is running. */
423
376
  private maintainClaim;
424
- private whileClaimed;
425
- respond(id: string, inputId: string, response: InputResponse, signal?: AbortSignal): Promise<void>;
426
- addSpans(id: string, spans: Span[], signal?: AbortSignal): Promise<void>;
427
- addLogs(id: string, logs: Log[], signal?: AbortSignal): Promise<void>;
428
- startSpan(id: string, name: string, options?: {
429
- stepId?: string;
430
- attemptId?: string;
431
- inputId?: string;
432
- parentSpanId?: string;
433
- startedAt?: string;
434
- attributes?: Record<string, Json>;
435
- }, signal?: AbortSignal): Promise<{
436
- id: string;
437
- end: (options?: {
438
- endedAt?: string;
439
- status?: "ok" | "error" | "cancelled";
440
- attributes?: Record<string, Json>;
441
- }, signal?: AbortSignal) => Promise<void>;
442
- }>;
443
- /** Live SSE delivery with durable cursor replay after disconnects. */
444
- events(id: string, options?: {
445
- after?: number;
446
- signal?: AbortSignal;
447
- }): AsyncGenerator<RequestEvent>;
448
- /** Process one delivered input and exit. An input notification can be retried safely. */
449
- handleInput(id: string, inputId: string, options?: DriveOptions): Promise<Inspection>;
450
- /** Legacy long-running helper. Use handleInput from a durable notification handler. */
451
- drive(id: string, options?: DriveOptions & {
452
- targetInputId?: string;
453
- }): Promise<Inspection>;
454
377
  /** Client-safe discovery with an execution key. */
455
378
  get models(): {
456
379
  list: (scope: ModelScope, signal?: AbortSignal) => Promise<Json>;
@@ -470,7 +393,7 @@ export declare class Constellation {
470
393
  }>;
471
394
  get: (id: string, signal?: AbortSignal) => Promise<Inspection>;
472
395
  getSummary: (id: string, signal?: AbortSignal) => Promise<Inspection>;
473
- list: (query?: Parameters<Constellation["list"]>[0], signal?: AbortSignal) => Promise<{
396
+ list: (query?: RequestListQuery, signal?: AbortSignal) => Promise<{
474
397
  items: RequestRecord[];
475
398
  total: number;
476
399
  offset: number;
@@ -484,7 +407,7 @@ export declare class Constellation {
484
407
  after?: number;
485
408
  signal?: AbortSignal;
486
409
  }) => AsyncGenerator<RequestEvent, any, any>;
487
- listRecords: <K extends keyof RecordTypes>(id: string, kind: K, query?: Parameters<Constellation["records"]>[2], signal?: AbortSignal) => Promise<{
410
+ listRecords: <K extends keyof RecordTypes>(id: string, kind: K, query?: RequestRecordsQuery, signal?: AbortSignal) => Promise<{
488
411
  items: RecordTypes[K][];
489
412
  total: number;
490
413
  offset: number;
@@ -509,7 +432,7 @@ export declare class Constellation {
509
432
  respond: (requestId: string, inputId: string, response: InputResponse, signal?: AbortSignal) => Promise<void>;
510
433
  };
511
434
  get spans(): {
512
- start: (requestId: string, name: string, options?: Parameters<Constellation["startSpan"]>[2], signal?: AbortSignal) => Promise<{
435
+ start: (requestId: string, name: string, options?: StartSpanOptions, signal?: AbortSignal) => Promise<{
513
436
  id: string;
514
437
  end: (options?: {
515
438
  endedAt?: string;
@@ -522,114 +445,5 @@ export declare class Constellation {
522
445
  get logs(): {
523
446
  add: (requestId: string, logs: Log[], signal?: AbortSignal) => Promise<void>;
524
447
  };
525
- /** Configuration endpoints require a management key. */
526
- get management(): {
527
- registry: {
528
- get: (signal?: AbortSignal) => Promise<Json>;
529
- listRows: (kind: "models" | "providers" | "plans" | "rules", query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
530
- update: (input: {
531
- expectedRevision: number;
532
- catalog: Json;
533
- }, signal?: AbortSignal) => Promise<Json>;
534
- applyChanges: (changes: Json[], signal?: AbortSignal) => Promise<Json>;
535
- listHistory: (kind: string, id: string, query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
536
- rollback: (kind: string, id: string, input: {
537
- toVersion: number;
538
- expectedVersion: number;
539
- }, signal?: AbortSignal) => Promise<Json>;
540
- preview: (input: ModelResolution, signal?: AbortSignal) => Promise<Json>;
541
- testRules: (scope: {
542
- workspaceId: string;
543
- userId?: string;
544
- }, signal?: AbortSignal) => Promise<Json>;
545
- };
546
- keys: {
547
- list: (signal?: AbortSignal) => Promise<Json>;
548
- listPage: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
549
- create: (input: Json, signal?: AbortSignal) => Promise<Json>;
550
- revoke: (id: string, signal?: AbortSignal) => Promise<void>;
551
- setInputWebhook: (id: string, input: {
552
- url: string | null;
553
- token?: string;
554
- }, signal?: AbortSignal) => Promise<Json>;
555
- };
556
- credentials: {
557
- list: (signal?: AbortSignal) => Promise<Json>;
558
- listPage: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
559
- create: (input: Json, signal?: AbortSignal) => Promise<Json>;
560
- update: (ref: string, input: Json, signal?: AbortSignal) => Promise<void>;
561
- delete: (ref: string, signal?: AbortSignal) => Promise<void>;
562
- };
563
- executionSettings: {
564
- get: (signal?: AbortSignal) => Promise<Json>;
565
- update: (input: Json, signal?: AbortSignal) => Promise<Json>;
566
- listHistory: (signal?: AbortSignal) => Promise<Json>;
567
- };
568
- };
569
- /** Read-only operational endpoints require a telemetry key. */
570
- get telemetry(): {
571
- requests: {
572
- list: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<RequestRecord>>;
573
- get: (id: string, signal?: AbortSignal) => Promise<Inspection>;
574
- getSummary: (id: string, signal?: AbortSignal) => Promise<Inspection>;
575
- listEvents: (id: string, after?: number, signal?: AbortSignal) => Promise<{
576
- items: RequestEvent[];
577
- }>;
578
- listRecords: <K extends keyof RecordTypes>(id: string, kind: K, query?: PageQuery, signal?: AbortSignal) => Promise<Page<RecordTypes[K]>>;
579
- getTimeline: (id: string, options?: {
580
- requestId?: string;
581
- signal?: AbortSignal;
582
- }) => Promise<Timeline>;
583
- getHttpExchange: (id: string, attemptId: string, signal?: AbortSignal) => Promise<Json>;
584
- getHttpBody: (id: string, attemptId: string, query: {
585
- direction: "request" | "response";
586
- offset?: number;
587
- limit?: number;
588
- }, signal?: AbortSignal) => Promise<Json>;
589
- };
590
- system: {
591
- get: (signal?: AbortSignal) => Promise<Json>;
592
- listHistory: (query?: {
593
- hours?: 1 | 24 | 168;
594
- }, signal?: AbortSignal) => Promise<Json>;
595
- getComponent: (component: string, signal?: AbortSignal) => Promise<Json>;
596
- };
597
- observability: {
598
- get: (query?: PageQuery, signal?: AbortSignal) => Promise<Json>;
599
- getSeries: (query: {
600
- source: "local" | "gateway";
601
- hours?: 1 | 24 | 168;
602
- providerId?: string;
603
- modelId?: string;
604
- }, signal?: AbortSignal) => Promise<Json>;
605
- getTiming: (query?: {
606
- hours?: 1 | 24 | 168;
607
- }, signal?: AbortSignal) => Promise<Json>;
608
- };
609
- jobs: {
610
- listHistory: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
611
- };
612
- notifications: {
613
- list: (query?: PageQuery & {
614
- status?: "active" | "resolved";
615
- }, signal?: AbortSignal) => Promise<Page<Json>>;
616
- get: (id: string, query?: PageQuery, signal?: AbortSignal) => Promise<Json>;
617
- listEvents: (query?: {
618
- after?: number;
619
- }, signal?: AbortSignal) => Promise<Json>;
620
- };
621
- logs: {
622
- searchSystem: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
623
- searchRequests: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
624
- searchAudit: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
625
- };
626
- };
627
- get health(): {
628
- live: (signal?: AbortSignal) => Promise<Json>;
629
- ready: (signal?: AbortSignal) => Promise<Json>;
630
- };
631
- get webhooks(): {
632
- verify: (request: Request, expectedToken: string) => Promise<WebhookEvent>;
633
- };
634
448
  }
635
449
  export {};
@@ -0,0 +1,96 @@
1
+ /** External server SDK. Operator APIs and cookie sessions are internal-only clients. */
2
+ import { RequestClient, type WebhookEvent, type Json, type Page, type PageQuery, type ModelResolution, type RequestRecord, type Inspection, type RequestEvent, type RecordTypes, type Timeline } from "../../client-core/src/index";
3
+ export { ConstellationError, uuid7 } from "../../client-core/src/index";
4
+ export type { Json, Tool, ToolCall, Message, RequestEventModes, RequestInput, Status, RequestRecord, Step, Attempt, PreparedStep, PendingInput, Span, TimelineRow, Timeline, Log, Inspection, RecordTypes, InputResponse, InputHandlers, RequestEvent, Page, PageQuery, ModelScope, ModelResolution, WebhookEvent, RequestRecordsQuery, RequestListQuery, StartSpanOptions } from "../../client-core/src/index";
5
+ export declare class Constellation extends RequestClient {
6
+ #private;
7
+ constructor(options: {
8
+ baseUrl: string;
9
+ apiKey: string;
10
+ fetch?: typeof fetch;
11
+ timeoutMs?: number;
12
+ });
13
+ /** Registry authoring only; keys, credentials and capacity controls are internal. */
14
+ get management(): {
15
+ registry: {
16
+ get: (signal?: AbortSignal) => Promise<Json>;
17
+ listRows: (kind: "models" | "providers" | "plans" | "rules", query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
18
+ update: (input: {
19
+ expectedRevision: number;
20
+ catalog: Json;
21
+ }, signal?: AbortSignal) => Promise<Json>;
22
+ applyChanges: (changes: Json[], signal?: AbortSignal) => Promise<Json>;
23
+ listHistory: (kind: string, id: string, query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
24
+ rollback: (kind: string, id: string, input: {
25
+ toVersion: number;
26
+ expectedVersion: number;
27
+ }, signal?: AbortSignal) => Promise<Json>;
28
+ preview: (input: ModelResolution, signal?: AbortSignal) => Promise<Json>;
29
+ testRules: (scope: {
30
+ workspaceId: string;
31
+ userId?: string;
32
+ }, signal?: AbortSignal) => Promise<Json>;
33
+ };
34
+ };
35
+ /** Read-only operational endpoints require a telemetry key. */
36
+ get telemetry(): {
37
+ requests: {
38
+ list: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<RequestRecord>>;
39
+ get: (id: string, signal?: AbortSignal) => Promise<Inspection>;
40
+ getSummary: (id: string, signal?: AbortSignal) => Promise<Inspection>;
41
+ listEvents: (id: string, after?: number, signal?: AbortSignal) => Promise<{
42
+ items: RequestEvent[];
43
+ }>;
44
+ listRecords: <K extends keyof RecordTypes>(id: string, kind: K, query?: PageQuery, signal?: AbortSignal) => Promise<Page<RecordTypes[K]>>;
45
+ getTimeline: (id: string, options?: {
46
+ requestId?: string;
47
+ signal?: AbortSignal;
48
+ }) => Promise<Timeline>;
49
+ getHttpExchange: (id: string, attemptId: string, signal?: AbortSignal) => Promise<Json>;
50
+ getHttpBody: (id: string, attemptId: string, query: {
51
+ direction: "request" | "response";
52
+ offset?: number;
53
+ limit?: number;
54
+ }, signal?: AbortSignal) => Promise<Json>;
55
+ };
56
+ system: {
57
+ get: (signal?: AbortSignal) => Promise<Json>;
58
+ listHistory: (query?: {
59
+ hours?: 1 | 24 | 168;
60
+ }, signal?: AbortSignal) => Promise<Json>;
61
+ getComponent: (component: string, signal?: AbortSignal) => Promise<Json>;
62
+ };
63
+ observability: {
64
+ get: (query?: PageQuery, signal?: AbortSignal) => Promise<Json>;
65
+ getSeries: (query: {
66
+ source: "local" | "gateway";
67
+ hours?: 1 | 24 | 168;
68
+ providerId?: string;
69
+ modelId?: string;
70
+ }, signal?: AbortSignal) => Promise<Json>;
71
+ getTiming: (query?: {
72
+ hours?: 1 | 24 | 168;
73
+ }, signal?: AbortSignal) => Promise<Json>;
74
+ };
75
+ jobs: {
76
+ listHistory: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
77
+ };
78
+ notifications: {
79
+ list: (query?: PageQuery & {
80
+ status?: "active" | "resolved";
81
+ }, signal?: AbortSignal) => Promise<Page<Json>>;
82
+ get: (id: string, query?: PageQuery, signal?: AbortSignal) => Promise<Json>;
83
+ listEvents: (query?: {
84
+ after?: number;
85
+ }, signal?: AbortSignal) => Promise<Json>;
86
+ };
87
+ logs: {
88
+ searchSystem: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
89
+ searchRequests: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
90
+ searchAudit: (query?: PageQuery, signal?: AbortSignal) => Promise<Page<Json>>;
91
+ };
92
+ };
93
+ get webhooks(): {
94
+ verify: (request: Request, expectedToken: string) => Promise<WebhookEvent>;
95
+ };
96
+ }
@@ -0,0 +1,48 @@
1
+ import { Constellation, uuid7 } from "@lionhummer/constellation";
2
+
3
+ function required(name) {
4
+ const value = process.env[name];
5
+ if (!value) throw new Error(`Set ${name} in your server environment.`);
6
+ return value;
7
+ }
8
+
9
+ const workspaceId = required("CONSTELLATION_WORKSPACE_ID");
10
+ const userId = process.env.CONSTELLATION_USER_ID || undefined;
11
+ const planId = process.env.CONSTELLATION_PLAN_ID || undefined;
12
+ const client = new Constellation({
13
+ baseUrl: required("CONSTELLATION_BASE_URL"),
14
+ apiKey: required("CONSTELLATION_EXECUTION_KEY"),
15
+ });
16
+
17
+ // Discovery uses the same scope as execution. It does not call a provider.
18
+ const catalog = await client.models.list({ workspaceId, userId, planId });
19
+ console.log("Available models:", JSON.stringify(catalog, null, 2));
20
+ const model = process.env.CONSTELLATION_MODEL;
21
+ if (!model) {
22
+ console.log("Set CONSTELLATION_MODEL to one of the returned models[].id values, then rerun.");
23
+ } else {
24
+ const input = {
25
+ idempotencyKey: uuid7(), // Save this input/key if submission needs retrying.
26
+ workspaceId,
27
+ userId,
28
+ planId,
29
+ model,
30
+ messages: [{ role: "user", text: "Say hello in one short sentence." }],
31
+ maxOutputTokens: 256,
32
+ timeoutMs: 120_000,
33
+ // No tools or wait checkpoints: no webhook or input consumer is needed.
34
+ };
35
+ const { id } = await client.requests.create(input);
36
+ console.log("Request ID:", id);
37
+ for await (const event of client.requests.streamEvents(id, {
38
+ signal: AbortSignal.timeout(150_000),
39
+ })) {
40
+ console.log(event.seq, event.type);
41
+ }
42
+ const { request } = await client.requests.getSummary(id);
43
+ console.log("Final status:", request.status);
44
+ console.log("Output:", request.output?.text ?? "");
45
+ if (request.status !== "completed") {
46
+ throw new Error(`Request ${id} ended as ${request.status}: ${request.reason ?? "inspect the request error and attempts"}`);
47
+ }
48
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lionhummer/constellation",
3
- "version": "0.1.3",
4
- "description": "TypeScript client for durable model requests and caller-controlled agent execution",
3
+ "version": "0.3.0",
4
+ "description": "TypeScript client for durable model requests and caller events",
5
5
  "type": "module",
6
6
  "license": "UNLICENSED",
7
7
  "repository": {
@@ -9,23 +9,33 @@
9
9
  "url": "git+https://github.com/FlatFilers/constellation.git",
10
10
  "directory": "packages/sdk"
11
11
  },
12
- "files": ["dist", "README.md"],
13
- "publishConfig": { "access": "public" },
14
- "types": "./dist/index.d.ts",
12
+ "files": [
13
+ "dist/index.js",
14
+ "dist/types/**/*.d.ts",
15
+ "examples/quickstart.mjs",
16
+ "README.md"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "types": "./dist/types/sdk/src/index.d.ts",
15
22
  "exports": {
16
23
  ".": {
17
- "types": "./dist/index.d.ts",
24
+ "types": "./dist/types/sdk/src/index.d.ts",
18
25
  "import": "./dist/index.js",
19
26
  "default": "./dist/index.js"
20
27
  }
21
28
  },
22
29
  "scripts": {
23
- "build": "tsc -p tsconfig.build.json",
30
+ "build": "tsc -p tsconfig.build.json && bun build ./src/index.ts --target node --format esm --outdir ./dist",
24
31
  "prepack": "bun run build",
25
32
  "test": "bun test",
26
33
  "typecheck": "tsc --noEmit --strict --target ES2022 --module ESNext --moduleResolution Bundler --lib ES2022,DOM src/index.ts"
27
34
  },
28
35
  "devDependencies": {
29
36
  "typescript": "^5.9.0"
37
+ },
38
+ "engines": {
39
+ "node": ">=22"
30
40
  }
31
41
  }