linkque-cli-v2 1.0.2-beta.2 → 1.0.2-beta.2026091502

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 (59) hide show
  1. package/README.md +2 -4
  2. package/linkquejs.js +35731 -24242
  3. package/package.json +5 -2
  4. package/vendor/linkque-agent-appwrite-integrate/dist/esm/anthropic-messages-EL2IU4YU.js +7172 -0
  5. package/vendor/linkque-agent-appwrite-integrate/dist/esm/azure-openai-responses-A4XURCOX.js +229 -0
  6. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-2ESYSVXG.js +48 -0
  7. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-46SEH6ER.js +78 -0
  8. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-5LYUFB4C.js +23196 -0
  9. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-6MHDOBWO.js +12 -0
  10. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-737ZCGB2.js +12289 -0
  11. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-7QWAKKTY.js +7054 -0
  12. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-B5XRGKYX.js +33 -0
  13. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-CT4G24PS.js +8 -0
  14. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-E2P6TIFG.js +31 -0
  15. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-ETG6PNHQ.js +1765 -0
  16. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-FC7MJHC3.js +671 -0
  17. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-FHNQ6DPF.js +14 -0
  18. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-G64JTU26.js +20 -0
  19. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-GAYNLDWK.js +11166 -0
  20. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-GQ4TD3EQ.js +31278 -0
  21. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-HM7KNEG3.js +1639 -0
  22. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-HTG7JBF2.js +38 -0
  23. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-IWOFD643.js +3570 -0
  24. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-M235KAEK.js +30 -0
  25. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-NKEOCGYU.js +76 -0
  26. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-PXCGFBV5.js +3584 -0
  27. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-Q2Y6LMNC.js +497 -0
  28. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-RR2GJPNV.js +4765 -0
  29. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-RYONFGPP.js +317 -0
  30. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-UFVAKOTZ.js +17 -0
  31. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-WJHOHUET.js +343 -0
  32. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-XMVFOHGJ.js +31 -0
  33. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-XUFLSZM4.js +5319 -0
  34. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-Y3G4J3TB.js +609 -0
  35. package/vendor/linkque-agent-appwrite-integrate/dist/esm/chunk-Y6UTJIT4.js +23 -0
  36. package/vendor/linkque-agent-appwrite-integrate/dist/esm/dist-TGBYXSBU.js +1224 -0
  37. package/vendor/linkque-agent-appwrite-integrate/dist/esm/getMachineId-bsd-H2ZLZRGB.js +40 -0
  38. package/vendor/linkque-agent-appwrite-integrate/dist/esm/getMachineId-darwin-HUKYR46U.js +39 -0
  39. package/vendor/linkque-agent-appwrite-integrate/dist/esm/getMachineId-linux-M5ZADHBA.js +33 -0
  40. package/vendor/linkque-agent-appwrite-integrate/dist/esm/getMachineId-unsupported-BM5RZZVM.js +23 -0
  41. package/vendor/linkque-agent-appwrite-integrate/dist/esm/getMachineId-win-BQPUF5TW.js +42 -0
  42. package/vendor/linkque-agent-appwrite-integrate/dist/esm/google-generative-ai-ENBYCHYT.js +412 -0
  43. package/vendor/linkque-agent-appwrite-integrate/dist/esm/google-vertex-RIGAEYLC.js +461 -0
  44. package/vendor/linkque-agent-appwrite-integrate/dist/esm/mistral-conversations-TQA2MPJJ.js +30344 -0
  45. package/vendor/linkque-agent-appwrite-integrate/dist/esm/multipart-parser-BXFNUG5H.js +178 -0
  46. package/vendor/linkque-agent-appwrite-integrate/dist/esm/multipart-parser-TAD6XL3Q.js +368 -0
  47. package/vendor/linkque-agent-appwrite-integrate/dist/esm/multipart-parser-ZRVTGJCT.js +170 -0
  48. package/vendor/linkque-agent-appwrite-integrate/dist/esm/openai-codex-responses-WLREQPZK.js +1308 -0
  49. package/vendor/linkque-agent-appwrite-integrate/dist/esm/openai-completions-U6LUBY4P.js +977 -0
  50. package/vendor/linkque-agent-appwrite-integrate/dist/esm/openai-responses-SFZAU5JA.js +264 -0
  51. package/vendor/linkque-agent-appwrite-integrate/dist/esm/openrouter-images-VSKAO4O5.js +138 -0
  52. package/vendor/linkque-agent-appwrite-integrate/dist/esm/otel-RXJWJ2TU.js +5728 -0
  53. package/vendor/linkque-agent-appwrite-integrate/dist/esm/pi-messages-QQA6ZGV2.js +309 -0
  54. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/chat.js +46018 -0
  55. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/handler/clientCapability.js +20 -0
  56. package/vendor/linkque-agent-appwrite-integrate/dist/esm/runtime/protocol.js +13 -0
  57. package/vendor/linkque-agent-appwrite-integrate/dist/esm/src-JSJTYJV5.js +1396 -0
  58. package/vendor/linkque-agent-appwrite-integrate/package.json +1 -0
  59. package/worker.js +124589 -104664
@@ -0,0 +1,229 @@
1
+ import {
2
+ convertResponsesMessages,
3
+ convertResponsesTools,
4
+ processResponsesStream
5
+ } from "./chunk-Q2Y6LMNC.js";
6
+ import "./chunk-UFVAKOTZ.js";
7
+ import {
8
+ clampOpenAIPromptCacheKey
9
+ } from "./chunk-FHNQ6DPF.js";
10
+ import {
11
+ AzureOpenAI
12
+ } from "./chunk-7QWAKKTY.js";
13
+ import {
14
+ formatProviderError,
15
+ normalizeProviderError
16
+ } from "./chunk-NKEOCGYU.js";
17
+ import {
18
+ buildBaseOptions
19
+ } from "./chunk-RYONFGPP.js";
20
+ import "./chunk-CT4G24PS.js";
21
+ import {
22
+ headersToRecord
23
+ } from "./chunk-Y6UTJIT4.js";
24
+ import "./chunk-WJHOHUET.js";
25
+ import {
26
+ getProviderEnvValue
27
+ } from "./chunk-B5XRGKYX.js";
28
+ import {
29
+ clampThinkingLevel
30
+ } from "./chunk-Y3G4J3TB.js";
31
+ import {
32
+ AssistantMessageEventStream
33
+ } from "./chunk-46SEH6ER.js";
34
+ import "./chunk-2ESYSVXG.js";
35
+
36
+ // ../../node_modules/@earendil-works/pi-ai/dist/api/azure-openai-responses.js
37
+ var DEFAULT_AZURE_API_VERSION = "v1";
38
+ var AZURE_TOOL_CALL_PROVIDERS = /* @__PURE__ */ new Set(["openai", "openai-codex", "opencode", "azure-openai-responses"]);
39
+ var OPENAI_RESPONSES_MIN_OUTPUT_TOKENS = 16;
40
+ function parseDeploymentNameMap(value) {
41
+ const map = /* @__PURE__ */ new Map();
42
+ if (!value)
43
+ return map;
44
+ for (const entry of value.split(",")) {
45
+ const trimmed = entry.trim();
46
+ if (!trimmed)
47
+ continue;
48
+ const [modelId, deploymentName] = trimmed.split("=", 2);
49
+ if (!modelId || !deploymentName)
50
+ continue;
51
+ map.set(modelId.trim(), deploymentName.trim());
52
+ }
53
+ return map;
54
+ }
55
+ function resolveDeploymentName(model, options) {
56
+ if (options?.azureDeploymentName) {
57
+ return options.azureDeploymentName;
58
+ }
59
+ const mappedDeployment = parseDeploymentNameMap(getProviderEnvValue("AZURE_OPENAI_DEPLOYMENT_NAME_MAP", options?.env)).get(model.id);
60
+ return mappedDeployment || model.id;
61
+ }
62
+ function formatAzureOpenAIError(error) {
63
+ return formatProviderError(normalizeProviderError(error), "Azure OpenAI API error");
64
+ }
65
+ var stream = (model, context, options) => {
66
+ const stream2 = new AssistantMessageEventStream();
67
+ (async () => {
68
+ const deploymentName = resolveDeploymentName(model, options);
69
+ const output = {
70
+ role: "assistant",
71
+ content: [],
72
+ api: "azure-openai-responses",
73
+ provider: model.provider,
74
+ model: model.id,
75
+ usage: {
76
+ input: 0,
77
+ output: 0,
78
+ cacheRead: 0,
79
+ cacheWrite: 0,
80
+ totalTokens: 0,
81
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
82
+ },
83
+ stopReason: "stop",
84
+ timestamp: Date.now()
85
+ };
86
+ try {
87
+ const apiKey = options?.apiKey;
88
+ if (!apiKey) {
89
+ throw new Error(`No API key for provider: ${model.provider}`);
90
+ }
91
+ const client = createClient(model, apiKey, options);
92
+ let params = buildParams(model, context, options, deploymentName);
93
+ const nextParams = await options?.onPayload?.(params, model);
94
+ if (nextParams !== void 0) {
95
+ params = nextParams;
96
+ }
97
+ const requestOptions = {
98
+ ...options?.signal ? { signal: options.signal } : {},
99
+ ...options?.timeoutMs !== void 0 ? { timeout: options.timeoutMs } : {},
100
+ maxRetries: options?.maxRetries ?? 0
101
+ };
102
+ const { data: openaiStream, response } = await client.responses.create(params, requestOptions).withResponse();
103
+ await options?.onResponse?.({ status: response.status, headers: headersToRecord(response.headers) }, model);
104
+ stream2.push({ type: "start", partial: output });
105
+ await processResponsesStream(openaiStream, output, stream2, model);
106
+ if (options?.signal?.aborted) {
107
+ throw new Error("Request was aborted");
108
+ }
109
+ if (output.stopReason === "aborted" || output.stopReason === "error") {
110
+ throw new Error("An unknown error occurred");
111
+ }
112
+ stream2.push({ type: "done", reason: output.stopReason, message: output });
113
+ stream2.end();
114
+ } catch (error) {
115
+ for (const block of output.content) {
116
+ delete block.index;
117
+ delete block.partialJson;
118
+ }
119
+ output.stopReason = options?.signal?.aborted ? "aborted" : "error";
120
+ output.errorMessage = formatAzureOpenAIError(error);
121
+ stream2.push({ type: "error", reason: output.stopReason, error: output });
122
+ stream2.end();
123
+ }
124
+ })();
125
+ return stream2;
126
+ };
127
+ var streamSimple = (model, context, options) => {
128
+ const apiKey = options?.apiKey;
129
+ if (!apiKey) {
130
+ throw new Error(`No API key for provider: ${model.provider}`);
131
+ }
132
+ const base = buildBaseOptions(model, context, options, apiKey);
133
+ const clampedReasoning = options?.reasoning ? clampThinkingLevel(model, options.reasoning) : void 0;
134
+ const reasoningEffort = clampedReasoning === "off" ? void 0 : clampedReasoning;
135
+ return stream(model, context, {
136
+ ...base,
137
+ reasoningEffort
138
+ });
139
+ };
140
+ function normalizeAzureBaseUrl(baseUrl) {
141
+ const trimmed = baseUrl.trim().replace(/\/+$/, "");
142
+ let url;
143
+ try {
144
+ url = new URL(trimmed);
145
+ } catch {
146
+ throw new Error(`Invalid Azure OpenAI base URL: ${baseUrl}`);
147
+ }
148
+ const isAzureHost = url.hostname.endsWith(".openai.azure.com") || url.hostname.endsWith(".cognitiveservices.azure.com") || url.hostname.endsWith(".ai.azure.com");
149
+ const normalizedPath = url.pathname.replace(/\/+$/, "");
150
+ if (isAzureHost && (normalizedPath === "" || normalizedPath === "/" || normalizedPath === "/openai" || normalizedPath === "/openai/v1/responses")) {
151
+ url.pathname = "/openai/v1";
152
+ url.search = "";
153
+ }
154
+ return url.toString().replace(/\/+$/, "");
155
+ }
156
+ function buildDefaultBaseUrl(resourceName) {
157
+ return `https://${resourceName}.openai.azure.com/openai/v1`;
158
+ }
159
+ function resolveAzureConfig(model, options) {
160
+ const apiVersion = options?.azureApiVersion || getProviderEnvValue("AZURE_OPENAI_API_VERSION", options?.env) || DEFAULT_AZURE_API_VERSION;
161
+ const baseUrl = options?.azureBaseUrl?.trim() || getProviderEnvValue("AZURE_OPENAI_BASE_URL", options?.env)?.trim() || void 0;
162
+ const resourceName = options?.azureResourceName || getProviderEnvValue("AZURE_OPENAI_RESOURCE_NAME", options?.env);
163
+ let resolvedBaseUrl = baseUrl;
164
+ if (!resolvedBaseUrl && resourceName) {
165
+ resolvedBaseUrl = buildDefaultBaseUrl(resourceName);
166
+ }
167
+ if (!resolvedBaseUrl && model.baseUrl) {
168
+ resolvedBaseUrl = model.baseUrl;
169
+ }
170
+ if (!resolvedBaseUrl) {
171
+ throw new Error("Azure OpenAI base URL is required. Set AZURE_OPENAI_BASE_URL or AZURE_OPENAI_RESOURCE_NAME, or pass azureBaseUrl, azureResourceName, or model.baseUrl.");
172
+ }
173
+ return {
174
+ baseUrl: normalizeAzureBaseUrl(resolvedBaseUrl),
175
+ apiVersion
176
+ };
177
+ }
178
+ function createClient(model, apiKey, options) {
179
+ const headers = { ...model.headers };
180
+ if (options?.headers) {
181
+ Object.assign(headers, options.headers);
182
+ }
183
+ const { baseUrl, apiVersion } = resolveAzureConfig(model, options);
184
+ return new AzureOpenAI({
185
+ apiKey,
186
+ apiVersion,
187
+ dangerouslyAllowBrowser: true,
188
+ defaultHeaders: headers,
189
+ baseURL: baseUrl
190
+ });
191
+ }
192
+ function buildParams(model, context, options, deploymentName) {
193
+ const messages = convertResponsesMessages(model, context, AZURE_TOOL_CALL_PROVIDERS);
194
+ const params = {
195
+ model: deploymentName,
196
+ input: messages,
197
+ stream: true,
198
+ prompt_cache_key: clampOpenAIPromptCacheKey(options?.sessionId),
199
+ store: false
200
+ };
201
+ if (options?.maxTokens) {
202
+ params.max_output_tokens = Math.max(options.maxTokens, OPENAI_RESPONSES_MIN_OUTPUT_TOKENS);
203
+ }
204
+ if (options?.temperature !== void 0) {
205
+ params.temperature = options?.temperature;
206
+ }
207
+ if (context.tools && context.tools.length > 0) {
208
+ params.tools = convertResponsesTools(context.tools);
209
+ }
210
+ if (model.reasoning) {
211
+ if (options?.reasoningEffort || options?.reasoningSummary) {
212
+ const effort = options?.reasoningEffort ? model.thinkingLevelMap?.[options.reasoningEffort] ?? options.reasoningEffort : "medium";
213
+ params.reasoning = {
214
+ effort,
215
+ summary: options?.reasoningSummary || "auto"
216
+ };
217
+ params.include = ["reasoning.encrypted_content"];
218
+ } else if (model.thinkingLevelMap?.off !== null) {
219
+ params.reasoning = {
220
+ effort: model.thinkingLevelMap?.off ?? "none"
221
+ };
222
+ }
223
+ }
224
+ return params;
225
+ }
226
+ export {
227
+ stream,
228
+ streamSimple
229
+ };
@@ -0,0 +1,48 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __esm = (fn, res) => function __init() {
14
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
+ };
16
+ var __commonJS = (cb, mod) => function __require2() {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ };
19
+ var __export = (target, all) => {
20
+ for (var name in all)
21
+ __defProp(target, name, { get: all[name], enumerable: true });
22
+ };
23
+ var __copyProps = (to, from, except, desc) => {
24
+ if (from && typeof from === "object" || typeof from === "function") {
25
+ for (let key of __getOwnPropNames(from))
26
+ if (!__hasOwnProp.call(to, key) && key !== except)
27
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28
+ }
29
+ return to;
30
+ };
31
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32
+ // If the importer is in node compatibility mode or this is not an ESM
33
+ // file that has been converted to a CommonJS file using a Babel-
34
+ // compatible transform (i.e. "__esModule" has not been set), then set
35
+ // "default" to the CommonJS "module.exports" for node compatibility.
36
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37
+ mod
38
+ ));
39
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
40
+
41
+ export {
42
+ __require,
43
+ __esm,
44
+ __commonJS,
45
+ __export,
46
+ __toESM,
47
+ __toCommonJS
48
+ };
@@ -0,0 +1,78 @@
1
+ // ../../node_modules/@earendil-works/pi-ai/dist/utils/event-stream.js
2
+ var EventStream = class {
3
+ queue = [];
4
+ waiting = [];
5
+ done = false;
6
+ finalResultPromise;
7
+ resolveFinalResult;
8
+ isComplete;
9
+ extractResult;
10
+ constructor(isComplete, extractResult) {
11
+ this.isComplete = isComplete;
12
+ this.extractResult = extractResult;
13
+ this.finalResultPromise = new Promise((resolve) => {
14
+ this.resolveFinalResult = resolve;
15
+ });
16
+ }
17
+ push(event) {
18
+ if (this.done)
19
+ return;
20
+ if (this.isComplete(event)) {
21
+ this.done = true;
22
+ this.resolveFinalResult(this.extractResult(event));
23
+ }
24
+ const waiter = this.waiting.shift();
25
+ if (waiter) {
26
+ waiter({ value: event, done: false });
27
+ } else {
28
+ this.queue.push(event);
29
+ }
30
+ }
31
+ end(result) {
32
+ this.done = true;
33
+ if (result !== void 0) {
34
+ this.resolveFinalResult(result);
35
+ }
36
+ while (this.waiting.length > 0) {
37
+ const waiter = this.waiting.shift();
38
+ waiter({ value: void 0, done: true });
39
+ }
40
+ }
41
+ async *[Symbol.asyncIterator]() {
42
+ while (true) {
43
+ if (this.queue.length > 0) {
44
+ yield this.queue.shift();
45
+ } else if (this.done) {
46
+ return;
47
+ } else {
48
+ const result = await new Promise((resolve) => this.waiting.push(resolve));
49
+ if (result.done)
50
+ return;
51
+ yield result.value;
52
+ }
53
+ }
54
+ }
55
+ result() {
56
+ return this.finalResultPromise;
57
+ }
58
+ };
59
+ var AssistantMessageEventStream = class extends EventStream {
60
+ constructor() {
61
+ super((event) => event.type === "done" || event.type === "error", (event) => {
62
+ if (event.type === "done") {
63
+ return event.message;
64
+ } else if (event.type === "error") {
65
+ return event.error;
66
+ }
67
+ throw new Error("Unexpected event type for final result");
68
+ });
69
+ }
70
+ };
71
+ function createAssistantMessageEventStream() {
72
+ return new AssistantMessageEventStream();
73
+ }
74
+
75
+ export {
76
+ AssistantMessageEventStream,
77
+ createAssistantMessageEventStream
78
+ };