@super-one/cli 0.50.5-alpha → 0.50.6-alpha
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/MANIFEST.json +2 -2
- package/lib/cli.mjs +303 -117
- package/package.json +1 -1
package/MANIFEST.json
CHANGED
package/lib/cli.mjs
CHANGED
|
@@ -256,7 +256,7 @@ var init_host_action_superone_descriptors = __esm({
|
|
|
256
256
|
},
|
|
257
257
|
"worktree": {
|
|
258
258
|
"type": "object",
|
|
259
|
-
"description": 'Request a host-managed worktree for same-repo isolation while cwd stays omitted or at the project root.
|
|
259
|
+
"description": 'Request a host-managed worktree for same-repo isolation while cwd stays omitted or at the project root. Use for parallel implementers (mode branch + unique branchName), not for default read-only review of the current shared checkout. Use mode detach only when reviewing a feature branch another implementer already has checked out. See read_manual({ domain: "product", topic: "collaboration" }).',
|
|
260
260
|
"properties": {
|
|
261
261
|
"enabled": {
|
|
262
262
|
"type": "boolean"
|
|
@@ -12027,8 +12027,11 @@ var init_session_runtime = __esm({
|
|
|
12027
12027
|
const s2 = this.live.get(sessionId);
|
|
12028
12028
|
return s2 ? this.clone(s2) : null;
|
|
12029
12029
|
}
|
|
12030
|
-
list(projectId) {
|
|
12031
|
-
|
|
12030
|
+
list(projectId, options) {
|
|
12031
|
+
const rows = [...this.live.values()].filter((s2) => !projectId || s2.projectId === projectId).sort((a, b2) => (b2.updatedAt ?? 0) - (a.updatedAt ?? 0) || (b2.createdAt ?? 0) - (a.createdAt ?? 0));
|
|
12032
|
+
const offset = Math.max(0, options?.offset ?? 0);
|
|
12033
|
+
const limited = options?.limit != null && options.limit >= 0 ? rows.slice(offset, offset + options.limit) : offset > 0 ? rows.slice(offset) : rows;
|
|
12034
|
+
return limited.map((s2) => this.clone(s2));
|
|
12032
12035
|
}
|
|
12033
12036
|
snapshotSequence() {
|
|
12034
12037
|
return this.events.headSequence();
|
|
@@ -18529,9 +18532,23 @@ var init_turn_attachments = __esm({
|
|
|
18529
18532
|
}
|
|
18530
18533
|
});
|
|
18531
18534
|
|
|
18535
|
+
// ../../packages/shared/src/agent-transcript-path.ts
|
|
18536
|
+
function isAgentTranscriptAbsolutePath(filePath) {
|
|
18537
|
+
if (!filePath || filePath.includes("\0")) return false;
|
|
18538
|
+
const norm = filePath.replace(/\\/g, "/");
|
|
18539
|
+
if (!norm.startsWith("/") && !/^[A-Za-z]:\//.test(norm)) return false;
|
|
18540
|
+
return norm.includes("/.grok/sessions/") || norm.includes("/.claude/projects/") || /\/\.grok\/sessions\/?$/.test(norm) || /\/\.claude\/projects\/?$/.test(norm);
|
|
18541
|
+
}
|
|
18542
|
+
var init_agent_transcript_path = __esm({
|
|
18543
|
+
"../../packages/shared/src/agent-transcript-path.ts"() {
|
|
18544
|
+
"use strict";
|
|
18545
|
+
}
|
|
18546
|
+
});
|
|
18547
|
+
|
|
18532
18548
|
// ../../packages/runtime/src/fs/path-security.ts
|
|
18533
18549
|
import { realpathSync as realpathSync2, existsSync as existsSync11, lstatSync, statSync } from "node:fs";
|
|
18534
|
-
import {
|
|
18550
|
+
import { homedir as homedir3 } from "node:os";
|
|
18551
|
+
import { dirname as dirname5, isAbsolute, join as join9, normalize, resolve, sep } from "node:path";
|
|
18535
18552
|
function resolveProjectPath(projectRoot2, relativePath) {
|
|
18536
18553
|
if (relativePath.includes("\0")) {
|
|
18537
18554
|
return { ok: false, reason: "null byte in path" };
|
|
@@ -18600,6 +18617,41 @@ function isToolOutputRelativePath(relativePath) {
|
|
|
18600
18617
|
if (n === "." || n === "" || n === ".." || n.startsWith("../")) return false;
|
|
18601
18618
|
return n === "temp" || n.startsWith(TOOL_OUTPUT_REL_PREFIX);
|
|
18602
18619
|
}
|
|
18620
|
+
function getAgentTranscriptRoots(opts) {
|
|
18621
|
+
const homeDir = opts?.homeDir ?? homedir3();
|
|
18622
|
+
return [
|
|
18623
|
+
join9(homeDir, ".grok", "sessions"),
|
|
18624
|
+
join9(homeDir, ".claude", "projects")
|
|
18625
|
+
];
|
|
18626
|
+
}
|
|
18627
|
+
function assertAgentTranscriptAbsolutePath(filePath, opts) {
|
|
18628
|
+
if (!isAgentTranscriptAbsolutePath(filePath)) return false;
|
|
18629
|
+
if (!isAbsolute(filePath) && !filePath.replace(/\\/g, "/").startsWith("/")) return false;
|
|
18630
|
+
const candidate = normalizeSep(resolve(filePath));
|
|
18631
|
+
const roots = getAgentTranscriptRoots(opts).map((root) => {
|
|
18632
|
+
const resolved = normalizeSep(resolve(root));
|
|
18633
|
+
const real = existsSync11(resolved) ? normalizeSep(resolveRealPath(resolved)) : resolved;
|
|
18634
|
+
return { resolved, real };
|
|
18635
|
+
});
|
|
18636
|
+
const underAnyRoot = (abs) => {
|
|
18637
|
+
const n = normalizeSep(abs);
|
|
18638
|
+
return roots.some(
|
|
18639
|
+
(r) => n === r.resolved || n.startsWith(r.resolved + sep) || n === r.real || n.startsWith(r.real + sep)
|
|
18640
|
+
);
|
|
18641
|
+
};
|
|
18642
|
+
if (!underAnyRoot(candidate)) return false;
|
|
18643
|
+
if (existsSync11(candidate)) {
|
|
18644
|
+
return underAnyRoot(resolveRealPath(candidate));
|
|
18645
|
+
}
|
|
18646
|
+
let existing = candidate;
|
|
18647
|
+
while (!existsSync11(existing)) {
|
|
18648
|
+
const parent = dirname5(existing);
|
|
18649
|
+
if (parent === existing) return true;
|
|
18650
|
+
if (!underAnyRoot(parent)) return true;
|
|
18651
|
+
existing = parent;
|
|
18652
|
+
}
|
|
18653
|
+
return underAnyRoot(resolveRealPath(existing));
|
|
18654
|
+
}
|
|
18603
18655
|
function pathKind(absolutePath) {
|
|
18604
18656
|
try {
|
|
18605
18657
|
const st = lstatSync(absolutePath);
|
|
@@ -18644,6 +18696,8 @@ var TOOL_OUTPUT_REL_PREFIX;
|
|
|
18644
18696
|
var init_path_security = __esm({
|
|
18645
18697
|
"../../packages/runtime/src/fs/path-security.ts"() {
|
|
18646
18698
|
"use strict";
|
|
18699
|
+
init_agent_transcript_path();
|
|
18700
|
+
init_agent_transcript_path();
|
|
18647
18701
|
TOOL_OUTPUT_REL_PREFIX = "temp/";
|
|
18648
18702
|
}
|
|
18649
18703
|
});
|
|
@@ -18734,7 +18788,7 @@ import {
|
|
|
18734
18788
|
statSync as statSync3,
|
|
18735
18789
|
writeFileSync as writeFileSync4
|
|
18736
18790
|
} from "node:fs";
|
|
18737
|
-
import { basename, dirname as
|
|
18791
|
+
import { basename, dirname as dirname6, join as join11, resolve as resolve2, sep as sep2 } from "node:path";
|
|
18738
18792
|
import { homedir as osHomedir3 } from "node:os";
|
|
18739
18793
|
function homeOf2(opts) {
|
|
18740
18794
|
return opts?.homeDir ?? osHomedir3();
|
|
@@ -19068,7 +19122,7 @@ function installManagedSkill(provider, cwd, input, opts) {
|
|
|
19068
19122
|
code: "invalid_argument"
|
|
19069
19123
|
});
|
|
19070
19124
|
}
|
|
19071
|
-
mkdirSync6(
|
|
19125
|
+
mkdirSync6(dirname6(abs), { recursive: true });
|
|
19072
19126
|
writeFileSync4(abs, content, "utf8");
|
|
19073
19127
|
}
|
|
19074
19128
|
} catch (err) {
|
|
@@ -19100,7 +19154,7 @@ var init_skills_manage = __esm({
|
|
|
19100
19154
|
|
|
19101
19155
|
// ../../packages/runtime/src/fs/mcp-config-claude.ts
|
|
19102
19156
|
import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync9, writeFileSync as writeFileSync5 } from "node:fs";
|
|
19103
|
-
import { dirname as
|
|
19157
|
+
import { dirname as dirname7, join as join12 } from "node:path";
|
|
19104
19158
|
import { homedir as osHomedir4 } from "node:os";
|
|
19105
19159
|
function homeOf3(opts) {
|
|
19106
19160
|
return opts?.homeDir ?? osHomedir4();
|
|
@@ -19123,7 +19177,7 @@ function readJsonFile(filePath) {
|
|
|
19123
19177
|
}
|
|
19124
19178
|
}
|
|
19125
19179
|
function writeJsonFile(filePath, data) {
|
|
19126
|
-
mkdirSync7(
|
|
19180
|
+
mkdirSync7(dirname7(filePath), { recursive: true });
|
|
19127
19181
|
writeFileSync5(filePath, JSON.stringify(data, null, 2) + "\n", "utf8");
|
|
19128
19182
|
}
|
|
19129
19183
|
function extractServers(config2, scope) {
|
|
@@ -20154,7 +20208,7 @@ var init_dist = __esm({
|
|
|
20154
20208
|
|
|
20155
20209
|
// ../../packages/runtime/src/fs/mcp-config-codex.ts
|
|
20156
20210
|
import { existsSync as existsSync15, mkdirSync as mkdirSync8, readFileSync as readFileSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
20157
|
-
import { dirname as
|
|
20211
|
+
import { dirname as dirname8, join as join13 } from "node:path";
|
|
20158
20212
|
import { homedir as osHomedir5 } from "node:os";
|
|
20159
20213
|
function homeOf4(opts) {
|
|
20160
20214
|
return opts?.homeDir ?? osHomedir5();
|
|
@@ -20176,7 +20230,7 @@ function readConfigFile2(filePath) {
|
|
|
20176
20230
|
}
|
|
20177
20231
|
}
|
|
20178
20232
|
function writeConfigFile(filePath, data) {
|
|
20179
|
-
mkdirSync8(
|
|
20233
|
+
mkdirSync8(dirname8(filePath), { recursive: true });
|
|
20180
20234
|
writeFileSync6(filePath, stringify(data), "utf8");
|
|
20181
20235
|
}
|
|
20182
20236
|
function parseConfigFile(filePath, scope) {
|
|
@@ -20434,7 +20488,7 @@ import {
|
|
|
20434
20488
|
statSync as statSync4,
|
|
20435
20489
|
writeFileSync as writeFileSync7
|
|
20436
20490
|
} from "node:fs";
|
|
20437
|
-
import { dirname as
|
|
20491
|
+
import { dirname as dirname9, join as join14, resolve as resolve3 } from "node:path";
|
|
20438
20492
|
import { homedir as osHomedir6 } from "node:os";
|
|
20439
20493
|
function homeOf5(opts) {
|
|
20440
20494
|
return opts?.homeDir ?? osHomedir6();
|
|
@@ -20491,7 +20545,7 @@ function getMarketplaceScopeMap(cwd, opts) {
|
|
|
20491
20545
|
return map2;
|
|
20492
20546
|
}
|
|
20493
20547
|
function writeSettingsJson(filePath, data) {
|
|
20494
|
-
mkdirSync9(
|
|
20548
|
+
mkdirSync9(dirname9(filePath), { recursive: true });
|
|
20495
20549
|
writeFileSync7(filePath, JSON.stringify(data, null, 2) + "\n");
|
|
20496
20550
|
}
|
|
20497
20551
|
function removeMarketplaceFromSettings(filePath, name) {
|
|
@@ -21030,7 +21084,7 @@ var init_plugins_manage = __esm({
|
|
|
21030
21084
|
|
|
21031
21085
|
// ../../packages/runtime/src/fs/hooks-config.ts
|
|
21032
21086
|
import { existsSync as existsSync17, mkdirSync as mkdirSync10, readFileSync as readFileSync12, writeFileSync as writeFileSync8 } from "node:fs";
|
|
21033
|
-
import { dirname as
|
|
21087
|
+
import { dirname as dirname10, join as join15 } from "node:path";
|
|
21034
21088
|
import { homedir as osHomedir7 } from "node:os";
|
|
21035
21089
|
function homeOf6(opts) {
|
|
21036
21090
|
return opts?.homeDir ?? osHomedir7();
|
|
@@ -21058,7 +21112,7 @@ function readJsonFile2(filePath) {
|
|
|
21058
21112
|
}
|
|
21059
21113
|
}
|
|
21060
21114
|
function writeJsonFile2(filePath, data) {
|
|
21061
|
-
mkdirSync10(
|
|
21115
|
+
mkdirSync10(dirname10(filePath), { recursive: true });
|
|
21062
21116
|
writeFileSync8(filePath, JSON.stringify(data, null, 2));
|
|
21063
21117
|
}
|
|
21064
21118
|
function getHooksMap(data) {
|
|
@@ -40991,8 +41045,11 @@ var init_tool_result_map = __esm({
|
|
|
40991
41045
|
});
|
|
40992
41046
|
|
|
40993
41047
|
// ../../packages/acp/src/xai-state.ts
|
|
40994
|
-
|
|
41048
|
+
import { homedir as homedir4 } from "node:os";
|
|
41049
|
+
import { join as join16 } from "node:path";
|
|
41050
|
+
function createXaiCorrelationState(opts) {
|
|
40995
41051
|
return {
|
|
41052
|
+
...opts?.cwd ? { cwd: opts.cwd } : {},
|
|
40996
41053
|
workflowToolByRunId: /* @__PURE__ */ new Map(),
|
|
40997
41054
|
workflowRevision: /* @__PURE__ */ new Map(),
|
|
40998
41055
|
workflowStarted: /* @__PURE__ */ new Set(),
|
|
@@ -41000,6 +41057,7 @@ function createXaiCorrelationState() {
|
|
|
41000
41057
|
smokeWorkflowToolIds: /* @__PURE__ */ new Set(),
|
|
41001
41058
|
pendingToolNamesById: /* @__PURE__ */ new Map(),
|
|
41002
41059
|
subagentToolById: /* @__PURE__ */ new Map(),
|
|
41060
|
+
subagentOutputById: /* @__PURE__ */ new Map(),
|
|
41003
41061
|
subagentStarted: /* @__PURE__ */ new Set(),
|
|
41004
41062
|
bgTaskById: /* @__PURE__ */ new Map(),
|
|
41005
41063
|
goalStarted: /* @__PURE__ */ new Set(),
|
|
@@ -41008,6 +41066,17 @@ function createXaiCorrelationState() {
|
|
|
41008
41066
|
lastMessageId: null
|
|
41009
41067
|
};
|
|
41010
41068
|
}
|
|
41069
|
+
function resolveGrokChildChatHistoryPath(cwd, childSessionId) {
|
|
41070
|
+
if (!cwd || !childSessionId) return void 0;
|
|
41071
|
+
return join16(homedir4(), ".grok", "sessions", encodeURIComponent(cwd), childSessionId, "chat_history.jsonl");
|
|
41072
|
+
}
|
|
41073
|
+
function noteSubagentOutputFile(state, subagentId, childSessionId) {
|
|
41074
|
+
const existing = state.subagentOutputById.get(subagentId);
|
|
41075
|
+
if (existing) return existing;
|
|
41076
|
+
const path = resolveGrokChildChatHistoryPath(state.cwd, childSessionId || subagentId);
|
|
41077
|
+
if (path) state.subagentOutputById.set(subagentId, path);
|
|
41078
|
+
return path;
|
|
41079
|
+
}
|
|
41011
41080
|
function isSubagentLaunchToolName(name) {
|
|
41012
41081
|
if (!name) return false;
|
|
41013
41082
|
const n = name.toLowerCase();
|
|
@@ -41270,6 +41339,12 @@ function mapXaiSessionUpdate(update, state, ctx = {}) {
|
|
|
41270
41339
|
return mapAutoRecoveryStarted(update);
|
|
41271
41340
|
case "auto_recovery_exhausted":
|
|
41272
41341
|
return mapAutoRecoveryExhausted(update);
|
|
41342
|
+
case "last_turn_summary":
|
|
41343
|
+
return mapLastTurnSummary(update, ctx);
|
|
41344
|
+
case "session_recap":
|
|
41345
|
+
return mapSessionRecap(update);
|
|
41346
|
+
case "session_recap_unavailable":
|
|
41347
|
+
return [];
|
|
41273
41348
|
case "unknown":
|
|
41274
41349
|
return [];
|
|
41275
41350
|
default:
|
|
@@ -41469,18 +41544,23 @@ function mapSubagentSpawned(u, state) {
|
|
|
41469
41544
|
state.subagentToolById.delete(id);
|
|
41470
41545
|
}
|
|
41471
41546
|
const toolUseId = workflowRunId ? void 0 : state.subagentToolById.get(id);
|
|
41547
|
+
const childSessionId = strField(u, "child_session_id", "childSessionId") ?? id;
|
|
41548
|
+
const outputFile = workflowRunId ? void 0 : noteSubagentOutputFile(state, id, childSessionId);
|
|
41472
41549
|
return [{
|
|
41473
41550
|
type: "task_started",
|
|
41474
41551
|
taskId: id,
|
|
41475
41552
|
...toolUseId ? { toolUseId } : {},
|
|
41476
41553
|
description,
|
|
41477
|
-
...subagentType ? { taskType: subagentType } : {}
|
|
41554
|
+
...subagentType ? { taskType: subagentType } : {},
|
|
41555
|
+
...outputFile ? { outputFile } : {}
|
|
41478
41556
|
}];
|
|
41479
41557
|
}
|
|
41480
41558
|
function mapSubagentProgress(u, state) {
|
|
41481
41559
|
const id = strField(u, "subagent_id", "subagentId");
|
|
41482
41560
|
if (!id) return [];
|
|
41483
41561
|
if (state.workflowOwnedSubagents.has(id)) return [];
|
|
41562
|
+
const childSessionId = strField(u, "child_session_id", "childSessionId") ?? id;
|
|
41563
|
+
const outputFile = noteSubagentOutputFile(state, id, childSessionId);
|
|
41484
41564
|
const events = [];
|
|
41485
41565
|
if (!state.subagentStarted.has(id)) {
|
|
41486
41566
|
state.subagentStarted.add(id);
|
|
@@ -41488,28 +41568,26 @@ function mapSubagentProgress(u, state) {
|
|
|
41488
41568
|
type: "task_started",
|
|
41489
41569
|
taskId: id,
|
|
41490
41570
|
...state.subagentToolById.get(id) ? { toolUseId: state.subagentToolById.get(id) } : {},
|
|
41491
|
-
description: id
|
|
41571
|
+
description: id,
|
|
41572
|
+
...outputFile ? { outputFile } : {}
|
|
41492
41573
|
});
|
|
41493
41574
|
}
|
|
41494
41575
|
const durationMs = numField(u, "duration_ms", "durationMs") ?? 0;
|
|
41495
41576
|
const toolCalls = numField(u, "tool_call_count", "toolCallCount") ?? 0;
|
|
41496
41577
|
const tokens = numField(u, "tokens_used", "tokensUsed") ?? 0;
|
|
41497
41578
|
const toolsUsed = (arrField(u, "tools_used", "toolsUsed") ?? []).filter((t) => typeof t === "string" && t.length > 0);
|
|
41498
|
-
const
|
|
41499
|
-
const lastTool = recent[recent.length - 1];
|
|
41500
|
-
const activityText = recent.length ? recent.join(", ") : void 0;
|
|
41501
|
-
const toolEntries = recent.map((toolName) => ({ toolName, description: "" }));
|
|
41579
|
+
const activityText = toolsUsed.length ? toolsUsed.join(", ") : void 0;
|
|
41502
41580
|
const toolUseId = state.subagentToolById.get(id);
|
|
41503
41581
|
events.push({
|
|
41504
41582
|
type: "task_progress",
|
|
41505
41583
|
taskId: id,
|
|
41506
41584
|
...toolUseId ? { toolUseId } : {},
|
|
41507
|
-
//
|
|
41508
|
-
description
|
|
41509
|
-
|
|
41585
|
+
// Keep a stable non-tool description so reducer does not invent history from
|
|
41586
|
+
// description transitions when no transcript path is available.
|
|
41587
|
+
description: id,
|
|
41510
41588
|
usage: { totalTokens: tokens, toolUses: toolCalls, durationMs },
|
|
41511
41589
|
...activityText ? { activityText } : {},
|
|
41512
|
-
...
|
|
41590
|
+
...outputFile ? { outputFile } : {}
|
|
41513
41591
|
});
|
|
41514
41592
|
return events;
|
|
41515
41593
|
}
|
|
@@ -41525,6 +41603,8 @@ function mapSubagentFinished(u, state) {
|
|
|
41525
41603
|
const durationMs = numField(u, "duration_ms", "durationMs") ?? 0;
|
|
41526
41604
|
const toolCalls = numField(u, "tool_calls", "toolCalls") ?? 0;
|
|
41527
41605
|
const tokens = numField(u, "tokens_used", "tokensUsed") ?? 0;
|
|
41606
|
+
const childSessionId = strField(u, "child_session_id", "childSessionId") ?? id;
|
|
41607
|
+
const outputFile = noteSubagentOutputFile(state, id, childSessionId) ?? "";
|
|
41528
41608
|
const events = [];
|
|
41529
41609
|
if (!state.subagentStarted.has(id)) {
|
|
41530
41610
|
state.subagentStarted.add(id);
|
|
@@ -41532,7 +41612,8 @@ function mapSubagentFinished(u, state) {
|
|
|
41532
41612
|
type: "task_started",
|
|
41533
41613
|
taskId: id,
|
|
41534
41614
|
...toolUseId ? { toolUseId } : {},
|
|
41535
|
-
description: id
|
|
41615
|
+
description: id,
|
|
41616
|
+
...outputFile ? { outputFile } : {}
|
|
41536
41617
|
});
|
|
41537
41618
|
}
|
|
41538
41619
|
events.push({
|
|
@@ -41540,7 +41621,7 @@ function mapSubagentFinished(u, state) {
|
|
|
41540
41621
|
taskId: id,
|
|
41541
41622
|
...toolUseId ? { toolUseId } : {},
|
|
41542
41623
|
taskStatus,
|
|
41543
|
-
outputFile
|
|
41624
|
+
outputFile,
|
|
41544
41625
|
summary: error51 ?? status,
|
|
41545
41626
|
usage: { totalTokens: tokens, toolUses: toolCalls, durationMs },
|
|
41546
41627
|
...output ? { resultText: output } : error51 ? { resultText: error51 } : {}
|
|
@@ -41873,6 +41954,27 @@ function mapAutoCompactFailed(u) {
|
|
|
41873
41954
|
compactError: error51
|
|
41874
41955
|
}];
|
|
41875
41956
|
}
|
|
41957
|
+
function mapLastTurnSummary(u, ctx) {
|
|
41958
|
+
const summary = strField(u, "summary")?.trim();
|
|
41959
|
+
if (!summary) return [];
|
|
41960
|
+
const promptId = strField(u, "prompt_id", "promptId");
|
|
41961
|
+
return [{
|
|
41962
|
+
type: "turn_summary",
|
|
41963
|
+
summary,
|
|
41964
|
+
...promptId ? { promptId } : {},
|
|
41965
|
+
...ctx.messageId ? { messageId: ctx.messageId } : {}
|
|
41966
|
+
}];
|
|
41967
|
+
}
|
|
41968
|
+
function mapSessionRecap(u) {
|
|
41969
|
+
const summary = strField(u, "summary")?.trim();
|
|
41970
|
+
if (!summary) return [];
|
|
41971
|
+
const auto = boolField(u, "auto");
|
|
41972
|
+
return [{
|
|
41973
|
+
type: "session_recap",
|
|
41974
|
+
summary,
|
|
41975
|
+
...auto != null ? { auto } : {}
|
|
41976
|
+
}];
|
|
41977
|
+
}
|
|
41876
41978
|
function mapModelChanged(u) {
|
|
41877
41979
|
const modelId = strField(u, "model_id", "modelId");
|
|
41878
41980
|
if (!modelId) return [];
|
|
@@ -42259,7 +42361,9 @@ function createAcpAgentEventMapper(options) {
|
|
|
42259
42361
|
const nativeToLocal = /* @__PURE__ */ new Map();
|
|
42260
42362
|
const localMessageIds = /* @__PURE__ */ new Set([options.messageId]);
|
|
42261
42363
|
const openTools = /* @__PURE__ */ new Set();
|
|
42262
|
-
const xaiCorrelation = createXaiCorrelationState(
|
|
42364
|
+
const xaiCorrelation = createXaiCorrelationState(
|
|
42365
|
+
options.cwd ? { cwd: options.cwd } : void 0
|
|
42366
|
+
);
|
|
42263
42367
|
let currentMessageId = options.messageId;
|
|
42264
42368
|
let started = false;
|
|
42265
42369
|
let terminal = false;
|
|
@@ -42579,7 +42683,8 @@ function createAcpAgentTurnRunner(opts = {}) {
|
|
|
42579
42683
|
const blockId = `acp-${sessionId}`;
|
|
42580
42684
|
agentEventMapper = input.onAgentEvent ? createAcpAgentEventMapper({
|
|
42581
42685
|
messageId: input.messageId ?? blockId,
|
|
42582
|
-
emit: input.onAgentEvent
|
|
42686
|
+
emit: input.onAgentEvent,
|
|
42687
|
+
cwd
|
|
42583
42688
|
}) : null;
|
|
42584
42689
|
agentEventMapper?.start(sessionId);
|
|
42585
42690
|
if (agentEventMapper) {
|
|
@@ -49109,23 +49214,23 @@ var init_parse4 = __esm({
|
|
|
49109
49214
|
// ../../packages/opencode/src/server.ts
|
|
49110
49215
|
import { spawn as spawn3 } from "node:child_process";
|
|
49111
49216
|
import { existsSync as existsSync20 } from "node:fs";
|
|
49112
|
-
import { homedir as
|
|
49113
|
-
import { delimiter, join as
|
|
49217
|
+
import { homedir as homedir5 } from "node:os";
|
|
49218
|
+
import { delimiter, join as join17 } from "node:path";
|
|
49114
49219
|
function appendOutput(current, chunk) {
|
|
49115
49220
|
const next = current + chunk.toString();
|
|
49116
49221
|
return next.length <= maxServerOutput ? next : next.slice(-maxServerOutput);
|
|
49117
49222
|
}
|
|
49118
49223
|
function defaultOpenCodeBinaryPath() {
|
|
49119
49224
|
const filename = process.platform === "win32" ? "opencode.exe" : "opencode";
|
|
49120
|
-
const installed =
|
|
49225
|
+
const installed = join17(homedir5(), ".opencode", "bin", filename);
|
|
49121
49226
|
return existsSync20(installed) ? installed : filename;
|
|
49122
49227
|
}
|
|
49123
49228
|
function openCodePath(pathEnv) {
|
|
49124
|
-
const home =
|
|
49229
|
+
const home = homedir5();
|
|
49125
49230
|
const paths = [
|
|
49126
|
-
|
|
49127
|
-
|
|
49128
|
-
|
|
49231
|
+
join17(home, ".opencode", "bin"),
|
|
49232
|
+
join17(home, ".local", "bin"),
|
|
49233
|
+
join17(home, ".bun", "bin"),
|
|
49129
49234
|
"/opt/homebrew/bin",
|
|
49130
49235
|
"/usr/local/bin",
|
|
49131
49236
|
...(pathEnv ?? "").split(delimiter)
|
|
@@ -49944,7 +50049,7 @@ __export(managed_harness_official_exports, {
|
|
|
49944
50049
|
});
|
|
49945
50050
|
import { existsSync as existsSync24, mkdirSync as mkdirSync12, readFileSync as readFileSync14, readdirSync as readdirSync8, statSync as statSync6 } from "node:fs";
|
|
49946
50051
|
import { arch as osArch2, platform as osPlatform2 } from "node:os";
|
|
49947
|
-
import { join as
|
|
50052
|
+
import { join as join19, resolve as resolve5 } from "node:path";
|
|
49948
50053
|
import { spawn as spawn4 } from "node:child_process";
|
|
49949
50054
|
function managedNpmPrefix(nodeHome, harnessId) {
|
|
49950
50055
|
return resolve5(nodeHome, "managed-npm", harnessId);
|
|
@@ -49990,29 +50095,29 @@ function officialPackageSpecs(harnessId) {
|
|
|
49990
50095
|
function resolveOfficialInstallBinary(harnessId, prefix) {
|
|
49991
50096
|
if (harnessId === "codex") {
|
|
49992
50097
|
const candidates = [
|
|
49993
|
-
|
|
49994
|
-
|
|
49995
|
-
|
|
50098
|
+
join19(prefix, "bin", "codex"),
|
|
50099
|
+
join19(prefix, "bin", "codex.cmd"),
|
|
50100
|
+
join19(prefix, "lib", "node_modules", "@openai", "codex", "bin", "codex.js")
|
|
49996
50101
|
];
|
|
49997
50102
|
for (const c of candidates) {
|
|
49998
50103
|
if (existsSync24(c) && (c.endsWith(".js") || isExecutableFile(c))) return c;
|
|
49999
50104
|
}
|
|
50000
50105
|
return null;
|
|
50001
50106
|
}
|
|
50002
|
-
const nm =
|
|
50003
|
-
const scoped =
|
|
50107
|
+
const nm = join19(prefix, "lib", "node_modules");
|
|
50108
|
+
const scoped = join19(nm, "@anthropic-ai");
|
|
50004
50109
|
try {
|
|
50005
50110
|
if (existsSync24(scoped)) {
|
|
50006
50111
|
const names = readdirSync8(scoped).filter((n) => n.startsWith("claude-agent-sdk-"));
|
|
50007
50112
|
for (const n of names) {
|
|
50008
50113
|
const ext = process.platform === "win32" ? ".exe" : "";
|
|
50009
|
-
const bin =
|
|
50114
|
+
const bin = join19(scoped, n, `claude${ext}`);
|
|
50010
50115
|
if (existsSync24(bin)) return bin;
|
|
50011
50116
|
}
|
|
50012
50117
|
}
|
|
50013
50118
|
} catch {
|
|
50014
50119
|
}
|
|
50015
|
-
const direct =
|
|
50120
|
+
const direct = join19(
|
|
50016
50121
|
nm,
|
|
50017
50122
|
...claudePlatformPackageName().split("/"),
|
|
50018
50123
|
process.platform === "win32" ? "claude.exe" : "claude"
|
|
@@ -50067,7 +50172,7 @@ async function installManagedFromOfficialNpm(opts) {
|
|
|
50067
50172
|
}
|
|
50068
50173
|
function readInstalledVersion(prefix, harnessId) {
|
|
50069
50174
|
try {
|
|
50070
|
-
const pkgPath = harnessId === "claude" ?
|
|
50175
|
+
const pkgPath = harnessId === "claude" ? join19(prefix, "lib", "node_modules", "@anthropic-ai", "claude-agent-sdk", "package.json") : join19(prefix, "lib", "node_modules", "@openai", "codex", "package.json");
|
|
50071
50176
|
if (!existsSync24(pkgPath)) return null;
|
|
50072
50177
|
const raw = JSON.parse(readFileSync14(pkgPath, "utf8"));
|
|
50073
50178
|
return raw.version?.trim() || null;
|
|
@@ -57259,7 +57364,7 @@ var require_dist = __commonJS({
|
|
|
57259
57364
|
});
|
|
57260
57365
|
|
|
57261
57366
|
// src/cli.ts
|
|
57262
|
-
import { homedir as
|
|
57367
|
+
import { homedir as homedir9 } from "node:os";
|
|
57263
57368
|
import { resolve as resolve12 } from "node:path";
|
|
57264
57369
|
|
|
57265
57370
|
// src/config.ts
|
|
@@ -57301,8 +57406,8 @@ import { fileURLToPath } from "node:url";
|
|
|
57301
57406
|
function resolveCliReleaseVersion() {
|
|
57302
57407
|
const fromEnv = process.env.SUPERONE_CLI_VERSION?.trim();
|
|
57303
57408
|
if (fromEnv) return fromEnv;
|
|
57304
|
-
if ("0.50.
|
|
57305
|
-
return "0.50.
|
|
57409
|
+
if ("0.50.6-alpha".trim()) {
|
|
57410
|
+
return "0.50.6-alpha".trim();
|
|
57306
57411
|
}
|
|
57307
57412
|
const fromDist = readDistManifestVersion();
|
|
57308
57413
|
if (fromDist) return fromDist;
|
|
@@ -58918,7 +59023,7 @@ import {
|
|
|
58918
59023
|
writeFileSync as writeFileSync9
|
|
58919
59024
|
} from "node:fs";
|
|
58920
59025
|
import { createHash as createHash4, randomBytes as randomBytes3 } from "node:crypto";
|
|
58921
|
-
import { dirname as
|
|
59026
|
+
import { dirname as dirname11, join as join18, relative, resolve as resolve4, sep as sep3 } from "node:path";
|
|
58922
59027
|
import { arch as osArch, platform as osPlatform } from "node:os";
|
|
58923
59028
|
var MANAGED_PAYLOAD_BASENAME = "payload.bin";
|
|
58924
59029
|
var MANAGED_META_BASENAME = "artifact.json";
|
|
@@ -59037,7 +59142,7 @@ function loadHarnessReleaseManifest(nodeHome) {
|
|
|
59037
59142
|
}
|
|
59038
59143
|
return parseHarnessReleaseManifest(JSON.parse(readFileSync13(fromEnv, "utf8")));
|
|
59039
59144
|
}
|
|
59040
|
-
const local =
|
|
59145
|
+
const local = join18(nodeHome, "release-manifest.json");
|
|
59041
59146
|
if (existsSync23(local)) {
|
|
59042
59147
|
return parseHarnessReleaseManifest(JSON.parse(readFileSync13(local, "utf8")));
|
|
59043
59148
|
}
|
|
@@ -59125,8 +59230,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
59125
59230
|
opts.harnessId,
|
|
59126
59231
|
pin.artifactVersion
|
|
59127
59232
|
);
|
|
59128
|
-
const finalFile =
|
|
59129
|
-
const metaPath =
|
|
59233
|
+
const finalFile = join18(destDir, MANAGED_PAYLOAD_BASENAME);
|
|
59234
|
+
const metaPath = join18(destDir, MANAGED_META_BASENAME);
|
|
59130
59235
|
assertStrictChild(finalFile, destDir, "payload path");
|
|
59131
59236
|
assertStrictChild(metaPath, destDir, "meta path");
|
|
59132
59237
|
const metaBody = JSON.stringify(
|
|
@@ -59165,15 +59270,15 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
59165
59270
|
);
|
|
59166
59271
|
}
|
|
59167
59272
|
} else {
|
|
59168
|
-
const harnessRoot2 =
|
|
59273
|
+
const harnessRoot2 = dirname11(destDir);
|
|
59169
59274
|
mkdirSync11(harnessRoot2, { recursive: true });
|
|
59170
59275
|
assertPathInside(destDir, harnessRoot2, "version dir");
|
|
59171
59276
|
const stagingDir = mkdtempSync(
|
|
59172
|
-
|
|
59277
|
+
join18(harnessRoot2, `.staging-${opts.harnessId}-${randomBytes3(8).toString("hex")}-`)
|
|
59173
59278
|
);
|
|
59174
59279
|
assertPathInside(stagingDir, harnessRoot2, "staging dir");
|
|
59175
|
-
const stagingFile =
|
|
59176
|
-
const stagingMeta =
|
|
59280
|
+
const stagingFile = join18(stagingDir, MANAGED_PAYLOAD_BASENAME);
|
|
59281
|
+
const stagingMeta = join18(stagingDir, MANAGED_META_BASENAME);
|
|
59177
59282
|
try {
|
|
59178
59283
|
copyFileSync(opts.artifactPath, stagingFile);
|
|
59179
59284
|
const stagedDigest = await sha256File(stagingFile);
|
|
@@ -59209,7 +59314,7 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
59209
59314
|
if (finalDigest !== art.digestSha256) {
|
|
59210
59315
|
throw new Error(`final payload digest mismatch for ${opts.harnessId}`);
|
|
59211
59316
|
}
|
|
59212
|
-
const harnessRoot =
|
|
59317
|
+
const harnessRoot = join18(
|
|
59213
59318
|
releasesRoot(opts.nodeHome),
|
|
59214
59319
|
opts.manifest.cliVersion,
|
|
59215
59320
|
"harnesses",
|
|
@@ -59217,8 +59322,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
59217
59322
|
);
|
|
59218
59323
|
assertPathInside(harnessRoot, releasesRoot(opts.nodeHome), "harness root");
|
|
59219
59324
|
mkdirSync11(harnessRoot, { recursive: true });
|
|
59220
|
-
const currentPath =
|
|
59221
|
-
const currentTmp =
|
|
59325
|
+
const currentPath = join18(harnessRoot, MANAGED_CURRENT_BASENAME);
|
|
59326
|
+
const currentTmp = join18(
|
|
59222
59327
|
harnessRoot,
|
|
59223
59328
|
`.${MANAGED_CURRENT_BASENAME}.${process.pid}.${randomBytes3(6).toString("hex")}.tmp`
|
|
59224
59329
|
);
|
|
@@ -59257,8 +59362,8 @@ async function installManagedArtifactFromFile(opts) {
|
|
|
59257
59362
|
async function replacePayloadAtomically(opts) {
|
|
59258
59363
|
mkdirSync11(opts.destDir, { recursive: true });
|
|
59259
59364
|
const nonce = randomBytes3(8).toString("hex");
|
|
59260
|
-
const payloadTmp =
|
|
59261
|
-
const metaTmp =
|
|
59365
|
+
const payloadTmp = join18(opts.destDir, `.${MANAGED_PAYLOAD_BASENAME}.${nonce}.tmp`);
|
|
59366
|
+
const metaTmp = join18(opts.destDir, `.${MANAGED_META_BASENAME}.${nonce}.tmp`);
|
|
59262
59367
|
assertStrictChild(payloadTmp, opts.destDir, "payload temp");
|
|
59263
59368
|
assertStrictChild(metaTmp, opts.destDir, "meta temp");
|
|
59264
59369
|
try {
|
|
@@ -59566,7 +59671,7 @@ function looksLikeSecretArg(value) {
|
|
|
59566
59671
|
// ../../packages/shared/src/git-clone.ts
|
|
59567
59672
|
import { execFile as execFile2 } from "node:child_process";
|
|
59568
59673
|
import { existsSync as existsSync26, mkdirSync as mkdirSync13 } from "node:fs";
|
|
59569
|
-
import { isAbsolute as isAbsolute3, join as
|
|
59674
|
+
import { isAbsolute as isAbsolute3, join as join20, resolve as resolve7 } from "node:path";
|
|
59570
59675
|
|
|
59571
59676
|
// ../../packages/shared/src/git-remote.ts
|
|
59572
59677
|
function repoNameFromGitUrl(url2) {
|
|
@@ -59631,7 +59736,7 @@ function resolveCloneDestination(input) {
|
|
|
59631
59736
|
if (name.includes("/") || name.includes("\\") || name === "." || name === "..") {
|
|
59632
59737
|
throw invalid(`invalid folder name: ${name}`);
|
|
59633
59738
|
}
|
|
59634
|
-
return { path:
|
|
59739
|
+
return { path: join20(resolve7(parent), name), name };
|
|
59635
59740
|
}
|
|
59636
59741
|
async function cloneRepository(input) {
|
|
59637
59742
|
const destination = resolveCloneDestination(input);
|
|
@@ -59681,7 +59786,7 @@ async function cloneRepository(input) {
|
|
|
59681
59786
|
init_resolve_service();
|
|
59682
59787
|
import { existsSync as existsSync27, mkdirSync as mkdirSync14, readdirSync as readdirSync9, statSync as statSync8 } from "node:fs";
|
|
59683
59788
|
import { join as pathJoin, resolve as pathResolve } from "node:path";
|
|
59684
|
-
import { arch, cpus, freemem, homedir as
|
|
59789
|
+
import { arch, cpus, freemem, homedir as homedir6, hostname as hostname4, platform, totalmem, uptime } from "node:os";
|
|
59685
59790
|
|
|
59686
59791
|
// src/rpc/resource-handlers.ts
|
|
59687
59792
|
init_environment();
|
|
@@ -62286,9 +62391,9 @@ function handleProjectGet(payload, ctx) {
|
|
|
62286
62391
|
function expandHostPath(path) {
|
|
62287
62392
|
const trimmed = path.trim();
|
|
62288
62393
|
if (!trimmed) return trimmed;
|
|
62289
|
-
if (trimmed === "~") return
|
|
62394
|
+
if (trimmed === "~") return homedir6();
|
|
62290
62395
|
if (trimmed.startsWith("~/") || trimmed.startsWith("~\\")) {
|
|
62291
|
-
return pathResolve(pathJoin(
|
|
62396
|
+
return pathResolve(pathJoin(homedir6(), trimmed.slice(2)));
|
|
62292
62397
|
}
|
|
62293
62398
|
return pathResolve(trimmed);
|
|
62294
62399
|
}
|
|
@@ -62571,10 +62676,12 @@ function handleWorkspaceTailWatchStart(payload, ctx) {
|
|
|
62571
62676
|
const p2 = asRecord14(payload);
|
|
62572
62677
|
try {
|
|
62573
62678
|
const offset = typeof p2.offset === "number" ? p2.offset : void 0;
|
|
62679
|
+
const absolutePath = typeof p2.absolutePath === "string" ? p2.absolutePath : void 0;
|
|
62574
62680
|
return {
|
|
62575
62681
|
result: ctx.workspaceTailWatch.start(String(p2.projectId ?? ""), String(p2.relativePath ?? ""), {
|
|
62576
62682
|
offset,
|
|
62577
|
-
ownerClientId: ctx.client.clientSessionId
|
|
62683
|
+
ownerClientId: ctx.client.clientSessionId,
|
|
62684
|
+
...absolutePath ? { absolutePath } : {}
|
|
62578
62685
|
})
|
|
62579
62686
|
};
|
|
62580
62687
|
} catch (err) {
|
|
@@ -63062,8 +63169,33 @@ function handleSessionList(payload, ctx) {
|
|
|
63062
63169
|
const denied = requireScopes6(ctx.client, OPERATION_SCOPES.readSession);
|
|
63063
63170
|
if (denied) return denied;
|
|
63064
63171
|
const p2 = asRecord14(payload);
|
|
63172
|
+
const projectId = typeof p2.projectId === "string" ? p2.projectId : void 0;
|
|
63173
|
+
if (typeof p2.limit !== "number" || !Number.isFinite(p2.limit)) {
|
|
63174
|
+
return { error: { code: "invalid_argument", message: "session.list requires finite limit" } };
|
|
63175
|
+
}
|
|
63176
|
+
if (typeof p2.offset !== "number" || !Number.isFinite(p2.offset)) {
|
|
63177
|
+
return { error: { code: "invalid_argument", message: "session.list requires finite offset" } };
|
|
63178
|
+
}
|
|
63179
|
+
const limit = Math.min(Math.max(Math.floor(p2.limit), 0), 500);
|
|
63180
|
+
const offset = Math.max(Math.floor(p2.offset), 0);
|
|
63181
|
+
const rows = ctx.sessions.list(projectId, { limit, offset });
|
|
63065
63182
|
return {
|
|
63066
|
-
result:
|
|
63183
|
+
result: rows.map((s2) => ({
|
|
63184
|
+
sessionId: s2.sessionId,
|
|
63185
|
+
projectId: s2.projectId,
|
|
63186
|
+
harnessId: s2.harnessId,
|
|
63187
|
+
providerId: s2.providerId,
|
|
63188
|
+
title: s2.title,
|
|
63189
|
+
status: s2.status,
|
|
63190
|
+
messageCount: Array.isArray(s2.transcript) ? s2.transcript.length : 0,
|
|
63191
|
+
cwd: s2.cwd,
|
|
63192
|
+
createdAt: s2.createdAt,
|
|
63193
|
+
updatedAt: s2.updatedAt,
|
|
63194
|
+
isPinned: s2.isPinned,
|
|
63195
|
+
isHidden: s2.isHidden,
|
|
63196
|
+
isAutomation: s2.isAutomation === true,
|
|
63197
|
+
automationId: s2.automationId ?? null
|
|
63198
|
+
}))
|
|
63067
63199
|
};
|
|
63068
63200
|
}
|
|
63069
63201
|
function handleSessionAcquireControl(payload, ctx) {
|
|
@@ -64311,7 +64443,7 @@ import {
|
|
|
64311
64443
|
unlinkSync,
|
|
64312
64444
|
writeFileSync as writeFileSync10
|
|
64313
64445
|
} from "node:fs";
|
|
64314
|
-
import { dirname as
|
|
64446
|
+
import { dirname as dirname12, join as join21, relative as relative2 } from "node:path";
|
|
64315
64447
|
import { createHash as createHash6 } from "node:crypto";
|
|
64316
64448
|
function normalizeRel(path) {
|
|
64317
64449
|
return path.replace(/\\/g, "/").replace(/\/+$/, "") || ".";
|
|
@@ -64367,7 +64499,7 @@ var WorkspaceFsService = class {
|
|
|
64367
64499
|
this.projects.touch(projectId);
|
|
64368
64500
|
const ents = readdirSync10(resolved.absolutePath, { withFileTypes: true });
|
|
64369
64501
|
return ents.map((ent) => {
|
|
64370
|
-
const abs =
|
|
64502
|
+
const abs = join21(resolved.absolutePath, ent.name);
|
|
64371
64503
|
let size;
|
|
64372
64504
|
let mtimeMs;
|
|
64373
64505
|
try {
|
|
@@ -64444,7 +64576,7 @@ var WorkspaceFsService = class {
|
|
|
64444
64576
|
throw Object.assign(new Error("content hash mismatch"), { code: "conflict" });
|
|
64445
64577
|
}
|
|
64446
64578
|
}
|
|
64447
|
-
mkdirSync15(
|
|
64579
|
+
mkdirSync15(dirname12(resolved.absolutePath), { recursive: true });
|
|
64448
64580
|
const data = typeof content === "string" ? Buffer.from(content, "utf8") : Buffer.from(content);
|
|
64449
64581
|
if (data.length > MAX_READ_BYTES) {
|
|
64450
64582
|
throw Object.assign(new Error("write payload too large"), { code: "invalid_argument" });
|
|
@@ -64520,7 +64652,7 @@ var WorkspaceFsService = class {
|
|
|
64520
64652
|
for (const ent of ents) {
|
|
64521
64653
|
if (hits.length >= MAX_SEARCH_HITS) return;
|
|
64522
64654
|
if (ent.name === ".git" || ent.name === "node_modules") continue;
|
|
64523
|
-
const abs =
|
|
64655
|
+
const abs = join21(dir, ent.name);
|
|
64524
64656
|
const rel = relative2(root, abs).split("\\").join("/");
|
|
64525
64657
|
const check2 = resolveProjectPath(root, rel);
|
|
64526
64658
|
if (!check2.ok) continue;
|
|
@@ -64653,7 +64785,7 @@ var WorkspaceFsService = class {
|
|
|
64653
64785
|
code: "conflict"
|
|
64654
64786
|
});
|
|
64655
64787
|
}
|
|
64656
|
-
mkdirSync15(
|
|
64788
|
+
mkdirSync15(dirname12(to.absolutePath), { recursive: true });
|
|
64657
64789
|
renameSync3(from.absolutePath, to.absolutePath);
|
|
64658
64790
|
this.projects.touch(projectId);
|
|
64659
64791
|
return { from: fromN, to: toN };
|
|
@@ -64679,7 +64811,7 @@ function hashFileBounded(absolutePath, size) {
|
|
|
64679
64811
|
|
|
64680
64812
|
// src/workspace/git-service.ts
|
|
64681
64813
|
import { existsSync as existsSync31, mkdirSync as mkdirSync16, realpathSync as realpathSync5, rmSync as rmSync4, writeFileSync as writeFileSync11 } from "node:fs";
|
|
64682
|
-
import { join as
|
|
64814
|
+
import { join as join23, resolve as resolve10 } from "node:path";
|
|
64683
64815
|
import { tmpdir as tmpdir2 } from "node:os";
|
|
64684
64816
|
import { randomUUID as randomUUID8 } from "node:crypto";
|
|
64685
64817
|
|
|
@@ -64874,19 +65006,19 @@ function gitRunSync(folderPath, args, env) {
|
|
|
64874
65006
|
}
|
|
64875
65007
|
|
|
64876
65008
|
// ../../packages/runtime/src/git/worktree-plan.ts
|
|
64877
|
-
import { basename as basename3, dirname as
|
|
64878
|
-
import { homedir as
|
|
65009
|
+
import { basename as basename3, dirname as dirname13, join as join22, resolve as resolve9, sep as sep4 } from "node:path";
|
|
65010
|
+
import { homedir as homedir7 } from "node:os";
|
|
64879
65011
|
function resolveMainDirFromCommonDir(folderPath, gitCommonDir) {
|
|
64880
65012
|
const repoRoot = resolve9(folderPath, gitCommonDir.trim());
|
|
64881
|
-
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ?
|
|
65013
|
+
return repoRoot.endsWith(`${sep4}.git`) || repoRoot.endsWith("/.git") ? dirname13(repoRoot) : repoRoot;
|
|
64882
65014
|
}
|
|
64883
65015
|
function planNewWorktreePaths(input) {
|
|
64884
|
-
const home = input.homeDir ??
|
|
65016
|
+
const home = input.homeDir ?? homedir7();
|
|
64885
65017
|
const repoName = basename3(input.mainDir);
|
|
64886
65018
|
const epoch = Math.floor((input.nowMs ?? Date.now()) / 1e3).toString(36);
|
|
64887
65019
|
const short = input.shortHash.slice(0, 7);
|
|
64888
|
-
const wtDir =
|
|
64889
|
-
const wtPath =
|
|
65020
|
+
const wtDir = join22(home, ".worktrees", repoName);
|
|
65021
|
+
const wtPath = join22(wtDir, `${epoch}-${short}`);
|
|
64890
65022
|
return { wtDir, wtPath };
|
|
64891
65023
|
}
|
|
64892
65024
|
function worktreeAddArgs(mode, wtPath, baseRef, branchName) {
|
|
@@ -64978,7 +65110,7 @@ var WorkspaceGitService = class {
|
|
|
64978
65110
|
* --ignored walks the whole tree of ignored paths and dominates remote latency.
|
|
64979
65111
|
*/
|
|
64980
65112
|
statusForCwd(cwd) {
|
|
64981
|
-
if (!existsSync31(
|
|
65113
|
+
if (!existsSync31(join23(cwd, ".git")) && !isGitWorktree(cwd)) {
|
|
64982
65114
|
return { isRepo: false, branch: null, dirty: false, ahead: 0, behind: 0, porcelain: "" };
|
|
64983
65115
|
}
|
|
64984
65116
|
try {
|
|
@@ -65233,7 +65365,7 @@ var WorkspaceGitService = class {
|
|
|
65233
65365
|
const mainStatus = git(diff.mainDir, ["status", "--porcelain"]).trim();
|
|
65234
65366
|
if (mainStatus) return { ok: false, reason: "main-dirty" };
|
|
65235
65367
|
const patch = git(diff.worktreePath, ["diff", "--binary", diff.base, diff.tree]);
|
|
65236
|
-
const patchFile =
|
|
65368
|
+
const patchFile = join23(tmpdir2(), `s1-handoff-${randomUUID8()}.patch`);
|
|
65237
65369
|
writeFileSync11(patchFile, `${patch}
|
|
65238
65370
|
`);
|
|
65239
65371
|
if (git(diff.mainDir, ["status", "--porcelain"]).trim()) {
|
|
@@ -65295,7 +65427,7 @@ var WorkspaceGitService = class {
|
|
|
65295
65427
|
};
|
|
65296
65428
|
}
|
|
65297
65429
|
writeWorkingTree(worktreePath) {
|
|
65298
|
-
const tmpIndex =
|
|
65430
|
+
const tmpIndex = join23(tmpdir2(), `s1-handoff-${randomUUID8()}.index`);
|
|
65299
65431
|
const env = { GIT_INDEX_FILE: tmpIndex };
|
|
65300
65432
|
try {
|
|
65301
65433
|
git(worktreePath, ["read-tree", "HEAD"], env);
|
|
@@ -66503,7 +66635,7 @@ var CollaborationService = class {
|
|
|
66503
66635
|
|
|
66504
66636
|
// src/provider/secret-crypto.ts
|
|
66505
66637
|
import { existsSync as existsSync33, mkdirSync as mkdirSync17, readFileSync as readFileSync16, writeFileSync as writeFileSync12, chmodSync as chmodSync2 } from "node:fs";
|
|
66506
|
-
import { dirname as
|
|
66638
|
+
import { dirname as dirname14 } from "node:path";
|
|
66507
66639
|
import { createCipheriv, createDecipheriv, randomBytes as randomBytes5 } from "node:crypto";
|
|
66508
66640
|
var ENC_PREFIX = "enc:v1:";
|
|
66509
66641
|
var KEY_BYTES = 32;
|
|
@@ -66515,7 +66647,7 @@ function ensureKeyFile(keyPath) {
|
|
|
66515
66647
|
const raw = readFileSync16(keyPath);
|
|
66516
66648
|
if (raw.length === KEY_BYTES) return raw;
|
|
66517
66649
|
}
|
|
66518
|
-
mkdirSync17(
|
|
66650
|
+
mkdirSync17(dirname14(keyPath), { recursive: true, mode: 448 });
|
|
66519
66651
|
const key = randomBytes5(KEY_BYTES);
|
|
66520
66652
|
writeFileSync12(keyPath, key, { mode: 384 });
|
|
66521
66653
|
try {
|
|
@@ -66659,7 +66791,7 @@ var WorkspaceWatchService = class {
|
|
|
66659
66791
|
|
|
66660
66792
|
// src/workspace/tail-watch-service.ts
|
|
66661
66793
|
init_fs();
|
|
66662
|
-
import { existsSync as existsSync34, fstatSync as fstatSync2, openSync as openSync2, closeSync as closeSync2, statSync as statSync12 } from "node:fs";
|
|
66794
|
+
import { existsSync as existsSync34, fstatSync as fstatSync2, openSync as openSync2, closeSync as closeSync2, statSync as statSync12, readSync as readSync2, realpathSync as realpathSync6 } from "node:fs";
|
|
66663
66795
|
var MAX_POLL_BYTES = 10 * 1024 * 1024;
|
|
66664
66796
|
var WorkspaceTailWatchService = class {
|
|
66665
66797
|
constructor(projects, fs) {
|
|
@@ -66670,16 +66802,41 @@ var WorkspaceTailWatchService = class {
|
|
|
66670
66802
|
start(projectId, relativePath, opts) {
|
|
66671
66803
|
const project = this.projects.get(projectId);
|
|
66672
66804
|
if (!project) throw Object.assign(new Error("project not found"), { code: "not_found" });
|
|
66673
|
-
const
|
|
66674
|
-
|
|
66675
|
-
|
|
66676
|
-
|
|
66677
|
-
|
|
66678
|
-
|
|
66679
|
-
|
|
66680
|
-
|
|
66681
|
-
|
|
66682
|
-
|
|
66805
|
+
const absolutePath = typeof opts?.absolutePath === "string" && opts.absolutePath ? opts.absolutePath : void 0;
|
|
66806
|
+
let rel = "";
|
|
66807
|
+
let resolvedAbs = "";
|
|
66808
|
+
if (absolutePath) {
|
|
66809
|
+
if (!assertAgentTranscriptAbsolutePath(absolutePath)) {
|
|
66810
|
+
throw Object.assign(
|
|
66811
|
+
new Error("absolute tail watch is limited to agent transcript roots (~/.grok/sessions, ~/.claude/projects)"),
|
|
66812
|
+
{ code: "invalid_argument" }
|
|
66813
|
+
);
|
|
66814
|
+
}
|
|
66815
|
+
try {
|
|
66816
|
+
resolvedAbs = existsSync34(absolutePath) ? realpathSync6(absolutePath) : absolutePath;
|
|
66817
|
+
} catch {
|
|
66818
|
+
resolvedAbs = absolutePath;
|
|
66819
|
+
}
|
|
66820
|
+
if (!assertAgentTranscriptAbsolutePath(resolvedAbs)) {
|
|
66821
|
+
throw Object.assign(
|
|
66822
|
+
new Error("absolute tail watch resolved outside agent transcript roots"),
|
|
66823
|
+
{ code: "invalid_argument" }
|
|
66824
|
+
);
|
|
66825
|
+
}
|
|
66826
|
+
rel = absolutePath;
|
|
66827
|
+
} else {
|
|
66828
|
+
rel = normalizeProjectRelativePath(relativePath || "");
|
|
66829
|
+
if (!isToolOutputRelativePath(rel)) {
|
|
66830
|
+
throw Object.assign(
|
|
66831
|
+
new Error("tail watch is limited to project-relative paths under temp/"),
|
|
66832
|
+
{ code: "invalid_argument" }
|
|
66833
|
+
);
|
|
66834
|
+
}
|
|
66835
|
+
const resolved = resolveProjectPath(project.path, rel);
|
|
66836
|
+
if (!resolved.ok) {
|
|
66837
|
+
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
66838
|
+
}
|
|
66839
|
+
resolvedAbs = resolved.absolutePath;
|
|
66683
66840
|
}
|
|
66684
66841
|
let offset = opts?.offset ?? 0;
|
|
66685
66842
|
if (!Number.isSafeInteger(offset) || offset < 0) {
|
|
@@ -66687,9 +66844,9 @@ var WorkspaceTailWatchService = class {
|
|
|
66687
66844
|
code: "invalid_argument"
|
|
66688
66845
|
});
|
|
66689
66846
|
}
|
|
66690
|
-
if (existsSync34(
|
|
66847
|
+
if (existsSync34(resolvedAbs)) {
|
|
66691
66848
|
try {
|
|
66692
|
-
const st = statSync12(
|
|
66849
|
+
const st = statSync12(resolvedAbs);
|
|
66693
66850
|
if (!st.isFile()) {
|
|
66694
66851
|
throw Object.assign(new Error("not a file"), { code: "invalid_argument" });
|
|
66695
66852
|
}
|
|
@@ -66702,12 +66859,19 @@ var WorkspaceTailWatchService = class {
|
|
|
66702
66859
|
const watchId = crypto.randomUUID();
|
|
66703
66860
|
this.entries.set(watchId, {
|
|
66704
66861
|
projectId,
|
|
66705
|
-
relativePath: rel,
|
|
66862
|
+
relativePath: absolutePath ? "" : rel,
|
|
66863
|
+
// Store resolved path so poll opens the verified target, not a swapped symlink.
|
|
66864
|
+
...absolutePath ? { absolutePath: resolvedAbs } : {},
|
|
66706
66865
|
offset,
|
|
66707
66866
|
owner: opts?.ownerClientId ?? ""
|
|
66708
66867
|
});
|
|
66709
66868
|
this.projects.touch(projectId);
|
|
66710
|
-
return {
|
|
66869
|
+
return {
|
|
66870
|
+
watchId,
|
|
66871
|
+
offset,
|
|
66872
|
+
relativePath: absolutePath ? "" : rel,
|
|
66873
|
+
...absolutePath ? { absolutePath: resolvedAbs } : {}
|
|
66874
|
+
};
|
|
66711
66875
|
}
|
|
66712
66876
|
poll(watchId, ownerClientId) {
|
|
66713
66877
|
const entry = this.entries.get(watchId);
|
|
@@ -66718,11 +66882,20 @@ var WorkspaceTailWatchService = class {
|
|
|
66718
66882
|
if (!project) {
|
|
66719
66883
|
throw Object.assign(new Error("project not found"), { code: "not_found" });
|
|
66720
66884
|
}
|
|
66721
|
-
|
|
66722
|
-
if (!
|
|
66723
|
-
|
|
66885
|
+
let absolutePath = entry.absolutePath;
|
|
66886
|
+
if (!absolutePath) {
|
|
66887
|
+
const resolved = resolveProjectPath(project.path, entry.relativePath);
|
|
66888
|
+
if (!resolved.ok) {
|
|
66889
|
+
throw Object.assign(new Error(resolved.reason), { code: "invalid_argument" });
|
|
66890
|
+
}
|
|
66891
|
+
absolutePath = resolved.absolutePath;
|
|
66892
|
+
} else if (!assertAgentTranscriptAbsolutePath(absolutePath)) {
|
|
66893
|
+
throw Object.assign(
|
|
66894
|
+
new Error("absolute tail watch resolved outside agent transcript roots"),
|
|
66895
|
+
{ code: "invalid_argument" }
|
|
66896
|
+
);
|
|
66724
66897
|
}
|
|
66725
|
-
if (!existsSync34(
|
|
66898
|
+
if (!existsSync34(absolutePath)) {
|
|
66726
66899
|
return {
|
|
66727
66900
|
content: "",
|
|
66728
66901
|
encoding: "base64",
|
|
@@ -66733,7 +66906,7 @@ var WorkspaceTailWatchService = class {
|
|
|
66733
66906
|
}
|
|
66734
66907
|
let size = 0;
|
|
66735
66908
|
try {
|
|
66736
|
-
const fd = openSync2(
|
|
66909
|
+
const fd = openSync2(absolutePath, "r");
|
|
66737
66910
|
try {
|
|
66738
66911
|
size = fstatSync2(fd).size;
|
|
66739
66912
|
} finally {
|
|
@@ -66755,14 +66928,27 @@ var WorkspaceTailWatchService = class {
|
|
|
66755
66928
|
return { content: "", encoding: "base64", offset: entry.offset, size };
|
|
66756
66929
|
}
|
|
66757
66930
|
const toRead = Math.min(MAX_POLL_BYTES, size - entry.offset);
|
|
66758
|
-
|
|
66759
|
-
|
|
66760
|
-
|
|
66761
|
-
|
|
66931
|
+
let contentB64;
|
|
66932
|
+
if (entry.absolutePath) {
|
|
66933
|
+
const buf = Buffer.alloc(toRead);
|
|
66934
|
+
const fd = openSync2(absolutePath, "r");
|
|
66935
|
+
try {
|
|
66936
|
+
const n = readSync2(fd, buf, 0, toRead, entry.offset);
|
|
66937
|
+
contentB64 = buf.subarray(0, n).toString("base64");
|
|
66938
|
+
} finally {
|
|
66939
|
+
closeSync2(fd);
|
|
66940
|
+
}
|
|
66941
|
+
} else {
|
|
66942
|
+
const slice = this.fs.readFile(entry.projectId, entry.relativePath, {
|
|
66943
|
+
offset: entry.offset,
|
|
66944
|
+
limit: toRead
|
|
66945
|
+
});
|
|
66946
|
+
contentB64 = slice.content;
|
|
66947
|
+
}
|
|
66762
66948
|
entry.offset = entry.offset + toRead;
|
|
66763
66949
|
this.projects.touch(entry.projectId);
|
|
66764
66950
|
return {
|
|
66765
|
-
content:
|
|
66951
|
+
content: contentB64,
|
|
66766
66952
|
encoding: "base64",
|
|
66767
66953
|
offset: entry.offset,
|
|
66768
66954
|
size
|
|
@@ -79693,7 +79879,7 @@ function readRuntimeStatus(nodeHome) {
|
|
|
79693
79879
|
// src/systemd/install.ts
|
|
79694
79880
|
import { spawnSync as spawnSync2 } from "node:child_process";
|
|
79695
79881
|
import { chmodSync as chmodSync3, existsSync as existsSync36, mkdirSync as mkdirSync18, unlinkSync as unlinkSync2, writeFileSync as writeFileSync14 } from "node:fs";
|
|
79696
|
-
import { dirname as
|
|
79882
|
+
import { dirname as dirname15 } from "node:path";
|
|
79697
79883
|
|
|
79698
79884
|
// src/systemd/unit.ts
|
|
79699
79885
|
function renderSystemdUserUnit(opts) {
|
|
@@ -79750,7 +79936,7 @@ function checkLinger(user) {
|
|
|
79750
79936
|
return { enabled: null, raw };
|
|
79751
79937
|
}
|
|
79752
79938
|
function writeSystemdUserUnit(opts, unitPath = systemdUserUnitPath()) {
|
|
79753
|
-
mkdirSync18(
|
|
79939
|
+
mkdirSync18(dirname15(unitPath), { recursive: true });
|
|
79754
79940
|
writeFileSync14(unitPath, renderSystemdUserUnit(opts), { encoding: "utf8", mode: 420 });
|
|
79755
79941
|
try {
|
|
79756
79942
|
chmodSync3(unitPath, 420);
|
|
@@ -79827,9 +80013,9 @@ function systemdUserStatus() {
|
|
|
79827
80013
|
|
|
79828
80014
|
// src/session/harness-cli.ts
|
|
79829
80015
|
init_environment();
|
|
79830
|
-
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync37, realpathSync as
|
|
80016
|
+
import { accessSync as accessSync2, constants as constants2, existsSync as existsSync37, realpathSync as realpathSync7, statSync as statSync13 } from "node:fs";
|
|
79831
80017
|
import { isAbsolute as isAbsolute4, resolve as resolve11 } from "node:path";
|
|
79832
|
-
import { homedir as
|
|
80018
|
+
import { homedir as homedir8 } from "node:os";
|
|
79833
80019
|
var DEFERRED_FLAGS = /* @__PURE__ */ new Set([
|
|
79834
80020
|
"--env-file",
|
|
79835
80021
|
"--server-password-stdin",
|
|
@@ -80345,7 +80531,7 @@ function resolveExternalCommand2(explicit, pathCandidates) {
|
|
|
80345
80531
|
}
|
|
80346
80532
|
const pathEnv = process.env.PATH || "";
|
|
80347
80533
|
const dirs = pathEnv.split(":").filter(Boolean);
|
|
80348
|
-
const home = process.env.HOME ||
|
|
80534
|
+
const home = process.env.HOME || homedir8();
|
|
80349
80535
|
const extra = [
|
|
80350
80536
|
`${home}/.local/bin`,
|
|
80351
80537
|
`${home}/.npm-global/bin`,
|
|
@@ -80376,7 +80562,7 @@ function isUsableExecutable(path) {
|
|
|
80376
80562
|
return null;
|
|
80377
80563
|
}
|
|
80378
80564
|
try {
|
|
80379
|
-
return
|
|
80565
|
+
return realpathSync7(path);
|
|
80380
80566
|
} catch {
|
|
80381
80567
|
return path;
|
|
80382
80568
|
}
|
|
@@ -80744,7 +80930,7 @@ async function main() {
|
|
|
80744
80930
|
const result = installSystemdUserService({
|
|
80745
80931
|
execStart: `${process.execPath} ${execStart}`,
|
|
80746
80932
|
nodeHome,
|
|
80747
|
-
home: process.env.HOME ||
|
|
80933
|
+
home: process.env.HOME || homedir9(),
|
|
80748
80934
|
bindHost: host,
|
|
80749
80935
|
bindPort: port
|
|
80750
80936
|
});
|
package/package.json
CHANGED