@ai-setting/roy-agent-core 1.7.62 → 1.7.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/env/agent/agent-component.d.ts +33 -0
- package/dist/env/agent/agent-component.js +4 -3
- package/dist/env/agent/index.js +4 -3
- package/dist/env/agent/types.d.ts +17 -0
- package/dist/env/error-reply.d.ts +53 -1
- package/dist/env/error-reply.js +8 -1
- package/dist/env/event-source/event-source-handlers.js +3 -2
- package/dist/env/event-source/index.js +4 -3
- package/dist/env/index.js +14 -13
- package/dist/env/llm/adapter-pi-ai.d.ts +47 -0
- package/dist/env/llm/index.js +3 -2
- package/dist/env/llm/model-fallback.d.ts +54 -0
- package/dist/env/llm/redact.d.ts +39 -0
- package/dist/env/llm/types.d.ts +13 -0
- package/dist/env/session/index.js +5 -4
- package/dist/env/session/storage/index.js +4 -3
- package/dist/env/task/delegate/delegate-tool.d.ts +27 -1
- package/dist/env/task/delegate/delegate-tool.js +1 -1
- package/dist/env/task/delegate/index.js +1 -1
- package/dist/env/task/index.js +2 -2
- package/dist/env/tool/types.d.ts +13 -0
- package/dist/env/workflow/index.js +7 -6
- package/dist/env/workflow/tools/index.js +6 -5
- package/dist/index.js +15 -14
- package/dist/shared/@ai-setting/{roy-agent-core-9qgrc9dy.js → roy-agent-core-03k5drfp.js} +54 -14
- package/dist/shared/@ai-setting/{roy-agent-core-2veqhrxa.js → roy-agent-core-1dnsk6ht.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-vvb4cyyy.js → roy-agent-core-2cw72f16.js} +7 -2
- package/dist/shared/@ai-setting/{roy-agent-core-cqpd41gf.js → roy-agent-core-5hq4v41q.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-fr296a53.js → roy-agent-core-60f7h284.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gz2jnaan.js → roy-agent-core-b4zdm2n4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-48h4zh60.js → roy-agent-core-bm3gav5d.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-h3fwjbhp.js → roy-agent-core-ebws32tv.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-5bj0xfjk.js → roy-agent-core-g23yp3t1.js} +298 -34
- package/dist/shared/@ai-setting/{roy-agent-core-w2h6xt6k.js → roy-agent-core-g6pw4esq.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-fqandv0a.js → roy-agent-core-gnt23yx0.js} +21 -11
- package/dist/shared/@ai-setting/roy-agent-core-ntn32q7j.js +72 -0
- package/dist/shared/@ai-setting/{roy-agent-core-x1d6edkh.js → roy-agent-core-rfhxj8v2.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-nmn853z0.js → roy-agent-core-t6nx0rsz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-9nvyffxg.js → roy-agent-core-va4m04e8.js} +117 -7
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
deriveTriggerEventIdFromEnvContext,
|
|
12
12
|
getSubAgentSpec,
|
|
13
13
|
handleBackgroundTask
|
|
14
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
14
|
+
} from "../../../shared/@ai-setting/roy-agent-core-gnt23yx0.js";
|
|
15
15
|
import"../../../shared/@ai-setting/roy-agent-core-jw63js86.js";
|
|
16
16
|
import"../../../shared/@ai-setting/roy-agent-core-a08dpf71.js";
|
|
17
17
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
BackgroundTaskEventTypes,
|
|
6
6
|
BackgroundTaskManager,
|
|
7
7
|
createDelegateTool
|
|
8
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../../shared/@ai-setting/roy-agent-core-gnt23yx0.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-jw63js86.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-a08dpf71.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
TaskPriorityEnum,
|
|
6
6
|
TaskStatusEnum,
|
|
7
7
|
TaskTypeEnum
|
|
8
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../shared/@ai-setting/roy-agent-core-5hq4v41q.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-jm136jzh.js";
|
|
11
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
import"../../shared/@ai-setting/roy-agent-core-gnt23yx0.js";
|
|
12
12
|
import"../../shared/@ai-setting/roy-agent-core-jw63js86.js";
|
|
13
13
|
import"../../shared/@ai-setting/roy-agent-core-5mrynf9g.js";
|
|
14
14
|
import {
|
package/dist/env/tool/types.d.ts
CHANGED
|
@@ -56,6 +56,19 @@ export interface ToolContext {
|
|
|
56
56
|
message_id?: string;
|
|
57
57
|
/** 中断信号 */
|
|
58
58
|
abort?: AbortSignal;
|
|
59
|
+
/**
|
|
60
|
+
* Task #4623 — 本次 run 使用的模型(`providerId/modelId`)。
|
|
61
|
+
*
|
|
62
|
+
* 由 AgentComponent 从 `ctx.context.model` 透传给工具,使
|
|
63
|
+
* `delegate_task` 能把父 agent 的模型继承给 sub-agent。
|
|
64
|
+
*/
|
|
65
|
+
model?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Task #4623 — 兜底模型(`providerId/modelId`)。
|
|
68
|
+
*
|
|
69
|
+
* 主模型调用失败(404 / 429 / 配额 / 5xx / 超时 / 重试耗尽)时自动切换。
|
|
70
|
+
*/
|
|
71
|
+
fallbackModel?: string;
|
|
59
72
|
/** 额外元数据 */
|
|
60
73
|
metadata?: Record<string, unknown>;
|
|
61
74
|
/** 沙箱配置 */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WorkflowComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-ebws32tv.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-dfqhc9ey.js";
|
|
5
5
|
import {
|
|
6
6
|
Edge,
|
|
@@ -14,9 +14,9 @@ import {
|
|
|
14
14
|
DecoratorNode,
|
|
15
15
|
init_decorator_node
|
|
16
16
|
} from "../../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
17
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
18
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
19
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
import"../../shared/@ai-setting/roy-agent-core-60f7h284.js";
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-bm3gav5d.js";
|
|
19
|
+
import"../../shared/@ai-setting/roy-agent-core-1dnsk6ht.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-6wxww10t.js";
|
|
22
22
|
import"../../shared/@ai-setting/roy-agent-core-bpvz1dqr.js";
|
|
@@ -85,10 +85,11 @@ import {
|
|
|
85
85
|
unresolvedVariable
|
|
86
86
|
} from "../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
|
|
87
87
|
import"../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
88
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
89
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
88
|
+
import"../../shared/@ai-setting/roy-agent-core-rfhxj8v2.js";
|
|
89
|
+
import"../../shared/@ai-setting/roy-agent-core-03k5drfp.js";
|
|
90
90
|
import"../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
91
91
|
import"../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
92
|
+
import"../../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
|
|
92
93
|
import {
|
|
93
94
|
AskUserError,
|
|
94
95
|
createNodeInterruptEvent,
|
|
@@ -24,9 +24,9 @@ import {
|
|
|
24
24
|
getRunWorkflowTool,
|
|
25
25
|
initRunWorkflowTool,
|
|
26
26
|
resetRunWorkflowTool
|
|
27
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
28
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
29
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
} from "../../../shared/@ai-setting/roy-agent-core-60f7h284.js";
|
|
28
|
+
import"../../../shared/@ai-setting/roy-agent-core-bm3gav5d.js";
|
|
29
|
+
import"../../../shared/@ai-setting/roy-agent-core-1dnsk6ht.js";
|
|
30
30
|
import"../../../shared/@ai-setting/roy-agent-core-6wxww10t.js";
|
|
31
31
|
import {
|
|
32
32
|
WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME,
|
|
@@ -41,10 +41,11 @@ import"../../../shared/@ai-setting/roy-agent-core-kmvw6b4v.js";
|
|
|
41
41
|
import"../../../shared/@ai-setting/roy-agent-core-p6a4v4fq.js";
|
|
42
42
|
import"../../../shared/@ai-setting/roy-agent-core-jrj30vq3.js";
|
|
43
43
|
import"../../../shared/@ai-setting/roy-agent-core-rvxg1wps.js";
|
|
44
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
45
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
44
|
+
import"../../../shared/@ai-setting/roy-agent-core-rfhxj8v2.js";
|
|
45
|
+
import"../../../shared/@ai-setting/roy-agent-core-03k5drfp.js";
|
|
46
46
|
import"../../../shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
47
47
|
import"../../../shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
48
|
+
import"../../../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
|
|
48
49
|
import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
49
50
|
import"../../../shared/@ai-setting/roy-agent-core-7hh0brvs.js";
|
|
50
51
|
import"../../../shared/@ai-setting/roy-agent-core-gtdtzbs7.js";
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ModelLimitsSchema,
|
|
6
6
|
ProviderCapabilitiesSchema,
|
|
7
7
|
ProviderConfigSchema
|
|
8
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "./shared/@ai-setting/roy-agent-core-2cw72f16.js";
|
|
9
9
|
import"./shared/@ai-setting/roy-agent-core-wjmwwc4a.js";
|
|
10
10
|
import"./shared/@ai-setting/roy-agent-core-pnj0zh25.js";
|
|
11
11
|
import {
|
|
@@ -61,13 +61,13 @@ import {
|
|
|
61
61
|
BaseEnvironment,
|
|
62
62
|
generateDescendingId,
|
|
63
63
|
generateId
|
|
64
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
64
|
+
} from "./shared/@ai-setting/roy-agent-core-b4zdm2n4.js";
|
|
65
65
|
import {
|
|
66
66
|
TaskComponent
|
|
67
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
67
|
+
} from "./shared/@ai-setting/roy-agent-core-5hq4v41q.js";
|
|
68
68
|
import"./shared/@ai-setting/roy-agent-core-amkqnyzy.js";
|
|
69
69
|
import"./shared/@ai-setting/roy-agent-core-jm136jzh.js";
|
|
70
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
70
|
+
import"./shared/@ai-setting/roy-agent-core-gnt23yx0.js";
|
|
71
71
|
import"./shared/@ai-setting/roy-agent-core-jw63js86.js";
|
|
72
72
|
import"./shared/@ai-setting/roy-agent-core-5mrynf9g.js";
|
|
73
73
|
import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
@@ -75,7 +75,7 @@ import"./shared/@ai-setting/roy-agent-core-as0dd70m.js";
|
|
|
75
75
|
import"./shared/@ai-setting/roy-agent-core-rn57psp0.js";
|
|
76
76
|
import {
|
|
77
77
|
EventSourceComponent
|
|
78
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
78
|
+
} from "./shared/@ai-setting/roy-agent-core-g6pw4esq.js";
|
|
79
79
|
import {
|
|
80
80
|
BountyIMInstance,
|
|
81
81
|
TimerInstance,
|
|
@@ -87,7 +87,7 @@ import {
|
|
|
87
87
|
larkCliHandler,
|
|
88
88
|
resolveBountyIMSystemPrompt,
|
|
89
89
|
timerHandler
|
|
90
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
90
|
+
} from "./shared/@ai-setting/roy-agent-core-t6nx0rsz.js";
|
|
91
91
|
import {
|
|
92
92
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
93
93
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -97,7 +97,7 @@ import {
|
|
|
97
97
|
isValidEventSourceType,
|
|
98
98
|
validateEventSourceConfig
|
|
99
99
|
} from "./shared/@ai-setting/roy-agent-core-bxkjk7zx.js";
|
|
100
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
100
|
+
import"./shared/@ai-setting/roy-agent-core-va4m04e8.js";
|
|
101
101
|
import {
|
|
102
102
|
CLI_COMMAND_ES_TYPE,
|
|
103
103
|
CLI_SESSION_CHAT_ID_PREFIX,
|
|
@@ -134,7 +134,7 @@ import"./shared/@ai-setting/roy-agent-core-cxpgd415.js";
|
|
|
134
134
|
import"./shared/@ai-setting/roy-agent-core-m3w3ytxt.js";
|
|
135
135
|
import {
|
|
136
136
|
WorkflowComponent
|
|
137
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
137
|
+
} from "./shared/@ai-setting/roy-agent-core-ebws32tv.js";
|
|
138
138
|
import {
|
|
139
139
|
init_node_registry_helper,
|
|
140
140
|
registerDecoratorNodeType
|
|
@@ -147,13 +147,13 @@ import {
|
|
|
147
147
|
createWorkflowFromClass
|
|
148
148
|
} from "./shared/@ai-setting/roy-agent-core-h0x19xgn.js";
|
|
149
149
|
import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
150
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
150
|
+
import"./shared/@ai-setting/roy-agent-core-60f7h284.js";
|
|
151
151
|
import {
|
|
152
152
|
SessionComponent
|
|
153
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
153
|
+
} from "./shared/@ai-setting/roy-agent-core-bm3gav5d.js";
|
|
154
154
|
import {
|
|
155
155
|
MemorySessionStore
|
|
156
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
156
|
+
} from "./shared/@ai-setting/roy-agent-core-1dnsk6ht.js";
|
|
157
157
|
import"./shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
158
158
|
import"./shared/@ai-setting/roy-agent-core-6wxww10t.js";
|
|
159
159
|
import"./shared/@ai-setting/roy-agent-core-bpvz1dqr.js";
|
|
@@ -178,7 +178,7 @@ import"./shared/@ai-setting/roy-agent-core-jagkferh.js";
|
|
|
178
178
|
import {
|
|
179
179
|
AgentComponent,
|
|
180
180
|
AgentComponentConfigSchema
|
|
181
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
181
|
+
} from "./shared/@ai-setting/roy-agent-core-g23yp3t1.js";
|
|
182
182
|
import {
|
|
183
183
|
ToolComponent,
|
|
184
184
|
ToolRegistry,
|
|
@@ -194,7 +194,7 @@ import {
|
|
|
194
194
|
getXDGPaths
|
|
195
195
|
} from "./shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
196
196
|
import"./shared/@ai-setting/roy-agent-core-p8rf4z89.js";
|
|
197
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
197
|
+
import"./shared/@ai-setting/roy-agent-core-rfhxj8v2.js";
|
|
198
198
|
import {
|
|
199
199
|
buildOpencodeHeaders,
|
|
200
200
|
createInvokeConfig,
|
|
@@ -203,7 +203,7 @@ import {
|
|
|
203
203
|
isOpencodeEndpoint,
|
|
204
204
|
isOpencodeProvider,
|
|
205
205
|
parseModelString
|
|
206
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
206
|
+
} from "./shared/@ai-setting/roy-agent-core-03k5drfp.js";
|
|
207
207
|
import {
|
|
208
208
|
ATTACH_FILE_MAX_BYTES,
|
|
209
209
|
isMediaType,
|
|
@@ -211,6 +211,7 @@ import {
|
|
|
211
211
|
sniffMimeType
|
|
212
212
|
} from "./shared/@ai-setting/roy-agent-core-zjdzk1gg.js";
|
|
213
213
|
import"./shared/@ai-setting/roy-agent-core-c1v263jn.js";
|
|
214
|
+
import"./shared/@ai-setting/roy-agent-core-ntn32q7j.js";
|
|
214
215
|
import {
|
|
215
216
|
AskUserError,
|
|
216
217
|
init_workflow_hil
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
sniffImageMime
|
|
3
3
|
} from "./roy-agent-core-zjdzk1gg.js";
|
|
4
|
+
import {
|
|
5
|
+
redactErrorForTransport,
|
|
6
|
+
redactSecrets
|
|
7
|
+
} from "./roy-agent-core-ntn32q7j.js";
|
|
4
8
|
import {
|
|
5
9
|
TracedAs,
|
|
6
10
|
embedParamFilter,
|
|
@@ -523,6 +527,35 @@ function resolvePiModel(provider, modelId, baseURL, capabilities) {
|
|
|
523
527
|
maxTokens: KNOWN_PROVIDER_APIS[provider]?.maxTokensLimit || 8192
|
|
524
528
|
};
|
|
525
529
|
}
|
|
530
|
+
var PI_MAX_RETRIES = 0;
|
|
531
|
+
function createResponseCapture() {
|
|
532
|
+
let last;
|
|
533
|
+
return {
|
|
534
|
+
onResponse: (response) => {
|
|
535
|
+
last = {
|
|
536
|
+
status: response?.status ?? 0,
|
|
537
|
+
headers: { ...response?.headers ?? {} }
|
|
538
|
+
};
|
|
539
|
+
},
|
|
540
|
+
captured: () => last
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
function buildProviderError(message, captured, knownSecrets = []) {
|
|
544
|
+
const err = new Error(redactSecrets(message, knownSecrets));
|
|
545
|
+
if (!captured)
|
|
546
|
+
return err;
|
|
547
|
+
const enriched = err;
|
|
548
|
+
if (captured.status)
|
|
549
|
+
enriched.statusCode = captured.status;
|
|
550
|
+
if (Object.keys(captured.headers).length > 0) {
|
|
551
|
+
enriched.responseHeaders = captured.headers;
|
|
552
|
+
}
|
|
553
|
+
enriched.cause = {
|
|
554
|
+
statusCode: captured.status,
|
|
555
|
+
responseHeaders: captured.headers
|
|
556
|
+
};
|
|
557
|
+
return enriched;
|
|
558
|
+
}
|
|
526
559
|
function toPiMessages(messages) {
|
|
527
560
|
const out = [];
|
|
528
561
|
const ts = Date.now();
|
|
@@ -647,12 +680,14 @@ class PiAiAdapter {
|
|
|
647
680
|
messages: toPiMessages(req.messages),
|
|
648
681
|
tools: toPiTools(req.tools)
|
|
649
682
|
};
|
|
683
|
+
const responseCapture = createResponseCapture();
|
|
650
684
|
const msg = await complete(model, ctx, {
|
|
651
685
|
apiKey: req.apiKey,
|
|
652
686
|
baseURL: req.baseURL,
|
|
653
687
|
temperature: req.temperature,
|
|
654
688
|
maxTokens: req.maxTokens,
|
|
655
689
|
signal: req.signal,
|
|
690
|
+
onResponse: responseCapture.onResponse,
|
|
656
691
|
...buildPiCacheOptions({
|
|
657
692
|
apiProtocol: model.api,
|
|
658
693
|
sessionId: req.sessionId,
|
|
@@ -662,8 +697,12 @@ class PiAiAdapter {
|
|
|
662
697
|
provider: req.provider,
|
|
663
698
|
modelId: req.modelId
|
|
664
699
|
}),
|
|
700
|
+
maxRetries: PI_MAX_RETRIES,
|
|
665
701
|
...piRequestExtras(req)
|
|
666
702
|
});
|
|
703
|
+
if (msg.stopReason === "error") {
|
|
704
|
+
throw buildProviderError(msg.errorMessage || "Provider returned an error stop reason", responseCapture.captured(), [req.apiKey]);
|
|
705
|
+
}
|
|
667
706
|
return fromAssistantMessage(msg);
|
|
668
707
|
}
|
|
669
708
|
async stream(req) {
|
|
@@ -675,12 +714,14 @@ class PiAiAdapter {
|
|
|
675
714
|
messages: toPiMessages(req.messages),
|
|
676
715
|
tools: toPiTools(req.tools)
|
|
677
716
|
};
|
|
717
|
+
const responseCapture = createResponseCapture();
|
|
678
718
|
const eventStream = piStream(model, ctx, {
|
|
679
719
|
apiKey: req.apiKey,
|
|
680
720
|
baseURL: req.baseURL,
|
|
681
721
|
temperature: req.temperature,
|
|
682
722
|
maxTokens: req.maxTokens,
|
|
683
723
|
signal: req.signal,
|
|
724
|
+
onResponse: responseCapture.onResponse,
|
|
684
725
|
...buildPiCacheOptions({
|
|
685
726
|
apiProtocol: model.api,
|
|
686
727
|
sessionId: req.sessionId,
|
|
@@ -690,9 +731,19 @@ class PiAiAdapter {
|
|
|
690
731
|
provider: req.provider,
|
|
691
732
|
modelId: req.modelId
|
|
692
733
|
}),
|
|
734
|
+
maxRetries: PI_MAX_RETRIES,
|
|
693
735
|
...piRequestExtras(req)
|
|
694
736
|
});
|
|
695
|
-
return {
|
|
737
|
+
return {
|
|
738
|
+
events: eventStream,
|
|
739
|
+
result: async () => {
|
|
740
|
+
const msg = await eventStream.result();
|
|
741
|
+
if (msg.stopReason === "error") {
|
|
742
|
+
throw buildProviderError(msg.errorMessage || "Provider returned an error stop reason", responseCapture.captured(), [req.apiKey]);
|
|
743
|
+
}
|
|
744
|
+
return fromAssistantMessage(msg);
|
|
745
|
+
}
|
|
746
|
+
};
|
|
696
747
|
}
|
|
697
748
|
async embed(_req) {
|
|
698
749
|
throw new EmbeddingNotSupportedError(this.name);
|
|
@@ -1577,22 +1628,11 @@ async function invoke(config, options, ctx) {
|
|
|
1577
1628
|
return {
|
|
1578
1629
|
toolCallId: "error-" + Date.now(),
|
|
1579
1630
|
result: safeMessage,
|
|
1580
|
-
isError: true
|
|
1631
|
+
isError: true,
|
|
1632
|
+
...error instanceof Error ? { originalError: redactErrorForTransport(error, [config.apiKey]) } : {}
|
|
1581
1633
|
};
|
|
1582
1634
|
}
|
|
1583
1635
|
}
|
|
1584
|
-
function redactSecrets(text, knownSecrets = []) {
|
|
1585
|
-
let out = text;
|
|
1586
|
-
for (const secret of knownSecrets) {
|
|
1587
|
-
if (secret && secret.length >= 8) {
|
|
1588
|
-
out = out.split(secret).join("<redacted>");
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
out = out.replace(/\boc_sk_[A-Za-z0-9_-]{8,}\b/g, "<redacted>");
|
|
1592
|
-
out = out.replace(/\bsk-(?:proj-)?[A-Za-z0-9_-]{16,}\b/g, "<redacted>");
|
|
1593
|
-
out = out.replace(/\bBearer\s+[A-Za-z0-9._\-+/=]{12,}\b/g, "<redacted>");
|
|
1594
|
-
return out;
|
|
1595
|
-
}
|
|
1596
1636
|
function resolveDefenseProtocol(providerId, baseURL) {
|
|
1597
1637
|
if (providerId === "openai")
|
|
1598
1638
|
return "openai-responses";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SessionMessageConverter
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-rfhxj8v2.js";
|
|
4
4
|
import {
|
|
5
5
|
canonicalizeParts
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-03k5drfp.js";
|
|
7
7
|
import {
|
|
8
8
|
createLogger,
|
|
9
9
|
init_logger
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
PiAiAdapter,
|
|
7
7
|
invoke,
|
|
8
8
|
invokeNonStream
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-03k5drfp.js";
|
|
10
10
|
import {
|
|
11
11
|
ContextError,
|
|
12
12
|
ErrorCodes
|
|
@@ -720,6 +720,8 @@ class LLMComponent extends BaseComponent {
|
|
|
720
720
|
const llmKeys = [
|
|
721
721
|
"llm.defaultModel",
|
|
722
722
|
"llm.defaultProvider",
|
|
723
|
+
"llm.fallbackModel",
|
|
724
|
+
"llm.fallbackProvider",
|
|
723
725
|
"llm.temperature",
|
|
724
726
|
"llm.maxTokens",
|
|
725
727
|
"llm.topP",
|
|
@@ -789,12 +791,15 @@ class LLMComponent extends BaseComponent {
|
|
|
789
791
|
const knownKeys = new Set([
|
|
790
792
|
"llm.defaultModel",
|
|
791
793
|
"llm.defaultProvider",
|
|
794
|
+
"llm.fallbackModel",
|
|
795
|
+
"llm.fallbackProvider",
|
|
792
796
|
"llm.temperature",
|
|
793
797
|
"llm.maxTokens",
|
|
794
798
|
"llm.topP",
|
|
795
799
|
"llm.stream",
|
|
796
800
|
"llm.options",
|
|
797
801
|
"llm.default",
|
|
802
|
+
"llm.fallback",
|
|
798
803
|
"llm.providers",
|
|
799
804
|
"llm.limits",
|
|
800
805
|
"llm.capabilities"
|
|
@@ -1015,7 +1020,7 @@ class LLMComponent extends BaseComponent {
|
|
|
1015
1020
|
cacheRetention: chatReq.cacheRetention
|
|
1016
1021
|
}, { abort: ctx.abortSignal });
|
|
1017
1022
|
if (result.isError) {
|
|
1018
|
-
throw new Error(result.result);
|
|
1023
|
+
throw result.originalError ? new Error(result.result, { cause: result.originalError }) : new Error(result.result);
|
|
1019
1024
|
}
|
|
1020
1025
|
try {
|
|
1021
1026
|
const parsed = JSON.parse(result.result);
|
|
@@ -273,7 +273,7 @@ class BaseEnvironment extends BaseComponent {
|
|
|
273
273
|
const ctxError = new ContextError(result.error, ErrorCodes.CONTEXT_THRESHOLD_EXCEEDED, context?.sessionId, usage, contextWindow);
|
|
274
274
|
throw ctxError;
|
|
275
275
|
}
|
|
276
|
-
throw new Error(result.error);
|
|
276
|
+
throw new Error(result.error, result.originalError ? { cause: result.originalError } : undefined);
|
|
277
277
|
}
|
|
278
278
|
return result.finalText || "";
|
|
279
279
|
}
|