@raisindb/client 0.5.8 → 0.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -27,6 +27,8 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
27
27
  // src/index.ts
28
28
  var src_exports = {};
29
29
  __export(src_exports, {
30
+ AgentRunsApi: () => AgentRunsApi,
31
+ AgentRunsWsApi: () => AgentRunsWsApi,
30
32
  AllNodeEventTypes: () => AllNodeEventTypes,
31
33
  Archetypes: () => Archetypes,
32
34
  AuthManager: () => AuthManager,
@@ -67,6 +69,7 @@ __export(src_exports, {
67
69
  McpClient: () => McpClient,
68
70
  MemoryTokenStorage: () => MemoryTokenStorage,
69
71
  NodeBuilder: () => NodeBuilder,
72
+ NodeDevApi: () => NodeDevApi,
70
73
  NodeEventType: () => NodeEventType,
71
74
  NodeFileSource: () => NodeFileSource,
72
75
  NodeHelpers: () => NodeHelpers,
@@ -134,12 +137,14 @@ __export(src_exports, {
134
137
  isTerminalEvent: () => isTerminalEvent,
135
138
  isWebSocketClient: () => isWebSocketClient,
136
139
  logger: () => logger,
140
+ newControlId: () => newControlId,
137
141
  normalizeHomePath: () => normalizeHomePath,
138
142
  projectPlansFromMessages: () => projectPlansFromMessages,
139
143
  readTokensFromFragment: () => readTokensFromFragment,
140
144
  rowsToObjects: () => rowsToObjects,
141
145
  setLogLevel: () => setLogLevel,
142
146
  sleep: () => sleep,
147
+ subjectOf: () => subjectOf,
143
148
  useConversation: () => useConversation,
144
149
  useConversationList: () => useConversationList,
145
150
  useFlow: () => useFlow,
@@ -953,6 +958,15 @@ var RequestType = /* @__PURE__ */ ((RequestType2) => {
953
958
  RequestType2["FlowCancel"] = "flow_cancel";
954
959
  RequestType2["FlowSubscribeEvents"] = "flow_subscribe_events";
955
960
  RequestType2["FlowUnsubscribeEvents"] = "flow_unsubscribe_events";
961
+ RequestType2["AgentRunCreate"] = "agent_run_create";
962
+ RequestType2["AgentRunGet"] = "agent_run_get";
963
+ RequestType2["AgentRunBySubject"] = "agent_run_by_subject";
964
+ RequestType2["AgentRunList"] = "agent_run_list";
965
+ RequestType2["AgentRunEvents"] = "agent_run_events";
966
+ RequestType2["AgentRunSubscribe"] = "agent_run_subscribe";
967
+ RequestType2["AgentRunUnsubscribe"] = "agent_run_unsubscribe";
968
+ RequestType2["AgentRunControl"] = "agent_run_control";
969
+ RequestType2["AgentRunChildren"] = "agent_run_children";
956
970
  RequestType2["FunctionInvoke"] = "function_invoke";
957
971
  RequestType2["FunctionInvokeSync"] = "function_invoke_sync";
958
972
  RequestType2["ScheduledInvocationCreate"] = "scheduled_invocation_create";
@@ -3437,6 +3451,417 @@ function createAsyncQueue() {
3437
3451
  };
3438
3452
  }
3439
3453
 
3454
+ // src/agent-run-children.ts
3455
+ function spawnBody(o) {
3456
+ return {
3457
+ objective: o.objective,
3458
+ budgets: o.budgets,
3459
+ on_exceeded: o.onExceeded,
3460
+ spawn_key: o.spawnKey,
3461
+ subject: o.subject,
3462
+ as_agent: o.asAgent,
3463
+ agent_ref: o.agentRef,
3464
+ input: o.input ?? null,
3465
+ executor_config: o.executorConfig,
3466
+ reducer: o.reducer,
3467
+ inherit_reducer: o.inheritReducer ?? false
3468
+ };
3469
+ }
3470
+ function checkpointBody(o) {
3471
+ return {
3472
+ fence: o.fence,
3473
+ operation_id: o.operationId,
3474
+ reason: o.reason,
3475
+ summary: o.summary,
3476
+ transcript_cutoff: o.transcriptCutoff,
3477
+ state: o.state,
3478
+ large_refs: o.largeRefs ?? []
3479
+ };
3480
+ }
3481
+
3482
+ // src/agent-runs.ts
3483
+ function createRunBody(options) {
3484
+ return {
3485
+ subject: options.subject,
3486
+ branch: options.branch,
3487
+ agent_ref: options.agentRef,
3488
+ create_key: options.createKey,
3489
+ budgets: options.budgets,
3490
+ input: options.input ?? null,
3491
+ reducer: options.reducer,
3492
+ executor_config: options.executorConfig,
3493
+ control_capability: options.controlCapability,
3494
+ as_agent: options.asAgent
3495
+ };
3496
+ }
3497
+ function subjectOf(subject) {
3498
+ if (typeof subject !== "string") return subject;
3499
+ const cut = subject.indexOf(":/");
3500
+ if (cut <= 0) throw new Error(`subject must be "workspace:/path", got "${subject}"`);
3501
+ return { workspace: subject.slice(0, cut), path: subject.slice(cut + 1) };
3502
+ }
3503
+ var controlCounter = 0;
3504
+ function newControlId(prefix = "ctl") {
3505
+ controlCounter += 1;
3506
+ const rand = Math.random().toString(36).slice(2, 10);
3507
+ return `${prefix}-${Date.now().toString(36)}-${controlCounter}-${rand}`;
3508
+ }
3509
+ var AgentRunsApi = class {
3510
+ constructor(repository, transport) {
3511
+ this.repository = repository;
3512
+ this.transport = transport;
3513
+ }
3514
+ base(runId, rest = "") {
3515
+ const repo = encodeURIComponent(this.repository);
3516
+ const run = runId ? `/${encodeURIComponent(runId)}` : "";
3517
+ return `/api/agent-runs/${repo}${run}${rest}`;
3518
+ }
3519
+ /** Create a run, or get back the subject's live run. */
3520
+ create(options) {
3521
+ return this.transport.request("POST", this.base(), createRunBody(options));
3522
+ }
3523
+ /** Every run about `subject` you may see, newest (the live one) first. */
3524
+ bySubject(subject, limit = 20) {
3525
+ const s = subjectOf(subject);
3526
+ const q = new URLSearchParams({ subject: `${s.workspace}:${s.path ?? ""}`, limit: String(limit) });
3527
+ if (s.node_id) q.set("subject_node_id", s.node_id);
3528
+ return this.transport.request("GET", `${this.base()}?${q.toString()}`);
3529
+ }
3530
+ /** Read a run (record + effective projection). */
3531
+ get(runId) {
3532
+ return this.transport.request("GET", this.base(runId));
3533
+ }
3534
+ /** Your runs in one status (default "running"). */
3535
+ list(status = "running", limit = 50) {
3536
+ return this.transport.request("GET", `${this.base()}?status=${status}&limit=${limit}`);
3537
+ }
3538
+ /** Durable events after `afterSeq` (gap-free; page with the last seq). */
3539
+ events(runId, afterSeq = 0, limit = 500) {
3540
+ return this.transport.request("GET", this.base(runId, `/events?after_seq=${afterSeq}&limit=${limit}`));
3541
+ }
3542
+ /** Any control. Retrying with the same `controlId` is a no-op. */
3543
+ control(runId, command, controlId = newControlId(command.command), capability) {
3544
+ return this.transport.request("POST", this.base(runId, "/control"), {
3545
+ control_id: controlId,
3546
+ command,
3547
+ capability
3548
+ });
3549
+ }
3550
+ stop(runId, reason, controlId) {
3551
+ return this.control(runId, { command: "stop", reason }, controlId);
3552
+ }
3553
+ pause(runId, controlId) {
3554
+ return this.control(runId, { command: "pause" }, controlId);
3555
+ }
3556
+ resume(runId, controlId) {
3557
+ return this.control(runId, { command: "resume" }, controlId);
3558
+ }
3559
+ /** Queue input for the run's next safe boundary. */
3560
+ steer(runId, input, controlId) {
3561
+ return this.control(runId, { command: "steer", input }, controlId);
3562
+ }
3563
+ /** Decide an approval request; the digest ties it to one changeset. */
3564
+ approve(runId, requestId, subjectDigest, reject, controlId) {
3565
+ const decision = reject ? { decision: "reject", reason: reject.reason } : { decision: "approve" };
3566
+ return this.control(
3567
+ runId,
3568
+ { command: "approve", request_id: requestId, decision, subject_digest: subjectDigest },
3569
+ controlId
3570
+ );
3571
+ }
3572
+ /** Answer an input request. */
3573
+ answer(runId, requestId, value, controlId) {
3574
+ return this.control(runId, { command: "provide_input", request_id: requestId, value }, controlId);
3575
+ }
3576
+ /**
3577
+ * Stream the run's events: replay after `afterSeq`, then live. Ends after
3578
+ * the run's terminal event. Resume after a disconnect with the last `seq`.
3579
+ */
3580
+ async *stream(runId, afterSeq = 0, signal) {
3581
+ const response = await this.transport.fetch(
3582
+ this.transport.url(this.base(runId, `/stream?after_seq=${afterSeq}`)),
3583
+ { headers: { ...this.transport.headers(), Accept: "text/event-stream" }, signal }
3584
+ );
3585
+ if (!response.ok || !response.body) {
3586
+ throw new Error(`agent run stream failed: ${response.status} ${await response.text()}`);
3587
+ }
3588
+ const reader = response.body.getReader();
3589
+ const decoder = new TextDecoder();
3590
+ let buffer = "";
3591
+ for (; ; ) {
3592
+ const { value, done } = await reader.read();
3593
+ if (done) return;
3594
+ buffer += decoder.decode(value, { stream: true });
3595
+ let cut;
3596
+ while ((cut = buffer.indexOf("\n\n")) >= 0) {
3597
+ const block = buffer.slice(0, cut);
3598
+ buffer = buffer.slice(cut + 2);
3599
+ let event = "message";
3600
+ let data = "";
3601
+ for (const line of block.split("\n")) {
3602
+ if (line.startsWith("event:")) event = line.slice(6).trim();
3603
+ else if (line.startsWith("data:")) data += line.slice(5).trim();
3604
+ }
3605
+ if (event === "end") return;
3606
+ if (event === "error") throw new Error(`agent run stream error: ${data}`);
3607
+ if (event === "run-event" && data) yield JSON.parse(data);
3608
+ }
3609
+ }
3610
+ }
3611
+ // ---- client-driven runs -------------------------------------------------
3612
+ /** Take the lease of a queued client-driven run. */
3613
+ acquire(runId) {
3614
+ return this.transport.request("POST", this.base(runId, "/lease/acquire"), {});
3615
+ }
3616
+ renew(runId, fence) {
3617
+ return this.transport.request("POST", this.base(runId, "/lease/renew"), { fence });
3618
+ }
3619
+ release(runId, fence) {
3620
+ return this.transport.request("POST", this.base(runId, "/lease/release"), { fence });
3621
+ }
3622
+ /** Begin an operation; returns the active operation (its `op_id`). */
3623
+ begin(runId, fence, op) {
3624
+ return this.transport.request("POST", this.base(runId, "/operations"), { fence, ...op });
3625
+ }
3626
+ /** Record an operation's result. */
3627
+ finish(runId, fence, opId, result) {
3628
+ return this.transport.request("POST", this.base(runId, "/operations/finish"), { fence, op_id: opId, ...result });
3629
+ }
3630
+ /** Open approval/input requests and wait (`kind: "approval" | "input"`). */
3631
+ wait(runId, fence, requests) {
3632
+ return this.transport.request("POST", this.base(runId, "/wait"), { fence, requests });
3633
+ }
3634
+ /** End a client-driven run. */
3635
+ complete(runId, fence, status, outcome) {
3636
+ return this.transport.request("POST", this.base(runId, "/complete"), { fence, status, outcome });
3637
+ }
3638
+ // ── Child runs, mailbox, checkpoints, usage ──────────────────────────────
3639
+ /** Spawn a child with a typed objective; its budgets come out of this run's. */
3640
+ spawnChild(runId, options) {
3641
+ const q = options.branch ? `?branch=${encodeURIComponent(options.branch)}` : "";
3642
+ return this.transport.request("POST", this.base(runId, `/children${q}`), spawnBody(options));
3643
+ }
3644
+ /** Every child of a run: the parent's link plus the child's live status. */
3645
+ children(runId) {
3646
+ return this.transport.request("GET", this.base(runId, "/children"));
3647
+ }
3648
+ /** Inspect one child: record, events after `afterSeq`, usage, checkpoint. */
3649
+ inspectChild(runId, childId, afterSeq = 0, limit = 200) {
3650
+ const rest = `/children/${encodeURIComponent(childId)}?after_seq=${afterSeq}&limit=${limit}`;
3651
+ return this.transport.request("GET", this.base(runId, rest));
3652
+ }
3653
+ /** Message, steer, interrupt or resume a child (idempotent per `controlId`). */
3654
+ controlChild(runId, childId, action, controlId = newControlId(action.action)) {
3655
+ const rest = `/children/${encodeURIComponent(childId)}/control`;
3656
+ return this.transport.request("POST", this.base(runId, rest), { control_id: controlId, ...action });
3657
+ }
3658
+ messageChild(runId, childId, message, controlId) {
3659
+ return this.controlChild(runId, childId, { action: "message", message }, controlId);
3660
+ }
3661
+ steerChild(runId, childId, input, controlId) {
3662
+ return this.controlChild(runId, childId, { action: "steer", input }, controlId);
3663
+ }
3664
+ interruptChild(runId, childId, reason, mode = "stop", controlId) {
3665
+ return this.controlChild(runId, childId, { action: "interrupt", mode, reason }, controlId);
3666
+ }
3667
+ /** A client-driven parent waits (under its lease) for a child's hand-back. */
3668
+ waitChild(runId, childId, fence, expiresAtMs) {
3669
+ const rest = `/children/${encodeURIComponent(childId)}/wait`;
3670
+ return this.transport.request("POST", this.base(runId, rest), { fence, expires_at_ms: expiresAtMs });
3671
+ }
3672
+ /** Unacknowledged mailbox items (hand-backs and child messages). */
3673
+ mailbox(runId) {
3674
+ return this.transport.request("GET", this.base(runId, "/mailbox"));
3675
+ }
3676
+ /** Acknowledge mailbox items up to `upTo`. */
3677
+ ackMailbox(runId, upTo) {
3678
+ return this.transport.request("POST", this.base(runId, "/mailbox/ack"), { up_to: upTo });
3679
+ }
3680
+ /** A child posts a message to its parent's mailbox (idempotent per id). */
3681
+ postToParent(runId, messageId, message) {
3682
+ return this.transport.request("POST", this.base(runId, "/post-to-parent"), { message_id: messageId, message });
3683
+ }
3684
+ /** Write a structured checkpoint (compaction keeps state, not prose). */
3685
+ checkpoint(runId, options) {
3686
+ return this.transport.request("POST", this.base(runId, "/checkpoints"), checkpointBody(options));
3687
+ }
3688
+ /** Read a checkpoint (default: latest) with its structured state. */
3689
+ readCheckpoint(runId, checkpointNo) {
3690
+ return this.transport.request("GET", this.base(runId, `/checkpoints/${checkpointNo ?? "latest"}`));
3691
+ }
3692
+ /** Usage accounting: own, children, reserved, spare. */
3693
+ usage(runId) {
3694
+ return this.transport.request("GET", this.base(runId, "/usage"));
3695
+ }
3696
+ };
3697
+
3698
+ // src/agent-runs-ws.ts
3699
+ var TERMINAL = ["completed", "failed", "stopped"];
3700
+ var AgentRunsWsApi = class {
3701
+ constructor(context, sendRequest, eventHandler) {
3702
+ this.context = context;
3703
+ this.sendRequest = sendRequest;
3704
+ this.eventHandler = eventHandler;
3705
+ }
3706
+ call(type, payload) {
3707
+ return this.sendRequest(payload, type, this.context);
3708
+ }
3709
+ /** Create a run, or get back the subject's live run. */
3710
+ create(options) {
3711
+ return this.call("agent_run_create" /* AgentRunCreate */, createRunBody(options));
3712
+ }
3713
+ /** Read a run (record + effective projection). */
3714
+ get(runId) {
3715
+ return this.call("agent_run_get" /* AgentRunGet */, { run_id: runId });
3716
+ }
3717
+ /**
3718
+ * Every run about `subject` (a conversation, a document) you may see,
3719
+ * newest first — the live run, if there is one, comes first.
3720
+ */
3721
+ bySubject(subject, limit = 20) {
3722
+ return this.call("agent_run_by_subject" /* AgentRunBySubject */, { ...subjectOf(subject), limit });
3723
+ }
3724
+ /** The newest run of `subject`, or null. */
3725
+ async latest(subject) {
3726
+ const [first] = await this.bySubject(subject, 1);
3727
+ return first ?? null;
3728
+ }
3729
+ /** Your runs in one status (default "running"). */
3730
+ list(status = "running", limit = 50) {
3731
+ return this.call("agent_run_list" /* AgentRunList */, { status, limit });
3732
+ }
3733
+ /** Durable events after `afterSeq`. */
3734
+ events(runId, afterSeq = 0, limit = 500) {
3735
+ return this.call("agent_run_events" /* AgentRunEvents */, { run_id: runId, after_seq: afterSeq, limit });
3736
+ }
3737
+ /** The children a run spawned, with their current status. */
3738
+ children(runId) {
3739
+ return this.call("agent_run_children" /* AgentRunChildren */, { run_id: runId });
3740
+ }
3741
+ /** Any control. Retrying with the same `controlId` is a no-op. */
3742
+ control(runId, command, controlId = newControlId(command.command), capability) {
3743
+ return this.call("agent_run_control" /* AgentRunControl */, { run_id: runId, control_id: controlId, command, capability });
3744
+ }
3745
+ stop(runId, reason, controlId) {
3746
+ return this.control(runId, { command: "stop", reason }, controlId);
3747
+ }
3748
+ pause(runId, controlId) {
3749
+ return this.control(runId, { command: "pause" }, controlId);
3750
+ }
3751
+ resume(runId, controlId) {
3752
+ return this.control(runId, { command: "resume" }, controlId);
3753
+ }
3754
+ /** Queue input for the run's next safe boundary. */
3755
+ steer(runId, input, controlId) {
3756
+ return this.control(runId, { command: "steer", input }, controlId);
3757
+ }
3758
+ /** Decide an approval request; the digest ties it to one changeset. */
3759
+ approve(runId, requestId, subjectDigest, reject, controlId) {
3760
+ const decision = reject ? { decision: "reject", reason: reject.reason } : { decision: "approve" };
3761
+ return this.control(runId, { command: "approve", request_id: requestId, decision, subject_digest: subjectDigest }, controlId);
3762
+ }
3763
+ /** Answer an input request. */
3764
+ answer(runId, requestId, value, controlId) {
3765
+ return this.control(runId, { command: "provide_input", request_id: requestId, value }, controlId);
3766
+ }
3767
+ /**
3768
+ * Follow a run: replay after `afterSeq`, then live, until the run ends.
3769
+ *
3770
+ * Events that reach the socket before the subscription is known here are
3771
+ * not lost: the durable log is read once the listener is in place, live
3772
+ * events are held until that read is merged, and every seq is delivered
3773
+ * exactly once, in order.
3774
+ */
3775
+ async subscribe(runId, options = {}) {
3776
+ let last = options.afterSeq ?? 0;
3777
+ let ready = false;
3778
+ let closed = false;
3779
+ const held = [];
3780
+ const buffer = [];
3781
+ const waiters = [];
3782
+ let resolveDone;
3783
+ const done = new Promise((r) => resolveDone = r);
3784
+ const close = (ended) => {
3785
+ if (closed) return;
3786
+ closed = true;
3787
+ if (ended) options.onEnd?.(last);
3788
+ for (const w of waiters.splice(0)) w({ value: void 0, done: true });
3789
+ resolveDone();
3790
+ };
3791
+ const deliver = (ev) => {
3792
+ if (closed || ev.seq <= last) return;
3793
+ last = ev.seq;
3794
+ options.onEvent?.(ev);
3795
+ const w = waiters.shift();
3796
+ if (w) w({ value: ev, done: false });
3797
+ else buffer.push(ev);
3798
+ };
3799
+ const listener = (message) => {
3800
+ if (message.event_type === "agent_run_end") {
3801
+ if (ready) close(true);
3802
+ else held.push({ seq: Number.MAX_SAFE_INTEGER });
3803
+ return;
3804
+ }
3805
+ const ev = message.payload;
3806
+ if (ready) deliver(ev);
3807
+ else held.push(ev);
3808
+ };
3809
+ const response = await this.call("agent_run_subscribe" /* AgentRunSubscribe */, {
3810
+ run_id: runId,
3811
+ after_seq: last
3812
+ });
3813
+ const subscriptionId = response.subscription_id;
3814
+ this.eventHandler.addFlowEventListener(subscriptionId, listener);
3815
+ const unsubscribe = async () => {
3816
+ this.eventHandler.removeFlowEventListener(subscriptionId);
3817
+ close(false);
3818
+ await this.call("agent_run_unsubscribe" /* AgentRunUnsubscribe */, { subscription_id: subscriptionId }).catch(() => void 0);
3819
+ };
3820
+ options.signal?.addEventListener("abort", () => void unsubscribe(), { once: true });
3821
+ for (; ; ) {
3822
+ const page = await this.events(runId, last, 500);
3823
+ page.forEach(deliver);
3824
+ if (page.length < 500) break;
3825
+ }
3826
+ ready = true;
3827
+ const endSeen = held.some((e) => e.seq === Number.MAX_SAFE_INTEGER);
3828
+ held.filter((e) => e.seq !== Number.MAX_SAFE_INTEGER).sort((a, b) => a.seq - b.seq).forEach(deliver);
3829
+ if (endSeen) close(true);
3830
+ else {
3831
+ const view = await this.get(runId).catch(() => null);
3832
+ const finalized = !view?.run?.domain || view.run.domain.finalized !== false;
3833
+ if (view && TERMINAL.includes(view.status) && finalized) {
3834
+ const tail = await this.events(runId, last, 500).catch(() => []);
3835
+ tail.forEach(deliver);
3836
+ this.eventHandler.removeFlowEventListener(subscriptionId);
3837
+ close(true);
3838
+ }
3839
+ }
3840
+ void done.then(() => this.eventHandler.removeFlowEventListener(subscriptionId));
3841
+ return {
3842
+ get lastSeq() {
3843
+ return last;
3844
+ },
3845
+ done,
3846
+ unsubscribe,
3847
+ [Symbol.asyncIterator]() {
3848
+ return {
3849
+ next: () => {
3850
+ const ev = buffer.shift();
3851
+ if (ev) return Promise.resolve({ value: ev, done: false });
3852
+ if (closed) return Promise.resolve({ value: void 0, done: true });
3853
+ return new Promise((r) => waiters.push(r));
3854
+ },
3855
+ return: async () => {
3856
+ await unsubscribe();
3857
+ return { value: void 0, done: true };
3858
+ }
3859
+ };
3860
+ }
3861
+ };
3862
+ }
3863
+ };
3864
+
3440
3865
  // src/functions-api.ts
3441
3866
  var FunctionsApi = class {
3442
3867
  constructor(repository, context, sendRequest) {
@@ -5615,6 +6040,16 @@ var Database = class _Database {
5615
6040
  }
5616
6041
  return this._flowsApi;
5617
6042
  }
6043
+ /**
6044
+ * Durable agent runs over this WebSocket connection: find a subject's run,
6045
+ * follow it live (gap-free, resumable), control it, list its children.
6046
+ */
6047
+ runs() {
6048
+ if (!this._runsApi) {
6049
+ this._runsApi = new AgentRunsWsApi(this._context, this.sendRequest, this.eventHandler);
6050
+ }
6051
+ return this._runsApi;
6052
+ }
5618
6053
  /**
5619
6054
  * Get FunctionsApi for invoking server-side functions via WebSocket
5620
6055
  */
@@ -7351,6 +7786,82 @@ function readTokensFromFragment(hashOrUrl) {
7351
7786
  return { accessToken, refreshToken: params.get("refresh_token") };
7352
7787
  }
7353
7788
 
7789
+ // src/node-dev.ts
7790
+ var NodeDevApi = class {
7791
+ constructor(repository, transport) {
7792
+ this.repository = repository;
7793
+ this.transport = transport;
7794
+ }
7795
+ /** Call any method by name (the typed helpers below all use this). */
7796
+ call(method, request) {
7797
+ const branch = typeof request.branch === "string" ? `?branch=${encodeURIComponent(request.branch)}` : "";
7798
+ return this.transport.request(
7799
+ "POST",
7800
+ `/api/node-dev/${encodeURIComponent(this.repository)}/${method}${branch}`,
7801
+ request
7802
+ );
7803
+ }
7804
+ changeset(o) {
7805
+ const { idempotencyKey, ...rest } = o;
7806
+ return { ...rest, idempotency_key: idempotencyKey };
7807
+ }
7808
+ stat(target, o = {}) {
7809
+ return this.call("stat", { ...o, target });
7810
+ }
7811
+ read(target, o = {}) {
7812
+ return this.call("read", { ...o, target });
7813
+ }
7814
+ list(target, o = {}) {
7815
+ return this.call("list", { ...o, target });
7816
+ }
7817
+ diff(target, from, to, o = {}) {
7818
+ return this.call("diff", { ...o, target, from, to });
7819
+ }
7820
+ /** Changes inside the roots after `since` (a cursor from a previous call). */
7821
+ watch(since, o = {}) {
7822
+ return this.call("watch", { ...o, since });
7823
+ }
7824
+ dryRun(o) {
7825
+ return this.call("dry_run", this.changeset(o));
7826
+ }
7827
+ propose(o) {
7828
+ return this.call(
7829
+ "propose",
7830
+ this.changeset(o)
7831
+ );
7832
+ }
7833
+ getChangeset(changesetId, o = {}) {
7834
+ return this.call("get_changeset", { ...o, changeset_id: changesetId });
7835
+ }
7836
+ listChangesets(o = {}) {
7837
+ return this.call("list_changesets", { ...o });
7838
+ }
7839
+ /** Commit; pass the reviewed digest to bind the commit to that approval. */
7840
+ commit(changesetId, expectedDigest, o = {}) {
7841
+ return this.call("commit", { ...o, changeset_id: changesetId, expected_digest: expectedDigest });
7842
+ }
7843
+ discard(changesetId, o = {}) {
7844
+ return this.call("discard", { ...o, changeset_id: changesetId });
7845
+ }
7846
+ /** Propose and commit in one call. */
7847
+ apply(o) {
7848
+ return this.call("apply", this.changeset(o));
7849
+ }
7850
+ forkBranch(name, o = {}) {
7851
+ return this.call("fork_branch", { ...o, name });
7852
+ }
7853
+ diffBranch(base = "main", o = {}) {
7854
+ return this.call("diff_branch", { ...o, base });
7855
+ }
7856
+ mergeBranch(target, o = {}) {
7857
+ const { dryRun, ...rest } = o;
7858
+ return this.call("merge_branch", { ...rest, target, dry_run: dryRun });
7859
+ }
7860
+ discardBranch(o = {}) {
7861
+ return this.call("discard_branch", { ...o });
7862
+ }
7863
+ };
7864
+
7354
7865
  // src/http-client.ts
7355
7866
  var RaisinHttpClient = class extends import_events3.EventEmitter {
7356
7867
  constructor(baseUrl, options = {}) {
@@ -8076,6 +8587,33 @@ var RaisinHttpClient = class extends import_events3.EventEmitter {
8076
8587
  * @param input - Input data passed to the function
8077
8588
  * @returns Execution ID and job ID for tracking
8078
8589
  */
8590
+ /**
8591
+ * Durable agent runs of `repository`: create, read, control, stream, and
8592
+ * drive them directly (see {@link AgentRunsApi}).
8593
+ */
8594
+ agentRuns(repository) {
8595
+ return new AgentRunsApi(repository, {
8596
+ request: async (method, path, body) => (await this.request({ method, path, body })).data,
8597
+ url: (path) => `${this.baseUrl}${path}`,
8598
+ headers: () => {
8599
+ const token = this.authManager.getAccessToken();
8600
+ const headers = {};
8601
+ if (token) headers["Authorization"] = `Bearer ${token}`;
8602
+ return headers;
8603
+ },
8604
+ fetch: this.fetchImpl
8605
+ });
8606
+ }
8607
+ /**
8608
+ * The node-development surface of `repository`: typed reads, atomic
8609
+ * changesets with review and idempotency, branch worktrees (see
8610
+ * {@link NodeDevApi}).
8611
+ */
8612
+ nodeDev(repository) {
8613
+ return new NodeDevApi(repository, {
8614
+ request: async (method, path, body) => (await this.request({ method, path, body })).data
8615
+ });
8616
+ }
8079
8617
  async invokeFunction(repository, functionName, input, options) {
8080
8618
  const requestTimeoutMs = options?.requestTimeoutMs ?? this.options.requestTimeout;
8081
8619
  let waitTimeoutMs = options?.waitTimeoutMs;
@@ -8279,6 +8817,14 @@ var HttpDatabase = class _HttpDatabase {
8279
8817
  /**
8280
8818
  * Get FunctionsApi for invoking server-side functions via HTTP
8281
8819
  */
8820
+ /** Durable agent runs of this repository. */
8821
+ agentRuns() {
8822
+ return this.client.agentRuns(this.repository);
8823
+ }
8824
+ /** The node-development surface of this repository. */
8825
+ nodeDev() {
8826
+ return this.client.nodeDev(this.repository);
8827
+ }
8282
8828
  functions() {
8283
8829
  return new HttpFunctionsApi(
8284
8830
  this.repository,
@@ -12727,6 +13273,8 @@ function createRaisinVue(vue) {
12727
13273
  }
12728
13274
  // Annotate the CommonJS export names for ESM import in node:
12729
13275
  0 && (module.exports = {
13276
+ AgentRunsApi,
13277
+ AgentRunsWsApi,
12730
13278
  AllNodeEventTypes,
12731
13279
  Archetypes,
12732
13280
  AuthManager,
@@ -12767,6 +13315,7 @@ function createRaisinVue(vue) {
12767
13315
  McpClient,
12768
13316
  MemoryTokenStorage,
12769
13317
  NodeBuilder,
13318
+ NodeDevApi,
12770
13319
  NodeEventType,
12771
13320
  NodeFileSource,
12772
13321
  NodeHelpers,
@@ -12834,12 +13383,14 @@ function createRaisinVue(vue) {
12834
13383
  isTerminalEvent,
12835
13384
  isWebSocketClient,
12836
13385
  logger,
13386
+ newControlId,
12837
13387
  normalizeHomePath,
12838
13388
  projectPlansFromMessages,
12839
13389
  readTokensFromFragment,
12840
13390
  rowsToObjects,
12841
13391
  setLogLevel,
12842
13392
  sleep,
13393
+ subjectOf,
12843
13394
  useConversation,
12844
13395
  useConversationList,
12845
13396
  useFlow,