@axlsdk/axl 0.16.1 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +158 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +159 -10
- package/dist/index.d.ts +159 -10
- package/dist/index.js +149 -22
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -116,6 +116,7 @@ __export(index_exports, {
|
|
|
116
116
|
AxlRuntime: () => AxlRuntime,
|
|
117
117
|
AxlStream: () => AxlStream,
|
|
118
118
|
BudgetExceededError: () => BudgetExceededError,
|
|
119
|
+
CONFIG_CANDIDATES: () => CONFIG_CANDIDATES,
|
|
119
120
|
COST_BEARING_LEAF_TYPES: () => COST_BEARING_LEAF_TYPES,
|
|
120
121
|
GeminiProvider: () => GeminiProvider,
|
|
121
122
|
GuardrailError: () => GuardrailError,
|
|
@@ -146,11 +147,19 @@ __export(index_exports, {
|
|
|
146
147
|
createSpanManager: () => createSpanManager,
|
|
147
148
|
defineConfig: () => defineConfig,
|
|
148
149
|
eventCostContribution: () => eventCostContribution,
|
|
150
|
+
expandGlob: () => expandGlob,
|
|
149
151
|
extractJson: () => extractJson,
|
|
152
|
+
findConfig: () => findConfig,
|
|
153
|
+
importModule: () => importModule,
|
|
150
154
|
isCostBearingLeaf: () => isCostBearingLeaf,
|
|
151
155
|
isRootLevel: () => isRootLevel,
|
|
156
|
+
needsTsxLoader: () => needsTsxLoader,
|
|
152
157
|
parsePartialJson: () => parsePartialJson,
|
|
158
|
+
pickDefault: () => pickDefault,
|
|
159
|
+
pickExport: () => pickExport,
|
|
153
160
|
redactEvent: () => redactEvent,
|
|
161
|
+
registerConditions: () => registerConditions,
|
|
162
|
+
resolveRuntime: () => resolveRuntime,
|
|
154
163
|
resolveThinkingOptions: () => resolveThinkingOptions,
|
|
155
164
|
tool: () => tool,
|
|
156
165
|
workflow: () => workflow,
|
|
@@ -178,7 +187,7 @@ function validateStringLengths(value, maxLen, path = "") {
|
|
|
178
187
|
}
|
|
179
188
|
}
|
|
180
189
|
function sleep(ms) {
|
|
181
|
-
return new Promise((
|
|
190
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
182
191
|
}
|
|
183
192
|
function getBackoffMs(attempt, strategy) {
|
|
184
193
|
switch (strategy) {
|
|
@@ -282,17 +291,17 @@ var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 503, 529]);
|
|
|
282
291
|
var MAX_RETRIES = 2;
|
|
283
292
|
var BASE_DELAY_MS = 1e3;
|
|
284
293
|
function sleep2(ms, signal) {
|
|
285
|
-
return new Promise((
|
|
294
|
+
return new Promise((resolve2) => {
|
|
286
295
|
if (signal?.aborted) {
|
|
287
|
-
|
|
296
|
+
resolve2();
|
|
288
297
|
return;
|
|
289
298
|
}
|
|
290
|
-
const timer = setTimeout(
|
|
299
|
+
const timer = setTimeout(resolve2, ms);
|
|
291
300
|
signal?.addEventListener(
|
|
292
301
|
"abort",
|
|
293
302
|
() => {
|
|
294
303
|
clearTimeout(timer);
|
|
295
|
-
|
|
304
|
+
resolve2();
|
|
296
305
|
},
|
|
297
306
|
{ once: true }
|
|
298
307
|
);
|
|
@@ -4318,7 +4327,7 @@ ${summaryResponse.content}`
|
|
|
4318
4327
|
const controller = new AbortController();
|
|
4319
4328
|
const parentSignal2 = this.currentSignal;
|
|
4320
4329
|
const composedSignal = parentSignal2 ? AbortSignal.any([parentSignal2, controller.signal]) : controller.signal;
|
|
4321
|
-
return new Promise((
|
|
4330
|
+
return new Promise((resolve2, reject) => {
|
|
4322
4331
|
let settled = false;
|
|
4323
4332
|
let completedCount = 0;
|
|
4324
4333
|
for (let i = 0; i < n; i++) {
|
|
@@ -4332,7 +4341,7 @@ ${summaryResponse.content}`
|
|
|
4332
4341
|
if (successCount >= quorum) {
|
|
4333
4342
|
settled = true;
|
|
4334
4343
|
controller.abort();
|
|
4335
|
-
|
|
4344
|
+
resolve2(results);
|
|
4336
4345
|
} else if (completedCount === n && successCount < quorum) {
|
|
4337
4346
|
settled = true;
|
|
4338
4347
|
reject(new QuorumNotMet(quorum, successCount, results));
|
|
@@ -4654,7 +4663,7 @@ ${summaryResponse.content}`
|
|
|
4654
4663
|
const schema = options?.schema;
|
|
4655
4664
|
const parentSignal = this.currentSignal;
|
|
4656
4665
|
const composedSignal = parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal;
|
|
4657
|
-
return new Promise((
|
|
4666
|
+
return new Promise((resolve2, reject) => {
|
|
4658
4667
|
let settled = false;
|
|
4659
4668
|
let remaining = fns.length;
|
|
4660
4669
|
for (const fn of fns) {
|
|
@@ -4701,12 +4710,12 @@ ${summaryResponse.content}`
|
|
|
4701
4710
|
if (settled) return;
|
|
4702
4711
|
settled = true;
|
|
4703
4712
|
controller.abort();
|
|
4704
|
-
|
|
4713
|
+
resolve2(parsed.data);
|
|
4705
4714
|
return;
|
|
4706
4715
|
}
|
|
4707
4716
|
settled = true;
|
|
4708
4717
|
controller.abort();
|
|
4709
|
-
|
|
4718
|
+
resolve2(value);
|
|
4710
4719
|
}).catch((err) => {
|
|
4711
4720
|
if (settled) return;
|
|
4712
4721
|
if (err instanceof DOMException && err.name === "AbortError") {
|
|
@@ -4752,9 +4761,9 @@ ${summaryResponse.content}`
|
|
|
4752
4761
|
const controller = quorum ? new AbortController() : void 0;
|
|
4753
4762
|
const parentSignal = this.currentSignal;
|
|
4754
4763
|
const mapSignal = controller ? parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal : parentSignal;
|
|
4755
|
-
return new Promise((
|
|
4764
|
+
return new Promise((resolve2, reject) => {
|
|
4756
4765
|
if (items.length === 0) {
|
|
4757
|
-
|
|
4766
|
+
resolve2([]);
|
|
4758
4767
|
return;
|
|
4759
4768
|
}
|
|
4760
4769
|
const runNext = async () => {
|
|
@@ -4775,14 +4784,14 @@ ${summaryResponse.content}`
|
|
|
4775
4784
|
if (quorum && successCount >= quorum) {
|
|
4776
4785
|
settled = true;
|
|
4777
4786
|
controller?.abort();
|
|
4778
|
-
|
|
4787
|
+
resolve2(results);
|
|
4779
4788
|
return;
|
|
4780
4789
|
}
|
|
4781
4790
|
if (completedCount === items.length) {
|
|
4782
4791
|
if (quorum && successCount < quorum) {
|
|
4783
4792
|
reject(new QuorumNotMet(quorum, successCount, results));
|
|
4784
4793
|
} else {
|
|
4785
|
-
|
|
4794
|
+
resolve2(results);
|
|
4786
4795
|
}
|
|
4787
4796
|
return;
|
|
4788
4797
|
}
|
|
@@ -4857,8 +4866,8 @@ ${summaryResponse.content}`
|
|
|
4857
4866
|
type: "await_human",
|
|
4858
4867
|
data: { channel: options.channel, prompt: options.prompt }
|
|
4859
4868
|
});
|
|
4860
|
-
const decision = await new Promise((
|
|
4861
|
-
this.pendingDecisions.set(this.executionId,
|
|
4869
|
+
const decision = await new Promise((resolve2) => {
|
|
4870
|
+
this.pendingDecisions.set(this.executionId, resolve2);
|
|
4862
4871
|
});
|
|
4863
4872
|
this.emitEvent({
|
|
4864
4873
|
type: "await_human_resolved",
|
|
@@ -6110,8 +6119,8 @@ var AxlStream = class _AxlStream extends import_node_stream.Readable {
|
|
|
6110
6119
|
} });
|
|
6111
6120
|
let resolvePromise;
|
|
6112
6121
|
let rejectPromise;
|
|
6113
|
-
this.promise = new Promise((
|
|
6114
|
-
resolvePromise =
|
|
6122
|
+
this.promise = new Promise((resolve2, reject) => {
|
|
6123
|
+
resolvePromise = resolve2;
|
|
6115
6124
|
rejectPromise = reject;
|
|
6116
6125
|
});
|
|
6117
6126
|
this.bus.on("__resolve", (value) => resolvePromise(value));
|
|
@@ -6151,8 +6160,8 @@ var AxlStream = class _AxlStream extends import_node_stream.Readable {
|
|
|
6151
6160
|
if (self.finished && self.eventQueue.length === 0) {
|
|
6152
6161
|
return Promise.resolve({ value: void 0, done: true });
|
|
6153
6162
|
}
|
|
6154
|
-
return new Promise((
|
|
6155
|
-
self.waiters.push(
|
|
6163
|
+
return new Promise((resolve2) => {
|
|
6164
|
+
self.waiters.push(resolve2);
|
|
6156
6165
|
});
|
|
6157
6166
|
},
|
|
6158
6167
|
[Symbol.asyncIterator]() {
|
|
@@ -6471,7 +6480,7 @@ var StdioMcpClient = class {
|
|
|
6471
6480
|
}
|
|
6472
6481
|
}
|
|
6473
6482
|
sendRequest(method, params, timeoutMs = 3e4) {
|
|
6474
|
-
return new Promise((
|
|
6483
|
+
return new Promise((resolve2, reject) => {
|
|
6475
6484
|
if (!this.process?.stdin?.writable) {
|
|
6476
6485
|
reject(new Error(`MCP server "${this.name}" is not connected`));
|
|
6477
6486
|
return;
|
|
@@ -6492,7 +6501,7 @@ var StdioMcpClient = class {
|
|
|
6492
6501
|
this.pending.set(id, {
|
|
6493
6502
|
resolve: (value) => {
|
|
6494
6503
|
clearTimeout(timer);
|
|
6495
|
-
|
|
6504
|
+
resolve2(value);
|
|
6496
6505
|
},
|
|
6497
6506
|
reject: (err) => {
|
|
6498
6507
|
clearTimeout(timer);
|
|
@@ -8044,6 +8053,124 @@ var AxlRuntime = class extends import_node_events2.EventEmitter {
|
|
|
8044
8053
|
}
|
|
8045
8054
|
};
|
|
8046
8055
|
|
|
8056
|
+
// src/module-resolve.ts
|
|
8057
|
+
function resolveRuntime(mod) {
|
|
8058
|
+
const def = mod.default;
|
|
8059
|
+
return def?.default ?? def ?? mod.runtime;
|
|
8060
|
+
}
|
|
8061
|
+
function pickDefault(mod) {
|
|
8062
|
+
const def = mod.default;
|
|
8063
|
+
return def?.default ?? def ?? mod.config ?? mod;
|
|
8064
|
+
}
|
|
8065
|
+
function pickExport(mod, key) {
|
|
8066
|
+
const def = mod.default;
|
|
8067
|
+
return mod[key] ?? def?.[key] ?? def?.default?.[key];
|
|
8068
|
+
}
|
|
8069
|
+
|
|
8070
|
+
// src/cli-internals.ts
|
|
8071
|
+
var import_node_path3 = require("path");
|
|
8072
|
+
var import_node_fs3 = require("fs");
|
|
8073
|
+
var import_node_url = require("url");
|
|
8074
|
+
var CONFIG_CANDIDATES = [
|
|
8075
|
+
"axl.config.mts",
|
|
8076
|
+
"axl.config.ts",
|
|
8077
|
+
"axl.config.mjs",
|
|
8078
|
+
"axl.config.js"
|
|
8079
|
+
];
|
|
8080
|
+
function findConfig(cwd) {
|
|
8081
|
+
for (const name of CONFIG_CANDIDATES) {
|
|
8082
|
+
const p = (0, import_node_path3.resolve)(cwd, name);
|
|
8083
|
+
if ((0, import_node_fs3.existsSync)(p)) return p;
|
|
8084
|
+
}
|
|
8085
|
+
return void 0;
|
|
8086
|
+
}
|
|
8087
|
+
function needsTsxLoader(filePath) {
|
|
8088
|
+
return /\.[mc]?tsx?$/.test(filePath);
|
|
8089
|
+
}
|
|
8090
|
+
var tsxRegistered;
|
|
8091
|
+
async function ensureTsxRegistered() {
|
|
8092
|
+
if (tsxRegistered !== void 0) return tsxRegistered;
|
|
8093
|
+
try {
|
|
8094
|
+
const mod = await import("tsx/esm/api");
|
|
8095
|
+
if (typeof mod.register === "function") {
|
|
8096
|
+
mod.register();
|
|
8097
|
+
tsxRegistered = true;
|
|
8098
|
+
} else {
|
|
8099
|
+
tsxRegistered = false;
|
|
8100
|
+
}
|
|
8101
|
+
} catch {
|
|
8102
|
+
tsxRegistered = false;
|
|
8103
|
+
}
|
|
8104
|
+
return tsxRegistered;
|
|
8105
|
+
}
|
|
8106
|
+
async function importModule(filePath, _parentURL) {
|
|
8107
|
+
if (needsTsxLoader(filePath)) {
|
|
8108
|
+
const registered = await ensureTsxRegistered();
|
|
8109
|
+
if (!registered) {
|
|
8110
|
+
throw new Error(
|
|
8111
|
+
`Cannot load TypeScript file ${filePath}: tsx is not installed.
|
|
8112
|
+
Install it as a dev dependency: npm install -D tsx (or pnpm add -D tsx)`
|
|
8113
|
+
);
|
|
8114
|
+
}
|
|
8115
|
+
}
|
|
8116
|
+
return await import((0, import_node_url.pathToFileURL)(filePath).href);
|
|
8117
|
+
}
|
|
8118
|
+
var MAX_GLOB_DEPTH = 20;
|
|
8119
|
+
function expandGlob(pattern, cwd) {
|
|
8120
|
+
if (pattern.includes("**/")) {
|
|
8121
|
+
const sepIdx = pattern.indexOf("**/");
|
|
8122
|
+
const baseDir = (0, import_node_path3.resolve)(cwd, pattern.slice(0, sepIdx) || ".");
|
|
8123
|
+
const fileGlob2 = pattern.slice(sepIdx + 3) || "*";
|
|
8124
|
+
return findFiles(baseDir, fileGlob2, true);
|
|
8125
|
+
}
|
|
8126
|
+
const dir = (0, import_node_path3.resolve)(cwd, (0, import_node_path3.dirname)(pattern));
|
|
8127
|
+
const fileGlob = (0, import_node_path3.basename)(pattern);
|
|
8128
|
+
return findFiles(dir, fileGlob, false);
|
|
8129
|
+
}
|
|
8130
|
+
function findFiles(dir, fileGlob, recursive, depth = 0) {
|
|
8131
|
+
if (depth > MAX_GLOB_DEPTH) return [];
|
|
8132
|
+
const matcher = globToRegex(fileGlob);
|
|
8133
|
+
const results = [];
|
|
8134
|
+
try {
|
|
8135
|
+
const entries = (0, import_node_fs3.readdirSync)(dir);
|
|
8136
|
+
for (const entry of entries) {
|
|
8137
|
+
const full = (0, import_node_path3.resolve)(dir, entry);
|
|
8138
|
+
try {
|
|
8139
|
+
const stat = (0, import_node_fs3.statSync)(full);
|
|
8140
|
+
if (stat.isFile() && matcher.test(entry)) {
|
|
8141
|
+
results.push(full);
|
|
8142
|
+
} else if (stat.isDirectory() && recursive) {
|
|
8143
|
+
results.push(...findFiles(full, fileGlob, true, depth + 1));
|
|
8144
|
+
}
|
|
8145
|
+
} catch {
|
|
8146
|
+
}
|
|
8147
|
+
}
|
|
8148
|
+
} catch {
|
|
8149
|
+
}
|
|
8150
|
+
return results;
|
|
8151
|
+
}
|
|
8152
|
+
function globToRegex(glob) {
|
|
8153
|
+
const escaped = glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
8154
|
+
return new RegExp(`^${escaped}$`);
|
|
8155
|
+
}
|
|
8156
|
+
async function registerConditions(conditions) {
|
|
8157
|
+
try {
|
|
8158
|
+
const nodeModule = await import("module");
|
|
8159
|
+
const hookCode = [
|
|
8160
|
+
`const extra = ${JSON.stringify(conditions)};`,
|
|
8161
|
+
`export async function resolve(specifier, context, nextResolve) {`,
|
|
8162
|
+
` return nextResolve(specifier, {`,
|
|
8163
|
+
` ...context,`,
|
|
8164
|
+
` conditions: [...new Set([...context.conditions, ...extra])],`,
|
|
8165
|
+
` });`,
|
|
8166
|
+
`}`
|
|
8167
|
+
].join("\n");
|
|
8168
|
+
nodeModule.register(`data:text/javascript,${encodeURIComponent(hookCode)}`);
|
|
8169
|
+
} catch {
|
|
8170
|
+
console.warn("Warning: --conditions requires Node.js 20.6+");
|
|
8171
|
+
}
|
|
8172
|
+
}
|
|
8173
|
+
|
|
8047
8174
|
// src/state/redis.ts
|
|
8048
8175
|
var RedisStore = class _RedisStore {
|
|
8049
8176
|
constructor(client) {
|
|
@@ -8402,6 +8529,7 @@ function cosineSimilarity2(a, b) {
|
|
|
8402
8529
|
AxlRuntime,
|
|
8403
8530
|
AxlStream,
|
|
8404
8531
|
BudgetExceededError,
|
|
8532
|
+
CONFIG_CANDIDATES,
|
|
8405
8533
|
COST_BEARING_LEAF_TYPES,
|
|
8406
8534
|
GeminiProvider,
|
|
8407
8535
|
GuardrailError,
|
|
@@ -8432,11 +8560,19 @@ function cosineSimilarity2(a, b) {
|
|
|
8432
8560
|
createSpanManager,
|
|
8433
8561
|
defineConfig,
|
|
8434
8562
|
eventCostContribution,
|
|
8563
|
+
expandGlob,
|
|
8435
8564
|
extractJson,
|
|
8565
|
+
findConfig,
|
|
8566
|
+
importModule,
|
|
8436
8567
|
isCostBearingLeaf,
|
|
8437
8568
|
isRootLevel,
|
|
8569
|
+
needsTsxLoader,
|
|
8438
8570
|
parsePartialJson,
|
|
8571
|
+
pickDefault,
|
|
8572
|
+
pickExport,
|
|
8439
8573
|
redactEvent,
|
|
8574
|
+
registerConditions,
|
|
8575
|
+
resolveRuntime,
|
|
8440
8576
|
resolveThinkingOptions,
|
|
8441
8577
|
tool,
|
|
8442
8578
|
workflow,
|