sim 2.1.8-dev.101.1 → 2.1.8-dev.95.1
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/README.md +1 -18
- package/dist/config/paths.d.ts +0 -11
- package/dist/contract/types.d.ts +0 -12
- package/dist/generated/v2-api.d.ts +13 -542
- package/dist/index.js +23 -678
- package/dist/runtime/request.d.ts +6 -4
- package/dist/runtime.d.ts +0 -1
- package/dist/runtime.js +8713 -9535
- package/package.json +1 -1
- package/dist/embed.d.ts +0 -39
- package/dist/update/check.d.ts +0 -53
package/dist/index.js
CHANGED
|
@@ -2366,9 +2366,6 @@ function configPath() {
|
|
|
2366
2366
|
function credentialsPath() {
|
|
2367
2367
|
return process.env.SIM_CREDENTIALS_FILE || join(configDir(), "credentials");
|
|
2368
2368
|
}
|
|
2369
|
-
function updateCachePath() {
|
|
2370
|
-
return join(configDir(), "update-check.json");
|
|
2371
|
-
}
|
|
2372
2369
|
// src/config/profile.ts
|
|
2373
2370
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2374
2371
|
import { dirname } from "node:path";
|
|
@@ -7156,6 +7153,13 @@ var V2_OPERATIONS = {
|
|
|
7156
7153
|
responseMode: "json",
|
|
7157
7154
|
summary: "Create Credential Connection",
|
|
7158
7155
|
personalKeyOnly: true,
|
|
7156
|
+
body: {
|
|
7157
|
+
workspaceId: {
|
|
7158
|
+
kind: "string",
|
|
7159
|
+
required: true,
|
|
7160
|
+
describe: "Workspace that will own the credential."
|
|
7161
|
+
}
|
|
7162
|
+
},
|
|
7159
7163
|
opaqueBody: true
|
|
7160
7164
|
},
|
|
7161
7165
|
createCustomTool: {
|
|
@@ -7568,47 +7572,6 @@ var V2_OPERATIONS = {
|
|
|
7568
7572
|
}
|
|
7569
7573
|
}
|
|
7570
7574
|
},
|
|
7571
|
-
createSandbox: {
|
|
7572
|
-
method: "POST",
|
|
7573
|
-
path: "/api/v2/sandboxes",
|
|
7574
|
-
pathParams: [],
|
|
7575
|
-
responseMode: "json",
|
|
7576
|
-
summary: "Create Sandbox",
|
|
7577
|
-
personalKeyOnly: true,
|
|
7578
|
-
body: {
|
|
7579
|
-
workspaceId: {
|
|
7580
|
-
kind: "string",
|
|
7581
|
-
required: true,
|
|
7582
|
-
describe: "Workspace in which to create the sandbox."
|
|
7583
|
-
},
|
|
7584
|
-
name: {
|
|
7585
|
-
kind: "string",
|
|
7586
|
-
required: true,
|
|
7587
|
-
describe: "Display name, unique within the workspace; 1 to 64 characters."
|
|
7588
|
-
},
|
|
7589
|
-
language: {
|
|
7590
|
-
kind: "enum",
|
|
7591
|
-
required: true,
|
|
7592
|
-
values: ["javascript", "python"],
|
|
7593
|
-
describe: "Dependency ecosystem: `javascript` installs from npm, `python` from PyPI."
|
|
7594
|
-
},
|
|
7595
|
-
dependencies: {
|
|
7596
|
-
kind: "array",
|
|
7597
|
-
default: [],
|
|
7598
|
-
describe: "Package specifiers installed into the sandbox, one per entry."
|
|
7599
|
-
},
|
|
7600
|
-
cliTools: {
|
|
7601
|
-
kind: "array",
|
|
7602
|
-
default: [],
|
|
7603
|
-
describe: "Pinned managed CLI ids installed into the sandbox, at most 10, no duplicates."
|
|
7604
|
-
},
|
|
7605
|
-
systemPackages: {
|
|
7606
|
-
kind: "array",
|
|
7607
|
-
default: [],
|
|
7608
|
-
describe: "Debian packages installed into the sandbox, one per entry."
|
|
7609
|
-
}
|
|
7610
|
-
}
|
|
7611
|
-
},
|
|
7612
7575
|
createServiceAccountCredential: {
|
|
7613
7576
|
method: "POST",
|
|
7614
7577
|
path: "/api/v2/credentials",
|
|
@@ -8126,18 +8089,6 @@ var V2_OPERATIONS = {
|
|
|
8126
8089
|
}
|
|
8127
8090
|
}
|
|
8128
8091
|
},
|
|
8129
|
-
deleteSandbox: {
|
|
8130
|
-
method: "DELETE",
|
|
8131
|
-
path: "/api/v2/sandboxes/[sandboxId]",
|
|
8132
|
-
pathParams: ["sandboxId"],
|
|
8133
|
-
pathParamDocs: { sandboxId: "Unique sandbox identifier." },
|
|
8134
|
-
responseMode: "json",
|
|
8135
|
-
summary: "Delete Sandbox",
|
|
8136
|
-
personalKeyOnly: true,
|
|
8137
|
-
query: {
|
|
8138
|
-
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the sandbox." }
|
|
8139
|
-
}
|
|
8140
|
-
},
|
|
8141
8092
|
deleteSecret: {
|
|
8142
8093
|
method: "DELETE",
|
|
8143
8094
|
path: "/api/v2/secrets/[name]",
|
|
@@ -8419,53 +8370,6 @@ var V2_OPERATIONS = {
|
|
|
8419
8370
|
}
|
|
8420
8371
|
}
|
|
8421
8372
|
},
|
|
8422
|
-
editFileContent: {
|
|
8423
|
-
method: "PATCH",
|
|
8424
|
-
path: "/api/v2/files/[fileId]/content",
|
|
8425
|
-
pathParams: ["fileId"],
|
|
8426
|
-
pathParamDocs: { fileId: "File identifier." },
|
|
8427
|
-
responseMode: "json",
|
|
8428
|
-
summary: "Edit File Content",
|
|
8429
|
-
body: {
|
|
8430
|
-
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the file." },
|
|
8431
|
-
edit: {
|
|
8432
|
-
kind: "unknown",
|
|
8433
|
-
required: true,
|
|
8434
|
-
describe: "One exact or anchor-based edit: search_replace, replace_between, insert_after, or delete_between."
|
|
8435
|
-
}
|
|
8436
|
-
}
|
|
8437
|
-
},
|
|
8438
|
-
executeTool: {
|
|
8439
|
-
method: "POST",
|
|
8440
|
-
path: "/api/v2/tools/[toolId]/execute",
|
|
8441
|
-
pathParams: ["toolId"],
|
|
8442
|
-
pathParamDocs: {
|
|
8443
|
-
toolId: "Tool identifier. An unversioned name resolves to the newest version, and the response echoes the resolved id."
|
|
8444
|
-
},
|
|
8445
|
-
responseMode: "json",
|
|
8446
|
-
summary: "Run Tool",
|
|
8447
|
-
personalKeyOnly: true,
|
|
8448
|
-
body: {
|
|
8449
|
-
workspaceId: {
|
|
8450
|
-
kind: "string",
|
|
8451
|
-
required: true,
|
|
8452
|
-
describe: "Workspace whose integration allowlist, credentials, and environment variables govern this call."
|
|
8453
|
-
},
|
|
8454
|
-
input: {
|
|
8455
|
-
kind: "object",
|
|
8456
|
-
default: {},
|
|
8457
|
-
describe: "Arguments for the tool, keyed by the parameter ids the tool catalog publishes for it. A parameter whose visibility is `user-only` also accepts an environment-variable reference written as the whole value, `{{VAR_NAME}}`, resolved server-side against the workspace environment; any other value is sent verbatim."
|
|
8458
|
-
},
|
|
8459
|
-
credentialId: {
|
|
8460
|
-
kind: "string",
|
|
8461
|
-
describe: "Credential to authenticate with. Required when the tool declares an OAuth requirement; the workspace credentials list names the candidates."
|
|
8462
|
-
},
|
|
8463
|
-
timeoutSeconds: {
|
|
8464
|
-
kind: "integer",
|
|
8465
|
-
describe: "How long to wait for the tool before abandoning the call."
|
|
8466
|
-
}
|
|
8467
|
-
}
|
|
8468
|
-
},
|
|
8469
8373
|
executeWorkflow: {
|
|
8470
8374
|
method: "POST",
|
|
8471
8375
|
path: "/api/v2/workflows/[workflowId]/execute",
|
|
@@ -8860,17 +8764,6 @@ var V2_OPERATIONS = {
|
|
|
8860
8764
|
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the table." }
|
|
8861
8765
|
}
|
|
8862
8766
|
},
|
|
8863
|
-
getSandbox: {
|
|
8864
|
-
method: "GET",
|
|
8865
|
-
path: "/api/v2/sandboxes/[sandboxId]",
|
|
8866
|
-
pathParams: ["sandboxId"],
|
|
8867
|
-
pathParamDocs: { sandboxId: "Unique sandbox identifier." },
|
|
8868
|
-
responseMode: "json",
|
|
8869
|
-
summary: "Get Sandbox",
|
|
8870
|
-
query: {
|
|
8871
|
-
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the sandbox." }
|
|
8872
|
-
}
|
|
8873
|
-
},
|
|
8874
8767
|
getSkill: {
|
|
8875
8768
|
method: "GET",
|
|
8876
8769
|
path: "/api/v2/skills/[skillId]",
|
|
@@ -9190,8 +9083,7 @@ var V2_OPERATIONS = {
|
|
|
9190
9083
|
"knowledge-base",
|
|
9191
9084
|
"voice-input",
|
|
9192
9085
|
"enrichment",
|
|
9193
|
-
"voice-output"
|
|
9194
|
-
"api-tool"
|
|
9086
|
+
"voice-output"
|
|
9195
9087
|
],
|
|
9196
9088
|
describe: "Restrict results to one usage source."
|
|
9197
9089
|
},
|
|
@@ -9494,28 +9386,6 @@ var V2_OPERATIONS = {
|
|
|
9494
9386
|
values: ["active", "archived"],
|
|
9495
9387
|
default: "active",
|
|
9496
9388
|
describe: "Which lifecycle set to list: `active` (default) returns live folders only; `archived` returns folders a recursive delete soft-deleted, which is how a caller finds a path to hand to the folder restore. Authorization is identical for both."
|
|
9497
|
-
},
|
|
9498
|
-
recursive: {
|
|
9499
|
-
kind: "enum",
|
|
9500
|
-
values: [
|
|
9501
|
-
"true",
|
|
9502
|
-
"1",
|
|
9503
|
-
"yes",
|
|
9504
|
-
"on",
|
|
9505
|
-
"y",
|
|
9506
|
-
"enabled",
|
|
9507
|
-
"false",
|
|
9508
|
-
"0",
|
|
9509
|
-
"no",
|
|
9510
|
-
"off",
|
|
9511
|
-
"n",
|
|
9512
|
-
"disabled"
|
|
9513
|
-
],
|
|
9514
|
-
describe: "Whether parentPath includes every descendant instead of direct children only."
|
|
9515
|
-
},
|
|
9516
|
-
depth: {
|
|
9517
|
-
kind: "integer",
|
|
9518
|
-
describe: "Deepest level below parentPath to include when recursive is true."
|
|
9519
9389
|
}
|
|
9520
9390
|
}
|
|
9521
9391
|
},
|
|
@@ -10044,41 +9914,6 @@ var V2_OPERATIONS = {
|
|
|
10044
9914
|
}
|
|
10045
9915
|
}
|
|
10046
9916
|
},
|
|
10047
|
-
listSandboxes: {
|
|
10048
|
-
method: "GET",
|
|
10049
|
-
path: "/api/v2/sandboxes",
|
|
10050
|
-
pathParams: [],
|
|
10051
|
-
responseMode: "json",
|
|
10052
|
-
summary: "List Sandboxes",
|
|
10053
|
-
query: {
|
|
10054
|
-
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the sandbox." },
|
|
10055
|
-
search: {
|
|
10056
|
-
kind: "string",
|
|
10057
|
-
describe: "Case-insensitive substring match against the sandbox name."
|
|
10058
|
-
},
|
|
10059
|
-
sortBy: {
|
|
10060
|
-
kind: "enum",
|
|
10061
|
-
values: ["name", "createdAt", "updatedAt"],
|
|
10062
|
-
default: "name",
|
|
10063
|
-
describe: "Field used to sort the result. Sorting by `name` is case-sensitive and follows the storage collation, so do not rely on a case-insensitive order."
|
|
10064
|
-
},
|
|
10065
|
-
sortOrder: {
|
|
10066
|
-
kind: "enum",
|
|
10067
|
-
values: ["asc", "desc"],
|
|
10068
|
-
default: "asc",
|
|
10069
|
-
describe: "Sort direction."
|
|
10070
|
-
},
|
|
10071
|
-
limit: {
|
|
10072
|
-
kind: "integer",
|
|
10073
|
-
default: 50,
|
|
10074
|
-
describe: "Maximum sandboxes to return per page. Must be a whole number from 1 to 100. Defaults to 50."
|
|
10075
|
-
},
|
|
10076
|
-
cursor: {
|
|
10077
|
-
kind: "string",
|
|
10078
|
-
describe: "Opaque cursor from the previous page. Send it back with the same sort and filters; only `limit` may change. Change anything else and pagination must restart without a cursor."
|
|
10079
|
-
}
|
|
10080
|
-
}
|
|
10081
|
-
},
|
|
10082
9917
|
listSecrets: {
|
|
10083
9918
|
method: "GET",
|
|
10084
9919
|
path: "/api/v2/secrets",
|
|
@@ -10734,14 +10569,6 @@ var V2_OPERATIONS = {
|
|
|
10734
10569
|
maxBytes: {
|
|
10735
10570
|
kind: "integer",
|
|
10736
10571
|
describe: "Optional ceiling on the source bytes fed to the parser, lowering but never raising the server limit."
|
|
10737
|
-
},
|
|
10738
|
-
offset: {
|
|
10739
|
-
kind: "integer",
|
|
10740
|
-
describe: "First line to return, 1-based. Absent starts at the first line."
|
|
10741
|
-
},
|
|
10742
|
-
limit: {
|
|
10743
|
-
kind: "integer",
|
|
10744
|
-
describe: "How many lines to return from `offset`. Absent reads to the end."
|
|
10745
10572
|
}
|
|
10746
10573
|
}
|
|
10747
10574
|
},
|
|
@@ -11072,50 +10899,6 @@ var V2_OPERATIONS = {
|
|
|
11072
10899
|
workspaceId: { kind: "string", required: true, describe: "Unique workspace identifier." }
|
|
11073
10900
|
}
|
|
11074
10901
|
},
|
|
11075
|
-
searchFileContent: {
|
|
11076
|
-
method: "GET",
|
|
11077
|
-
path: "/api/v2/files/search",
|
|
11078
|
-
pathParams: [],
|
|
11079
|
-
responseMode: "json",
|
|
11080
|
-
summary: "Search File Content",
|
|
11081
|
-
query: {
|
|
11082
|
-
workspaceId: { kind: "string", required: true, describe: "Workspace to search." },
|
|
11083
|
-
query: {
|
|
11084
|
-
kind: "string",
|
|
11085
|
-
required: true,
|
|
11086
|
-
describe: "Regular expression, or exact text when `mode` is `exact`."
|
|
11087
|
-
},
|
|
11088
|
-
mode: {
|
|
11089
|
-
kind: "enum",
|
|
11090
|
-
values: ["exact", "regex"],
|
|
11091
|
-
default: "regex",
|
|
11092
|
-
describe: "How `query` is read."
|
|
11093
|
-
},
|
|
11094
|
-
maxResults: { kind: "integer", default: 50, describe: "Maximum matching lines to return." },
|
|
11095
|
-
folderPaths: {
|
|
11096
|
-
kind: "string",
|
|
11097
|
-
describe: "Folders the search is confined to, comma-separated. Absent searches the whole workspace. The scope also narrows `indexStatus`, so `complete` describes the folders searched rather than the workspace."
|
|
11098
|
-
},
|
|
11099
|
-
includeSubfolders: {
|
|
11100
|
-
kind: "enum",
|
|
11101
|
-
values: [
|
|
11102
|
-
"true",
|
|
11103
|
-
"1",
|
|
11104
|
-
"yes",
|
|
11105
|
-
"on",
|
|
11106
|
-
"y",
|
|
11107
|
-
"enabled",
|
|
11108
|
-
"false",
|
|
11109
|
-
"0",
|
|
11110
|
-
"no",
|
|
11111
|
-
"off",
|
|
11112
|
-
"n",
|
|
11113
|
-
"disabled"
|
|
11114
|
-
],
|
|
11115
|
-
describe: "Whether the scope descends into nested folders. Absent means yes. The listed spellings are the whole accepted vocabulary and are case-sensitive; any other value is rejected."
|
|
11116
|
-
}
|
|
11117
|
-
}
|
|
11118
|
-
},
|
|
11119
10902
|
searchKnowledge: {
|
|
11120
10903
|
method: "POST",
|
|
11121
10904
|
path: "/api/v2/knowledge/search",
|
|
@@ -11148,6 +10931,7 @@ var V2_OPERATIONS = {
|
|
|
11148
10931
|
},
|
|
11149
10932
|
searchMode: {
|
|
11150
10933
|
kind: "enum",
|
|
10934
|
+
default: "vector",
|
|
11151
10935
|
describe: "Retrieval strategy: vector is semantic-only, while hybrid also runs full-text search."
|
|
11152
10936
|
},
|
|
11153
10937
|
rerankerEnabled: {
|
|
@@ -11630,39 +11414,6 @@ var V2_OPERATIONS = {
|
|
|
11630
11414
|
limit: { kind: "integer", describe: "Maximum matching rows to update." }
|
|
11631
11415
|
}
|
|
11632
11416
|
},
|
|
11633
|
-
updateSandbox: {
|
|
11634
|
-
method: "PATCH",
|
|
11635
|
-
path: "/api/v2/sandboxes/[sandboxId]",
|
|
11636
|
-
pathParams: ["sandboxId"],
|
|
11637
|
-
pathParamDocs: { sandboxId: "Unique sandbox identifier." },
|
|
11638
|
-
responseMode: "json",
|
|
11639
|
-
summary: "Update Sandbox",
|
|
11640
|
-
personalKeyOnly: true,
|
|
11641
|
-
body: {
|
|
11642
|
-
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the sandbox." },
|
|
11643
|
-
name: {
|
|
11644
|
-
kind: "string",
|
|
11645
|
-
describe: "New display name, unique within the workspace; 1 to 64 characters."
|
|
11646
|
-
},
|
|
11647
|
-
language: {
|
|
11648
|
-
kind: "enum",
|
|
11649
|
-
values: ["javascript", "python"],
|
|
11650
|
-
describe: "Replacement dependency ecosystem. The whole spec is revalidated against it, so a Python dependency list does not survive a switch to JavaScript."
|
|
11651
|
-
},
|
|
11652
|
-
dependencies: {
|
|
11653
|
-
kind: "array",
|
|
11654
|
-
describe: "Replacement package list; replaces the whole list."
|
|
11655
|
-
},
|
|
11656
|
-
cliTools: {
|
|
11657
|
-
kind: "array",
|
|
11658
|
-
describe: "Replacement managed CLI list; replaces the whole list."
|
|
11659
|
-
},
|
|
11660
|
-
systemPackages: {
|
|
11661
|
-
kind: "array",
|
|
11662
|
-
describe: "Replacement Debian package list; replaces the whole list."
|
|
11663
|
-
}
|
|
11664
|
-
}
|
|
11665
|
-
},
|
|
11666
11417
|
updateSkill: {
|
|
11667
11418
|
method: "PATCH",
|
|
11668
11419
|
path: "/api/v2/skills/[skillId]",
|
|
@@ -12401,7 +12152,6 @@ var TABLE_SORT_HELP = 'Ordered sort keys: [{"field":"createdAt","direction":"des
|
|
|
12401
12152
|
var KNOWLEDGE_TAG_DEFINITIONS_HELP = 'Tag definitions: [{"tagSlot":"tag1","displayName":"category","fieldType":"text"}]';
|
|
12402
12153
|
var CUSTOM_TOOL_SCHEMA_HELP = 'OpenAI function schema: {"type":"function","function":{"name":"...","parameters":{"type":"object","properties":{}}}}';
|
|
12403
12154
|
var DISPATCH_ROW_LIMIT_HELP = "Stop after this many eligible rows have run (1-1,000,000). Omit for an unbounded run";
|
|
12404
|
-
var FILE_EDIT_HELP = 'One edit object: {"mode":"search_replace","search":"old","content":"new","replaceAll":false}, {"mode":"replace_between","beforeAnchor":"start line","afterAnchor":"end line","content":"new"}, {"mode":"insert_after","anchor":"line","content":"new"}, or {"mode":"delete_between","startAnchor":"first line deleted","endAnchor":"ending line kept"}. Anchored modes also accept occurrence starting at 1';
|
|
12405
12155
|
var WORKFLOW_OPERATIONS_HELP = 'Edits to apply, in a single batch, keyed by operation_type: [{"operation_type":"add","block_id":"my-fn","params":{"type":"function","name":"My Fn","inputs":{"code":"return {ok:true}"}}},{"operation_type":"edit","block_id":"<uuid>","params":{"name":"Renamed","connections":{"success":"my-fn"}}},{"operation_type":"delete","block_id":"<uuid>"}]. Also extract_from_subflow, whose params carry {"subflowId":"<loop-id>"}, and insert_into_subflow, which creates a block and so takes an add’s params plus that subflowId';
|
|
12406
12156
|
var WORKFLOW_SET_BLOCK_ENABLED_HELP = 'Blocks to enable or disable, applied after --operations: [{"block_id":"<uuid>","enabled":false}]. Disabling a loop or parallel cascades to its unlocked descendants; enabling a block whose container is disabled is declined';
|
|
12407
12157
|
var WORKFLOW_VARIABLE_OPERATIONS_HELP = 'Variable changes to apply in order, keyed by operation: [{"operation":"add","name":"my_var","type":"string","value":"hello"},{"operation":"edit","name":"my_var","value":"updated"},{"operation":"delete","name":"my_var"}]';
|
|
@@ -12599,9 +12349,6 @@ var CLI_CONTRACT = {
|
|
|
12599
12349
|
confirm: "This revokes the explicit skill editor grant for the selected email."
|
|
12600
12350
|
},
|
|
12601
12351
|
deleteCustomTool: { confirm: "This deletes the custom tool." },
|
|
12602
|
-
deleteSandbox: {
|
|
12603
|
-
confirm: "This deletes the sandbox; Function blocks that select it fail until re-pointed."
|
|
12604
|
-
},
|
|
12605
12352
|
deleteMcpServer: {
|
|
12606
12353
|
confirm: "This removes the MCP server and the tools it provides."
|
|
12607
12354
|
},
|
|
@@ -12785,25 +12532,6 @@ var CLI_CONTRACT = {
|
|
|
12785
12532
|
flags: { folderPaths: FOLDER_PATHS_FLAG },
|
|
12786
12533
|
confirm: "This deletes every listed table and all of their rows."
|
|
12787
12534
|
},
|
|
12788
|
-
searchFileContent: {
|
|
12789
|
-
flags: {
|
|
12790
|
-
folderPaths: {
|
|
12791
|
-
...FOLDER_PATHS_FLAG,
|
|
12792
|
-
describe: "Folders to search, by path as shown in the app; omit to search the whole workspace"
|
|
12793
|
-
},
|
|
12794
|
-
includeSubfolders: {
|
|
12795
|
-
boolean: true,
|
|
12796
|
-
negatable: true,
|
|
12797
|
-
describe: "Whether each folder scope includes nested folders; on by default"
|
|
12798
|
-
}
|
|
12799
|
-
},
|
|
12800
|
-
itemsPath: "results",
|
|
12801
|
-
columns: [
|
|
12802
|
-
{ header: "file", path: "fileId" },
|
|
12803
|
-
{ header: "line", path: "lineNumber" },
|
|
12804
|
-
{ header: "text" }
|
|
12805
|
-
]
|
|
12806
|
-
},
|
|
12807
12535
|
searchKnowledge: {
|
|
12808
12536
|
flags: {
|
|
12809
12537
|
knowledgeBaseIds: { name: "kb", list: true, describe: "Knowledge base ID (repeatable)" },
|
|
@@ -12888,20 +12616,6 @@ var CLI_CONTRACT = {
|
|
|
12888
12616
|
importWorkflow: { flags: { folderPath: FOLDER_PATH_FLAG } },
|
|
12889
12617
|
createCustomTool: { flags: { schema: { json: true, describe: CUSTOM_TOOL_SCHEMA_HELP } } },
|
|
12890
12618
|
updateCustomTool: { flags: { schema: { json: true, describe: CUSTOM_TOOL_SCHEMA_HELP } } },
|
|
12891
|
-
createSandbox: {
|
|
12892
|
-
flags: {
|
|
12893
|
-
dependencies: { list: true, manifest: true },
|
|
12894
|
-
cliTools: { list: true },
|
|
12895
|
-
systemPackages: { list: true, manifest: true }
|
|
12896
|
-
}
|
|
12897
|
-
},
|
|
12898
|
-
updateSandbox: {
|
|
12899
|
-
flags: {
|
|
12900
|
-
dependencies: { list: true, manifest: true },
|
|
12901
|
-
cliTools: { list: true },
|
|
12902
|
-
systemPackages: { list: true, manifest: true }
|
|
12903
|
-
}
|
|
12904
|
-
},
|
|
12905
12619
|
listTables: {
|
|
12906
12620
|
flags: { folderPath: FOLDER_PATH_FLAG },
|
|
12907
12621
|
columns: [
|
|
@@ -13043,15 +12757,6 @@ var CLI_CONTRACT = {
|
|
|
13043
12757
|
{ header: "updated", path: "updatedAt", format: "timestamp" }
|
|
13044
12758
|
]
|
|
13045
12759
|
},
|
|
13046
|
-
listSandboxes: {
|
|
13047
|
-
columns: [
|
|
13048
|
-
{ header: "id" },
|
|
13049
|
-
{ header: "name" },
|
|
13050
|
-
{ header: "language" },
|
|
13051
|
-
{ header: "status", path: "buildStatus" },
|
|
13052
|
-
{ header: "updated", path: "updatedAt", format: "timestamp" }
|
|
13053
|
-
]
|
|
13054
|
-
},
|
|
13055
12760
|
listCredentials: {
|
|
13056
12761
|
columns: [
|
|
13057
12762
|
{ header: "id" },
|
|
@@ -13246,13 +12951,6 @@ var CLI_CONTRACT = {
|
|
|
13246
12951
|
folderPaths: FOLDER_PATHS_FLAG
|
|
13247
12952
|
}
|
|
13248
12953
|
},
|
|
13249
|
-
editFileContent: {
|
|
13250
|
-
command: "files edit",
|
|
13251
|
-
describe: "Apply one exact or anchor-based edit to a text file",
|
|
13252
|
-
flags: {
|
|
13253
|
-
edit: { describe: FILE_EDIT_HELP }
|
|
13254
|
-
}
|
|
13255
|
-
},
|
|
13256
12954
|
updateFileContent: {
|
|
13257
12955
|
command: "files set-content",
|
|
13258
12956
|
describe: "Replace a file’s contents",
|
|
@@ -13491,24 +13189,6 @@ var CLI_CONTRACT = {
|
|
|
13491
13189
|
describe: "Print a workflow as a portable JSON document",
|
|
13492
13190
|
document: true
|
|
13493
13191
|
},
|
|
13494
|
-
executeTool: {
|
|
13495
|
-
command: "tools execute",
|
|
13496
|
-
describe: "Run one built-in tool and print what it produced",
|
|
13497
|
-
flags: {
|
|
13498
|
-
input: {
|
|
13499
|
-
json: true,
|
|
13500
|
-
describe: "Tool arguments as JSON, keyed by the parameter ids `sim tools get <toolId>` lists"
|
|
13501
|
-
},
|
|
13502
|
-
credentialId: { describe: "Credential to authenticate with, required for OAuth tools" },
|
|
13503
|
-
timeoutSeconds: { name: "timeout", describe: "Seconds to wait before abandoning the call" }
|
|
13504
|
-
},
|
|
13505
|
-
fields: [
|
|
13506
|
-
{ path: "toolId", header: "Tool" },
|
|
13507
|
-
{ path: "status", header: "Status" },
|
|
13508
|
-
{ path: "output", header: "Output" },
|
|
13509
|
-
{ path: "error.message", header: "Error" }
|
|
13510
|
-
]
|
|
13511
|
-
},
|
|
13512
13192
|
executeWorkflow: {
|
|
13513
13193
|
command: "workflows run",
|
|
13514
13194
|
describe: "Run a deployed workflow or execute saved state manually",
|
|
@@ -13848,11 +13528,7 @@ async function readArgumentSource(raw, flagName) {
|
|
|
13848
13528
|
throw new SimApiError(`--${flagName} cannot read ${path}: ${error.message}${literalAtHint(error, path)}`, 0);
|
|
13849
13529
|
}
|
|
13850
13530
|
}
|
|
13851
|
-
function
|
|
13852
|
-
const trimmed = line.trim();
|
|
13853
|
-
return trimmed === "" || trimmed.startsWith("#");
|
|
13854
|
-
}
|
|
13855
|
-
async function readListValues(raw, flagName, manifest = false) {
|
|
13531
|
+
async function readListValues(raw, flagName) {
|
|
13856
13532
|
const arguments_ = Array.isArray(raw) ? raw : [raw];
|
|
13857
13533
|
const values = [];
|
|
13858
13534
|
for (const argument of arguments_) {
|
|
@@ -13867,11 +13543,10 @@ async function readListValues(raw, flagName, manifest = false) {
|
|
|
13867
13543
|
const lines = source.text.split(/\r?\n/);
|
|
13868
13544
|
if (lines.at(-1) === "")
|
|
13869
13545
|
lines.pop();
|
|
13870
|
-
|
|
13871
|
-
if (kept.length === 0) {
|
|
13546
|
+
if (lines.length === 0) {
|
|
13872
13547
|
throw new SimApiError(`--${flagName}${source.from} contains no values`, 0);
|
|
13873
13548
|
}
|
|
13874
|
-
values.push(...
|
|
13549
|
+
values.push(...lines.map((line, index) => {
|
|
13875
13550
|
const value = line.trim();
|
|
13876
13551
|
if (!value) {
|
|
13877
13552
|
throw new SimApiError(`--${flagName}${source.from} has an empty value on line ${index + 1}`, 0);
|
|
@@ -13916,7 +13591,7 @@ async function coerce(raw, field, flag, flagName) {
|
|
|
13916
13591
|
if (raw === undefined)
|
|
13917
13592
|
return;
|
|
13918
13593
|
if (flag.list) {
|
|
13919
|
-
const values = (await readListValues(raw, flagName
|
|
13594
|
+
const values = (await readListValues(raw, flagName)).map((value) => flag.folderPath ? encodeFolderPath(value) : value);
|
|
13920
13595
|
return field.kind === "string" ? values.join(",") : values;
|
|
13921
13596
|
}
|
|
13922
13597
|
if (flag.rowCap)
|
|
@@ -14065,7 +13740,7 @@ function withoutWireVocabulary(documented) {
|
|
|
14065
13740
|
return documented.replace(WIRE_VOCABULARY_SENTENCE, " ").trim();
|
|
14066
13741
|
}
|
|
14067
13742
|
var NON_PAGINATED_LIMIT_HINT = " (caps a --filter match only; omit it to act on every match, and note 0 is not accepted)";
|
|
14068
|
-
function addFieldOption(command, operation, field, descriptor, slot, paginates
|
|
13743
|
+
function addFieldOption(command, operation, field, descriptor, slot, paginates) {
|
|
14069
13744
|
if (field === PROFILE_INJECTED_FIELD || field === "cursor")
|
|
14070
13745
|
return;
|
|
14071
13746
|
const flag = flagSpecFor(operation, field);
|
|
@@ -14077,7 +13752,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
|
|
|
14077
13752
|
command.option("--limit <n>", "Maximum items to return (0 for everything)", String(DEFAULT_LIMIT));
|
|
14078
13753
|
return;
|
|
14079
13754
|
}
|
|
14080
|
-
const documented = `${describeField(flag, descriptor, name, field)}${
|
|
13755
|
+
const documented = `${describeField(flag, descriptor, name, field)}${field === "limit" && (descriptor.kind === "number" || descriptor.kind === "integer") ? NON_PAGINATED_LIMIT_HINT : ""}`;
|
|
14081
13756
|
if (descriptor.kind === "boolean" || flag.boolean) {
|
|
14082
13757
|
const booleanDoc = withoutWireVocabulary(documented);
|
|
14083
13758
|
if (descriptor.required) {
|
|
@@ -14095,7 +13770,7 @@ function addFieldOption(command, operation, field, descriptor, slot, paginates,
|
|
|
14095
13770
|
const placeholder = takesList ? "<value...>" : flag.rowCap ? "<n>" : wantsJson ? "<json|@file>" : "<value>";
|
|
14096
13771
|
const choices = flag.choices ?? descriptor.values;
|
|
14097
13772
|
const literalNull = slot === "body" && !takesList && !wantsJson;
|
|
14098
|
-
const describe = `${documented}${takesList ?
|
|
13773
|
+
const describe = `${documented}${takesList ? " (space-separated, or @path / @- with one value per line; @@value for a literal leading @)" : wantsJson ? " (JSON, or @path / @- to read a file or stdin)" : ""}${descriptor.required ? " (required)" : ""}${literalNull ? literalNullHint(documented, name) : ""}`;
|
|
14099
13774
|
const renamedFrom = flag.renamedFrom ?? [];
|
|
14100
13775
|
const option = new Option(`${short}--${name} ${placeholder}`, describe);
|
|
14101
13776
|
if (flag.hidden)
|
|
@@ -14125,14 +13800,13 @@ function addOperationOptions(command, operation, commandSpec, operationSpec) {
|
|
|
14125
13800
|
command.addOption(new Option(`${short}--${name} <${flag.placeholder ?? "value"}>`, `${flag.describe ?? operationSpec.pathParamDocs?.[param] ?? `Set ${name.replaceAll("-", " ")}`} (required)`).makeOptionMandatory());
|
|
14126
13801
|
}
|
|
14127
13802
|
const paginates = cursorSlot(operationSpec) !== null;
|
|
14128
|
-
const capsAFilter = ["query", "body", "headers"].some((slot) => operationSpec[slot] !== undefined && ("filter" in operationSpec[slot]));
|
|
14129
13803
|
for (const slot of ["query", "body", "headers"]) {
|
|
14130
13804
|
for (const [field, descriptor] of Object.entries(operationSpec[slot] ?? {})) {
|
|
14131
13805
|
if (commandSpec.requestFields && !commandSpec.requestFields.includes(field))
|
|
14132
13806
|
continue;
|
|
14133
13807
|
if (commandSpec.positionals?.includes(field))
|
|
14134
13808
|
continue;
|
|
14135
|
-
addFieldOption(command, operation, field, descriptor, slot, paginates
|
|
13809
|
+
addFieldOption(command, operation, field, descriptor, slot, paginates);
|
|
14136
13810
|
}
|
|
14137
13811
|
}
|
|
14138
13812
|
if (commandSpec.allWorkspaces) {
|
|
@@ -14523,25 +14197,20 @@ function renderResult(operation, format, raw, spec, options = {}, envelope) {
|
|
|
14523
14197
|
}
|
|
14524
14198
|
|
|
14525
14199
|
// src/runtime/execute.ts
|
|
14526
|
-
var RUN_OUTCOME_OPERATIONS =
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
},
|
|
14531
|
-
executeTool: {
|
|
14532
|
-
failed: "The tool call failed."
|
|
14533
|
-
}
|
|
14200
|
+
var RUN_OUTCOME_OPERATIONS = new Set(["executeWorkflow"]);
|
|
14201
|
+
var FAILED_RUN_STATUS_MESSAGES = {
|
|
14202
|
+
failed: "The workflow run failed.",
|
|
14203
|
+
cancelled: "The workflow run was cancelled."
|
|
14534
14204
|
};
|
|
14535
14205
|
function runFailureMessage(operation, payload) {
|
|
14536
|
-
|
|
14537
|
-
if (!failureMessages)
|
|
14206
|
+
if (!RUN_OUTCOME_OPERATIONS.has(operation))
|
|
14538
14207
|
return null;
|
|
14539
14208
|
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
14540
14209
|
return null;
|
|
14541
14210
|
const { status, error } = payload;
|
|
14542
14211
|
if (typeof status !== "string")
|
|
14543
14212
|
return null;
|
|
14544
|
-
const fallback =
|
|
14213
|
+
const fallback = FAILED_RUN_STATUS_MESSAGES[status];
|
|
14545
14214
|
if (!fallback)
|
|
14546
14215
|
return null;
|
|
14547
14216
|
const reported = error?.message;
|
|
@@ -14855,7 +14524,6 @@ var GROUP_ALIASES = {
|
|
|
14855
14524
|
knowledge: "kb",
|
|
14856
14525
|
logs: "log",
|
|
14857
14526
|
"mcp-servers": "mcp-server",
|
|
14858
|
-
sandboxes: "sandbox",
|
|
14859
14527
|
secrets: "secret",
|
|
14860
14528
|
skills: "skill",
|
|
14861
14529
|
tables: "table",
|
|
@@ -17098,328 +16766,6 @@ function attachSecretCommands(program) {
|
|
|
17098
16766
|
secrets.command("set").argument("<name>", "Secret name, as referenced in workflows").description(describeOperation(V2_OPERATIONS.setSecret, "Create or replace a named secret")).addOption(new Option("--scope <scope>", "Secret ownership scope (required)").choices([...SECRET_SCOPES]).makeOptionMandatory()).option("--value <value|@file>", "Secret value. Passing it inline exposes it to shell history and process listings; @path reads it from a file and @- from stdin, verbatim — a trailing newline is part of the value, so write the file with printf rather than echo. Prefix a literal leading @ with a second one").option("--description <description>", "What the secret is for, shown to teammates; workspace scope only. Omit to leave an existing description unchanged").option("--unredacted", `${V2_OPERATIONS.setSecret.body.unredacted.describe} Pass --no-unredacted to restore redaction`).option("--no-unredacted", "Send --unredacted as false").on("option:unredacted", () => redactionSpellings.add("--unredacted")).on("option:no-unredacted", () => redactionSpellings.add("--no-unredacted")).action((name, options, command) => setSecret(name, options, command, redactionSpellings));
|
|
17099
16767
|
}
|
|
17100
16768
|
|
|
17101
|
-
// src/update/check.ts
|
|
17102
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
17103
|
-
import {
|
|
17104
|
-
closeSync,
|
|
17105
|
-
constants as constants2,
|
|
17106
|
-
fstatSync,
|
|
17107
|
-
lstatSync,
|
|
17108
|
-
mkdirSync as mkdirSync2,
|
|
17109
|
-
openSync,
|
|
17110
|
-
readSync as readSync2,
|
|
17111
|
-
renameSync,
|
|
17112
|
-
unlinkSync,
|
|
17113
|
-
writeFileSync as writeFileSync2
|
|
17114
|
-
} from "node:fs";
|
|
17115
|
-
import { dirname as dirname3 } from "node:path";
|
|
17116
|
-
import { fileURLToPath } from "node:url";
|
|
17117
|
-
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
17118
|
-
var REGISTRY_TIMEOUT_MS = 1000;
|
|
17119
|
-
var DEFAULT_REGISTRY = "https://registry.npmjs.org";
|
|
17120
|
-
var PACKAGE_NAME = "sim";
|
|
17121
|
-
var DIST_TAGS_PATH = `-/package/${PACKAGE_NAME}/dist-tags`;
|
|
17122
|
-
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
17123
|
-
var MAX_CACHE_BYTES = 4 * 1024;
|
|
17124
|
-
var STABLE_VERSION_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
|
|
17125
|
-
function parseStableVersion(version) {
|
|
17126
|
-
const match = STABLE_VERSION_PATTERN.exec(version);
|
|
17127
|
-
if (!match)
|
|
17128
|
-
return null;
|
|
17129
|
-
const parsed = [Number(match[1]), Number(match[2]), Number(match[3])];
|
|
17130
|
-
return parsed.every(Number.isSafeInteger) ? parsed : null;
|
|
17131
|
-
}
|
|
17132
|
-
function isNewerVersion(candidate, current) {
|
|
17133
|
-
if (candidate[0] !== current[0])
|
|
17134
|
-
return candidate[0] > current[0];
|
|
17135
|
-
if (candidate[1] !== current[1])
|
|
17136
|
-
return candidate[1] > current[1];
|
|
17137
|
-
return candidate[2] > current[2];
|
|
17138
|
-
}
|
|
17139
|
-
var CI_VARIABLES = [
|
|
17140
|
-
"CI",
|
|
17141
|
-
"GITHUB_ACTIONS",
|
|
17142
|
-
"JENKINS_URL",
|
|
17143
|
-
"TEAMCITY_VERSION",
|
|
17144
|
-
"BUILDKITE"
|
|
17145
|
-
];
|
|
17146
|
-
var CACHE_VERSION = 1;
|
|
17147
|
-
var cacheWriteSequence = 0;
|
|
17148
|
-
function isEnabled(value) {
|
|
17149
|
-
if (value === undefined)
|
|
17150
|
-
return false;
|
|
17151
|
-
const normalized = value.trim().toLowerCase();
|
|
17152
|
-
return normalized !== "" && normalized !== "0" && normalized !== "false";
|
|
17153
|
-
}
|
|
17154
|
-
function isProjectLocalInstall(modulePath, cwd) {
|
|
17155
|
-
const normalizedModulePath = normalizeModulePath(modulePath);
|
|
17156
|
-
const nodeModulesIndex = normalizedModulePath.indexOf("/node_modules/");
|
|
17157
|
-
if (nodeModulesIndex < 0)
|
|
17158
|
-
return false;
|
|
17159
|
-
const installRoot = normalizedModulePath.slice(0, nodeModulesIndex);
|
|
17160
|
-
const workingDirectory = normalizeModulePath(cwd).replace(/\/+$/, "");
|
|
17161
|
-
return workingDirectory === installRoot || workingDirectory.startsWith(`${installRoot}/`);
|
|
17162
|
-
}
|
|
17163
|
-
function isUnadvisableInstall(modulePath, env, cwd) {
|
|
17164
|
-
const normalized = normalizeModulePath(modulePath);
|
|
17165
|
-
return env.npm_command === "exec" || normalized.includes("/_npx/") || normalized.includes("/packages/sim-cli/") || isProjectLocalInstall(modulePath, cwd);
|
|
17166
|
-
}
|
|
17167
|
-
function normalizeModulePath(modulePath) {
|
|
17168
|
-
return modulePath.replace(/\\/g, "/").toLowerCase();
|
|
17169
|
-
}
|
|
17170
|
-
function registryUrl(env) {
|
|
17171
|
-
const fallback = new URL(DIST_TAGS_PATH, DEFAULT_REGISTRY);
|
|
17172
|
-
const configured = env.npm_config_registry?.trim();
|
|
17173
|
-
if (!configured)
|
|
17174
|
-
return fallback;
|
|
17175
|
-
try {
|
|
17176
|
-
const base = new URL(configured);
|
|
17177
|
-
if (base.protocol !== "http:" && base.protocol !== "https:")
|
|
17178
|
-
return null;
|
|
17179
|
-
if (base.username || base.password)
|
|
17180
|
-
return null;
|
|
17181
|
-
base.pathname = `${base.pathname.replace(/\/$/, "")}/${DIST_TAGS_PATH}`;
|
|
17182
|
-
return base;
|
|
17183
|
-
} catch {
|
|
17184
|
-
return null;
|
|
17185
|
-
}
|
|
17186
|
-
}
|
|
17187
|
-
var REGISTRY_REQUEST_SCRIPT = `
|
|
17188
|
-
let input = ''
|
|
17189
|
-
process.stdin.setEncoding('utf8')
|
|
17190
|
-
for await (const chunk of process.stdin) input += chunk
|
|
17191
|
-
|
|
17192
|
-
try {
|
|
17193
|
-
const { url, headers, maxResponseBytes, timeoutMs } = JSON.parse(input)
|
|
17194
|
-
const deadline = setTimeout(() => process.exit(1), timeoutMs)
|
|
17195
|
-
const response = await fetch(url, { headers, redirect: 'error' })
|
|
17196
|
-
const declared = Number(response.headers.get('content-length'))
|
|
17197
|
-
|
|
17198
|
-
if (!response.ok || !response.body || (Number.isFinite(declared) && declared > maxResponseBytes)) {
|
|
17199
|
-
process.exit(1)
|
|
17200
|
-
}
|
|
17201
|
-
|
|
17202
|
-
const reader = response.body.getReader()
|
|
17203
|
-
const chunks = []
|
|
17204
|
-
let seen = 0
|
|
17205
|
-
|
|
17206
|
-
while (true) {
|
|
17207
|
-
const { done, value } = await reader.read()
|
|
17208
|
-
if (done) break
|
|
17209
|
-
seen += value.byteLength
|
|
17210
|
-
if (seen > maxResponseBytes) {
|
|
17211
|
-
process.exit(1)
|
|
17212
|
-
}
|
|
17213
|
-
chunks.push(Buffer.from(value))
|
|
17214
|
-
}
|
|
17215
|
-
|
|
17216
|
-
clearTimeout(deadline)
|
|
17217
|
-
process.stdout.write(Buffer.concat(chunks), () => process.exit(0))
|
|
17218
|
-
} catch {
|
|
17219
|
-
process.exit(1)
|
|
17220
|
-
}
|
|
17221
|
-
`;
|
|
17222
|
-
function registryProcessEnv() {
|
|
17223
|
-
const env = { ...process.env };
|
|
17224
|
-
for (const key of Object.keys(env)) {
|
|
17225
|
-
const normalized = key.toLowerCase();
|
|
17226
|
-
if (normalized === "npm_config_registry" || normalized === "sim_api_key")
|
|
17227
|
-
delete env[key];
|
|
17228
|
-
}
|
|
17229
|
-
return env;
|
|
17230
|
-
}
|
|
17231
|
-
function requestRegistry(url, { headers, maxResponseBytes, timeoutMs }) {
|
|
17232
|
-
return new Promise((resolve, reject) => {
|
|
17233
|
-
const proxyArguments = process.execArgv.filter((argument) => argument === "--use-env-proxy" || argument === "--no-use-env-proxy");
|
|
17234
|
-
const child = spawn2(process.execPath, [...proxyArguments, "--input-type=module", "--eval", REGISTRY_REQUEST_SCRIPT], {
|
|
17235
|
-
env: registryProcessEnv(),
|
|
17236
|
-
killSignal: "SIGKILL",
|
|
17237
|
-
stdio: ["pipe", "pipe", "ignore"],
|
|
17238
|
-
timeout: timeoutMs,
|
|
17239
|
-
windowsHide: true
|
|
17240
|
-
});
|
|
17241
|
-
const chunks = [];
|
|
17242
|
-
let failed = false;
|
|
17243
|
-
let seen = 0;
|
|
17244
|
-
child.stdout.on("data", (chunk) => {
|
|
17245
|
-
seen += chunk.byteLength;
|
|
17246
|
-
if (seen > maxResponseBytes) {
|
|
17247
|
-
failed = true;
|
|
17248
|
-
child.kill("SIGKILL");
|
|
17249
|
-
return;
|
|
17250
|
-
}
|
|
17251
|
-
chunks.push(chunk);
|
|
17252
|
-
});
|
|
17253
|
-
child.stdout.on("error", () => {
|
|
17254
|
-
failed = true;
|
|
17255
|
-
child.kill("SIGKILL");
|
|
17256
|
-
});
|
|
17257
|
-
child.stdin.on("error", () => {});
|
|
17258
|
-
child.once("error", reject);
|
|
17259
|
-
child.once("close", (code) => {
|
|
17260
|
-
resolve(code === 0 && !failed ? Buffer.concat(chunks).toString("utf8") : null);
|
|
17261
|
-
});
|
|
17262
|
-
child.stdin.end(JSON.stringify({ headers, maxResponseBytes, timeoutMs, url: url.href }));
|
|
17263
|
-
});
|
|
17264
|
-
}
|
|
17265
|
-
async function fetchDistTags(env, request) {
|
|
17266
|
-
try {
|
|
17267
|
-
const url = registryUrl(env);
|
|
17268
|
-
if (!url)
|
|
17269
|
-
return null;
|
|
17270
|
-
const text = await request(url, {
|
|
17271
|
-
headers: { accept: "application/json", "user-agent": `${PACKAGE_NAME}-cli/${cliVersion()}` },
|
|
17272
|
-
maxResponseBytes: MAX_RESPONSE_BYTES,
|
|
17273
|
-
timeoutMs: REGISTRY_TIMEOUT_MS
|
|
17274
|
-
});
|
|
17275
|
-
if (text === null || Buffer.byteLength(text) > MAX_RESPONSE_BYTES)
|
|
17276
|
-
return null;
|
|
17277
|
-
const body = JSON.parse(text);
|
|
17278
|
-
if (typeof body !== "object" || body === null || Array.isArray(body))
|
|
17279
|
-
return null;
|
|
17280
|
-
const tags = {};
|
|
17281
|
-
for (const [tag, version] of Object.entries(body)) {
|
|
17282
|
-
if (typeof version === "string")
|
|
17283
|
-
tags[tag] = version;
|
|
17284
|
-
}
|
|
17285
|
-
return tags;
|
|
17286
|
-
} catch {
|
|
17287
|
-
return null;
|
|
17288
|
-
}
|
|
17289
|
-
}
|
|
17290
|
-
function readCache(path) {
|
|
17291
|
-
let descriptor = null;
|
|
17292
|
-
try {
|
|
17293
|
-
if (!lstatSync(path).isFile())
|
|
17294
|
-
return null;
|
|
17295
|
-
descriptor = openSync(path, constants2.O_RDONLY | constants2.O_NONBLOCK | constants2.O_NOFOLLOW);
|
|
17296
|
-
const descriptorStats = fstatSync(descriptor);
|
|
17297
|
-
if (!descriptorStats.isFile() || descriptorStats.size > MAX_CACHE_BYTES) {
|
|
17298
|
-
return null;
|
|
17299
|
-
}
|
|
17300
|
-
const buffer = Buffer.allocUnsafe(MAX_CACHE_BYTES + 1);
|
|
17301
|
-
let bytesRead = 0;
|
|
17302
|
-
while (bytesRead < buffer.byteLength) {
|
|
17303
|
-
const count = readSync2(descriptor, buffer, bytesRead, buffer.byteLength - bytesRead, bytesRead);
|
|
17304
|
-
if (count === 0)
|
|
17305
|
-
break;
|
|
17306
|
-
bytesRead += count;
|
|
17307
|
-
}
|
|
17308
|
-
if (bytesRead > MAX_CACHE_BYTES)
|
|
17309
|
-
return null;
|
|
17310
|
-
const parsed = JSON.parse(buffer.subarray(0, bytesRead).toString("utf8"));
|
|
17311
|
-
if (typeof parsed !== "object" || parsed === null)
|
|
17312
|
-
return null;
|
|
17313
|
-
const entry = parsed;
|
|
17314
|
-
if (entry.version !== CACHE_VERSION)
|
|
17315
|
-
return null;
|
|
17316
|
-
if (typeof entry.checkedAt !== "string" || Number.isNaN(Date.parse(entry.checkedAt)))
|
|
17317
|
-
return null;
|
|
17318
|
-
return {
|
|
17319
|
-
version: CACHE_VERSION,
|
|
17320
|
-
checkedAt: entry.checkedAt
|
|
17321
|
-
};
|
|
17322
|
-
} catch {
|
|
17323
|
-
return null;
|
|
17324
|
-
} finally {
|
|
17325
|
-
if (descriptor !== null) {
|
|
17326
|
-
try {
|
|
17327
|
-
closeSync(descriptor);
|
|
17328
|
-
} catch {}
|
|
17329
|
-
}
|
|
17330
|
-
}
|
|
17331
|
-
}
|
|
17332
|
-
function writeCache(path, entry) {
|
|
17333
|
-
let descriptor = null;
|
|
17334
|
-
let temporaryCreated = false;
|
|
17335
|
-
const temporaryPath = `${path}.${process.pid}.${Date.now()}.${cacheWriteSequence++}.tmp`;
|
|
17336
|
-
try {
|
|
17337
|
-
mkdirSync2(dirname3(path), { recursive: true, mode: 448 });
|
|
17338
|
-
descriptor = openSync(temporaryPath, "wx", 420);
|
|
17339
|
-
temporaryCreated = true;
|
|
17340
|
-
writeFileSync2(descriptor, `${JSON.stringify(entry, null, 2)}
|
|
17341
|
-
`);
|
|
17342
|
-
closeSync(descriptor);
|
|
17343
|
-
descriptor = null;
|
|
17344
|
-
renameSync(temporaryPath, path);
|
|
17345
|
-
temporaryCreated = false;
|
|
17346
|
-
} catch {} finally {
|
|
17347
|
-
if (descriptor !== null) {
|
|
17348
|
-
try {
|
|
17349
|
-
closeSync(descriptor);
|
|
17350
|
-
} catch {}
|
|
17351
|
-
}
|
|
17352
|
-
if (temporaryCreated) {
|
|
17353
|
-
try {
|
|
17354
|
-
unlinkSync(temporaryPath);
|
|
17355
|
-
} catch {}
|
|
17356
|
-
}
|
|
17357
|
-
}
|
|
17358
|
-
}
|
|
17359
|
-
function isFresh(entry, now) {
|
|
17360
|
-
const age = now.getTime() - Date.parse(entry.checkedAt);
|
|
17361
|
-
return age >= 0 && age < CHECK_INTERVAL_MS;
|
|
17362
|
-
}
|
|
17363
|
-
function upgradeCommand(modulePath = fileURLToPath(import.meta.url), env = process.env) {
|
|
17364
|
-
const target = `${PACKAGE_NAME}@latest`;
|
|
17365
|
-
const normalized = normalizeModulePath(modulePath);
|
|
17366
|
-
if (normalized.includes(".bun/install/global"))
|
|
17367
|
-
return `bun add -g ${target}`;
|
|
17368
|
-
if (normalized.includes("/pnpm/") || normalized.includes("/.pnpm/")) {
|
|
17369
|
-
return `pnpm add -g ${target}`;
|
|
17370
|
-
}
|
|
17371
|
-
if (normalized.includes("/.yarn/") || normalized.includes("/yarn/")) {
|
|
17372
|
-
return `yarn global add ${target}`;
|
|
17373
|
-
}
|
|
17374
|
-
const agent = env.npm_config_user_agent ?? "";
|
|
17375
|
-
if (agent.startsWith("pnpm/"))
|
|
17376
|
-
return `pnpm add -g ${target}`;
|
|
17377
|
-
if (agent.startsWith("yarn/"))
|
|
17378
|
-
return `yarn global add ${target}`;
|
|
17379
|
-
if (agent.startsWith("bun/"))
|
|
17380
|
-
return `bun add -g ${target}`;
|
|
17381
|
-
return `npm install -g ${target}`;
|
|
17382
|
-
}
|
|
17383
|
-
async function announceUpdateIfAvailable(options = {}) {
|
|
17384
|
-
try {
|
|
17385
|
-
const env = options.env ?? process.env;
|
|
17386
|
-
const isTty = options.isTty ?? process.stderr.isTTY === true;
|
|
17387
|
-
const modulePath = options.modulePath ?? fileURLToPath(import.meta.url);
|
|
17388
|
-
const cwd = options.cwd ?? process.cwd();
|
|
17389
|
-
const now = options.now ?? new Date;
|
|
17390
|
-
if (isEnabled(env.SIM_NO_UPDATE_CHECK))
|
|
17391
|
-
return;
|
|
17392
|
-
if (!isTty)
|
|
17393
|
-
return;
|
|
17394
|
-
if (CI_VARIABLES.some((variable) => isEnabled(env[variable])))
|
|
17395
|
-
return;
|
|
17396
|
-
if (isUnadvisableInstall(modulePath, env, cwd))
|
|
17397
|
-
return;
|
|
17398
|
-
const currentVersion = options.currentVersion ?? cliVersion();
|
|
17399
|
-
const current = parseStableVersion(currentVersion);
|
|
17400
|
-
if (!current)
|
|
17401
|
-
return;
|
|
17402
|
-
const cachePath = updateCachePath();
|
|
17403
|
-
const cached = readCache(cachePath);
|
|
17404
|
-
if (cached && isFresh(cached, now))
|
|
17405
|
-
return;
|
|
17406
|
-
const tags = await fetchDistTags(env, options.registryRequest ?? requestRegistry);
|
|
17407
|
-
const latest = tags?.latest ?? null;
|
|
17408
|
-
const available = latest ? parseStableVersion(latest) : null;
|
|
17409
|
-
writeCache(cachePath, {
|
|
17410
|
-
version: CACHE_VERSION,
|
|
17411
|
-
checkedAt: now.toISOString()
|
|
17412
|
-
});
|
|
17413
|
-
if (!latest || !available)
|
|
17414
|
-
return;
|
|
17415
|
-
if (!isNewerVersion(available, current))
|
|
17416
|
-
return;
|
|
17417
|
-
const write = options.write ?? ((message) => void process.stderr.write(message));
|
|
17418
|
-
write(`Update available: sim ${currentVersion} → ${latest}. Run: ${upgradeCommand(modulePath, env)}
|
|
17419
|
-
`);
|
|
17420
|
-
} catch {}
|
|
17421
|
-
}
|
|
17422
|
-
|
|
17423
16769
|
// src/program.ts
|
|
17424
16770
|
var PROGRAM_DESCRIPTION = "Talk to the Sim API from your terminal";
|
|
17425
16771
|
var HELP_EPILOGUE = `
|
|
@@ -17502,7 +16848,6 @@ function buildProgram(options = {}) {
|
|
|
17502
16848
|
attachProtocolCommands(program);
|
|
17503
16849
|
attachSecretCommands(program);
|
|
17504
16850
|
program.addHelpText("after", options.helpText ?? HELP_EPILOGUE);
|
|
17505
|
-
program.hook("preAction", () => announceUpdateIfAvailable());
|
|
17506
16851
|
refuseHelpAfterUnknownCommand(program);
|
|
17507
16852
|
assertNoReservedProgramFlags(program);
|
|
17508
16853
|
return program;
|