@skydiveai/pi-extensions 0.1.254-beta.62 → 0.1.254-beta.63
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.mjs +0 -63
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -6105,68 +6105,6 @@ function createSubagentExtension({ channelContext }) {
|
|
|
6105
6105
|
};
|
|
6106
6106
|
}
|
|
6107
6107
|
//#endregion
|
|
6108
|
-
//#region src/extensions/proactive-result.ts
|
|
6109
|
-
const contextSchema = z.object({
|
|
6110
|
-
proactiveAction: z.literal(true).optional(),
|
|
6111
|
-
runId: z.string().uuid(),
|
|
6112
|
-
messageId: z.string().uuid()
|
|
6113
|
-
});
|
|
6114
|
-
function createProactiveResultExtension({ channelContext }) {
|
|
6115
|
-
return (pi) => {
|
|
6116
|
-
let context;
|
|
6117
|
-
try {
|
|
6118
|
-
context = contextSchema.safeParse(JSON.parse(channelContext ?? ""));
|
|
6119
|
-
} catch (_error) {
|
|
6120
|
-
return;
|
|
6121
|
-
}
|
|
6122
|
-
if (!context.success || !context.data.proactiveAction) return;
|
|
6123
|
-
const { runId, messageId } = context.data;
|
|
6124
|
-
let registered = false;
|
|
6125
|
-
pi.on("session_start", async () => {
|
|
6126
|
-
if (registered) return;
|
|
6127
|
-
const client = sandboxClient();
|
|
6128
|
-
if (!client) return;
|
|
6129
|
-
try {
|
|
6130
|
-
const response = await client["proactive-result"].$get({ query: {
|
|
6131
|
-
runId,
|
|
6132
|
-
messageId
|
|
6133
|
-
} });
|
|
6134
|
-
if (response.status === 404) return;
|
|
6135
|
-
if (!response.ok) throw new Error(`proactive result discovery failed: ${response.status}`);
|
|
6136
|
-
const { tool } = await response.json();
|
|
6137
|
-
if (!tool) return;
|
|
6138
|
-
pi.registerTool({
|
|
6139
|
-
name: tool.name,
|
|
6140
|
-
label: "Submit proactive result",
|
|
6141
|
-
description: tool.description,
|
|
6142
|
-
parameters: Type.Unsafe(tool.parameters),
|
|
6143
|
-
async execute(_toolCallId, result, signal) {
|
|
6144
|
-
const submitted = await client["proactive-result"].$post({ json: {
|
|
6145
|
-
runId,
|
|
6146
|
-
messageId,
|
|
6147
|
-
result
|
|
6148
|
-
} }, { init: { signal } });
|
|
6149
|
-
return {
|
|
6150
|
-
content: [{
|
|
6151
|
-
type: "text",
|
|
6152
|
-
text: await submitted.text()
|
|
6153
|
-
}],
|
|
6154
|
-
isError: !submitted.ok,
|
|
6155
|
-
details: {}
|
|
6156
|
-
};
|
|
6157
|
-
}
|
|
6158
|
-
});
|
|
6159
|
-
registered = true;
|
|
6160
|
-
} catch (err) {
|
|
6161
|
-
logger.warn({
|
|
6162
|
-
err,
|
|
6163
|
-
runId
|
|
6164
|
-
}, "proactive result tool unavailable");
|
|
6165
|
-
}
|
|
6166
|
-
});
|
|
6167
|
-
};
|
|
6168
|
-
}
|
|
6169
|
-
//#endregion
|
|
6170
6108
|
//#region src/extensions/tool-history.ts
|
|
6171
6109
|
const VALID_NAME_RE = /^[a-zA-Z0-9_-]+$/;
|
|
6172
6110
|
function isValidToolName(name) {
|
|
@@ -6331,7 +6269,6 @@ function platformExtensions({ sessionId, channelContext }) {
|
|
|
6331
6269
|
sessionId
|
|
6332
6270
|
}),
|
|
6333
6271
|
createSubagentExtension({ channelContext }),
|
|
6334
|
-
createProactiveResultExtension({ channelContext }),
|
|
6335
6272
|
createContextManagementExtension(),
|
|
6336
6273
|
resourcePressureWarningExtension,
|
|
6337
6274
|
tool_history_default
|