@ai-sdk/harness-pi 1.0.95 → 1.0.97
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 +18 -0
- package/dist/index.js +16 -9
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/pi-harness.ts +1 -2
- package/src/pi-session.ts +22 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ai-sdk/harness-pi
|
|
2
2
|
|
|
3
|
+
## 1.0.97
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [371e954]
|
|
8
|
+
- Updated dependencies [87b4858]
|
|
9
|
+
- @ai-sdk/harness@1.0.95
|
|
10
|
+
|
|
11
|
+
## 1.0.96
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- 8961fde: feat(harness): allow changing `model` between turns via call options
|
|
16
|
+
- Updated dependencies [8961fde]
|
|
17
|
+
- Updated dependencies [eb59f2a]
|
|
18
|
+
- @ai-sdk/harness@1.0.94
|
|
19
|
+
- @ai-sdk/provider-utils@5.0.34
|
|
20
|
+
|
|
3
21
|
## 1.0.95
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -134,7 +134,7 @@ import {
|
|
|
134
134
|
import { access } from "fs/promises";
|
|
135
135
|
|
|
136
136
|
// src/version.ts
|
|
137
|
-
var VERSION = true ? "1.0.
|
|
137
|
+
var VERSION = true ? "1.0.97" : "0.0.0-test";
|
|
138
138
|
|
|
139
139
|
// src/pi-auth.ts
|
|
140
140
|
var DEFAULT_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh";
|
|
@@ -2015,7 +2015,7 @@ async function createPiSession(input) {
|
|
|
2015
2015
|
modelRegistry,
|
|
2016
2016
|
env: resolverEnv
|
|
2017
2017
|
});
|
|
2018
|
-
|
|
2018
|
+
let activeResolvedModel = resolveModel(input.settings.model);
|
|
2019
2019
|
const mcpServers = resolvePiMcpServers({
|
|
2020
2020
|
mcpServers: input.settings.mcpServers
|
|
2021
2021
|
});
|
|
@@ -2240,6 +2240,7 @@ async function createPiSession(input) {
|
|
|
2240
2240
|
try {
|
|
2241
2241
|
const control = await runTurn({
|
|
2242
2242
|
text: "",
|
|
2243
|
+
...continueOpts.model ? { model: continueOpts.model } : {},
|
|
2243
2244
|
skills: continueOpts.skills,
|
|
2244
2245
|
tools: continueOpts.tools ?? [],
|
|
2245
2246
|
instructions: continueOpts.instructions,
|
|
@@ -2419,7 +2420,7 @@ async function createPiSession(input) {
|
|
|
2419
2420
|
customTools,
|
|
2420
2421
|
...hasMcpServers ? { noTools: "builtin" } : { tools: toolNames },
|
|
2421
2422
|
...input.settings.thinkingLevel ? { thinkingLevel: input.settings.thinkingLevel } : {},
|
|
2422
|
-
...
|
|
2423
|
+
...activeResolvedModel ? { model: activeResolvedModel } : {}
|
|
2423
2424
|
});
|
|
2424
2425
|
piSession = session;
|
|
2425
2426
|
if (hasMcpServers) {
|
|
@@ -2483,6 +2484,8 @@ async function createPiSession(input) {
|
|
|
2483
2484
|
await applySessionInstructions(turnOpts.instructions);
|
|
2484
2485
|
turnAbortController.signal.throwIfAborted();
|
|
2485
2486
|
const didAppendDeliveredHostToolResults = appendDeliveredHostToolResults();
|
|
2487
|
+
const nextModel = turnOpts.model == null ? void 0 : resolveModel(turnOpts.model);
|
|
2488
|
+
if (nextModel != null) activeResolvedModel = nextModel;
|
|
2486
2489
|
const signature = JSON.stringify(userTools.map((t) => t.name).sort());
|
|
2487
2490
|
const needsRebuild = piSession == null || signature !== lastToolsSignature;
|
|
2488
2491
|
let resourcesReloaded = false;
|
|
@@ -2493,6 +2496,9 @@ async function createPiSession(input) {
|
|
|
2493
2496
|
);
|
|
2494
2497
|
turnAbortController.signal.throwIfAborted();
|
|
2495
2498
|
lastToolsSignature = signature;
|
|
2499
|
+
} else if (nextModel != null && piSession != null && (piSession.model?.provider !== nextModel.provider || piSession.model.id !== nextModel.id)) {
|
|
2500
|
+
await piSession.setModel(nextModel);
|
|
2501
|
+
turnAbortController.signal.throwIfAborted();
|
|
2496
2502
|
}
|
|
2497
2503
|
if (!resourcesReloaded) {
|
|
2498
2504
|
await reloadResourcesOnly();
|
|
@@ -2509,7 +2515,10 @@ async function createPiSession(input) {
|
|
|
2509
2515
|
hostToolNames: userTools.map((tool2) => tool2.name),
|
|
2510
2516
|
nativeToCommon: NATIVE_TO_COMMON
|
|
2511
2517
|
});
|
|
2512
|
-
currentEmit?.({
|
|
2518
|
+
currentEmit?.({
|
|
2519
|
+
type: "stream-start",
|
|
2520
|
+
...piSession?.model?.id ? { modelId: piSession.model.id } : {}
|
|
2521
|
+
});
|
|
2513
2522
|
if (didAppendDeliveredHostToolResults) {
|
|
2514
2523
|
currentEmit?.({
|
|
2515
2524
|
type: "finish-step",
|
|
@@ -2636,9 +2645,6 @@ async function createPiSession(input) {
|
|
|
2636
2645
|
const sessionImpl = {
|
|
2637
2646
|
sessionId: input.sessionId,
|
|
2638
2647
|
isResume: input.isResume,
|
|
2639
|
-
// The model Pi actually resolves to (the configured id, or its default when
|
|
2640
|
-
// unset) — `gen_ai.request.model`.
|
|
2641
|
-
...resolvedModel?.id ? { modelId: resolvedModel.id } : {},
|
|
2642
2648
|
// Pi has no bridge to attach to and no on-disk event log to replay; its
|
|
2643
2649
|
// only resume path is restoring the session file on a fresh/snapshotted
|
|
2644
2650
|
// sandbox, i.e. `rerun`.
|
|
@@ -2651,6 +2657,7 @@ async function createPiSession(input) {
|
|
|
2651
2657
|
}
|
|
2652
2658
|
return runTurn({
|
|
2653
2659
|
text: extractUserText(promptOpts.prompt),
|
|
2660
|
+
...promptOpts.model ? { model: promptOpts.model } : {},
|
|
2654
2661
|
skills: promptOpts.skills,
|
|
2655
2662
|
tools: promptOpts.tools ?? [],
|
|
2656
2663
|
instructions: promptOpts.instructions,
|
|
@@ -2687,6 +2694,7 @@ async function createPiSession(input) {
|
|
|
2687
2694
|
}
|
|
2688
2695
|
return runTurn({
|
|
2689
2696
|
text: "",
|
|
2697
|
+
...continueOpts.model ? { model: continueOpts.model } : {},
|
|
2690
2698
|
skills: continueOpts.skills,
|
|
2691
2699
|
tools: continueOpts.tools ?? [],
|
|
2692
2700
|
instructions: continueOpts.instructions,
|
|
@@ -3108,7 +3116,6 @@ function createPi(settings = {}) {
|
|
|
3108
3116
|
supportsBuiltinToolFiltering: true,
|
|
3109
3117
|
lifecycleStateSchema: piResumeStateSchema,
|
|
3110
3118
|
doStart: async (startOpts) => {
|
|
3111
|
-
const model = startOpts.model ?? settings.model;
|
|
3112
3119
|
const lifecycleState = startOpts.continueFrom ?? startOpts.resumeFrom;
|
|
3113
3120
|
const resumeData = lifecycleState?.data;
|
|
3114
3121
|
return createPiSession({
|
|
@@ -3117,7 +3124,7 @@ function createPi(settings = {}) {
|
|
|
3117
3124
|
sessionWorkDir: startOpts.sessionWorkDir,
|
|
3118
3125
|
settings: {
|
|
3119
3126
|
...settings.auth ? { auth: settings.auth } : {},
|
|
3120
|
-
...model == null ? {} : { model },
|
|
3127
|
+
...settings.model == null ? {} : { model: settings.model },
|
|
3121
3128
|
...settings.thinkingLevel ? { thinkingLevel: settings.thinkingLevel } : {},
|
|
3122
3129
|
...settings.mcpServers ? { mcpServers: settings.mcpServers } : {},
|
|
3123
3130
|
...settings.extensionFactories ? { extensionFactories: settings.extensionFactories } : {}
|