@skydiveai/pi-extensions 0.1.0-beta.2444 → 0.1.0-beta.2447
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/README.md +13 -0
- package/dist/index.mjs +64 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,6 +14,19 @@ Extensions (load agent workspace content):
|
|
|
14
14
|
daemon session tracking, sandbox heartbeats, OTel self-tracing. Every
|
|
15
15
|
session must include these.
|
|
16
16
|
|
|
17
|
+
Proactive evaluation sessions additionally receive `submit_proactive_action_result`.
|
|
18
|
+
The tool schema comes from the authenticated sandbox API, which validates and
|
|
19
|
+
stores the result for the originating evaluation. Ordinary sessions do not
|
|
20
|
+
discover or register this tool. Submission does not deliver a message; the
|
|
21
|
+
worker reconciles it only after the run succeeds.
|
|
22
|
+
|
|
23
|
+
Deploy the sandbox API and updated platform CLI before enabling the v4 worker
|
|
24
|
+
prompt. Older/custom harnesses use `platform proactive-result` to submit the
|
|
25
|
+
same structured result. The native tool reaches agents through the normal
|
|
26
|
+
reviewed pi-extensions release and opt-in harness upgrade, not by rewriting
|
|
27
|
+
their harness files. Already-started v1/v2/v3 evaluations retain text-result
|
|
28
|
+
compatibility.
|
|
29
|
+
|
|
17
30
|
Platform layer:
|
|
18
31
|
|
|
19
32
|
- `createHarness` — composes @skydiveai/pi-server's protocol handlers
|
package/dist/index.mjs
CHANGED
|
@@ -4346,6 +4346,69 @@ function createSubagentExtension({ channelContext }) {
|
|
|
4346
4346
|
};
|
|
4347
4347
|
}
|
|
4348
4348
|
//#endregion
|
|
4349
|
+
//#region src/extensions/proactive-result.ts
|
|
4350
|
+
const contextSchema = z.object({
|
|
4351
|
+
proactiveAction: z.literal(true),
|
|
4352
|
+
runId: z.string().uuid(),
|
|
4353
|
+
messageId: z.string().uuid()
|
|
4354
|
+
});
|
|
4355
|
+
function createProactiveResultExtension({ channelContext }) {
|
|
4356
|
+
return (pi) => {
|
|
4357
|
+
if (!channelContext) return;
|
|
4358
|
+
let context;
|
|
4359
|
+
try {
|
|
4360
|
+
context = contextSchema.safeParse(JSON.parse(channelContext));
|
|
4361
|
+
} catch (_error) {
|
|
4362
|
+
return;
|
|
4363
|
+
}
|
|
4364
|
+
if (!context.success) return;
|
|
4365
|
+
const { runId, messageId } = context.data;
|
|
4366
|
+
let registered = false;
|
|
4367
|
+
pi.on("session_start", async () => {
|
|
4368
|
+
if (registered) return;
|
|
4369
|
+
const client = sandboxClient();
|
|
4370
|
+
if (!client) return;
|
|
4371
|
+
try {
|
|
4372
|
+
const response = await client["proactive-result"].$get({ query: {
|
|
4373
|
+
runId,
|
|
4374
|
+
messageId
|
|
4375
|
+
} });
|
|
4376
|
+
if (response.status === 404) return;
|
|
4377
|
+
if (!response.ok) throw new Error(`proactive result discovery failed: ${response.status}`);
|
|
4378
|
+
const { tool } = await response.json();
|
|
4379
|
+
if (!tool) return;
|
|
4380
|
+
pi.registerTool({
|
|
4381
|
+
name: tool.name,
|
|
4382
|
+
label: "Submit proactive result",
|
|
4383
|
+
description: tool.description,
|
|
4384
|
+
parameters: Type.Unsafe(tool.parameters),
|
|
4385
|
+
async execute(_toolCallId, result, signal) {
|
|
4386
|
+
const submitted = await client["proactive-result"].$post({ json: {
|
|
4387
|
+
runId,
|
|
4388
|
+
messageId,
|
|
4389
|
+
result
|
|
4390
|
+
} }, { init: { signal } });
|
|
4391
|
+
return {
|
|
4392
|
+
content: [{
|
|
4393
|
+
type: "text",
|
|
4394
|
+
text: await submitted.text()
|
|
4395
|
+
}],
|
|
4396
|
+
isError: !submitted.ok,
|
|
4397
|
+
details: {}
|
|
4398
|
+
};
|
|
4399
|
+
}
|
|
4400
|
+
});
|
|
4401
|
+
registered = true;
|
|
4402
|
+
} catch (err) {
|
|
4403
|
+
logger.warn({
|
|
4404
|
+
err,
|
|
4405
|
+
runId
|
|
4406
|
+
}, "proactive result tool unavailable; platform CLI submission remains available");
|
|
4407
|
+
}
|
|
4408
|
+
});
|
|
4409
|
+
};
|
|
4410
|
+
}
|
|
4411
|
+
//#endregion
|
|
4349
4412
|
//#region src/extensions/tool-call-env.ts
|
|
4350
4413
|
const TOOL_CALL_ID_VAR = "TOOL_CALL_ID";
|
|
4351
4414
|
function shellQuoteValue(value) {
|
|
@@ -5078,6 +5141,7 @@ function platformExtensions({ sessionId, channelContext }) {
|
|
|
5078
5141
|
selfTraceExtension,
|
|
5079
5142
|
createBackgroundTasksExtension({ channelContext }),
|
|
5080
5143
|
createSubagentExtension({ channelContext }),
|
|
5144
|
+
createProactiveResultExtension({ channelContext }),
|
|
5081
5145
|
createContextManagementExtension(),
|
|
5082
5146
|
resourcePressureWarningExtension
|
|
5083
5147
|
];
|