@sema-agent/sdk 0.0.121 → 0.0.122

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 +290 -0
  2. package/package.json +1 -1
package/openapi.yaml CHANGED
@@ -547,6 +547,296 @@ paths:
547
547
  application/json:
548
548
  schema: { $ref: '#/components/schemas/ErrorResponse' }
549
549
 
550
+ /v1/runs/{taskId}/compact:
551
+ parameters:
552
+ - $ref: '#/components/parameters/PrincipalHeader'
553
+ - $ref: '#/components/parameters/TaskIdPath'
554
+ post:
555
+ tags: [runs]
556
+ operationId: runsCompact
557
+ x-status: live # core 1.293 compact(opts); manual-compaction control leg.
558
+ summary: Request a manual compaction of a LIVE run (fires at the next safe turn boundary).
559
+ description: >
560
+ Manual compaction control. FIRE-AND-FORGET 202 — `compact()` resolves only once processed at the next
561
+ SAFE turn boundary (possibly a whole in-flight turn away), so the ack is immediate and the outcome
562
+ rides the run's OWN stream: a `compacted{trigger:"manual"}` event IF anything was summarized; the
563
+ other outcomes (failed/mooted/noop/blocked/disabled) emit NO event (a spinner must time out, not
564
+ block). `instructions` = the shell's targeted-summary directive, capped at 2048 CODE POINTS (the
565
+ engine's own cap — over-cap is a fail-loud 400 here, never a silently truncated 202). LIVE-only and
566
+ replica-local (`steerableRuns` handle): a run active on another replica or terminal → 409
567
+ `compact.not_running`. Owner-gated (operator may compact any tenant's run); burns model budget —
568
+ rate/quota/lease gates apply.
569
+ requestBody:
570
+ required: false
571
+ content:
572
+ application/json:
573
+ schema:
574
+ type: object
575
+ properties:
576
+ instructions: { type: string, minLength: 1, description: 'Targeted compaction directive; ≤2048 code points (engine cap, enforced fail-loud).' }
577
+ responses:
578
+ '202':
579
+ description: Accepted — compaction runs at the next turn boundary; watch the run stream for `compacted{trigger:"manual"}`.
580
+ content:
581
+ application/json:
582
+ schema:
583
+ type: object
584
+ required: [taskId, status, delivery]
585
+ properties:
586
+ taskId: { type: string }
587
+ status: { type: string }
588
+ delivery: { type: string, enum: [accepted] }
589
+ note: { type: string }
590
+ '400': { $ref: '#/components/responses/BadRequest' }
591
+ '401': { $ref: '#/components/responses/Unauthorized' }
592
+ '404': { $ref: '#/components/responses/NotFound' }
593
+ '409':
594
+ description: 'errorCode "compact.not_running" — run is terminal, or active on another replica (manual compact is replica-local).'
595
+ content:
596
+ application/json:
597
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
598
+ '501': { $ref: '#/components/responses/NotImplemented' }
599
+
600
+ /v1/runs/{taskId}/detach:
601
+ parameters:
602
+ - $ref: '#/components/parameters/PrincipalHeader'
603
+ - $ref: '#/components/parameters/TaskIdPath'
604
+ post:
605
+ tags: [runs]
606
+ operationId: runsDetach
607
+ x-status: live # core 1.207 design/116 (CC mid-flight ctrl+b) sync-leg detach verb.
608
+ summary: Move a RUNNING tool call of this run to the background (CC ctrl+b).
609
+ description: >
610
+ design/116 — `TaskStream.detach(toolCallId)`. Fire-and-forget by CONTRACT and race-safe core-side: a
611
+ request landing before the tool reads its signal still detaches; after it finished = no-op; unknown
612
+ toolCallId = no-op (fail-safe — but note the ≤256-char cap is load-bearing: an unknown id still
613
+ allocates a registry entry for the run's lifetime). Only a detach-capable env honors it
614
+ (`backgroundCapabilities.supportsDetach`). The outcome surfaces on the run's OWN stream: the
615
+ early-settled `tool_end` with the `detached:true` structured card, then the `b*` task notification.
616
+ LIVE-only + replica-local (like compact) → 409 `detach.not_running` otherwise. Owner-gated; mutating
617
+ but runs no model (rate-limited only, no quota gate — parity with cancel).
618
+ requestBody:
619
+ required: true
620
+ content:
621
+ application/json:
622
+ schema:
623
+ type: object
624
+ required: [toolCallId]
625
+ properties:
626
+ toolCallId: { type: string, minLength: 1, maxLength: 256 }
627
+ responses:
628
+ '202':
629
+ description: Requested — honest about carrying no confirmation (the run stream carries the outcome).
630
+ content:
631
+ application/json:
632
+ schema:
633
+ type: object
634
+ required: [taskId, toolCallId, delivery]
635
+ properties:
636
+ taskId: { type: string }
637
+ toolCallId: { type: string }
638
+ delivery: { type: string, enum: [requested] }
639
+ note: { type: string }
640
+ '400': { $ref: '#/components/responses/BadRequest' }
641
+ '401': { $ref: '#/components/responses/Unauthorized' }
642
+ '404': { $ref: '#/components/responses/NotFound' }
643
+ '409':
644
+ description: 'errorCode "detach.not_running" — run is terminal, or active on another replica.'
645
+ content:
646
+ application/json:
647
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
648
+ '501': { $ref: '#/components/responses/NotImplemented' }
649
+
650
+ /v1/runs/{taskId}/subagents/{target}/output:
651
+ parameters:
652
+ - $ref: '#/components/parameters/PrincipalHeader'
653
+ - $ref: '#/components/parameters/TaskIdPath'
654
+ - name: target
655
+ in: path
656
+ required: true
657
+ schema: { type: string }
658
+ description: 'Background-agent handle (`a*` short form) under this parent run.'
659
+ get:
660
+ tags: [runs]
661
+ operationId: runsSubagentOutput
662
+ x-status: live # [1488]③(b) background child read face (announced background_agent-ONLY contract, byte-stable).
663
+ summary: Read a BACKGROUND child's final report / current status (non-blocking).
664
+ description: >
665
+ [1488]③(b) — the background child read face. The fleet viewer gets `bg_notification` summaries only;
666
+ the child's FINAL assistant body lives in the core TaskRegistry (what the TaskOutput tool reads) and
667
+ is served here. Auth = the runs-face read pattern (verified principal → owner via the parent run row →
668
+ honest 404, no existence oracle); registry access is derived from the run row, NEVER caller-supplied.
669
+ Replica-local (in-process registry, like steer). Non-blocking: a still-running child returns its
670
+ current status honestly, no long-poll. This face is the announced `background_agent`-ONLY contract —
671
+ the generic task-handle verbs live under `/v1/runs/{taskId}/tasks/{target}/…`.
672
+ responses:
673
+ '200':
674
+ description: 'The registry projection. `content` = the child''s final assistant body (UNTRUSTED model output).'
675
+ content:
676
+ application/json:
677
+ schema:
678
+ type: object
679
+ required: [taskId, target]
680
+ properties:
681
+ taskId: { type: string }
682
+ target: { type: string }
683
+ content: { type: string }
684
+ output: { type: object, description: 'Registry details projection (status/kind/…), passed through verbatim.' }
685
+ '401': { $ref: '#/components/responses/Unauthorized' }
686
+ '404': { $ref: '#/components/responses/NotFound' }
687
+ '501': { $ref: '#/components/responses/NotImplemented' }
688
+
689
+ /v1/runs/{taskId}/subagents/{target}/resume:
690
+ parameters:
691
+ - $ref: '#/components/parameters/PrincipalHeader'
692
+ - $ref: '#/components/parameters/TaskIdPath'
693
+ - name: target
694
+ in: path
695
+ required: true
696
+ schema: { type: string }
697
+ description: 'The delegating tool call''s id (`parentToolCallId`) or the subagent''s agentName (ambiguous → 409).'
698
+ post:
699
+ tags: [runs]
700
+ operationId: runsResumeSubagent
701
+ x-status: live # design/122 ③ (CC dfe parity): revive a settled child on its retained session.
702
+ summary: REVIVE a SETTLED subagent with a new prompt (async, on its retained session).
703
+ description: >
704
+ design/122 — CC "resume the agent" parity. Always async: the revived child runs in the background on
705
+ its RETAINED session (requires the parent run to have set `retainSubagentSessions`); completion is
706
+ announced via the deployment notify sink. Resume is only legal AFTER settle (handles live until leg
707
+ end). Owner-gated via the parent run row; content is fenced (`redactSteerIn`); the child's session id
708
+ is a continuation capability and never appears in any response. BILLABLE (starts model work) —
709
+ rate/quota/lease gates apply.
710
+ requestBody:
711
+ required: true
712
+ content:
713
+ application/json:
714
+ schema:
715
+ type: object
716
+ required: [content]
717
+ properties:
718
+ content: { type: string, description: 'The revival prompt (untrusted DATA; fenced server-side).' }
719
+ responses:
720
+ '200':
721
+ description: 'Revived. Body `{ taskId, target, status, delivery, marker, note }`.'
722
+ '401': { $ref: '#/components/responses/Unauthorized' }
723
+ '404': { $ref: '#/components/responses/NotFound' }
724
+ '409':
725
+ description: 'core''s typed rejections verbatim as `errorCode`: resume.still_running / resume.retain_off / resume.evicted / resume.cap / resume.session_not_found (design/122 D2).'
726
+ content:
727
+ application/json:
728
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
729
+ '501': { $ref: '#/components/responses/NotImplemented' }
730
+
731
+ /v1/runs/{taskId}/subagents/{target}/stream:
732
+ parameters:
733
+ - $ref: '#/components/parameters/PrincipalHeader'
734
+ - $ref: '#/components/parameters/TaskIdPath'
735
+ - name: target
736
+ in: path
737
+ required: true
738
+ schema: { type: string }
739
+ description: 'Background-agent handle (`a*` short form) under this parent run.'
740
+ get:
741
+ tags: [runs]
742
+ operationId: runsSubagentStream
743
+ x-status: live # S2 [1520] per-agent live tail (core 1.370 bgAgentId).
744
+ summary: Per-agent LIVE TAIL (SSE) — content frames from connect time onward.
745
+ description: >
746
+ S2 — the "tail" half of replay+tail (replay/final report = the `/output` face). SSE frames: first an
747
+ `event: meta` frame (`{version, runId, target, status, seq?, live: "replica-local", replayFace}`),
748
+ then `event: forward` frames (text/reasoning deltas, tool_start/end, task_progress — same builder
749
+ discipline as the sync main stream's forward branch) and `event: heartbeat` keepalives (real frames,
750
+ not comment lines). Frames are produced only on the replica hosting the parent run ⇒ live frames are
751
+ replica-local (the meta declares it; a row running on another instance heartbeats only, never
752
+ fabricates). A terminal child ends the stream right after the meta (the replay face is the read
753
+ surface). Gates are byte-identical to the `/output` face (principal → owner → session, fail-closed
754
+ 404, no oracle).
755
+ responses:
756
+ '200':
757
+ description: 'SSE stream (`text/event-stream`): meta → forward*/heartbeat*.'
758
+ content:
759
+ text/event-stream:
760
+ schema: { type: string }
761
+ '401': { $ref: '#/components/responses/Unauthorized' }
762
+ '404': { $ref: '#/components/responses/NotFound' }
763
+ '501': { $ref: '#/components/responses/NotImplemented' }
764
+
765
+ /v1/runs/{taskId}/tasks/{target}/output:
766
+ parameters:
767
+ - $ref: '#/components/parameters/PrincipalHeader'
768
+ - $ref: '#/components/parameters/TaskIdPath'
769
+ - name: target
770
+ in: path
771
+ required: true
772
+ schema: { type: string }
773
+ description: 'EXACT task handle only (`b*` background bash, monitor, background agent) — agent-name / legacy-shellId resolution is deliberately not on the wire (fail-closed 404).'
774
+ get:
775
+ tags: [runs]
776
+ operationId: runsTaskOutput
777
+ x-status: live # [1499] CC TaskOutput human-side counterpart (generic task-handle verb family).
778
+ summary: Read a background task handle's output (CC TaskOutput human-side counterpart).
779
+ description: >
780
+ [1499] — the GENERIC task-handle read serving the full registry kind set (background_bash stdout,
781
+ monitor batches, background_agent final report). Whether a read consumes the output cursor depends on
782
+ the handle's shape — the top-level `cursorSemantics` key ("cursor" = new bytes per read | "full" =
783
+ re-readable) is minted server-side so consumers never parse content markers; absent on error/not_ready
784
+ shapes (no fake semantics). `workflow` handles are refused at the seam (journal face owns workflow
785
+ reads — a poll here would suppress the completion push). `?filter=` is NOT accepted (400): the wire
786
+ serves the clipped projection. Gates mirror the subagent output face (principal → owner → session).
787
+ responses:
788
+ '200':
789
+ description: 'Registry projection passed through verbatim; `content` is UNTRUSTED tool/model output.'
790
+ content:
791
+ application/json:
792
+ schema:
793
+ type: object
794
+ required: [taskId, target]
795
+ properties:
796
+ taskId: { type: string }
797
+ target: { type: string }
798
+ content: { type: string }
799
+ output: { type: object }
800
+ cursorSemantics: { type: string, enum: [cursor, full], description: 'G14: whether THIS read consumed the cursor. Absent on error/not_ready or unknown kinds.' }
801
+ '400': { $ref: '#/components/responses/BadRequest' }
802
+ '401': { $ref: '#/components/responses/Unauthorized' }
803
+ '404': { $ref: '#/components/responses/NotFound' }
804
+ '501': { $ref: '#/components/responses/NotImplemented' }
805
+
806
+ /v1/runs/{taskId}/tasks/{target}/stop:
807
+ parameters:
808
+ - $ref: '#/components/parameters/PrincipalHeader'
809
+ - $ref: '#/components/parameters/TaskIdPath'
810
+ - name: target
811
+ in: path
812
+ required: true
813
+ schema: { type: string }
814
+ description: 'EXACT task handle only (see the output verb); `workflow` handles refused.'
815
+ post:
816
+ tags: [runs]
817
+ operationId: runsTaskStop
818
+ x-status: live # [1499] CC TaskStop human-side counterpart.
819
+ summary: Stop a background task handle (CC TaskStop human-side counterpart).
820
+ description: >
821
+ [1499] — stop the handle's process. A stop whose kill did NOT land must not read as success: core
822
+ keeps the handle honest (status stays "running", error = the env failure code) and the wire surfaces
823
+ that as a 409 with a discriminated `errorCode` — stop.not_local (task attached to another instance) /
824
+ stop.park_arbiter_unreachable / stop.park_resume_won (a concurrent approval resume won the race) /
825
+ stop.parked (durably parked on a tool-approval — resolve the approval instead, nothing live to kill) /
826
+ stop.not_landed. Mutating but runs no model (rate-limited only, parity with detach). Gates mirror the
827
+ output verb.
828
+ responses:
829
+ '200':
830
+ description: 'Stopped — same projection shape as the output verb ({ taskId, target, content, output }).'
831
+ '401': { $ref: '#/components/responses/Unauthorized' }
832
+ '404': { $ref: '#/components/responses/NotFound' }
833
+ '409':
834
+ description: 'Stop did not land — discriminated `errorCode` (stop.not_local / stop.park_arbiter_unreachable / stop.park_resume_won / stop.parked / stop.not_landed); body includes the current projection.'
835
+ content:
836
+ application/json:
837
+ schema: { $ref: '#/components/schemas/ErrorResponse' }
838
+ '501': { $ref: '#/components/responses/NotImplemented' }
839
+
550
840
  /v1/sessions:
551
841
  parameters:
552
842
  - $ref: '#/components/parameters/PrincipalHeader'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sema-agent/sdk",
3
- "version": "0.0.121",
3
+ "version": "0.0.122",
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",