@swmansion/argent 0.35.1-next.85 → 0.35.1-next.86
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/cli-cmds.mjs +33 -4
- package/dist/client.js +24 -0
- package/dist/installer.mjs +3 -1
- package/dist/mcp-server.mjs +66 -5
- package/dist/tool-args.generated.d.ts +4 -0
- package/dist/tool-server.cjs +788 -355
- package/package.json +2 -2
package/dist/cli-cmds.mjs
CHANGED
|
@@ -12768,6 +12768,10 @@ import * as path14 from "node:path";
|
|
|
12768
12768
|
var LINKED_CALL_HEADER = "x-argent-linked";
|
|
12769
12769
|
var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
|
|
12770
12770
|
var CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
|
|
12771
|
+
var SESSION_HEADER = "x-argent-session";
|
|
12772
|
+
function isValidSession(session) {
|
|
12773
|
+
return /^[\x21-\x7e]{1,128}$/.test(session);
|
|
12774
|
+
}
|
|
12771
12775
|
var CLIENT_SECRET_SOURCES_HEADER = "x-argent-client-secret-sources";
|
|
12772
12776
|
|
|
12773
12777
|
// ../registry/src/artifacts.ts
|
|
@@ -13052,6 +13056,8 @@ var FAILURE_CODES = {
|
|
|
13052
13056
|
HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
|
|
13053
13057
|
HTTP_DEVICE_RESOLUTION_FAILED: "HTTP_DEVICE_RESOLUTION_FAILED",
|
|
13054
13058
|
HTTP_DEPENDENCY_PREFLIGHT_MISSING: "HTTP_DEPENDENCY_PREFLIGHT_MISSING",
|
|
13059
|
+
// Another session holds a claim on the device the call names.
|
|
13060
|
+
DEVICE_IN_USE: "DEVICE_IN_USE",
|
|
13055
13061
|
// The client's POST /upload of a file input was refused, so the call was not sent.
|
|
13056
13062
|
FILE_INPUT_UPLOAD_FAILED: "FILE_INPUT_UPLOAD_FAILED",
|
|
13057
13063
|
CLI_RUN_TOOL_NOT_FOUND: "CLI_RUN_TOOL_NOT_FOUND",
|
|
@@ -33835,6 +33841,9 @@ function removePendingArchives() {
|
|
|
33835
33841
|
function removeArchivesOnSignal(signal) {
|
|
33836
33842
|
removePendingArchives();
|
|
33837
33843
|
if (process.listenerCount(signal) > 0) return;
|
|
33844
|
+
raiseSignal(signal);
|
|
33845
|
+
}
|
|
33846
|
+
function raiseSignal(signal) {
|
|
33838
33847
|
try {
|
|
33839
33848
|
process.kill(process.pid, signal);
|
|
33840
33849
|
} catch {
|
|
@@ -34860,6 +34869,19 @@ function failedRun(result) {
|
|
|
34860
34869
|
}
|
|
34861
34870
|
return result;
|
|
34862
34871
|
}
|
|
34872
|
+
function sessionFromEnv() {
|
|
34873
|
+
const session = process.env.ARGENT_SESSION?.trim();
|
|
34874
|
+
if (!session) return void 0;
|
|
34875
|
+
if (!isValidSession(session)) {
|
|
34876
|
+
throw new ToolInvocationError(
|
|
34877
|
+
"ARGENT_SESSION must be 1 to 128 printable ASCII characters without spaces."
|
|
34878
|
+
);
|
|
34879
|
+
}
|
|
34880
|
+
return session;
|
|
34881
|
+
}
|
|
34882
|
+
function hasSessionHeader(headers) {
|
|
34883
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === SESSION_HEADER);
|
|
34884
|
+
}
|
|
34863
34885
|
function createToolsClient(options = {}) {
|
|
34864
34886
|
let cached3 = null;
|
|
34865
34887
|
let linkedNoticeShown = false;
|
|
@@ -34916,6 +34938,7 @@ function createToolsClient(options = {}) {
|
|
|
34916
34938
|
async function callTool(name, args, opts) {
|
|
34917
34939
|
opts?.signal?.throwIfAborted();
|
|
34918
34940
|
assertFiniteNumbers(args);
|
|
34941
|
+
const envSession = options.ignoreEnvSession || hasSessionHeader(options.headers?.() ?? {}) ? void 0 : sessionFromEnv();
|
|
34919
34942
|
const { url: url2, token, remote } = await route();
|
|
34920
34943
|
let finalArgs = canonicalToolArgs(name, args);
|
|
34921
34944
|
const { tools: tools2, uploadFormats } = await fetchToolList({ signal: opts?.signal });
|
|
@@ -34992,6 +35015,7 @@ function createToolsClient(options = {}) {
|
|
|
34992
35015
|
}
|
|
34993
35016
|
const toolUrl = `${url2}/tools/${encodeURIComponent(meta3?.name ?? name)}`;
|
|
34994
35017
|
const headers = {
|
|
35018
|
+
...envSession ? { [SESSION_HEADER]: envSession } : {},
|
|
34995
35019
|
...options.headers?.(),
|
|
34996
35020
|
"Content-Type": "application/json",
|
|
34997
35021
|
// Tells the tool-server the call came over a link, a link to
|
|
@@ -39122,7 +39146,7 @@ function isCi(env = process.env) {
|
|
|
39122
39146
|
var SESSION_ID2 = randomUUID5();
|
|
39123
39147
|
function readCliVersion() {
|
|
39124
39148
|
if (true) {
|
|
39125
|
-
return "0.35.1-next.
|
|
39149
|
+
return "0.35.1-next.86";
|
|
39126
39150
|
}
|
|
39127
39151
|
return "0.0.0";
|
|
39128
39152
|
}
|
|
@@ -42023,6 +42047,12 @@ var SAFE_TOOL_RE = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
|
42023
42047
|
function safeToolName(toolName) {
|
|
42024
42048
|
return toolName && SAFE_TOOL_RE.test(toolName) ? toolName : "unknown";
|
|
42025
42049
|
}
|
|
42050
|
+
function callFailureSignal(err) {
|
|
42051
|
+
if (err instanceof ToolInvocationError && err.errorCode === FAILURE_CODES.DEVICE_IN_USE) {
|
|
42052
|
+
return { error_code: FAILURE_CODES.DEVICE_IN_USE, error_kind: "validation" };
|
|
42053
|
+
}
|
|
42054
|
+
return { error_code: FAILURE_CODES.CLI_RUN_TOOL_CALL_FAILED, error_kind: "unknown" };
|
|
42055
|
+
}
|
|
42026
42056
|
async function trackRunFailure(toolName, startedAt, signal) {
|
|
42027
42057
|
const tool = toolName ? canonicalToolId(toolName) : toolName;
|
|
42028
42058
|
track("cli:run_fail", {
|
|
@@ -42236,10 +42266,9 @@ settled=false or debugger-status's not_connected.
|
|
|
42236
42266
|
}
|
|
42237
42267
|
console.error(err instanceof Error ? err.message : String(err));
|
|
42238
42268
|
await trackRunFailure(toolName, startedAt, {
|
|
42239
|
-
|
|
42269
|
+
...callFailureSignal(err),
|
|
42240
42270
|
failure_stage: "cli_run_call_tool",
|
|
42241
|
-
failure_area: "cli"
|
|
42242
|
-
error_kind: "unknown"
|
|
42271
|
+
failure_area: "cli"
|
|
42243
42272
|
});
|
|
42244
42273
|
process.exit(1);
|
|
42245
42274
|
}
|
package/dist/client.js
CHANGED
|
@@ -9069,6 +9069,10 @@ import * as path14 from "node:path";
|
|
|
9069
9069
|
var LINKED_CALL_HEADER = "x-argent-linked";
|
|
9070
9070
|
var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
|
|
9071
9071
|
var CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
|
|
9072
|
+
var SESSION_HEADER = "x-argent-session";
|
|
9073
|
+
function isValidSession(session) {
|
|
9074
|
+
return /^[\x21-\x7e]{1,128}$/.test(session);
|
|
9075
|
+
}
|
|
9072
9076
|
var CLIENT_SECRET_SOURCES_HEADER = "x-argent-client-secret-sources";
|
|
9073
9077
|
|
|
9074
9078
|
// ../registry/src/artifacts.ts
|
|
@@ -9350,6 +9354,8 @@ var FAILURE_CODES = {
|
|
|
9350
9354
|
HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
|
|
9351
9355
|
HTTP_DEVICE_RESOLUTION_FAILED: "HTTP_DEVICE_RESOLUTION_FAILED",
|
|
9352
9356
|
HTTP_DEPENDENCY_PREFLIGHT_MISSING: "HTTP_DEPENDENCY_PREFLIGHT_MISSING",
|
|
9357
|
+
// Another session holds a claim on the device the call names.
|
|
9358
|
+
DEVICE_IN_USE: "DEVICE_IN_USE",
|
|
9353
9359
|
// The client's POST /upload of a file input was refused, so the call was not sent.
|
|
9354
9360
|
FILE_INPUT_UPLOAD_FAILED: "FILE_INPUT_UPLOAD_FAILED",
|
|
9355
9361
|
CLI_RUN_TOOL_NOT_FOUND: "CLI_RUN_TOOL_NOT_FOUND",
|
|
@@ -10304,6 +10310,9 @@ function removePendingArchives() {
|
|
|
10304
10310
|
function removeArchivesOnSignal(signal) {
|
|
10305
10311
|
removePendingArchives();
|
|
10306
10312
|
if (process.listenerCount(signal) > 0) return;
|
|
10313
|
+
raiseSignal(signal);
|
|
10314
|
+
}
|
|
10315
|
+
function raiseSignal(signal) {
|
|
10307
10316
|
try {
|
|
10308
10317
|
process.kill(process.pid, signal);
|
|
10309
10318
|
} catch {
|
|
@@ -11329,6 +11338,19 @@ function failedRun(result) {
|
|
|
11329
11338
|
}
|
|
11330
11339
|
return result;
|
|
11331
11340
|
}
|
|
11341
|
+
function sessionFromEnv() {
|
|
11342
|
+
const session = process.env.ARGENT_SESSION?.trim();
|
|
11343
|
+
if (!session) return void 0;
|
|
11344
|
+
if (!isValidSession(session)) {
|
|
11345
|
+
throw new ToolInvocationError(
|
|
11346
|
+
"ARGENT_SESSION must be 1 to 128 printable ASCII characters without spaces."
|
|
11347
|
+
);
|
|
11348
|
+
}
|
|
11349
|
+
return session;
|
|
11350
|
+
}
|
|
11351
|
+
function hasSessionHeader(headers) {
|
|
11352
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === SESSION_HEADER);
|
|
11353
|
+
}
|
|
11332
11354
|
function createToolsClient(options = {}) {
|
|
11333
11355
|
let cached = null;
|
|
11334
11356
|
let linkedNoticeShown = false;
|
|
@@ -11385,6 +11407,7 @@ function createToolsClient(options = {}) {
|
|
|
11385
11407
|
async function callTool(name, args, opts) {
|
|
11386
11408
|
opts?.signal?.throwIfAborted();
|
|
11387
11409
|
assertFiniteNumbers(args);
|
|
11410
|
+
const envSession = options.ignoreEnvSession || hasSessionHeader(options.headers?.() ?? {}) ? void 0 : sessionFromEnv();
|
|
11388
11411
|
const { url, token, remote } = await route();
|
|
11389
11412
|
let finalArgs = canonicalToolArgs(name, args);
|
|
11390
11413
|
const { tools, uploadFormats } = await fetchToolList({ signal: opts?.signal });
|
|
@@ -11461,6 +11484,7 @@ function createToolsClient(options = {}) {
|
|
|
11461
11484
|
}
|
|
11462
11485
|
const toolUrl = `${url}/tools/${encodeURIComponent(meta?.name ?? name)}`;
|
|
11463
11486
|
const headers = {
|
|
11487
|
+
...envSession ? { [SESSION_HEADER]: envSession } : {},
|
|
11464
11488
|
...options.headers?.(),
|
|
11465
11489
|
"Content-Type": "application/json",
|
|
11466
11490
|
// Tells the tool-server the call came over a link, a link to
|
package/dist/installer.mjs
CHANGED
|
@@ -15894,6 +15894,8 @@ var FAILURE_CODES = {
|
|
|
15894
15894
|
HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
|
|
15895
15895
|
HTTP_DEVICE_RESOLUTION_FAILED: "HTTP_DEVICE_RESOLUTION_FAILED",
|
|
15896
15896
|
HTTP_DEPENDENCY_PREFLIGHT_MISSING: "HTTP_DEPENDENCY_PREFLIGHT_MISSING",
|
|
15897
|
+
// Another session holds a claim on the device the call names.
|
|
15898
|
+
DEVICE_IN_USE: "DEVICE_IN_USE",
|
|
15897
15899
|
// The client's POST /upload of a file input was refused, so the call was not sent.
|
|
15898
15900
|
FILE_INPUT_UPLOAD_FAILED: "FILE_INPUT_UPLOAD_FAILED",
|
|
15899
15901
|
CLI_RUN_TOOL_NOT_FOUND: "CLI_RUN_TOOL_NOT_FOUND",
|
|
@@ -17175,7 +17177,7 @@ function isCi(env = process.env) {
|
|
|
17175
17177
|
var SESSION_ID = randomUUID4();
|
|
17176
17178
|
function readCliVersion() {
|
|
17177
17179
|
if (true) {
|
|
17178
|
-
return "0.35.1-next.
|
|
17180
|
+
return "0.35.1-next.86";
|
|
17179
17181
|
}
|
|
17180
17182
|
return "0.0.0";
|
|
17181
17183
|
}
|
package/dist/mcp-server.mjs
CHANGED
|
@@ -32308,7 +32308,7 @@ function configFilePath(scope = "global", options = {}) {
|
|
|
32308
32308
|
}
|
|
32309
32309
|
|
|
32310
32310
|
// ../configuration-core/src/config.ts
|
|
32311
|
-
import * as
|
|
32311
|
+
import * as crypto2 from "node:crypto";
|
|
32312
32312
|
import * as fs4 from "node:fs";
|
|
32313
32313
|
import * as path4 from "node:path";
|
|
32314
32314
|
function readConfigObject(scope = "global", options = {}) {
|
|
@@ -32410,7 +32410,7 @@ function updateConfig(mutate, scope = "global", options = {}) {
|
|
|
32410
32410
|
try {
|
|
32411
32411
|
const next = readConfigObject(scope, options);
|
|
32412
32412
|
mutate(next);
|
|
32413
|
-
const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${
|
|
32413
|
+
const tmpPath = path4.join(dir, `.config.tmp.${process.pid}.${crypto2.randomUUID()}`);
|
|
32414
32414
|
const fd = fs4.openSync(tmpPath, "wx", 384);
|
|
32415
32415
|
try {
|
|
32416
32416
|
fs4.writeSync(fd, JSON.stringify(next, null, 2) + "\n");
|
|
@@ -33503,6 +33503,10 @@ import * as path14 from "node:path";
|
|
|
33503
33503
|
var LINKED_CALL_HEADER = "x-argent-linked";
|
|
33504
33504
|
var E2E_DIR_CLIENT_HEADER = "x-argent-e2e-dir";
|
|
33505
33505
|
var CLIENT_SECRETS_HEADER = "x-argent-client-secrets";
|
|
33506
|
+
var SESSION_HEADER = "x-argent-session";
|
|
33507
|
+
function isValidSession(session) {
|
|
33508
|
+
return /^[\x21-\x7e]{1,128}$/.test(session);
|
|
33509
|
+
}
|
|
33506
33510
|
var CLIENT_SECRET_SOURCES_HEADER = "x-argent-client-secret-sources";
|
|
33507
33511
|
|
|
33508
33512
|
// ../registry/src/artifacts.ts
|
|
@@ -33784,6 +33788,8 @@ var FAILURE_CODES = {
|
|
|
33784
33788
|
HTTP_CAPABILITY_UNSUPPORTED_OPERATION: "HTTP_CAPABILITY_UNSUPPORTED_OPERATION",
|
|
33785
33789
|
HTTP_DEVICE_RESOLUTION_FAILED: "HTTP_DEVICE_RESOLUTION_FAILED",
|
|
33786
33790
|
HTTP_DEPENDENCY_PREFLIGHT_MISSING: "HTTP_DEPENDENCY_PREFLIGHT_MISSING",
|
|
33791
|
+
// Another session holds a claim on the device the call names.
|
|
33792
|
+
DEVICE_IN_USE: "DEVICE_IN_USE",
|
|
33787
33793
|
// The client's POST /upload of a file input was refused, so the call was not sent.
|
|
33788
33794
|
FILE_INPUT_UPLOAD_FAILED: "FILE_INPUT_UPLOAD_FAILED",
|
|
33789
33795
|
CLI_RUN_TOOL_NOT_FOUND: "CLI_RUN_TOOL_NOT_FOUND",
|
|
@@ -34788,6 +34794,9 @@ function removePendingArchives() {
|
|
|
34788
34794
|
function removeArchivesOnSignal(signal) {
|
|
34789
34795
|
removePendingArchives();
|
|
34790
34796
|
if (process.listenerCount(signal) > 0) return;
|
|
34797
|
+
raiseSignal(signal);
|
|
34798
|
+
}
|
|
34799
|
+
function raiseSignal(signal) {
|
|
34791
34800
|
try {
|
|
34792
34801
|
process.kill(process.pid, signal);
|
|
34793
34802
|
} catch {
|
|
@@ -35813,6 +35822,19 @@ function failedRun(result) {
|
|
|
35813
35822
|
}
|
|
35814
35823
|
return result;
|
|
35815
35824
|
}
|
|
35825
|
+
function sessionFromEnv() {
|
|
35826
|
+
const session = process.env.ARGENT_SESSION?.trim();
|
|
35827
|
+
if (!session) return void 0;
|
|
35828
|
+
if (!isValidSession(session)) {
|
|
35829
|
+
throw new ToolInvocationError(
|
|
35830
|
+
"ARGENT_SESSION must be 1 to 128 printable ASCII characters without spaces."
|
|
35831
|
+
);
|
|
35832
|
+
}
|
|
35833
|
+
return session;
|
|
35834
|
+
}
|
|
35835
|
+
function hasSessionHeader(headers) {
|
|
35836
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === SESSION_HEADER);
|
|
35837
|
+
}
|
|
35816
35838
|
function createToolsClient(options = {}) {
|
|
35817
35839
|
let cached2 = null;
|
|
35818
35840
|
let linkedNoticeShown = false;
|
|
@@ -35869,6 +35891,7 @@ function createToolsClient(options = {}) {
|
|
|
35869
35891
|
async function callTool(name, args, opts) {
|
|
35870
35892
|
opts?.signal?.throwIfAborted();
|
|
35871
35893
|
assertFiniteNumbers(args);
|
|
35894
|
+
const envSession = options.ignoreEnvSession || hasSessionHeader(options.headers?.() ?? {}) ? void 0 : sessionFromEnv();
|
|
35872
35895
|
const { url, token, remote } = await route();
|
|
35873
35896
|
let finalArgs = canonicalToolArgs(name, args);
|
|
35874
35897
|
const { tools, uploadFormats } = await fetchToolList({ signal: opts?.signal });
|
|
@@ -35945,6 +35968,7 @@ function createToolsClient(options = {}) {
|
|
|
35945
35968
|
}
|
|
35946
35969
|
const toolUrl = `${url}/tools/${encodeURIComponent(meta2?.name ?? name)}`;
|
|
35947
35970
|
const headers = {
|
|
35971
|
+
...envSession ? { [SESSION_HEADER]: envSession } : {},
|
|
35948
35972
|
...options.headers?.(),
|
|
35949
35973
|
"Content-Type": "application/json",
|
|
35950
35974
|
// Tells the tool-server the call came over a link, a link to
|
|
@@ -36867,7 +36891,7 @@ import { existsSync as existsSync4 } from "node:fs";
|
|
|
36867
36891
|
var SESSION_ID2 = randomUUID5();
|
|
36868
36892
|
|
|
36869
36893
|
// ../telemetry/src/identity.ts
|
|
36870
|
-
import * as
|
|
36894
|
+
import * as crypto3 from "node:crypto";
|
|
36871
36895
|
import * as fs12 from "node:fs";
|
|
36872
36896
|
import * as path16 from "node:path";
|
|
36873
36897
|
|
|
@@ -38371,6 +38395,7 @@ function createToolCaller(deps) {
|
|
|
38371
38395
|
const client = createToolsClient({
|
|
38372
38396
|
baseUrl: async () => ({ ...deps.getHandle(), remote: deps.remote }),
|
|
38373
38397
|
headers: deps.extraHeaders,
|
|
38398
|
+
ignoreEnvSession: true,
|
|
38374
38399
|
refuseRelativeProjectPaths: true,
|
|
38375
38400
|
fetchImpl: async (url, init, meta2) => {
|
|
38376
38401
|
parseUrl(url);
|
|
@@ -38393,6 +38418,19 @@ function createToolCaller(deps) {
|
|
|
38393
38418
|
};
|
|
38394
38419
|
}
|
|
38395
38420
|
|
|
38421
|
+
// ../argent-mcp/src/release-on-exit.ts
|
|
38422
|
+
var EXIT_SIGNALS = ["SIGTERM", "SIGINT", "SIGHUP"];
|
|
38423
|
+
function releaseOnExit(release) {
|
|
38424
|
+
process.stdin.on("close", () => void release());
|
|
38425
|
+
function releaseThenRaise(signal) {
|
|
38426
|
+
void release().finally(() => {
|
|
38427
|
+
for (const s of EXIT_SIGNALS) process.removeListener(s, releaseThenRaise);
|
|
38428
|
+
raiseSignal(signal);
|
|
38429
|
+
});
|
|
38430
|
+
}
|
|
38431
|
+
for (const signal of EXIT_SIGNALS) process.on(signal, releaseThenRaise);
|
|
38432
|
+
}
|
|
38433
|
+
|
|
38396
38434
|
// ../argent-mcp/src/call-log.ts
|
|
38397
38435
|
import {
|
|
38398
38436
|
appendFileSync as appendFileSync2,
|
|
@@ -38549,7 +38587,7 @@ async function startMcpServer(options) {
|
|
|
38549
38587
|
const autoDescribeOn = autoDescribeEnabled();
|
|
38550
38588
|
const whatsNewOn = whatsNewEnabled();
|
|
38551
38589
|
const installedVersion = getInstalledVersion();
|
|
38552
|
-
const highlightsVersion = true ? "0.35.1-next.
|
|
38590
|
+
const highlightsVersion = true ? "0.35.1-next.86" : installedVersion;
|
|
38553
38591
|
const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
|
|
38554
38592
|
const trees = createTreeMemory();
|
|
38555
38593
|
const screenshots = createScreenshotMemory();
|
|
@@ -38584,6 +38622,13 @@ async function startMcpServer(options) {
|
|
|
38584
38622
|
if (rawName) return { "X-Argent-AI-Client": "other" };
|
|
38585
38623
|
return {};
|
|
38586
38624
|
}
|
|
38625
|
+
const sessionId2 = crypto.randomUUID();
|
|
38626
|
+
let sessionCalledTools = false;
|
|
38627
|
+
let sessionEnded = false;
|
|
38628
|
+
function callerHeaders() {
|
|
38629
|
+
if (sessionEnded) return aiClientHeaders();
|
|
38630
|
+
return { ...aiClientHeaders(), [SESSION_HEADER]: sessionId2 };
|
|
38631
|
+
}
|
|
38587
38632
|
let reconnectPromise = null;
|
|
38588
38633
|
async function reconnect() {
|
|
38589
38634
|
if (remote) return;
|
|
@@ -38603,7 +38648,7 @@ async function startMcpServer(options) {
|
|
|
38603
38648
|
getHandle: () => ({ url: TOOLS_URL, token: AUTH_TOKEN }),
|
|
38604
38649
|
remote,
|
|
38605
38650
|
reconnect,
|
|
38606
|
-
extraHeaders:
|
|
38651
|
+
extraHeaders: callerHeaders
|
|
38607
38652
|
});
|
|
38608
38653
|
const callForCapture = async (name, args, signal) => (await callTool(name, args, { signal })).result;
|
|
38609
38654
|
async function logReadiness(toolName, settled) {
|
|
@@ -38727,6 +38772,7 @@ ${shown.text}` }];
|
|
|
38727
38772
|
});
|
|
38728
38773
|
server.setRequestHandler(CallToolRequestSchema, async ({ params }, { signal }) => {
|
|
38729
38774
|
const t0 = Date.now();
|
|
38775
|
+
sessionCalledTools = true;
|
|
38730
38776
|
const callSignal = SAVES_FILES_AFTER_CANCEL.has(canonicalToolId(params.name)) ? void 0 : signal;
|
|
38731
38777
|
let treeUdid;
|
|
38732
38778
|
let screenshotUdid;
|
|
@@ -38868,6 +38914,21 @@ ${shown.text}` }];
|
|
|
38868
38914
|
}, HEALTH_INTERVAL_MS);
|
|
38869
38915
|
healthInterval.unref();
|
|
38870
38916
|
}
|
|
38917
|
+
let release;
|
|
38918
|
+
function releaseSessionDevices() {
|
|
38919
|
+
if (!sessionCalledTools) return Promise.resolve();
|
|
38920
|
+
release ??= fetch(`${TOOLS_URL}/tools/release-device`, {
|
|
38921
|
+
method: "POST",
|
|
38922
|
+
headers: { ...authHeader(), ...callerHeaders(), "Content-Type": "application/json" },
|
|
38923
|
+
body: "{}",
|
|
38924
|
+
signal: AbortSignal.timeout(2e3)
|
|
38925
|
+
}).catch(() => {
|
|
38926
|
+
});
|
|
38927
|
+
sessionEnded = true;
|
|
38928
|
+
return release;
|
|
38929
|
+
}
|
|
38930
|
+
server.onclose = () => void releaseSessionDevices();
|
|
38931
|
+
if (!options.transport) releaseOnExit(releaseSessionDevices);
|
|
38871
38932
|
if (process.env.ARGENT_TOOL_SERVER_SHUTDOWN_ON_MCP_EXIT === "1") {
|
|
38872
38933
|
process.stdin.on("close", () => {
|
|
38873
38934
|
fetch(`${TOOLS_URL}/shutdown`, { method: "POST", headers: authHeader() }).catch(() => {
|
|
@@ -1014,6 +1014,10 @@ export interface ArgentToolArgs {
|
|
|
1014
1014
|
/** Path to `.app` (iOS), `.apk` (Android), `.vpkg` (Vega), or `.hap` (HarmonyOS). */
|
|
1015
1015
|
appPath: string;
|
|
1016
1016
|
};
|
|
1017
|
+
"release-device": {
|
|
1018
|
+
/** The device to release. Omit it to release every device of the session. */
|
|
1019
|
+
udid?: string;
|
|
1020
|
+
};
|
|
1017
1021
|
"restart-app": {
|
|
1018
1022
|
/** Target device id from `list-devices`. */
|
|
1019
1023
|
udid: string;
|