@synkro-sh/cli 1.7.36 → 1.7.37
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/bootstrap.js +53 -2
- package/dist/bootstrap.js.map +1 -1
- package/package.json +1 -1
package/dist/bootstrap.js
CHANGED
|
@@ -839,6 +839,34 @@ function filePathFromToolInput(ti: any): string {
|
|
|
839
839
|
return ti.file_path || ti.notebook_path || ti.path || ti.target_file || '';
|
|
840
840
|
}
|
|
841
841
|
|
|
842
|
+
// Latest real human message from a CC transcript (JSONL). Scans from the end for a
|
|
843
|
+
// user turn, skipping sidechain (sub-agent) turns, meta entries, tool-result-only
|
|
844
|
+
// turns, and the synthetic local-command/caveat wrappers. Returns '' if none found.
|
|
845
|
+
function latestUserText(transcript: string): string {
|
|
846
|
+
const lines = transcript.split('\n');
|
|
847
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
848
|
+
const ln = lines[i].trim();
|
|
849
|
+
if (!ln) continue;
|
|
850
|
+
let o: any;
|
|
851
|
+
try { o = JSON.parse(ln); } catch { continue; }
|
|
852
|
+
if (o && (o.isSidechain || o.isMeta)) continue;
|
|
853
|
+
const m = o && o.message;
|
|
854
|
+
const role = (m && m.role) || (o && o.type);
|
|
855
|
+
if (role !== 'user') continue;
|
|
856
|
+
const c = m && m.content;
|
|
857
|
+
let text = '';
|
|
858
|
+
if (typeof c === 'string') text = c;
|
|
859
|
+
else if (Array.isArray(c)) {
|
|
860
|
+
text = c.filter((b: any) => b && b.type === 'text' && typeof b.text === 'string').map((b: any) => b.text).join(' ');
|
|
861
|
+
}
|
|
862
|
+
text = text.trim();
|
|
863
|
+
if (!text) continue;
|
|
864
|
+
if (text.startsWith('<local-command') || text.startsWith('<command-') || text.startsWith('Caveat:') || text.startsWith('<system-reminder')) continue;
|
|
865
|
+
return text;
|
|
866
|
+
}
|
|
867
|
+
return '';
|
|
868
|
+
}
|
|
869
|
+
|
|
842
870
|
interface StubOpts {
|
|
843
871
|
needsFile?: boolean;
|
|
844
872
|
needsTranscript?: boolean;
|
|
@@ -886,6 +914,29 @@ export async function runStub(surface: string, opts: StubOpts = {}): Promise<voi
|
|
|
886
914
|
// Gather host-only inputs the container can't read.
|
|
887
915
|
const envelope: any = { payload, harness, cwd: root || cwd, sessionId, synkroFileText };
|
|
888
916
|
|
|
917
|
+
// Sub-agent attribution (host-side — the container has no access to ~/.claude).
|
|
918
|
+
// A spawned sub-agent's tool-call hooks carry the ROOT session_id but a sidechain
|
|
919
|
+
// transcript at agent-<id>.jsonl (vs the main <session_id>.jsonl). Detect it from
|
|
920
|
+
// transcript_path, and read the ROOT transcript for the human turn that dispatched
|
|
921
|
+
// this (the sub-agent's own transcript starts with the task prompt, not the human).
|
|
922
|
+
try {
|
|
923
|
+
const tpath = typeof payload.transcript_path === 'string' ? payload.transcript_path : '';
|
|
924
|
+
const tbase = tpath.split('/').pop() || '';
|
|
925
|
+
const am = tbase.match(/^agent-(.+)\.jsonl$/);
|
|
926
|
+
if (am) {
|
|
927
|
+
envelope.isSubagent = true;
|
|
928
|
+
envelope.agentId = am[1];
|
|
929
|
+
try {
|
|
930
|
+
const dir = tpath.slice(0, tpath.length - tbase.length);
|
|
931
|
+
const rootPath = dir + sessionId + '.jsonl';
|
|
932
|
+
if (rootPath !== tpath && existsSync(rootPath)) {
|
|
933
|
+
const msg = latestUserText(readFileSync(rootPath, 'utf-8'));
|
|
934
|
+
if (msg) envelope.triggeringMessage = msg.slice(0, 2000);
|
|
935
|
+
}
|
|
936
|
+
} catch {}
|
|
937
|
+
}
|
|
938
|
+
} catch {}
|
|
939
|
+
|
|
889
940
|
if (opts.needsFile) {
|
|
890
941
|
const fp = filePathFromToolInput(payload.tool_input || {});
|
|
891
942
|
if (fp && existsSync(fp)) {
|
|
@@ -4778,7 +4829,7 @@ function writeConfigEnv(opts) {
|
|
|
4778
4829
|
`SYNKRO_CREDENTIALS_PATH=${shellQuoteSingle(credsPath)}`,
|
|
4779
4830
|
`SYNKRO_TIER=${shellQuoteSingle(safeTier)}`,
|
|
4780
4831
|
`SYNKRO_INFERENCE=${shellQuoteSingle(safeInference)}`,
|
|
4781
|
-
`SYNKRO_VERSION=${shellQuoteSingle("1.7.
|
|
4832
|
+
`SYNKRO_VERSION=${shellQuoteSingle("1.7.37")}`
|
|
4782
4833
|
];
|
|
4783
4834
|
if (safeSynkroBin) lines.push(`SYNKRO_CLI_BIN=${shellQuoteSingle(safeSynkroBin)}`);
|
|
4784
4835
|
if (safeUserId) lines.push(`SYNKRO_USER_ID=${shellQuoteSingle(safeUserId)}`);
|
|
@@ -8976,7 +9027,7 @@ var args = process.argv.slice(2);
|
|
|
8976
9027
|
var cmd = args[0] || "";
|
|
8977
9028
|
var subArgs = args.slice(1);
|
|
8978
9029
|
function printVersion() {
|
|
8979
|
-
console.log("1.7.
|
|
9030
|
+
console.log("1.7.37");
|
|
8980
9031
|
}
|
|
8981
9032
|
function printHelp2() {
|
|
8982
9033
|
console.log(`Synkro CLI \u2014 runtime safety for AI coding agents
|