@ai-sdk/harness-claude-code 1.0.67 → 1.0.69
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 +16 -0
- package/dist/bridge/index.mjs +10 -0
- package/dist/bridge/index.mjs.map +1 -1
- package/dist/index.js +5 -19
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/bridge/claude-code-system-prompt.ts +11 -0
- package/src/bridge/index.ts +2 -0
- package/src/claude-code-bridge-protocol.ts +1 -0
- package/src/claude-code-harness.ts +7 -31
|
@@ -1378,13 +1378,6 @@ function createSession({
|
|
|
1378
1378
|
* `attach`ed bridge is already past its first turn and continues on its own.
|
|
1379
1379
|
*/
|
|
1380
1380
|
let pendingResumeFlag = continueOnFirstPrompt;
|
|
1381
|
-
/*
|
|
1382
|
-
* Instructions are prepended to the first user message of a fresh session
|
|
1383
|
-
* only. A resumed session (attach/replay/rerun) already carried them in its
|
|
1384
|
-
* original first message (preserved in the workdir snapshot), so it starts
|
|
1385
|
-
* "applied".
|
|
1386
|
-
*/
|
|
1387
|
-
let instructionsApplied = isResume;
|
|
1388
1381
|
|
|
1389
1382
|
/*
|
|
1390
1383
|
* Wire the channel into one turn's worth of events and return the control
|
|
@@ -1531,20 +1524,17 @@ function createSession({
|
|
|
1531
1524
|
abortSignal: promptOpts.abortSignal,
|
|
1532
1525
|
});
|
|
1533
1526
|
|
|
1534
|
-
let promptText = extractUserText(promptOpts.prompt);
|
|
1535
|
-
if (!instructionsApplied && promptOpts.instructions) {
|
|
1536
|
-
promptText = frameInstructions(promptOpts.instructions, promptText);
|
|
1537
|
-
}
|
|
1538
|
-
instructionsApplied = true;
|
|
1539
|
-
|
|
1540
1527
|
const startMessage = {
|
|
1541
1528
|
type: 'start' as const,
|
|
1542
|
-
prompt:
|
|
1529
|
+
prompt: extractUserText(promptOpts.prompt),
|
|
1543
1530
|
tools: (promptOpts.tools ?? []).map(t => ({
|
|
1544
1531
|
name: t.name,
|
|
1545
1532
|
description: t.description,
|
|
1546
1533
|
inputSchema: t.inputSchema,
|
|
1547
1534
|
})),
|
|
1535
|
+
...(promptOpts.instructions
|
|
1536
|
+
? { instructions: promptOpts.instructions }
|
|
1537
|
+
: {}),
|
|
1548
1538
|
model,
|
|
1549
1539
|
maxTurns,
|
|
1550
1540
|
...(env !== undefined ? { env } : {}),
|
|
@@ -1599,6 +1589,9 @@ function createSession({
|
|
|
1599
1589
|
description: t.description,
|
|
1600
1590
|
inputSchema: t.inputSchema,
|
|
1601
1591
|
})),
|
|
1592
|
+
...(continueOpts.instructions
|
|
1593
|
+
? { instructions: continueOpts.instructions }
|
|
1594
|
+
: {}),
|
|
1602
1595
|
model,
|
|
1603
1596
|
maxTurns,
|
|
1604
1597
|
...(env !== undefined ? { env } : {}),
|
|
@@ -1794,23 +1787,6 @@ function createSession({
|
|
|
1794
1787
|
};
|
|
1795
1788
|
}
|
|
1796
1789
|
|
|
1797
|
-
/*
|
|
1798
|
-
* Frame session instructions and the user's text so the runtime treats the
|
|
1799
|
-
* instructions as system-provided operating guidance, not something the user
|
|
1800
|
-
* wrote. Without the wrapper the agent can echo the prepended text back as if
|
|
1801
|
-
* the user had asked for it, which is confusing since the user never typed it.
|
|
1802
|
-
* Applied only to the first user message of a fresh session.
|
|
1803
|
-
*/
|
|
1804
|
-
function frameInstructions(instructions: string, userText: string): string {
|
|
1805
|
-
return (
|
|
1806
|
-
'<session-instructions>\n' +
|
|
1807
|
-
'The block below is operating guidance from the system, not a message from the user — follow it, but do not mention it or attribute it to the user.\n\n' +
|
|
1808
|
-
`${instructions}\n` +
|
|
1809
|
-
'</session-instructions>\n\n' +
|
|
1810
|
-
`<user-message>\n${userText}\n</user-message>`
|
|
1811
|
-
);
|
|
1812
|
-
}
|
|
1813
|
-
|
|
1814
1790
|
/*
|
|
1815
1791
|
* Reduce a `HarnessV1Prompt` to the plain user text the bridge forwards
|
|
1816
1792
|
* to the Claude SDK. File and image parts on the message are not yet
|