buckyos 0.7.121 → 0.7.123

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.
@@ -498,14 +498,14 @@ var TaskEventType = /* @__PURE__ */ ((TaskEventType2) => {
498
498
  TaskEventType2["PayloadRedacted"] = "PayloadRedacted";
499
499
  return TaskEventType2;
500
500
  })(TaskEventType || {});
501
- function asRecord$5(value, what) {
501
+ function asRecord$4(value, what) {
502
502
  if (!value || typeof value !== "object" || Array.isArray(value)) {
503
503
  throw new RPCError(`Expected ${what} in TaskMgr response`);
504
504
  }
505
505
  return value;
506
506
  }
507
507
  function requiredField$1(value, field, what) {
508
- const record = asRecord$5(value, what);
508
+ const record = asRecord$4(value, what);
509
509
  if (!(field in record)) {
510
510
  throw new RPCError(`Expected ${field} in TaskMgr response`);
511
511
  }
@@ -653,11 +653,11 @@ class TaskManagerClient {
653
653
  }
654
654
  async listTaskSchemas(request = {}) {
655
655
  const result = await this.rpcClient.call("list_task_schemas", request);
656
- const schemas = requiredField$1(result, "schemas", "task schema list");
657
- if (!Array.isArray(schemas)) {
656
+ const schemas2 = requiredField$1(result, "schemas", "task schema list");
657
+ if (!Array.isArray(schemas2)) {
658
658
  throw new RPCError("Expected schemas array in TaskMgr response");
659
659
  }
660
- return schemas;
660
+ return schemas2;
661
661
  }
662
662
  async setTaskSchemaEnabled(schemaId, schemaVersion, enabled) {
663
663
  return this.rpcClient.call("set_task_schema_enabled", {
@@ -883,7 +883,7 @@ var WorkflowScheduledTaskFireStatus = /* @__PURE__ */ ((WorkflowScheduledTaskFir
883
883
  WorkflowScheduledTaskFireStatus2["Failed"] = "failed";
884
884
  return WorkflowScheduledTaskFireStatus2;
885
885
  })(WorkflowScheduledTaskFireStatus || {});
886
- function asRecord$4(value) {
886
+ function asRecord$3(value) {
887
887
  if (!value || typeof value !== "object" || Array.isArray(value)) {
888
888
  throw new RPCError("Invalid workflow RPC response format");
889
889
  }
@@ -904,7 +904,7 @@ class WorkflowClient {
904
904
  }
905
905
  async callOk(method, params) {
906
906
  const result = await this.rpcClient.call(method, params);
907
- const parsed = asRecord$4(result);
907
+ const parsed = asRecord$3(result);
908
908
  if (parsed.ok === true) {
909
909
  return parsed;
910
910
  }
@@ -1160,17 +1160,15 @@ class SystemConfigClient {
1160
1160
  await this.rpcClient.call("sys_refresh_trust_keys", {});
1161
1161
  }
1162
1162
  }
1163
- const AICC_SERVICE_NAME = "aicc";
1164
1163
  const AICC_SERVICE_UNIQUE_ID = "aicc";
1165
- const AICC_SERVICE_SERVICE_NAME = AICC_SERVICE_NAME;
1164
+ const AICC_SERVICE_SERVICE_NAME = "aicc";
1166
1165
  const AICC_SERVICE_SERVICE_PORT = 4040;
1167
1166
  const AICC_AI_METHODS = {
1168
- LLM_CHAT: "llm.chat",
1169
- LLM_COMPLETION: "llm.completion",
1167
+ CHAT_COMPLETIONS_CREATE: "chat.completions.create",
1168
+ IMAGES_GENERATE: "images.generate",
1170
1169
  EMBEDDING_TEXT: "embedding.text",
1171
1170
  EMBEDDING_MULTIMODAL: "embedding.multimodal",
1172
1171
  RERANK: "rerank",
1173
- IMAGE_TXT2IMG: "image.txt2img",
1174
1172
  IMAGE_IMG2IMG: "image.img2img",
1175
1173
  IMAGE_INPAINT: "image.inpaint",
1176
1174
  IMAGE_UPSCALE: "image.upscale",
@@ -1190,28 +1188,45 @@ const AICC_AI_METHODS = {
1190
1188
  VIDEO_UPSCALE: "video.upscale",
1191
1189
  AGENT_COMPUTER_USE: "agent.computer_use"
1192
1190
  };
1193
- const AICC_CONTROL_METHODS = {
1194
- CANCEL: "cancel",
1195
- RELOAD_SETTINGS: "reload_settings",
1191
+ const AICC_CORE_METHODS = {
1192
+ ROUTE_RESOLVE: "route.resolve",
1193
+ HELPER_LLM_CHAT: "helper.llm_chat",
1194
+ HELPER_TEXT_TO_IMAGE: "helper.text_to_image",
1195
+ CANCEL: "cancel"
1196
+ };
1197
+ const AICC_MANAGEMENT_METHODS = {
1196
1198
  SERVICE_RELOAD_SETTINGS: "service.reload_settings",
1197
1199
  QUOTA_QUERY: "quota.query",
1200
+ USAGE_QUERY: "usage.query",
1201
+ TRACE_QUERY: "trace.query",
1202
+ ROUTING_GET: "routing.get",
1203
+ ROUTING_UPDATE: "routing.update",
1204
+ PROVIDER_CATALOG: "provider.catalog",
1205
+ PROTOCOL_ADAPTER_LIST: "protocol_adapter.list",
1206
+ PROVIDER_VALIDATE: "provider.validate",
1207
+ PROVIDER_ADD: "provider.add",
1198
1208
  PROVIDER_LIST: "provider.list",
1199
- PROVIDER_HEALTH: "provider.health"
1209
+ PROVIDER_HEALTH: "provider.health",
1210
+ PROVIDER_UPDATE: "provider.update",
1211
+ PROVIDER_DELETE: "provider.delete",
1212
+ PROVIDER_REFRESH_MODELS: "provider.refresh_models",
1213
+ MODELS_LIST: "models.list",
1214
+ DRIVER_METADATA_UPDATE_GET: "driver_metadata_update.get",
1215
+ DRIVER_METADATA_UPDATE_SET: "driver_metadata_update.set"
1200
1216
  };
1217
+ const AICC_METHODS = { ...AICC_AI_METHODS, ...AICC_CORE_METHODS, ...AICC_MANAGEMENT_METHODS };
1201
1218
  const AICC_FEATURES = {
1202
1219
  PLAN: "plan",
1203
- TOOL_CALLING: "tool_calling",
1204
- JSON_OUTPUT: "json_output",
1220
+ TOOL_CALL: "tool_call",
1221
+ JSON_SCHEMA: "json_schema",
1205
1222
  WEB_SEARCH: "web_search",
1206
1223
  VISION: "vision",
1224
+ IMAGE_GENERATION: "image_generation",
1207
1225
  ASR: "asr",
1208
1226
  VIDEO_UNDERSTAND: "video_understand"
1209
1227
  };
1228
+ const AICC_EXECUTION_MODES = { IMMEDIATE: "immediate", STREAM: "stream" };
1210
1229
  const AI_METHOD_SET = new Set(Object.values(AICC_AI_METHODS));
1211
- const CAPABILITY_SET = /* @__PURE__ */ new Set(["llm", "embedding", "rerank", "image", "vision", "audio", "video", "agent"]);
1212
- const METHOD_STATUS_SET = /* @__PURE__ */ new Set(["succeeded", "running", "failed"]);
1213
- const AI_ROLE_SET = /* @__PURE__ */ new Set(["system", "user", "assistant", "tool", "developer"]);
1214
- const NON_TEXT_BLOCK_ESTIMATED_LEN = 256;
1215
1230
  function isAiccAiMethod(method) {
1216
1231
  return AI_METHOD_SET.has(method);
1217
1232
  }
@@ -1219,390 +1234,264 @@ function aiccTextMessage(role, text) {
1219
1234
  return { role, content: [{ type: "text", text }] };
1220
1235
  }
1221
1236
  function aiccMessageTextContent(message) {
1222
- return message.content.filter((block) => block.type === "text").map((block) => block.text).join("");
1237
+ return message.content.filter((b2) => b2.type === "text").map((b2) => b2.text).join("\n");
1223
1238
  }
1224
1239
  function aiccMessageFirstText(message) {
1225
1240
  var _a2;
1226
- return (_a2 = message.content.find((block) => block.type === "text")) == null ? void 0 : _a2.text;
1227
- }
1228
- function aiccResponseTextContent(response) {
1229
- return aiccMessageTextContent(response.message);
1230
- }
1231
- function aiccResponseToolCalls(response) {
1232
- return response.message.content.filter((block) => block.type === "tool_use").map((block) => ({
1233
- name: block.name,
1234
- args: block.args,
1235
- call_id: block.call_id
1236
- }));
1237
- }
1238
- function aiccResponseArtifacts(response) {
1239
- const artifacts = [];
1240
- response.message.content.forEach((block, index) => {
1241
- if (block.type === "image") {
1242
- artifacts.push({
1243
- name: `image_${index + 1}`,
1244
- resource: block.source,
1245
- mime: aiccResourceRefMime(block.source)
1246
- });
1247
- }
1248
- if (block.type === "document") {
1249
- artifacts.push({
1250
- name: block.title ?? `document_${index + 1}`,
1251
- resource: block.source,
1252
- mime: aiccResourceRefMime(block.source)
1253
- });
1254
- }
1255
- });
1256
- return artifacts;
1257
- }
1258
- function aiccRenderMessageForDebug(message) {
1259
- return message.content.map(renderAiccContentForDebug).join("");
1260
- }
1261
- function aiccEstimateMessageTextLen(message) {
1262
- return message.content.reduce((total, block) => {
1263
- var _a2, _b;
1264
- if (block.type === "text") {
1265
- return total + block.text.length;
1266
- }
1267
- if (block.type === "thinking") {
1268
- return total + (((_a2 = block.summary) == null ? void 0 : _a2.length) ?? 0) + (((_b = block.text) == null ? void 0 : _b.length) ?? 0);
1269
- }
1270
- return total + NON_TEXT_BLOCK_ESTIMATED_LEN;
1271
- }, 0);
1241
+ return (_a2 = message.content.find((b2) => b2.type === "text")) == null ? void 0 : _a2.text;
1272
1242
  }
1273
1243
  function validateAiccMessage(message) {
1274
- if (!message || typeof message !== "object" || Array.isArray(message)) {
1275
- throw new RPCError("AiccMessage must be an object");
1276
- }
1277
- if (!AI_ROLE_SET.has(message.role)) {
1278
- throw new RPCError(`AiccMessage.role is invalid: ${String(message.role)}`);
1279
- }
1280
- if (!Array.isArray(message.content)) {
1281
- throw new RPCError("AiccMessage.content must be an array of content blocks");
1244
+ const allowed = {
1245
+ system: ["text"],
1246
+ developer: ["text"],
1247
+ user: ["text", "image", "document"],
1248
+ assistant: ["text", "image", "document", "tool_use", "thinking", "provider_state"],
1249
+ tool: ["tool_result"]
1250
+ };
1251
+ if (!message || !Array.isArray(message.content) || !allowed[message.role])
1252
+ throw new RPCError("invalid AiMessage");
1253
+ if (message.role === "tool" && (message.content.length !== 1 || message.content[0].type !== "tool_result")) {
1254
+ throw new RPCError("role Tool requires exactly one ToolResult block");
1282
1255
  }
1283
1256
  for (const block of message.content) {
1284
- validateAiccContentBlockForRole(message.role, block);
1285
- }
1286
- }
1287
- function validateAiccMessages(messages) {
1288
- if (!Array.isArray(messages)) {
1289
- throw new RPCError("AiccLlmChatInput.messages must be an array");
1290
- }
1291
- for (const message of messages) {
1292
- validateAiccMessage(message);
1293
- }
1294
- }
1295
- function validateAiccResponse(response) {
1296
- const record = asRecord$3(response);
1297
- for (const key of ["text", "tool_calls", "artifacts"]) {
1298
- if (key in record) {
1299
- throw new RPCError(`AiccResponse.${key} is no longer supported; use AiccResponse.message`);
1300
- }
1301
- }
1302
- if (!record.message) {
1303
- throw new RPCError("AiccResponse.message is required");
1304
- }
1305
- validateAiccMessage(record.message);
1306
- if (record.message.role !== "assistant") {
1307
- throw new RPCError("AiccResponse.message.role must be assistant");
1308
- }
1309
- }
1310
- function renderAiccContentForDebug(block) {
1311
- switch (block.type) {
1312
- case "text":
1313
- return block.text;
1314
- case "image":
1315
- return "[image]";
1316
- case "document":
1317
- return block.title ? `[document title=${block.title}]` : "[document]";
1318
- case "tool_use":
1319
- return `[tool_use name=${block.name} call_id=${block.call_id}]`;
1320
- case "tool_result":
1321
- return `[tool_result call_id=${block.call_id}${block.is_error ? " is_error=true" : ""}]`;
1322
- case "thinking":
1323
- return block.text ?? block.summary ?? "[thinking]";
1324
- case "provider_state":
1325
- return `[provider_state provider=${block.provider}]`;
1326
- }
1327
- }
1328
- function aiccResourceRefMime(resource) {
1329
- switch (resource.kind) {
1330
- case "url":
1331
- return resource.mime_hint ?? null;
1332
- case "base64":
1333
- return resource.mime;
1334
- case "named_object":
1335
- return null;
1336
- }
1337
- }
1338
- function validateAiccContentBlockForRole(role, block) {
1339
- if (!block || typeof block !== "object" || !("type" in block) || typeof block.type !== "string") {
1340
- throw new RPCError(`AiccMessage contains an invalid content block for role ${role}`);
1341
- }
1342
- if (!isBlockAllowedForRole(role, block.type)) {
1343
- throw new RPCError(`AiccMessage role ${role} cannot contain ${block.type} content`);
1344
- }
1345
- if ((block.type === "tool_use" || block.type === "tool_result") && !block.call_id) {
1346
- throw new RPCError(`AiccContent.${block.type} requires call_id`);
1347
- }
1348
- if (block.type === "tool_use" && !block.name) {
1349
- throw new RPCError("AiccContent.tool_use requires name");
1350
- }
1351
- if (block.type === "tool_result" && (!Array.isArray(block.content) || block.content.length === 0)) {
1352
- throw new RPCError("AiccContent.tool_result requires non-empty content");
1353
- }
1354
- if (block.type === "tool_result") {
1355
- for (const item of block.content) {
1356
- validateAiccToolResultContent(item);
1357
- }
1358
- }
1359
- if (block.type === "provider_state" && !block.provider) {
1360
- throw new RPCError("AiccContent.provider_state requires provider");
1257
+ if (!allowed[message.role].includes(block.type))
1258
+ throw new RPCError(`AiMessage role ${message.role} cannot contain ${block.type} content`);
1259
+ if ((block.type === "tool_use" || block.type === "tool_result") && !block.call_id)
1260
+ throw new RPCError(`${block.type} requires call_id`);
1261
+ if (block.type === "tool_result" && block.content.length === 0)
1262
+ throw new RPCError("tool_result requires non-empty content");
1263
+ }
1264
+ }
1265
+ function exact(value) {
1266
+ if (!value || value.split("@").length !== 2 || value.startsWith("@") || value.endsWith("@")) {
1267
+ throw new RPCError("exact_model must be `<provider_model_id>[:<variant>]@<provider_instance_name>`");
1268
+ }
1269
+ }
1270
+ function logical(value) {
1271
+ if (!(value == null ? void 0 : value.trim()) || value.includes("@"))
1272
+ throw new RPCError("logical_model must be a non-empty logical path without `@`");
1273
+ }
1274
+ function strict(request, allowed) {
1275
+ for (const key of Object.keys(request))
1276
+ if (!allowed.includes(key))
1277
+ throw new RPCError(`unknown field \`${key}\``);
1278
+ const mode = request.execution_mode;
1279
+ if (mode !== void 0 && mode !== AICC_EXECUTION_MODES.IMMEDIATE && mode !== AICC_EXECUTION_MODES.STREAM) {
1280
+ throw new RPCError("execution_mode must be `immediate` or `stream`");
1281
+ }
1282
+ const sessionId = request.session_id;
1283
+ if (sessionId !== void 0 && (typeof sessionId !== "string" || !sessionId.trim() || new TextEncoder().encode(sessionId).length > 512)) {
1284
+ throw new RPCError("session_id must contain 1..512 bytes");
1285
+ }
1286
+ }
1287
+ const common = ["exact_model", "trace_id", "execution_mode", "idempotency_key", "task_options", "session_id"];
1288
+ const schemas = {
1289
+ [AICC_AI_METHODS.CHAT_COMPLETIONS_CREATE]: [...common, "messages", "tools", "response_format", "temperature", "top_p", "max_output_tokens", "seed", "stop", "output"],
1290
+ [AICC_AI_METHODS.IMAGES_GENERATE]: [...common, "prompt", "negative_prompt", "n", "aspect_ratio", "size", "quality", "style", "seed", "output"],
1291
+ [AICC_AI_METHODS.EMBEDDING_TEXT]: [...common, "items", "chunking", "embedding_space_id", "dimensions", "normalize", "prefer_artifact"],
1292
+ [AICC_AI_METHODS.EMBEDDING_MULTIMODAL]: [...common, "items", "dimensions", "normalize"],
1293
+ [AICC_AI_METHODS.RERANK]: [...common, "query", "documents", "n", "return_documents"],
1294
+ [AICC_AI_METHODS.IMAGE_IMG2IMG]: [...common, "images", "prompt", "strength", "output"],
1295
+ [AICC_AI_METHODS.IMAGE_INPAINT]: [...common, "image", "mask", "prompt", "mask_semantics", "output"],
1296
+ [AICC_AI_METHODS.IMAGE_UPSCALE]: [...common, "image", "scale", "target_width", "target_height", "preserve_faces", "output"],
1297
+ [AICC_AI_METHODS.IMAGE_BG_REMOVE]: [...common, "image", "mode", "output"],
1298
+ [AICC_AI_METHODS.VISION_OCR]: [...common, "document", "level", "language_hints", "return_layout", "return_artifacts"],
1299
+ [AICC_AI_METHODS.VISION_CAPTION]: [...common, "image", "style", "language", "n"],
1300
+ [AICC_AI_METHODS.VISION_DETECT]: [...common, "image", "classes", "score_threshold", "bbox_spec"],
1301
+ [AICC_AI_METHODS.VISION_SEGMENT]: [...common, "image", "prompt", "mask_format", "return_bitmap_mask"],
1302
+ [AICC_AI_METHODS.AUDIO_TTS]: [...common, "text", "voice", "speed", "output"],
1303
+ [AICC_AI_METHODS.AUDIO_ASR]: [...common, "audio", "language", "timestamps", "diarization", "output_formats"],
1304
+ [AICC_AI_METHODS.AUDIO_MUSIC]: [...common, "prompt", "duration_seconds", "instrumental", "lyrics", "seed", "output"],
1305
+ [AICC_AI_METHODS.AUDIO_ENHANCE]: [...common, "audio", "task", "strength", "return_stems"],
1306
+ [AICC_AI_METHODS.VIDEO_TXT2VIDEO]: [...common, "prompt", "duration_seconds", "aspect_ratio", "resolution", "generate_audio", "seed", "output"],
1307
+ [AICC_AI_METHODS.VIDEO_IMG2VIDEO]: [...common, "image", "prompt", "duration_seconds", "aspect_ratio", "resolution"],
1308
+ [AICC_AI_METHODS.VIDEO_VIDEO2VIDEO]: [...common, "video", "prompt", "preserve_motion", "time_range"],
1309
+ [AICC_AI_METHODS.VIDEO_EXTEND]: [...common, "video", "prompt", "continuation_handle", "duration_seconds", "resolution"],
1310
+ [AICC_AI_METHODS.VIDEO_UPSCALE]: [...common, "video", "target_resolution", "denoise", "sharpen", "output"],
1311
+ [AICC_AI_METHODS.AGENT_COMPUTER_USE]: [...common, "task", "environment", "allowed_actions"],
1312
+ [AICC_CORE_METHODS.ROUTE_RESOLVE]: ["trace_id", "execution_mode", "request_id", "api_type", "logical_model", "requirements", "disable", "policy", "estimated_input_tokens", "estimated_output_tokens", "session_overlay", "session_id"],
1313
+ [AICC_CORE_METHODS.HELPER_LLM_CHAT]: ["logical_model", "trace_id", "execution_mode", "requirements", "disable", "policy", "messages", "tools", "response_format", "temperature", "top_p", "max_output_tokens", "seed", "stop", "output", "idempotency_key", "task_options", "session_overlay", "session_id"],
1314
+ [AICC_CORE_METHODS.HELPER_TEXT_TO_IMAGE]: ["logical_model", "trace_id", "execution_mode", "requirements", "disable", "policy", "prompt", "negative_prompt", "n", "aspect_ratio", "size", "quality", "style", "seed", "output", "idempotency_key", "task_options", "session_overlay", "session_id"],
1315
+ [AICC_CORE_METHODS.CANCEL]: ["task_id"],
1316
+ [AICC_MANAGEMENT_METHODS.SERVICE_RELOAD_SETTINGS]: [],
1317
+ [AICC_MANAGEMENT_METHODS.QUOTA_QUERY]: ["capability", "method"],
1318
+ [AICC_MANAGEMENT_METHODS.USAGE_QUERY]: ["time_range", "filters", "group_by", "time_bucket", "output_mode", "limit", "cursor"],
1319
+ [AICC_MANAGEMENT_METHODS.TRACE_QUERY]: ["limit", "cursor", "start_time_ms", "end_time_ms", "task_ids", "request_ids", "api_types", "provider_instance_names", "selected_exact_models", "scheduler_profiles", "query", "outcome"],
1320
+ [AICC_MANAGEMENT_METHODS.ROUTING_GET]: [],
1321
+ [AICC_MANAGEMENT_METHODS.ROUTING_UPDATE]: ["settings_revision", "provider_weights"],
1322
+ [AICC_MANAGEMENT_METHODS.PROVIDER_CATALOG]: [],
1323
+ [AICC_MANAGEMENT_METHODS.PROTOCOL_ADAPTER_LIST]: [],
1324
+ [AICC_MANAGEMENT_METHODS.PROVIDER_VALIDATE]: ["provider_instance_name", "provider_type", "provider_profile_id", "protocol_family_id", "protocol_adapter_id", "base_url", "credentials", "region", "workspace", "account", "provider_rules_id", "auth", "discovery", "instance_rules", "timeout_ms", "auto_sync_models"],
1325
+ [AICC_MANAGEMENT_METHODS.PROVIDER_ADD]: ["provider_instance_name", "provider_type", "provider_profile_id", "protocol_family_id", "protocol_adapter_id", "base_url", "credentials", "region", "workspace", "account", "provider_rules_id", "auth", "discovery", "instance_rules", "timeout_ms", "auto_sync_models"],
1326
+ [AICC_MANAGEMENT_METHODS.PROVIDER_LIST]: ["method"],
1327
+ [AICC_MANAGEMENT_METHODS.PROVIDER_HEALTH]: ["exact_model"],
1328
+ [AICC_MANAGEMENT_METHODS.PROVIDER_UPDATE]: ["provider_instance_name", "settings_revision", "enabled", "base_url", "credential", "provider_profile_id", "protocol_adapter_id", "discovery", "instance_rules"],
1329
+ [AICC_MANAGEMENT_METHODS.PROVIDER_DELETE]: ["provider_instance_name"],
1330
+ [AICC_MANAGEMENT_METHODS.PROVIDER_REFRESH_MODELS]: ["provider_instance_name"],
1331
+ [AICC_MANAGEMENT_METHODS.MODELS_LIST]: [],
1332
+ [AICC_MANAGEMENT_METHODS.DRIVER_METADATA_UPDATE_GET]: [],
1333
+ [AICC_MANAGEMENT_METHODS.DRIVER_METADATA_UPDATE_SET]: ["enabled", "source_url", "interval_secs"]
1334
+ };
1335
+ class AiccClient {
1336
+ constructor(rpcClient) {
1337
+ this.rpcClient = rpcClient;
1361
1338
  }
1362
- }
1363
- function validateAiccToolResultContent(content) {
1364
- if (!content || typeof content !== "object" || Array.isArray(content)) {
1365
- throw new RPCError("AiccToolResultContent must be an object");
1339
+ setSeq(seq) {
1340
+ this.rpcClient.setSeq(seq);
1366
1341
  }
1367
- switch (content.type) {
1368
- case "text":
1369
- if (typeof content.text !== "string") {
1370
- throw new RPCError("AiccToolResultContent.text requires text");
1371
- }
1372
- return;
1373
- case "image":
1374
- if (!content.source) {
1375
- throw new RPCError("AiccToolResultContent.image requires source");
1376
- }
1377
- return;
1378
- case "document":
1379
- if (!content.source) {
1380
- throw new RPCError("AiccToolResultContent.document requires source");
1381
- }
1382
- return;
1383
- default:
1384
- throw new RPCError(`AiccToolResultContent type is invalid: ${String(content.type)}`);
1342
+ call(method, request) {
1343
+ const schema = schemas[method];
1344
+ const params = (schema == null ? void 0 : schema.includes("execution_mode")) && request.execution_mode === void 0 ? { ...request, execution_mode: AICC_EXECUTION_MODES.IMMEDIATE } : request;
1345
+ if (schema)
1346
+ strict(params, schema);
1347
+ return this.rpcClient.call(method, params);
1385
1348
  }
1386
- }
1387
- function isBlockAllowedForRole(role, blockType) {
1388
- switch (role) {
1389
- case "system":
1390
- case "developer":
1391
- return blockType === "text";
1392
- case "user":
1393
- return blockType === "text" || blockType === "image" || blockType === "document";
1394
- case "assistant":
1395
- return blockType === "text" || blockType === "image" || blockType === "document" || blockType === "tool_use" || blockType === "thinking" || blockType === "provider_state";
1396
- case "tool":
1397
- return blockType === "tool_result";
1349
+ inference(method, request) {
1350
+ exact(request.exact_model);
1351
+ return this.call(method, request);
1398
1352
  }
1399
- }
1400
- function asRecord$3(value) {
1401
- if (!value || typeof value !== "object" || Array.isArray(value)) {
1402
- throw new RPCError("Invalid RPC response format");
1353
+ routeResolve(r) {
1354
+ logical(r.logical_model);
1355
+ return this.call(AICC_CORE_METHODS.ROUTE_RESOLVE, r);
1403
1356
  }
1404
- return value;
1405
- }
1406
- function rejectDeprecatedRequestFields(request) {
1407
- const requirements = request.requirements;
1408
- if ("resp_foramt" in requirements) {
1409
- throw new RPCError("AiccRequirements.resp_foramt is no longer supported; use resp_format");
1357
+ chatCompletionsCreate(r) {
1358
+ r.messages.forEach(validateAiccMessage);
1359
+ return this.inference(AICC_AI_METHODS.CHAT_COMPLETIONS_CREATE, r);
1410
1360
  }
1411
- const payload = request.payload;
1412
- for (const key of ["text", "messages", "tool_specs"]) {
1413
- if (key in payload) {
1414
- throw new RPCError(`AiccPayload.${key} is no longer supported; put method fields under payload.input_json`);
1415
- }
1361
+ imagesGenerate(r) {
1362
+ return this.inference(AICC_AI_METHODS.IMAGES_GENERATE, r);
1416
1363
  }
1417
- }
1418
- function normalizeMethodRequest(request) {
1419
- if (!request.capability || !CAPABILITY_SET.has(request.capability)) {
1420
- throw new RPCError("AiccMethodRequest.capability is invalid");
1364
+ helperLlmChat(r) {
1365
+ logical(r.logical_model);
1366
+ r.messages.forEach(validateAiccMessage);
1367
+ return this.call(AICC_CORE_METHODS.HELPER_LLM_CHAT, r);
1421
1368
  }
1422
- if (!request.model || !request.model.alias) {
1423
- throw new RPCError("AiccMethodRequest.model.alias is required");
1369
+ helperTextToImage(r) {
1370
+ logical(r.logical_model);
1371
+ return this.call(AICC_CORE_METHODS.HELPER_TEXT_TO_IMAGE, r);
1424
1372
  }
1425
- if (!request.requirements || typeof request.requirements !== "object") {
1426
- throw new RPCError("AiccMethodRequest.requirements is required");
1373
+ embeddingText(r) {
1374
+ return this.inference(AICC_AI_METHODS.EMBEDDING_TEXT, r);
1427
1375
  }
1428
- if (!request.payload || typeof request.payload !== "object" || Array.isArray(request.payload)) {
1429
- throw new RPCError("AiccMethodRequest.payload is required");
1376
+ embeddingMultimodal(r) {
1377
+ return this.inference(AICC_AI_METHODS.EMBEDDING_MULTIMODAL, r);
1430
1378
  }
1431
- rejectDeprecatedRequestFields(request);
1432
- return {
1433
- ...request,
1434
- payload: {
1435
- input_json: request.payload.input_json ?? {},
1436
- resources: request.payload.resources ?? [],
1437
- options: request.payload.options ?? {}
1438
- }
1439
- };
1440
- }
1441
- function validateLlmChatPayload(request) {
1442
- const input = request.payload.input_json;
1443
- if (!input || typeof input !== "object" || Array.isArray(input)) {
1444
- throw new RPCError("AiccLlmChatInput must be an object");
1379
+ rerank(r) {
1380
+ return this.inference(AICC_AI_METHODS.RERANK, r);
1445
1381
  }
1446
- const messages = input.messages;
1447
- validateAiccMessages(messages);
1448
- }
1449
- function parseMethodResponse(result) {
1450
- const record = asRecord$3(result);
1451
- if (typeof record.task_id !== "string") {
1452
- throw new RPCError("AiccMethodResponse missing task_id");
1382
+ imageToImage(r) {
1383
+ return this.inference(AICC_AI_METHODS.IMAGE_IMG2IMG, r);
1453
1384
  }
1454
- if (typeof record.status !== "string" || !METHOD_STATUS_SET.has(record.status)) {
1455
- throw new RPCError("AiccMethodResponse missing or invalid status");
1385
+ imageInpaint(r) {
1386
+ return this.inference(AICC_AI_METHODS.IMAGE_INPAINT, r);
1456
1387
  }
1457
- if (record.result != null) {
1458
- validateAiccResponse(record.result);
1388
+ imageUpscale(r) {
1389
+ return this.inference(AICC_AI_METHODS.IMAGE_UPSCALE, r);
1459
1390
  }
1460
- return record;
1461
- }
1462
- function normalizeModel(model) {
1463
- if (typeof model === "string") {
1464
- return { alias: model };
1391
+ imageBackgroundRemove(r) {
1392
+ return this.inference(AICC_AI_METHODS.IMAGE_BG_REMOVE, r);
1465
1393
  }
1466
- return model;
1467
- }
1468
- function buildTypedMethodRequest(capability, request) {
1469
- return {
1470
- capability,
1471
- model: normalizeModel(request.model),
1472
- requirements: request.requirements ?? {},
1473
- payload: {
1474
- input_json: request.input,
1475
- resources: request.resources ?? [],
1476
- options: request.options ?? {}
1477
- },
1478
- policy: request.policy,
1479
- idempotency_key: request.idempotency_key,
1480
- task_options: request.task_options
1481
- };
1482
- }
1483
- class AiccClient {
1484
- constructor(rpcClient) {
1485
- this.rpcClient = rpcClient;
1394
+ visionOcr(r) {
1395
+ return this.inference(AICC_AI_METHODS.VISION_OCR, r);
1486
1396
  }
1487
- setSeq(seq) {
1488
- this.rpcClient.setSeq(seq);
1397
+ visionCaption(r) {
1398
+ return this.inference(AICC_AI_METHODS.VISION_CAPTION, r);
1489
1399
  }
1490
- async callMethod(method, request) {
1491
- if (!isAiccAiMethod(method)) {
1492
- throw new RPCError(`Unknown AICC AI method: ${method}`);
1493
- }
1494
- const normalizedRequest = normalizeMethodRequest(request);
1495
- if (method === AICC_AI_METHODS.LLM_CHAT) {
1496
- validateLlmChatPayload(normalizedRequest);
1497
- }
1498
- const result = await this.rpcClient.call(method, normalizedRequest);
1499
- return parseMethodResponse(result);
1400
+ visionDetect(r) {
1401
+ return this.inference(AICC_AI_METHODS.VISION_DETECT, r);
1500
1402
  }
1501
- async llmChat(request) {
1502
- return this.callMethod(AICC_AI_METHODS.LLM_CHAT, buildTypedMethodRequest("llm", request));
1403
+ visionSegment(r) {
1404
+ return this.inference(AICC_AI_METHODS.VISION_SEGMENT, r);
1503
1405
  }
1504
- async llmCompletion(request) {
1505
- return this.callMethod(AICC_AI_METHODS.LLM_COMPLETION, buildTypedMethodRequest("llm", request));
1406
+ audioTextToSpeech(r) {
1407
+ return this.inference(AICC_AI_METHODS.AUDIO_TTS, r);
1506
1408
  }
1507
- async embeddingText(request) {
1508
- return this.callMethod(AICC_AI_METHODS.EMBEDDING_TEXT, buildTypedMethodRequest("embedding", request));
1409
+ audioSpeechRecognition(r) {
1410
+ return this.inference(AICC_AI_METHODS.AUDIO_ASR, r);
1509
1411
  }
1510
- async embeddingMultimodal(request) {
1511
- return this.callMethod(
1512
- AICC_AI_METHODS.EMBEDDING_MULTIMODAL,
1513
- buildTypedMethodRequest("embedding", request)
1514
- );
1412
+ audioMusic(r) {
1413
+ return this.inference(AICC_AI_METHODS.AUDIO_MUSIC, r);
1515
1414
  }
1516
- async rerank(request) {
1517
- return this.callMethod(AICC_AI_METHODS.RERANK, buildTypedMethodRequest("rerank", request));
1415
+ audioEnhance(r) {
1416
+ return this.inference(AICC_AI_METHODS.AUDIO_ENHANCE, r);
1518
1417
  }
1519
- async imageTxt2img(request) {
1520
- return this.callMethod(AICC_AI_METHODS.IMAGE_TXT2IMG, buildTypedMethodRequest("image", request));
1418
+ videoTextToVideo(r) {
1419
+ return this.inference(AICC_AI_METHODS.VIDEO_TXT2VIDEO, r);
1521
1420
  }
1522
- async imageImg2img(request) {
1523
- return this.callMethod(AICC_AI_METHODS.IMAGE_IMG2IMG, buildTypedMethodRequest("image", request));
1421
+ videoImageToVideo(r) {
1422
+ return this.inference(AICC_AI_METHODS.VIDEO_IMG2VIDEO, r);
1524
1423
  }
1525
- async imageInpaint(request) {
1526
- return this.callMethod(AICC_AI_METHODS.IMAGE_INPAINT, buildTypedMethodRequest("image", request));
1424
+ videoToVideo(r) {
1425
+ return this.inference(AICC_AI_METHODS.VIDEO_VIDEO2VIDEO, r);
1527
1426
  }
1528
- async imageUpscale(request) {
1529
- return this.callMethod(AICC_AI_METHODS.IMAGE_UPSCALE, buildTypedMethodRequest("image", request));
1427
+ videoExtend(r) {
1428
+ return this.inference(AICC_AI_METHODS.VIDEO_EXTEND, r);
1530
1429
  }
1531
- async imageBgRemove(request) {
1532
- return this.callMethod(AICC_AI_METHODS.IMAGE_BG_REMOVE, buildTypedMethodRequest("image", request));
1430
+ videoUpscale(r) {
1431
+ return this.inference(AICC_AI_METHODS.VIDEO_UPSCALE, r);
1533
1432
  }
1534
- async visionOcr(request) {
1535
- return this.callMethod(AICC_AI_METHODS.VISION_OCR, buildTypedMethodRequest("vision", request));
1433
+ computerUse(r) {
1434
+ return this.inference(AICC_AI_METHODS.AGENT_COMPUTER_USE, r);
1536
1435
  }
1537
- async visionCaption(request) {
1538
- return this.callMethod(AICC_AI_METHODS.VISION_CAPTION, buildTypedMethodRequest("vision", request));
1436
+ cancel(taskId) {
1437
+ if (!taskId)
1438
+ throw new RPCError("cancel requires non-empty task_id");
1439
+ return this.call(AICC_CORE_METHODS.CANCEL, { task_id: taskId });
1539
1440
  }
1540
- async visionDetect(request) {
1541
- return this.callMethod(AICC_AI_METHODS.VISION_DETECT, buildTypedMethodRequest("vision", request));
1441
+ reloadSettings() {
1442
+ return this.call(AICC_MANAGEMENT_METHODS.SERVICE_RELOAD_SETTINGS, {});
1542
1443
  }
1543
- async visionSegment(request) {
1544
- return this.callMethod(AICC_AI_METHODS.VISION_SEGMENT, buildTypedMethodRequest("vision", request));
1444
+ queryQuota(r = {}) {
1445
+ return this.call(AICC_MANAGEMENT_METHODS.QUOTA_QUERY, r);
1545
1446
  }
1546
- async audioTts(request) {
1547
- return this.callMethod(AICC_AI_METHODS.AUDIO_TTS, buildTypedMethodRequest("audio", request));
1447
+ queryUsage(r) {
1448
+ return this.call(AICC_MANAGEMENT_METHODS.USAGE_QUERY, r);
1548
1449
  }
1549
- async audioAsr(request) {
1550
- return this.callMethod(AICC_AI_METHODS.AUDIO_ASR, buildTypedMethodRequest("audio", request));
1450
+ queryTrace(r = {}) {
1451
+ return this.call(AICC_MANAGEMENT_METHODS.TRACE_QUERY, r);
1551
1452
  }
1552
- async audioMusic(request) {
1553
- return this.callMethod(AICC_AI_METHODS.AUDIO_MUSIC, buildTypedMethodRequest("audio", request));
1453
+ getRouting() {
1454
+ return this.call(AICC_MANAGEMENT_METHODS.ROUTING_GET, {});
1554
1455
  }
1555
- async audioEnhance(request) {
1556
- return this.callMethod(AICC_AI_METHODS.AUDIO_ENHANCE, buildTypedMethodRequest("audio", request));
1456
+ updateRouting(r) {
1457
+ return this.call(AICC_MANAGEMENT_METHODS.ROUTING_UPDATE, r);
1557
1458
  }
1558
- async videoTxt2video(request) {
1559
- return this.callMethod(AICC_AI_METHODS.VIDEO_TXT2VIDEO, buildTypedMethodRequest("video", request));
1459
+ providerCatalog() {
1460
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_CATALOG, {});
1560
1461
  }
1561
- async videoImg2video(request) {
1562
- return this.callMethod(AICC_AI_METHODS.VIDEO_IMG2VIDEO, buildTypedMethodRequest("video", request));
1462
+ listProtocolAdapters() {
1463
+ return this.call(AICC_MANAGEMENT_METHODS.PROTOCOL_ADAPTER_LIST, {});
1563
1464
  }
1564
- async videoVideo2video(request) {
1565
- return this.callMethod(AICC_AI_METHODS.VIDEO_VIDEO2VIDEO, buildTypedMethodRequest("video", request));
1465
+ validateProvider(r) {
1466
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_VALIDATE, r);
1566
1467
  }
1567
- async videoExtend(request) {
1568
- return this.callMethod(AICC_AI_METHODS.VIDEO_EXTEND, buildTypedMethodRequest("video", request));
1468
+ addProvider(r) {
1469
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_ADD, r);
1569
1470
  }
1570
- async videoUpscale(request) {
1571
- return this.callMethod(AICC_AI_METHODS.VIDEO_UPSCALE, buildTypedMethodRequest("video", request));
1471
+ listProviders(r = {}) {
1472
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_LIST, r);
1572
1473
  }
1573
- async agentComputerUse(request) {
1574
- return this.callMethod(AICC_AI_METHODS.AGENT_COMPUTER_USE, buildTypedMethodRequest("agent", request));
1474
+ providerHealth(r) {
1475
+ exact(r.exact_model);
1476
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_HEALTH, r);
1575
1477
  }
1576
- async cancel(taskId) {
1577
- if (!taskId) {
1578
- throw new RPCError("AiccClient.cancel requires a non-empty task_id");
1579
- }
1580
- const result = await this.rpcClient.call(AICC_CONTROL_METHODS.CANCEL, { task_id: taskId });
1581
- const record = asRecord$3(result);
1582
- if (typeof record.task_id !== "string" || typeof record.accepted !== "boolean") {
1583
- throw new RPCError("Invalid cancel response");
1584
- }
1585
- return { task_id: record.task_id, accepted: record.accepted };
1478
+ updateProvider(r) {
1479
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_UPDATE, r);
1586
1480
  }
1587
- async reloadSettings() {
1588
- return this.rpcClient.call(AICC_CONTROL_METHODS.RELOAD_SETTINGS, {});
1481
+ deleteProvider(r) {
1482
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_DELETE, r);
1589
1483
  }
1590
- async serviceReloadSettings() {
1591
- return this.rpcClient.call(AICC_CONTROL_METHODS.SERVICE_RELOAD_SETTINGS, {});
1484
+ refreshProviderModels(r) {
1485
+ return this.call(AICC_MANAGEMENT_METHODS.PROVIDER_REFRESH_MODELS, r);
1592
1486
  }
1593
- async queryQuota(request) {
1594
- const result = await this.rpcClient.call(AICC_CONTROL_METHODS.QUOTA_QUERY, request);
1595
- const record = asRecord$3(result);
1596
- if (!record.quota || typeof record.quota !== "object" || Array.isArray(record.quota)) {
1597
- throw new RPCError("Invalid quota.query response");
1598
- }
1599
- return record;
1487
+ listModels() {
1488
+ return this.call(AICC_MANAGEMENT_METHODS.MODELS_LIST, {});
1600
1489
  }
1601
- async listProviders(request = {}) {
1602
- return this.rpcClient.call(AICC_CONTROL_METHODS.PROVIDER_LIST, request);
1490
+ getDriverMetadataUpdate() {
1491
+ return this.call(AICC_MANAGEMENT_METHODS.DRIVER_METADATA_UPDATE_GET, {});
1603
1492
  }
1604
- async providerHealth(request) {
1605
- return this.rpcClient.call(AICC_CONTROL_METHODS.PROVIDER_HEALTH, request);
1493
+ setDriverMetadataUpdate(r) {
1494
+ return this.call(AICC_MANAGEMENT_METHODS.DRIVER_METADATA_UPDATE_SET, r);
1606
1495
  }
1607
1496
  }
1608
1497
  const DEFAULT_QUEUE_CONFIG = {
@@ -28417,7 +28306,7 @@ export {
28417
28306
  TASK_ERR_STALE_RUNNER_EPOCH as Z,
28418
28307
  TASK_ERR_INVALID_PHASE as _,
28419
28308
  ndm_proxy as a,
28420
- parseAppInstanceId as a$,
28309
+ BNS_DNS_TXT_DEFAULT_TTL as a$,
28421
28310
  TASK_ERR_CONTROL_ALREADY_PENDING as a0,
28422
28311
  TASK_ERR_ALREADY_COMPLETED as a1,
28423
28312
  TASK_ERR_INPUT_SCHEMA_MISMATCH as a2,
@@ -28429,32 +28318,32 @@ export {
28429
28318
  taskMgrTreeEventPath as a8,
28430
28319
  taskMgrErrorCode as a9,
28431
28320
  WorkflowClient as aA,
28432
- AICC_SERVICE_NAME as aB,
28433
- AICC_SERVICE_UNIQUE_ID as aC,
28434
- AICC_SERVICE_SERVICE_NAME as aD,
28435
- AICC_SERVICE_SERVICE_PORT as aE,
28436
- AICC_AI_METHODS as aF,
28437
- AICC_CONTROL_METHODS as aG,
28438
- AICC_FEATURES as aH,
28439
- isAiccAiMethod as aI,
28440
- aiccTextMessage as aJ,
28441
- aiccMessageTextContent as aK,
28442
- aiccMessageFirstText as aL,
28443
- aiccResponseTextContent as aM,
28444
- aiccResponseToolCalls as aN,
28445
- aiccResponseArtifacts as aO,
28446
- aiccRenderMessageForDebug as aP,
28447
- aiccEstimateMessageTextLen as aQ,
28448
- validateAiccMessage as aR,
28449
- validateAiccMessages as aS,
28450
- validateAiccResponse as aT,
28451
- AiccClient as aU,
28452
- KEventReader as aV,
28453
- KEventClient as aW,
28454
- appIdFromDid as aX,
28455
- parseAppId as aY,
28456
- appDidFromId as aZ,
28457
- createAppInstanceId as a_,
28321
+ AICC_SERVICE_UNIQUE_ID as aB,
28322
+ AICC_SERVICE_SERVICE_NAME as aC,
28323
+ AICC_SERVICE_SERVICE_PORT as aD,
28324
+ AICC_AI_METHODS as aE,
28325
+ AICC_CORE_METHODS as aF,
28326
+ AICC_MANAGEMENT_METHODS as aG,
28327
+ AICC_METHODS as aH,
28328
+ AICC_FEATURES as aI,
28329
+ AICC_EXECUTION_MODES as aJ,
28330
+ isAiccAiMethod as aK,
28331
+ aiccTextMessage as aL,
28332
+ aiccMessageTextContent as aM,
28333
+ aiccMessageFirstText as aN,
28334
+ validateAiccMessage as aO,
28335
+ AiccClient as aP,
28336
+ KEventReader as aQ,
28337
+ KEventClient as aR,
28338
+ appIdFromDid as aS,
28339
+ parseAppId as aT,
28340
+ appDidFromId as aU,
28341
+ createAppInstanceId as aV,
28342
+ parseAppInstanceId as aW,
28343
+ BNS_EVM_DEFAULT_GAS_LIMIT as aX,
28344
+ BNS_EVM_DEFAULT_MAX_FEE_PER_GAS as aY,
28345
+ BNS_EVM_DEFAULT_MAX_PRIORITY_FEE_PER_GAS as aZ,
28346
+ BNS_MAX_INLINE_DOCUMENT_BYTES as a_,
28458
28347
  TaskExecutorKind as aa,
28459
28348
  TaskPhase as ab,
28460
28349
  isTerminalTaskPhase as ac,
@@ -28482,19 +28371,14 @@ export {
28482
28371
  WorkflowScheduledTaskMisfirePolicy as ay,
28483
28372
  WorkflowScheduledTaskFireStatus as az,
28484
28373
  bns_client as b,
28485
- BNS_EVM_DEFAULT_GAS_LIMIT as b0,
28486
- BNS_EVM_DEFAULT_MAX_FEE_PER_GAS as b1,
28487
- BNS_EVM_DEFAULT_MAX_PRIORITY_FEE_PER_GAS as b2,
28488
- BNS_MAX_INLINE_DOCUMENT_BYTES as b3,
28489
- BNS_DNS_TXT_DEFAULT_TTL as b4,
28490
- BNS_DNS_TXT_DOC_TYPE as b5,
28491
- BNS_PUBLISH_DOCUMENT_ABI as b6,
28492
- BnsEvmTxError as b7,
28493
- BnsEvmTxBuilder as b8,
28494
- decodeBnsPublishDocumentCalldata as b9,
28495
- BnsTxExecutorError as ba,
28496
- walletUserHasSnAccount as bb,
28497
- BnsTxExecutor as bc,
28374
+ BNS_DNS_TXT_DOC_TYPE as b0,
28375
+ BNS_PUBLISH_DOCUMENT_ABI as b1,
28376
+ BnsEvmTxError as b2,
28377
+ BnsEvmTxBuilder as b3,
28378
+ decodeBnsPublishDocumentCalldata as b4,
28379
+ BnsTxExecutorError as b5,
28380
+ walletUserHasSnAccount as b6,
28381
+ BnsTxExecutor as b7,
28498
28382
  createSDKModule as c,
28499
28383
  BS_SERVICE_TASK_MANAGER as d,
28500
28384
  getActiveRuntimeType as e,
@@ -28520,4 +28404,4 @@ export {
28520
28404
  WORKFLOW_SCHEDULE_TASK_SCHEMA_ID as y,
28521
28405
  WORKFLOW_SEND_MESSAGE_TASK_SCHEMA_ID as z
28522
28406
  };
28523
- //# sourceMappingURL=ndm_proxy-8f547002.mjs.map
28407
+ //# sourceMappingURL=ndm_proxy-3fce55e8.mjs.map