@reasontrail/cli 0.1.3 → 0.1.5
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/CHANGELOG.md +15 -0
- package/README.md +90 -2
- package/package.json +1 -1
- package/runtime/reasontrail-credential-broker.mjs +43419 -0
- package/runtime/reasontrail-credential-broker.mjs.sha256 +1 -0
- package/runtime/reasontrail-runtime.mjs +1 -1
- package/runtime/reasontrail-runtime.mjs.sha256 +1 -1
- package/skills/reasontrail/SKILL.md +35 -0
- package/src/build-info.json +1 -1
- package/src/cli.mjs +138 -26
- package/src/codex-sync.mjs +3 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ac2db95959683af8d18bdd4e0544cf027e4b7e7578252f9b266301c12d92306a reasontrail-credential-broker.mjs
|
|
@@ -22761,7 +22761,7 @@ var POLL_IDLE_MS = 5e3;
|
|
|
22761
22761
|
var POLL_BACKOFF_MAX_MS = 6e4;
|
|
22762
22762
|
var HEARTBEAT_MS = 3e4;
|
|
22763
22763
|
var RUNTIME_VERSION = "0.3.3";
|
|
22764
|
-
var RUNTIME_SOURCE_SHA = true ? "
|
|
22764
|
+
var RUNTIME_SOURCE_SHA = true ? "94fcd4782ad73dd42e232665da7f1b9d2e4d6350" : "development";
|
|
22765
22765
|
var RUNTIME_PROTOCOL_VERSION = 3;
|
|
22766
22766
|
async function dependencyNetworkPreflight(policy) {
|
|
22767
22767
|
if (policy !== "public") return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
03073358141704852517d933e17cda384d5a9c358d92e13b12584741df9c0804 reasontrail-runtime.mjs
|
|
@@ -74,6 +74,25 @@ that transcript source as unavailable and request the binding or access needed.
|
|
|
74
74
|
A summary-only project update may still follow the normal governance policy,
|
|
75
75
|
but it is not evidence that any Conversation messages were synchronized.
|
|
76
76
|
|
|
77
|
+
When the user says **"update my brain"** or explicitly asks for the **full
|
|
78
|
+
conversation**, the intended result is that the complete visible conversation
|
|
79
|
+
through the current checkpoint exists in ReasonTrail, not merely a summary or
|
|
80
|
+
the latest exchange. First inspect the native source and compare it with the
|
|
81
|
+
durable ReasonTrail cursor. Preserve the same native session and Conversation
|
|
82
|
+
identity; send only missing visible user/assistant turns after the cursor, so
|
|
83
|
+
earlier turns remain part of the complete transcript without being duplicated.
|
|
84
|
+
For Codex Desktop, use the authorized Codex app transcript reader when exposed
|
|
85
|
+
and page until the source reports no more turns. Include original visible
|
|
86
|
+
messages and stable source ids; exclude hidden reasoning and tool internals.
|
|
87
|
+
If the source exposes more turns than one MCP call accepts, use the supported
|
|
88
|
+
delta/chunk workflow under that same identity. Do not split one session into
|
|
89
|
+
new synthetic conversations or use `save_conversation` fragments to evade a
|
|
90
|
+
limit. Do not fall back to a summary when the native transcript is readable.
|
|
91
|
+
If identity, cursor, or coverage cannot be reconciled, stop the transcript
|
|
92
|
+
write, report the exact blocker, and keep any separately authorized project
|
|
93
|
+
summary clearly labeled as summary-only. Report measured source coverage and
|
|
94
|
+
persisted counts; never claim COMPLETE from a successful tool response alone.
|
|
95
|
+
|
|
77
96
|
## Context
|
|
78
97
|
|
|
79
98
|
For substantive work on an associated repository—implementation, debugging,
|
|
@@ -99,6 +118,7 @@ Treat **"update my brain"** as the primary request to synchronize the current
|
|
|
99
118
|
session. Equivalent phrases include:
|
|
100
119
|
|
|
101
120
|
- "update ReasonTrail"
|
|
121
|
+
- "update to ReasonTrail"
|
|
102
122
|
- "sync this session"
|
|
103
123
|
- "save what we've done"
|
|
104
124
|
- "update project memory"
|
|
@@ -108,6 +128,21 @@ For this intent:
|
|
|
108
128
|
1. Resolve the actual host-native session identity through the authorized
|
|
109
129
|
capture adapter, then inspect only that mapped session. Never guess the
|
|
110
130
|
identity or derive the transcript from the current model context.
|
|
131
|
+
Transcript-bearing MCP calls are fail-closed: if a call includes `userRequest`,
|
|
132
|
+
`turns` or complete `messages`, set `captureMode`. Use `MANUAL` only when the
|
|
133
|
+
user explicitly requested a sync, and `AUTOMATIC` only after the policy check
|
|
134
|
+
below. For ordinary task tracking, omit transcript fields and use metadata only.
|
|
135
|
+
Respect the user's per-project capture choice. Manual-only capture requires
|
|
136
|
+
an explicit sync command; automatic capture requires the project-managed
|
|
137
|
+
service to be enabled and verified. An MCP connection alone is not consent
|
|
138
|
+
or proof that automatic capture is active. A manual command never turns on
|
|
139
|
+
background capture.
|
|
140
|
+
Before an automatic adapter reads or sends native transcript turns, call
|
|
141
|
+
`get_conversation_capture_policy` with the exact project slug. Continue only
|
|
142
|
+
when the current member's project setting returns `automaticEnabled: true`,
|
|
143
|
+
and mark previews and writes as `captureMode: "AUTOMATIC"`. If the tool is
|
|
144
|
+
unavailable or the preference is off, do not inspect or send the transcript;
|
|
145
|
+
an explicit user-requested sync remains `captureMode: "MANUAL"`.
|
|
111
146
|
2. Determine the original visible user/assistant delta since the last
|
|
112
147
|
successful ReasonTrail sync. Use the last returned sync cursor when
|
|
113
148
|
available. Never include hidden reasoning.
|
package/src/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"sourceRevision":"
|
|
1
|
+
{"sourceRevision":"94fcd4782ad73dd42e232665da7f1b9d2e4d6350"}
|
package/src/cli.mjs
CHANGED
|
@@ -69,13 +69,17 @@ function commandExists(name) {
|
|
|
69
69
|
return spawnSync("sh", ["-c", `command -v ${name}`], { stdio: "ignore" }).status === 0;
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
function osCredentialStoreEnabled() {
|
|
73
|
+
return !(process.env.NODE_ENV === "test" && process.env.REASONTRAIL_TEST_DISABLE_OS_CREDENTIAL_STORE === "1");
|
|
74
|
+
}
|
|
75
|
+
|
|
72
76
|
async function loadCredential(profile) {
|
|
73
77
|
const paths = profilePaths(profile);
|
|
74
|
-
if (process.platform === "darwin" && commandExists("security")) {
|
|
78
|
+
if (osCredentialStoreEnabled() && process.platform === "darwin" && commandExists("security")) {
|
|
75
79
|
const found = spawnSync("security", ["find-generic-password", "-s", KEYCHAIN_SERVICE, "-a", profile, "-w"], { encoding: "utf8" });
|
|
76
80
|
if (found.status === 0 && found.stdout.trim()) return { token: found.stdout.trim(), source: "macOS Keychain" };
|
|
77
81
|
}
|
|
78
|
-
if (process.platform === "linux" && commandExists("secret-tool")) {
|
|
82
|
+
if (osCredentialStoreEnabled() && process.platform === "linux" && commandExists("secret-tool")) {
|
|
79
83
|
const found = spawnSync("secret-tool", ["lookup", "service", KEYCHAIN_SERVICE, "account", profile], { encoding: "utf8" });
|
|
80
84
|
if (found.status === 0 && found.stdout.trim()) return { token: found.stdout.trim(), source: "Secret Service" };
|
|
81
85
|
}
|
|
@@ -87,12 +91,18 @@ async function loadCredential(profile) {
|
|
|
87
91
|
async function storeCredential(profile, token) {
|
|
88
92
|
const paths = profilePaths(profile);
|
|
89
93
|
if (!token.startsWith("rtmcp_")) throw new CliError("That is not a ReasonTrail MCP access token.", 2);
|
|
90
|
-
if (process.platform === "darwin" && commandExists("security")) {
|
|
91
|
-
|
|
94
|
+
if (osCredentialStoreEnabled() && process.platform === "darwin" && commandExists("security")) {
|
|
95
|
+
// Keep the bearer token out of argv. macOS security(1) reads it from
|
|
96
|
+
// stdin when `-w` is the final argument and prompts twice on creation.
|
|
97
|
+
const stored = spawnSync(
|
|
98
|
+
"security",
|
|
99
|
+
["add-generic-password", "-U", "-s", KEYCHAIN_SERVICE, "-a", profile, "-w"],
|
|
100
|
+
{ input: `${token}\n${token}\n`, encoding: "utf8" },
|
|
101
|
+
);
|
|
92
102
|
if (stored.status !== 0) throw new CliError(stored.stderr.trim() || "Could not store the credential in macOS Keychain.");
|
|
93
103
|
return "macOS Keychain";
|
|
94
104
|
}
|
|
95
|
-
if (process.platform === "linux" && commandExists("secret-tool")) {
|
|
105
|
+
if (osCredentialStoreEnabled() && process.platform === "linux" && commandExists("secret-tool")) {
|
|
96
106
|
const stored = spawnSync("secret-tool", ["store", "--label", `ReasonTrail CLI (${profile})`, "service", KEYCHAIN_SERVICE, "account", profile], { input: token, encoding: "utf8" });
|
|
97
107
|
if (stored.status !== 0) throw new CliError(stored.stderr.trim() || "Could not store the credential in Secret Service.");
|
|
98
108
|
return "Secret Service";
|
|
@@ -104,11 +114,11 @@ async function storeCredential(profile, token) {
|
|
|
104
114
|
async function removeCredential(profile) {
|
|
105
115
|
const paths = profilePaths(profile);
|
|
106
116
|
const removed = [];
|
|
107
|
-
if (process.platform === "darwin" && commandExists("security")) {
|
|
117
|
+
if (osCredentialStoreEnabled() && process.platform === "darwin" && commandExists("security")) {
|
|
108
118
|
const result = spawnSync("security", ["delete-generic-password", "-s", KEYCHAIN_SERVICE, "-a", profile], { encoding: "utf8" });
|
|
109
119
|
if (result.status === 0) removed.push("macOS Keychain");
|
|
110
120
|
}
|
|
111
|
-
if (process.platform === "linux" && commandExists("secret-tool")) {
|
|
121
|
+
if (osCredentialStoreEnabled() && process.platform === "linux" && commandExists("secret-tool")) {
|
|
112
122
|
const result = spawnSync("secret-tool", ["clear", "service", KEYCHAIN_SERVICE, "account", profile], { encoding: "utf8" });
|
|
113
123
|
if (result.status === 0) removed.push("Secret Service");
|
|
114
124
|
}
|
|
@@ -621,10 +631,21 @@ async function getStatus(target) {
|
|
|
621
631
|
}
|
|
622
632
|
const hooksInstalled = await claudeHooksInstalled(target.profile);
|
|
623
633
|
const codexSyncState = await readSyncState(target.paths.dir);
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
634
|
+
let capturePolicy = { automaticEnabled: false, status: "unavailable" };
|
|
635
|
+
if (projectBound && binding?.projectSlug && hasTool(tools, "get_conversation_capture_policy")) {
|
|
636
|
+
try {
|
|
637
|
+
const policy = await client.call("get_conversation_capture_policy", { projectSlug: binding.projectSlug });
|
|
638
|
+
capturePolicy = { automaticEnabled: policy?.automaticEnabled === true, status: "available" };
|
|
639
|
+
} catch (error) {
|
|
640
|
+
capturePolicy = { automaticEnabled: false, status: "error", error: String(error?.message || error).slice(0, 200) };
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const codexSessions = capturePolicy.automaticEnabled
|
|
644
|
+
? await discoverAndMapCodexSessions({
|
|
645
|
+
codexHome: defaultCodexHome(),
|
|
646
|
+
bindings: target.cfg.bindings || {},
|
|
647
|
+
}).catch(() => [])
|
|
648
|
+
: [];
|
|
628
649
|
const codexMapped = codexSessions.filter((s) => s.mapped);
|
|
629
650
|
const codexPending = codexMapped.filter((s) => {
|
|
630
651
|
const prev = codexSyncState.sessions?.[s.threadId];
|
|
@@ -653,14 +674,19 @@ async function getStatus(target) {
|
|
|
653
674
|
conversation_connector: projectBound
|
|
654
675
|
? (hooksInstalled ? "Claude Code Hooks; Codex Local Session Sync" : "Codex Local Session Sync")
|
|
655
676
|
: "none",
|
|
656
|
-
automatic_transcript_sync:
|
|
677
|
+
automatic_transcript_sync: !capturePolicy.automaticEnabled
|
|
678
|
+
? capturePolicy.status === "available" ? "disabled_by_project_preference" : `policy_${capturePolicy.status}`
|
|
679
|
+
: managedCapture.active ? "active_managed_capture" : "preference_enabled_service_inactive",
|
|
680
|
+
conversation_capture_policy: capturePolicy,
|
|
657
681
|
managed_capture_service: managedCapture,
|
|
658
682
|
codex_desktop: {
|
|
659
683
|
brain_access: codexMcp ? "connected" : "not_configured",
|
|
660
684
|
workspace: root,
|
|
661
685
|
repository: normalizedRepositoryUrl(gitRemote(root)),
|
|
662
686
|
project: projectBound ? binding.projectSlug : null,
|
|
663
|
-
capture_mechanism:
|
|
687
|
+
capture_mechanism: !capturePolicy.automaticEnabled
|
|
688
|
+
? "automatic capture off for project; explicit sync remains available"
|
|
689
|
+
: managedCapture.active ? "managed capture service" : "preference enabled; managed service inactive",
|
|
664
690
|
session_store: join(defaultCodexHome(), "sessions"),
|
|
665
691
|
mcp_configured: codexMcp,
|
|
666
692
|
skill_installed: codexSkill,
|
|
@@ -1179,14 +1205,37 @@ async function syncCommand(argv) {
|
|
|
1179
1205
|
return client.call(tool, { ...(project ? { projectSlug: project } : {}), syncMode: "MANUAL" });
|
|
1180
1206
|
}
|
|
1181
1207
|
if (sub === "managed") {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1208
|
+
let capturePolicy = { automaticEnabled: false, status: "unavailable" };
|
|
1209
|
+
if (project && hasTool(tools, "get_conversation_capture_policy")) {
|
|
1210
|
+
try {
|
|
1211
|
+
const policy = await client.call("get_conversation_capture_policy", { projectSlug: project });
|
|
1212
|
+
capturePolicy = { automaticEnabled: policy?.automaticEnabled === true, status: "available" };
|
|
1213
|
+
} catch (error) {
|
|
1214
|
+
capturePolicy = { automaticEnabled: false, status: "error", error: String(error?.message || error).slice(0, 200) };
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
const codex = capturePolicy.automaticEnabled
|
|
1218
|
+
? await syncCodex(client, tools, target.paths.dir, target.cfg, {
|
|
1219
|
+
dryRun: !apply,
|
|
1220
|
+
managed: true,
|
|
1221
|
+
since: opts.since || null,
|
|
1222
|
+
project,
|
|
1223
|
+
session: opts.session || null,
|
|
1224
|
+
force: Boolean(opts.force),
|
|
1225
|
+
captureMode: "AUTOMATIC",
|
|
1226
|
+
})
|
|
1227
|
+
: {
|
|
1228
|
+
synchronized: false,
|
|
1229
|
+
dry_run: !apply,
|
|
1230
|
+
automatic_capture: "disabled",
|
|
1231
|
+
skipped_reason: capturePolicy.status === "available"
|
|
1232
|
+
? "automatic_capture_disabled_for_project"
|
|
1233
|
+
: `capture_policy_${capturePolicy.status}`,
|
|
1234
|
+
error: capturePolicy.error || null,
|
|
1235
|
+
sessions_discovered: 0,
|
|
1236
|
+
sessions_mapped: 0,
|
|
1237
|
+
eligible_for_import: 0,
|
|
1238
|
+
};
|
|
1190
1239
|
let docs = null;
|
|
1191
1240
|
const docsTool = apply ? "sync_docs" : "preview_docs_reconciliation";
|
|
1192
1241
|
if (hasTool(tools, docsTool)) {
|
|
@@ -1201,7 +1250,7 @@ async function syncCommand(argv) {
|
|
|
1201
1250
|
throw new Error(`Repository Resource synchronization was partial: ${detail}`);
|
|
1202
1251
|
}
|
|
1203
1252
|
}
|
|
1204
|
-
const result = { synchronized: apply, dry_run: !apply, codex, docs };
|
|
1253
|
+
const result = { synchronized: apply, dry_run: !apply, conversation_capture_policy: capturePolicy, codex, docs };
|
|
1205
1254
|
if (apply) {
|
|
1206
1255
|
await recordManagedHeartbeat(target, project, {
|
|
1207
1256
|
service: managedServiceIdentity(target, project).service,
|
|
@@ -1211,6 +1260,7 @@ async function syncCommand(argv) {
|
|
|
1211
1260
|
lastSuccessAt: new Date().toISOString(),
|
|
1212
1261
|
lastError: null,
|
|
1213
1262
|
codex,
|
|
1263
|
+
conversationCapturePolicy: capturePolicy,
|
|
1214
1264
|
docs,
|
|
1215
1265
|
});
|
|
1216
1266
|
}
|
|
@@ -1533,10 +1583,13 @@ async function claudeHookCommandUnsafe(argv) {
|
|
|
1533
1583
|
if (!eventCwd) throw new CliError("WORKSPACE UNBOUND: Claude hook payload did not include cwd; automatic capture is disabled.", 2, { kind: "workspace_unbound" });
|
|
1534
1584
|
const { root, binding } = await bindingFor(target, eventCwd);
|
|
1535
1585
|
if (!binding?.projectSlug) throw new CliError(`WORKSPACE UNBOUND: ${root}`, 2, { kind: "workspace_unbound" });
|
|
1586
|
+
const { client, tools } = await connected(target);
|
|
1587
|
+
if (!hasTool(tools, "get_conversation_capture_policy")) return;
|
|
1588
|
+
const capturePolicy = await client.call("get_conversation_capture_policy", { projectSlug: binding.projectSlug });
|
|
1589
|
+
if (capturePolicy?.automaticEnabled !== true) return;
|
|
1536
1590
|
const stateDir = join(target.paths.connectors, "claude");
|
|
1537
1591
|
const stateFile = join(stateDir, `${createHash("sha256").update(session).digest("hex")}.json`);
|
|
1538
1592
|
const state = await readJson(stateFile, { session, clientConversationId: `claude:${session}`, turns: [], started: false, completed: false });
|
|
1539
|
-
const { client, tools } = await connected(target);
|
|
1540
1593
|
const project = { projectSlug: binding.projectSlug };
|
|
1541
1594
|
const now = new Date().toISOString();
|
|
1542
1595
|
const text = (value) => typeof value === "string" ? value.trim() : "";
|
|
@@ -1545,12 +1598,12 @@ async function claudeHookCommandUnsafe(argv) {
|
|
|
1545
1598
|
client.turnId = eventId;
|
|
1546
1599
|
async function sync(turns) {
|
|
1547
1600
|
if (!turns.length || !hasTool(tools, "sync_conversation_delta")) return;
|
|
1548
|
-
const result = await client.call("sync_conversation_delta", { clientConversationId: state.clientConversationId, turns, ...project });
|
|
1601
|
+
const result = await client.call("sync_conversation_delta", { clientConversationId: state.clientConversationId, captureMode: "AUTOMATIC", turns, ...project });
|
|
1549
1602
|
state.lastSyncAt = now; state.cursor = result?.lastSyncedMessageId || result?.lastSyncedMessageId === null ? result.lastSyncedMessageId : state.cursor;
|
|
1550
1603
|
await saveJson(stateFile, state);
|
|
1551
1604
|
}
|
|
1552
1605
|
if (name === "SessionStart" && !state.started) {
|
|
1553
|
-
await client.call("begin_task", { taskTitle: text(event.task_title || event.prompt || "Claude Code session") || "Claude Code session", userRequest: text(event.prompt), messageId: `${eventId}:start`, clientConversationId: state.clientConversationId, timestamp: now, ...project });
|
|
1606
|
+
await client.call("begin_task", { taskTitle: text(event.task_title || event.prompt || "Claude Code session") || "Claude Code session", userRequest: text(event.prompt), messageId: `${eventId}:start`, clientConversationId: state.clientConversationId, timestamp: now, captureMode: "AUTOMATIC", ...project });
|
|
1554
1607
|
state.started = true; await saveJson(stateFile, state);
|
|
1555
1608
|
} else if (name === "UserPromptSubmit") {
|
|
1556
1609
|
const content = text(event.prompt || event.user_prompt || event.message);
|
|
@@ -1611,6 +1664,8 @@ async function claudeHookCommand(argv) {
|
|
|
1611
1664
|
*/
|
|
1612
1665
|
const RUNTIME_BUNDLE = join(PACKAGE_ROOT, "runtime", "reasontrail-runtime.mjs");
|
|
1613
1666
|
const RUNTIME_CHECKSUM = `${RUNTIME_BUNDLE}.sha256`;
|
|
1667
|
+
const BROKER_BUNDLE = join(PACKAGE_ROOT, "runtime", "reasontrail-credential-broker.mjs");
|
|
1668
|
+
const BROKER_CHECKSUM = `${BROKER_BUNDLE}.sha256`;
|
|
1614
1669
|
|
|
1615
1670
|
async function runtimeBundleIntegrity() {
|
|
1616
1671
|
let bundle;
|
|
@@ -1630,6 +1685,24 @@ async function runtimeBundleIntegrity() {
|
|
|
1630
1685
|
return { state: actual === expected ? "verified" : "mismatch", expected, actual };
|
|
1631
1686
|
}
|
|
1632
1687
|
|
|
1688
|
+
async function brokerBundleIntegrity() {
|
|
1689
|
+
let bundle;
|
|
1690
|
+
let checksum;
|
|
1691
|
+
try {
|
|
1692
|
+
[bundle, checksum] = await Promise.all([
|
|
1693
|
+
readFile(BROKER_BUNDLE),
|
|
1694
|
+
readFile(BROKER_CHECKSUM, "utf8"),
|
|
1695
|
+
]);
|
|
1696
|
+
} catch (error) {
|
|
1697
|
+
if (error?.code === "ENOENT") return { state: "missing" };
|
|
1698
|
+
throw new CliError(`Could not verify the credential-broker bundle: ${error.message}`);
|
|
1699
|
+
}
|
|
1700
|
+
const expected = checksum.trim().split(/\s+/)[0]?.toLowerCase();
|
|
1701
|
+
if (!/^[0-9a-f]{64}$/.test(expected || "")) return { state: "invalid-checksum" };
|
|
1702
|
+
const actual = createHash("sha256").update(bundle).digest("hex");
|
|
1703
|
+
return { state: actual === expected ? "verified" : "mismatch", expected, actual };
|
|
1704
|
+
}
|
|
1705
|
+
|
|
1633
1706
|
async function runtimeConfig(profile) {
|
|
1634
1707
|
return readJson(profilePaths(profile).runtime, null);
|
|
1635
1708
|
}
|
|
@@ -1772,6 +1845,39 @@ async function runtimeCommand(argv) {
|
|
|
1772
1845
|
throw new CliError(`Unknown runtime command '${sub}'.\n\n` + runtimeUsage(), 2);
|
|
1773
1846
|
}
|
|
1774
1847
|
|
|
1848
|
+
function brokerUsage() {
|
|
1849
|
+
return (
|
|
1850
|
+
`Usage: reasontrail broker <command> --profile <development|production>\n\n` +
|
|
1851
|
+
` enroll --label <name> --allow-software-key\n` +
|
|
1852
|
+
` Enroll this user device in the explicitly weaker software-key tier\n` +
|
|
1853
|
+
` devices List this user's enrolled broker devices\n` +
|
|
1854
|
+
` store --project <slug> --name <label> --kind <kind> [--payload-stdin]\n` +
|
|
1855
|
+
` Encrypt locally to this device before upload (managers only on software-key devices)\n` +
|
|
1856
|
+
` migrate --project <slug> --secret <id> --version <number> --acknowledge-one-way-device-migration\n` +
|
|
1857
|
+
` One-way manager migration to this device\n` +
|
|
1858
|
+
` share --project <slug> --secret <id> --target-device <id>\n` +
|
|
1859
|
+
` Re-encrypt for another verified device\n` +
|
|
1860
|
+
` revoke Revoke this device and remove its local key\n` +
|
|
1861
|
+
` mcp Serve approved fixed operations over local MCP\n`
|
|
1862
|
+
);
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
async function brokerCommand(argv) {
|
|
1866
|
+
const sub = argv[0];
|
|
1867
|
+
if (!sub || sub === "help" || sub === "--help") return stdout.write(brokerUsage());
|
|
1868
|
+
await resolveTarget(argv.slice(1), { allowMissing: false, confirm: true });
|
|
1869
|
+
const integrity = await brokerBundleIntegrity();
|
|
1870
|
+
if (integrity.state === "missing") {
|
|
1871
|
+
throw new CliError(`The credential-broker bundle or checksum is missing from this installation (${BROKER_BUNDLE}). Reinstall the CLI.`);
|
|
1872
|
+
}
|
|
1873
|
+
if (integrity.state !== "verified") {
|
|
1874
|
+
throw new CliError(`The credential-broker bundle failed its integrity check (${integrity.state}). Reinstall the CLI before using project credentials.`);
|
|
1875
|
+
}
|
|
1876
|
+
const result = spawnSync(process.execPath, [BROKER_BUNDLE, sub, ...argv.slice(1)], { stdio: "inherit" });
|
|
1877
|
+
if (result.error) throw new CliError(`Could not start the credential broker: ${result.error.message}`);
|
|
1878
|
+
process.exitCode = result.status ?? 0;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1775
1881
|
function helpCommand() {
|
|
1776
1882
|
stdout.write(`ReasonTrail CLI ${VERSION}\n\n` +
|
|
1777
1883
|
`Usage: reasontrail <command> --profile <development|production>\n\n` +
|
|
@@ -1797,16 +1903,21 @@ function helpCommand() {
|
|
|
1797
1903
|
` hook claude Receive a Claude Code lifecycle hook event\n` +
|
|
1798
1904
|
` config endpoint <url> --profile <profile> Configure an isolated named profile\n` +
|
|
1799
1905
|
` runtime enroll|start|status|logout ReasonTrail Runtime on this machine\n` +
|
|
1906
|
+
` broker enroll|devices|store|migrate|share|revoke|mcp Local approved credential operations\n` +
|
|
1800
1907
|
` upgrade Reserved until signed releases exist\n`);
|
|
1801
1908
|
}
|
|
1802
1909
|
|
|
1803
1910
|
async function main() {
|
|
1804
1911
|
const [command, ...argv] = process.argv.slice(2);
|
|
1805
|
-
|
|
1912
|
+
// `broker migrate --version <number>` names the credential version. Keep
|
|
1913
|
+
// that subcommand-owned option out of the CLI-wide executable-version path.
|
|
1914
|
+
const brokerMigration = command === "broker" && argv[0] === "migrate";
|
|
1915
|
+
if (command === "--version" || command === "-v" || (!brokerMigration && (argv.includes("--version") || argv.includes("-v")))) {
|
|
1806
1916
|
const build = await cliBuildIdentity();
|
|
1807
1917
|
return stdout.write(`${VERSION} revision ${build.source_revision || "unknown"}\n`);
|
|
1808
1918
|
}
|
|
1809
1919
|
if (!command || command === "help" || command === "--help" || command === "-h") return helpCommand();
|
|
1920
|
+
if (command === "broker" && (argv[0] === "help" || argv.includes("--help") || argv.includes("-h"))) return brokerCommand(argv);
|
|
1810
1921
|
if (argv.includes("--help") || argv.includes("-h") || argv[0] === "help") return helpCommand();
|
|
1811
1922
|
if (command === "status") return statusCommand(argv);
|
|
1812
1923
|
if (command === "doctor") return doctorCommand(argv);
|
|
@@ -1825,6 +1936,7 @@ async function main() {
|
|
|
1825
1936
|
if (command === "hook" && argv[0] === "claude") return claudeHookCommand(argv.slice(1));
|
|
1826
1937
|
if (command === "config") return configCommand(argv);
|
|
1827
1938
|
if (command === "runtime") return runtimeCommand(argv);
|
|
1939
|
+
if (command === "broker") return brokerCommand(argv);
|
|
1828
1940
|
if (command === "upgrade") throw new CliError("Automatic upgrade is unavailable until versioned signed artifacts are published. No changes were made.", 2);
|
|
1829
1941
|
throw new CliError(`Unknown command '${command}'. Run \`reasontrail help\`.`, 2);
|
|
1830
1942
|
}
|
package/src/codex-sync.mjs
CHANGED
|
@@ -609,6 +609,7 @@ export async function syncCodex(client, tools, configDir, config, options = {})
|
|
|
609
609
|
sourceSessionId: session.threadId,
|
|
610
610
|
sourceCheckpoint: session.sourceCheckpoint,
|
|
611
611
|
turns,
|
|
612
|
+
captureMode: options.captureMode === "AUTOMATIC" ? "AUTOMATIC" : "MANUAL",
|
|
612
613
|
projectSlug: session.projectSlug,
|
|
613
614
|
}));
|
|
614
615
|
}
|
|
@@ -737,6 +738,7 @@ export async function syncCodex(client, tools, configDir, config, options = {})
|
|
|
737
738
|
taskTitle: s.title,
|
|
738
739
|
...(firstUser ? { userRequest: firstUser.content, messageId: firstUser.messageId } : {}),
|
|
739
740
|
timestamp: s.startedAt || s.updatedAt || now,
|
|
741
|
+
captureMode: options.captureMode === "AUTOMATIC" ? "AUTOMATIC" : "MANUAL",
|
|
740
742
|
...project,
|
|
741
743
|
});
|
|
742
744
|
|
|
@@ -755,6 +757,7 @@ export async function syncCodex(client, tools, configDir, config, options = {})
|
|
|
755
757
|
sourceCheckpoint: s.sourceCheckpoint,
|
|
756
758
|
sourceEligibleTurns: s.turns.length,
|
|
757
759
|
sourceAvailability: "AVAILABLE",
|
|
760
|
+
captureMode: options.captureMode === "AUTOMATIC" ? "AUTOMATIC" : "MANUAL",
|
|
758
761
|
turns,
|
|
759
762
|
sourceStatus: s.interrupted ? "INTERRUPTED" : "ACTIVE",
|
|
760
763
|
sourceStatusReason: s.interruptionReason,
|