@aigne/aigne-hub 0.6.4 → 0.6.7

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/lib/{esm/cli-aigne-hub-model.d.ts → cjs/aigne-hub-model.d.ts} +5 -4
  3. package/lib/cjs/aigne-hub-model.js +86 -0
  4. package/lib/cjs/index.d.ts +9 -11
  5. package/lib/cjs/index.js +19 -24
  6. package/lib/cjs/utils/blocklet.d.ts +1 -0
  7. package/lib/cjs/utils/blocklet.js +14 -0
  8. package/lib/cjs/utils/constants.d.ts +3 -0
  9. package/lib/cjs/utils/constants.js +6 -0
  10. package/lib/cjs/utils/model.d.ts +16 -0
  11. package/lib/cjs/utils/model.js +103 -0
  12. package/lib/dts/{cli-aigne-hub-model.d.ts → aigne-hub-model.d.ts} +5 -4
  13. package/lib/dts/index.d.ts +9 -11
  14. package/lib/dts/utils/blocklet.d.ts +1 -0
  15. package/lib/dts/utils/constants.d.ts +3 -0
  16. package/lib/dts/utils/model.d.ts +16 -0
  17. package/lib/{cjs/cli-aigne-hub-model.d.ts → esm/aigne-hub-model.d.ts} +5 -4
  18. package/lib/esm/aigne-hub-model.js +82 -0
  19. package/lib/esm/index.d.ts +9 -11
  20. package/lib/esm/index.js +19 -24
  21. package/lib/esm/utils/blocklet.d.ts +1 -0
  22. package/lib/esm/utils/blocklet.js +11 -0
  23. package/lib/esm/utils/constants.d.ts +3 -0
  24. package/lib/esm/utils/constants.js +3 -0
  25. package/lib/esm/utils/model.d.ts +16 -0
  26. package/lib/esm/{util → utils}/model.js +8 -82
  27. package/package.json +15 -28
  28. package/lib/cjs/blocklet-aigne-hub-model.d.ts +0 -23
  29. package/lib/cjs/blocklet-aigne-hub-model.js +0 -75
  30. package/lib/cjs/cli-aigne-hub-model.js +0 -65
  31. package/lib/cjs/util/constants.d.ts +0 -14
  32. package/lib/cjs/util/constants.js +0 -30
  33. package/lib/cjs/util/credential.d.ts +0 -24
  34. package/lib/cjs/util/credential.js +0 -226
  35. package/lib/cjs/util/crypto.d.ts +0 -4
  36. package/lib/cjs/util/crypto.js +0 -16
  37. package/lib/cjs/util/model.d.ts +0 -12
  38. package/lib/cjs/util/model.js +0 -185
  39. package/lib/cjs/util/type.d.ts +0 -58
  40. package/lib/cjs/util/type.js +0 -2
  41. package/lib/dts/blocklet-aigne-hub-model.d.ts +0 -23
  42. package/lib/dts/util/constants.d.ts +0 -14
  43. package/lib/dts/util/credential.d.ts +0 -24
  44. package/lib/dts/util/crypto.d.ts +0 -4
  45. package/lib/dts/util/model.d.ts +0 -12
  46. package/lib/dts/util/type.d.ts +0 -58
  47. package/lib/esm/blocklet-aigne-hub-model.d.ts +0 -23
  48. package/lib/esm/blocklet-aigne-hub-model.js +0 -71
  49. package/lib/esm/cli-aigne-hub-model.js +0 -61
  50. package/lib/esm/util/constants.d.ts +0 -14
  51. package/lib/esm/util/constants.js +0 -15
  52. package/lib/esm/util/credential.d.ts +0 -24
  53. package/lib/esm/util/credential.js +0 -214
  54. package/lib/esm/util/crypto.d.ts +0 -4
  55. package/lib/esm/util/crypto.js +0 -9
  56. package/lib/esm/util/model.d.ts +0 -12
  57. package/lib/esm/util/type.d.ts +0 -58
  58. package/lib/esm/util/type.js +0 -1
package/lib/esm/index.js CHANGED
@@ -1,35 +1,30 @@
1
1
  import { ChatModel, } from "@aigne/core";
2
- import { AIGNEHubChatModel as BlockletAIGNEHubChatModel } from "./blocklet-aigne-hub-model.js";
3
- import { AIGNEHubChatModel as CliAIGNEHubChatModel, } from "./cli-aigne-hub-model.js";
4
- import { AIGNE_HUB_URL } from "./util/constants.js";
5
- import { getAIGNEHubMountPoint } from "./util/credential.js";
6
- export * from "./util/constants.js";
7
- export * from "./util/credential.js";
8
- export * from "./util/crypto.js";
9
- export * from "./util/model.js";
10
- export * from "./util/type.js";
2
+ import { findModel } from "./utils/model.js";
3
+ export * from "./utils/blocklet.js";
4
+ export * from "./utils/constants.js";
5
+ export * from "./utils/model.js";
11
6
  export class AIGNEHubChatModel extends ChatModel {
12
7
  options;
13
- client;
14
8
  static async load(options) {
15
- const u = process.env.BLOCKLET_AIGNE_API_URL ?? process.env.AIGNE_HUB_API_URL ?? AIGNE_HUB_URL;
16
- let url = options.url ?? u;
17
- if ((process.env.BLOCKLET_AIGNE_API_PROVIDER || "").toLocaleLowerCase().includes("aignehub")) {
18
- url = await getAIGNEHubMountPoint(url);
19
- }
20
- return new AIGNEHubChatModel({ ...options, url });
9
+ return new AIGNEHubChatModel(options);
21
10
  }
22
11
  constructor(options) {
23
- super();
12
+ const provider = process.env.BLOCKLET_AIGNE_API_PROVIDER || AIGNEHubChatModel.name;
13
+ const { match, all } = findModel(provider);
14
+ if (!match) {
15
+ const available = all.map((m) => m.name).join(", ");
16
+ throw new Error(`Unsupported model provider: ${provider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
17
+ }
18
+ const client = match.create(options);
19
+ super({ name: client.name });
24
20
  this.options = options;
25
- const isBlocklet = process.env.BLOCKLET_AIGNE_API_URL && process.env.BLOCKLET_AIGNE_API_PROVIDER;
26
- const AIGNEHubModel = isBlocklet ? BlockletAIGNEHubChatModel : CliAIGNEHubChatModel;
27
- this.client = new AIGNEHubModel(options);
21
+ this.client = client;
28
22
  }
29
- getCredential() {
30
- return this.client.getCredential();
23
+ client;
24
+ get credential() {
25
+ return this.client.credential;
31
26
  }
32
- process(input, options) {
33
- return this.client.process(input, options);
27
+ async process(input, options) {
28
+ return this.client.invoke(input, options);
34
29
  }
35
30
  }
@@ -0,0 +1 @@
1
+ export declare function getAIGNEHubMountPoint(url: string, component: string): Promise<string>;
@@ -0,0 +1,11 @@
1
+ import { joinURL } from "ufo";
2
+ export async function getAIGNEHubMountPoint(url, component) {
3
+ const { origin } = new URL(url);
4
+ const BLOCKLET_JSON_PATH = "__blocklet__.js?type=json";
5
+ const blockletInfo = await fetch(joinURL(origin, BLOCKLET_JSON_PATH));
6
+ const blocklet = await blockletInfo.json();
7
+ const comp = (blocklet?.componentMountPoints || []).find((m) => m.did === component);
8
+ if (!comp)
9
+ throw new Error(`Component ${component} not found in blocklet ${url}`);
10
+ return joinURL(origin, comp.mountPoint);
11
+ }
@@ -0,0 +1,3 @@
1
+ export declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
+ export declare const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
+ export declare const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
@@ -0,0 +1,3 @@
1
+ export const AIGNE_HUB_URL = "https://hub.aigne.io/";
2
+ export const AIGNE_HUB_BLOCKLET_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
3
+ export const AIGNE_HUB_DEFAULT_MODEL = "openai/gpt-5-mini";
@@ -0,0 +1,16 @@
1
+ import type { ChatModel, ChatModelOptions } from "@aigne/core";
2
+ export interface LoadableModel {
3
+ name: string | string[];
4
+ apiKeyEnvName?: string | string[];
5
+ create: (options: {
6
+ model?: string;
7
+ modelOptions?: ChatModelOptions;
8
+ apiKey?: string;
9
+ url?: string;
10
+ }) => ChatModel;
11
+ }
12
+ export declare function availableModels(): LoadableModel[];
13
+ export declare function findModel(provider: string): {
14
+ all: LoadableModel[];
15
+ match: LoadableModel | undefined;
16
+ };
@@ -6,16 +6,11 @@ import { GeminiChatModel } from "@aigne/gemini";
6
6
  import { OllamaChatModel } from "@aigne/ollama";
7
7
  import { OpenRouterChatModel } from "@aigne/open-router";
8
8
  import { OpenAIChatModel } from "@aigne/openai";
9
- import { nodejs } from "@aigne/platform-helpers/nodejs/index.js";
10
9
  import { PoeChatModel } from "@aigne/poe";
11
10
  import { XAIChatModel } from "@aigne/xai";
12
11
  import { NodeHttpHandler, streamCollector } from "@smithy/node-http-handler";
13
- import chalk from "chalk";
14
12
  import { HttpsProxyAgent } from "https-proxy-agent";
15
- import { AIGNEHubChatModel } from "../cli-aigne-hub-model.js";
16
- import { AGENT_HUB_PROVIDER, DEFAULT_AIGNE_HUB_PROVIDER_MODEL, DEFAULT_MODEL_PROVIDER, } from "./constants.js";
17
- import { loadCredential } from "./credential.js";
18
- const { MODEL_PROVIDER, MODEL_NAME } = nodejs.env;
13
+ import { AIGNEHubChatModel } from "../aigne-hub-model.js";
19
14
  export function availableModels() {
20
15
  const proxy = ["HTTPS_PROXY", "https_proxy", "HTTP_PROXY", "http_proxy", "ALL_PROXY", "all_proxy"]
21
16
  .map((i) => process.env[i])
@@ -91,83 +86,14 @@ export function availableModels() {
91
86
  },
92
87
  ];
93
88
  }
94
- export function findModel(models, provider) {
95
- return models.find((m) => {
89
+ export function findModel(provider) {
90
+ provider = provider.toLowerCase().replace(/-/g, "");
91
+ const all = availableModels();
92
+ const match = all.find((m) => {
96
93
  if (typeof m.name === "string") {
97
- return m.name.toLowerCase().includes(provider.toLowerCase());
94
+ return m.name.toLowerCase().includes(provider);
98
95
  }
99
- return m.name.some((n) => n.toLowerCase().includes(provider.toLowerCase()));
100
- });
101
- }
102
- export const parseModelOption = (model) => {
103
- const { provider, name } = (model || process.env.MODEL)?.match(/(?<provider>[^:]*)(:(?<name>(\S+)))?/)?.groups ?? {};
104
- return { provider, name };
105
- };
106
- export const formatModelName = async (model, inquirerPrompt) => {
107
- const models = availableModels();
108
- if (!model)
109
- return DEFAULT_AIGNE_HUB_PROVIDER_MODEL;
110
- const { provider, name } = parseModelOption(model);
111
- if (!provider) {
112
- return DEFAULT_AIGNE_HUB_PROVIDER_MODEL;
113
- }
114
- const providerName = provider.replace(/-/g, "");
115
- if (providerName.includes(AGENT_HUB_PROVIDER)) {
116
- return model;
117
- }
118
- const m = findModel(models, providerName);
119
- if (!m)
120
- throw new Error(`Unsupported model: ${provider} ${name}`);
121
- const apiKeyEnvName = Array.isArray(m.apiKeyEnvName) ? m.apiKeyEnvName : [m.apiKeyEnvName];
122
- if (apiKeyEnvName.some((name) => name && process.env[name])) {
123
- return model;
124
- }
125
- const result = await inquirerPrompt({
126
- type: "list",
127
- name: "useAigneHub",
128
- message: `Seems no API Key configured for ${provider}/${name}, select your preferred way to continue:`,
129
- choices: [
130
- {
131
- name: `Connect to AIGNE Hub to use ${name} (Recommended since free credits available)`,
132
- value: true,
133
- },
134
- {
135
- name: `Exit and bring my owner API Key by set ${apiKeyEnvName.join(", ")}`,
136
- value: false,
137
- },
138
- ],
139
- default: true,
140
- });
141
- if (!result.useAigneHub) {
142
- console.log(chalk.yellow(`You can use command "export ${apiKeyEnvName[0]}=xxx" to set API Key in your shell. Or you can set environment variables in .env file.`));
143
- process.exit(0);
144
- }
145
- return `${AGENT_HUB_PROVIDER}:${provider}/${name}`;
146
- };
147
- export function maskApiKey(apiKey) {
148
- if (!apiKey || apiKey.length <= 8)
149
- return apiKey;
150
- const start = apiKey.slice(0, 4);
151
- const end = apiKey.slice(-4);
152
- return `${start}${"*".repeat(8)}${end}`;
153
- }
154
- export async function loadModel(model, modelOptions, options) {
155
- const params = {
156
- model: MODEL_NAME ?? model?.name ?? undefined,
157
- temperature: model?.temperature ?? undefined,
158
- topP: model?.topP ?? undefined,
159
- frequencyPenalty: model?.frequencyPenalty ?? undefined,
160
- presencePenalty: model?.presencePenalty ?? undefined,
161
- };
162
- const provider = (MODEL_PROVIDER ?? model?.provider ?? DEFAULT_MODEL_PROVIDER).replace(/-/g, "");
163
- const models = availableModels();
164
- const m = findModel(models, provider);
165
- if (!m)
166
- throw new Error(`Unsupported model: ${model?.provider} ${model?.name}`);
167
- const credential = await loadCredential({ ...options, model: `${provider}:${params.model}` });
168
- return m.create({
169
- ...(credential || {}),
170
- model: params.model,
171
- modelOptions: { ...params, ...modelOptions },
96
+ return m.name.some((n) => n.toLowerCase().includes(provider));
172
97
  });
98
+ return { all, match };
173
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/aigne-hub",
3
- "version": "0.6.4",
3
+ "version": "0.6.7",
4
4
  "description": "AIGNE Hub SDK for integrating with Hub AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -32,39 +32,26 @@
32
32
  "import": "./lib/esm/index.js",
33
33
  "require": "./lib/cjs/index.js",
34
34
  "types": "./lib/dts/index.d.ts"
35
- },
36
- "./constants": {
37
- "import": "./lib/esm/constants.js",
38
- "require": "./lib/cjs/constants.js",
39
- "types": "./lib/dts/constants.d.ts"
40
35
  }
41
36
  },
42
37
  "dependencies": {
43
- "@ocap/mcrypto": "^1.21.0",
44
38
  "@smithy/node-http-handler": "^4.1.0",
45
- "chalk": "^5.4.1",
46
39
  "https-proxy-agent": "^7.0.6",
47
- "inquirer": "^12.7.0",
48
- "open": "^10.2.0",
49
- "openai": "^5.8.3",
50
- "p-wait-for": "^5.0.2",
51
40
  "ufo": "^1.6.1",
52
- "yaml": "^2.8.0",
53
41
  "zod": "^3.25.67",
54
- "@aigne/anthropic": "^0.11.4",
55
- "@aigne/core": "^1.51.0",
56
- "@aigne/deepseek": "^0.7.22",
57
- "@aigne/bedrock": "^0.9.4",
58
- "@aigne/default-memory": "^1.1.4",
59
- "@aigne/doubao": "^1.0.16",
60
- "@aigne/ollama": "^0.7.22",
61
- "@aigne/open-router": "^0.7.22",
62
- "@aigne/gemini": "^0.9.4",
42
+ "@aigne/anthropic": "^0.11.7",
43
+ "@aigne/core": "^1.54.0",
44
+ "@aigne/deepseek": "^0.7.25",
45
+ "@aigne/bedrock": "^0.9.7",
46
+ "@aigne/ollama": "^0.7.25",
47
+ "@aigne/open-router": "^0.7.25",
48
+ "@aigne/openai": "^0.12.1",
49
+ "@aigne/poe": "^1.0.5",
50
+ "@aigne/transport": "^0.14.5",
63
51
  "@aigne/platform-helpers": "^0.6.2",
64
- "@aigne/poe": "^1.0.2",
65
- "@aigne/openai": "^0.11.4",
66
- "@aigne/transport": "^0.14.2",
67
- "@aigne/xai": "^0.7.22"
52
+ "@aigne/xai": "^0.7.25",
53
+ "@aigne/doubao": "^1.0.19",
54
+ "@aigne/gemini": "^0.9.7"
68
55
  },
69
56
  "devDependencies": {
70
57
  "@types/bun": "^1.2.18",
@@ -73,8 +60,8 @@
73
60
  "npm-run-all": "^4.1.5",
74
61
  "rimraf": "^6.0.1",
75
62
  "typescript": "^5.8.3",
76
- "@aigne/openai": "^0.11.4",
77
- "@aigne/test-utils": "^0.5.30"
63
+ "@aigne/openai": "^0.12.1",
64
+ "@aigne/test-utils": "^0.5.33"
78
65
  },
79
66
  "scripts": {
80
67
  "lint": "tsc --noEmit",
@@ -1,23 +0,0 @@
1
- import { type AgentProcessResult, ChatModel, type ChatModelInput, type ChatModelOutput } from "@aigne/core";
2
- import type { BaseClientInvokeOptions } from "@aigne/transport/http-client/base-client.js";
3
- import type { AIGNEHubChatModelOptions } from "./cli-aigne-hub-model.js";
4
- export declare class AIGNEHubChatModel extends ChatModel {
5
- options: AIGNEHubChatModelOptions & {
6
- apiKey?: string;
7
- baseURL?: string;
8
- url?: string;
9
- };
10
- protected _client?: Promise<ChatModel>;
11
- constructor(options: AIGNEHubChatModelOptions & {
12
- apiKey?: string;
13
- baseURL?: string;
14
- url?: string;
15
- });
16
- client(): Promise<ChatModel>;
17
- getCredential(): Promise<{
18
- url: string;
19
- apiKey: any;
20
- model: string | undefined;
21
- }>;
22
- process(input: ChatModelInput, options: BaseClientInvokeOptions): Promise<AgentProcessResult<ChatModelOutput>>;
23
- }
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AIGNEHubChatModel = void 0;
4
- const core_1 = require("@aigne/core");
5
- const constants_js_1 = require("./util/constants.js");
6
- const credential_js_1 = require("./util/credential.js");
7
- const model_js_1 = require("./util/model.js");
8
- class AIGNEHubChatModel extends core_1.ChatModel {
9
- options;
10
- _client;
11
- constructor(options) {
12
- super();
13
- this.options = options;
14
- }
15
- async client() {
16
- const models = (0, model_js_1.availableModels)();
17
- const rawProvider = process.env.BLOCKLET_AIGNE_API_PROVIDER ?? "";
18
- const providerKey = rawProvider.toLowerCase().replace(/-/g, "");
19
- const modelEntry = (0, model_js_1.findModel)(models, providerKey);
20
- if (!modelEntry) {
21
- const available = models.map((m) => m.name).join(", ");
22
- throw new Error(`Unsupported model provider: ${rawProvider} ${process.env.BLOCKLET_AIGNE_API_MODEL}. Available providers: ${available}`);
23
- }
24
- const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
25
- let credentialOptions = {};
26
- try {
27
- credentialOptions =
28
- typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
29
- }
30
- catch (err) {
31
- console.error(err);
32
- }
33
- this._client ??= this.getCredential().then((credential) => {
34
- const { apiKey, url, model } = credential;
35
- const options = {
36
- ...this.options,
37
- ...credentialOptions,
38
- modelOptions: this.options.modelOptions,
39
- model,
40
- url,
41
- apiKey,
42
- };
43
- return modelEntry.create(options);
44
- });
45
- return this._client;
46
- }
47
- async getCredential() {
48
- const rawCredential = process.env.BLOCKLET_AIGNE_API_CREDENTIAL;
49
- let credentialOptions = {};
50
- try {
51
- credentialOptions =
52
- typeof rawCredential === "string" ? JSON.parse(rawCredential) : (rawCredential ?? {});
53
- }
54
- catch (err) {
55
- console.error(err);
56
- }
57
- const url = await (0, credential_js_1.getAIGNEHubMountPoint)(this.options.url || process.env.BLOCKLET_AIGNE_API_URL || constants_js_1.AIGNE_HUB_URL);
58
- return {
59
- url,
60
- apiKey: this.options.apiKey || credentialOptions?.apiKey,
61
- model: this.options.model || process.env.BLOCKLET_AIGNE_API_MODEL,
62
- };
63
- }
64
- async process(input, options) {
65
- const { BLOCKLET_APP_PID, ABT_NODE_DID } = process.env;
66
- const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || "";
67
- options.fetchOptions = {
68
- headers: { "x-aigne-hub-client-did": clientId },
69
- ...options.fetchOptions,
70
- };
71
- const client = await this.client();
72
- return client.invoke(input, options);
73
- }
74
- }
75
- exports.AIGNEHubChatModel = AIGNEHubChatModel;
@@ -1,65 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AIGNEHubChatModel = void 0;
4
- const core_1 = require("@aigne/core");
5
- const type_utils_js_1 = require("@aigne/core/utils/type-utils.js");
6
- const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
7
- const base_client_js_1 = require("@aigne/transport/http-client/base-client.js");
8
- const ufo_1 = require("ufo");
9
- const zod_1 = require("zod");
10
- const constants_js_1 = require("./util/constants.js");
11
- const credential_js_1 = require("./util/credential.js");
12
- const aigneHubChatModelOptionsSchema = zod_1.z.object({
13
- url: zod_1.z.string().optional(),
14
- apiKey: zod_1.z.string().optional(),
15
- model: zod_1.z.string().optional(),
16
- modelOptions: zod_1.z
17
- .object({
18
- model: zod_1.z.string().optional(),
19
- temperature: zod_1.z.number().optional(),
20
- topP: zod_1.z.number().optional(),
21
- frequencyPenalty: zod_1.z.number().optional(),
22
- presencePenalty: zod_1.z.number().optional(),
23
- parallelToolCalls: zod_1.z.boolean().optional().default(true),
24
- })
25
- .optional(),
26
- clientOptions: zod_1.z.object({}).optional(),
27
- });
28
- class AIGNEHubChatModel extends core_1.ChatModel {
29
- options;
30
- _client;
31
- constructor(options) {
32
- (0, type_utils_js_1.checkArguments)("AIGNEHubChatModel", aigneHubChatModelOptionsSchema, options);
33
- super();
34
- this.options = options;
35
- }
36
- async client() {
37
- this._client ??= this.getCredential().then((credential) => {
38
- const { url, apiKey, model } = credential;
39
- const options = { ...this.options, url, apiKey, model };
40
- return new base_client_js_1.BaseClient(options);
41
- });
42
- return this._client;
43
- }
44
- async getCredential() {
45
- const url = await (0, credential_js_1.getAIGNEHubMountPoint)(this.options.url || process.env.AIGNE_HUB_API_URL || constants_js_1.AIGNE_HUB_URL);
46
- const path = "/api/v2/chat";
47
- return {
48
- url: url.endsWith(path) ? url : (0, ufo_1.joinURL)(url, path),
49
- apiKey: this.options.apiKey || process.env.AIGNE_HUB_API_KEY,
50
- model: this.options.model || constants_js_1.DEFAULT_AIGNE_HUB_MODEL,
51
- };
52
- }
53
- async process(input, options) {
54
- const { BLOCKLET_APP_PID, ABT_NODE_DID } = process.env;
55
- const localClientId = `@aigne/aigne-hub:${index_js_1.nodejs.os.hostname()}`;
56
- const clientId = this.options?.clientOptions?.clientId || BLOCKLET_APP_PID || ABT_NODE_DID || localClientId;
57
- options.fetchOptions = {
58
- headers: { "x-aigne-hub-client-did": clientId },
59
- ...options.fetchOptions,
60
- };
61
- const client = await this.client();
62
- return client.__invoke(undefined, input, options);
63
- }
64
- }
65
- exports.AIGNEHubChatModel = AIGNEHubChatModel;
@@ -1,14 +0,0 @@
1
- declare const WELLKNOWN_SERVICE_PATH_PREFIX = "/.well-known/service";
2
- declare const ACCESS_KEY_PREFIX = "/api/access-key";
3
- declare const ACCESS_KEY_SESSION_API = "/api/access-key/session";
4
- declare const AIGNE_HUB_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
5
- declare const AGENT_HUB_PROVIDER = "aignehub";
6
- declare const AIGNE_HUB_URL = "https://hub.aigne.io/";
7
- declare const DEFAULT_AIGNE_HUB_MODEL = "openai/gpt-5-mini";
8
- declare const DEFAULT_AIGNE_HUB_PROVIDER_MODEL = "aignehub:openai/gpt-5-mini";
9
- declare const DEFAULT_MODEL_PROVIDER = "openai";
10
- declare const isTest: string | boolean;
11
- declare const TEST_AIGNE_ENV_FILE: string;
12
- declare const PROD_AIGNE_ENV_FILE: string;
13
- declare const AIGNE_ENV_FILE: string;
14
- export { DEFAULT_AIGNE_HUB_MODEL, DEFAULT_AIGNE_HUB_PROVIDER_MODEL, DEFAULT_MODEL_PROVIDER, AIGNE_HUB_DID, AIGNE_HUB_URL, isTest, WELLKNOWN_SERVICE_PATH_PREFIX, ACCESS_KEY_PREFIX, ACCESS_KEY_SESSION_API, AGENT_HUB_PROVIDER, TEST_AIGNE_ENV_FILE, PROD_AIGNE_ENV_FILE, AIGNE_ENV_FILE, };
@@ -1,30 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AIGNE_ENV_FILE = exports.PROD_AIGNE_ENV_FILE = exports.TEST_AIGNE_ENV_FILE = exports.AGENT_HUB_PROVIDER = exports.ACCESS_KEY_SESSION_API = exports.ACCESS_KEY_PREFIX = exports.WELLKNOWN_SERVICE_PATH_PREFIX = exports.isTest = exports.AIGNE_HUB_URL = exports.AIGNE_HUB_DID = exports.DEFAULT_MODEL_PROVIDER = exports.DEFAULT_AIGNE_HUB_PROVIDER_MODEL = exports.DEFAULT_AIGNE_HUB_MODEL = void 0;
4
- const index_js_1 = require("@aigne/platform-helpers/nodejs/index.js");
5
- const WELLKNOWN_SERVICE_PATH_PREFIX = "/.well-known/service";
6
- exports.WELLKNOWN_SERVICE_PATH_PREFIX = WELLKNOWN_SERVICE_PATH_PREFIX;
7
- const ACCESS_KEY_PREFIX = "/api/access-key";
8
- exports.ACCESS_KEY_PREFIX = ACCESS_KEY_PREFIX;
9
- const ACCESS_KEY_SESSION_API = `${ACCESS_KEY_PREFIX}/session`;
10
- exports.ACCESS_KEY_SESSION_API = ACCESS_KEY_SESSION_API;
11
- const AIGNE_HUB_DID = "z8ia3xzq2tMq8CRHfaXj1BTYJyYnEcHbqP8cJ";
12
- exports.AIGNE_HUB_DID = AIGNE_HUB_DID;
13
- const AGENT_HUB_PROVIDER = "aignehub";
14
- exports.AGENT_HUB_PROVIDER = AGENT_HUB_PROVIDER;
15
- const AIGNE_HUB_URL = "https://hub.aigne.io/";
16
- exports.AIGNE_HUB_URL = AIGNE_HUB_URL;
17
- const DEFAULT_AIGNE_HUB_MODEL = "openai/gpt-5-mini";
18
- exports.DEFAULT_AIGNE_HUB_MODEL = DEFAULT_AIGNE_HUB_MODEL;
19
- const DEFAULT_AIGNE_HUB_PROVIDER_MODEL = `${AGENT_HUB_PROVIDER}:${DEFAULT_AIGNE_HUB_MODEL}`;
20
- exports.DEFAULT_AIGNE_HUB_PROVIDER_MODEL = DEFAULT_AIGNE_HUB_PROVIDER_MODEL;
21
- const DEFAULT_MODEL_PROVIDER = "openai";
22
- exports.DEFAULT_MODEL_PROVIDER = DEFAULT_MODEL_PROVIDER;
23
- const isTest = process.env.CI || process.env.NODE_ENV === "test";
24
- exports.isTest = isTest;
25
- const TEST_AIGNE_ENV_FILE = index_js_1.nodejs.path.join(index_js_1.nodejs.os.homedir(), ".aigne", "test-aigne-hub-connected.yaml");
26
- exports.TEST_AIGNE_ENV_FILE = TEST_AIGNE_ENV_FILE;
27
- const PROD_AIGNE_ENV_FILE = index_js_1.nodejs.path.join(index_js_1.nodejs.os.homedir(), ".aigne", "aigne-hub-connected.yaml");
28
- exports.PROD_AIGNE_ENV_FILE = PROD_AIGNE_ENV_FILE;
29
- const AIGNE_ENV_FILE = isTest ? TEST_AIGNE_ENV_FILE : PROD_AIGNE_ENV_FILE;
30
- exports.AIGNE_ENV_FILE = AIGNE_ENV_FILE;
@@ -1,24 +0,0 @@
1
- import type { CreateConnectOptions, FetchResult, LoadCredentialOptions } from "./type.js";
2
- export declare const fetchConfigs: ({ connectUrl, sessionId, fetchInterval, fetchTimeout, }: {
3
- connectUrl: string;
4
- sessionId: string;
5
- fetchInterval: number;
6
- fetchTimeout: number;
7
- }) => Promise<any>;
8
- export declare function createConnect({ connectUrl, openPage, fetchInterval, retry, source, connectAction, wrapSpinner, closeOnSuccess, intervalFetchConfig, appName, appLogo, }: CreateConnectOptions): Promise<FetchResult>;
9
- export declare function getAIGNEHubMountPoint(url: string): Promise<string>;
10
- export declare function connectToAIGNEHub(url: string): Promise<{
11
- apiKey: string;
12
- url: string;
13
- } | {
14
- apiKey: undefined;
15
- url: undefined;
16
- }>;
17
- export declare const checkConnectionStatus: (host: string) => Promise<{
18
- apiKey: any;
19
- url: any;
20
- }>;
21
- export declare function loadCredential(options?: LoadCredentialOptions): Promise<{
22
- apiKey?: string;
23
- url?: string;
24
- } | undefined>;