@swmansion/argent 0.35.1-next.85 → 0.35.1-next.87
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 +35 -5
- package/dist/client.js +26 -1
- package/dist/installer.mjs +3 -1
- package/dist/mcp-server.mjs +68 -6
- package/dist/tool-args.generated.d.ts +4 -0
- package/dist/tool-server.cjs +826 -371
- 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",
|
|
@@ -33617,7 +33623,8 @@ function tarEnv(env) {
|
|
|
33617
33623
|
async function runTar(archive, args, signal) {
|
|
33618
33624
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
33619
33625
|
signal,
|
|
33620
|
-
env: tarEnv(process.env)
|
|
33626
|
+
env: tarEnv(process.env),
|
|
33627
|
+
windowsHide: true
|
|
33621
33628
|
});
|
|
33622
33629
|
let childError;
|
|
33623
33630
|
child.on("error", (err) => {
|
|
@@ -33835,6 +33842,9 @@ function removePendingArchives() {
|
|
|
33835
33842
|
function removeArchivesOnSignal(signal) {
|
|
33836
33843
|
removePendingArchives();
|
|
33837
33844
|
if (process.listenerCount(signal) > 0) return;
|
|
33845
|
+
raiseSignal(signal);
|
|
33846
|
+
}
|
|
33847
|
+
function raiseSignal(signal) {
|
|
33838
33848
|
try {
|
|
33839
33849
|
process.kill(process.pid, signal);
|
|
33840
33850
|
} catch {
|
|
@@ -34860,6 +34870,19 @@ function failedRun(result) {
|
|
|
34860
34870
|
}
|
|
34861
34871
|
return result;
|
|
34862
34872
|
}
|
|
34873
|
+
function sessionFromEnv() {
|
|
34874
|
+
const session = process.env.ARGENT_SESSION?.trim();
|
|
34875
|
+
if (!session) return void 0;
|
|
34876
|
+
if (!isValidSession(session)) {
|
|
34877
|
+
throw new ToolInvocationError(
|
|
34878
|
+
"ARGENT_SESSION must be 1 to 128 printable ASCII characters without spaces."
|
|
34879
|
+
);
|
|
34880
|
+
}
|
|
34881
|
+
return session;
|
|
34882
|
+
}
|
|
34883
|
+
function hasSessionHeader(headers) {
|
|
34884
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === SESSION_HEADER);
|
|
34885
|
+
}
|
|
34863
34886
|
function createToolsClient(options = {}) {
|
|
34864
34887
|
let cached3 = null;
|
|
34865
34888
|
let linkedNoticeShown = false;
|
|
@@ -34916,6 +34939,7 @@ function createToolsClient(options = {}) {
|
|
|
34916
34939
|
async function callTool(name, args, opts) {
|
|
34917
34940
|
opts?.signal?.throwIfAborted();
|
|
34918
34941
|
assertFiniteNumbers(args);
|
|
34942
|
+
const envSession = options.ignoreEnvSession || hasSessionHeader(options.headers?.() ?? {}) ? void 0 : sessionFromEnv();
|
|
34919
34943
|
const { url: url2, token, remote } = await route();
|
|
34920
34944
|
let finalArgs = canonicalToolArgs(name, args);
|
|
34921
34945
|
const { tools: tools2, uploadFormats } = await fetchToolList({ signal: opts?.signal });
|
|
@@ -34992,6 +35016,7 @@ function createToolsClient(options = {}) {
|
|
|
34992
35016
|
}
|
|
34993
35017
|
const toolUrl = `${url2}/tools/${encodeURIComponent(meta3?.name ?? name)}`;
|
|
34994
35018
|
const headers = {
|
|
35019
|
+
...envSession ? { [SESSION_HEADER]: envSession } : {},
|
|
34995
35020
|
...options.headers?.(),
|
|
34996
35021
|
"Content-Type": "application/json",
|
|
34997
35022
|
// Tells the tool-server the call came over a link, a link to
|
|
@@ -39122,7 +39147,7 @@ function isCi(env = process.env) {
|
|
|
39122
39147
|
var SESSION_ID2 = randomUUID5();
|
|
39123
39148
|
function readCliVersion() {
|
|
39124
39149
|
if (true) {
|
|
39125
|
-
return "0.35.1-next.
|
|
39150
|
+
return "0.35.1-next.86";
|
|
39126
39151
|
}
|
|
39127
39152
|
return "0.0.0";
|
|
39128
39153
|
}
|
|
@@ -42023,6 +42048,12 @@ var SAFE_TOOL_RE = /^[a-z][a-z0-9_-]{0,63}$/;
|
|
|
42023
42048
|
function safeToolName(toolName) {
|
|
42024
42049
|
return toolName && SAFE_TOOL_RE.test(toolName) ? toolName : "unknown";
|
|
42025
42050
|
}
|
|
42051
|
+
function callFailureSignal(err) {
|
|
42052
|
+
if (err instanceof ToolInvocationError && err.errorCode === FAILURE_CODES.DEVICE_IN_USE) {
|
|
42053
|
+
return { error_code: FAILURE_CODES.DEVICE_IN_USE, error_kind: "validation" };
|
|
42054
|
+
}
|
|
42055
|
+
return { error_code: FAILURE_CODES.CLI_RUN_TOOL_CALL_FAILED, error_kind: "unknown" };
|
|
42056
|
+
}
|
|
42026
42057
|
async function trackRunFailure(toolName, startedAt, signal) {
|
|
42027
42058
|
const tool = toolName ? canonicalToolId(toolName) : toolName;
|
|
42028
42059
|
track("cli:run_fail", {
|
|
@@ -42236,10 +42267,9 @@ settled=false or debugger-status's not_connected.
|
|
|
42236
42267
|
}
|
|
42237
42268
|
console.error(err instanceof Error ? err.message : String(err));
|
|
42238
42269
|
await trackRunFailure(toolName, startedAt, {
|
|
42239
|
-
|
|
42270
|
+
...callFailureSignal(err),
|
|
42240
42271
|
failure_stage: "cli_run_call_tool",
|
|
42241
|
-
failure_area: "cli"
|
|
42242
|
-
error_kind: "unknown"
|
|
42272
|
+
failure_area: "cli"
|
|
42243
42273
|
});
|
|
42244
42274
|
process.exit(1);
|
|
42245
42275
|
}
|
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",
|
|
@@ -10086,7 +10092,8 @@ function tarEnv(env) {
|
|
|
10086
10092
|
async function runTar(archive, args, signal) {
|
|
10087
10093
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
10088
10094
|
signal,
|
|
10089
|
-
env: tarEnv(process.env)
|
|
10095
|
+
env: tarEnv(process.env),
|
|
10096
|
+
windowsHide: true
|
|
10090
10097
|
});
|
|
10091
10098
|
let childError;
|
|
10092
10099
|
child.on("error", (err) => {
|
|
@@ -10304,6 +10311,9 @@ function removePendingArchives() {
|
|
|
10304
10311
|
function removeArchivesOnSignal(signal) {
|
|
10305
10312
|
removePendingArchives();
|
|
10306
10313
|
if (process.listenerCount(signal) > 0) return;
|
|
10314
|
+
raiseSignal(signal);
|
|
10315
|
+
}
|
|
10316
|
+
function raiseSignal(signal) {
|
|
10307
10317
|
try {
|
|
10308
10318
|
process.kill(process.pid, signal);
|
|
10309
10319
|
} catch {
|
|
@@ -11329,6 +11339,19 @@ function failedRun(result) {
|
|
|
11329
11339
|
}
|
|
11330
11340
|
return result;
|
|
11331
11341
|
}
|
|
11342
|
+
function sessionFromEnv() {
|
|
11343
|
+
const session = process.env.ARGENT_SESSION?.trim();
|
|
11344
|
+
if (!session) return void 0;
|
|
11345
|
+
if (!isValidSession(session)) {
|
|
11346
|
+
throw new ToolInvocationError(
|
|
11347
|
+
"ARGENT_SESSION must be 1 to 128 printable ASCII characters without spaces."
|
|
11348
|
+
);
|
|
11349
|
+
}
|
|
11350
|
+
return session;
|
|
11351
|
+
}
|
|
11352
|
+
function hasSessionHeader(headers) {
|
|
11353
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === SESSION_HEADER);
|
|
11354
|
+
}
|
|
11332
11355
|
function createToolsClient(options = {}) {
|
|
11333
11356
|
let cached = null;
|
|
11334
11357
|
let linkedNoticeShown = false;
|
|
@@ -11385,6 +11408,7 @@ function createToolsClient(options = {}) {
|
|
|
11385
11408
|
async function callTool(name, args, opts) {
|
|
11386
11409
|
opts?.signal?.throwIfAborted();
|
|
11387
11410
|
assertFiniteNumbers(args);
|
|
11411
|
+
const envSession = options.ignoreEnvSession || hasSessionHeader(options.headers?.() ?? {}) ? void 0 : sessionFromEnv();
|
|
11388
11412
|
const { url, token, remote } = await route();
|
|
11389
11413
|
let finalArgs = canonicalToolArgs(name, args);
|
|
11390
11414
|
const { tools, uploadFormats } = await fetchToolList({ signal: opts?.signal });
|
|
@@ -11461,6 +11485,7 @@ function createToolsClient(options = {}) {
|
|
|
11461
11485
|
}
|
|
11462
11486
|
const toolUrl = `${url}/tools/${encodeURIComponent(meta?.name ?? name)}`;
|
|
11463
11487
|
const headers = {
|
|
11488
|
+
...envSession ? { [SESSION_HEADER]: envSession } : {},
|
|
11464
11489
|
...options.headers?.(),
|
|
11465
11490
|
"Content-Type": "application/json",
|
|
11466
11491
|
// 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",
|
|
@@ -34570,7 +34576,8 @@ function tarEnv(env) {
|
|
|
34570
34576
|
async function runTar(archive, args, signal) {
|
|
34571
34577
|
const child = spawn2("tar", [...args, "-f", "-"], {
|
|
34572
34578
|
signal,
|
|
34573
|
-
env: tarEnv(process.env)
|
|
34579
|
+
env: tarEnv(process.env),
|
|
34580
|
+
windowsHide: true
|
|
34574
34581
|
});
|
|
34575
34582
|
let childError;
|
|
34576
34583
|
child.on("error", (err) => {
|
|
@@ -34788,6 +34795,9 @@ function removePendingArchives() {
|
|
|
34788
34795
|
function removeArchivesOnSignal(signal) {
|
|
34789
34796
|
removePendingArchives();
|
|
34790
34797
|
if (process.listenerCount(signal) > 0) return;
|
|
34798
|
+
raiseSignal(signal);
|
|
34799
|
+
}
|
|
34800
|
+
function raiseSignal(signal) {
|
|
34791
34801
|
try {
|
|
34792
34802
|
process.kill(process.pid, signal);
|
|
34793
34803
|
} catch {
|
|
@@ -35813,6 +35823,19 @@ function failedRun(result) {
|
|
|
35813
35823
|
}
|
|
35814
35824
|
return result;
|
|
35815
35825
|
}
|
|
35826
|
+
function sessionFromEnv() {
|
|
35827
|
+
const session = process.env.ARGENT_SESSION?.trim();
|
|
35828
|
+
if (!session) return void 0;
|
|
35829
|
+
if (!isValidSession(session)) {
|
|
35830
|
+
throw new ToolInvocationError(
|
|
35831
|
+
"ARGENT_SESSION must be 1 to 128 printable ASCII characters without spaces."
|
|
35832
|
+
);
|
|
35833
|
+
}
|
|
35834
|
+
return session;
|
|
35835
|
+
}
|
|
35836
|
+
function hasSessionHeader(headers) {
|
|
35837
|
+
return Object.keys(headers).some((name) => name.toLowerCase() === SESSION_HEADER);
|
|
35838
|
+
}
|
|
35816
35839
|
function createToolsClient(options = {}) {
|
|
35817
35840
|
let cached2 = null;
|
|
35818
35841
|
let linkedNoticeShown = false;
|
|
@@ -35869,6 +35892,7 @@ function createToolsClient(options = {}) {
|
|
|
35869
35892
|
async function callTool(name, args, opts) {
|
|
35870
35893
|
opts?.signal?.throwIfAborted();
|
|
35871
35894
|
assertFiniteNumbers(args);
|
|
35895
|
+
const envSession = options.ignoreEnvSession || hasSessionHeader(options.headers?.() ?? {}) ? void 0 : sessionFromEnv();
|
|
35872
35896
|
const { url, token, remote } = await route();
|
|
35873
35897
|
let finalArgs = canonicalToolArgs(name, args);
|
|
35874
35898
|
const { tools, uploadFormats } = await fetchToolList({ signal: opts?.signal });
|
|
@@ -35945,6 +35969,7 @@ function createToolsClient(options = {}) {
|
|
|
35945
35969
|
}
|
|
35946
35970
|
const toolUrl = `${url}/tools/${encodeURIComponent(meta2?.name ?? name)}`;
|
|
35947
35971
|
const headers = {
|
|
35972
|
+
...envSession ? { [SESSION_HEADER]: envSession } : {},
|
|
35948
35973
|
...options.headers?.(),
|
|
35949
35974
|
"Content-Type": "application/json",
|
|
35950
35975
|
// Tells the tool-server the call came over a link, a link to
|
|
@@ -36867,7 +36892,7 @@ import { existsSync as existsSync4 } from "node:fs";
|
|
|
36867
36892
|
var SESSION_ID2 = randomUUID5();
|
|
36868
36893
|
|
|
36869
36894
|
// ../telemetry/src/identity.ts
|
|
36870
|
-
import * as
|
|
36895
|
+
import * as crypto3 from "node:crypto";
|
|
36871
36896
|
import * as fs12 from "node:fs";
|
|
36872
36897
|
import * as path16 from "node:path";
|
|
36873
36898
|
|
|
@@ -38371,6 +38396,7 @@ function createToolCaller(deps) {
|
|
|
38371
38396
|
const client = createToolsClient({
|
|
38372
38397
|
baseUrl: async () => ({ ...deps.getHandle(), remote: deps.remote }),
|
|
38373
38398
|
headers: deps.extraHeaders,
|
|
38399
|
+
ignoreEnvSession: true,
|
|
38374
38400
|
refuseRelativeProjectPaths: true,
|
|
38375
38401
|
fetchImpl: async (url, init, meta2) => {
|
|
38376
38402
|
parseUrl(url);
|
|
@@ -38393,6 +38419,19 @@ function createToolCaller(deps) {
|
|
|
38393
38419
|
};
|
|
38394
38420
|
}
|
|
38395
38421
|
|
|
38422
|
+
// ../argent-mcp/src/release-on-exit.ts
|
|
38423
|
+
var EXIT_SIGNALS = ["SIGTERM", "SIGINT", "SIGHUP"];
|
|
38424
|
+
function releaseOnExit(release) {
|
|
38425
|
+
process.stdin.on("close", () => void release());
|
|
38426
|
+
function releaseThenRaise(signal) {
|
|
38427
|
+
void release().finally(() => {
|
|
38428
|
+
for (const s of EXIT_SIGNALS) process.removeListener(s, releaseThenRaise);
|
|
38429
|
+
raiseSignal(signal);
|
|
38430
|
+
});
|
|
38431
|
+
}
|
|
38432
|
+
for (const signal of EXIT_SIGNALS) process.on(signal, releaseThenRaise);
|
|
38433
|
+
}
|
|
38434
|
+
|
|
38396
38435
|
// ../argent-mcp/src/call-log.ts
|
|
38397
38436
|
import {
|
|
38398
38437
|
appendFileSync as appendFileSync2,
|
|
@@ -38549,7 +38588,7 @@ async function startMcpServer(options) {
|
|
|
38549
38588
|
const autoDescribeOn = autoDescribeEnabled();
|
|
38550
38589
|
const whatsNewOn = whatsNewEnabled();
|
|
38551
38590
|
const installedVersion = getInstalledVersion();
|
|
38552
|
-
const highlightsVersion = true ? "0.35.1-next.
|
|
38591
|
+
const highlightsVersion = true ? "0.35.1-next.86" : installedVersion;
|
|
38553
38592
|
const captureTimeoutMs = options.captureTimeoutMs ?? CAPTURE_TIMEOUT_MS;
|
|
38554
38593
|
const trees = createTreeMemory();
|
|
38555
38594
|
const screenshots = createScreenshotMemory();
|
|
@@ -38584,6 +38623,13 @@ async function startMcpServer(options) {
|
|
|
38584
38623
|
if (rawName) return { "X-Argent-AI-Client": "other" };
|
|
38585
38624
|
return {};
|
|
38586
38625
|
}
|
|
38626
|
+
const sessionId2 = crypto.randomUUID();
|
|
38627
|
+
let sessionCalledTools = false;
|
|
38628
|
+
let sessionEnded = false;
|
|
38629
|
+
function callerHeaders() {
|
|
38630
|
+
if (sessionEnded) return aiClientHeaders();
|
|
38631
|
+
return { ...aiClientHeaders(), [SESSION_HEADER]: sessionId2 };
|
|
38632
|
+
}
|
|
38587
38633
|
let reconnectPromise = null;
|
|
38588
38634
|
async function reconnect() {
|
|
38589
38635
|
if (remote) return;
|
|
@@ -38603,7 +38649,7 @@ async function startMcpServer(options) {
|
|
|
38603
38649
|
getHandle: () => ({ url: TOOLS_URL, token: AUTH_TOKEN }),
|
|
38604
38650
|
remote,
|
|
38605
38651
|
reconnect,
|
|
38606
|
-
extraHeaders:
|
|
38652
|
+
extraHeaders: callerHeaders
|
|
38607
38653
|
});
|
|
38608
38654
|
const callForCapture = async (name, args, signal) => (await callTool(name, args, { signal })).result;
|
|
38609
38655
|
async function logReadiness(toolName, settled) {
|
|
@@ -38727,6 +38773,7 @@ ${shown.text}` }];
|
|
|
38727
38773
|
});
|
|
38728
38774
|
server.setRequestHandler(CallToolRequestSchema, async ({ params }, { signal }) => {
|
|
38729
38775
|
const t0 = Date.now();
|
|
38776
|
+
sessionCalledTools = true;
|
|
38730
38777
|
const callSignal = SAVES_FILES_AFTER_CANCEL.has(canonicalToolId(params.name)) ? void 0 : signal;
|
|
38731
38778
|
let treeUdid;
|
|
38732
38779
|
let screenshotUdid;
|
|
@@ -38868,6 +38915,21 @@ ${shown.text}` }];
|
|
|
38868
38915
|
}, HEALTH_INTERVAL_MS);
|
|
38869
38916
|
healthInterval.unref();
|
|
38870
38917
|
}
|
|
38918
|
+
let release;
|
|
38919
|
+
function releaseSessionDevices() {
|
|
38920
|
+
if (!sessionCalledTools) return Promise.resolve();
|
|
38921
|
+
release ??= fetch(`${TOOLS_URL}/tools/release-device`, {
|
|
38922
|
+
method: "POST",
|
|
38923
|
+
headers: { ...authHeader(), ...callerHeaders(), "Content-Type": "application/json" },
|
|
38924
|
+
body: "{}",
|
|
38925
|
+
signal: AbortSignal.timeout(2e3)
|
|
38926
|
+
}).catch(() => {
|
|
38927
|
+
});
|
|
38928
|
+
sessionEnded = true;
|
|
38929
|
+
return release;
|
|
38930
|
+
}
|
|
38931
|
+
server.onclose = () => void releaseSessionDevices();
|
|
38932
|
+
if (!options.transport) releaseOnExit(releaseSessionDevices);
|
|
38871
38933
|
if (process.env.ARGENT_TOOL_SERVER_SHUTDOWN_ON_MCP_EXIT === "1") {
|
|
38872
38934
|
process.stdin.on("close", () => {
|
|
38873
38935
|
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;
|