runpane 2.4.104 → 2.4.106

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.
@@ -6,6 +6,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.runReposList = runReposList;
7
7
  exports.runReposAdd = runReposAdd;
8
8
  exports.runPanesList = runPanesList;
9
+ exports.runSessionsList = runSessionsList;
10
+ exports.runSessionsCreate = runSessionsCreate;
11
+ exports.runSessionsGet = runSessionsGet;
12
+ exports.runSessionsUpdate = runSessionsUpdate;
13
+ exports.runSessionsSetAgent = runSessionsSetAgent;
14
+ exports.runSessionsAssociate = runSessionsAssociate;
15
+ exports.runSessionsDetach = runSessionsDetach;
16
+ exports.runSessionsOverview = runSessionsOverview;
9
17
  exports.runPanesCost = runPanesCost;
10
18
  exports.runWorkspaceState = runWorkspaceState;
11
19
  exports.runWatch = runWatch;
@@ -29,6 +37,7 @@ const promises_1 = require("node:readline/promises");
29
37
  const boundaryDecoder_1 = require("./boundaryDecoder");
30
38
  const daemonClient_1 = require("./daemonClient");
31
39
  const contract_1 = require("./generated/contract");
40
+ const commands_1 = require("./commands");
32
41
  const watchLines_1 = require("./watchLines");
33
42
  const agentSchema = boundaryDecoder_1.boundary.enumeration(...contract_1.RUNPANE_CONTRACT.enums.agents);
34
43
  const repoSummarySchema = boundaryDecoder_1.boundary.object({
@@ -148,6 +157,123 @@ const paneListResultSchema = boundaryDecoder_1.boundary.object({
148
157
  repo: boundaryDecoder_1.boundary.optional(repoSummarySchema),
149
158
  panes: boundaryDecoder_1.boundary.array(paneSummarySchema),
150
159
  });
160
+ const orchestrationLinkSchema = boundaryDecoder_1.boundary.object({
161
+ label: boundaryDecoder_1.boundary.nonEmptyString,
162
+ url: boundaryDecoder_1.boundary.nonEmptyString,
163
+ kind: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('evidence', 'output', 'ticket', 'pull-request', 'other')),
164
+ provenance: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
165
+ addedAt: boundaryDecoder_1.boundary.nonEmptyString,
166
+ });
167
+ const orchestrationReportSchema = boundaryDecoder_1.boundary.object({
168
+ summary: boundaryDecoder_1.boundary.nonEmptyString,
169
+ status: boundaryDecoder_1.boundary.enumeration('reported', 'verified'),
170
+ evidence: boundaryDecoder_1.boundary.array(orchestrationLinkSchema),
171
+ reportedAt: boundaryDecoder_1.boundary.nonEmptyString,
172
+ provenance: boundaryDecoder_1.boundary.nonEmptyString,
173
+ });
174
+ const orchestrationAssociationSchema = boundaryDecoder_1.boundary.object({
175
+ paneId: boundaryDecoder_1.boundary.nonEmptyString,
176
+ panelIds: boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.nonEmptyString),
177
+ attachedAt: boundaryDecoder_1.boundary.nonEmptyString,
178
+ });
179
+ const orchestrationActivitySchema = boundaryDecoder_1.boundary.object({
180
+ id: boundaryDecoder_1.boundary.nonEmptyString,
181
+ kind: boundaryDecoder_1.boundary.enumeration('created', 'updated', 'associated', 'detached', 'working', 'blocked', 'idle', 'unknown', 'report'),
182
+ message: boundaryDecoder_1.boundary.string,
183
+ at: boundaryDecoder_1.boundary.nonEmptyString,
184
+ source: boundaryDecoder_1.boundary.enumeration('user', 'agent', 'system'),
185
+ paneId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
186
+ panelId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
187
+ });
188
+ const orchestrationSessionRecordSchema = boundaryDecoder_1.boundary.object({
189
+ id: boundaryDecoder_1.boundary.nonEmptyString,
190
+ name: boundaryDecoder_1.boundary.nonEmptyString,
191
+ archived: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
192
+ isPinned: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
193
+ agent: agentSchema,
194
+ internalSessionId: boundaryDecoder_1.boundary.nonEmptyString,
195
+ panelIds: boundaryDecoder_1.boundary.object({
196
+ claude: boundaryDecoder_1.boundary.nonEmptyString,
197
+ codex: boundaryDecoder_1.boundary.nonEmptyString,
198
+ cursor: boundaryDecoder_1.boundary.nonEmptyString,
199
+ }),
200
+ goal: boundaryDecoder_1.boundary.string,
201
+ context: boundaryDecoder_1.boundary.string,
202
+ decisions: boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string),
203
+ blockers: boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string),
204
+ nextAction: boundaryDecoder_1.boundary.string,
205
+ evidence: boundaryDecoder_1.boundary.array(orchestrationLinkSchema),
206
+ outputs: boundaryDecoder_1.boundary.array(orchestrationLinkSchema),
207
+ associations: boundaryDecoder_1.boundary.array(orchestrationAssociationSchema),
208
+ activity: boundaryDecoder_1.boundary.array(orchestrationActivitySchema),
209
+ report: boundaryDecoder_1.boundary.optional(orchestrationReportSchema),
210
+ reportActivityId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
211
+ reportAcceptedAt: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
212
+ revision: boundaryDecoder_1.boundary.number,
213
+ createdAt: boundaryDecoder_1.boundary.nonEmptyString,
214
+ updatedAt: boundaryDecoder_1.boundary.nonEmptyString,
215
+ });
216
+ const runpaneSessionListResultSchema = boundaryDecoder_1.boundary.object({
217
+ ok: boundaryDecoder_1.boundary.literal(true),
218
+ sessions: boundaryDecoder_1.boundary.array(orchestrationSessionRecordSchema),
219
+ selectedSessionId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
220
+ });
221
+ const runpaneSessionResultSchema = boundaryDecoder_1.boundary.object({
222
+ ok: boundaryDecoder_1.boundary.literal(true),
223
+ session: orchestrationSessionRecordSchema,
224
+ panelId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
225
+ internalSessionId: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
226
+ });
227
+ const orchestrationPanelOverviewSchema = boundaryDecoder_1.boundary.object({
228
+ panelId: boundaryDecoder_1.boundary.nonEmptyString,
229
+ title: boundaryDecoder_1.boundary.string,
230
+ agentType: boundaryDecoder_1.boundary.optional(agentSchema),
231
+ state: boundaryDecoder_1.boundary.enumeration('blocked', 'working', 'idle', 'unknown'),
232
+ initialized: boundaryDecoder_1.boundary.boolean,
233
+ lastActivityAt: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nonEmptyString),
234
+ missing: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
235
+ });
236
+ const orchestrationPaneOverviewSchema = boundaryDecoder_1.boundary.object({
237
+ paneId: boundaryDecoder_1.boundary.nonEmptyString,
238
+ name: boundaryDecoder_1.boundary.string,
239
+ worktreePath: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
240
+ branch: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
241
+ archived: boundaryDecoder_1.boundary.boolean,
242
+ missing: boundaryDecoder_1.boundary.boolean,
243
+ panels: boundaryDecoder_1.boundary.array(orchestrationPanelOverviewSchema),
244
+ git: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.object({
245
+ state: boundaryDecoder_1.boundary.string,
246
+ ahead: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.number),
247
+ behind: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.number),
248
+ hasUncommittedChanges: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
249
+ hasUntrackedFiles: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
250
+ prNumber: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.number),
251
+ prUrl: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
252
+ prTitle: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
253
+ prState: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
254
+ })),
255
+ });
256
+ const runpaneSessionOverviewResultSchema = boundaryDecoder_1.boundary.object({
257
+ ok: boundaryDecoder_1.boundary.literal(true),
258
+ session: orchestrationSessionRecordSchema,
259
+ status: boundaryDecoder_1.boundary.enumeration('working', 'blocked', 'idle', 'unknown', 'unassociated'),
260
+ panes: boundaryDecoder_1.boundary.array(orchestrationPaneOverviewSchema),
261
+ activity: boundaryDecoder_1.boundary.array(orchestrationActivitySchema),
262
+ report: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.object({
263
+ ...orchestrationReportSchemaFields(),
264
+ freshness: boundaryDecoder_1.boundary.enumeration('current', 'stale'),
265
+ })),
266
+ refreshedAt: boundaryDecoder_1.boundary.nonEmptyString,
267
+ });
268
+ function orchestrationReportSchemaFields() {
269
+ return {
270
+ summary: boundaryDecoder_1.boundary.nonEmptyString,
271
+ status: boundaryDecoder_1.boundary.enumeration('reported', 'verified'),
272
+ evidence: boundaryDecoder_1.boundary.array(orchestrationLinkSchema),
273
+ reportedAt: boundaryDecoder_1.boundary.nonEmptyString,
274
+ provenance: boundaryDecoder_1.boundary.nonEmptyString,
275
+ };
276
+ }
151
277
  const usageTotalsResultSchema = boundaryDecoder_1.boundary.object({
152
278
  inputTokens: boundaryDecoder_1.boundary.number,
153
279
  outputTokens: boundaryDecoder_1.boundary.number,
@@ -554,6 +680,135 @@ async function runPanesList(parsed) {
554
680
  printPaneListResult(result);
555
681
  return 0;
556
682
  }
683
+ async function runSessionsList(parsed) {
684
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:list', [], runpaneSessionListResultSchema, {
685
+ paneDir: parsed.paneDir,
686
+ });
687
+ if (parsed.json) {
688
+ printJson(result);
689
+ return 0;
690
+ }
691
+ for (const session of result.sessions) {
692
+ console.log(`${session.id}\t${session.name}\t${session.agent}\t${session.associations.length} Pane(s)`);
693
+ }
694
+ if (result.sessions.length === 0)
695
+ console.log('No named Sessions.');
696
+ return 0;
697
+ }
698
+ async function runSessionsCreate(parsed) {
699
+ if (!parsed.fromJson)
700
+ throw new Error('runpane sessions create requires --from-json <path|->.');
701
+ const input = parseSessionCreatePayload(JSON.parse(stripUtf8Bom(readInputSource(parsed.fromJson))));
702
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:create', [input], runpaneSessionResultSchema, {
703
+ paneDir: parsed.paneDir,
704
+ });
705
+ return printSessionResult(result, parsed.json, 'Created');
706
+ }
707
+ async function runSessionsGet(parsed) {
708
+ const selector = sessionSelectorFromParsed(parsed);
709
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:get', [selector], runpaneSessionResultSchema, {
710
+ paneDir: parsed.paneDir,
711
+ });
712
+ return printSessionResult(result, parsed.json, '');
713
+ }
714
+ async function runSessionsUpdate(parsed) {
715
+ if (!parsed.fromJson)
716
+ throw new Error('runpane sessions update requires --from-json <path|->.');
717
+ const input = parseSessionUpdatePayload(JSON.parse(stripUtf8Bom(readInputSource(parsed.fromJson))));
718
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:update', [{ selector: sessionSelectorFromParsed(parsed), input }], runpaneSessionResultSchema, {
719
+ paneDir: parsed.paneDir,
720
+ });
721
+ return printSessionResult(result, parsed.json, 'Updated');
722
+ }
723
+ async function runSessionsSetAgent(parsed) {
724
+ const selector = sessionSelectorFromParsed(parsed);
725
+ if (!parsed.agent)
726
+ throw new Error('runpane sessions set-agent requires --agent.');
727
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:set-agent', [{ selector, agent: parsed.agent }], runpaneSessionResultSchema, {
728
+ paneDir: parsed.paneDir,
729
+ });
730
+ return printSessionResult(result, parsed.json, 'Updated agent for');
731
+ }
732
+ async function runSessionsAssociate(parsed) {
733
+ const selector = sessionSelectorFromParsed(parsed);
734
+ if (!parsed.paneId)
735
+ throw new Error('runpane sessions associate requires --pane.');
736
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:associate', [{ selector, association: {
737
+ paneId: parsed.paneId,
738
+ panelIds: parsed.panelId ? [parsed.panelId] : undefined,
739
+ } }], runpaneSessionResultSchema, { paneDir: parsed.paneDir });
740
+ return printSessionResult(result, parsed.json, 'Associated');
741
+ }
742
+ async function runSessionsDetach(parsed) {
743
+ const selector = sessionSelectorFromParsed(parsed);
744
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:detach', [{ selector, paneId: parsed.paneId }], runpaneSessionResultSchema, {
745
+ paneDir: parsed.paneDir,
746
+ });
747
+ return printSessionResult(result, parsed.json, 'Detached');
748
+ }
749
+ async function runSessionsOverview(parsed) {
750
+ const result = await (0, daemonClient_1.invokeDaemon)('runpane:sessions:overview', [sessionSelectorFromParsed(parsed)], runpaneSessionOverviewResultSchema, {
751
+ paneDir: parsed.paneDir,
752
+ });
753
+ if (parsed.json) {
754
+ printJson(result);
755
+ return 0;
756
+ }
757
+ console.log(`${result.session.name}: ${result.status}`);
758
+ for (const pane of result.panes) {
759
+ const details = pane.missing ? 'missing' : pane.archived ? 'archived' : pane.panels.map(panel => `${panel.title}=${panel.state}`).join(', ') || 'no terminal panels';
760
+ console.log(` ${pane.name}: ${details}`);
761
+ }
762
+ return 0;
763
+ }
764
+ function sessionSelectorFromParsed(parsed) {
765
+ const sessionId = parsed.sessionId?.trim();
766
+ if (!sessionId)
767
+ throw new Error('Named Session id or name is required via --session.');
768
+ return { sessionId };
769
+ }
770
+ function parseSessionCreatePayload(value) {
771
+ return (0, boundaryDecoder_1.decodeBoundary)(value, boundaryDecoder_1.boundary.object({
772
+ name: boundaryDecoder_1.boundary.nonEmptyString,
773
+ agent: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('codex', 'claude', 'cursor')),
774
+ goal: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
775
+ context: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
776
+ decisions: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
777
+ blockers: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
778
+ nextAction: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
779
+ evidence: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(orchestrationLinkSchema)),
780
+ outputs: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(orchestrationLinkSchema)),
781
+ }));
782
+ }
783
+ function parseSessionUpdatePayload(value) {
784
+ return (0, boundaryDecoder_1.decodeBoundary)(value, boundaryDecoder_1.boundary.object({
785
+ name: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
786
+ archived: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
787
+ isPinned: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.boolean),
788
+ agent: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('codex', 'claude', 'cursor')),
789
+ goal: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
790
+ context: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
791
+ decisions: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
792
+ blockers: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(boundaryDecoder_1.boundary.string)),
793
+ nextAction: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.string),
794
+ evidence: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(orchestrationLinkSchema)),
795
+ outputs: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.array(orchestrationLinkSchema)),
796
+ report: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.nullable(orchestrationReportSchema)),
797
+ expectedRevision: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.number),
798
+ source: boundaryDecoder_1.boundary.optional(boundaryDecoder_1.boundary.enumeration('user', 'agent')),
799
+ }));
800
+ }
801
+ function printSessionResult(result, json, action) {
802
+ if (json) {
803
+ printJson(result);
804
+ return 0;
805
+ }
806
+ const prefix = action ? `${action} ` : '';
807
+ console.log(`${prefix}${result.session.name} (${result.session.id})`);
808
+ if (result.panelId)
809
+ console.log(` panel: ${result.panelId}`);
810
+ return 0;
811
+ }
557
812
  async function runPanesCost(parsed) {
558
813
  const result = await (0, daemonClient_1.invokeDaemon)('runpane:panes:cost', [{
559
814
  repo: parsed.repo,
@@ -597,7 +852,10 @@ async function runWatch(parsed) {
597
852
  const includeHeldInput = parsed.includeHeldInput && !parsed.noHeldInput ? true : undefined;
598
853
  const includeHeldInputPresence = defaults.includeHeldInputPresence
599
854
  && !parsed.noHeldInput && parsed.follow && format === 'lines' ? true : undefined;
600
- const watchAs = parsed.watchAs ?? (parsed.follow ? process.env.PANE_PANEL_ID : undefined);
855
+ const cadenceValueFlagPresent = (0, commands_1.hasCadenceValueFlag)(parsed);
856
+ // Cadence state lives in the daemon per named consumer, so an anonymous follower names itself.
857
+ const watchAs = parsed.watchAs
858
+ ?? (parsed.follow ? process.env.PANE_PANEL_ID || (cadenceValueFlagPresent ? `follow-${process.pid}` : undefined) : undefined);
601
859
  const request = {
602
860
  as: watchAs,
603
861
  since: parsed.watchSince,
@@ -614,6 +872,10 @@ async function runWatch(parsed) {
614
872
  includeHeldInput,
615
873
  includeHeldInputPresence,
616
874
  idleAfterMs,
875
+ settleMs: parsed.settleMs,
876
+ blockedSettleMs: parsed.blockedSettleMs,
877
+ minIntervalMs: parsed.minIntervalMs,
878
+ idleBackoff: parsed.idleBackoff || undefined,
617
879
  };
618
880
  let armed = false;
619
881
  let failingCode;