@ai-setting/roy-agent-core 1.5.89 → 1.5.91
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/config/index.js +8 -8
- package/dist/env/agent/index.js +14 -14
- package/dist/env/commands/index.js +8 -8
- package/dist/env/context/index.js +4 -4
- package/dist/env/debug/index.js +8 -8
- package/dist/env/event-source/index.js +18 -14
- package/dist/env/hook/index.js +6 -6
- package/dist/env/index.js +35 -35
- package/dist/env/llm/index.js +12 -10
- package/dist/env/log-trace/index.js +8 -8
- package/dist/env/mcp/index.js +9 -9
- package/dist/env/mcp/tool/index.js +2 -2
- package/dist/env/memory/index.js +9 -9
- package/dist/env/memory/plugin/index.js +2 -2
- package/dist/env/plugin/index.js +8 -8
- package/dist/env/prompt/index.js +9 -9
- package/dist/env/session/index.js +11 -11
- package/dist/env/session/storage/index.js +4 -4
- package/dist/env/skill/index.js +8 -8
- package/dist/env/task/delegate/index.js +7 -7
- package/dist/env/task/index.js +12 -12
- package/dist/env/task/plugins/index.js +7 -7
- package/dist/env/task/storage/index.js +2 -2
- package/dist/env/task/tools/index.js +4 -4
- package/dist/env/tool/built-in/index.js +3 -3
- package/dist/env/tool/index.js +10 -10
- package/dist/env/workflow/engine/index.js +9 -9
- package/dist/env/workflow/index.js +15 -15
- package/dist/env/workflow/nodes/index.js +3 -3
- package/dist/env/workflow/service/index.js +3 -3
- package/dist/env/workflow/storage/index.js +4 -4
- package/dist/env/workflow/tools/index.js +4 -4
- package/dist/env/workflow/utils/index.js +3 -3
- package/dist/index.js +155 -50
- package/dist/shared/@ai-setting/{roy-agent-core-fvfc7f6v.js → roy-agent-core-0ger6zdn.js} +65 -11
- package/dist/shared/@ai-setting/{roy-agent-core-bwjpte58.js → roy-agent-core-0vsnecwa.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-h5867smx.js → roy-agent-core-0ye4q2jj.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-prdngx28.js → roy-agent-core-33rhv946.js} +43 -7
- package/dist/shared/@ai-setting/{roy-agent-core-djtkntar.js → roy-agent-core-4w6rgxs4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-fgpnv7dt.js → roy-agent-core-55br4t6v.js} +80 -37
- package/dist/shared/@ai-setting/{roy-agent-core-3952rkj0.js → roy-agent-core-578qk38y.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-2q7cshpm.js → roy-agent-core-5j649pb1.js} +289 -21
- package/dist/shared/@ai-setting/{roy-agent-core-2h38rvyj.js → roy-agent-core-634ee5jb.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-w6bmrgap.js → roy-agent-core-7svhckhz.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-ce10b0ez.js → roy-agent-core-8x4ngxcy.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-83d035pp.js → roy-agent-core-97tjdb2r.js} +70 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qbq3jgrn.js → roy-agent-core-9amq4epa.js} +14 -14
- package/dist/shared/@ai-setting/{roy-agent-core-pcdzfwdv.js → roy-agent-core-9xby523m.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-mw4ty0ba.js → roy-agent-core-at05dk0z.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-ewr1nw7t.js → roy-agent-core-b1vkkcbr.js} +7 -7
- package/dist/shared/@ai-setting/{roy-agent-core-n19rm7tw.js → roy-agent-core-b2thb9xj.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-3sv590cv.js → roy-agent-core-b77yz0wt.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-yanpq5gb.js → roy-agent-core-bdajt9cs.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-3czy06aq.js → roy-agent-core-bqwj1dq0.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-k05v31rc.js → roy-agent-core-cg146hmg.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-07290s9n.js → roy-agent-core-cx67bv9d.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-taxvytzz.js → roy-agent-core-cx9p8b2t.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-d6597yp0.js → roy-agent-core-ddghwfmk.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-vneyghpg.js → roy-agent-core-ddq5hcp5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qhhxx2x2.js → roy-agent-core-ds5f75pg.js} +2 -1
- package/dist/shared/@ai-setting/{roy-agent-core-tq9528d3.js → roy-agent-core-e7t3rj0e.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-h2d1s8yd.js → roy-agent-core-fg5eaht3.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-q7sqeax6.js → roy-agent-core-fx1fdzbz.js} +163 -3
- package/dist/shared/@ai-setting/{roy-agent-core-hc20420t.js → roy-agent-core-g2mth323.js} +28 -4
- package/dist/shared/@ai-setting/{roy-agent-core-7tp56w6n.js → roy-agent-core-gp872e7m.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-c67wr8sp.js → roy-agent-core-hf8pqrvy.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-32m0nb9j.js → roy-agent-core-j3qb695p.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-r0m0at3x.js → roy-agent-core-j7jeqxhd.js} +121 -9
- package/dist/shared/@ai-setting/{roy-agent-core-h4h55x4h.js → roy-agent-core-jexyz11d.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-hxsbegfc.js → roy-agent-core-jf865m5b.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-b8r4tfqq.js → roy-agent-core-ksx9a556.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rgckng3p.js → roy-agent-core-pf1c360e.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-xckhrs2p.js → roy-agent-core-q7ffkt1e.js} +6 -6
- package/dist/shared/@ai-setting/{roy-agent-core-gb9gbkc3.js → roy-agent-core-q88vxmx5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-y5d04fm3.js → roy-agent-core-scp0afxg.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-3f6k060j.js → roy-agent-core-snvsn60t.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-xnxyzaw4.js → roy-agent-core-spzb03na.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-86d4exyf.js → roy-agent-core-sssn8kt9.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-m3dkyprg.js → roy-agent-core-svcr4gjw.js} +14 -9
- package/dist/shared/@ai-setting/{roy-agent-core-nqzt9ne4.js → roy-agent-core-vady4w02.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-shme7set.js → roy-agent-core-vyygk314.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-5kdw0p98.js → roy-agent-core-w1s8yrm5.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-v8xa6vs8.js → roy-agent-core-wmkx79b1.js} +14 -12
- package/dist/shared/@ai-setting/{roy-agent-core-t1ef8hf2.js → roy-agent-core-ws76avbn.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-xhcgg11h.js → roy-agent-core-wtbyj0q1.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-fjexv5nm.js → roy-agent-core-xgnpr28w.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-c1j7ev4e.js → roy-agent-core-yfhgxh5a.js} +71 -1
- package/dist/shared/@ai-setting/{roy-agent-core-qg4rma4c.js → roy-agent-core-zttjq1h3.js} +1 -1
- package/package.json +1 -1
- /package/dist/shared/@ai-setting/{roy-agent-core-4f3976cd.js → roy-agent-core-k5hxvaf0.js} +0 -0
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
WorkflowRepository,
|
|
3
3
|
migrateEmptyTagsToDefault,
|
|
4
4
|
rowToWorkflow
|
|
5
|
-
} from "./roy-agent-core-
|
|
6
|
-
import"./roy-agent-core-
|
|
5
|
+
} from "./roy-agent-core-jexyz11d.js";
|
|
6
|
+
import"./roy-agent-core-b77yz0wt.js";
|
|
7
7
|
import"./roy-agent-core-rvxg1wps.js";
|
|
8
|
-
import"./roy-agent-core-
|
|
9
|
-
import"./roy-agent-core-
|
|
8
|
+
import"./roy-agent-core-cg146hmg.js";
|
|
9
|
+
import"./roy-agent-core-vyygk314.js";
|
|
10
10
|
import"./roy-agent-core-7z9b1fm8.js";
|
|
11
11
|
import"./roy-agent-core-c6592r3c.js";
|
|
12
12
|
import"./roy-agent-core-fs0mn2jk.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WORKFLOW_EXTRACT_PROMPT
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-97tjdb2r.js";
|
|
4
4
|
import {
|
|
5
5
|
BasePlugin
|
|
6
6
|
} from "./roy-agent-core-az13yzmc.js";
|
|
@@ -12,18 +12,18 @@ import {
|
|
|
12
12
|
} from "./roy-agent-core-92z6t4he.js";
|
|
13
13
|
import {
|
|
14
14
|
init_context
|
|
15
|
-
} from "./roy-agent-core-
|
|
15
|
+
} from "./roy-agent-core-zttjq1h3.js";
|
|
16
16
|
import {
|
|
17
17
|
getEnvContextOrEmpty
|
|
18
|
-
} from "./roy-agent-core-
|
|
18
|
+
} from "./roy-agent-core-scp0afxg.js";
|
|
19
19
|
import {
|
|
20
20
|
TracedAs,
|
|
21
21
|
init_decorator
|
|
22
|
-
} from "./roy-agent-core-
|
|
22
|
+
} from "./roy-agent-core-cg146hmg.js";
|
|
23
23
|
import {
|
|
24
24
|
createLogger,
|
|
25
25
|
init_logger
|
|
26
|
-
} from "./roy-agent-core-
|
|
26
|
+
} from "./roy-agent-core-vyygk314.js";
|
|
27
27
|
import {
|
|
28
28
|
__legacyDecorateClassTS,
|
|
29
29
|
__require
|
|
@@ -288,11 +288,11 @@ ${prompt}`;
|
|
|
288
288
|
}
|
|
289
289
|
if (!this._workflowRepo) {
|
|
290
290
|
try {
|
|
291
|
-
const sqlite = await import("./roy-agent-core-
|
|
291
|
+
const sqlite = await import("./roy-agent-core-cx9p8b2t.js");
|
|
292
292
|
this.ensureDataDir();
|
|
293
293
|
const db = sqlite.getDatabase();
|
|
294
294
|
sqlite.initializeTables();
|
|
295
|
-
const { WorkflowRepository } = await import("./roy-agent-core-
|
|
295
|
+
const { WorkflowRepository } = await import("./roy-agent-core-sssn8kt9.js");
|
|
296
296
|
this._workflowRepo = new WorkflowRepository(db);
|
|
297
297
|
return this._workflowRepo;
|
|
298
298
|
} catch {
|
|
@@ -461,10 +461,12 @@ ${content}`;
|
|
|
461
461
|
if (isTaskNotifyDebugEnabled()) {
|
|
462
462
|
logger2.debug(`Sending message - messageId: ${messageId}`);
|
|
463
463
|
}
|
|
464
|
+
const profile = replyChannel?.profile;
|
|
464
465
|
await this.sendLarkMessage({
|
|
465
466
|
chatId,
|
|
466
467
|
messageId,
|
|
467
|
-
content: message
|
|
468
|
+
content: message,
|
|
469
|
+
profile
|
|
468
470
|
});
|
|
469
471
|
logger2.info(`Notification sent: ${type}`);
|
|
470
472
|
} catch (error) {
|
|
@@ -473,7 +475,7 @@ ${content}`;
|
|
|
473
475
|
}
|
|
474
476
|
sendLarkMessage(options) {
|
|
475
477
|
return new Promise((resolve, reject) => {
|
|
476
|
-
const { chatId, messageId, content } = options;
|
|
478
|
+
const { chatId, messageId, content, profile } = options;
|
|
477
479
|
let args;
|
|
478
480
|
if (messageId) {
|
|
479
481
|
args = [
|
|
@@ -496,6 +498,9 @@ ${content}`;
|
|
|
496
498
|
content
|
|
497
499
|
];
|
|
498
500
|
}
|
|
501
|
+
if (profile) {
|
|
502
|
+
args.unshift("--profile", profile);
|
|
503
|
+
}
|
|
499
504
|
const proc = spawn("lark-cli", args, {
|
|
500
505
|
shell: false,
|
|
501
506
|
stdio: ["pipe", "pipe", "pipe"]
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
TracedAs,
|
|
6
6
|
init_decorator
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-cg146hmg.js";
|
|
8
8
|
import {
|
|
9
9
|
createLogger,
|
|
10
10
|
init_logger
|
|
11
|
-
} from "./roy-agent-core-
|
|
11
|
+
} from "./roy-agent-core-vyygk314.js";
|
|
12
12
|
import {
|
|
13
13
|
__legacyDecorateClassTS
|
|
14
14
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
@@ -113,7 +113,7 @@ function expandHomeDir(path) {
|
|
|
113
113
|
}
|
|
114
114
|
function getLogFile() {
|
|
115
115
|
if (configComponentInstance) {
|
|
116
|
-
const file = configComponentInstance.get("
|
|
116
|
+
const file = configComponentInstance.get("log-trace.logging.file");
|
|
117
117
|
if (file) {
|
|
118
118
|
return file;
|
|
119
119
|
}
|
|
@@ -122,7 +122,7 @@ function getLogFile() {
|
|
|
122
122
|
}
|
|
123
123
|
function getLogDir() {
|
|
124
124
|
if (configComponentInstance) {
|
|
125
|
-
const dir = configComponentInstance.get("
|
|
125
|
+
const dir = configComponentInstance.get("log-trace.logging.dir");
|
|
126
126
|
if (dir) {
|
|
127
127
|
return dir;
|
|
128
128
|
}
|
|
@@ -9,16 +9,16 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
globalHookManager,
|
|
11
11
|
init_global_hook_manager
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-gp872e7m.js";
|
|
13
13
|
import {
|
|
14
14
|
TracedAs,
|
|
15
15
|
init_decorator,
|
|
16
16
|
wrapFunction
|
|
17
|
-
} from "./roy-agent-core-
|
|
17
|
+
} from "./roy-agent-core-cg146hmg.js";
|
|
18
18
|
import {
|
|
19
19
|
createLogger,
|
|
20
20
|
init_logger
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-vyygk314.js";
|
|
22
22
|
import {
|
|
23
23
|
__esm,
|
|
24
24
|
__legacyDecorateClassTS
|
|
@@ -3,16 +3,16 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseComponent
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-pf1c360e.js";
|
|
7
7
|
import {
|
|
8
8
|
init_decorator
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-cg146hmg.js";
|
|
10
10
|
import {
|
|
11
11
|
createLogger,
|
|
12
12
|
init_logger,
|
|
13
13
|
setConfigComponent,
|
|
14
14
|
setQuietMode
|
|
15
|
-
} from "./roy-agent-core-
|
|
15
|
+
} from "./roy-agent-core-vyygk314.js";
|
|
16
16
|
import {
|
|
17
17
|
getTracerProvider,
|
|
18
18
|
init_propagation,
|
|
@@ -151,14 +151,14 @@ var LOG_TRACE_CONFIG_REGISTRATION = {
|
|
|
151
151
|
{ type: "env", envPrefix: "LOG_TRACE", priority: 20, watch: false }
|
|
152
152
|
],
|
|
153
153
|
keys: [
|
|
154
|
-
{ key: "log-trace.logging.enabled", sources: ["env", "file"] },
|
|
155
|
-
{ key: "log-trace.logging.level", sources: ["env", "file"] },
|
|
156
|
-
{ key: "log-trace.logging.quiet", sources: ["env", "file"] },
|
|
157
|
-
{ key: "log-trace.logging.dir", sources: ["env", "file"] },
|
|
158
|
-
{ key: "log-trace.logging.file", sources: ["env", "file"] },
|
|
159
|
-
{ key: "log-trace.logging.maxOutput", sources: ["env", "file"] },
|
|
160
|
-
{ key: "log-trace.tracing.enabled", sources: ["env", "file"] },
|
|
161
|
-
{ key: "log-trace.tracing.dbPath", sources: ["env", "file"] }
|
|
154
|
+
{ key: "log-trace.logging.enabled", sources: ["project", "env", "file"] },
|
|
155
|
+
{ key: "log-trace.logging.level", sources: ["project", "env", "file"] },
|
|
156
|
+
{ key: "log-trace.logging.quiet", sources: ["project", "env", "file"] },
|
|
157
|
+
{ key: "log-trace.logging.dir", sources: ["project", "env", "file"] },
|
|
158
|
+
{ key: "log-trace.logging.file", sources: ["project", "env", "file"] },
|
|
159
|
+
{ key: "log-trace.logging.maxOutput", sources: ["project", "env", "file"] },
|
|
160
|
+
{ key: "log-trace.tracing.enabled", sources: ["project", "env", "file"] },
|
|
161
|
+
{ key: "log-trace.tracing.dbPath", sources: ["project", "env", "file"] }
|
|
162
162
|
]
|
|
163
163
|
};
|
|
164
164
|
|
|
@@ -232,9 +232,11 @@ class LogTraceComponent extends BaseComponent {
|
|
|
232
232
|
const configComponent = options.configComponent;
|
|
233
233
|
if (!configComponent)
|
|
234
234
|
return;
|
|
235
|
-
const { configPath, envPrefix, config } = options;
|
|
235
|
+
const { configPath, envPrefix, cwd, config } = options;
|
|
236
236
|
const prefix = envPrefix !== undefined ? envPrefix : "LOG_TRACE";
|
|
237
|
+
const projectCwd = cwd ?? process.cwd();
|
|
237
238
|
configComponent.registerComponent(LOG_TRACE_CONFIG_REGISTRATION);
|
|
239
|
+
configComponent.registerProjectSource({ cwd: projectCwd });
|
|
238
240
|
if (configPath) {
|
|
239
241
|
configComponent.registerSource({
|
|
240
242
|
type: "file",
|
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-az13yzmc.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseComponent
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-pf1c360e.js";
|
|
7
7
|
import {
|
|
8
8
|
globalHookManager,
|
|
9
9
|
init_global_hook_manager
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-gp872e7m.js";
|
|
11
11
|
import {
|
|
12
12
|
createLogger,
|
|
13
13
|
init_logger
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-vyygk314.js";
|
|
15
15
|
|
|
16
16
|
// src/env/plugin/plugin-component.ts
|
|
17
17
|
init_global_hook_manager();
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
import {
|
|
10
10
|
TracedAs,
|
|
11
11
|
init_decorator
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-cg146hmg.js";
|
|
13
13
|
import {
|
|
14
14
|
createLogger,
|
|
15
15
|
init_logger
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-vyygk314.js";
|
|
17
17
|
import {
|
|
18
18
|
__esm,
|
|
19
19
|
__export,
|
|
@@ -1,10 +1,45 @@
|
|
|
1
1
|
import {
|
|
2
2
|
safeParseToolArgs
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-8x4ngxcy.js";
|
|
4
4
|
|
|
5
5
|
// src/env/session/session-message-converter.ts
|
|
6
6
|
import { randomUUID } from "crypto";
|
|
7
7
|
var DEFAULT_REASONING_BUDGET_TOKENS = 1e4;
|
|
8
|
+
function toModelImagePart(imagePart) {
|
|
9
|
+
return {
|
|
10
|
+
type: "image",
|
|
11
|
+
image: normalizeImagePayload(imagePart.image, imagePart.mimeType),
|
|
12
|
+
mimeType: imagePart.mimeType
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function isLegacyBufferShape(v) {
|
|
16
|
+
return typeof v === "object" && v !== null && !Array.isArray(v) && !(v instanceof Uint8Array) && !(v instanceof URL) && v.type === "Buffer" && Array.isArray(v.data);
|
|
17
|
+
}
|
|
18
|
+
function normalizeImagePayload(image, mimeType) {
|
|
19
|
+
if (typeof image === "string" || image instanceof URL) {
|
|
20
|
+
return image;
|
|
21
|
+
}
|
|
22
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer(image)) {
|
|
23
|
+
const mime = mimeType ?? "image/jpeg";
|
|
24
|
+
return `data:${mime};base64,${image.toString("base64")}`;
|
|
25
|
+
}
|
|
26
|
+
if (image instanceof Uint8Array) {
|
|
27
|
+
if (typeof Buffer !== "undefined") {
|
|
28
|
+
const mime2 = mimeType ?? "image/jpeg";
|
|
29
|
+
return `data:${mime2};base64,${Buffer.from(image).toString("base64")}`;
|
|
30
|
+
}
|
|
31
|
+
let binary = "";
|
|
32
|
+
for (let i = 0;i < image.length; i++) {
|
|
33
|
+
binary += String.fromCharCode(image[i]);
|
|
34
|
+
}
|
|
35
|
+
const mime = mimeType ?? "image/jpeg";
|
|
36
|
+
return `data:${mime};base64,${globalThis.btoa?.(binary) ?? binary}`;
|
|
37
|
+
}
|
|
38
|
+
if (isLegacyBufferShape(image)) {
|
|
39
|
+
return new Uint8Array(image.data);
|
|
40
|
+
}
|
|
41
|
+
return image;
|
|
42
|
+
}
|
|
8
43
|
|
|
9
44
|
class SessionMessageConverter {
|
|
10
45
|
toModelMessage(msg) {
|
|
@@ -47,6 +82,8 @@ class SessionMessageConverter {
|
|
|
47
82
|
mimeType: filePart.mime,
|
|
48
83
|
filename: filePart.filename
|
|
49
84
|
});
|
|
85
|
+
} else if (part.type === "image") {
|
|
86
|
+
content.push(toModelImagePart(part));
|
|
50
87
|
} else if (part.type === "tool-result" || part.type === "checkpoint") {} else {
|
|
51
88
|
console.debug(`[session-message-converter] Skipping unsupported part type in assistant: ${part.type}`);
|
|
52
89
|
}
|
|
@@ -68,6 +105,32 @@ class SessionMessageConverter {
|
|
|
68
105
|
}]
|
|
69
106
|
};
|
|
70
107
|
}
|
|
108
|
+
if (msg.role === "user" || msg.role === "system") {
|
|
109
|
+
const parts = msg.parts || [];
|
|
110
|
+
const hasMultimodal = parts.some((p) => p.type === "image" || p.type === "file");
|
|
111
|
+
if (hasMultimodal) {
|
|
112
|
+
const content = [];
|
|
113
|
+
for (const part of parts) {
|
|
114
|
+
if (part.type === "text") {
|
|
115
|
+
content.push({ type: "text", text: part.content });
|
|
116
|
+
} else if (part.type === "image") {
|
|
117
|
+
content.push(toModelImagePart(part));
|
|
118
|
+
} else if (part.type === "file") {
|
|
119
|
+
const filePart = part;
|
|
120
|
+
content.push({
|
|
121
|
+
type: "file",
|
|
122
|
+
url: filePart.url,
|
|
123
|
+
mimeType: filePart.mime,
|
|
124
|
+
filename: filePart.filename
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
role: msg.role,
|
|
130
|
+
content
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
71
134
|
return {
|
|
72
135
|
role: msg.role,
|
|
73
136
|
content: msg.content || ""
|
|
@@ -121,6 +184,13 @@ class SessionMessageConverter {
|
|
|
121
184
|
url: p.url,
|
|
122
185
|
filename: p.filename
|
|
123
186
|
});
|
|
187
|
+
} else if (p.type === "image") {
|
|
188
|
+
const imageData = normalizeImagePayload(p.image, p.mimeType);
|
|
189
|
+
parts.push({
|
|
190
|
+
type: "image",
|
|
191
|
+
image: imageData,
|
|
192
|
+
mimeType: p.mimeType
|
|
193
|
+
});
|
|
124
194
|
} else {
|
|
125
195
|
console.debug(`[session-message-converter] Unknown part type: ${p.type}`);
|
|
126
196
|
}
|
package/package.json
CHANGED
|
File without changes
|