overlord-cli 0.2608132027.0 → 0.2608141252.0
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 +182 -122
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16556,12 +16556,88 @@ var init_latch_environment = __esm({
|
|
|
16556
16556
|
}
|
|
16557
16557
|
});
|
|
16558
16558
|
|
|
16559
|
-
// ../packages/core/dist/service/
|
|
16559
|
+
// ../packages/core/dist/service/terminal-profile-types.js
|
|
16560
|
+
function parseViewerOpenAs(value) {
|
|
16561
|
+
return typeof value === "string" && value.trim().toLowerCase() === "tab" ? "tab" : DEFAULT_VIEWER_OPEN_AS;
|
|
16562
|
+
}
|
|
16560
16563
|
function trimmed(value) {
|
|
16561
16564
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
16562
16565
|
}
|
|
16566
|
+
function viewerKindForLauncher(launcher) {
|
|
16567
|
+
const value = trimmed(launcher);
|
|
16568
|
+
if (!value)
|
|
16569
|
+
return "inline";
|
|
16570
|
+
const lowered = value.toLowerCase();
|
|
16571
|
+
if (lowered === "iterm2" || lowered === "iterm")
|
|
16572
|
+
return "iterm";
|
|
16573
|
+
if (lowered === "terminal")
|
|
16574
|
+
return "terminal";
|
|
16575
|
+
return "custom";
|
|
16576
|
+
}
|
|
16577
|
+
function normalizeExecutionProvider(value) {
|
|
16578
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
16579
|
+
return null;
|
|
16580
|
+
const cast = value;
|
|
16581
|
+
const kind = trimmed(cast.kind)?.toLowerCase() === "latch" ? "latch" : "direct";
|
|
16582
|
+
return {
|
|
16583
|
+
kind,
|
|
16584
|
+
executable: trimmed(cast.executable) ?? DEFAULT_LATCH_EXECUTABLE
|
|
16585
|
+
};
|
|
16586
|
+
}
|
|
16587
|
+
function launchSessionSnapshotFromMetadata(metadata) {
|
|
16588
|
+
const raw = metadata?.[LAUNCH_SESSION_METADATA_KEY];
|
|
16589
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
16590
|
+
return null;
|
|
16591
|
+
const cast = raw;
|
|
16592
|
+
if (cast.version !== TERMINAL_PROFILE_VERSION)
|
|
16593
|
+
return null;
|
|
16594
|
+
const viewer = cast.viewer && typeof cast.viewer === "object" && !Array.isArray(cast.viewer) ? cast.viewer : null;
|
|
16595
|
+
const launcher = trimmed(viewer?.launcher);
|
|
16596
|
+
const source = (value) => trimmed(value) === "target" ? "target" : "user_default";
|
|
16597
|
+
return {
|
|
16598
|
+
version: TERMINAL_PROFILE_VERSION,
|
|
16599
|
+
executionProvider: normalizeExecutionProvider(cast.executionProvider) ?? {
|
|
16600
|
+
...DEFAULT_EXECUTION_PROVIDER
|
|
16601
|
+
},
|
|
16602
|
+
viewer: {
|
|
16603
|
+
kind: trimmed(viewer?.kind) ? trimmed(viewer?.kind) : viewerKindForLauncher(launcher),
|
|
16604
|
+
launcher,
|
|
16605
|
+
openOnLaunch: viewer?.openOnLaunch !== false,
|
|
16606
|
+
// A snapshot frozen before `openAs` existed carries none; `window` is what
|
|
16607
|
+
// those runs actually did, so the absent case must not become `tab`.
|
|
16608
|
+
openAs: parseViewerOpenAs(viewer?.openAs)
|
|
16609
|
+
},
|
|
16610
|
+
executionProviderSource: source(cast.executionProviderSource),
|
|
16611
|
+
viewerOpenSource: source(cast.viewerOpenSource),
|
|
16612
|
+
resolvedAt: trimmed(cast.resolvedAt) ?? ""
|
|
16613
|
+
};
|
|
16614
|
+
}
|
|
16615
|
+
var DEFAULT_VIEWER_OPEN_AS, TERMINAL_PROFILE_VERSION, DEFAULT_LATCH_EXECUTABLE, DEFAULT_EXECUTION_PROVIDER, DEFAULT_OPEN_VIEWER_ON_LAUNCH, DEFAULT_LAUNCH_SESSION_DEFAULTS, LAUNCH_SESSION_METADATA_KEY;
|
|
16616
|
+
var init_terminal_profile_types2 = __esm({
|
|
16617
|
+
"../packages/core/dist/service/terminal-profile-types.js"() {
|
|
16618
|
+
"use strict";
|
|
16619
|
+
DEFAULT_VIEWER_OPEN_AS = "window";
|
|
16620
|
+
TERMINAL_PROFILE_VERSION = 1;
|
|
16621
|
+
DEFAULT_LATCH_EXECUTABLE = "latch";
|
|
16622
|
+
DEFAULT_EXECUTION_PROVIDER = {
|
|
16623
|
+
kind: "direct",
|
|
16624
|
+
executable: DEFAULT_LATCH_EXECUTABLE
|
|
16625
|
+
};
|
|
16626
|
+
DEFAULT_OPEN_VIEWER_ON_LAUNCH = true;
|
|
16627
|
+
DEFAULT_LAUNCH_SESSION_DEFAULTS = {
|
|
16628
|
+
executionProvider: { ...DEFAULT_EXECUTION_PROVIDER },
|
|
16629
|
+
openViewerOnLaunch: DEFAULT_OPEN_VIEWER_ON_LAUNCH
|
|
16630
|
+
};
|
|
16631
|
+
LAUNCH_SESSION_METADATA_KEY = "launchSession";
|
|
16632
|
+
}
|
|
16633
|
+
});
|
|
16634
|
+
|
|
16635
|
+
// ../packages/core/dist/service/latch-launch.js
|
|
16636
|
+
function trimmed2(value) {
|
|
16637
|
+
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
16638
|
+
}
|
|
16563
16639
|
function buildLatchCreateManifest({ commandString, shell = process.env.SHELL?.trim() || "/bin/bash", cwd, env, size = DEFAULT_LATCH_TERMINAL_SIZE, title, name, commandLabel, externalRunId }) {
|
|
16564
|
-
const shellPath =
|
|
16640
|
+
const shellPath = trimmed2(shell) ?? "/bin/bash";
|
|
16565
16641
|
const cleanedEnv = {};
|
|
16566
16642
|
for (const [key, value] of Object.entries(env)) {
|
|
16567
16643
|
if (key.trim() && typeof value === "string")
|
|
@@ -16570,15 +16646,15 @@ function buildLatchCreateManifest({ commandString, shell = process.env.SHELL?.tr
|
|
|
16570
16646
|
const display = {
|
|
16571
16647
|
source: {
|
|
16572
16648
|
kind: "overlord",
|
|
16573
|
-
...
|
|
16649
|
+
...trimmed2(externalRunId) ? { external_run_id: trimmed2(externalRunId) } : {}
|
|
16574
16650
|
}
|
|
16575
16651
|
};
|
|
16576
|
-
if (
|
|
16577
|
-
display.title =
|
|
16578
|
-
if (
|
|
16579
|
-
display.name =
|
|
16580
|
-
if (
|
|
16581
|
-
display.command_label =
|
|
16652
|
+
if (trimmed2(title))
|
|
16653
|
+
display.title = trimmed2(title);
|
|
16654
|
+
if (trimmed2(name))
|
|
16655
|
+
display.name = trimmed2(name);
|
|
16656
|
+
if (trimmed2(commandLabel))
|
|
16657
|
+
display.command_label = trimmed2(commandLabel);
|
|
16582
16658
|
return {
|
|
16583
16659
|
format_version: LATCH_MANIFEST_FORMAT_VERSION,
|
|
16584
16660
|
launch: {
|
|
@@ -16597,7 +16673,7 @@ function buildLatchCreateManifest({ commandString, shell = process.env.SHELL?.tr
|
|
|
16597
16673
|
function parseLatchCreateReport(raw) {
|
|
16598
16674
|
try {
|
|
16599
16675
|
const parsed = JSON.parse(raw);
|
|
16600
|
-
const id =
|
|
16676
|
+
const id = trimmed2(parsed.session?.id);
|
|
16601
16677
|
if (!id)
|
|
16602
16678
|
return null;
|
|
16603
16679
|
const protocolVersion = typeof parsed.protocolVersion === "number" && Number.isFinite(parsed.protocolVersion) ? parsed.protocolVersion : LATCH_MANIFEST_FORMAT_VERSION;
|
|
@@ -16605,9 +16681,9 @@ function parseLatchCreateReport(raw) {
|
|
|
16605
16681
|
protocolVersion,
|
|
16606
16682
|
session: {
|
|
16607
16683
|
id,
|
|
16608
|
-
name:
|
|
16609
|
-
state:
|
|
16610
|
-
createdAt:
|
|
16684
|
+
name: trimmed2(parsed.session?.name) ?? id,
|
|
16685
|
+
state: trimmed2(parsed.session?.state) ?? "running",
|
|
16686
|
+
createdAt: trimmed2(parsed.session?.createdAt) ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
16611
16687
|
}
|
|
16612
16688
|
};
|
|
16613
16689
|
} catch {
|
|
@@ -16619,28 +16695,28 @@ function toExecutionProviderSession({ createReport, executionTargetId, createdAt
|
|
|
16619
16695
|
provider: "latch",
|
|
16620
16696
|
providerSessionId: createReport.session.id,
|
|
16621
16697
|
sessionName: createReport.session.name,
|
|
16622
|
-
executionTargetId:
|
|
16698
|
+
executionTargetId: trimmed2(executionTargetId),
|
|
16623
16699
|
agentSessionId: null,
|
|
16624
16700
|
createdAt: createdAt ?? createReport.session.createdAt,
|
|
16625
16701
|
lastObservedState: createReport.session.state
|
|
16626
16702
|
};
|
|
16627
16703
|
}
|
|
16628
16704
|
function existingLatchProviderSession({ latchSessionId, executionTargetId, createdAt = (/* @__PURE__ */ new Date()).toISOString() }) {
|
|
16629
|
-
const providerSessionId =
|
|
16705
|
+
const providerSessionId = trimmed2(latchSessionId);
|
|
16630
16706
|
if (!providerSessionId)
|
|
16631
16707
|
return null;
|
|
16632
16708
|
return {
|
|
16633
16709
|
provider: "latch",
|
|
16634
16710
|
providerSessionId,
|
|
16635
16711
|
sessionName: null,
|
|
16636
|
-
executionTargetId:
|
|
16712
|
+
executionTargetId: trimmed2(executionTargetId),
|
|
16637
16713
|
agentSessionId: null,
|
|
16638
16714
|
createdAt,
|
|
16639
16715
|
lastObservedState: "running"
|
|
16640
16716
|
};
|
|
16641
16717
|
}
|
|
16642
16718
|
function latchViewerFlagForKind(kind) {
|
|
16643
|
-
switch (
|
|
16719
|
+
switch (trimmed2(kind)?.toLowerCase()) {
|
|
16644
16720
|
case "iterm":
|
|
16645
16721
|
case "iterm2":
|
|
16646
16722
|
return "iterm";
|
|
@@ -16648,28 +16724,59 @@ function latchViewerFlagForKind(kind) {
|
|
|
16648
16724
|
return null;
|
|
16649
16725
|
}
|
|
16650
16726
|
}
|
|
16727
|
+
function compareLatchProductVersions(a, b) {
|
|
16728
|
+
const parts = (value) => value.trim().split(".").map((segment) => {
|
|
16729
|
+
const parsed = Number.parseInt(segment, 10);
|
|
16730
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
16731
|
+
});
|
|
16732
|
+
const left = parts(a);
|
|
16733
|
+
const right = parts(b);
|
|
16734
|
+
const length = Math.max(left.length, right.length);
|
|
16735
|
+
for (let index = 0; index < length; index += 1) {
|
|
16736
|
+
const diff = (left[index] ?? 0) - (right[index] ?? 0);
|
|
16737
|
+
if (diff !== 0)
|
|
16738
|
+
return diff;
|
|
16739
|
+
}
|
|
16740
|
+
return 0;
|
|
16741
|
+
}
|
|
16742
|
+
function latchSupportsOpenAs(productVersion) {
|
|
16743
|
+
const version = trimmed2(productVersion);
|
|
16744
|
+
if (!version)
|
|
16745
|
+
return false;
|
|
16746
|
+
return compareLatchProductVersions(version, LATCH_OPEN_AS_MIN_PRODUCT_VERSION) >= 0;
|
|
16747
|
+
}
|
|
16748
|
+
function buildLatchOpenArgs({ providerSessionId, viewer, openAs, productVersion }) {
|
|
16749
|
+
const args = ["open", providerSessionId, "--with", viewer];
|
|
16750
|
+
if (openAs && latchSupportsOpenAs(productVersion)) {
|
|
16751
|
+
args.push("--as", parseViewerOpenAs(openAs));
|
|
16752
|
+
}
|
|
16753
|
+
args.push("--json");
|
|
16754
|
+
return args;
|
|
16755
|
+
}
|
|
16651
16756
|
function latchAttachCommand({ executable = "latch", providerSessionId }) {
|
|
16652
|
-
return `${
|
|
16757
|
+
return `${trimmed2(executable) ?? "latch"} attach ${providerSessionId}`;
|
|
16653
16758
|
}
|
|
16654
16759
|
function shouldUseLatchProvider({ providerKind, latchSelectable }) {
|
|
16655
|
-
return
|
|
16760
|
+
return trimmed2(providerKind)?.toLowerCase() === "latch" && latchSelectable === true;
|
|
16656
16761
|
}
|
|
16657
|
-
var LATCH_MANIFEST_FORMAT_VERSION, DEFAULT_LATCH_TERMINAL_SIZE;
|
|
16762
|
+
var LATCH_MANIFEST_FORMAT_VERSION, DEFAULT_LATCH_TERMINAL_SIZE, LATCH_OPEN_AS_MIN_PRODUCT_VERSION;
|
|
16658
16763
|
var init_latch_launch = __esm({
|
|
16659
16764
|
"../packages/core/dist/service/latch-launch.js"() {
|
|
16660
16765
|
"use strict";
|
|
16766
|
+
init_terminal_profile_types2();
|
|
16661
16767
|
LATCH_MANIFEST_FORMAT_VERSION = 1;
|
|
16662
16768
|
DEFAULT_LATCH_TERMINAL_SIZE = { cols: 120, rows: 36 };
|
|
16769
|
+
LATCH_OPEN_AS_MIN_PRODUCT_VERSION = "0.2608140931.0";
|
|
16663
16770
|
}
|
|
16664
16771
|
});
|
|
16665
16772
|
|
|
16666
16773
|
// ../packages/core/dist/service/latch-session.js
|
|
16667
16774
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
16668
|
-
function
|
|
16775
|
+
function trimmed3(value) {
|
|
16669
16776
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
16670
16777
|
}
|
|
16671
16778
|
function parseState(value) {
|
|
16672
|
-
switch (
|
|
16779
|
+
switch (trimmed3(value)) {
|
|
16673
16780
|
case "running":
|
|
16674
16781
|
return "running";
|
|
16675
16782
|
case "exited":
|
|
@@ -16708,11 +16815,11 @@ function runLatchJson({ executable, args }) {
|
|
|
16708
16815
|
}
|
|
16709
16816
|
}
|
|
16710
16817
|
function inspectLatchSession({ executable = "latch", providerSessionId }) {
|
|
16711
|
-
const sessionId =
|
|
16818
|
+
const sessionId = trimmed3(providerSessionId);
|
|
16712
16819
|
if (!sessionId)
|
|
16713
16820
|
throw new LatchSessionCommandError("A Latch session id is required.");
|
|
16714
16821
|
const report = runLatchJson({
|
|
16715
|
-
executable:
|
|
16822
|
+
executable: trimmed3(executable) ?? "latch",
|
|
16716
16823
|
args: ["inspect", sessionId, "--json"]
|
|
16717
16824
|
});
|
|
16718
16825
|
const state = parseState(report.state);
|
|
@@ -16720,47 +16827,61 @@ function inspectLatchSession({ executable = "latch", providerSessionId }) {
|
|
|
16720
16827
|
throw new LatchSessionCommandError("Latch returned an unsupported session state.");
|
|
16721
16828
|
const exit = report.exit && typeof report.exit === "object" && !Array.isArray(report.exit) ? report.exit : null;
|
|
16722
16829
|
return {
|
|
16723
|
-
providerSessionId:
|
|
16724
|
-
name:
|
|
16830
|
+
providerSessionId: trimmed3(report.id) ?? sessionId,
|
|
16831
|
+
name: trimmed3(report.name) ?? sessionId,
|
|
16725
16832
|
state,
|
|
16726
16833
|
exitCode: typeof exit?.code === "number" && Number.isFinite(exit.code) ? exit.code : null,
|
|
16727
16834
|
inspectedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
16728
16835
|
};
|
|
16729
16836
|
}
|
|
16730
|
-
function
|
|
16731
|
-
|
|
16837
|
+
function readLatchProductVersion(executable) {
|
|
16838
|
+
try {
|
|
16839
|
+
return trimmed3(runLatchJson({ executable, args: ["capabilities", "--json"] }).productVersion);
|
|
16840
|
+
} catch {
|
|
16841
|
+
return null;
|
|
16842
|
+
}
|
|
16843
|
+
}
|
|
16844
|
+
function openLatchSession({ executable = "latch", providerSessionId, viewerKind, openAs }) {
|
|
16845
|
+
const sessionId = trimmed3(providerSessionId);
|
|
16732
16846
|
if (!sessionId)
|
|
16733
16847
|
throw new LatchSessionCommandError("A Latch session id is required.");
|
|
16734
16848
|
const viewer = latchViewerFlagForKind(viewerKind);
|
|
16735
16849
|
if (!viewer) {
|
|
16736
16850
|
throw new LatchSessionCommandError(`Latch cannot open the configured viewer "${viewerKind}".`);
|
|
16737
16851
|
}
|
|
16852
|
+
const exe = trimmed3(executable) ?? "latch";
|
|
16738
16853
|
const report = runLatchJson({
|
|
16739
|
-
executable:
|
|
16740
|
-
args:
|
|
16854
|
+
executable: exe,
|
|
16855
|
+
args: buildLatchOpenArgs({
|
|
16856
|
+
providerSessionId: sessionId,
|
|
16857
|
+
viewer,
|
|
16858
|
+
openAs,
|
|
16859
|
+
productVersion: openAs ? readLatchProductVersion(exe) : null
|
|
16860
|
+
})
|
|
16741
16861
|
});
|
|
16742
16862
|
if (report.opened !== true) {
|
|
16743
16863
|
throw new LatchSessionCommandError(`Latch did not open the ${viewer} viewer.`);
|
|
16744
16864
|
}
|
|
16745
16865
|
return {
|
|
16746
|
-
providerSessionId:
|
|
16747
|
-
viewer:
|
|
16748
|
-
opened: true
|
|
16866
|
+
providerSessionId: trimmed3(report.id) ?? sessionId,
|
|
16867
|
+
viewer: trimmed3(report.viewer) ?? viewer,
|
|
16868
|
+
opened: true,
|
|
16869
|
+
behavior: trimmed3(report.behavior) ? parseViewerOpenAs(report.behavior) : null
|
|
16749
16870
|
};
|
|
16750
16871
|
}
|
|
16751
16872
|
function stopLatchSession({ executable = "latch", providerSessionId }) {
|
|
16752
|
-
const sessionId =
|
|
16873
|
+
const sessionId = trimmed3(providerSessionId);
|
|
16753
16874
|
if (!sessionId)
|
|
16754
16875
|
throw new LatchSessionCommandError("A Latch session id is required.");
|
|
16755
16876
|
const report = runLatchJson({
|
|
16756
|
-
executable:
|
|
16877
|
+
executable: trimmed3(executable) ?? "latch",
|
|
16757
16878
|
args: ["stop", sessionId, "--json"]
|
|
16758
16879
|
});
|
|
16759
16880
|
const state = parseState(report.state);
|
|
16760
16881
|
if (!state)
|
|
16761
16882
|
throw new LatchSessionCommandError("Latch returned an unsupported session state.");
|
|
16762
16883
|
return {
|
|
16763
|
-
providerSessionId:
|
|
16884
|
+
providerSessionId: trimmed3(report.id) ?? sessionId,
|
|
16764
16885
|
state
|
|
16765
16886
|
};
|
|
16766
16887
|
}
|
|
@@ -16770,6 +16891,7 @@ var init_latch_session = __esm({
|
|
|
16770
16891
|
"use strict";
|
|
16771
16892
|
init_latch_environment();
|
|
16772
16893
|
init_latch_launch();
|
|
16894
|
+
init_terminal_profile_types2();
|
|
16773
16895
|
LatchSessionCommandError = class extends Error {
|
|
16774
16896
|
constructor(message) {
|
|
16775
16897
|
super(message);
|
|
@@ -16781,17 +16903,17 @@ var init_latch_session = __esm({
|
|
|
16781
16903
|
|
|
16782
16904
|
// ../packages/core/dist/service/latch-events.js
|
|
16783
16905
|
import { spawn as spawn3 } from "node:child_process";
|
|
16784
|
-
function
|
|
16906
|
+
function trimmed4(value) {
|
|
16785
16907
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
16786
16908
|
}
|
|
16787
16909
|
function parseHarnessEvent(value) {
|
|
16788
16910
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
16789
16911
|
return null;
|
|
16790
16912
|
const row = value;
|
|
16791
|
-
const type =
|
|
16792
|
-
const sessionId =
|
|
16793
|
-
const at =
|
|
16794
|
-
const harnessVersion =
|
|
16913
|
+
const type = trimmed4(row.type);
|
|
16914
|
+
const sessionId = trimmed4(row.sessionId);
|
|
16915
|
+
const at = trimmed4(row.at);
|
|
16916
|
+
const harnessVersion = trimmed4(row.harnessVersion);
|
|
16795
16917
|
const connectorEpoch = typeof row.connectorEpoch === "number" && Number.isFinite(row.connectorEpoch) ? row.connectorEpoch : null;
|
|
16796
16918
|
if (!type || !HARNESS_EVENT_TYPES.has(type) || !sessionId || !at || !harnessVersion)
|
|
16797
16919
|
return null;
|
|
@@ -16802,26 +16924,26 @@ function parseHarnessEvent(value) {
|
|
|
16802
16924
|
case "user_message":
|
|
16803
16925
|
case "assistant_delta":
|
|
16804
16926
|
case "assistant_message": {
|
|
16805
|
-
const text =
|
|
16927
|
+
const text = trimmed4(row.text);
|
|
16806
16928
|
if (!text)
|
|
16807
16929
|
return null;
|
|
16808
16930
|
return { ...base, type, text };
|
|
16809
16931
|
}
|
|
16810
16932
|
case "tool_started": {
|
|
16811
|
-
const tool =
|
|
16933
|
+
const tool = trimmed4(row.tool);
|
|
16812
16934
|
if (!tool)
|
|
16813
16935
|
return null;
|
|
16814
16936
|
return { ...base, type, tool, input: row.input };
|
|
16815
16937
|
}
|
|
16816
16938
|
case "tool_finished": {
|
|
16817
|
-
const tool =
|
|
16939
|
+
const tool = trimmed4(row.tool);
|
|
16818
16940
|
if (!tool)
|
|
16819
16941
|
return null;
|
|
16820
16942
|
return { ...base, type, tool, output: row.output };
|
|
16821
16943
|
}
|
|
16822
16944
|
case "awaiting_input": {
|
|
16823
|
-
const requestId =
|
|
16824
|
-
const kind =
|
|
16945
|
+
const requestId = trimmed4(row.requestId);
|
|
16946
|
+
const kind = trimmed4(row.kind);
|
|
16825
16947
|
const prompt = typeof row.prompt === "string" ? row.prompt : null;
|
|
16826
16948
|
if (!requestId || kind !== "permission" && kind !== "question" || prompt === null) {
|
|
16827
16949
|
return null;
|
|
@@ -16837,7 +16959,7 @@ function parseHarnessEvent(value) {
|
|
|
16837
16959
|
};
|
|
16838
16960
|
}
|
|
16839
16961
|
case "status": {
|
|
16840
|
-
const status =
|
|
16962
|
+
const status = trimmed4(row.status);
|
|
16841
16963
|
if (!status)
|
|
16842
16964
|
return null;
|
|
16843
16965
|
return { ...base, type, status };
|
|
@@ -16862,11 +16984,11 @@ function parseHarnessEventNdjson(raw) {
|
|
|
16862
16984
|
return events;
|
|
16863
16985
|
}
|
|
16864
16986
|
async function collectLatchEvents({ executable = "latch", providerSessionId, from = 0, idleMs = 250, timeoutMs = 8e3 }) {
|
|
16865
|
-
const sessionId =
|
|
16987
|
+
const sessionId = trimmed4(providerSessionId);
|
|
16866
16988
|
if (!sessionId)
|
|
16867
16989
|
throw new LatchSessionCommandError("A Latch session id is required.");
|
|
16868
16990
|
const fromCursor = Number.isFinite(from) && from > 0 ? Math.floor(from) : 0;
|
|
16869
|
-
const bin =
|
|
16991
|
+
const bin = trimmed4(executable) ?? "latch";
|
|
16870
16992
|
return new Promise((resolve, reject) => {
|
|
16871
16993
|
const child = spawn3(bin, ["events", sessionId, "--json", "--from", String(fromCursor)], {
|
|
16872
16994
|
stdio: ["ignore", "pipe", "pipe"],
|
|
@@ -17281,75 +17403,6 @@ var init_git_tree = __esm({
|
|
|
17281
17403
|
}
|
|
17282
17404
|
});
|
|
17283
17405
|
|
|
17284
|
-
// ../packages/core/dist/service/terminal-profile-types.js
|
|
17285
|
-
function trimmed4(value) {
|
|
17286
|
-
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
17287
|
-
}
|
|
17288
|
-
function viewerKindForLauncher(launcher) {
|
|
17289
|
-
const value = trimmed4(launcher);
|
|
17290
|
-
if (!value)
|
|
17291
|
-
return "inline";
|
|
17292
|
-
const lowered = value.toLowerCase();
|
|
17293
|
-
if (lowered === "iterm2" || lowered === "iterm")
|
|
17294
|
-
return "iterm";
|
|
17295
|
-
if (lowered === "terminal")
|
|
17296
|
-
return "terminal";
|
|
17297
|
-
return "custom";
|
|
17298
|
-
}
|
|
17299
|
-
function normalizeExecutionProvider(value) {
|
|
17300
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
17301
|
-
return null;
|
|
17302
|
-
const cast = value;
|
|
17303
|
-
const kind = trimmed4(cast.kind)?.toLowerCase() === "latch" ? "latch" : "direct";
|
|
17304
|
-
return {
|
|
17305
|
-
kind,
|
|
17306
|
-
executable: trimmed4(cast.executable) ?? DEFAULT_LATCH_EXECUTABLE
|
|
17307
|
-
};
|
|
17308
|
-
}
|
|
17309
|
-
function launchSessionSnapshotFromMetadata(metadata) {
|
|
17310
|
-
const raw = metadata?.[LAUNCH_SESSION_METADATA_KEY];
|
|
17311
|
-
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
17312
|
-
return null;
|
|
17313
|
-
const cast = raw;
|
|
17314
|
-
if (cast.version !== TERMINAL_PROFILE_VERSION)
|
|
17315
|
-
return null;
|
|
17316
|
-
const viewer = cast.viewer && typeof cast.viewer === "object" && !Array.isArray(cast.viewer) ? cast.viewer : null;
|
|
17317
|
-
const launcher = trimmed4(viewer?.launcher);
|
|
17318
|
-
const source = (value) => trimmed4(value) === "target" ? "target" : "user_default";
|
|
17319
|
-
return {
|
|
17320
|
-
version: TERMINAL_PROFILE_VERSION,
|
|
17321
|
-
executionProvider: normalizeExecutionProvider(cast.executionProvider) ?? {
|
|
17322
|
-
...DEFAULT_EXECUTION_PROVIDER
|
|
17323
|
-
},
|
|
17324
|
-
viewer: {
|
|
17325
|
-
kind: trimmed4(viewer?.kind) ? trimmed4(viewer?.kind) : viewerKindForLauncher(launcher),
|
|
17326
|
-
launcher,
|
|
17327
|
-
openOnLaunch: viewer?.openOnLaunch !== false
|
|
17328
|
-
},
|
|
17329
|
-
executionProviderSource: source(cast.executionProviderSource),
|
|
17330
|
-
viewerOpenSource: source(cast.viewerOpenSource),
|
|
17331
|
-
resolvedAt: trimmed4(cast.resolvedAt) ?? ""
|
|
17332
|
-
};
|
|
17333
|
-
}
|
|
17334
|
-
var TERMINAL_PROFILE_VERSION, DEFAULT_LATCH_EXECUTABLE, DEFAULT_EXECUTION_PROVIDER, DEFAULT_OPEN_VIEWER_ON_LAUNCH, DEFAULT_LAUNCH_SESSION_DEFAULTS, LAUNCH_SESSION_METADATA_KEY;
|
|
17335
|
-
var init_terminal_profile_types2 = __esm({
|
|
17336
|
-
"../packages/core/dist/service/terminal-profile-types.js"() {
|
|
17337
|
-
"use strict";
|
|
17338
|
-
TERMINAL_PROFILE_VERSION = 1;
|
|
17339
|
-
DEFAULT_LATCH_EXECUTABLE = "latch";
|
|
17340
|
-
DEFAULT_EXECUTION_PROVIDER = {
|
|
17341
|
-
kind: "direct",
|
|
17342
|
-
executable: DEFAULT_LATCH_EXECUTABLE
|
|
17343
|
-
};
|
|
17344
|
-
DEFAULT_OPEN_VIEWER_ON_LAUNCH = true;
|
|
17345
|
-
DEFAULT_LAUNCH_SESSION_DEFAULTS = {
|
|
17346
|
-
executionProvider: { ...DEFAULT_EXECUTION_PROVIDER },
|
|
17347
|
-
openViewerOnLaunch: DEFAULT_OPEN_VIEWER_ON_LAUNCH
|
|
17348
|
-
};
|
|
17349
|
-
LAUNCH_SESSION_METADATA_KEY = "launchSession";
|
|
17350
|
-
}
|
|
17351
|
-
});
|
|
17352
|
-
|
|
17353
17406
|
// ../packages/core/dist/service/latch-discovery.js
|
|
17354
17407
|
import { execFileSync as execFileSync3 } from "node:child_process";
|
|
17355
17408
|
import { existsSync as existsSync16, mkdirSync as mkdirSync9, readFileSync as readFileSync15, statSync as statSync4, writeFileSync as writeFileSync8 } from "node:fs";
|
|
@@ -19186,7 +19239,9 @@ function createLatchSession({
|
|
|
19186
19239
|
function openLatchViewer({
|
|
19187
19240
|
executable = DEFAULT_LATCH_EXECUTABLE,
|
|
19188
19241
|
providerSessionId,
|
|
19189
|
-
viewerKind
|
|
19242
|
+
viewerKind,
|
|
19243
|
+
openAs,
|
|
19244
|
+
productVersion
|
|
19190
19245
|
}) {
|
|
19191
19246
|
const viewer = latchViewerFlagForKind(viewerKind);
|
|
19192
19247
|
const attachCommand = latchAttachCommand({ executable, providerSessionId });
|
|
@@ -19197,9 +19252,10 @@ function openLatchViewer({
|
|
|
19197
19252
|
attachCommand
|
|
19198
19253
|
};
|
|
19199
19254
|
}
|
|
19255
|
+
const sendsOpenAs = Boolean(openAs) && latchSupportsOpenAs(productVersion);
|
|
19200
19256
|
const result = spawnLatchJson({
|
|
19201
19257
|
executable,
|
|
19202
|
-
args:
|
|
19258
|
+
args: buildLatchOpenArgs({ providerSessionId, viewer, openAs, productVersion })
|
|
19203
19259
|
});
|
|
19204
19260
|
if (result.status !== 0) {
|
|
19205
19261
|
const detail = (result.stderr || result.stdout || `exit ${result.status ?? "null"}`).trim();
|
|
@@ -19209,7 +19265,7 @@ function openLatchViewer({
|
|
|
19209
19265
|
attachCommand
|
|
19210
19266
|
};
|
|
19211
19267
|
}
|
|
19212
|
-
return { ok: true, viewer };
|
|
19268
|
+
return { ok: true, viewer, openAs: sendsOpenAs ? parseViewerOpenAs(openAs) : null };
|
|
19213
19269
|
}
|
|
19214
19270
|
var init_latch_launch2 = __esm({
|
|
19215
19271
|
"src/latch-launch.ts"() {
|
|
@@ -19917,6 +19973,7 @@ async function launchAgent({
|
|
|
19917
19973
|
let providerFallbackWarning = null;
|
|
19918
19974
|
let useLatch = false;
|
|
19919
19975
|
let resolvedLatchExecutable = executable;
|
|
19976
|
+
let latchProductVersion = null;
|
|
19920
19977
|
const existingProviderSession = providerKind === "latch" ? existingLatchProviderSession({
|
|
19921
19978
|
latchSessionId: process.env.LATCH_SESSION_ID,
|
|
19922
19979
|
executionTargetId: options.executionTargetId
|
|
@@ -19960,6 +20017,7 @@ async function launchAgent({
|
|
|
19960
20017
|
});
|
|
19961
20018
|
if (useLatch && discovery.state === "found") {
|
|
19962
20019
|
resolvedLatchExecutable = discovery.resolvedPath;
|
|
20020
|
+
latchProductVersion = discovery.productVersion;
|
|
19963
20021
|
}
|
|
19964
20022
|
if (!useLatch) {
|
|
19965
20023
|
providerFallbackWarning = discovery.state === "not_installed" ? `Latch is not installed on this execution target (${discovery.installCommand}); falling back to direct launch.` : discovery.state === "incompatible" ? `Latch is incompatible (${discovery.missingCapability}: ${discovery.detail}); falling back to direct launch.` : "Latch is unavailable; falling back to direct launch.";
|
|
@@ -19984,7 +20042,9 @@ async function launchAgent({
|
|
|
19984
20042
|
viewerOpen = openLatchViewer({
|
|
19985
20043
|
executable: resolvedLatchExecutable,
|
|
19986
20044
|
providerSessionId: created.providerSession.providerSessionId,
|
|
19987
|
-
viewerKind: snapshot?.viewer.kind ?? "iterm"
|
|
20045
|
+
viewerKind: snapshot?.viewer.kind ?? "iterm",
|
|
20046
|
+
openAs: snapshot?.viewer.openAs ?? null,
|
|
20047
|
+
productVersion: latchProductVersion
|
|
19988
20048
|
});
|
|
19989
20049
|
}
|
|
19990
20050
|
return {
|