@sema-agent/sdk 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/openapi.yaml +513 -0
  2. package/package.json +1 -1
package/openapi.yaml CHANGED
@@ -4992,6 +4992,7 @@ components:
4992
4992
  turns: { type: number }
4993
4993
  costMicroUsd: { type: number }
4994
4994
  transcriptId: { type: string, description: "The child's transcript anchor (server 1.258). Additive." }
4995
+ parentToolCallId: { type: string, description: 'The parent tool_use id VERBATIM (E2 domain, engine-minted) — [1832] P1-2, server >= 1.290 / engine 1.432; the terminal notification frame carries it too. Additive / tolerate-absent.' }
4995
4996
  ts: { type: integer }
4996
4997
  FleetFrame_hook_notice:
4997
4998
  type: object
@@ -6293,3 +6294,515 @@ components:
6293
6294
  type: { const: failed }
6294
6295
  errorCode: { type: string }
6295
6296
  errorMessage: { type: string }
6297
+
6298
+ # ── resources/*.ts schema backfill, batch 2 (2026-07-28) — the 28-item WIRE_PENDING ratchet zeroed.
6299
+ # Each schema below is cross-checked against the server source (file:line cited in its description
6300
+ # or in the SDK resource JSDoc it mirrors). Wire objects are OPEN sets (additionalProperties: true).
6301
+
6302
+ ApprovalStreamEvent:
6303
+ type: object
6304
+ description: >
6305
+ One delta event off GET /v1/approvals/stream (SSE; server streamApprovals, http/server.ts:8924).
6306
+ Every data payload echoes a `type` field mirroring the SSE event name (so a client can dispatch
6307
+ without the `event:` line). OPEN set — a consumer that does not parse the delta can treat any
6308
+ non-heartbeat event as a "changed" signal and refetch the authoritative GET /v1/approvals list.
6309
+ Known types: `meta` (first frame — {version, mode:"approvals-delta", pollMs}), `pending` (a new
6310
+ suspend — the payload spreads the FULL PendingCheckpoint row), `synced` (end of the connect-time
6311
+ snapshot — {count}), `resolved` (a decided/expired/gone pending — {sessionId, toolCallId}),
6312
+ `heartbeat`, and `error` (the 15-minute stream cap — reconnect).
6313
+ required: [type]
6314
+ additionalProperties: true
6315
+ properties:
6316
+ type:
6317
+ type: string
6318
+ description: 'Open on read. Known values: pending / resolved / synced / heartbeat / meta / error.'
6319
+ sessionId: { type: string, description: '`resolved` frames: which pending settled.' }
6320
+ toolCallId: { type: string, description: '`resolved` frames: the settled pending''s bound tool-call id (absent when the pending carried none).' }
6321
+ count: { type: integer, description: '`synced` frames: how many pendings the connect-time snapshot carried.' }
6322
+
6323
+ ParkedDecideAccepted:
6324
+ type: object
6325
+ description: >
6326
+ The 200 body of POST /v1/approvals/{sessionId}/decide when the pending checkpoint belongs to a
6327
+ PARKED background agent (server 1.267, ASSISTANT-WIRE-CONTRACT §4a parked variant; server
6328
+ parked-decide.ts:272 — exact literal shape). ACCEPTANCE semantics: the revive drives
6329
+ ASYNCHRONOUSLY — 200 means accepted, not completed; a failed drive honestly re-parks the row and
6330
+ the pending re-appears on the list. Task-level suspends keep the legacy resumed shape —
6331
+ discriminate by `status === "resuming"`.
6332
+ required: [taskId, status, decision]
6333
+ additionalProperties: true
6334
+ properties:
6335
+ taskId: { type: string, description: 'The background agent handle (a* domain).' }
6336
+ status: { type: string, enum: [resuming] }
6337
+ decision: { type: string, enum: [approve, deny] }
6338
+
6339
+ FleetMeta:
6340
+ type: object
6341
+ description: >
6342
+ The connect-time `meta` frame payload of GET /v1/fleet/stream (server http/server.ts:9675 —
6343
+ the payload view of FleetFrame_meta, without the SSE frame envelope).
6344
+ required: [version, scoped]
6345
+ additionalProperties: true
6346
+ properties:
6347
+ version: { type: integer }
6348
+ scoped: { type: boolean, description: 'true ⇒ this connection is OWNER-SCOPED (the caller''s own rows); false ⇒ FLEET-WIDE (operator/trace token).' }
6349
+ sessionScoped: { type: boolean, description: 'server 1.247+: true ⇒ this connection carries ?session= (rows AND notifications filtered by the host session). Additive / tolerate-absent.' }
6350
+ bgNotifyFailClosed: { type: boolean, description: 'server 1.247+ generation flag: true ⇒ bg_notification delivery is fail-CLOSED for session-scoped subscribers (a new-generation shell may drop frame-level own/foreign discrimination — session-bound connections only). Absent = older server, keep discriminating.' }
6351
+
6352
+ FleetBgNotification:
6353
+ type: object
6354
+ description: >
6355
+ A background child's COMPLETION notification payload (design/129-B gap②; service fleet-bus.ts
6356
+ `BgNotification` minus the wire-stripped ownerScope/ownerSessionId — this is the post-strip
6357
+ shape the SDK re-nests under FleetFrame's `notification`). EVENT semantics, not state — never in
6358
+ the snapshot; consumers dedup by (taskId, status, seq). On the wire it rides FLAT inside the
6359
+ `bg_notification` fleet frame (see FleetFrame_bg_notification).
6360
+ required: [taskId, status, scope]
6361
+ additionalProperties: true
6362
+ properties:
6363
+ taskId: { type: string, description: 'Registry handle (a* domain — the TaskOutput/TaskStop key).' }
6364
+ sessionId: { type: string, description: "The child RUN's session id (uuid domain — the a*↔uuid dual anchor), when known." }
6365
+ seq: { type: integer, description: 'Stop-cycle counter (server 1.239, core terminal-frame seq; a revive second cycle = higher seq) — fold into the dedup key. Absent on older engines.' }
6366
+ status: { type: string, enum: [completed, failed, killed] }
6367
+ summary: { type: string }
6368
+ scope: { type: string, enum: [task, session], description: 'Background LIFETIME scope (design/129), NOT the tenant scope.' }
6369
+ parentTaskId: { type: string }
6370
+ stoppedBy: { type: string, description: 'Verbatim open enum (who/what stopped a killed child).' }
6371
+ resumable: { type: boolean }
6372
+ recentSteps:
6373
+ type: array
6374
+ items:
6375
+ type: object
6376
+ required: [tool, target, outcome]
6377
+ properties:
6378
+ tool: { type: string }
6379
+ target: { type: string }
6380
+ outcome: { type: string }
6381
+ editedFiles:
6382
+ type: array
6383
+ items:
6384
+ type: object
6385
+ required: [path, edits]
6386
+ properties:
6387
+ path: { type: string }
6388
+ edits: { type: integer }
6389
+ rootSessionId: { type: string, description: 'Delegation-tree ROOT host session (fixed-point semantics — nested grandchildren anchor the root shell; server 1.250 / core 1.367δ). Additive.' }
6390
+ usage:
6391
+ type: object
6392
+ description: 'Completion cost rollup (server 1.258; fields picked, numbers verbatim). Additive.'
6393
+ properties:
6394
+ totalTokens: { type: number }
6395
+ toolUses: { type: number }
6396
+ durationMs: { type: number }
6397
+ tokens: { type: number }
6398
+ turns: { type: number }
6399
+ costMicroUsd: { type: number }
6400
+ transcriptId: { type: string, description: "The child's transcript anchor (server 1.258). Additive." }
6401
+ parentToolCallId: { type: string, description: 'The parent tool_use id VERBATIM (E2 domain, engine-minted) — [1832] P1-2, server >= 1.290 / engine 1.432. Additive / tolerate-absent.' }
6402
+
6403
+ FleetHookNotice:
6404
+ type: object
6405
+ description: >
6406
+ A hook adjudication FAILED TO COMPLETE this cycle (service fleet-bus.ts `HookNotice` minus the
6407
+ wire-stripped ownerScope/ownerSessionId — the payload view of FleetFrame_hook_notice). Semantics
6408
+ are "could not evaluate", NOT "evaluated to fail": render as "this cycle went unguarded, allowed
6409
+ through", never "the guard is broken". Pure observe — it does not block, resume, or inject.
6410
+ Visibility is fail-CLOSED: a ?session= subscriber only receives notices provably owned by that
6411
+ session.
6412
+ required: [kind, event, reason]
6413
+ additionalProperties: true
6414
+ properties:
6415
+ kind:
6416
+ type: string
6417
+ enum: [hook_decision_unavailable]
6418
+ description: 'Only one kind today; an enum slot so the next observability frame kind needs no new frame arm.'
6419
+ event: { type: string, description: 'Which hook event (Stop / PreToolUse / …) — defined by "a hook adjudication did not complete", not any single feature.' }
6420
+ reason:
6421
+ type: string
6422
+ enum: [no_content, unparsed, skipped]
6423
+ description: 'Machine-branchable cause. CLOSED on the server side (fleet-bus.ts HookNotice.reason) but OPEN ON READ — branch known values, render anything else as the generic "could not evaluate".'
6424
+ detail: { type: string, description: 'Redacted supplement (e.g. why skipped). Additive / tolerate-absent.' }
6425
+
6426
+ BakeClaim:
6427
+ type: object
6428
+ description: >
6429
+ The RUNNER claim response of POST /v1/images/bakes/claim and POST /v1/images/bakes/{bakeId}/claim
6430
+ (server claimResponse, http/server.ts:9164 — exact key set): the VETTED argv + the per-bake ingest
6431
+ secret (minted at claim, echoed on every ingest via the x-bake-ingest-secret header) + the
6432
+ profile/bands the runner needs for its profile-aware hard deadline. The runner executes `argv`
6433
+ VERBATIM — it never assembles its own command line. 204 (no body) = queue empty.
6434
+ required: [bakeId, argv, push, dryRun, profile, ingestSecret, leaseUntil]
6435
+ additionalProperties: true
6436
+ properties:
6437
+ bakeId: { type: string }
6438
+ argv:
6439
+ type: array
6440
+ items: { type: string }
6441
+ description: 'The server-assembled, whitelist-vetted build command — execute verbatim, never self-assemble.'
6442
+ push: { type: boolean }
6443
+ dryRun: { type: boolean }
6444
+ logs: { description: 'Log routing config, passed through as stored (opaque to the claim contract).' }
6445
+ profile: { type: string }
6446
+ bands: { description: 'Profile bands for the runner''s profile-aware hard deadline (opaque passthrough).' }
6447
+ ingestSecret: { type: string, description: 'Per-bake credential — the ONLY place it leaves image-api; echo it on every ingest.' }
6448
+ leaseUntil:
6449
+ description: 'Lease expiry (epoch ms or ISO timestamp depending on store backend).'
6450
+ oneOf: [{ type: number }, { type: string }]
6451
+
6452
+ OutcomeRow:
6453
+ type: object
6454
+ description: >
6455
+ One task-outcome ledger row of GET /v1/outcomes (envelope key `outcomes`; design/73 §7 read-only
6456
+ base). Shape = the SQL ledgers' per-(taskSignature, model) summary projection (server
6457
+ tidb-outcome-ledger.ts:186 / pg-outcome-ledger.ts:124 — the only queryable sinks; a File sink
6458
+ 501s honestly). OPEN set — mechanical-signal read-only surface.
6459
+ required: [taskSignature, model, n, passRate, meanCostMicroUsd]
6460
+ additionalProperties: true
6461
+ properties:
6462
+ taskSignature: { type: string }
6463
+ model: { type: string }
6464
+ n: { type: integer, description: 'How many outcome facts aggregate into this row.' }
6465
+ passRate: { type: number }
6466
+ meanCostMicroUsd: { type: number }
6467
+
6468
+ SendfileLinkRow:
6469
+ type: object
6470
+ description: >
6471
+ One SendUserFile distribution-link ledger row of GET /v1/sendfile-links (envelope `{links,
6472
+ nextBefore?}`; server http/server.ts:5504 — exact projection). A principal caller is PINNED to its
6473
+ own scope (?scope= ignored); a fleet credential may pass ?scope= (default = the single-user
6474
+ sentinel "_"). Page with `before` = a previous page's `nextBefore` (uuidv7; malformed → 400).
6475
+ required: [id, filename, size, ttlSec, track, bucket, key, createdAt]
6476
+ additionalProperties: true
6477
+ properties:
6478
+ id: { type: string, description: 'uuidv7 link id — also the `before` pagination cursor.' }
6479
+ filename: { type: string }
6480
+ size: { type: integer }
6481
+ ttlSec: { type: integer }
6482
+ track: { type: string }
6483
+ bucket: { type: string }
6484
+ key: { type: string, description: 'The object-store key the link resolves to.' }
6485
+ createdAt: { type: string, description: 'ISO-8601.' }
6486
+ taskId: { type: string, description: 'Issuing task, when recorded. Additive / tolerate-absent.' }
6487
+ sessionId: { type: string, description: 'Issuing session, when recorded. Additive / tolerate-absent.' }
6488
+
6489
+ SubagentSteerReceipt:
6490
+ type: object
6491
+ description: >
6492
+ The 200 receipt of POST /v1/runs/{runId}/subagents/{target}/steer and …/resume (server
6493
+ http/server.ts:4143/4148 — exact literal: `status:"running"`, `delivery:"applied"`, `marker` =
6494
+ the engine-minted delivery marker, `note` = the CC-verbatim "Message queued for delivery…" copy).
6495
+ required: [taskId, target]
6496
+ additionalProperties: true
6497
+ properties:
6498
+ taskId: { type: string, description: 'The parent runId (echoed).' }
6499
+ target: { type: string, description: 'The child addressed (parentToolCallId or agentName), echoed.' }
6500
+ status: { type: string, description: 'Literal "running" on today''s server.' }
6501
+ delivery: { type: string, description: 'Literal "applied" on today''s server.' }
6502
+ note: { type: string, description: 'The CC-verbatim queued copy ("Message queued for delivery to <name>…").' }
6503
+ marker: { type: string, description: 'Engine-minted delivery marker (present on both steer and resume 200s, server 1.214+).' }
6504
+
6505
+ SubagentOutputResult:
6506
+ type: object
6507
+ description: >
6508
+ The 200 body of GET /v1/runs/{runId}/subagents/{target}/output and the generic
6509
+ …/tasks/{target}/output|/stop faces (server http/server.ts:3852/4070). `content` = the engine
6510
+ TaskOutput-tool text (the child's final assistant body once terminal) — UNTRUSTED model output,
6511
+ same posture as a run `result`. `output` = the engine registry's UnifiedTaskOutput projection
6512
+ passed through VERBATIM.
6513
+ required: [taskId, target, content, output]
6514
+ additionalProperties: true
6515
+ properties:
6516
+ taskId: { type: string }
6517
+ target: { type: string }
6518
+ content: { type: string, description: 'UNTRUSTED engine/model output — render only.' }
6519
+ output:
6520
+ type: object
6521
+ additionalProperties: true
6522
+ description: 'The registry''s honest projection, verbatim (status/retrieval_status/partial flags).'
6523
+ properties:
6524
+ task_id: { type: string }
6525
+ type: { type: string, description: 'Registry kind (e.g. background_agent / background_bash / monitor).' }
6526
+ status: { type: string, description: 'Known: pending / running / completed / failed / killed (open on read).' }
6527
+ retrieval_status: { type: string, description: '"success" once readable.' }
6528
+ error: { type: string }
6529
+ stoppedBy: { type: string }
6530
+ seq: { type: integer, description: 'Stop-cycle generation (core 1.373 durable terminal-serve projection; 1 = first settle, >= 2 = a revive cycle re-settled). In-process poll does not project it — absent does not mean unsettled.' }
6531
+ partial_result: { type: boolean }
6532
+ details: { description: 'Kind-specific inner details, opaque passthrough.' }
6533
+ cursorSemantics:
6534
+ type: string
6535
+ enum: [cursor, full]
6536
+ description: >
6537
+ G14 (server >= 1.291, generic taskOutput face ONLY — the narrow subagentOutput face does not
6538
+ mint it): this read's cursor semantics. "cursor" = reading consumed the cursor (non-spool
6539
+ background_bash: the client must accumulate; a re-read does not return old segments); "full" =
6540
+ re-reading is safe (spool bash / monitor / agent reports). Not minted on error/not_ready
6541
+ shapes — never treat absence as "full". Additive / tolerate-absent.
6542
+
6543
+ CompactAck:
6544
+ type: object
6545
+ description: >
6546
+ The 202 ack of POST /v1/runs/{runId}/compact (K-1c manual compaction; server http/server.ts:3595 —
6547
+ exact literal: `status:"running"`, `delivery:"accepted"`). ACCEPTANCE, not an outcome: compaction
6548
+ runs at the next turn boundary and a `compacted{trigger:"manual"}` event rides the run stream ONLY
6549
+ if anything was summarized (mooted/failed → no event).
6550
+ required: [taskId]
6551
+ additionalProperties: true
6552
+ properties:
6553
+ taskId: { type: string }
6554
+ status: { type: string, description: 'Literal "running" on today''s server.' }
6555
+ delivery: { type: string, description: 'Literal "accepted" on today''s server.' }
6556
+ note: { type: string, description: 'The "compaction will run at the next turn boundary…" copy.' }
6557
+
6558
+ DetachAck:
6559
+ type: object
6560
+ description: >
6561
+ The 202 ack of POST /v1/runs/{runId}/detach (server http/server.ts:3650 — exact literal:
6562
+ `toolCallId` echoed, `delivery:"requested"`). Fire-and-forget: acceptance only — the
6563
+ authoritative outcome is the tool call's own `tool_end.structured {detached:true, task_id}`;
6564
+ a non-detachable env makes the request a fail-safe no-op.
6565
+ required: [taskId]
6566
+ additionalProperties: true
6567
+ properties:
6568
+ taskId: { type: string }
6569
+ toolCallId: { type: string, description: 'Echoed from the request.' }
6570
+ delivery: { type: string, description: 'Literal "requested" on today''s server.' }
6571
+ note: { type: string, description: 'The fail-safe no-op copy.' }
6572
+
6573
+ SideQueryRequest:
6574
+ type: object
6575
+ description: >
6576
+ The POST /v1/side-query body ([1469], server 1.242; http/server.ts:1853 — whitelist passthrough of
6577
+ core SideQuerySpec). One-shot brain routing Q&A: no session side effects, no tool EXECUTION, no
6578
+ engine-side policy gate, no streaming (v1). `signal` is server territory — client disconnect
6579
+ abandons the call; sending it in the body is discarded. Rides every billable-submit gate
6580
+ (no-token 503 fail-closed, draining/model-ready 503, rate/quota/lease).
6581
+ required: [messages]
6582
+ additionalProperties: true
6583
+ properties:
6584
+ model: { type: string, description: 'Pool name / role / @mention, resolved like the task face; default role when absent.' }
6585
+ modelRole: { type: string }
6586
+ thinking: { type: string, description: 'A core thinking level; invalid → 400.' }
6587
+ systemPrompt: { type: string }
6588
+ messages:
6589
+ type: array
6590
+ items: { type: object, additionalProperties: true }
6591
+ description: 'core SideQueryMessage[] (user/assistant/toolResult arms; assistant metadata optional, string content foldable). Non-empty — [] → 400.'
6592
+ tools:
6593
+ type: array
6594
+ items:
6595
+ type: object
6596
+ required: [name, description, parameters]
6597
+ properties:
6598
+ name: { type: string }
6599
+ description: { type: string }
6600
+ parameters: { type: object, additionalProperties: true }
6601
+ description: 'Tool DEFINITIONS (so the model can emit toolCalls data) — the server NEVER executes them.'
6602
+ maxOutputTokens: { type: integer }
6603
+
6604
+ SideQueryResult:
6605
+ type: object
6606
+ description: >
6607
+ The 200 body of POST /v1/side-query (core SideQueryResult passed through verbatim, server
6608
+ http/server.ts:1917). `model` = routing identity; `servedModel` = who actually served (degrading
6609
+ fallback attributes honestly). A post-stream error lands in `errorMessage`, NOT an HTTP error
6610
+ (400 is reserved for validation/model-resolution; 5xx = a server defect).
6611
+ required: [text, toolCalls, model, servedModel, usage, stopReason]
6612
+ additionalProperties: true
6613
+ properties:
6614
+ text: { type: string }
6615
+ toolCalls:
6616
+ type: array
6617
+ items:
6618
+ type: object
6619
+ required: [id, name, args]
6620
+ properties:
6621
+ id: { type: string }
6622
+ name: { type: string }
6623
+ args: { description: 'The model-authored tool arguments (data only — nothing was executed).' }
6624
+ model: { type: string, description: 'The routing identity the request resolved to.' }
6625
+ servedModel: { type: string, description: 'Who actually served (degrading fallback attributes honestly).' }
6626
+ degraded:
6627
+ type: object
6628
+ additionalProperties: true
6629
+ properties:
6630
+ from: { type: string }
6631
+ to: { type: string }
6632
+ reason: { type: string }
6633
+ responseModel: { type: string }
6634
+ usage: { type: object, additionalProperties: true }
6635
+ usageMissing: { type: boolean, enum: [true] }
6636
+ stopReason: { type: string }
6637
+ errorMessage: { type: string, description: 'A post-stream error (contract: not thrown as HTTP).' }
6638
+
6639
+ ToolApprovalDecision:
6640
+ type: string
6641
+ enum: [allow, allow_session, deny]
6642
+ description: >
6643
+ The human's decision on a live tool-approval gate (server parseToolApprovalDecision,
6644
+ tool-approval.ts — CLOSED 3-word set; anything else is a 400). `allow_session` = allow AND
6645
+ remember for this session's category (fs-write tools share ONE category: approving Write covers
6646
+ Edit/NotebookEdit; other tools are per-tool) — the CC "don't ask again this session" semantic.
6647
+
6648
+ ToolApprovalRespondAck:
6649
+ type: object
6650
+ description: >
6651
+ The 200 ack of POST /v1/tool-approvals/{approvalId}/respond (server tool-approval.ts:521 — exact
6652
+ shape, `decision` echoed). Owner-gated with a 404 and NO existence oracle: non-owner and
6653
+ unknown/settled/expired/wrong-replica ids are indistinguishable.
6654
+ required: [approvalId, delivery, decision]
6655
+ additionalProperties: true
6656
+ properties:
6657
+ approvalId: { type: string }
6658
+ delivery: { type: string, enum: [applied] }
6659
+ decision: { $ref: '#/components/schemas/ToolApprovalDecision' }
6660
+ rememberApplied:
6661
+ type: boolean
6662
+ description: >
6663
+ server 1.239 ([1392]②): on allow_session, an honest echo of whether the grant was REALLY
6664
+ recorded (true = landed in the bridge store; false = no sessionId, could not record — do not
6665
+ render "session-wide allowed"). Omitted on non-allow_session decisions and on older servers.
6666
+ updatedInputForwarded:
6667
+ type: boolean
6668
+ description: >
6669
+ server 1.241 ([1458]): present (true) when an allow-family decision carried `updatedInput` and
6670
+ the server forwarded the edited args to the engine — forwarded, not necessarily applied
6671
+ (consumption depends on the core OnAsk object arm). Omitted on deny / no edit / older servers.
6672
+
6673
+ UsageMetric:
6674
+ type: string
6675
+ enum: [tasks, tokensIn, tokensOut, costUsd]
6676
+ description: 'The ?metric= axis of GET /v1/usage/series (server usage-analytics.ts:67). Default costUsd.'
6677
+
6678
+ UsageGranularity:
6679
+ type: string
6680
+ enum: [hour, day]
6681
+ description: 'The ?granularity= axis of GET /v1/usage/series (UTC buckets; server usage-analytics.ts:68). Default day.'
6682
+
6683
+ UsageDimension:
6684
+ type: string
6685
+ enum: [principal, model]
6686
+ description: >
6687
+ The ?dimension= axis of GET /v1/usage/breakdown (server usage-analytics.ts:85). Default principal.
6688
+ A JWT principal querying dimension=principal only ever sees its own bucket (owner is enforced
6689
+ upstream — the semantics hold naturally, no leak surface).
6690
+
6691
+ UsageTotals:
6692
+ type: object
6693
+ description: >
6694
+ Window totals (server usage-analytics.ts:31 UsageTotals). tokensIn = Σ(inputTokens +
6695
+ cacheReadTokens + cacheWriteTokens) — the billing view (cache hits count); tokensOut = Σ
6696
+ outputTokens; costUsd = Σ costMicroUsd / 1e6 (authoritative micro-USD ledger, not an estimate).
6697
+ required: [tasks, tokensIn, tokensOut, costUsd, estimated]
6698
+ additionalProperties: true
6699
+ properties:
6700
+ tasks: { type: integer }
6701
+ tokensIn: { type: number }
6702
+ tokensOut: { type: number }
6703
+ costUsd: { type: number }
6704
+ estimated:
6705
+ type: boolean
6706
+ description: 'true = some rows lacked the per-model echo and fell back to stats.tokens (counted into tokensOut) — the token view is partly estimated. Honest flag, contract-required.'
6707
+
6708
+ UsageWindowBase:
6709
+ type: object
6710
+ description: >
6711
+ The common window envelope of the /v1/usage/{summary,series,breakdown} responses (server
6712
+ http/server.ts:1284). `from`/`to` are the RESOLVED window (ISO-8601; defaults now-7d..now).
6713
+ required: [from, to]
6714
+ additionalProperties: true
6715
+ properties:
6716
+ from: { type: string, description: 'ISO-8601 window start (resolved from the request or the 7-day default).' }
6717
+ to: { type: string, description: 'ISO-8601 window end.' }
6718
+ truncated:
6719
+ type: boolean
6720
+ enum: [true]
6721
+ description: 'Present (true) ⇔ the store scan hit its row limit (USAGE_SCAN_LIMIT) — the window was truncated, never silently.'
6722
+
6723
+ UsageSummary:
6724
+ description: 'The 200 body of GET /v1/usage/summary — window envelope + totals (server http/server.ts:1286).'
6725
+ allOf:
6726
+ - $ref: '#/components/schemas/UsageWindowBase'
6727
+ - $ref: '#/components/schemas/UsageTotals'
6728
+
6729
+ UsageSeries:
6730
+ description: >
6731
+ The 200 body of GET /v1/usage/series (server http/server.ts:1294). UTC buckets; EMPTY BUCKETS ARE
6732
+ NOT EMITTED — consumers zero-fill as needed.
6733
+ allOf:
6734
+ - $ref: '#/components/schemas/UsageWindowBase'
6735
+ - type: object
6736
+ required: [metric, granularity, series]
6737
+ properties:
6738
+ metric: { $ref: '#/components/schemas/UsageMetric' }
6739
+ granularity: { $ref: '#/components/schemas/UsageGranularity' }
6740
+ series:
6741
+ type: array
6742
+ items:
6743
+ type: object
6744
+ required: [t, v]
6745
+ properties:
6746
+ t: { type: string, description: 'ISO-8601 bucket start (UTC).' }
6747
+ v: { type: number }
6748
+
6749
+ UsageBreakdown:
6750
+ description: >
6751
+ The 200 body of GET /v1/usage/breakdown (server http/server.ts:1302). dimension=model expands the
6752
+ per-model echo (one run may contribute to several model buckets; fallback rows land in
6753
+ "(unattributed)"); dimension=principal maps a NULL owner to "(anonymous)".
6754
+ allOf:
6755
+ - $ref: '#/components/schemas/UsageWindowBase'
6756
+ - type: object
6757
+ required: [dimension, breakdown]
6758
+ properties:
6759
+ dimension: { $ref: '#/components/schemas/UsageDimension' }
6760
+ breakdown:
6761
+ type: array
6762
+ items:
6763
+ allOf:
6764
+ - type: object
6765
+ required: [key]
6766
+ properties:
6767
+ key: { type: string, description: 'The bucket key (a principal or a model id).' }
6768
+ - $ref: '#/components/schemas/UsageTotals'
6769
+
6770
+ WorkflowAgentSteerReceipt:
6771
+ type: object
6772
+ description: >
6773
+ The 200 receipt of POST /v1/workflows/{runId}/agents/{label}/steer (server http/server.ts:3752 —
6774
+ exact literal: `status:"running"`, `delivery:"applied"`, `marker` = the engine-minted delivery
6775
+ marker; NO `note`, unlike the run-subagent verb).
6776
+ required: [runId, label]
6777
+ additionalProperties: true
6778
+ properties:
6779
+ runId: { type: string }
6780
+ label: { type: string }
6781
+ status: { type: string, description: 'Literal "running" on today''s server.' }
6782
+ delivery: { type: string, description: 'Literal "applied" on today''s server.' }
6783
+ marker: { type: string, description: 'Engine-minted delivery marker.' }
6784
+
6785
+ WorkspaceSnapshotRow:
6786
+ type: object
6787
+ description: >
6788
+ One snapshot row of GET /v1/sessions/{sessionId}/workspace (envelope `{sessionId, snapshots,
6789
+ latest?, total}`; server http/server.ts:6109 — newest first, uuidv7 keys). E19 snapshot store's
6790
+ read-only projection: each row is the freeze at a turn boundary, NOT a live workspace.
6791
+ required: [key, files]
6792
+ additionalProperties: true
6793
+ properties:
6794
+ key: { type: string, description: 'Snapshot key (uuidv7 entry id; "latest" is an accepted alias on the sub-routes).' }
6795
+ files: { type: integer, description: 'Manifest row count.' }
6796
+ bytes: { type: integer, description: 'Total snapshot bytes — present only when the store has a sizes face (SQL backends); the local store honestly omits it ([1894]② additive).' }
6797
+
6798
+ WorkspaceTreeEntry:
6799
+ type: object
6800
+ description: >
6801
+ One file entry of GET /v1/sessions/{sessionId}/workspace/{key}/tree (envelope `{sessionId, key,
6802
+ entries, total, nextOffset?}`; server http/server.ts:6144 — stable path order, offset paging).
6803
+ required: [path, hash]
6804
+ additionalProperties: true
6805
+ properties:
6806
+ path: { type: string, description: 'The relPath — pass VERBATIM as ?path= on the file sub-route.' }
6807
+ hash: { type: string, description: 'Content address (sha256) — enables cross-snapshot change highlighting ([1894]②).' }
6808
+ size: { type: integer, description: 'Present only when the store has a sizes face (SQL backends).' }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/sdk",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Typed, zero-runtime-dependency SDK for the Sema agent fleet usage plane. The shared substrate for all doors (CC/Codex MCP façade + web). Server-side only — tokens never enter the browser.",
5
5
  "type": "module",
6
6
  "license": "BUSL-1.1",