@axlsdk/axl 0.16.0 → 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.js
CHANGED
|
@@ -22,7 +22,7 @@ function validateStringLengths(value, maxLen, path = "") {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
function sleep(ms) {
|
|
25
|
-
return new Promise((
|
|
25
|
+
return new Promise((resolve2) => setTimeout(resolve2, ms));
|
|
26
26
|
}
|
|
27
27
|
function getBackoffMs(attempt, strategy) {
|
|
28
28
|
switch (strategy) {
|
|
@@ -126,17 +126,17 @@ var RETRYABLE_STATUS_CODES = /* @__PURE__ */ new Set([429, 503, 529]);
|
|
|
126
126
|
var MAX_RETRIES = 2;
|
|
127
127
|
var BASE_DELAY_MS = 1e3;
|
|
128
128
|
function sleep2(ms, signal) {
|
|
129
|
-
return new Promise((
|
|
129
|
+
return new Promise((resolve2) => {
|
|
130
130
|
if (signal?.aborted) {
|
|
131
|
-
|
|
131
|
+
resolve2();
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
|
-
const timer = setTimeout(
|
|
134
|
+
const timer = setTimeout(resolve2, ms);
|
|
135
135
|
signal?.addEventListener(
|
|
136
136
|
"abort",
|
|
137
137
|
() => {
|
|
138
138
|
clearTimeout(timer);
|
|
139
|
-
|
|
139
|
+
resolve2();
|
|
140
140
|
},
|
|
141
141
|
{ once: true }
|
|
142
142
|
);
|
|
@@ -4162,7 +4162,7 @@ ${summaryResponse.content}`
|
|
|
4162
4162
|
const controller = new AbortController();
|
|
4163
4163
|
const parentSignal2 = this.currentSignal;
|
|
4164
4164
|
const composedSignal = parentSignal2 ? AbortSignal.any([parentSignal2, controller.signal]) : controller.signal;
|
|
4165
|
-
return new Promise((
|
|
4165
|
+
return new Promise((resolve2, reject) => {
|
|
4166
4166
|
let settled = false;
|
|
4167
4167
|
let completedCount = 0;
|
|
4168
4168
|
for (let i = 0; i < n; i++) {
|
|
@@ -4176,7 +4176,7 @@ ${summaryResponse.content}`
|
|
|
4176
4176
|
if (successCount >= quorum) {
|
|
4177
4177
|
settled = true;
|
|
4178
4178
|
controller.abort();
|
|
4179
|
-
|
|
4179
|
+
resolve2(results);
|
|
4180
4180
|
} else if (completedCount === n && successCount < quorum) {
|
|
4181
4181
|
settled = true;
|
|
4182
4182
|
reject(new QuorumNotMet(quorum, successCount, results));
|
|
@@ -4498,7 +4498,7 @@ ${summaryResponse.content}`
|
|
|
4498
4498
|
const schema = options?.schema;
|
|
4499
4499
|
const parentSignal = this.currentSignal;
|
|
4500
4500
|
const composedSignal = parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal;
|
|
4501
|
-
return new Promise((
|
|
4501
|
+
return new Promise((resolve2, reject) => {
|
|
4502
4502
|
let settled = false;
|
|
4503
4503
|
let remaining = fns.length;
|
|
4504
4504
|
for (const fn of fns) {
|
|
@@ -4545,12 +4545,12 @@ ${summaryResponse.content}`
|
|
|
4545
4545
|
if (settled) return;
|
|
4546
4546
|
settled = true;
|
|
4547
4547
|
controller.abort();
|
|
4548
|
-
|
|
4548
|
+
resolve2(parsed.data);
|
|
4549
4549
|
return;
|
|
4550
4550
|
}
|
|
4551
4551
|
settled = true;
|
|
4552
4552
|
controller.abort();
|
|
4553
|
-
|
|
4553
|
+
resolve2(value);
|
|
4554
4554
|
}).catch((err) => {
|
|
4555
4555
|
if (settled) return;
|
|
4556
4556
|
if (err instanceof DOMException && err.name === "AbortError") {
|
|
@@ -4596,9 +4596,9 @@ ${summaryResponse.content}`
|
|
|
4596
4596
|
const controller = quorum ? new AbortController() : void 0;
|
|
4597
4597
|
const parentSignal = this.currentSignal;
|
|
4598
4598
|
const mapSignal = controller ? parentSignal ? AbortSignal.any([parentSignal, controller.signal]) : controller.signal : parentSignal;
|
|
4599
|
-
return new Promise((
|
|
4599
|
+
return new Promise((resolve2, reject) => {
|
|
4600
4600
|
if (items.length === 0) {
|
|
4601
|
-
|
|
4601
|
+
resolve2([]);
|
|
4602
4602
|
return;
|
|
4603
4603
|
}
|
|
4604
4604
|
const runNext = async () => {
|
|
@@ -4619,14 +4619,14 @@ ${summaryResponse.content}`
|
|
|
4619
4619
|
if (quorum && successCount >= quorum) {
|
|
4620
4620
|
settled = true;
|
|
4621
4621
|
controller?.abort();
|
|
4622
|
-
|
|
4622
|
+
resolve2(results);
|
|
4623
4623
|
return;
|
|
4624
4624
|
}
|
|
4625
4625
|
if (completedCount === items.length) {
|
|
4626
4626
|
if (quorum && successCount < quorum) {
|
|
4627
4627
|
reject(new QuorumNotMet(quorum, successCount, results));
|
|
4628
4628
|
} else {
|
|
4629
|
-
|
|
4629
|
+
resolve2(results);
|
|
4630
4630
|
}
|
|
4631
4631
|
return;
|
|
4632
4632
|
}
|
|
@@ -4701,8 +4701,8 @@ ${summaryResponse.content}`
|
|
|
4701
4701
|
type: "await_human",
|
|
4702
4702
|
data: { channel: options.channel, prompt: options.prompt }
|
|
4703
4703
|
});
|
|
4704
|
-
const decision = await new Promise((
|
|
4705
|
-
this.pendingDecisions.set(this.executionId,
|
|
4704
|
+
const decision = await new Promise((resolve2) => {
|
|
4705
|
+
this.pendingDecisions.set(this.executionId, resolve2);
|
|
4706
4706
|
});
|
|
4707
4707
|
this.emitEvent({
|
|
4708
4708
|
type: "await_human_resolved",
|
|
@@ -5954,8 +5954,8 @@ var AxlStream = class _AxlStream extends Readable {
|
|
|
5954
5954
|
} });
|
|
5955
5955
|
let resolvePromise;
|
|
5956
5956
|
let rejectPromise;
|
|
5957
|
-
this.promise = new Promise((
|
|
5958
|
-
resolvePromise =
|
|
5957
|
+
this.promise = new Promise((resolve2, reject) => {
|
|
5958
|
+
resolvePromise = resolve2;
|
|
5959
5959
|
rejectPromise = reject;
|
|
5960
5960
|
});
|
|
5961
5961
|
this.bus.on("__resolve", (value) => resolvePromise(value));
|
|
@@ -5995,8 +5995,8 @@ var AxlStream = class _AxlStream extends Readable {
|
|
|
5995
5995
|
if (self.finished && self.eventQueue.length === 0) {
|
|
5996
5996
|
return Promise.resolve({ value: void 0, done: true });
|
|
5997
5997
|
}
|
|
5998
|
-
return new Promise((
|
|
5999
|
-
self.waiters.push(
|
|
5998
|
+
return new Promise((resolve2) => {
|
|
5999
|
+
self.waiters.push(resolve2);
|
|
6000
6000
|
});
|
|
6001
6001
|
},
|
|
6002
6002
|
[Symbol.asyncIterator]() {
|
|
@@ -6315,7 +6315,7 @@ var StdioMcpClient = class {
|
|
|
6315
6315
|
}
|
|
6316
6316
|
}
|
|
6317
6317
|
sendRequest(method, params, timeoutMs = 3e4) {
|
|
6318
|
-
return new Promise((
|
|
6318
|
+
return new Promise((resolve2, reject) => {
|
|
6319
6319
|
if (!this.process?.stdin?.writable) {
|
|
6320
6320
|
reject(new Error(`MCP server "${this.name}" is not connected`));
|
|
6321
6321
|
return;
|
|
@@ -6336,7 +6336,7 @@ var StdioMcpClient = class {
|
|
|
6336
6336
|
this.pending.set(id, {
|
|
6337
6337
|
resolve: (value) => {
|
|
6338
6338
|
clearTimeout(timer);
|
|
6339
|
-
|
|
6339
|
+
resolve2(value);
|
|
6340
6340
|
},
|
|
6341
6341
|
reject: (err) => {
|
|
6342
6342
|
clearTimeout(timer);
|
|
@@ -7887,6 +7887,124 @@ var AxlRuntime = class extends EventEmitter2 {
|
|
|
7887
7887
|
}
|
|
7888
7888
|
};
|
|
7889
7889
|
|
|
7890
|
+
// src/module-resolve.ts
|
|
7891
|
+
function resolveRuntime(mod) {
|
|
7892
|
+
const def = mod.default;
|
|
7893
|
+
return def?.default ?? def ?? mod.runtime;
|
|
7894
|
+
}
|
|
7895
|
+
function pickDefault(mod) {
|
|
7896
|
+
const def = mod.default;
|
|
7897
|
+
return def?.default ?? def ?? mod.config ?? mod;
|
|
7898
|
+
}
|
|
7899
|
+
function pickExport(mod, key) {
|
|
7900
|
+
const def = mod.default;
|
|
7901
|
+
return mod[key] ?? def?.[key] ?? def?.default?.[key];
|
|
7902
|
+
}
|
|
7903
|
+
|
|
7904
|
+
// src/cli-internals.ts
|
|
7905
|
+
import { resolve, dirname as dirname2, basename } from "path";
|
|
7906
|
+
import { existsSync as existsSync2, readdirSync, statSync } from "fs";
|
|
7907
|
+
import { pathToFileURL } from "url";
|
|
7908
|
+
var CONFIG_CANDIDATES = [
|
|
7909
|
+
"axl.config.mts",
|
|
7910
|
+
"axl.config.ts",
|
|
7911
|
+
"axl.config.mjs",
|
|
7912
|
+
"axl.config.js"
|
|
7913
|
+
];
|
|
7914
|
+
function findConfig(cwd) {
|
|
7915
|
+
for (const name of CONFIG_CANDIDATES) {
|
|
7916
|
+
const p = resolve(cwd, name);
|
|
7917
|
+
if (existsSync2(p)) return p;
|
|
7918
|
+
}
|
|
7919
|
+
return void 0;
|
|
7920
|
+
}
|
|
7921
|
+
function needsTsxLoader(filePath) {
|
|
7922
|
+
return /\.[mc]?tsx?$/.test(filePath);
|
|
7923
|
+
}
|
|
7924
|
+
var tsxRegistered;
|
|
7925
|
+
async function ensureTsxRegistered() {
|
|
7926
|
+
if (tsxRegistered !== void 0) return tsxRegistered;
|
|
7927
|
+
try {
|
|
7928
|
+
const mod = await import("tsx/esm/api");
|
|
7929
|
+
if (typeof mod.register === "function") {
|
|
7930
|
+
mod.register();
|
|
7931
|
+
tsxRegistered = true;
|
|
7932
|
+
} else {
|
|
7933
|
+
tsxRegistered = false;
|
|
7934
|
+
}
|
|
7935
|
+
} catch {
|
|
7936
|
+
tsxRegistered = false;
|
|
7937
|
+
}
|
|
7938
|
+
return tsxRegistered;
|
|
7939
|
+
}
|
|
7940
|
+
async function importModule(filePath, _parentURL) {
|
|
7941
|
+
if (needsTsxLoader(filePath)) {
|
|
7942
|
+
const registered = await ensureTsxRegistered();
|
|
7943
|
+
if (!registered) {
|
|
7944
|
+
throw new Error(
|
|
7945
|
+
`Cannot load TypeScript file ${filePath}: tsx is not installed.
|
|
7946
|
+
Install it as a dev dependency: npm install -D tsx (or pnpm add -D tsx)`
|
|
7947
|
+
);
|
|
7948
|
+
}
|
|
7949
|
+
}
|
|
7950
|
+
return await import(pathToFileURL(filePath).href);
|
|
7951
|
+
}
|
|
7952
|
+
var MAX_GLOB_DEPTH = 20;
|
|
7953
|
+
function expandGlob(pattern, cwd) {
|
|
7954
|
+
if (pattern.includes("**/")) {
|
|
7955
|
+
const sepIdx = pattern.indexOf("**/");
|
|
7956
|
+
const baseDir = resolve(cwd, pattern.slice(0, sepIdx) || ".");
|
|
7957
|
+
const fileGlob2 = pattern.slice(sepIdx + 3) || "*";
|
|
7958
|
+
return findFiles(baseDir, fileGlob2, true);
|
|
7959
|
+
}
|
|
7960
|
+
const dir = resolve(cwd, dirname2(pattern));
|
|
7961
|
+
const fileGlob = basename(pattern);
|
|
7962
|
+
return findFiles(dir, fileGlob, false);
|
|
7963
|
+
}
|
|
7964
|
+
function findFiles(dir, fileGlob, recursive, depth = 0) {
|
|
7965
|
+
if (depth > MAX_GLOB_DEPTH) return [];
|
|
7966
|
+
const matcher = globToRegex(fileGlob);
|
|
7967
|
+
const results = [];
|
|
7968
|
+
try {
|
|
7969
|
+
const entries = readdirSync(dir);
|
|
7970
|
+
for (const entry of entries) {
|
|
7971
|
+
const full = resolve(dir, entry);
|
|
7972
|
+
try {
|
|
7973
|
+
const stat = statSync(full);
|
|
7974
|
+
if (stat.isFile() && matcher.test(entry)) {
|
|
7975
|
+
results.push(full);
|
|
7976
|
+
} else if (stat.isDirectory() && recursive) {
|
|
7977
|
+
results.push(...findFiles(full, fileGlob, true, depth + 1));
|
|
7978
|
+
}
|
|
7979
|
+
} catch {
|
|
7980
|
+
}
|
|
7981
|
+
}
|
|
7982
|
+
} catch {
|
|
7983
|
+
}
|
|
7984
|
+
return results;
|
|
7985
|
+
}
|
|
7986
|
+
function globToRegex(glob) {
|
|
7987
|
+
const escaped = glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
|
|
7988
|
+
return new RegExp(`^${escaped}$`);
|
|
7989
|
+
}
|
|
7990
|
+
async function registerConditions(conditions) {
|
|
7991
|
+
try {
|
|
7992
|
+
const nodeModule = await import("module");
|
|
7993
|
+
const hookCode = [
|
|
7994
|
+
`const extra = ${JSON.stringify(conditions)};`,
|
|
7995
|
+
`export async function resolve(specifier, context, nextResolve) {`,
|
|
7996
|
+
` return nextResolve(specifier, {`,
|
|
7997
|
+
` ...context,`,
|
|
7998
|
+
` conditions: [...new Set([...context.conditions, ...extra])],`,
|
|
7999
|
+
` });`,
|
|
8000
|
+
`}`
|
|
8001
|
+
].join("\n");
|
|
8002
|
+
nodeModule.register(`data:text/javascript,${encodeURIComponent(hookCode)}`);
|
|
8003
|
+
} catch {
|
|
8004
|
+
console.warn("Warning: --conditions requires Node.js 20.6+");
|
|
8005
|
+
}
|
|
8006
|
+
}
|
|
8007
|
+
|
|
7890
8008
|
// src/state/redis.ts
|
|
7891
8009
|
var RedisStore = class _RedisStore {
|
|
7892
8010
|
constructor(client) {
|
|
@@ -8244,6 +8362,7 @@ export {
|
|
|
8244
8362
|
AxlRuntime,
|
|
8245
8363
|
AxlStream,
|
|
8246
8364
|
BudgetExceededError,
|
|
8365
|
+
CONFIG_CANDIDATES,
|
|
8247
8366
|
COST_BEARING_LEAF_TYPES,
|
|
8248
8367
|
GeminiProvider,
|
|
8249
8368
|
GuardrailError,
|
|
@@ -8274,11 +8393,19 @@ export {
|
|
|
8274
8393
|
createSpanManager,
|
|
8275
8394
|
defineConfig,
|
|
8276
8395
|
eventCostContribution,
|
|
8396
|
+
expandGlob,
|
|
8277
8397
|
extractJson,
|
|
8398
|
+
findConfig,
|
|
8399
|
+
importModule,
|
|
8278
8400
|
isCostBearingLeaf,
|
|
8279
8401
|
isRootLevel,
|
|
8402
|
+
needsTsxLoader,
|
|
8280
8403
|
parsePartialJson,
|
|
8404
|
+
pickDefault,
|
|
8405
|
+
pickExport,
|
|
8281
8406
|
redactEvent,
|
|
8407
|
+
registerConditions,
|
|
8408
|
+
resolveRuntime,
|
|
8282
8409
|
resolveThinkingOptions,
|
|
8283
8410
|
tool,
|
|
8284
8411
|
workflow,
|