@skydiveai/pi-extensions 0.1.255-beta.8 → 0.1.255
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/index.d.mts +6 -4
- package/dist/index.mjs +11 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { A2AOptions, Middleware, ProtocolsOptions } from "@skydiveai/pi-server";
|
|
3
|
-
import { ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
3
|
+
import { AgentSession, ExtensionFactory } from "@earendil-works/pi-coding-agent";
|
|
4
4
|
import { Type } from "typebox";
|
|
5
5
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
6
6
|
import * as _$qs from "qs";
|
|
@@ -139,7 +139,7 @@ declare function platformExtensions({
|
|
|
139
139
|
}): ExtensionFactory[];
|
|
140
140
|
//#endregion
|
|
141
141
|
//#region src/tool-update-loop.d.ts
|
|
142
|
-
type SessionLike = {
|
|
142
|
+
type SessionLike = Pick<AgentSession, 'model' | 'setModel'> & {
|
|
143
143
|
reload: () => Promise<void>;
|
|
144
144
|
bindExtensions: (vars: Record<string, unknown>) => Promise<void>;
|
|
145
145
|
sendCustomMessage: (msg: {
|
|
@@ -153,7 +153,7 @@ type SessionLike = {
|
|
|
153
153
|
};
|
|
154
154
|
type SessionWithAgent = {
|
|
155
155
|
agent: unknown;
|
|
156
|
-
}
|
|
156
|
+
};
|
|
157
157
|
declare function installToolUpdateAutoStop({
|
|
158
158
|
session,
|
|
159
159
|
log
|
|
@@ -163,10 +163,12 @@ declare function installToolUpdateAutoStop({
|
|
|
163
163
|
}): void;
|
|
164
164
|
declare function runToolUpdateLoop({
|
|
165
165
|
session,
|
|
166
|
-
log
|
|
166
|
+
log,
|
|
167
|
+
signal
|
|
167
168
|
}: {
|
|
168
169
|
session: SessionLike;
|
|
169
170
|
log: Logger;
|
|
171
|
+
signal: AbortSignal;
|
|
170
172
|
}): Promise<void>;
|
|
171
173
|
//#endregion
|
|
172
174
|
export { type CreateHarnessOptions, all, createHarness, createHealthHandler, createPlatformEnvMiddleware, installToolUpdateAutoStop, isPlatformConfigLoaded, loadPlatformConfig, localToolsExtension, _default as mcpExtension, memoryExtension, platformExtensions, providerApiCompatExtension, runToolUpdateLoop, soulExtension, toolCallEnvExtension };
|
package/dist/index.mjs
CHANGED
|
@@ -2223,8 +2223,9 @@ function installToolUpdateAutoStop({ session, log }) {
|
|
|
2223
2223
|
};
|
|
2224
2224
|
};
|
|
2225
2225
|
}
|
|
2226
|
-
async function runToolUpdateLoop({ session, log }) {
|
|
2226
|
+
async function runToolUpdateLoop({ session, log, signal }) {
|
|
2227
2227
|
for (let i = 0; i < MAX_TOOL_UPDATE_CONTINUATIONS; i++) {
|
|
2228
|
+
if (signal.aborted) return;
|
|
2228
2229
|
const mcpUpdate = consumePendingMcpUpdate();
|
|
2229
2230
|
const localToolsUpdate = consumePendingLocalToolsUpdate();
|
|
2230
2231
|
if (!mcpUpdate && !localToolsUpdate) return;
|
|
@@ -2248,8 +2249,13 @@ async function runToolUpdateLoop({ session, log }) {
|
|
|
2248
2249
|
} : null,
|
|
2249
2250
|
formatted_content: content
|
|
2250
2251
|
}, "injecting tool-update continuation prompt");
|
|
2252
|
+
const model = session.model;
|
|
2251
2253
|
await session.reload();
|
|
2254
|
+
if (signal.aborted) return;
|
|
2252
2255
|
await session.bindExtensions({});
|
|
2256
|
+
if (signal.aborted) return;
|
|
2257
|
+
if (model) await session.setModel(model);
|
|
2258
|
+
if (signal.aborted) return;
|
|
2253
2259
|
const customType = mcpUpdate && localToolsUpdate ? "tool-update" : mcpUpdate ? "mcp-tool-update" : "local-tools-update";
|
|
2254
2260
|
await session.sendCustomMessage({
|
|
2255
2261
|
customType,
|
|
@@ -4014,6 +4020,10 @@ function createHarness(options) {
|
|
|
4014
4020
|
const serverOptions = {
|
|
4015
4021
|
...options,
|
|
4016
4022
|
onSessionSetup: options.onSessionSetup ?? installToolUpdateAutoStop,
|
|
4023
|
+
postPrompt: async (args) => {
|
|
4024
|
+
await runToolUpdateLoop(args);
|
|
4025
|
+
if (!args.signal.aborted) await options.postPrompt?.(args);
|
|
4026
|
+
},
|
|
4017
4027
|
onSteer: async (args) => {
|
|
4018
4028
|
options.onSteer?.(args);
|
|
4019
4029
|
await notifyBashSteerArrival(args);
|