@aigne/afs-aignehub 1.11.0-beta.10

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.
@@ -0,0 +1,1635 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ const require_auth = require('./auth.cjs');
3
+ const require_types = require('./types.cjs');
4
+ const require_decorate = require('./_virtual/_@oxc-project_runtime@0.108.0/helpers/decorate.cjs');
5
+ let _aigne_afs = require("@aigne/afs");
6
+ let _aigne_afs_utils_zod = require("@aigne/afs/utils/zod");
7
+ let _aigne_aigne_hub = require("@aigne/aigne-hub");
8
+ let ufo = require("ufo");
9
+ let zod = require("zod");
10
+
11
+ //#region src/aignehub.ts
12
+ const MODEL_TYPES = [
13
+ "chat",
14
+ "image",
15
+ "video"
16
+ ];
17
+ const CHAT_INPUT_PROPERTIES = {
18
+ prompt: {
19
+ type: "string",
20
+ description: "Your question or instruction (shorthand for single user message)"
21
+ },
22
+ image: {
23
+ type: "string",
24
+ description: "Image URL or base64 data URI for vision (used with prompt)"
25
+ },
26
+ messages: {
27
+ type: "array",
28
+ items: {
29
+ type: "object",
30
+ properties: {
31
+ role: {
32
+ type: "string",
33
+ description: "Message role (user, assistant, system)"
34
+ },
35
+ content: {
36
+ type: "string",
37
+ description: "Message content"
38
+ }
39
+ },
40
+ required: ["role", "content"]
41
+ },
42
+ description: "Full conversation messages array (takes priority over prompt)"
43
+ },
44
+ temperature: {
45
+ type: "number",
46
+ description: "Sampling temperature (0-2)"
47
+ },
48
+ topP: {
49
+ type: "number",
50
+ description: "Nucleus sampling parameter (0-1)"
51
+ },
52
+ frequencyPenalty: {
53
+ type: "number",
54
+ description: "Frequency penalty (-2 to 2)"
55
+ },
56
+ presencePenalty: {
57
+ type: "number",
58
+ description: "Presence penalty (-2 to 2)"
59
+ },
60
+ reasoningEffort: {
61
+ type: "string",
62
+ enum: [
63
+ "low",
64
+ "medium",
65
+ "high"
66
+ ],
67
+ description: "Reasoning effort level for supported models"
68
+ },
69
+ responseFormat: {
70
+ type: "object",
71
+ properties: {
72
+ type: {
73
+ type: "string",
74
+ enum: ["text", "json_schema"]
75
+ },
76
+ jsonSchema: {
77
+ type: "object",
78
+ description: "JSON Schema when type is json_schema"
79
+ }
80
+ },
81
+ description: "Response format configuration"
82
+ },
83
+ tools: {
84
+ type: "array",
85
+ items: { type: "object" },
86
+ description: "Function tool definitions for tool-calling models"
87
+ },
88
+ toolChoice: {
89
+ type: "string",
90
+ enum: [
91
+ "auto",
92
+ "none",
93
+ "required"
94
+ ],
95
+ description: "Tool choice strategy"
96
+ },
97
+ outputFileType: {
98
+ type: "string",
99
+ enum: [
100
+ "url",
101
+ "file",
102
+ "local"
103
+ ],
104
+ description: "Output file type for generated content (url, file, or local)"
105
+ }
106
+ };
107
+ const CHAT_SCHEMA = {
108
+ type: "object",
109
+ properties: CHAT_INPUT_PROPERTIES
110
+ };
111
+ const GENERATE_IMAGE_SCHEMA = {
112
+ type: "object",
113
+ properties: {
114
+ prompt: {
115
+ type: "string",
116
+ description: "Image generation prompt"
117
+ },
118
+ n: {
119
+ type: "number",
120
+ description: "Number of images to generate"
121
+ },
122
+ size: {
123
+ type: "string",
124
+ description: "Image size (e.g. 1024x1024, 1024x1792)"
125
+ },
126
+ quality: {
127
+ type: "string",
128
+ description: "Image quality (e.g. standard, hd)"
129
+ },
130
+ style: {
131
+ type: "string",
132
+ description: "Image style (e.g. natural, vivid)"
133
+ },
134
+ outputFileType: {
135
+ type: "string",
136
+ enum: [
137
+ "url",
138
+ "file",
139
+ "local"
140
+ ],
141
+ description: "Output file type for generated images (url, file, or local)"
142
+ }
143
+ },
144
+ required: ["prompt"]
145
+ };
146
+ const GENERATE_VIDEO_SCHEMA = {
147
+ type: "object",
148
+ properties: {
149
+ prompt: {
150
+ type: "string",
151
+ description: "Video generation prompt"
152
+ },
153
+ size: {
154
+ type: "string",
155
+ description: "Video resolution (e.g. 1920x1080)"
156
+ },
157
+ seconds: {
158
+ type: "string",
159
+ description: "Video duration"
160
+ },
161
+ outputFileType: {
162
+ type: "string",
163
+ enum: [
164
+ "url",
165
+ "file",
166
+ "local"
167
+ ],
168
+ description: "Output file type for generated videos (url, file, or local)"
169
+ }
170
+ },
171
+ required: ["prompt"]
172
+ };
173
+ const ROOT_CHAT_SCHEMA = {
174
+ type: "object",
175
+ properties: {
176
+ model: {
177
+ type: "string",
178
+ description: "Model name (e.g. gpt-4o)"
179
+ },
180
+ ...CHAT_INPUT_PROPERTIES
181
+ },
182
+ required: ["model"]
183
+ };
184
+ const ROOT_GENERATE_IMAGE_SCHEMA = {
185
+ type: "object",
186
+ properties: {
187
+ model: {
188
+ type: "string",
189
+ description: "Model name (e.g. gpt-image-1)"
190
+ },
191
+ ...GENERATE_IMAGE_SCHEMA.properties
192
+ },
193
+ required: ["model", "prompt"]
194
+ };
195
+ const ROOT_GENERATE_VIDEO_SCHEMA = {
196
+ type: "object",
197
+ properties: {
198
+ model: {
199
+ type: "string",
200
+ description: "Model name (e.g. sora-2)"
201
+ },
202
+ ...GENERATE_VIDEO_SCHEMA.properties
203
+ },
204
+ required: ["model", "prompt"]
205
+ };
206
+ const SET_DEFAULT_SCHEMA = {
207
+ type: "object",
208
+ properties: {}
209
+ };
210
+ const SET_DEFAULT_MODEL_SCHEMA = {
211
+ type: "object",
212
+ properties: {
213
+ type: {
214
+ type: "string",
215
+ enum: [
216
+ "chat",
217
+ "image",
218
+ "video"
219
+ ],
220
+ description: "Model type"
221
+ },
222
+ model: {
223
+ type: "string",
224
+ description: "Model name to set as default"
225
+ }
226
+ },
227
+ required: ["type", "model"]
228
+ };
229
+ const SET_DEFAULT_ACTION = {
230
+ name: "setDefault",
231
+ description: "Set this model as the default for its type",
232
+ schema: SET_DEFAULT_SCHEMA
233
+ };
234
+ function getActionsForType(type) {
235
+ if (type === "chat") return [{
236
+ name: "chat",
237
+ description: "Chat inference (prompt shorthand or full messages array)",
238
+ schema: CHAT_SCHEMA
239
+ }, SET_DEFAULT_ACTION];
240
+ if (type === "image") return [{
241
+ name: "generateImage",
242
+ description: "Generate images from a text prompt",
243
+ schema: GENERATE_IMAGE_SCHEMA
244
+ }, SET_DEFAULT_ACTION];
245
+ return [{
246
+ name: "generateVideo",
247
+ description: "Generate video from a text prompt",
248
+ schema: GENERATE_VIDEO_SCHEMA
249
+ }, SET_DEFAULT_ACTION];
250
+ }
251
+ /** Get the primary action name for a model type */
252
+ function primaryActionForType(type) {
253
+ if (type === "chat") return "chat";
254
+ if (type === "image") return "generateImage";
255
+ return "generateVideo";
256
+ }
257
+ /** Root-level actions (includes model param as required) */
258
+ const ROOT_ACTIONS = [
259
+ {
260
+ name: "chat",
261
+ description: "Chat inference (prompt shorthand or full messages array)",
262
+ schema: ROOT_CHAT_SCHEMA
263
+ },
264
+ {
265
+ name: "generateImage",
266
+ description: "Generate images from a text prompt",
267
+ schema: ROOT_GENERATE_IMAGE_SCHEMA
268
+ },
269
+ {
270
+ name: "generateVideo",
271
+ description: "Generate video from a text prompt",
272
+ schema: ROOT_GENERATE_VIDEO_SCHEMA
273
+ },
274
+ {
275
+ name: "setDefaultModel",
276
+ description: "Set the default model for a given type",
277
+ schema: SET_DEFAULT_MODEL_SCHEMA
278
+ },
279
+ {
280
+ name: "refresh",
281
+ description: "Clear model catalog cache and reload on next access",
282
+ schema: {
283
+ type: "object",
284
+ properties: {}
285
+ }
286
+ }
287
+ ];
288
+ function missingParam(name) {
289
+ return {
290
+ success: false,
291
+ error: {
292
+ code: "MISSING_PARAM",
293
+ message: `The '${name}' parameter is required`
294
+ }
295
+ };
296
+ }
297
+ function inferenceError(modelName, err) {
298
+ return {
299
+ success: false,
300
+ error: {
301
+ code: "INFERENCE_ERROR",
302
+ message: `Inference failed for ${modelName}: ${err instanceof Error ? err.message : String(err)}`
303
+ }
304
+ };
305
+ }
306
+ /** Extract last segment of model name for use as a path segment */
307
+ function modelPathSegment(model) {
308
+ const idx = model.model.lastIndexOf("/");
309
+ return idx >= 0 ? model.model.slice(idx + 1) : model.model;
310
+ }
311
+ /** Build multimodal message content from prompt + optional image */
312
+ function buildMessageContent(prompt, image) {
313
+ if (!image) return prompt;
314
+ const parts = [{
315
+ type: "text",
316
+ text: prompt
317
+ }];
318
+ if (image.startsWith("data:")) parts.push({
319
+ type: "file",
320
+ data: image
321
+ });
322
+ else parts.push({
323
+ type: "url",
324
+ url: image
325
+ });
326
+ return parts;
327
+ }
328
+ /** Build SDK ChatModelInput from flat args */
329
+ function buildChatSDKInput(args) {
330
+ const input = {};
331
+ const image = args.image;
332
+ if (Array.isArray(args.messages) && args.messages.length > 0) input.messages = args.messages;
333
+ else if (args.prompt !== void 0 && args.prompt !== null) input.messages = [{
334
+ role: "user",
335
+ content: buildMessageContent(String(args.prompt), image)
336
+ }];
337
+ const modelOptions = {};
338
+ for (const key of [
339
+ "temperature",
340
+ "topP",
341
+ "frequencyPenalty",
342
+ "presencePenalty",
343
+ "reasoningEffort"
344
+ ]) if (args[key] !== void 0) modelOptions[key] = args[key];
345
+ if (Object.keys(modelOptions).length > 0) input.modelOptions = modelOptions;
346
+ if (args.responseFormat !== void 0) input.responseFormat = args.responseFormat;
347
+ if (args.tools !== void 0) input.tools = args.tools;
348
+ if (args.toolChoice !== void 0) input.toolChoice = args.toolChoice;
349
+ input.outputFileType = args.outputFileType ?? "url";
350
+ return input;
351
+ }
352
+ var AFSAigneHub = class AFSAigneHub extends _aigne_afs.AFSBaseProvider {
353
+ static schema() {
354
+ return require_types.afsAigneHubOptionsSchema;
355
+ }
356
+ static manifest() {
357
+ return {
358
+ name: "aignehub",
359
+ description: "AigneHub AI Model Gateway — discover and run AI models",
360
+ uriTemplate: "aignehub://{host?}",
361
+ category: "ai",
362
+ schema: zod.z.object({
363
+ host: zod.z.string().optional(),
364
+ apiKey: zod.z.string().meta({ sensitive: true })
365
+ }),
366
+ tags: [
367
+ "ai",
368
+ "llm",
369
+ "model",
370
+ "aignehub"
371
+ ]
372
+ };
373
+ }
374
+ static async load({ config } = {}) {
375
+ const cfg = { ...config ?? {} };
376
+ if (cfg.host && !cfg.url) cfg.url = `https://${cfg.host}`;
377
+ return new AFSAigneHub(await AFSAigneHub.schema().parseAsync(cfg));
378
+ }
379
+ static async auth(context) {
380
+ const host = context.resolved?.host;
381
+ return require_auth.aigneHubAuth(context, host ? `https://${host}` : void 0);
382
+ }
383
+ name;
384
+ description;
385
+ accessMode = "readwrite";
386
+ apiKey;
387
+ baseURL;
388
+ needsURLDiscovery;
389
+ catalog = null;
390
+ /** Config-level defaults (from constructor options) */
391
+ configDefaults;
392
+ /** Runtime overrides (set via setDefault action, takes highest priority) */
393
+ runtimeDefaults = {};
394
+ /** Mount path captured from onMount (for config persistence) */
395
+ mountPath;
396
+ /** Injectable callback for persisting config changes */
397
+ updateConfigFn;
398
+ constructor(options) {
399
+ super();
400
+ const parsed = (0, _aigne_afs_utils_zod.zodParse)(require_types.afsAigneHubOptionsSchema, options);
401
+ this.name = parsed.name;
402
+ this.description = parsed.description;
403
+ this.apiKey = parsed.apiKey;
404
+ this.baseURL = parsed.url || _aigne_aigne_hub.AIGNE_HUB_URL;
405
+ this.needsURLDiscovery = !parsed.url;
406
+ this.configDefaults = {
407
+ ...parsed.defaultChat ? { chat: parsed.defaultChat } : {},
408
+ ...parsed.defaultImage ? { image: parsed.defaultImage } : {},
409
+ ...parsed.defaultVideo ? { video: parsed.defaultVideo } : {}
410
+ };
411
+ }
412
+ async ready() {
413
+ if (this.needsURLDiscovery) {
414
+ const { getAIGNEHubMountPoint } = await import("@aigne/aigne-hub");
415
+ const { AIGNE_HUB_BLOCKLET_DID } = await Promise.resolve().then(() => require("./auth.cjs"));
416
+ this.baseURL = await getAIGNEHubMountPoint(this.baseURL, AIGNE_HUB_BLOCKLET_DID);
417
+ }
418
+ }
419
+ onMount(root, mountPath) {
420
+ this.mountPath = mountPath;
421
+ this.updateConfigFn = root.updateProviderConfig;
422
+ }
423
+ async ensureCatalog() {
424
+ if (this.catalog) return this.catalog;
425
+ const [chat, image, video] = await Promise.all([
426
+ this.fetchModels("chat"),
427
+ this.fetchModels("image"),
428
+ this.fetchModels("video")
429
+ ]);
430
+ const catalog = {
431
+ chat,
432
+ image,
433
+ video
434
+ };
435
+ this.catalog = catalog;
436
+ return catalog;
437
+ }
438
+ async fetchModels(type) {
439
+ const url = (0, ufo.joinURL)(this.baseURL, "/api/ai/models");
440
+ const response = await fetch(`${url}?type=${type}`, { headers: { Authorization: `Bearer ${this.apiKey}` } });
441
+ if (!response.ok) throw new Error(`Failed to fetch ${type} models: ${response.status} ${response.statusText}`);
442
+ return (await response.json()).map((m) => ({
443
+ type,
444
+ model: m.model,
445
+ provider: m.provider,
446
+ inputCreditsPerToken: m.input_credits_per_token,
447
+ outputCreditsPerToken: m.output_credits_per_token,
448
+ providerDisplayName: m.providerDisplayName,
449
+ status: m.status,
450
+ modelMetadata: m.modelMetadata
451
+ }));
452
+ }
453
+ /** Get unique providers with their model counts */
454
+ getProviderStats(catalog) {
455
+ const map = /* @__PURE__ */ new Map();
456
+ for (const type of MODEL_TYPES) for (const m of catalog[type]) {
457
+ const existing = map.get(m.provider);
458
+ if (existing) existing.count++;
459
+ else map.set(m.provider, {
460
+ displayName: m.providerDisplayName,
461
+ count: 1
462
+ });
463
+ }
464
+ return Array.from(map.entries()).map(([name, v]) => ({
465
+ name,
466
+ displayName: v.displayName,
467
+ count: v.count
468
+ }));
469
+ }
470
+ /** Get all models for a specific provider */
471
+ getModelsForProvider(catalog, provider) {
472
+ return MODEL_TYPES.flatMap((type) => catalog[type].filter((m) => m.provider === provider));
473
+ }
474
+ /** Get default model for a type. Priority: runtime override > config > API first */
475
+ getDefaultModel(catalog, type) {
476
+ const models = catalog[type];
477
+ const name = this.runtimeDefaults[type] ?? this.configDefaults[type];
478
+ if (name) {
479
+ const found = models.find((m) => m.model === name);
480
+ if (found) return found;
481
+ }
482
+ return models[0];
483
+ }
484
+ /** Validate type param, throw AFSNotFoundError if invalid */
485
+ validateType(type) {
486
+ if (MODEL_TYPES.includes(type)) return type;
487
+ throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/types", type), `Type '${type}' not found. Available types: ${MODEL_TYPES.join(", ")}`);
488
+ }
489
+ async listRoot(_ctx) {
490
+ const catalog = await this.ensureCatalog();
491
+ const providerCount = this.getProviderStats(catalog).length;
492
+ return { data: [
493
+ this.buildEntry("/defaults", { meta: {
494
+ childrenCount: MODEL_TYPES.length,
495
+ kind: "aignehub:directory"
496
+ } }),
497
+ this.buildEntry("/providers", { meta: {
498
+ childrenCount: providerCount,
499
+ kind: "aignehub:directory"
500
+ } }),
501
+ this.buildEntry("/types", { meta: {
502
+ childrenCount: MODEL_TYPES.length,
503
+ kind: "aignehub:directory"
504
+ } })
505
+ ] };
506
+ }
507
+ async readRoot(_ctx) {
508
+ return this.buildEntry("/", {
509
+ content: {
510
+ provider: "aignehub",
511
+ description: "AigneHub AI Model Gateway"
512
+ },
513
+ meta: {
514
+ childrenCount: 3,
515
+ kind: "aignehub:root"
516
+ }
517
+ });
518
+ }
519
+ async rootMeta(_ctx) {
520
+ return this.buildEntry("/.meta", {
521
+ content: {
522
+ provider: "aignehub",
523
+ baseURL: this.baseURL,
524
+ description: "AigneHub AI Model Gateway"
525
+ },
526
+ meta: {
527
+ childrenCount: 3,
528
+ kind: "aignehub:root"
529
+ }
530
+ });
531
+ }
532
+ async readCapabilities(_ctx) {
533
+ const operations = this.getOperationsDeclaration();
534
+ const manifest = {
535
+ schemaVersion: 1,
536
+ provider: this.name,
537
+ description: this.description || "AigneHub AI Model Gateway",
538
+ tools: [],
539
+ operations,
540
+ actions: [{
541
+ description: "Root-level actions",
542
+ catalog: [
543
+ {
544
+ name: "chat",
545
+ description: "Chat inference (prompt shorthand or full messages array)",
546
+ inputSchema: ROOT_CHAT_SCHEMA
547
+ },
548
+ {
549
+ name: "generateImage",
550
+ description: "Generate images from a text prompt",
551
+ inputSchema: ROOT_GENERATE_IMAGE_SCHEMA
552
+ },
553
+ {
554
+ name: "generateVideo",
555
+ description: "Generate video from a text prompt",
556
+ inputSchema: ROOT_GENERATE_VIDEO_SCHEMA
557
+ },
558
+ {
559
+ name: "refresh",
560
+ description: "Clear model catalog cache",
561
+ inputSchema: {
562
+ type: "object",
563
+ properties: {}
564
+ }
565
+ }
566
+ ],
567
+ discovery: {
568
+ pathTemplate: "/.actions",
569
+ note: "Root actions: chat, generateImage, generateVideo, refresh"
570
+ }
571
+ }, {
572
+ description: "Model-level actions (varies by model type)",
573
+ catalog: [
574
+ {
575
+ name: "chat",
576
+ description: "Chat inference (chat models)",
577
+ inputSchema: CHAT_SCHEMA
578
+ },
579
+ {
580
+ name: "generateImage",
581
+ description: "Generate images (image models)",
582
+ inputSchema: GENERATE_IMAGE_SCHEMA
583
+ },
584
+ {
585
+ name: "generateVideo",
586
+ description: "Generate video (video models)",
587
+ inputSchema: GENERATE_VIDEO_SCHEMA
588
+ }
589
+ ],
590
+ discovery: {
591
+ pathTemplate: "/providers/:provider/:model/.actions",
592
+ note: "Actions depend on model type. Chat: chat; Image: generateImage; Video: generateVideo. Also accessible via /defaults/:type/.actions and /types/:type/:model/.actions."
593
+ }
594
+ }]
595
+ };
596
+ return this.buildEntry("/.meta/.capabilities", {
597
+ content: manifest,
598
+ meta: {
599
+ kind: "afs:capabilities",
600
+ ...operations
601
+ }
602
+ });
603
+ }
604
+ async explainRoot(_ctx) {
605
+ const catalog = await this.ensureCatalog();
606
+ const providers = this.getProviderStats(catalog);
607
+ return {
608
+ content: [
609
+ "# AigneHub AI Model Gateway",
610
+ "",
611
+ `Unified access to ${MODEL_TYPES.reduce((sum, t) => sum + catalog[t].length, 0)} AI models from ${providers.length} providers.`,
612
+ "",
613
+ "## Quick Start",
614
+ "",
615
+ "- Chat: `exec /defaults/chat/.actions/chat { \"prompt\": \"Hello\" }`",
616
+ "- Generate image: `exec /defaults/image/.actions/generateImage { \"prompt\": \"A sunset\" }`",
617
+ "- Generate video: `exec /defaults/video/.actions/generateVideo { \"prompt\": \"Ocean waves\" }`",
618
+ "",
619
+ "## Browse Models",
620
+ "",
621
+ "- `list /defaults` — Default models for quick access",
622
+ "- `list /providers` — Browse by provider",
623
+ "- `list /types` — Browse by capability (chat, image, video)",
624
+ "",
625
+ "## Root Actions",
626
+ "",
627
+ "- `exec /.actions/chat { \"model\": \"gpt-4o\", \"prompt\": \"Hello\" }`",
628
+ "- `exec /.actions/generateImage { \"model\": \"gpt-image-1\", \"prompt\": \"A cat\" }`",
629
+ "- `exec /.actions/refresh` — Reload model catalog"
630
+ ].join("\n"),
631
+ format: "markdown"
632
+ };
633
+ }
634
+ async statRoot(_ctx) {
635
+ return { data: this.buildEntry("/", { meta: {
636
+ childrenCount: 3,
637
+ kind: "aignehub:root"
638
+ } }) };
639
+ }
640
+ async listDefaults(_ctx) {
641
+ const catalog = await this.ensureCatalog();
642
+ return { data: MODEL_TYPES.map((type) => {
643
+ const model = this.getDefaultModel(catalog, type);
644
+ return this.buildEntry((0, ufo.joinURL)("/defaults", type), { meta: {
645
+ childrenCount: 0,
646
+ kind: `aignehub:default-${type}`,
647
+ type,
648
+ ...model ? {
649
+ model: model.model,
650
+ provider: model.provider
651
+ } : {}
652
+ } });
653
+ }) };
654
+ }
655
+ async readDefaults(_ctx) {
656
+ const catalog = await this.ensureCatalog();
657
+ const defaults = {};
658
+ for (const type of MODEL_TYPES) defaults[type] = this.getDefaultModel(catalog, type)?.model ?? null;
659
+ return this.buildEntry("/defaults", {
660
+ content: { defaults },
661
+ meta: {
662
+ childrenCount: MODEL_TYPES.length,
663
+ kind: "aignehub:directory"
664
+ }
665
+ });
666
+ }
667
+ async defaultsMeta(_ctx) {
668
+ return this.buildEntry("/defaults/.meta", {
669
+ content: { description: "Default model shortcuts" },
670
+ meta: {
671
+ childrenCount: MODEL_TYPES.length,
672
+ kind: "aignehub:directory"
673
+ }
674
+ });
675
+ }
676
+ async statDefaults(_ctx) {
677
+ return { data: this.buildEntry("/defaults", { meta: {
678
+ childrenCount: MODEL_TYPES.length,
679
+ kind: "aignehub:directory"
680
+ } }) };
681
+ }
682
+ async explainDefaults(_ctx) {
683
+ const catalog = await this.ensureCatalog();
684
+ const lines = [
685
+ "# Default Models",
686
+ "",
687
+ "Pre-selected models for quick access — one per type.",
688
+ "",
689
+ "## Examples",
690
+ ""
691
+ ];
692
+ for (const type of MODEL_TYPES) {
693
+ const model = this.getDefaultModel(catalog, type);
694
+ const action = primaryActionForType(type);
695
+ if (model) lines.push(`- **${type}** (${model.model}): \`exec /defaults/${type}/.actions/${action} { "prompt": "..." }\``);
696
+ }
697
+ lines.push("", "## Navigation", "");
698
+ for (const type of MODEL_TYPES) lines.push(`- \`explain /defaults/${type}\` — Default ${type} model details`);
699
+ return {
700
+ content: lines.join("\n"),
701
+ format: "markdown"
702
+ };
703
+ }
704
+ async listDefault(ctx) {
705
+ this.validateType(ctx.params.type);
706
+ return { data: [] };
707
+ }
708
+ async readDefault(ctx) {
709
+ const type = this.validateType(ctx.params.type);
710
+ const catalog = await this.ensureCatalog();
711
+ const model = this.getDefaultModel(catalog, type);
712
+ if (!model) return this.buildEntry((0, ufo.joinURL)("/defaults", type), {
713
+ content: {
714
+ type,
715
+ model: null,
716
+ message: `No ${type} models available`
717
+ },
718
+ meta: {
719
+ childrenCount: 0,
720
+ kind: `aignehub:default-${type}`
721
+ }
722
+ });
723
+ return this.buildModelEntry((0, ufo.joinURL)("/defaults", type), model);
724
+ }
725
+ async statDefault(ctx) {
726
+ const type = this.validateType(ctx.params.type);
727
+ const catalog = await this.ensureCatalog();
728
+ const model = this.getDefaultModel(catalog, type);
729
+ return { data: this.buildEntry((0, ufo.joinURL)("/defaults", type), { meta: {
730
+ childrenCount: 0,
731
+ kind: `aignehub:default-${type}`,
732
+ type,
733
+ ...model ? { model: model.model } : {}
734
+ } }) };
735
+ }
736
+ async defaultTypeMeta(ctx) {
737
+ const type = this.validateType(ctx.params.type);
738
+ const catalog = await this.ensureCatalog();
739
+ const model = this.getDefaultModel(catalog, type);
740
+ return this.buildEntry((0, ufo.joinURL)("/defaults", type, ".meta"), {
741
+ content: {
742
+ type,
743
+ model: model?.model ?? null
744
+ },
745
+ meta: {
746
+ childrenCount: 0,
747
+ kind: `aignehub:default-${type}`,
748
+ type,
749
+ ...model ? { model: model.model } : {}
750
+ }
751
+ });
752
+ }
753
+ async explainDefault(ctx) {
754
+ const type = this.validateType(ctx.params.type);
755
+ const catalog = await this.ensureCatalog();
756
+ const model = this.getDefaultModel(catalog, type);
757
+ if (!model) return {
758
+ content: `No default ${type} model available.`,
759
+ format: "text"
760
+ };
761
+ return this.buildModelExplain((0, ufo.joinURL)("/defaults", type), model);
762
+ }
763
+ async listDefaultActions(ctx) {
764
+ const type = this.validateType(ctx.params.type);
765
+ const basePath = (0, ufo.joinURL)("/defaults", type);
766
+ return { data: getActionsForType(type).map((action) => this.buildActionEntry((0, ufo.joinURL)(basePath, ".actions", action.name), action.name, action.description, action.schema)) };
767
+ }
768
+ async execDefaultChat(ctx, args) {
769
+ const type = this.validateType(ctx.params.type);
770
+ if (type !== "chat") throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/defaults", type, ".actions/chat"), `Action 'chat' is not available for ${type} models.`);
771
+ const catalog = await this.ensureCatalog();
772
+ const model = this.getDefaultModel(catalog, type);
773
+ if (!model) return {
774
+ success: false,
775
+ error: {
776
+ code: "NO_DEFAULT",
777
+ message: `No default ${type} model available`
778
+ }
779
+ };
780
+ return this.runChat(model.model, args);
781
+ }
782
+ async execDefaultGenerateImage(ctx, args) {
783
+ const type = this.validateType(ctx.params.type);
784
+ if (type !== "image") throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/defaults", type, ".actions/generateImage"), `Action 'generateImage' is not available for ${type} models.`);
785
+ const catalog = await this.ensureCatalog();
786
+ const model = this.getDefaultModel(catalog, type);
787
+ if (!model) return {
788
+ success: false,
789
+ error: {
790
+ code: "NO_DEFAULT",
791
+ message: `No default ${type} model available`
792
+ }
793
+ };
794
+ return this.runImage(model.model, args);
795
+ }
796
+ async execDefaultGenerateVideo(ctx, args) {
797
+ const type = this.validateType(ctx.params.type);
798
+ if (type !== "video") throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/defaults", type, ".actions/generateVideo"), `Action 'generateVideo' is not available for ${type} models.`);
799
+ const catalog = await this.ensureCatalog();
800
+ const model = this.getDefaultModel(catalog, type);
801
+ if (!model) return {
802
+ success: false,
803
+ error: {
804
+ code: "NO_DEFAULT",
805
+ message: `No default ${type} model available`
806
+ }
807
+ };
808
+ return this.runVideo(model.model, args);
809
+ }
810
+ async listProviders(_ctx) {
811
+ const catalog = await this.ensureCatalog();
812
+ return { data: this.getProviderStats(catalog).map((p) => this.buildEntry((0, ufo.joinURL)("/providers", p.name), { meta: {
813
+ childrenCount: p.count,
814
+ kind: "aignehub:provider",
815
+ providerDisplayName: p.displayName
816
+ } })) };
817
+ }
818
+ async readProviders(_ctx) {
819
+ const catalog = await this.ensureCatalog();
820
+ const providers = this.getProviderStats(catalog);
821
+ const totalModels = MODEL_TYPES.reduce((sum, t) => sum + catalog[t].length, 0);
822
+ return this.buildEntry("/providers", {
823
+ content: {
824
+ providers: providers.map((p) => p.name),
825
+ totalModels
826
+ },
827
+ meta: {
828
+ childrenCount: providers.length,
829
+ kind: "aignehub:directory"
830
+ }
831
+ });
832
+ }
833
+ async providersMeta(_ctx) {
834
+ const catalog = await this.ensureCatalog();
835
+ const providers = this.getProviderStats(catalog);
836
+ const totalModels = MODEL_TYPES.reduce((sum, t) => sum + catalog[t].length, 0);
837
+ return this.buildEntry("/providers/.meta", {
838
+ content: {
839
+ providers: providers.map((p) => p.name),
840
+ totalModels
841
+ },
842
+ meta: {
843
+ childrenCount: providers.length,
844
+ kind: "aignehub:directory"
845
+ }
846
+ });
847
+ }
848
+ async statProviders(_ctx) {
849
+ const catalog = await this.ensureCatalog();
850
+ const providers = this.getProviderStats(catalog);
851
+ return { data: this.buildEntry("/providers", { meta: {
852
+ childrenCount: providers.length,
853
+ kind: "aignehub:directory"
854
+ } }) };
855
+ }
856
+ async explainProviders(_ctx) {
857
+ const catalog = await this.ensureCatalog();
858
+ const providers = this.getProviderStats(catalog);
859
+ const totalModels = MODEL_TYPES.reduce((sum, t) => sum + catalog[t].length, 0);
860
+ return {
861
+ content: [
862
+ "# Providers",
863
+ "",
864
+ `${providers.length} providers, ${totalModels} models total.`,
865
+ "",
866
+ "## Available Providers",
867
+ "",
868
+ ...providers.map((p) => `- **${p.displayName}** (\`${p.name}\`): ${p.count} models`),
869
+ "",
870
+ "## Example",
871
+ "",
872
+ `\`list /providers/${providers[0]?.name ?? "openai"}\` — List models from a provider`
873
+ ].join("\n"),
874
+ format: "markdown"
875
+ };
876
+ }
877
+ async listProvider(ctx) {
878
+ const catalog = await this.ensureCatalog();
879
+ const models = this.getModelsForProvider(catalog, ctx.params.provider);
880
+ if (models.length === 0) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", ctx.params.provider), `Provider '${ctx.params.provider}' not found.`);
881
+ return { data: models.map((m) => this.buildEntry((0, ufo.joinURL)("/providers", ctx.params.provider, modelPathSegment(m)), { meta: {
882
+ childrenCount: 0,
883
+ kind: `aignehub:${m.type}-model`,
884
+ type: m.type
885
+ } })) };
886
+ }
887
+ async readProvider(ctx) {
888
+ const catalog = await this.ensureCatalog();
889
+ const models = this.getModelsForProvider(catalog, ctx.params.provider);
890
+ if (models.length === 0) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", ctx.params.provider), `Provider '${ctx.params.provider}' not found.`);
891
+ const displayName = models[0].providerDisplayName;
892
+ return this.buildEntry((0, ufo.joinURL)("/providers", ctx.params.provider), {
893
+ content: {
894
+ provider: ctx.params.provider,
895
+ providerDisplayName: displayName,
896
+ modelCount: models.length,
897
+ models: models.map((m) => ({
898
+ model: m.model,
899
+ type: m.type
900
+ }))
901
+ },
902
+ meta: {
903
+ childrenCount: models.length,
904
+ kind: "aignehub:provider",
905
+ providerDisplayName: displayName
906
+ }
907
+ });
908
+ }
909
+ async providerMeta(ctx) {
910
+ const catalog = await this.ensureCatalog();
911
+ const models = this.getModelsForProvider(catalog, ctx.params.provider);
912
+ if (models.length === 0) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", ctx.params.provider), `Provider '${ctx.params.provider}' not found.`);
913
+ const displayName = models[0].providerDisplayName;
914
+ return this.buildEntry((0, ufo.joinURL)("/providers", ctx.params.provider, ".meta"), {
915
+ content: {
916
+ provider: ctx.params.provider,
917
+ providerDisplayName: displayName,
918
+ modelCount: models.length
919
+ },
920
+ meta: {
921
+ childrenCount: models.length,
922
+ kind: "aignehub:provider",
923
+ providerDisplayName: displayName
924
+ }
925
+ });
926
+ }
927
+ async statProvider(ctx) {
928
+ const catalog = await this.ensureCatalog();
929
+ const models = this.getModelsForProvider(catalog, ctx.params.provider);
930
+ if (models.length === 0) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", ctx.params.provider), `Provider '${ctx.params.provider}' not found.`);
931
+ return { data: this.buildEntry((0, ufo.joinURL)("/providers", ctx.params.provider), { meta: {
932
+ childrenCount: models.length,
933
+ kind: "aignehub:provider"
934
+ } }) };
935
+ }
936
+ async explainProvider(ctx) {
937
+ const catalog = await this.ensureCatalog();
938
+ const models = this.getModelsForProvider(catalog, ctx.params.provider);
939
+ if (models.length === 0) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", ctx.params.provider), `Provider '${ctx.params.provider}' not found.`);
940
+ const displayName = models[0].providerDisplayName;
941
+ const chatModels = models.filter((m) => m.type === "chat");
942
+ const imageModels = models.filter((m) => m.type === "image");
943
+ const videoModels = models.filter((m) => m.type === "video");
944
+ const parts = [
945
+ chatModels.length ? `${chatModels.length} chat` : null,
946
+ imageModels.length ? `${imageModels.length} image` : null,
947
+ videoModels.length ? `${videoModels.length} video` : null
948
+ ].filter(Boolean);
949
+ const firstChat = chatModels[0];
950
+ const lines = [
951
+ `# ${displayName}`,
952
+ "",
953
+ `${parts.join(", ")} models available.`,
954
+ "",
955
+ "## Models",
956
+ "",
957
+ ...models.map((m) => `- **${modelPathSegment(m)}** (${m.type})`),
958
+ "",
959
+ "## Example",
960
+ ""
961
+ ];
962
+ if (firstChat) lines.push(`\`exec /providers/${ctx.params.provider}/${modelPathSegment(firstChat)}/.actions/chat { "prompt": "Hello" }\``);
963
+ return {
964
+ content: lines.join("\n"),
965
+ format: "markdown"
966
+ };
967
+ }
968
+ async listProviderModel(ctx) {
969
+ await this.findModelByPath(ctx.params.provider, ctx.params.model);
970
+ return { data: [] };
971
+ }
972
+ async readProviderModel(ctx) {
973
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
974
+ return this.buildModelEntry((0, ufo.joinURL)("/providers", ctx.params.provider, ctx.params.model), model);
975
+ }
976
+ async providerModelMeta(ctx) {
977
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
978
+ return this.buildEntry((0, ufo.joinURL)("/providers", ctx.params.provider, ctx.params.model, ".meta"), {
979
+ content: {
980
+ model: model.model,
981
+ provider: model.provider,
982
+ type: model.type
983
+ },
984
+ meta: {
985
+ childrenCount: 0,
986
+ kind: `aignehub:${model.type}-model`,
987
+ type: model.type
988
+ }
989
+ });
990
+ }
991
+ async statProviderModel(ctx) {
992
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
993
+ return { data: this.buildEntry((0, ufo.joinURL)("/providers", ctx.params.provider, ctx.params.model), { meta: {
994
+ childrenCount: 0,
995
+ kind: `aignehub:${model.type}-model`,
996
+ type: model.type
997
+ } }) };
998
+ }
999
+ async explainProviderModel(ctx) {
1000
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
1001
+ return this.buildModelExplain((0, ufo.joinURL)("/providers", ctx.params.provider, ctx.params.model), model);
1002
+ }
1003
+ async listProviderModelActions(ctx) {
1004
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
1005
+ const basePath = (0, ufo.joinURL)("/providers", ctx.params.provider, ctx.params.model);
1006
+ return { data: getActionsForType(model.type).map((action) => this.buildActionEntry((0, ufo.joinURL)(basePath, ".actions", action.name), action.name, action.description, action.schema)) };
1007
+ }
1008
+ async execProviderChat(ctx, args) {
1009
+ const model = await this.findModelOfTypeByPath(ctx.params.provider, ctx.params.model, "chat");
1010
+ return this.runChat(model.model, args);
1011
+ }
1012
+ async execProviderGenerateImage(ctx, args) {
1013
+ const model = await this.findModelOfTypeByPath(ctx.params.provider, ctx.params.model, "image");
1014
+ return this.runImage(model.model, args);
1015
+ }
1016
+ async execProviderGenerateVideo(ctx, args) {
1017
+ const model = await this.findModelOfTypeByPath(ctx.params.provider, ctx.params.model, "video");
1018
+ return this.runVideo(model.model, args);
1019
+ }
1020
+ async execProviderSetDefault(ctx) {
1021
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
1022
+ return await this.setDefault(model);
1023
+ }
1024
+ async listTypes(_ctx) {
1025
+ const catalog = await this.ensureCatalog();
1026
+ return { data: MODEL_TYPES.map((type) => this.buildEntry((0, ufo.joinURL)("/types", type), { meta: {
1027
+ childrenCount: catalog[type].length,
1028
+ kind: `aignehub:type-${type}`
1029
+ } })) };
1030
+ }
1031
+ async readTypes(_ctx) {
1032
+ const catalog = await this.ensureCatalog();
1033
+ const types = MODEL_TYPES.map((type) => ({
1034
+ type,
1035
+ count: catalog[type].length
1036
+ }));
1037
+ return this.buildEntry("/types", {
1038
+ content: { types },
1039
+ meta: {
1040
+ childrenCount: MODEL_TYPES.length,
1041
+ kind: "aignehub:directory"
1042
+ }
1043
+ });
1044
+ }
1045
+ async typesMeta(_ctx) {
1046
+ const catalog = await this.ensureCatalog();
1047
+ const types = MODEL_TYPES.map((type) => ({
1048
+ type,
1049
+ count: catalog[type].length
1050
+ }));
1051
+ return this.buildEntry("/types/.meta", {
1052
+ content: { types },
1053
+ meta: {
1054
+ childrenCount: MODEL_TYPES.length,
1055
+ kind: "aignehub:directory"
1056
+ }
1057
+ });
1058
+ }
1059
+ async statTypes(_ctx) {
1060
+ return { data: this.buildEntry("/types", { meta: {
1061
+ childrenCount: MODEL_TYPES.length,
1062
+ kind: "aignehub:directory"
1063
+ } }) };
1064
+ }
1065
+ async explainTypes(_ctx) {
1066
+ const catalog = await this.ensureCatalog();
1067
+ return {
1068
+ content: [
1069
+ "# Model Types",
1070
+ "",
1071
+ "Browse models by capability.",
1072
+ "",
1073
+ ...MODEL_TYPES.map((type) => `- **${type}**: ${catalog[type].length} models`),
1074
+ "",
1075
+ "## Example",
1076
+ "",
1077
+ "`list /types/chat` — List all chat models",
1078
+ "",
1079
+ "## Navigation",
1080
+ "",
1081
+ "- By provider: `list /providers`"
1082
+ ].join("\n"),
1083
+ format: "markdown"
1084
+ };
1085
+ }
1086
+ async listType(ctx) {
1087
+ const type = this.validateType(ctx.params.type);
1088
+ return { data: (await this.ensureCatalog())[type].map((m) => this.buildEntry((0, ufo.joinURL)("/types", type, modelPathSegment(m)), { meta: {
1089
+ childrenCount: 0,
1090
+ kind: `aignehub:${type}-model`,
1091
+ type,
1092
+ provider: m.provider
1093
+ } })) };
1094
+ }
1095
+ async readType(ctx) {
1096
+ const type = this.validateType(ctx.params.type);
1097
+ const catalog = await this.ensureCatalog();
1098
+ return this.buildEntry((0, ufo.joinURL)("/types", type), {
1099
+ content: {
1100
+ type,
1101
+ modelCount: catalog[type].length,
1102
+ models: catalog[type].map((m) => ({
1103
+ model: m.model,
1104
+ provider: m.provider
1105
+ }))
1106
+ },
1107
+ meta: {
1108
+ childrenCount: catalog[type].length,
1109
+ kind: `aignehub:type-${type}`
1110
+ }
1111
+ });
1112
+ }
1113
+ async typeMeta(ctx) {
1114
+ const type = this.validateType(ctx.params.type);
1115
+ const catalog = await this.ensureCatalog();
1116
+ return this.buildEntry((0, ufo.joinURL)("/types", type, ".meta"), {
1117
+ content: {
1118
+ type,
1119
+ modelCount: catalog[type].length
1120
+ },
1121
+ meta: {
1122
+ childrenCount: catalog[type].length,
1123
+ kind: `aignehub:type-${type}`
1124
+ }
1125
+ });
1126
+ }
1127
+ async statType(ctx) {
1128
+ const type = this.validateType(ctx.params.type);
1129
+ const catalog = await this.ensureCatalog();
1130
+ return { data: this.buildEntry((0, ufo.joinURL)("/types", type), { meta: {
1131
+ childrenCount: catalog[type].length,
1132
+ kind: `aignehub:type-${type}`
1133
+ } }) };
1134
+ }
1135
+ async explainType(ctx) {
1136
+ const type = this.validateType(ctx.params.type);
1137
+ const models = (await this.ensureCatalog())[type];
1138
+ const action = primaryActionForType(type);
1139
+ const lines = [
1140
+ `# ${type} models`,
1141
+ "",
1142
+ `${models.length} models available.`,
1143
+ "",
1144
+ "## Models",
1145
+ "",
1146
+ ...models.map((m) => `- **${modelPathSegment(m)}** (${m.providerDisplayName})`),
1147
+ "",
1148
+ "## Example",
1149
+ ""
1150
+ ];
1151
+ if (models.length > 0) {
1152
+ const first = models[0];
1153
+ lines.push(`\`exec /types/${type}/${modelPathSegment(first)}/.actions/${action} { "prompt": "..." }\``);
1154
+ }
1155
+ lines.push("", "## Navigation", "", "- By provider: `list /providers`");
1156
+ return {
1157
+ content: lines.join("\n"),
1158
+ format: "markdown"
1159
+ };
1160
+ }
1161
+ async listTypeModel(ctx) {
1162
+ const type = this.validateType(ctx.params.type);
1163
+ await this.findModelByTypeAndSegment(type, ctx.params.model);
1164
+ return { data: [] };
1165
+ }
1166
+ async readTypeModel(ctx) {
1167
+ const type = this.validateType(ctx.params.type);
1168
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1169
+ return this.buildModelEntry((0, ufo.joinURL)("/types", type, ctx.params.model), model);
1170
+ }
1171
+ async statTypeModel(ctx) {
1172
+ const type = this.validateType(ctx.params.type);
1173
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1174
+ return { data: this.buildEntry((0, ufo.joinURL)("/types", type, ctx.params.model), { meta: {
1175
+ childrenCount: 0,
1176
+ kind: `aignehub:${model.type}-model`,
1177
+ type: model.type
1178
+ } }) };
1179
+ }
1180
+ async typeModelMeta(ctx) {
1181
+ const type = this.validateType(ctx.params.type);
1182
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1183
+ return this.buildEntry((0, ufo.joinURL)("/types", type, ctx.params.model, ".meta"), {
1184
+ content: {
1185
+ model: model.model,
1186
+ provider: model.provider,
1187
+ type: model.type
1188
+ },
1189
+ meta: {
1190
+ childrenCount: 0,
1191
+ kind: `aignehub:${model.type}-model`,
1192
+ type: model.type
1193
+ }
1194
+ });
1195
+ }
1196
+ async explainTypeModel(ctx) {
1197
+ const type = this.validateType(ctx.params.type);
1198
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1199
+ return this.buildModelExplain((0, ufo.joinURL)("/types", type, ctx.params.model), model);
1200
+ }
1201
+ async listTypeModelActions(ctx) {
1202
+ const type = this.validateType(ctx.params.type);
1203
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1204
+ const basePath = (0, ufo.joinURL)("/types", type, ctx.params.model);
1205
+ return { data: getActionsForType(model.type).map((action) => this.buildActionEntry((0, ufo.joinURL)(basePath, ".actions", action.name), action.name, action.description, action.schema)) };
1206
+ }
1207
+ async execTypeChat(ctx, args) {
1208
+ const type = this.validateType(ctx.params.type);
1209
+ if (type !== "chat") throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/types", type, ctx.params.model, ".actions/chat"), `Action 'chat' is not available for ${type} models.`);
1210
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1211
+ return this.runChat(model.model, args);
1212
+ }
1213
+ async execTypeGenerateImage(ctx, args) {
1214
+ const type = this.validateType(ctx.params.type);
1215
+ if (type !== "image") throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/types", type, ctx.params.model, ".actions/generateImage"), `Action 'generateImage' is not available for ${type} models.`);
1216
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1217
+ return this.runImage(model.model, args);
1218
+ }
1219
+ async execTypeGenerateVideo(ctx, args) {
1220
+ const type = this.validateType(ctx.params.type);
1221
+ if (type !== "video") throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/types", type, ctx.params.model, ".actions/generateVideo"), `Action 'generateVideo' is not available for ${type} models.`);
1222
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1223
+ return this.runVideo(model.model, args);
1224
+ }
1225
+ async execTypeSetDefault(ctx) {
1226
+ const type = this.validateType(ctx.params.type);
1227
+ const model = await this.findModelByTypeAndSegment(type, ctx.params.model);
1228
+ return await this.setDefault(model);
1229
+ }
1230
+ async listRootActions(_ctx) {
1231
+ return { data: [
1232
+ this.buildActionEntry("/.actions/chat", "chat", "Chat inference (prompt shorthand or full messages array)", ROOT_CHAT_SCHEMA),
1233
+ this.buildActionEntry("/.actions/generateImage", "generateImage", "Generate images from a text prompt", ROOT_GENERATE_IMAGE_SCHEMA),
1234
+ this.buildActionEntry("/.actions/generateVideo", "generateVideo", "Generate video from a text prompt", ROOT_GENERATE_VIDEO_SCHEMA),
1235
+ this.buildActionEntry("/.actions/setDefaultModel", "setDefaultModel", "Set the default model for a given type", SET_DEFAULT_MODEL_SCHEMA),
1236
+ this.buildActionEntry("/.actions/refresh", "refresh", "Clear model catalog cache and reload on next access", {
1237
+ type: "object",
1238
+ properties: {}
1239
+ })
1240
+ ] };
1241
+ }
1242
+ async execRootChat(_ctx, args) {
1243
+ const modelName = args.model;
1244
+ if (!modelName) return missingParam("model");
1245
+ await this.findModelOfType(modelName, "chat");
1246
+ return this.runChat(modelName, args);
1247
+ }
1248
+ async execRootGenerateImage(_ctx, args) {
1249
+ const modelName = args.model;
1250
+ if (!modelName) return missingParam("model");
1251
+ await this.findModelOfType(modelName, "image");
1252
+ return this.runImage(modelName, args);
1253
+ }
1254
+ async execRootGenerateVideo(_ctx, args) {
1255
+ const modelName = args.model;
1256
+ if (!modelName) return missingParam("model");
1257
+ await this.findModelOfType(modelName, "video");
1258
+ return this.runVideo(modelName, args);
1259
+ }
1260
+ async execRootSetDefaultModel(_ctx, args) {
1261
+ const typeName = args.type;
1262
+ const modelName = args.model;
1263
+ if (!typeName) return missingParam("type");
1264
+ if (!modelName) return missingParam("model");
1265
+ const type = this.validateType(typeName);
1266
+ const model = await this.findModelOfType(modelName, type);
1267
+ return await this.setDefault(model);
1268
+ }
1269
+ async execRefresh(_ctx, _args) {
1270
+ this.catalog = null;
1271
+ return {
1272
+ success: true,
1273
+ data: { message: "Model catalog cache cleared" }
1274
+ };
1275
+ }
1276
+ async setDefault(model) {
1277
+ const type = model.type;
1278
+ this.runtimeDefaults[type] = model.model;
1279
+ if (this.updateConfigFn && this.mountPath) {
1280
+ const key = type === "chat" ? "defaultChat" : type === "image" ? "defaultImage" : "defaultVideo";
1281
+ await this.updateConfigFn(this.mountPath, { [key]: model.model });
1282
+ }
1283
+ return {
1284
+ success: true,
1285
+ data: {
1286
+ message: `Default ${type} model set to ${model.model}`,
1287
+ type,
1288
+ model: model.model,
1289
+ provider: model.provider
1290
+ }
1291
+ };
1292
+ }
1293
+ buildActionsListExplain(basePath, actions) {
1294
+ return {
1295
+ content: [
1296
+ `# Actions for ${basePath || "/"}`,
1297
+ "",
1298
+ "Available actions:",
1299
+ "",
1300
+ ...actions.map((a) => `- **${a.name}** — ${a.description}`),
1301
+ "",
1302
+ `Use \`explain ${basePath}/.actions/<name>\` for input schema and usage.`
1303
+ ].join("\n"),
1304
+ format: "markdown"
1305
+ };
1306
+ }
1307
+ buildActionExplain(basePath, actionName, actions) {
1308
+ const action = actions.find((a) => a.name === actionName);
1309
+ if (!action) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)(basePath, ".actions", actionName));
1310
+ return {
1311
+ content: [
1312
+ `# ${action.name}`,
1313
+ "",
1314
+ action.description,
1315
+ "",
1316
+ "## Input Schema",
1317
+ "",
1318
+ "```json",
1319
+ JSON.stringify(action.schema, null, 2),
1320
+ "```",
1321
+ "",
1322
+ "## Example",
1323
+ "",
1324
+ `\`exec ${basePath}/.actions/${action.name} ${JSON.stringify(Object.fromEntries((Array.isArray(action.schema.required) ? action.schema.required : []).map((k) => [k, `<${k}>`])))}\``
1325
+ ].join("\n"),
1326
+ format: "markdown"
1327
+ };
1328
+ }
1329
+ async explainRootActionsList(_ctx) {
1330
+ return this.buildActionsListExplain("", ROOT_ACTIONS);
1331
+ }
1332
+ async explainRootAction(ctx) {
1333
+ return this.buildActionExplain("", ctx.params.action, ROOT_ACTIONS);
1334
+ }
1335
+ async explainDefaultActionsList(ctx) {
1336
+ const type = this.validateType(ctx.params.type);
1337
+ return this.buildActionsListExplain((0, ufo.joinURL)("/defaults", type), getActionsForType(type));
1338
+ }
1339
+ async explainDefaultAction(ctx) {
1340
+ const type = this.validateType(ctx.params.type);
1341
+ return this.buildActionExplain((0, ufo.joinURL)("/defaults", type), ctx.params.action, getActionsForType(type));
1342
+ }
1343
+ async explainProviderModelActionsList(ctx) {
1344
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
1345
+ return this.buildActionsListExplain((0, ufo.joinURL)("/providers", ctx.params.provider, ctx.params.model), getActionsForType(model.type));
1346
+ }
1347
+ async explainProviderModelAction(ctx) {
1348
+ const model = await this.findModelByPath(ctx.params.provider, ctx.params.model);
1349
+ return this.buildActionExplain((0, ufo.joinURL)("/providers", ctx.params.provider, ctx.params.model), ctx.params.action, getActionsForType(model.type));
1350
+ }
1351
+ async explainTypeModelActionsList(ctx) {
1352
+ const type = this.validateType(ctx.params.type);
1353
+ return this.buildActionsListExplain((0, ufo.joinURL)("/types", type, ctx.params.model), getActionsForType(type));
1354
+ }
1355
+ async explainTypeModelAction(ctx) {
1356
+ const type = this.validateType(ctx.params.type);
1357
+ return this.buildActionExplain((0, ufo.joinURL)("/types", type, ctx.params.model), ctx.params.action, getActionsForType(type));
1358
+ }
1359
+ buildActionEntry(path, name, description, inputSchema) {
1360
+ return this.buildEntry(path, {
1361
+ id: name,
1362
+ content: {
1363
+ name,
1364
+ description,
1365
+ inputSchema
1366
+ },
1367
+ meta: {
1368
+ name,
1369
+ kind: "afs:executable",
1370
+ description,
1371
+ inputSchema
1372
+ }
1373
+ });
1374
+ }
1375
+ buildModelEntry(path, model) {
1376
+ return this.buildEntry(path, {
1377
+ content: {
1378
+ model: model.model,
1379
+ provider: model.provider,
1380
+ providerDisplayName: model.providerDisplayName,
1381
+ type: model.type,
1382
+ inputCreditsPerToken: model.inputCreditsPerToken,
1383
+ outputCreditsPerToken: model.outputCreditsPerToken,
1384
+ available: model.status?.available ?? true
1385
+ },
1386
+ meta: {
1387
+ childrenCount: 0,
1388
+ kind: `aignehub:${model.type}-model`,
1389
+ type: model.type
1390
+ }
1391
+ });
1392
+ }
1393
+ buildModelExplain(modelPath, model) {
1394
+ const actions = getActionsForType(model.type);
1395
+ const action = actions[0];
1396
+ const actionNames = actions.map((a) => a.name).join(", ");
1397
+ const lines = [
1398
+ `# ${model.model}`,
1399
+ "",
1400
+ `- **Type**: ${model.type}`,
1401
+ `- **Provider**: ${model.providerDisplayName} (${model.provider})`,
1402
+ `- **Input Credits**: ${model.inputCreditsPerToken} per token`,
1403
+ `- **Output Credits**: ${model.outputCreditsPerToken} per token`,
1404
+ `- **Available**: ${model.status?.available ?? true ? "Yes" : "No"}`,
1405
+ `- **Actions**: ${actionNames}`,
1406
+ "",
1407
+ "## Example",
1408
+ "",
1409
+ `\`exec ${modelPath}/.actions/${action.name} { "prompt": "..." }\``
1410
+ ];
1411
+ for (const a of actions) lines.push("", `## ${a.name} Input Schema`, "", "```json", JSON.stringify(a.schema, null, 2), "```");
1412
+ lines.push("", "## Navigation", "", `- Same type: \`list /types/${model.type}\``, `- Same provider: \`list /providers/${model.provider}\``);
1413
+ return {
1414
+ content: lines.join("\n"),
1415
+ format: "markdown"
1416
+ };
1417
+ }
1418
+ async runChat(modelName, args) {
1419
+ const input = buildChatSDKInput(args);
1420
+ if (!input.messages) return {
1421
+ success: false,
1422
+ error: {
1423
+ code: "MISSING_PARAM",
1424
+ message: "Either 'messages' or 'prompt' is required for chat"
1425
+ }
1426
+ };
1427
+ try {
1428
+ const output = await new _aigne_aigne_hub.AIGNEHubChatModel({
1429
+ baseURL: this.baseURL,
1430
+ apiKey: this.apiKey,
1431
+ model: modelName
1432
+ }).invoke(input);
1433
+ const usage = output.usage;
1434
+ const data = { model: modelName };
1435
+ if (output.text !== void 0 && output.text !== "") data.text = output.text;
1436
+ if (output.json !== void 0) data.json = output.json;
1437
+ if (output.toolCalls !== void 0) data.toolCalls = output.toolCalls;
1438
+ if (output.thoughts !== void 0) data.thoughts = output.thoughts;
1439
+ if (output.files !== void 0) data.files = output.files;
1440
+ if (usage) {
1441
+ data.inputTokens = usage.inputTokens;
1442
+ data.outputTokens = usage.outputTokens;
1443
+ }
1444
+ return {
1445
+ success: true,
1446
+ data
1447
+ };
1448
+ } catch (err) {
1449
+ return inferenceError(modelName, err);
1450
+ }
1451
+ }
1452
+ async runImage(modelName, args) {
1453
+ const prompt = args.prompt;
1454
+ if (prompt === void 0 || prompt === null) return missingParam("prompt");
1455
+ try {
1456
+ const baseOptions = {
1457
+ baseURL: this.baseURL,
1458
+ apiKey: this.apiKey,
1459
+ model: modelName
1460
+ };
1461
+ const modelOptions = {};
1462
+ if (args.size !== void 0) modelOptions.size = args.size;
1463
+ if (args.quality !== void 0) modelOptions.quality = args.quality;
1464
+ if (args.style !== void 0) modelOptions.style = args.style;
1465
+ const input = { prompt: String(prompt) };
1466
+ if (args.n !== void 0) input.n = args.n;
1467
+ input.outputFileType = args.outputFileType ?? "url";
1468
+ if (Object.keys(modelOptions).length > 0) input.modelOptions = modelOptions;
1469
+ const output = await new _aigne_aigne_hub.AIGNEHubImageModel(baseOptions).invoke(input);
1470
+ const data = {
1471
+ images: output.images ?? [],
1472
+ model: modelName
1473
+ };
1474
+ if (output.usage) data.usage = output.usage;
1475
+ return {
1476
+ success: true,
1477
+ data
1478
+ };
1479
+ } catch (err) {
1480
+ return inferenceError(modelName, err);
1481
+ }
1482
+ }
1483
+ async runVideo(modelName, args) {
1484
+ const prompt = args.prompt;
1485
+ if (prompt === void 0 || prompt === null) return missingParam("prompt");
1486
+ try {
1487
+ const baseOptions = {
1488
+ baseURL: this.baseURL,
1489
+ apiKey: this.apiKey,
1490
+ model: modelName
1491
+ };
1492
+ const input = { prompt: String(prompt) };
1493
+ if (args.size !== void 0) input.size = args.size;
1494
+ if (args.seconds !== void 0) input.seconds = args.seconds;
1495
+ input.outputFileType = args.outputFileType ?? "url";
1496
+ const output = await new _aigne_aigne_hub.AIGNEHubVideoModel(baseOptions).invoke(input);
1497
+ const data = {
1498
+ videos: output.videos ?? [],
1499
+ model: modelName
1500
+ };
1501
+ if (output.seconds !== void 0) data.seconds = output.seconds;
1502
+ if (output.usage) data.usage = output.usage;
1503
+ return {
1504
+ success: true,
1505
+ data
1506
+ };
1507
+ } catch (err) {
1508
+ return inferenceError(modelName, err);
1509
+ }
1510
+ }
1511
+ /** Find model by provider + path segment across all types */
1512
+ async findModelByPath(provider, segment) {
1513
+ const catalog = await this.ensureCatalog();
1514
+ for (const type of MODEL_TYPES) {
1515
+ const model = catalog[type].find((m) => m.provider === provider && modelPathSegment(m) === segment);
1516
+ if (model) return model;
1517
+ }
1518
+ const providerModels = this.getModelsForProvider(catalog, provider);
1519
+ if (providerModels.length === 0) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", provider, segment), `Provider '${provider}' not found.`);
1520
+ const available = providerModels.map((m) => modelPathSegment(m));
1521
+ throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", provider, segment), `Model '${segment}' not found under provider '${provider}'. Available: ${available.slice(0, 8).join(", ")}${available.length > 8 ? "..." : ""}`);
1522
+ }
1523
+ /** Find model by provider + path segment in a specific type catalog */
1524
+ async findModelOfTypeByPath(provider, segment, type) {
1525
+ const catalog = await this.ensureCatalog();
1526
+ const model = catalog[type].find((m) => m.provider === provider && modelPathSegment(m) === segment);
1527
+ if (model) return model;
1528
+ for (const otherType of MODEL_TYPES) {
1529
+ if (otherType === type) continue;
1530
+ if (catalog[otherType].find((m) => m.provider === provider && modelPathSegment(m) === segment)) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", provider, segment), `Model '${segment}' (${provider}) is not a ${type} model. It is listed under ${otherType} models.`);
1531
+ }
1532
+ throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/providers", provider, segment), `Model '${segment}' not found in ${type} models for provider '${provider}'.`);
1533
+ }
1534
+ /** Find model by type + path segment (for /types/:type/:model) */
1535
+ async findModelByTypeAndSegment(type, segment) {
1536
+ const catalog = await this.ensureCatalog();
1537
+ const model = catalog[type].find((m) => modelPathSegment(m) === segment);
1538
+ if (model) return model;
1539
+ for (const otherType of MODEL_TYPES) {
1540
+ if (otherType === type) continue;
1541
+ if (catalog[otherType].find((m) => modelPathSegment(m) === segment)) throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/types", type, segment), `Model '${segment}' is not a ${type} model. It is listed under ${otherType} models.`);
1542
+ }
1543
+ const available = catalog[type].map((m) => modelPathSegment(m));
1544
+ throw new _aigne_afs.AFSNotFoundError((0, ufo.joinURL)("/types", type, segment), `Model '${segment}' not found in ${type} models. Available: ${available.slice(0, 8).join(", ")}${available.length > 8 ? "..." : ""}`);
1545
+ }
1546
+ /** Find model by full model name in a specific type catalog (for root exec) */
1547
+ async findModelOfType(modelName, type) {
1548
+ const catalog = await this.ensureCatalog();
1549
+ const model = catalog[type].find((m) => m.model === modelName);
1550
+ if (model) return model;
1551
+ for (const otherType of MODEL_TYPES) {
1552
+ if (otherType === type) continue;
1553
+ if (catalog[otherType].find((m) => m.model === modelName)) throw new _aigne_afs.AFSNotFoundError(modelName, `Model '${modelName}' is not a ${type} model. It is listed under ${otherType} models.`);
1554
+ }
1555
+ const available = catalog[type].map((m) => m.model);
1556
+ throw new _aigne_afs.AFSNotFoundError(modelName, `Model '${modelName}' not found in ${type} models. Available: ${available.slice(0, 8).join(", ")}${available.length > 8 ? "..." : ""}`);
1557
+ }
1558
+ };
1559
+ require_decorate.__decorate([(0, _aigne_afs.List)("/")], AFSAigneHub.prototype, "listRoot", null);
1560
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/")], AFSAigneHub.prototype, "readRoot", null);
1561
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/")], AFSAigneHub.prototype, "rootMeta", null);
1562
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/.meta/.capabilities")], AFSAigneHub.prototype, "readCapabilities", null);
1563
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/")], AFSAigneHub.prototype, "explainRoot", null);
1564
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/")], AFSAigneHub.prototype, "statRoot", null);
1565
+ require_decorate.__decorate([(0, _aigne_afs.List)("/defaults")], AFSAigneHub.prototype, "listDefaults", null);
1566
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/defaults")], AFSAigneHub.prototype, "readDefaults", null);
1567
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/defaults")], AFSAigneHub.prototype, "defaultsMeta", null);
1568
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/defaults")], AFSAigneHub.prototype, "statDefaults", null);
1569
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/defaults")], AFSAigneHub.prototype, "explainDefaults", null);
1570
+ require_decorate.__decorate([(0, _aigne_afs.List)("/defaults/:type")], AFSAigneHub.prototype, "listDefault", null);
1571
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/defaults/:type")], AFSAigneHub.prototype, "readDefault", null);
1572
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/defaults/:type")], AFSAigneHub.prototype, "statDefault", null);
1573
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/defaults/:type")], AFSAigneHub.prototype, "defaultTypeMeta", null);
1574
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/defaults/:type")], AFSAigneHub.prototype, "explainDefault", null);
1575
+ require_decorate.__decorate([(0, _aigne_afs.Actions)("/defaults/:type")], AFSAigneHub.prototype, "listDefaultActions", null);
1576
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/defaults/:type", "chat")], AFSAigneHub.prototype, "execDefaultChat", null);
1577
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/defaults/:type", "generateImage")], AFSAigneHub.prototype, "execDefaultGenerateImage", null);
1578
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/defaults/:type", "generateVideo")], AFSAigneHub.prototype, "execDefaultGenerateVideo", null);
1579
+ require_decorate.__decorate([(0, _aigne_afs.List)("/providers")], AFSAigneHub.prototype, "listProviders", null);
1580
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/providers")], AFSAigneHub.prototype, "readProviders", null);
1581
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/providers")], AFSAigneHub.prototype, "providersMeta", null);
1582
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/providers")], AFSAigneHub.prototype, "statProviders", null);
1583
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/providers")], AFSAigneHub.prototype, "explainProviders", null);
1584
+ require_decorate.__decorate([(0, _aigne_afs.List)("/providers/:provider")], AFSAigneHub.prototype, "listProvider", null);
1585
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/providers/:provider")], AFSAigneHub.prototype, "readProvider", null);
1586
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/providers/:provider")], AFSAigneHub.prototype, "providerMeta", null);
1587
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/providers/:provider")], AFSAigneHub.prototype, "statProvider", null);
1588
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/providers/:provider")], AFSAigneHub.prototype, "explainProvider", null);
1589
+ require_decorate.__decorate([(0, _aigne_afs.List)("/providers/:provider/:model")], AFSAigneHub.prototype, "listProviderModel", null);
1590
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/providers/:provider/:model")], AFSAigneHub.prototype, "readProviderModel", null);
1591
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/providers/:provider/:model")], AFSAigneHub.prototype, "providerModelMeta", null);
1592
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/providers/:provider/:model")], AFSAigneHub.prototype, "statProviderModel", null);
1593
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/providers/:provider/:model")], AFSAigneHub.prototype, "explainProviderModel", null);
1594
+ require_decorate.__decorate([(0, _aigne_afs.Actions)("/providers/:provider/:model")], AFSAigneHub.prototype, "listProviderModelActions", null);
1595
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/providers/:provider/:model", "chat")], AFSAigneHub.prototype, "execProviderChat", null);
1596
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/providers/:provider/:model", "generateImage")], AFSAigneHub.prototype, "execProviderGenerateImage", null);
1597
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/providers/:provider/:model", "generateVideo")], AFSAigneHub.prototype, "execProviderGenerateVideo", null);
1598
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/providers/:provider/:model", "setDefault")], AFSAigneHub.prototype, "execProviderSetDefault", null);
1599
+ require_decorate.__decorate([(0, _aigne_afs.List)("/types")], AFSAigneHub.prototype, "listTypes", null);
1600
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/types")], AFSAigneHub.prototype, "readTypes", null);
1601
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/types")], AFSAigneHub.prototype, "typesMeta", null);
1602
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/types")], AFSAigneHub.prototype, "statTypes", null);
1603
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/types")], AFSAigneHub.prototype, "explainTypes", null);
1604
+ require_decorate.__decorate([(0, _aigne_afs.List)("/types/:type")], AFSAigneHub.prototype, "listType", null);
1605
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/types/:type")], AFSAigneHub.prototype, "readType", null);
1606
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/types/:type")], AFSAigneHub.prototype, "typeMeta", null);
1607
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/types/:type")], AFSAigneHub.prototype, "statType", null);
1608
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/types/:type")], AFSAigneHub.prototype, "explainType", null);
1609
+ require_decorate.__decorate([(0, _aigne_afs.List)("/types/:type/:model")], AFSAigneHub.prototype, "listTypeModel", null);
1610
+ require_decorate.__decorate([(0, _aigne_afs.Read)("/types/:type/:model")], AFSAigneHub.prototype, "readTypeModel", null);
1611
+ require_decorate.__decorate([(0, _aigne_afs.Stat)("/types/:type/:model")], AFSAigneHub.prototype, "statTypeModel", null);
1612
+ require_decorate.__decorate([(0, _aigne_afs.Meta)("/types/:type/:model")], AFSAigneHub.prototype, "typeModelMeta", null);
1613
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/types/:type/:model")], AFSAigneHub.prototype, "explainTypeModel", null);
1614
+ require_decorate.__decorate([(0, _aigne_afs.Actions)("/types/:type/:model")], AFSAigneHub.prototype, "listTypeModelActions", null);
1615
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/types/:type/:model", "chat")], AFSAigneHub.prototype, "execTypeChat", null);
1616
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/types/:type/:model", "generateImage")], AFSAigneHub.prototype, "execTypeGenerateImage", null);
1617
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/types/:type/:model", "generateVideo")], AFSAigneHub.prototype, "execTypeGenerateVideo", null);
1618
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/types/:type/:model", "setDefault")], AFSAigneHub.prototype, "execTypeSetDefault", null);
1619
+ require_decorate.__decorate([(0, _aigne_afs.Actions)("/")], AFSAigneHub.prototype, "listRootActions", null);
1620
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/", "chat")], AFSAigneHub.prototype, "execRootChat", null);
1621
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/", "generateImage")], AFSAigneHub.prototype, "execRootGenerateImage", null);
1622
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/", "generateVideo")], AFSAigneHub.prototype, "execRootGenerateVideo", null);
1623
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/", "setDefaultModel")], AFSAigneHub.prototype, "execRootSetDefaultModel", null);
1624
+ require_decorate.__decorate([_aigne_afs.Actions.Exec("/", "refresh")], AFSAigneHub.prototype, "execRefresh", null);
1625
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/.actions")], AFSAigneHub.prototype, "explainRootActionsList", null);
1626
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/.actions/:action")], AFSAigneHub.prototype, "explainRootAction", null);
1627
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/defaults/:type/.actions")], AFSAigneHub.prototype, "explainDefaultActionsList", null);
1628
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/defaults/:type/.actions/:action")], AFSAigneHub.prototype, "explainDefaultAction", null);
1629
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/providers/:provider/:model/.actions")], AFSAigneHub.prototype, "explainProviderModelActionsList", null);
1630
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/providers/:provider/:model/.actions/:action")], AFSAigneHub.prototype, "explainProviderModelAction", null);
1631
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/types/:type/:model/.actions")], AFSAigneHub.prototype, "explainTypeModelActionsList", null);
1632
+ require_decorate.__decorate([(0, _aigne_afs.Explain)("/types/:type/:model/.actions/:action")], AFSAigneHub.prototype, "explainTypeModelAction", null);
1633
+
1634
+ //#endregion
1635
+ exports.AFSAigneHub = AFSAigneHub;