happy-imou-cloud 2.0.21 → 2.0.22
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/bin/happy-cloud.mjs +1 -1
- package/dist/{BaseReasoningProcessor-0nj-PMFc.cjs → BaseReasoningProcessor-CJVv1aNR.cjs} +3 -3
- package/dist/{BaseReasoningProcessor-DnVC7liC.mjs → BaseReasoningProcessor-mIqqngd3.mjs} +3 -3
- package/dist/ProviderSelectionHandler-BjLyIfSR.mjs +673 -0
- package/dist/ProviderSelectionHandler-e4zL4Y5_.cjs +680 -0
- package/dist/{api-MGlKcEf3.cjs → api-DP-RQUao.cjs} +13 -3
- package/dist/{api-DJe9WP9M.mjs → api-DrijKeDb.mjs} +13 -4
- package/dist/{command-CfyFnMv2.mjs → command--vV6BSsL.mjs} +3 -3
- package/dist/{command-DAlFmWmr.cjs → command-BZphfJrt.cjs} +3 -3
- package/dist/{index-CHXCgpwi.mjs → index-BIki80pQ.mjs} +8 -8
- package/dist/{index-CgVjDJpt.cjs → index-CqCEZDFi.cjs} +11 -11
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/lib.cjs +1 -1
- package/dist/lib.d.cts +13 -13
- package/dist/lib.d.mts +13 -13
- package/dist/lib.mjs +1 -1
- package/dist/{persistence-CkP90vEt.mjs → persistence-C3NBdZdz.mjs} +1 -1
- package/dist/{persistence-DLFUNI9q.cjs → persistence-yVTbf_Ng.cjs} +1 -1
- package/dist/{registerKillSessionHandler-DsHTZDsU.mjs → registerKillSessionHandler-CHEj7UjN.mjs} +4 -354
- package/dist/{registerKillSessionHandler-Cs_INk4A.cjs → registerKillSessionHandler-QmBN446A.cjs} +3 -356
- package/dist/{runClaude-BGSgcyUp.cjs → runClaude-BuI6OOEv.cjs} +8 -8
- package/dist/{runClaude-DAQAEmHe.mjs → runClaude-D0DD_Ya5.mjs} +5 -5
- package/dist/{runCodex-earICaxw.cjs → runCodex-1jTTmCvq.cjs} +9 -9
- package/dist/{runCodex-B2UpSn82.mjs → runCodex-BzZ0jODI.mjs} +6 -6
- package/dist/{runGemini-D5RAIaR0.cjs → runGemini-1gJRE8oT.cjs} +9 -73
- package/dist/{runGemini-BBUmH1Qh.mjs → runGemini-Bx2SYAyG.mjs} +9 -73
- package/package.json +1 -1
- package/scripts/build.mjs +66 -66
- package/scripts/devtools/README.md +9 -9
- package/scripts/e2e/fake-codex-acp-agent.mjs +139 -139
- package/scripts/e2e/local-server-session-roundtrip.mjs +1063 -1063
- package/dist/ProviderSelectionHandler-Bafuy28L.cjs +0 -265
- package/dist/ProviderSelectionHandler-R-2r7ItM.mjs +0 -261
package/dist/{registerKillSessionHandler-Cs_INk4A.cjs → registerKillSessionHandler-QmBN446A.cjs}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
4
|
-
var persistence = require('./persistence-
|
|
3
|
+
var index = require('./index-CqCEZDFi.cjs');
|
|
4
|
+
var persistence = require('./persistence-yVTbf_Ng.cjs');
|
|
5
5
|
var os = require('node:os');
|
|
6
6
|
var path = require('node:path');
|
|
7
|
-
var api = require('./api-
|
|
7
|
+
var api = require('./api-DP-RQUao.cjs');
|
|
8
8
|
var node_crypto = require('node:crypto');
|
|
9
9
|
var crypto = require('crypto');
|
|
10
10
|
require('axios');
|
|
@@ -353,356 +353,6 @@ async function syncControlledByUserState(sessionClient, controlledByUser) {
|
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
function normalizeOptionalText(value) {
|
|
357
|
-
if (typeof value !== "string") {
|
|
358
|
-
return null;
|
|
359
|
-
}
|
|
360
|
-
const trimmed = value.trim();
|
|
361
|
-
return trimmed.length > 0 ? trimmed : null;
|
|
362
|
-
}
|
|
363
|
-
function cloneHappyOrgMetadata(happyOrg) {
|
|
364
|
-
return {
|
|
365
|
-
taskContext: happyOrg?.taskContext ? { ...happyOrg.taskContext } : void 0,
|
|
366
|
-
runtime: happyOrg?.runtime ? { ...happyOrg.runtime } : void 0,
|
|
367
|
-
activeOwner: happyOrg?.activeOwner ? { ...happyOrg.activeOwner } : null,
|
|
368
|
-
repeat: happyOrg?.repeat ? {
|
|
369
|
-
threshold: happyOrg.repeat.threshold,
|
|
370
|
-
fingerprints: Object.fromEntries(
|
|
371
|
-
Object.entries(happyOrg.repeat.fingerprints ?? {}).map(([fingerprint, entry]) => [
|
|
372
|
-
fingerprint,
|
|
373
|
-
{ ...entry }
|
|
374
|
-
])
|
|
375
|
-
)
|
|
376
|
-
} : void 0,
|
|
377
|
-
lastTurnReport: happyOrg?.lastTurnReport ? { ...happyOrg.lastTurnReport } : void 0
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
function normalizeHappyOrgMetadata(metadata) {
|
|
381
|
-
const happyOrg = cloneHappyOrgMetadata(metadata?.happyOrg);
|
|
382
|
-
return {
|
|
383
|
-
...happyOrg,
|
|
384
|
-
runtime: happyOrg.runtime ?? {
|
|
385
|
-
status: "active",
|
|
386
|
-
reason: null
|
|
387
|
-
},
|
|
388
|
-
repeat: happyOrg.repeat ?? {
|
|
389
|
-
threshold: api.HAPPY_ORG_REPEAT_THRESHOLD,
|
|
390
|
-
fingerprints: {}
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
function withHappyOrgMetadata(metadata, happyOrg) {
|
|
395
|
-
return {
|
|
396
|
-
...metadata,
|
|
397
|
-
happyOrg
|
|
398
|
-
};
|
|
399
|
-
}
|
|
400
|
-
function resetHappyOrgRuntimeForTask(taskContext) {
|
|
401
|
-
return {
|
|
402
|
-
taskContext,
|
|
403
|
-
runtime: {
|
|
404
|
-
status: "active",
|
|
405
|
-
reason: null
|
|
406
|
-
},
|
|
407
|
-
activeOwner: null,
|
|
408
|
-
repeat: {
|
|
409
|
-
threshold: api.HAPPY_ORG_REPEAT_THRESHOLD,
|
|
410
|
-
fingerprints: {}
|
|
411
|
-
}
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
function buildTerminatedStatusMessage(taskId) {
|
|
415
|
-
return `Task ${taskId} is terminated. Reopen it with new context, a new decision, or a new resource before continuing.`;
|
|
416
|
-
}
|
|
417
|
-
function buildOwnerConflictStatusMessage(taskId, ownerAgentId) {
|
|
418
|
-
return `Task ${taskId} is already active under owner ${ownerAgentId}. This turn must exit without continuing token usage.`;
|
|
419
|
-
}
|
|
420
|
-
function inferInterventionType(draft) {
|
|
421
|
-
if (draft?.interventionType === "none" || draft?.interventionType === "review_needed" || draft?.interventionType === "blocker" || draft?.interventionType === "decision_needed") {
|
|
422
|
-
return draft.interventionType;
|
|
423
|
-
}
|
|
424
|
-
if (normalizeOptionalText(draft?.decisionNeeded)) {
|
|
425
|
-
return "decision_needed";
|
|
426
|
-
}
|
|
427
|
-
if (normalizeOptionalText(draft?.blockerCode)) {
|
|
428
|
-
return "blocker";
|
|
429
|
-
}
|
|
430
|
-
return "none";
|
|
431
|
-
}
|
|
432
|
-
function buildFallbackSummary(text, turnStatus) {
|
|
433
|
-
const trimmed = text.trim();
|
|
434
|
-
if (trimmed) {
|
|
435
|
-
return trimmed.replace(/\s+/g, " ").slice(0, 160);
|
|
436
|
-
}
|
|
437
|
-
return turnStatus === "turn_aborted" ? "Turn aborted before completion." : "Turn completed without a textual summary.";
|
|
438
|
-
}
|
|
439
|
-
function normalizeTurnReportDraft(draft) {
|
|
440
|
-
return {
|
|
441
|
-
summary: normalizeOptionalText(draft?.summary)?.replace(/\s+/g, " ").slice(0, 160) ?? null,
|
|
442
|
-
interventionType: inferInterventionType(draft),
|
|
443
|
-
blockerCode: normalizeOptionalText(draft?.blockerCode),
|
|
444
|
-
decisionNeeded: normalizeOptionalText(draft?.decisionNeeded),
|
|
445
|
-
targetArtifact: normalizeOptionalText(draft?.targetArtifact)
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
function stripCodeFence(text) {
|
|
449
|
-
return text.replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/i, "").trim();
|
|
450
|
-
}
|
|
451
|
-
function extractTaggedTurnReport(text) {
|
|
452
|
-
const matcher = new RegExp(
|
|
453
|
-
`<${api.HAPPY_ORG_TURN_REPORT_TAG}>\\s*([\\s\\S]*?)\\s*</${api.HAPPY_ORG_TURN_REPORT_TAG}>`,
|
|
454
|
-
"gi"
|
|
455
|
-
);
|
|
456
|
-
let lastMatch = null;
|
|
457
|
-
for (let match = matcher.exec(text); match; match = matcher.exec(text)) {
|
|
458
|
-
lastMatch = match;
|
|
459
|
-
}
|
|
460
|
-
if (!lastMatch) {
|
|
461
|
-
return {
|
|
462
|
-
cleanedText: text.trim(),
|
|
463
|
-
draft: null
|
|
464
|
-
};
|
|
465
|
-
}
|
|
466
|
-
const rawBlock = stripCodeFence(lastMatch[1] ?? "");
|
|
467
|
-
let draft = null;
|
|
468
|
-
try {
|
|
469
|
-
const parsed = JSON.parse(rawBlock);
|
|
470
|
-
draft = {
|
|
471
|
-
summary: normalizeOptionalText(parsed.summary),
|
|
472
|
-
interventionType: normalizeOptionalText(parsed.interventionType),
|
|
473
|
-
blockerCode: normalizeOptionalText(parsed.blockerCode),
|
|
474
|
-
decisionNeeded: normalizeOptionalText(parsed.decisionNeeded),
|
|
475
|
-
targetArtifact: normalizeOptionalText(parsed.targetArtifact)
|
|
476
|
-
};
|
|
477
|
-
} catch {
|
|
478
|
-
draft = null;
|
|
479
|
-
}
|
|
480
|
-
const cleanedText = `${text.slice(0, lastMatch.index)}${text.slice(lastMatch.index + lastMatch[0].length)}`.replace(/\n{3,}/g, "\n\n").trim();
|
|
481
|
-
return {
|
|
482
|
-
cleanedText,
|
|
483
|
-
draft
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
function buildRepeatFingerprint(context, blockerCode, targetArtifact) {
|
|
487
|
-
if (!blockerCode) {
|
|
488
|
-
return null;
|
|
489
|
-
}
|
|
490
|
-
return [
|
|
491
|
-
context.taskId,
|
|
492
|
-
context.memberAgentId,
|
|
493
|
-
blockerCode,
|
|
494
|
-
targetArtifact ?? ""
|
|
495
|
-
].join("::");
|
|
496
|
-
}
|
|
497
|
-
function buildHappyOrgTurnPrompt(prompt, turn) {
|
|
498
|
-
const reopenLines = turn.reopenContext ? [
|
|
499
|
-
"",
|
|
500
|
-
"This task was explicitly reopened for this turn with the following new inputs:",
|
|
501
|
-
turn.reopenContext.newContext ? `- newContext: ${turn.reopenContext.newContext}` : null,
|
|
502
|
-
turn.reopenContext.newDecision ? `- newDecision: ${turn.reopenContext.newDecision}` : null,
|
|
503
|
-
turn.reopenContext.newResource ? `- newResource: ${turn.reopenContext.newResource}` : null
|
|
504
|
-
].filter(Boolean) : [];
|
|
505
|
-
const header = [
|
|
506
|
-
"[HAPPY_ORG_TASK_CONTEXT]",
|
|
507
|
-
`taskId=${turn.context.taskId}`,
|
|
508
|
-
`organizationId=${turn.context.organizationId}`,
|
|
509
|
-
`memberAgentId=${turn.context.memberAgentId}`,
|
|
510
|
-
`supervisorAgentId=${turn.context.supervisorAgentId}`,
|
|
511
|
-
"Stay on this exact task for the whole turn.",
|
|
512
|
-
"End your response with exactly one raw JSON block inside these tags and do not wrap it in a markdown code fence:",
|
|
513
|
-
`<${api.HAPPY_ORG_TURN_REPORT_TAG}>{"summary":"short factual summary","interventionType":"none","blockerCode":null,"decisionNeeded":null,"targetArtifact":null}</${api.HAPPY_ORG_TURN_REPORT_TAG}>`,
|
|
514
|
-
"Allowed interventionType values: none, review_needed, blocker, decision_needed.",
|
|
515
|
-
"summary must read like a CEO todo card title: short, actionable, and without long process logs.",
|
|
516
|
-
"Use blocker only for problems the organization may still solve internally.",
|
|
517
|
-
"Use decision_needed only when a CEO or user decision is required.",
|
|
518
|
-
"Use review_needed when supervisor review is needed but the work is not blocked.",
|
|
519
|
-
...reopenLines,
|
|
520
|
-
"[/HAPPY_ORG_TASK_CONTEXT]",
|
|
521
|
-
"",
|
|
522
|
-
prompt
|
|
523
|
-
];
|
|
524
|
-
return header.join("\n");
|
|
525
|
-
}
|
|
526
|
-
function resolveHappyOrgQueuedTurn(opts) {
|
|
527
|
-
const metadata = opts.metadata ?? null;
|
|
528
|
-
if (!metadata) {
|
|
529
|
-
return {
|
|
530
|
-
nextMetadata: null,
|
|
531
|
-
queuedTurn: null,
|
|
532
|
-
blocked: false
|
|
533
|
-
};
|
|
534
|
-
}
|
|
535
|
-
const currentHappyOrg = normalizeHappyOrgMetadata(metadata);
|
|
536
|
-
let nextHappyOrg = cloneHappyOrgMetadata(currentHappyOrg);
|
|
537
|
-
const messageHappyOrg = opts.message.meta?.happyOrg;
|
|
538
|
-
const now = opts.now?.() ?? Date.now();
|
|
539
|
-
const createRunId = opts.createRunId ?? ((taskContext2, currentNow) => `${taskContext2.taskId}:${taskContext2.memberAgentId}:${currentNow}`);
|
|
540
|
-
if (messageHappyOrg?.taskContext) {
|
|
541
|
-
const currentTaskId = currentHappyOrg.taskContext?.taskId ?? null;
|
|
542
|
-
if (currentTaskId !== messageHappyOrg.taskContext.taskId) {
|
|
543
|
-
nextHappyOrg = resetHappyOrgRuntimeForTask(messageHappyOrg.taskContext);
|
|
544
|
-
} else {
|
|
545
|
-
nextHappyOrg.taskContext = { ...messageHappyOrg.taskContext };
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
const taskContext = nextHappyOrg.taskContext ?? null;
|
|
549
|
-
if (!taskContext) {
|
|
550
|
-
return {
|
|
551
|
-
nextMetadata: metadata,
|
|
552
|
-
queuedTurn: null,
|
|
553
|
-
blocked: false
|
|
554
|
-
};
|
|
555
|
-
}
|
|
556
|
-
const control = messageHappyOrg?.control;
|
|
557
|
-
if (control?.action === "terminate") {
|
|
558
|
-
nextHappyOrg.runtime = {
|
|
559
|
-
status: "terminated",
|
|
560
|
-
reason: normalizeOptionalText(control.reason) ?? "terminated_by_supervisor",
|
|
561
|
-
terminatedAt: now
|
|
562
|
-
};
|
|
563
|
-
nextHappyOrg.activeOwner = null;
|
|
564
|
-
return {
|
|
565
|
-
nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
|
|
566
|
-
queuedTurn: null,
|
|
567
|
-
blocked: true,
|
|
568
|
-
statusMessage: buildTerminatedStatusMessage(taskContext.taskId)
|
|
569
|
-
};
|
|
570
|
-
}
|
|
571
|
-
const hasReopenInputs = Boolean(
|
|
572
|
-
normalizeOptionalText(control?.newContext) || normalizeOptionalText(control?.newDecision) || normalizeOptionalText(control?.newResource)
|
|
573
|
-
);
|
|
574
|
-
if (nextHappyOrg.runtime?.status === "terminated") {
|
|
575
|
-
if (control?.action !== "reopen") {
|
|
576
|
-
return {
|
|
577
|
-
nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
|
|
578
|
-
queuedTurn: null,
|
|
579
|
-
blocked: true,
|
|
580
|
-
statusMessage: buildTerminatedStatusMessage(taskContext.taskId)
|
|
581
|
-
};
|
|
582
|
-
}
|
|
583
|
-
if (!hasReopenInputs) {
|
|
584
|
-
return {
|
|
585
|
-
nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
|
|
586
|
-
queuedTurn: null,
|
|
587
|
-
blocked: true,
|
|
588
|
-
statusMessage: `Task ${taskContext.taskId} can only reopen with new context, a new decision, or a new resource.`
|
|
589
|
-
};
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
const reopenContext = control?.action === "reopen" && hasReopenInputs ? {
|
|
593
|
-
newContext: normalizeOptionalText(control.newContext),
|
|
594
|
-
newDecision: normalizeOptionalText(control.newDecision),
|
|
595
|
-
newResource: normalizeOptionalText(control.newResource)
|
|
596
|
-
} : void 0;
|
|
597
|
-
if (reopenContext) {
|
|
598
|
-
nextHappyOrg.runtime = {
|
|
599
|
-
status: "active",
|
|
600
|
-
reason: null,
|
|
601
|
-
reopenedAt: now
|
|
602
|
-
};
|
|
603
|
-
} else if (!nextHappyOrg.runtime) {
|
|
604
|
-
nextHappyOrg.runtime = {
|
|
605
|
-
status: "active",
|
|
606
|
-
reason: null
|
|
607
|
-
};
|
|
608
|
-
}
|
|
609
|
-
if (!nextHappyOrg.activeOwner) {
|
|
610
|
-
nextHappyOrg.activeOwner = {
|
|
611
|
-
ownerAgentId: taskContext.memberAgentId,
|
|
612
|
-
ownerRunId: createRunId(taskContext, now),
|
|
613
|
-
claimedAt: now
|
|
614
|
-
};
|
|
615
|
-
} else if (nextHappyOrg.activeOwner.ownerAgentId !== taskContext.memberAgentId) {
|
|
616
|
-
return {
|
|
617
|
-
nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
|
|
618
|
-
queuedTurn: null,
|
|
619
|
-
blocked: true,
|
|
620
|
-
statusMessage: buildOwnerConflictStatusMessage(
|
|
621
|
-
taskContext.taskId,
|
|
622
|
-
nextHappyOrg.activeOwner.ownerAgentId
|
|
623
|
-
)
|
|
624
|
-
};
|
|
625
|
-
}
|
|
626
|
-
return {
|
|
627
|
-
nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
|
|
628
|
-
queuedTurn: {
|
|
629
|
-
context: taskContext,
|
|
630
|
-
...reopenContext ? { reopenContext } : {}
|
|
631
|
-
},
|
|
632
|
-
blocked: false
|
|
633
|
-
};
|
|
634
|
-
}
|
|
635
|
-
function finalizeHappyOrgTurn(opts) {
|
|
636
|
-
const metadata = opts.metadata ?? null;
|
|
637
|
-
const queuedTurn = opts.queuedTurn ?? null;
|
|
638
|
-
const { cleanedText, draft } = extractTaggedTurnReport(opts.responseText);
|
|
639
|
-
if (!metadata || !queuedTurn) {
|
|
640
|
-
return {
|
|
641
|
-
cleanedText,
|
|
642
|
-
report: null,
|
|
643
|
-
nextMetadata: metadata
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
const now = opts.now?.() ?? Date.now();
|
|
647
|
-
const normalizedDraft = normalizeTurnReportDraft(draft);
|
|
648
|
-
const report = {
|
|
649
|
-
...queuedTurn.context,
|
|
650
|
-
turnStatus: opts.turnStatus,
|
|
651
|
-
interventionType: normalizedDraft.interventionType ?? "none",
|
|
652
|
-
summary: normalizedDraft.summary ?? buildFallbackSummary(cleanedText, opts.turnStatus),
|
|
653
|
-
blockerCode: normalizedDraft.blockerCode ?? null,
|
|
654
|
-
decisionNeeded: normalizedDraft.decisionNeeded ?? null,
|
|
655
|
-
targetArtifact: normalizedDraft.targetArtifact ?? null,
|
|
656
|
-
repeatFingerprint: buildRepeatFingerprint(
|
|
657
|
-
queuedTurn.context,
|
|
658
|
-
normalizedDraft.blockerCode ?? null,
|
|
659
|
-
normalizedDraft.targetArtifact ?? null
|
|
660
|
-
)
|
|
661
|
-
};
|
|
662
|
-
const nextHappyOrg = normalizeHappyOrgMetadata(metadata);
|
|
663
|
-
nextHappyOrg.taskContext = { ...queuedTurn.context };
|
|
664
|
-
nextHappyOrg.lastTurnReport = report;
|
|
665
|
-
nextHappyOrg.activeOwner = null;
|
|
666
|
-
nextHappyOrg.repeat = nextHappyOrg.repeat ?? {
|
|
667
|
-
threshold: api.HAPPY_ORG_REPEAT_THRESHOLD,
|
|
668
|
-
fingerprints: {}
|
|
669
|
-
};
|
|
670
|
-
let terminateMessage;
|
|
671
|
-
if (report.repeatFingerprint) {
|
|
672
|
-
const currentEntry = nextHappyOrg.repeat.fingerprints[report.repeatFingerprint] ?? {
|
|
673
|
-
count: 0};
|
|
674
|
-
const nextCount = currentEntry.count + 1;
|
|
675
|
-
nextHappyOrg.repeat.fingerprints[report.repeatFingerprint] = {
|
|
676
|
-
count: nextCount,
|
|
677
|
-
lastSeenAt: now
|
|
678
|
-
};
|
|
679
|
-
if (nextCount >= nextHappyOrg.repeat.threshold) {
|
|
680
|
-
nextHappyOrg.runtime = {
|
|
681
|
-
status: "terminated",
|
|
682
|
-
reason: `repeat_fingerprint:${report.repeatFingerprint}`,
|
|
683
|
-
terminatedAt: now
|
|
684
|
-
};
|
|
685
|
-
terminateMessage = `Task ${queuedTurn.context.taskId} hit repeat threshold for ${report.repeatFingerprint} and is now terminated until reopen.`;
|
|
686
|
-
} else if (!nextHappyOrg.runtime || nextHappyOrg.runtime.status !== "terminated") {
|
|
687
|
-
nextHappyOrg.runtime = {
|
|
688
|
-
status: "active",
|
|
689
|
-
reason: null
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
} else if (!nextHappyOrg.runtime || nextHappyOrg.runtime.status !== "terminated") {
|
|
693
|
-
nextHappyOrg.runtime = {
|
|
694
|
-
status: "active",
|
|
695
|
-
reason: null
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
return {
|
|
699
|
-
cleanedText,
|
|
700
|
-
report,
|
|
701
|
-
nextMetadata: withHappyOrgMetadata(metadata, nextHappyOrg),
|
|
702
|
-
terminateMessage
|
|
703
|
-
};
|
|
704
|
-
}
|
|
705
|
-
|
|
706
356
|
const DEFAULT_MAX_MESSAGES = 200;
|
|
707
357
|
const DEFAULT_MAX_CHARACTERS = 1e5;
|
|
708
358
|
const DEFAULT_MAX_MESSAGE_CHARACTERS = 8e3;
|
|
@@ -1535,17 +1185,14 @@ exports.INTERACTION_TIMED_OUT_ERROR = INTERACTION_TIMED_OUT_ERROR;
|
|
|
1535
1185
|
exports.MessageBuffer = MessageBuffer;
|
|
1536
1186
|
exports.MessageQueue2 = MessageQueue2;
|
|
1537
1187
|
exports.MissingMachineIdError = MissingMachineIdError;
|
|
1538
|
-
exports.buildHappyOrgTurnPrompt = buildHappyOrgTurnPrompt;
|
|
1539
1188
|
exports.closeProviderSession = closeProviderSession;
|
|
1540
1189
|
exports.createSessionMetadata = createSessionMetadata;
|
|
1541
1190
|
exports.ensureManagedProviderMachine = ensureManagedProviderMachine;
|
|
1542
|
-
exports.finalizeHappyOrgTurn = finalizeHappyOrgTurn;
|
|
1543
1191
|
exports.forwardAgentMessageToProviderSession = forwardAgentMessageToProviderSession;
|
|
1544
1192
|
exports.getPendingInteractionTimeoutMs = getPendingInteractionTimeoutMs;
|
|
1545
1193
|
exports.hashObject = hashObject;
|
|
1546
1194
|
exports.inferToolResultError = inferToolResultError;
|
|
1547
1195
|
exports.launchRuntimeHandleWithFactoryResult = launchRuntimeHandleWithFactoryResult;
|
|
1548
1196
|
exports.registerKillSessionHandler = registerKillSessionHandler;
|
|
1549
|
-
exports.resolveHappyOrgQueuedTurn = resolveHappyOrgQueuedTurn;
|
|
1550
1197
|
exports.syncControlledByUserState = syncControlledByUserState;
|
|
1551
1198
|
exports.waitForResponseCompleteWithAbort = waitForResponseCompleteWithAbort;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_crypto = require('node:crypto');
|
|
4
|
-
var api = require('./api-
|
|
4
|
+
var api = require('./api-DP-RQUao.cjs');
|
|
5
5
|
require('cross-spawn');
|
|
6
6
|
require('@agentclientprotocol/sdk');
|
|
7
|
-
var index = require('./index-
|
|
7
|
+
var index = require('./index-CqCEZDFi.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-
|
|
18
|
+
require('./persistence-yVTbf_Ng.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-
|
|
29
|
+
var ProviderSelectionHandler = require('./ProviderSelectionHandler-e4zL4Y5_.cjs');
|
|
30
30
|
var types = require('./types-DVk3crez.cjs');
|
|
31
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
31
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-QmBN446A.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 =
|
|
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 =
|
|
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 ?
|
|
3164
|
+
const happyOrgResult = opts.happyOrg ? ProviderSelectionHandler.resolveHappyOrgQueuedTurn({
|
|
3165
3165
|
metadata: opts.happyOrg.getMetadata(),
|
|
3166
3166
|
message
|
|
3167
3167
|
}) : {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { l as logger,
|
|
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-DrijKeDb.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-
|
|
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-BIki80pQ.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-
|
|
16
|
+
import './persistence-C3NBdZdz.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-
|
|
27
|
+
import { c as createKeepAliveController, P as ProviderSelectionHandler, b as buildHappyOrgTurnPrompt, f as finalizeHappyOrgTurn, r as runModeLoop, a as resolveHappyOrgQueuedTurn } from './ProviderSelectionHandler-BjLyIfSR.mjs';
|
|
28
28
|
import { R as RawJSONLinesSchema } from './types-CiliQpqS.mjs';
|
|
29
|
-
import { B as BasePermissionHandler, d as MessageBuffer, C as ConversationHistory$1,
|
|
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-CHEj7UjN.mjs';
|
|
30
30
|
import 'socket.io-client';
|
|
31
31
|
import 'expo-server-sdk';
|
|
32
32
|
import { isDeepStrictEqual } from 'node:util';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var node_crypto = require('node:crypto');
|
|
4
|
-
var api = require('./api-
|
|
5
|
-
var registerKillSessionHandler = require('./registerKillSessionHandler-
|
|
6
|
-
var index = require('./index-
|
|
4
|
+
var api = require('./api-DP-RQUao.cjs');
|
|
5
|
+
var registerKillSessionHandler = require('./registerKillSessionHandler-QmBN446A.cjs');
|
|
6
|
+
var index = require('./index-CqCEZDFi.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-
|
|
19
|
+
require('./persistence-yVTbf_Ng.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-
|
|
31
|
-
var BaseReasoningProcessor = require('./BaseReasoningProcessor-
|
|
30
|
+
var ProviderSelectionHandler = require('./ProviderSelectionHandler-e4zL4Y5_.cjs');
|
|
31
|
+
var BaseReasoningProcessor = require('./BaseReasoningProcessor-CJVv1aNR.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 =
|
|
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 =
|
|
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 =
|
|
1236
|
+
const happyOrgResult = ProviderSelectionHandler.resolveHappyOrgQueuedTurn({
|
|
1237
1237
|
metadata: sessionClient.getMetadataSnapshot?.() ?? metadata,
|
|
1238
1238
|
message
|
|
1239
1239
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
|
-
import { l as logger,
|
|
3
|
-
import { B as BasePermissionHandler, h as hashObject, d as MessageBuffer, C as ConversationHistory$1,
|
|
4
|
-
import { f as formatDisplayMessage, v as validateCodexAcpSpawn, d as createCodexBackend, t as truncateDisplayMessage, b as stopCaffeinate } from './index-
|
|
2
|
+
import { l as logger, f as connectionState, A as ApiClient } from './api-DrijKeDb.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-CHEj7UjN.mjs';
|
|
4
|
+
import { f as formatDisplayMessage, v as validateCodexAcpSpawn, d as createCodexBackend, t as truncateDisplayMessage, b as stopCaffeinate } from './index-BIki80pQ.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-
|
|
17
|
+
import './persistence-C3NBdZdz.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-
|
|
29
|
-
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-
|
|
28
|
+
import { c as createKeepAliveController, P as ProviderSelectionHandler, b as buildHappyOrgTurnPrompt, f as finalizeHappyOrgTurn, r as runModeLoop, a as resolveHappyOrgQueuedTurn } from './ProviderSelectionHandler-BjLyIfSR.mjs';
|
|
29
|
+
import { B as BaseReasoningProcessor, b as bootstrapManagedProviderSession } from './BaseReasoningProcessor-mIqqngd3.mjs';
|
|
30
30
|
import 'zod';
|
|
31
31
|
import 'socket.io-client';
|
|
32
32
|
import 'expo-server-sdk';
|