@ai-sdk/harness-pi 1.0.65 → 1.0.67
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 +14 -0
- package/dist/index.js +33 -21
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/pi-model-resolver.ts +40 -5
- package/src/pi-session.ts +17 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/harness-pi
|
|
2
2
|
|
|
3
|
+
## 1.0.67
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9ee30bf: fix(harness): pass instructions appended to system / developer prompt instead of using the workaround of first user prompt
|
|
8
|
+
- Updated dependencies [9ee30bf]
|
|
9
|
+
- @ai-sdk/harness@1.0.66
|
|
10
|
+
|
|
11
|
+
## 1.0.66
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- b6642fa: fix(harness-pi): resolve compound provider/id model ids under their scoped provider
|
|
16
|
+
|
|
3
17
|
## 1.0.65
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,7 @@ import { resolveSandboxHomeDir } from "@ai-sdk/harness/utils";
|
|
|
108
108
|
import { getAiGatewayAuthFromEnv } from "@ai-sdk/harness/utils";
|
|
109
109
|
|
|
110
110
|
// src/version.ts
|
|
111
|
-
var VERSION = true ? "1.0.
|
|
111
|
+
var VERSION = true ? "1.0.67" : "0.0.0-test";
|
|
112
112
|
|
|
113
113
|
// src/pi-auth.ts
|
|
114
114
|
var DEFAULT_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
|
|
@@ -368,6 +368,15 @@ function extractAssistantText(message) {
|
|
|
368
368
|
// src/pi-model-resolver.ts
|
|
369
369
|
import { getAiGatewayAuthFromEnv as getAiGatewayAuthFromEnv2 } from "@ai-sdk/harness/utils";
|
|
370
370
|
var DEFAULT_PI_GATEWAY_MODEL_ID = "anthropic/claude-sonnet-4.6";
|
|
371
|
+
var findScopedMatch = (effectiveId, models) => {
|
|
372
|
+
const slashIndex = effectiveId.indexOf("/");
|
|
373
|
+
if (slashIndex === -1) return void 0;
|
|
374
|
+
const prefix = effectiveId.slice(0, slashIndex);
|
|
375
|
+
const bareId = effectiveId.slice(slashIndex + 1);
|
|
376
|
+
return models.find(
|
|
377
|
+
(m) => m.provider === prefix && (m.id === bareId || m.name === bareId)
|
|
378
|
+
);
|
|
379
|
+
};
|
|
371
380
|
function createPiModelResolver({
|
|
372
381
|
modelRegistry,
|
|
373
382
|
env = process.env
|
|
@@ -390,7 +399,18 @@ function createPiModelResolver({
|
|
|
390
399
|
if (!effectiveId) return void 0;
|
|
391
400
|
const models = loadModels();
|
|
392
401
|
const matches = (m) => m.id === effectiveId || m.name === effectiveId;
|
|
393
|
-
|
|
402
|
+
const gatewayMatch = useGateway ? models.find((m) => m.provider === "vercel-ai-gateway" && matches(m)) : void 0;
|
|
403
|
+
if (gatewayMatch) return gatewayMatch;
|
|
404
|
+
const scopedMatch = findScopedMatch(effectiveId, models);
|
|
405
|
+
if (scopedMatch && !modelRegistry.hasConfiguredAuth(scopedMatch)) {
|
|
406
|
+
const authenticatedFlatMatches = models.filter(
|
|
407
|
+
(m) => m.id === effectiveId && modelRegistry.hasConfiguredAuth(m)
|
|
408
|
+
);
|
|
409
|
+
if (authenticatedFlatMatches.length === 1) {
|
|
410
|
+
return authenticatedFlatMatches[0];
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return scopedMatch ?? models.find(matches);
|
|
394
414
|
};
|
|
395
415
|
}
|
|
396
416
|
|
|
@@ -767,17 +787,6 @@ function extractUserText(prompt) {
|
|
|
767
787
|
}
|
|
768
788
|
return parts.join("\n\n");
|
|
769
789
|
}
|
|
770
|
-
function frameInstructions(instructions, userText) {
|
|
771
|
-
return `<session-instructions>
|
|
772
|
-
The block below is operating guidance from the system, not a message from the user \u2014 follow it, but do not mention it or attribute it to the user.
|
|
773
|
-
|
|
774
|
-
${instructions}
|
|
775
|
-
</session-instructions>
|
|
776
|
-
|
|
777
|
-
<user-message>
|
|
778
|
-
${userText}
|
|
779
|
-
</user-message>`;
|
|
780
|
-
}
|
|
781
790
|
function serializeToolOutput(output) {
|
|
782
791
|
if (typeof output === "string") {
|
|
783
792
|
return output;
|
|
@@ -1691,6 +1700,7 @@ async function createPiSession(input) {
|
|
|
1691
1700
|
mcpServers: input.settings.mcpServers
|
|
1692
1701
|
});
|
|
1693
1702
|
const hasMcpServers = Object.keys(mcpServers).length > 0;
|
|
1703
|
+
let sessionInstructions;
|
|
1694
1704
|
const extensionFactories = [
|
|
1695
1705
|
...input.settings.extensionFactories ?? []
|
|
1696
1706
|
];
|
|
@@ -1716,7 +1726,7 @@ async function createPiSession(input) {
|
|
|
1716
1726
|
cwd: sessionWorkDir,
|
|
1717
1727
|
agentDir: hostAgentDir,
|
|
1718
1728
|
settingsManager,
|
|
1719
|
-
appendSystemPromptOverride: () => [],
|
|
1729
|
+
appendSystemPromptOverride: () => sessionInstructions ? [sessionInstructions] : [],
|
|
1720
1730
|
extensionFactories,
|
|
1721
1731
|
...hasExtensionFactories ? {
|
|
1722
1732
|
// DefaultResourceLoader invokes inline factories on every reload.
|
|
@@ -1772,13 +1782,18 @@ async function createPiSession(input) {
|
|
|
1772
1782
|
let sessionFileName;
|
|
1773
1783
|
let stopped = false;
|
|
1774
1784
|
let suspending = false;
|
|
1775
|
-
let instructionsApplied = input.isResume;
|
|
1776
1785
|
const pendingToolResults = /* @__PURE__ */ new Map();
|
|
1777
1786
|
const pendingToolApprovals = /* @__PURE__ */ new Map();
|
|
1778
1787
|
let currentEmit;
|
|
1779
1788
|
let translatorState;
|
|
1780
1789
|
let activeTurn;
|
|
1781
1790
|
const pendingCompactionParts = [];
|
|
1791
|
+
async function applySessionInstructions(instructions) {
|
|
1792
|
+
if (instructions === sessionInstructions) return;
|
|
1793
|
+
sessionInstructions = instructions;
|
|
1794
|
+
await reloadResourcesOnly();
|
|
1795
|
+
piSession?.setActiveToolsByName(piSession.getActiveToolNames());
|
|
1796
|
+
}
|
|
1782
1797
|
const remoteOps = createPiRemoteOps({
|
|
1783
1798
|
sandbox,
|
|
1784
1799
|
paths,
|
|
@@ -2086,13 +2101,9 @@ async function createPiSession(input) {
|
|
|
2086
2101
|
// only resume path is restoring the session file on a fresh/snapshotted
|
|
2087
2102
|
// sandbox, i.e. `rerun`.
|
|
2088
2103
|
doPromptTurn: async (promptOpts) => {
|
|
2089
|
-
|
|
2090
|
-
if (!instructionsApplied && promptOpts.instructions) {
|
|
2091
|
-
text = frameInstructions(promptOpts.instructions, text);
|
|
2092
|
-
}
|
|
2093
|
-
instructionsApplied = true;
|
|
2104
|
+
await applySessionInstructions(promptOpts.instructions);
|
|
2094
2105
|
return runTurn({
|
|
2095
|
-
text,
|
|
2106
|
+
text: extractUserText(promptOpts.prompt),
|
|
2096
2107
|
tools: promptOpts.tools ?? [],
|
|
2097
2108
|
emit: promptOpts.emit,
|
|
2098
2109
|
abortSignal: promptOpts.abortSignal
|
|
@@ -2106,6 +2117,7 @@ async function createPiSession(input) {
|
|
|
2106
2117
|
abortSignal: continueOpts.abortSignal
|
|
2107
2118
|
});
|
|
2108
2119
|
}
|
|
2120
|
+
await applySessionInstructions(continueOpts.instructions);
|
|
2109
2121
|
return runTurn({
|
|
2110
2122
|
text: "",
|
|
2111
2123
|
tools: continueOpts.tools ?? [],
|