happy-imou-cloud 2.0.21 → 2.0.23

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 (29) hide show
  1. package/dist/{BaseReasoningProcessor-0nj-PMFc.cjs → BaseReasoningProcessor-BzbDRBqp.cjs} +3 -3
  2. package/dist/{BaseReasoningProcessor-DnVC7liC.mjs → BaseReasoningProcessor-DH3BCCTf.mjs} +3 -3
  3. package/dist/ProviderSelectionHandler-CbkbtIRC.mjs +673 -0
  4. package/dist/ProviderSelectionHandler-meVvz9NZ.cjs +680 -0
  5. package/dist/{api-MGlKcEf3.cjs → api-C4bF6GEA.cjs} +35 -3
  6. package/dist/{api-DJe9WP9M.mjs → api-DX7Vg4Hz.mjs} +35 -4
  7. package/dist/{command-DAlFmWmr.cjs → command-CF6Wi_v2.cjs} +3 -3
  8. package/dist/{command-CfyFnMv2.mjs → command-DicPZ-Up.mjs} +3 -3
  9. package/dist/{index-CgVjDJpt.cjs → index-BybqdOf2.cjs} +63 -15
  10. package/dist/{index-CHXCgpwi.mjs → index-CEJmASSW.mjs} +60 -12
  11. package/dist/index.cjs +3 -3
  12. package/dist/index.mjs +3 -3
  13. package/dist/lib.cjs +1 -1
  14. package/dist/lib.d.cts +108 -105
  15. package/dist/lib.d.mts +108 -105
  16. package/dist/lib.mjs +1 -1
  17. package/dist/{persistence-DLFUNI9q.cjs → persistence-CdqBfAwo.cjs} +1 -1
  18. package/dist/{persistence-CkP90vEt.mjs → persistence-xypxp7ei.mjs} +1 -1
  19. package/dist/{registerKillSessionHandler-Cs_INk4A.cjs → registerKillSessionHandler-BK3fZIch.cjs} +14 -364
  20. package/dist/{registerKillSessionHandler-DsHTZDsU.mjs → registerKillSessionHandler-BNN-_qNu.mjs} +15 -362
  21. package/dist/{runClaude-DAQAEmHe.mjs → runClaude-B-ex_tr3.mjs} +8 -6
  22. package/dist/{runClaude-BGSgcyUp.cjs → runClaude-CT3jCZjH.cjs} +11 -9
  23. package/dist/{runCodex-B2UpSn82.mjs → runCodex-DhbvUtJC.mjs} +9 -7
  24. package/dist/{runCodex-earICaxw.cjs → runCodex-DodH9jhh.cjs} +12 -10
  25. package/dist/{runGemini-BBUmH1Qh.mjs → runGemini-BsFR5Pd3.mjs} +12 -74
  26. package/dist/{runGemini-D5RAIaR0.cjs → runGemini-CeHCZ1l4.cjs} +12 -74
  27. package/package.json +1 -1
  28. package/dist/ProviderSelectionHandler-Bafuy28L.cjs +0 -265
  29. package/dist/ProviderSelectionHandler-R-2r7ItM.mjs +0 -261
@@ -1,8 +1,8 @@
1
- import { i as initialMachineMetadata, e as projectPath, R as RuntimeShell, h as resolveCanonicalToolNameV2, f as formatDisplayMessage } from './index-CHXCgpwi.mjs';
2
- import { readSettings } from './persistence-CkP90vEt.mjs';
1
+ import { i as initialMachineMetadata, e as projectPath, R as RuntimeShell, h as resolveCanonicalToolNameV2, f as formatDisplayMessage } from './index-CEJmASSW.mjs';
2
+ import { readSettings } from './persistence-xypxp7ei.mjs';
3
3
  import os from 'node:os';
4
4
  import { resolve } from 'node:path';
5
- import { c as configuration, p as packageJson, H as HAPPY_ORG_TURN_REPORT_TAG, d as HAPPY_ORG_REPEAT_THRESHOLD, l as logger } from './api-DJe9WP9M.mjs';
5
+ import { c as configuration, p as packageJson, l as logger } from './api-DX7Vg4Hz.mjs';
6
6
  import { randomUUID } from 'node:crypto';
7
7
  import { createHash } from 'crypto';
8
8
  import 'axios';
@@ -259,15 +259,18 @@ async function closeProviderSession(session, opts = {}) {
259
259
  firstError = error;
260
260
  }
261
261
  };
262
- if (opts.archiveReason) {
262
+ if (opts.archiveOnClose || opts.archiveReason) {
263
263
  try {
264
- session.updateMetadata((currentMetadata) => ({
265
- ...currentMetadata,
266
- lifecycleState: "archived",
267
- lifecycleStateSince: Date.now(),
268
- archivedBy: opts.archivedBy ?? "cli",
269
- archiveReason: opts.archiveReason
270
- }));
264
+ session.updateMetadata((currentMetadata) => {
265
+ const { archiveReason: _existingArchiveReason, ...metadataWithoutArchiveReason } = currentMetadata;
266
+ return {
267
+ ...metadataWithoutArchiveReason,
268
+ lifecycleState: "archived",
269
+ lifecycleStateSince: Date.now(),
270
+ archivedBy: opts.archivedBy ?? "cli",
271
+ ...opts.archiveReason ? { archiveReason: opts.archiveReason } : {}
272
+ };
273
+ });
271
274
  } catch (error) {
272
275
  captureError(error);
273
276
  }
@@ -351,356 +354,6 @@ async function syncControlledByUserState(sessionClient, controlledByUser) {
351
354
  });
352
355
  }
353
356
 
354
- function normalizeOptionalText(value) {
355
- if (typeof value !== "string") {
356
- return null;
357
- }
358
- const trimmed = value.trim();
359
- return trimmed.length > 0 ? trimmed : null;
360
- }
361
- function cloneHappyOrgMetadata(happyOrg) {
362
- return {
363
- taskContext: happyOrg?.taskContext ? { ...happyOrg.taskContext } : void 0,
364
- runtime: happyOrg?.runtime ? { ...happyOrg.runtime } : void 0,
365
- activeOwner: happyOrg?.activeOwner ? { ...happyOrg.activeOwner } : null,
366
- repeat: happyOrg?.repeat ? {
367
- threshold: happyOrg.repeat.threshold,
368
- fingerprints: Object.fromEntries(
369
- Object.entries(happyOrg.repeat.fingerprints ?? {}).map(([fingerprint, entry]) => [
370
- fingerprint,
371
- { ...entry }
372
- ])
373
- )
374
- } : void 0,
375
- lastTurnReport: happyOrg?.lastTurnReport ? { ...happyOrg.lastTurnReport } : void 0
376
- };
377
- }
378
- function normalizeHappyOrgMetadata(metadata) {
379
- const happyOrg = cloneHappyOrgMetadata(metadata?.happyOrg);
380
- return {
381
- ...happyOrg,
382
- runtime: happyOrg.runtime ?? {
383
- status: "active",
384
- reason: null
385
- },
386
- repeat: happyOrg.repeat ?? {
387
- threshold: HAPPY_ORG_REPEAT_THRESHOLD,
388
- fingerprints: {}
389
- }
390
- };
391
- }
392
- function withHappyOrgMetadata(metadata, happyOrg) {
393
- return {
394
- ...metadata,
395
- happyOrg
396
- };
397
- }
398
- function resetHappyOrgRuntimeForTask(taskContext) {
399
- return {
400
- taskContext,
401
- runtime: {
402
- status: "active",
403
- reason: null
404
- },
405
- activeOwner: null,
406
- repeat: {
407
- threshold: HAPPY_ORG_REPEAT_THRESHOLD,
408
- fingerprints: {}
409
- }
410
- };
411
- }
412
- function buildTerminatedStatusMessage(taskId) {
413
- return `Task ${taskId} is terminated. Reopen it with new context, a new decision, or a new resource before continuing.`;
414
- }
415
- function buildOwnerConflictStatusMessage(taskId, ownerAgentId) {
416
- return `Task ${taskId} is already active under owner ${ownerAgentId}. This turn must exit without continuing token usage.`;
417
- }
418
- function inferInterventionType(draft) {
419
- if (draft?.interventionType === "none" || draft?.interventionType === "review_needed" || draft?.interventionType === "blocker" || draft?.interventionType === "decision_needed") {
420
- return draft.interventionType;
421
- }
422
- if (normalizeOptionalText(draft?.decisionNeeded)) {
423
- return "decision_needed";
424
- }
425
- if (normalizeOptionalText(draft?.blockerCode)) {
426
- return "blocker";
427
- }
428
- return "none";
429
- }
430
- function buildFallbackSummary(text, turnStatus) {
431
- const trimmed = text.trim();
432
- if (trimmed) {
433
- return trimmed.replace(/\s+/g, " ").slice(0, 160);
434
- }
435
- return turnStatus === "turn_aborted" ? "Turn aborted before completion." : "Turn completed without a textual summary.";
436
- }
437
- function normalizeTurnReportDraft(draft) {
438
- return {
439
- summary: normalizeOptionalText(draft?.summary)?.replace(/\s+/g, " ").slice(0, 160) ?? null,
440
- interventionType: inferInterventionType(draft),
441
- blockerCode: normalizeOptionalText(draft?.blockerCode),
442
- decisionNeeded: normalizeOptionalText(draft?.decisionNeeded),
443
- targetArtifact: normalizeOptionalText(draft?.targetArtifact)
444
- };
445
- }
446
- function stripCodeFence(text) {
447
- return text.replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/i, "").trim();
448
- }
449
- function extractTaggedTurnReport(text) {
450
- const matcher = new RegExp(
451
- `<${HAPPY_ORG_TURN_REPORT_TAG}>\\s*([\\s\\S]*?)\\s*</${HAPPY_ORG_TURN_REPORT_TAG}>`,
452
- "gi"
453
- );
454
- let lastMatch = null;
455
- for (let match = matcher.exec(text); match; match = matcher.exec(text)) {
456
- lastMatch = match;
457
- }
458
- if (!lastMatch) {
459
- return {
460
- cleanedText: text.trim(),
461
- draft: null
462
- };
463
- }
464
- const rawBlock = stripCodeFence(lastMatch[1] ?? "");
465
- let draft = null;
466
- try {
467
- const parsed = JSON.parse(rawBlock);
468
- draft = {
469
- summary: normalizeOptionalText(parsed.summary),
470
- interventionType: normalizeOptionalText(parsed.interventionType),
471
- blockerCode: normalizeOptionalText(parsed.blockerCode),
472
- decisionNeeded: normalizeOptionalText(parsed.decisionNeeded),
473
- targetArtifact: normalizeOptionalText(parsed.targetArtifact)
474
- };
475
- } catch {
476
- draft = null;
477
- }
478
- const cleanedText = `${text.slice(0, lastMatch.index)}${text.slice(lastMatch.index + lastMatch[0].length)}`.replace(/\n{3,}/g, "\n\n").trim();
479
- return {
480
- cleanedText,
481
- draft
482
- };
483
- }
484
- function buildRepeatFingerprint(context, blockerCode, targetArtifact) {
485
- if (!blockerCode) {
486
- return null;
487
- }
488
- return [
489
- context.taskId,
490
- context.memberAgentId,
491
- blockerCode,
492
- targetArtifact ?? ""
493
- ].join("::");
494
- }
495
- function buildHappyOrgTurnPrompt(prompt, turn) {
496
- const reopenLines = turn.reopenContext ? [
497
- "",
498
- "This task was explicitly reopened for this turn with the following new inputs:",
499
- turn.reopenContext.newContext ? `- newContext: ${turn.reopenContext.newContext}` : null,
500
- turn.reopenContext.newDecision ? `- newDecision: ${turn.reopenContext.newDecision}` : null,
501
- turn.reopenContext.newResource ? `- newResource: ${turn.reopenContext.newResource}` : null
502
- ].filter(Boolean) : [];
503
- const header = [
504
- "[HAPPY_ORG_TASK_CONTEXT]",
505
- `taskId=${turn.context.taskId}`,
506
- `organizationId=${turn.context.organizationId}`,
507
- `memberAgentId=${turn.context.memberAgentId}`,
508
- `supervisorAgentId=${turn.context.supervisorAgentId}`,
509
- "Stay on this exact task for the whole turn.",
510
- "End your response with exactly one raw JSON block inside these tags and do not wrap it in a markdown code fence:",
511
- `<${HAPPY_ORG_TURN_REPORT_TAG}>{"summary":"short factual summary","interventionType":"none","blockerCode":null,"decisionNeeded":null,"targetArtifact":null}</${HAPPY_ORG_TURN_REPORT_TAG}>`,
512
- "Allowed interventionType values: none, review_needed, blocker, decision_needed.",
513
- "summary must read like a CEO todo card title: short, actionable, and without long process logs.",
514
- "Use blocker only for problems the organization may still solve internally.",
515
- "Use decision_needed only when a CEO or user decision is required.",
516
- "Use review_needed when supervisor review is needed but the work is not blocked.",
517
- ...reopenLines,
518
- "[/HAPPY_ORG_TASK_CONTEXT]",
519
- "",
520
- prompt
521
- ];
522
- return header.join("\n");
523
- }
524
- function resolveHappyOrgQueuedTurn(opts) {
525
- const metadata = opts.metadata ?? null;
526
- if (!metadata) {
527
- return {
528
- nextMetadata: null,
529
- queuedTurn: null,
530
- blocked: false
531
- };
532
- }
533
- const currentHappyOrg = normalizeHappyOrgMetadata(metadata);
534
- let nextHappyOrg = cloneHappyOrgMetadata(currentHappyOrg);
535
- const messageHappyOrg = opts.message.meta?.happyOrg;
536
- const now = opts.now?.() ?? Date.now();
537
- const createRunId = opts.createRunId ?? ((taskContext2, currentNow) => `${taskContext2.taskId}:${taskContext2.memberAgentId}:${currentNow}`);
538
- if (messageHappyOrg?.taskContext) {
539
- const currentTaskId = currentHappyOrg.taskContext?.taskId ?? null;
540
- if (currentTaskId !== messageHappyOrg.taskContext.taskId) {
541
- nextHappyOrg = resetHappyOrgRuntimeForTask(messageHappyOrg.taskContext);
542
- } else {
543
- nextHappyOrg.taskContext = { ...messageHappyOrg.taskContext };
544
- }
545
- }
546
- const taskContext = nextHappyOrg.taskContext ?? null;
547
- if (!taskContext) {
548
- return {
549
- nextMetadata: metadata,
550
- queuedTurn: null,
551
- blocked: false
552
- };
553
- }
554
- const control = messageHappyOrg?.control;
555
- if (control?.action === "terminate") {
556
- nextHappyOrg.runtime = {
557
- status: "terminated",
558
- reason: normalizeOptionalText(control.reason) ?? "terminated_by_supervisor",
559
- terminatedAt: now
560
- };
561
- nextHappyOrg.activeOwner = null;
562
- return {
563
- nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
564
- queuedTurn: null,
565
- blocked: true,
566
- statusMessage: buildTerminatedStatusMessage(taskContext.taskId)
567
- };
568
- }
569
- const hasReopenInputs = Boolean(
570
- normalizeOptionalText(control?.newContext) || normalizeOptionalText(control?.newDecision) || normalizeOptionalText(control?.newResource)
571
- );
572
- if (nextHappyOrg.runtime?.status === "terminated") {
573
- if (control?.action !== "reopen") {
574
- return {
575
- nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
576
- queuedTurn: null,
577
- blocked: true,
578
- statusMessage: buildTerminatedStatusMessage(taskContext.taskId)
579
- };
580
- }
581
- if (!hasReopenInputs) {
582
- return {
583
- nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
584
- queuedTurn: null,
585
- blocked: true,
586
- statusMessage: `Task ${taskContext.taskId} can only reopen with new context, a new decision, or a new resource.`
587
- };
588
- }
589
- }
590
- const reopenContext = control?.action === "reopen" && hasReopenInputs ? {
591
- newContext: normalizeOptionalText(control.newContext),
592
- newDecision: normalizeOptionalText(control.newDecision),
593
- newResource: normalizeOptionalText(control.newResource)
594
- } : void 0;
595
- if (reopenContext) {
596
- nextHappyOrg.runtime = {
597
- status: "active",
598
- reason: null,
599
- reopenedAt: now
600
- };
601
- } else if (!nextHappyOrg.runtime) {
602
- nextHappyOrg.runtime = {
603
- status: "active",
604
- reason: null
605
- };
606
- }
607
- if (!nextHappyOrg.activeOwner) {
608
- nextHappyOrg.activeOwner = {
609
- ownerAgentId: taskContext.memberAgentId,
610
- ownerRunId: createRunId(taskContext, now),
611
- claimedAt: now
612
- };
613
- } else if (nextHappyOrg.activeOwner.ownerAgentId !== taskContext.memberAgentId) {
614
- return {
615
- nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
616
- queuedTurn: null,
617
- blocked: true,
618
- statusMessage: buildOwnerConflictStatusMessage(
619
- taskContext.taskId,
620
- nextHappyOrg.activeOwner.ownerAgentId
621
- )
622
- };
623
- }
624
- return {
625
- nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
626
- queuedTurn: {
627
- context: taskContext,
628
- ...reopenContext ? { reopenContext } : {}
629
- },
630
- blocked: false
631
- };
632
- }
633
- function finalizeHappyOrgTurn(opts) {
634
- const metadata = opts.metadata ?? null;
635
- const queuedTurn = opts.queuedTurn ?? null;
636
- const { cleanedText, draft } = extractTaggedTurnReport(opts.responseText);
637
- if (!metadata || !queuedTurn) {
638
- return {
639
- cleanedText,
640
- report: null,
641
- nextMetadata: metadata
642
- };
643
- }
644
- const now = opts.now?.() ?? Date.now();
645
- const normalizedDraft = normalizeTurnReportDraft(draft);
646
- const report = {
647
- ...queuedTurn.context,
648
- turnStatus: opts.turnStatus,
649
- interventionType: normalizedDraft.interventionType ?? "none",
650
- summary: normalizedDraft.summary ?? buildFallbackSummary(cleanedText, opts.turnStatus),
651
- blockerCode: normalizedDraft.blockerCode ?? null,
652
- decisionNeeded: normalizedDraft.decisionNeeded ?? null,
653
- targetArtifact: normalizedDraft.targetArtifact ?? null,
654
- repeatFingerprint: buildRepeatFingerprint(
655
- queuedTurn.context,
656
- normalizedDraft.blockerCode ?? null,
657
- normalizedDraft.targetArtifact ?? null
658
- )
659
- };
660
- const nextHappyOrg = normalizeHappyOrgMetadata(metadata);
661
- nextHappyOrg.taskContext = { ...queuedTurn.context };
662
- nextHappyOrg.lastTurnReport = report;
663
- nextHappyOrg.activeOwner = null;
664
- nextHappyOrg.repeat = nextHappyOrg.repeat ?? {
665
- threshold: HAPPY_ORG_REPEAT_THRESHOLD,
666
- fingerprints: {}
667
- };
668
- let terminateMessage;
669
- if (report.repeatFingerprint) {
670
- const currentEntry = nextHappyOrg.repeat.fingerprints[report.repeatFingerprint] ?? {
671
- count: 0};
672
- const nextCount = currentEntry.count + 1;
673
- nextHappyOrg.repeat.fingerprints[report.repeatFingerprint] = {
674
- count: nextCount,
675
- lastSeenAt: now
676
- };
677
- if (nextCount >= nextHappyOrg.repeat.threshold) {
678
- nextHappyOrg.runtime = {
679
- status: "terminated",
680
- reason: `repeat_fingerprint:${report.repeatFingerprint}`,
681
- terminatedAt: now
682
- };
683
- terminateMessage = `Task ${queuedTurn.context.taskId} hit repeat threshold for ${report.repeatFingerprint} and is now terminated until reopen.`;
684
- } else if (!nextHappyOrg.runtime || nextHappyOrg.runtime.status !== "terminated") {
685
- nextHappyOrg.runtime = {
686
- status: "active",
687
- reason: null
688
- };
689
- }
690
- } else if (!nextHappyOrg.runtime || nextHappyOrg.runtime.status !== "terminated") {
691
- nextHappyOrg.runtime = {
692
- status: "active",
693
- reason: null
694
- };
695
- }
696
- return {
697
- cleanedText,
698
- report,
699
- nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
700
- terminateMessage
701
- };
702
- }
703
-
704
357
  const DEFAULT_MAX_MESSAGES = 200;
705
358
  const DEFAULT_MAX_CHARACTERS = 1e5;
706
359
  const DEFAULT_MAX_MESSAGE_CHARACTERS = 8e3;
@@ -1526,4 +1179,4 @@ function registerKillSessionHandler(rpcHandlerManager, killThisHappy) {
1526
1179
  });
1527
1180
  }
1528
1181
 
1529
- export { BasePermissionHandler as B, ConversationHistory$1 as C, INTERACTION_SUPERSEDED_ERROR as I, MissingMachineIdError as M, INTERACTION_TIMED_OUT_ERROR as a, MessageQueue2 as b, createSessionMetadata as c, MessageBuffer as d, ensureManagedProviderMachine as e, registerKillSessionHandler as f, getPendingInteractionTimeoutMs as g, hashObject as h, buildHappyOrgTurnPrompt as i, finalizeHappyOrgTurn as j, closeProviderSession as k, launchRuntimeHandleWithFactoryResult as l, inferToolResultError as m, forwardAgentMessageToProviderSession as n, resolveHappyOrgQueuedTurn as r, syncControlledByUserState as s, waitForResponseCompleteWithAbort as w };
1182
+ export { BasePermissionHandler as B, ConversationHistory$1 as C, INTERACTION_SUPERSEDED_ERROR as I, MissingMachineIdError as M, INTERACTION_TIMED_OUT_ERROR as a, MessageQueue2 as b, createSessionMetadata as c, MessageBuffer as d, ensureManagedProviderMachine as e, closeProviderSession as f, getPendingInteractionTimeoutMs as g, hashObject as h, inferToolResultError as i, forwardAgentMessageToProviderSession as j, launchRuntimeHandleWithFactoryResult as l, registerKillSessionHandler as r, syncControlledByUserState as s, waitForResponseCompleteWithAbort as w };
@@ -1,8 +1,8 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { l as logger, f as backoff, g as delay, h as AsyncLock, c as configuration, s as startOfflineReconnection, b as connectionState, A as ApiClient, i as isAuthenticationRequiredError } from './api-DJe9WP9M.mjs';
2
+ import { l as logger, g as backoff, h as delay, j as AsyncLock, c as configuration, s as startOfflineReconnection, f as connectionState, A as ApiClient, i as isAuthenticationRequiredError } from './api-DX7Vg4Hz.mjs';
3
3
  import 'cross-spawn';
4
4
  import '@agentclientprotocol/sdk';
5
- import { j as getProjectPath, F as Future, k as claudeLocal, E as ExitCodeError, l as trimIdent, m as createClaudeBackend, f as formatDisplayMessage, t as truncateDisplayMessage, n as claudeCheckSession, e as projectPath, o as mapToClaudeMode, P as PushableAsyncIterable, q as query, A as AbortError, b as stopCaffeinate, p as publishSessionRegistration, u as getEnvironmentInfo, w as startCaffeinate } from './index-CHXCgpwi.mjs';
5
+ import { j as getProjectPath, F as Future, k as claudeLocal, E as ExitCodeError, l as trimIdent, m as createClaudeBackend, f as formatDisplayMessage, t as truncateDisplayMessage, n as claudeCheckSession, e as projectPath, o as mapToClaudeMode, P as PushableAsyncIterable, q as query, A as AbortError, b as stopCaffeinate, p as publishSessionRegistration, u as getEnvironmentInfo, w as startCaffeinate } from './index-CEJmASSW.mjs';
6
6
  import 'ps-list';
7
7
  import 'fs';
8
8
  import 'path';
@@ -13,7 +13,7 @@ import { dirname, basename, join, resolve } from 'node:path';
13
13
  import { homedir } from 'node:os';
14
14
  import { execSync } from 'node:child_process';
15
15
  import 'node:readline';
16
- import './persistence-CkP90vEt.mjs';
16
+ import './persistence-xypxp7ei.mjs';
17
17
  import { readFile } from 'node:fs/promises';
18
18
  import { stat, watch, access } from 'fs/promises';
19
19
  import 'crypto';
@@ -24,9 +24,9 @@ import 'tweetnacl';
24
24
  import 'open';
25
25
  import React, { useState, useRef, useEffect, useCallback } from 'react';
26
26
  import { useStdout, useInput, Box, Text, render } from 'ink';
27
- import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-R-2r7ItM.mjs';
27
+ import { c as createKeepAliveController, P as ProviderSelectionHandler, b as buildHappyOrgTurnPrompt, f as finalizeHappyOrgTurn, r as runModeLoop, a as resolveHappyOrgQueuedTurn } from './ProviderSelectionHandler-CbkbtIRC.mjs';
28
28
  import { R as RawJSONLinesSchema } from './types-CiliQpqS.mjs';
29
- import { B as BasePermissionHandler, d as MessageBuffer, C as ConversationHistory$1, i as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, j as finalizeHappyOrgTurn, l as launchRuntimeHandleWithFactoryResult, n as forwardAgentMessageToProviderSession, s as syncControlledByUserState, r as resolveHappyOrgQueuedTurn, e as ensureManagedProviderMachine, M as MissingMachineIdError, c as createSessionMetadata, b as MessageQueue2, h as hashObject, f as registerKillSessionHandler, k as closeProviderSession } from './registerKillSessionHandler-DsHTZDsU.mjs';
29
+ import { B as BasePermissionHandler, d as MessageBuffer, C as ConversationHistory$1, w as waitForResponseCompleteWithAbort, l as launchRuntimeHandleWithFactoryResult, j as forwardAgentMessageToProviderSession, s as syncControlledByUserState, e as ensureManagedProviderMachine, M as MissingMachineIdError, c as createSessionMetadata, b as MessageQueue2, h as hashObject, r as registerKillSessionHandler, f as closeProviderSession } from './registerKillSessionHandler-BNN-_qNu.mjs';
30
30
  import 'socket.io-client';
31
31
  import 'expo-server-sdk';
32
32
  import { isDeepStrictEqual } from 'node:util';
@@ -3363,7 +3363,9 @@ async function runClaude(credentials, options = {}) {
3363
3363
  currentSession?.cleanup();
3364
3364
  logger.debug("Waiting for socket to flush...");
3365
3365
  logger.debug("Closing session...");
3366
- await closeProviderSession(session);
3366
+ await closeProviderSession(session, {
3367
+ archiveOnClose: true
3368
+ });
3367
3369
  stopCaffeinate();
3368
3370
  logger.debug("Stopped sleep prevention");
3369
3371
  hookServer.stop();
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var node_crypto = require('node:crypto');
4
- var api = require('./api-MGlKcEf3.cjs');
4
+ var api = require('./api-C4bF6GEA.cjs');
5
5
  require('cross-spawn');
6
6
  require('@agentclientprotocol/sdk');
7
- var index = require('./index-CgVjDJpt.cjs');
7
+ var index = require('./index-BybqdOf2.cjs');
8
8
  require('ps-list');
9
9
  require('fs');
10
10
  require('path');
@@ -15,7 +15,7 @@ var path = require('node:path');
15
15
  var os = require('node:os');
16
16
  var node_child_process = require('node:child_process');
17
17
  require('node:readline');
18
- require('./persistence-DLFUNI9q.cjs');
18
+ require('./persistence-CdqBfAwo.cjs');
19
19
  var promises = require('node:fs/promises');
20
20
  var fs = require('fs/promises');
21
21
  require('crypto');
@@ -26,9 +26,9 @@ require('tweetnacl');
26
26
  require('open');
27
27
  var React = require('react');
28
28
  var ink = require('ink');
29
- var ProviderSelectionHandler = require('./ProviderSelectionHandler-Bafuy28L.cjs');
29
+ var ProviderSelectionHandler = require('./ProviderSelectionHandler-meVvz9NZ.cjs');
30
30
  var types = require('./types-DVk3crez.cjs');
31
- var registerKillSessionHandler = require('./registerKillSessionHandler-Cs_INk4A.cjs');
31
+ var registerKillSessionHandler = require('./registerKillSessionHandler-BK3fZIch.cjs');
32
32
  require('socket.io-client');
33
33
  require('expo-server-sdk');
34
34
  var node_util = require('node:util');
@@ -1388,7 +1388,7 @@ ${systemPrompt}` : systemPrompt,
1388
1388
  api.logger.debug(`[ClaudeACP] Injected conversation history context (${historyContext.length} chars)`);
1389
1389
  }
1390
1390
  if (message.mode.happyOrg) {
1391
- promptToSend = registerKillSessionHandler.buildHappyOrgTurnPrompt(promptToSend, message.mode.happyOrg);
1391
+ promptToSend = ProviderSelectionHandler.buildHappyOrgTurnPrompt(promptToSend, message.mode.happyOrg);
1392
1392
  }
1393
1393
  if (specialCommand.type === "compact") {
1394
1394
  emitStatusMessage("Compaction started");
@@ -1420,7 +1420,7 @@ ${systemPrompt}` : systemPrompt,
1420
1420
  currentModeHash = null;
1421
1421
  }
1422
1422
  } finally {
1423
- const finalizedTurn = registerKillSessionHandler.finalizeHappyOrgTurn({
1423
+ const finalizedTurn = ProviderSelectionHandler.finalizeHappyOrgTurn({
1424
1424
  metadata: session.client.getMetadataSnapshot?.() ?? null,
1425
1425
  queuedTurn: message.mode.happyOrg,
1426
1426
  responseText: accumulatedResponse,
@@ -3161,7 +3161,7 @@ function resolveClaudeQueuedMessage(message, currentState) {
3161
3161
  function bindClaudeUserMessageQueue(opts) {
3162
3162
  let currentState = { ...opts.initialState };
3163
3163
  opts.session.onUserMessage((message) => {
3164
- const happyOrgResult = opts.happyOrg ? registerKillSessionHandler.resolveHappyOrgQueuedTurn({
3164
+ const happyOrgResult = opts.happyOrg ? ProviderSelectionHandler.resolveHappyOrgQueuedTurn({
3165
3165
  metadata: opts.happyOrg.getMetadata(),
3166
3166
  message
3167
3167
  }) : {
@@ -3365,7 +3365,9 @@ async function runClaude(credentials, options = {}) {
3365
3365
  currentSession?.cleanup();
3366
3366
  api.logger.debug("Waiting for socket to flush...");
3367
3367
  api.logger.debug("Closing session...");
3368
- await registerKillSessionHandler.closeProviderSession(session);
3368
+ await registerKillSessionHandler.closeProviderSession(session, {
3369
+ archiveOnClose: true
3370
+ });
3369
3371
  index.stopCaffeinate();
3370
3372
  api.logger.debug("Stopped sleep prevention");
3371
3373
  hookServer.stop();
@@ -1,7 +1,7 @@
1
1
  import { randomUUID } from 'node:crypto';
2
- import { l as logger, b as connectionState, A as ApiClient } from './api-DJe9WP9M.mjs';
3
- import { B as BasePermissionHandler, h as hashObject, d as MessageBuffer, C as ConversationHistory$1, i as buildHappyOrgTurnPrompt, w as waitForResponseCompleteWithAbort, j as finalizeHappyOrgTurn, f as registerKillSessionHandler, l as launchRuntimeHandleWithFactoryResult, m as inferToolResultError, n as forwardAgentMessageToProviderSession, k as closeProviderSession, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, r as resolveHappyOrgQueuedTurn, s as syncControlledByUserState } from './registerKillSessionHandler-DsHTZDsU.mjs';
4
- import { f as formatDisplayMessage, v as validateCodexAcpSpawn, d as createCodexBackend, t as truncateDisplayMessage, b as stopCaffeinate } from './index-CHXCgpwi.mjs';
2
+ import { l as logger, f as connectionState, A as ApiClient } from './api-DX7Vg4Hz.mjs';
3
+ import { B as BasePermissionHandler, h as hashObject, d as MessageBuffer, C as ConversationHistory$1, w as waitForResponseCompleteWithAbort, r as registerKillSessionHandler, l as launchRuntimeHandleWithFactoryResult, i as inferToolResultError, j as forwardAgentMessageToProviderSession, f as closeProviderSession, e as ensureManagedProviderMachine, M as MissingMachineIdError, b as MessageQueue2, s as syncControlledByUserState } from './registerKillSessionHandler-BNN-_qNu.mjs';
4
+ import { f as formatDisplayMessage, v as validateCodexAcpSpawn, d as createCodexBackend, t as truncateDisplayMessage, b as stopCaffeinate } from './index-CEJmASSW.mjs';
5
5
  import 'cross-spawn';
6
6
  import '@agentclientprotocol/sdk';
7
7
  import 'ps-list';
@@ -14,7 +14,7 @@ import 'node:path';
14
14
  import 'node:os';
15
15
  import 'node:child_process';
16
16
  import 'node:readline';
17
- import './persistence-CkP90vEt.mjs';
17
+ import './persistence-xypxp7ei.mjs';
18
18
  import 'node:fs/promises';
19
19
  import 'fs/promises';
20
20
  import 'crypto';
@@ -25,8 +25,8 @@ import 'tweetnacl';
25
25
  import 'open';
26
26
  import React, { useState, useRef, useEffect, useCallback } from 'react';
27
27
  import { useStdout, useInput, Box, Text, render } from 'ink';
28
- import { c as createKeepAliveController, P as ProviderSelectionHandler, r as runModeLoop } from './ProviderSelectionHandler-R-2r7ItM.mjs';
29
- import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-DnVC7liC.mjs';
28
+ import { c as createKeepAliveController, P as ProviderSelectionHandler, b as buildHappyOrgTurnPrompt, f as finalizeHappyOrgTurn, r as runModeLoop, a as resolveHappyOrgQueuedTurn } from './ProviderSelectionHandler-CbkbtIRC.mjs';
29
+ import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-DH3BCCTf.mjs';
30
30
  import 'zod';
31
31
  import 'socket.io-client';
32
32
  import 'expo-server-sdk';
@@ -1297,7 +1297,9 @@ async function runCodex(opts) {
1297
1297
  loopError = error;
1298
1298
  } finally {
1299
1299
  try {
1300
- await closeProviderSession(sessionClient);
1300
+ await closeProviderSession(sessionClient, {
1301
+ archiveOnClose: true
1302
+ });
1301
1303
  } catch (error) {
1302
1304
  closeError = error;
1303
1305
  }
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var node_crypto = require('node:crypto');
4
- var api = require('./api-MGlKcEf3.cjs');
5
- var registerKillSessionHandler = require('./registerKillSessionHandler-Cs_INk4A.cjs');
6
- var index = require('./index-CgVjDJpt.cjs');
4
+ var api = require('./api-C4bF6GEA.cjs');
5
+ var registerKillSessionHandler = require('./registerKillSessionHandler-BK3fZIch.cjs');
6
+ var index = require('./index-BybqdOf2.cjs');
7
7
  require('cross-spawn');
8
8
  require('@agentclientprotocol/sdk');
9
9
  require('ps-list');
@@ -16,7 +16,7 @@ require('node:path');
16
16
  require('node:os');
17
17
  require('node:child_process');
18
18
  require('node:readline');
19
- require('./persistence-DLFUNI9q.cjs');
19
+ require('./persistence-CdqBfAwo.cjs');
20
20
  require('node:fs/promises');
21
21
  require('fs/promises');
22
22
  require('crypto');
@@ -27,8 +27,8 @@ require('tweetnacl');
27
27
  require('open');
28
28
  var React = require('react');
29
29
  var ink = require('ink');
30
- var ProviderSelectionHandler = require('./ProviderSelectionHandler-Bafuy28L.cjs');
31
- var BaseReasoningProcessor = require('./BaseReasoningProcessor-0nj-PMFc.cjs');
30
+ var ProviderSelectionHandler = require('./ProviderSelectionHandler-meVvz9NZ.cjs');
31
+ var BaseReasoningProcessor = require('./BaseReasoningProcessor-BzbDRBqp.cjs');
32
32
  require('zod');
33
33
  require('socket.io-client');
34
34
  require('expo-server-sdk');
@@ -1021,7 +1021,7 @@ async function codexRemoteLauncher(session) {
1021
1021
  api.logger.debug(`[Codex] Injected conversation history context (${historyContext.length} chars)`);
1022
1022
  }
1023
1023
  if (message.mode.happyOrg) {
1024
- promptToSend = registerKillSessionHandler.buildHappyOrgTurnPrompt(promptToSend, message.mode.happyOrg);
1024
+ promptToSend = ProviderSelectionHandler.buildHappyOrgTurnPrompt(promptToSend, message.mode.happyOrg);
1025
1025
  }
1026
1026
  conversationHistory.addUserMessage(message.message);
1027
1027
  await activeRuntimeHandle.sendPrompt(promptToSend);
@@ -1051,7 +1051,7 @@ async function codexRemoteLauncher(session) {
1051
1051
  }
1052
1052
  } finally {
1053
1053
  turnInFlight = false;
1054
- const finalizedTurn = registerKillSessionHandler.finalizeHappyOrgTurn({
1054
+ const finalizedTurn = ProviderSelectionHandler.finalizeHappyOrgTurn({
1055
1055
  metadata: session.runtimeSession.getMetadataSnapshot?.() ?? null,
1056
1056
  queuedTurn: message.mode.happyOrg,
1057
1057
  responseText: accumulatedResponse,
@@ -1233,7 +1233,7 @@ async function runCodex(opts) {
1233
1233
  let currentPermissionMode = initialPermissionMode;
1234
1234
  let currentModel;
1235
1235
  sessionClient.onUserMessage((message) => {
1236
- const happyOrgResult = registerKillSessionHandler.resolveHappyOrgQueuedTurn({
1236
+ const happyOrgResult = ProviderSelectionHandler.resolveHappyOrgQueuedTurn({
1237
1237
  metadata: sessionClient.getMetadataSnapshot?.() ?? metadata,
1238
1238
  message
1239
1239
  });
@@ -1299,7 +1299,9 @@ async function runCodex(opts) {
1299
1299
  loopError = error;
1300
1300
  } finally {
1301
1301
  try {
1302
- await registerKillSessionHandler.closeProviderSession(sessionClient);
1302
+ await registerKillSessionHandler.closeProviderSession(sessionClient, {
1303
+ archiveOnClose: true
1304
+ });
1303
1305
  } catch (error) {
1304
1306
  closeError = error;
1305
1307
  }