@vm0/cli 9.78.0 → 9.78.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/index.js +903 -1220
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -47,7 +47,7 @@ if (DSN) {
|
|
|
47
47
|
Sentry.init({
|
|
48
48
|
dsn: DSN,
|
|
49
49
|
environment: process.env.SENTRY_ENVIRONMENT ?? "production",
|
|
50
|
-
release: "9.78.
|
|
50
|
+
release: "9.78.1",
|
|
51
51
|
sendDefaultPii: false,
|
|
52
52
|
tracesSampleRate: 0,
|
|
53
53
|
shutdownTimeout: 500,
|
|
@@ -66,7 +66,7 @@ if (DSN) {
|
|
|
66
66
|
}
|
|
67
67
|
});
|
|
68
68
|
Sentry.setContext("cli", {
|
|
69
|
-
version: "9.78.
|
|
69
|
+
version: "9.78.1",
|
|
70
70
|
command: process.argv.slice(2).join(" ")
|
|
71
71
|
});
|
|
72
72
|
Sentry.setContext("runtime", {
|
|
@@ -85,7 +85,7 @@ process.stdout.on("error", handleEpipe);
|
|
|
85
85
|
process.stderr.on("error", handleEpipe);
|
|
86
86
|
|
|
87
87
|
// src/index.ts
|
|
88
|
-
import { Command as
|
|
88
|
+
import { Command as Command95 } from "commander";
|
|
89
89
|
|
|
90
90
|
// src/lib/network/proxy.ts
|
|
91
91
|
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
|
|
@@ -6632,6 +6632,58 @@ function resolveFirewallRef(input) {
|
|
|
6632
6632
|
return trimmed;
|
|
6633
6633
|
}
|
|
6634
6634
|
|
|
6635
|
+
// ../../packages/core/src/firewalls/agentmail.generated.ts
|
|
6636
|
+
var agentmailFirewall = {
|
|
6637
|
+
name: "agentmail",
|
|
6638
|
+
description: "AgentMail API",
|
|
6639
|
+
placeholders: {
|
|
6640
|
+
AGENTMAIL_TOKEN: "am_00000000000000000000000000000000"
|
|
6641
|
+
},
|
|
6642
|
+
apis: [
|
|
6643
|
+
{
|
|
6644
|
+
base: "https://api.agentmail.to",
|
|
6645
|
+
auth: {
|
|
6646
|
+
headers: {
|
|
6647
|
+
Authorization: "Bearer ${{ secrets.AGENTMAIL_TOKEN }}"
|
|
6648
|
+
}
|
|
6649
|
+
},
|
|
6650
|
+
permissions: [
|
|
6651
|
+
{
|
|
6652
|
+
name: "unrestricted",
|
|
6653
|
+
description: "Allow all endpoints",
|
|
6654
|
+
rules: ["ANY /{path*}"]
|
|
6655
|
+
}
|
|
6656
|
+
]
|
|
6657
|
+
}
|
|
6658
|
+
]
|
|
6659
|
+
};
|
|
6660
|
+
|
|
6661
|
+
// ../../packages/core/src/firewalls/ahrefs.generated.ts
|
|
6662
|
+
var ahrefsFirewall = {
|
|
6663
|
+
name: "ahrefs",
|
|
6664
|
+
description: "Ahrefs API",
|
|
6665
|
+
placeholders: {
|
|
6666
|
+
AHREFS_TOKEN: "Vm0PlaceHolder0000000000000000000000000000"
|
|
6667
|
+
},
|
|
6668
|
+
apis: [
|
|
6669
|
+
{
|
|
6670
|
+
base: "https://api.ahrefs.com",
|
|
6671
|
+
auth: {
|
|
6672
|
+
headers: {
|
|
6673
|
+
Authorization: "Bearer ${{ secrets.AHREFS_TOKEN }}"
|
|
6674
|
+
}
|
|
6675
|
+
},
|
|
6676
|
+
permissions: [
|
|
6677
|
+
{
|
|
6678
|
+
name: "unrestricted",
|
|
6679
|
+
description: "Allow all endpoints",
|
|
6680
|
+
rules: ["ANY /{path*}"]
|
|
6681
|
+
}
|
|
6682
|
+
]
|
|
6683
|
+
}
|
|
6684
|
+
]
|
|
6685
|
+
};
|
|
6686
|
+
|
|
6635
6687
|
// ../../packages/core/src/firewalls/confluence.generated.ts
|
|
6636
6688
|
var confluenceFirewall = {
|
|
6637
6689
|
name: "confluence",
|
|
@@ -12458,8 +12510,36 @@ var vercelFirewall = {
|
|
|
12458
12510
|
]
|
|
12459
12511
|
};
|
|
12460
12512
|
|
|
12513
|
+
// ../../packages/core/src/firewalls/zeptomail.generated.ts
|
|
12514
|
+
var zeptomailFirewall = {
|
|
12515
|
+
name: "zeptomail",
|
|
12516
|
+
description: "ZeptoMail API",
|
|
12517
|
+
placeholders: {
|
|
12518
|
+
ZEPTOMAIL_TOKEN: "vm0placeholder00000000000000000a"
|
|
12519
|
+
},
|
|
12520
|
+
apis: [
|
|
12521
|
+
{
|
|
12522
|
+
base: "https://api.zeptomail.com",
|
|
12523
|
+
auth: {
|
|
12524
|
+
headers: {
|
|
12525
|
+
Authorization: "Zoho-enczapikey ${{ secrets.ZEPTOMAIL_TOKEN }}"
|
|
12526
|
+
}
|
|
12527
|
+
},
|
|
12528
|
+
permissions: [
|
|
12529
|
+
{
|
|
12530
|
+
name: "unrestricted",
|
|
12531
|
+
description: "Allow all endpoints",
|
|
12532
|
+
rules: ["ANY /{path*}"]
|
|
12533
|
+
}
|
|
12534
|
+
]
|
|
12535
|
+
}
|
|
12536
|
+
]
|
|
12537
|
+
};
|
|
12538
|
+
|
|
12461
12539
|
// ../../packages/core/src/firewalls/index.ts
|
|
12462
12540
|
var builtinFirewalls = {
|
|
12541
|
+
agentmail: agentmailFirewall,
|
|
12542
|
+
ahrefs: ahrefsFirewall,
|
|
12463
12543
|
confluence: confluenceFirewall,
|
|
12464
12544
|
figma: figmaFirewall,
|
|
12465
12545
|
github: githubFirewall,
|
|
@@ -12471,7 +12551,8 @@ var builtinFirewalls = {
|
|
|
12471
12551
|
jira: jiraFirewall,
|
|
12472
12552
|
notion: notionFirewall,
|
|
12473
12553
|
slack: slackFirewall,
|
|
12474
|
-
vercel: vercelFirewall
|
|
12554
|
+
vercel: vercelFirewall,
|
|
12555
|
+
zeptomail: zeptomailFirewall
|
|
12475
12556
|
};
|
|
12476
12557
|
|
|
12477
12558
|
// ../../packages/core/src/firewall-loader.ts
|
|
@@ -13467,7 +13548,7 @@ import { z as z31 } from "zod";
|
|
|
13467
13548
|
var c25 = initContract();
|
|
13468
13549
|
var scheduleResponseSchema = z31.object({
|
|
13469
13550
|
id: z31.string().uuid(),
|
|
13470
|
-
|
|
13551
|
+
agentId: z31.string().uuid(),
|
|
13471
13552
|
agentName: z31.string(),
|
|
13472
13553
|
orgSlug: z31.string(),
|
|
13473
13554
|
userId: z31.string(),
|
|
@@ -13514,13 +13595,13 @@ var zeroDeployScheduleRequestSchema = z31.object({
|
|
|
13514
13595
|
artifactName: z31.string().optional(),
|
|
13515
13596
|
artifactVersion: z31.string().optional(),
|
|
13516
13597
|
volumeVersions: z31.record(z31.string(), z31.string()).optional(),
|
|
13517
|
-
|
|
13598
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13518
13599
|
composeId: z31.string().uuid("Invalid compose ID").optional(),
|
|
13519
13600
|
enabled: z31.boolean().optional(),
|
|
13520
13601
|
notifyEmail: z31.boolean().optional(),
|
|
13521
13602
|
notifySlack: z31.boolean().optional()
|
|
13522
|
-
}).refine((data) => Boolean(data.
|
|
13523
|
-
message: "Either '
|
|
13603
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13604
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13524
13605
|
}).refine(
|
|
13525
13606
|
(data) => {
|
|
13526
13607
|
const triggers = [
|
|
@@ -13571,10 +13652,10 @@ var zeroSchedulesByNameContract = c25.router({
|
|
|
13571
13652
|
name: z31.string().min(1, "Schedule name required")
|
|
13572
13653
|
}),
|
|
13573
13654
|
query: z31.object({
|
|
13574
|
-
|
|
13655
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13575
13656
|
composeId: z31.string().uuid("Invalid compose ID").optional()
|
|
13576
|
-
}).refine((data) => Boolean(data.
|
|
13577
|
-
message: "Either '
|
|
13657
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13658
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13578
13659
|
}),
|
|
13579
13660
|
responses: {
|
|
13580
13661
|
204: c25.noBody(),
|
|
@@ -13594,10 +13675,10 @@ var zeroSchedulesEnableContract = c25.router({
|
|
|
13594
13675
|
name: z31.string().min(1, "Schedule name required")
|
|
13595
13676
|
}),
|
|
13596
13677
|
body: z31.object({
|
|
13597
|
-
|
|
13678
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13598
13679
|
composeId: z31.string().uuid("Invalid compose ID").optional()
|
|
13599
|
-
}).refine((data) => Boolean(data.
|
|
13600
|
-
message: "Either '
|
|
13680
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13681
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13601
13682
|
}),
|
|
13602
13683
|
responses: {
|
|
13603
13684
|
200: scheduleResponseSchema,
|
|
@@ -13616,10 +13697,10 @@ var zeroSchedulesEnableContract = c25.router({
|
|
|
13616
13697
|
name: z31.string().min(1, "Schedule name required")
|
|
13617
13698
|
}),
|
|
13618
13699
|
body: z31.object({
|
|
13619
|
-
|
|
13700
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13620
13701
|
composeId: z31.string().uuid("Invalid compose ID").optional()
|
|
13621
|
-
}).refine((data) => Boolean(data.
|
|
13622
|
-
message: "Either '
|
|
13702
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13703
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13623
13704
|
}),
|
|
13624
13705
|
responses: {
|
|
13625
13706
|
200: scheduleResponseSchema,
|
|
@@ -14637,7 +14718,7 @@ function getConfigPath() {
|
|
|
14637
14718
|
return join2(homedir2(), ".vm0", "config.json");
|
|
14638
14719
|
}
|
|
14639
14720
|
var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
|
|
14640
|
-
console.log(chalk4.bold(`VM0 CLI v${"9.78.
|
|
14721
|
+
console.log(chalk4.bold(`VM0 CLI v${"9.78.1"}`));
|
|
14641
14722
|
console.log();
|
|
14642
14723
|
const config = await loadConfig();
|
|
14643
14724
|
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
@@ -14860,48 +14941,11 @@ async function listStorages(query) {
|
|
|
14860
14941
|
handleError(result, `Failed to list ${query.type}s`);
|
|
14861
14942
|
}
|
|
14862
14943
|
|
|
14863
|
-
// src/lib/api/domains/connectors.ts
|
|
14864
|
-
import { initClient as initClient5 } from "@ts-rest/core";
|
|
14865
|
-
async function listConnectors() {
|
|
14866
|
-
const config = await getClientConfig();
|
|
14867
|
-
const client = initClient5(connectorsMainContract, config);
|
|
14868
|
-
const result = await client.list({ headers: {} });
|
|
14869
|
-
if (result.status === 200) {
|
|
14870
|
-
return result.body;
|
|
14871
|
-
}
|
|
14872
|
-
handleError(result, "Failed to list connectors");
|
|
14873
|
-
}
|
|
14874
|
-
async function deleteConnector(type2) {
|
|
14875
|
-
const config = await getClientConfig();
|
|
14876
|
-
const client = initClient5(connectorsByTypeContract, config);
|
|
14877
|
-
const result = await client.delete({
|
|
14878
|
-
params: { type: type2 }
|
|
14879
|
-
});
|
|
14880
|
-
if (result.status === 204) {
|
|
14881
|
-
return;
|
|
14882
|
-
}
|
|
14883
|
-
handleError(result, `Connector "${type2}" not found`);
|
|
14884
|
-
}
|
|
14885
|
-
async function getConnector(type2) {
|
|
14886
|
-
const config = await getClientConfig();
|
|
14887
|
-
const client = initClient5(connectorsByTypeContract, config);
|
|
14888
|
-
const result = await client.get({
|
|
14889
|
-
params: { type: type2 }
|
|
14890
|
-
});
|
|
14891
|
-
if (result.status === 200) {
|
|
14892
|
-
return result.body;
|
|
14893
|
-
}
|
|
14894
|
-
if (result.status === 404) {
|
|
14895
|
-
return null;
|
|
14896
|
-
}
|
|
14897
|
-
handleError(result, `Failed to get connector "${type2}"`);
|
|
14898
|
-
}
|
|
14899
|
-
|
|
14900
14944
|
// src/lib/api/domains/user-preferences.ts
|
|
14901
|
-
import { initClient as
|
|
14945
|
+
import { initClient as initClient5 } from "@ts-rest/core";
|
|
14902
14946
|
async function getUserPreferences() {
|
|
14903
14947
|
const config = await getClientConfig();
|
|
14904
|
-
const client =
|
|
14948
|
+
const client = initClient5(userPreferencesContract, config);
|
|
14905
14949
|
const result = await client.get({ headers: {} });
|
|
14906
14950
|
if (result.status === 200) {
|
|
14907
14951
|
return result.body;
|
|
@@ -14910,7 +14954,7 @@ async function getUserPreferences() {
|
|
|
14910
14954
|
}
|
|
14911
14955
|
async function updateUserPreferences(body) {
|
|
14912
14956
|
const config = await getClientConfig();
|
|
14913
|
-
const client =
|
|
14957
|
+
const client = initClient5(userPreferencesContract, config);
|
|
14914
14958
|
const result = await client.update({ body });
|
|
14915
14959
|
if (result.status === 200) {
|
|
14916
14960
|
return result.body;
|
|
@@ -15001,7 +15045,7 @@ async function resolveSkills(skillUrls) {
|
|
|
15001
15045
|
}
|
|
15002
15046
|
|
|
15003
15047
|
// src/lib/api/domains/zero-orgs.ts
|
|
15004
|
-
import { initClient as
|
|
15048
|
+
import { initClient as initClient6 } from "@ts-rest/core";
|
|
15005
15049
|
async function getUserTokenClientConfig() {
|
|
15006
15050
|
const baseUrl = await getBaseUrl();
|
|
15007
15051
|
const token = await getToken();
|
|
@@ -15019,7 +15063,7 @@ async function getUserTokenClientConfig() {
|
|
|
15019
15063
|
}
|
|
15020
15064
|
async function getZeroOrg() {
|
|
15021
15065
|
const config = await getClientConfig();
|
|
15022
|
-
const client =
|
|
15066
|
+
const client = initClient6(zeroOrgContract, config);
|
|
15023
15067
|
const result = await client.get({ headers: {} });
|
|
15024
15068
|
if (result.status === 200) {
|
|
15025
15069
|
return result.body;
|
|
@@ -15028,7 +15072,7 @@ async function getZeroOrg() {
|
|
|
15028
15072
|
}
|
|
15029
15073
|
async function updateZeroOrg(body) {
|
|
15030
15074
|
const config = await getClientConfig();
|
|
15031
|
-
const client =
|
|
15075
|
+
const client = initClient6(zeroOrgContract, config);
|
|
15032
15076
|
const result = await client.update({ body });
|
|
15033
15077
|
if (result.status === 200) {
|
|
15034
15078
|
return result.body;
|
|
@@ -15037,7 +15081,7 @@ async function updateZeroOrg(body) {
|
|
|
15037
15081
|
}
|
|
15038
15082
|
async function listZeroOrgs() {
|
|
15039
15083
|
const config = await getUserTokenClientConfig();
|
|
15040
|
-
const client =
|
|
15084
|
+
const client = initClient6(zeroOrgListContract, config);
|
|
15041
15085
|
const result = await client.list({ headers: {} });
|
|
15042
15086
|
if (result.status === 200) {
|
|
15043
15087
|
return result.body;
|
|
@@ -15046,7 +15090,7 @@ async function listZeroOrgs() {
|
|
|
15046
15090
|
}
|
|
15047
15091
|
async function getZeroOrgMembers() {
|
|
15048
15092
|
const config = await getClientConfig();
|
|
15049
|
-
const client =
|
|
15093
|
+
const client = initClient6(zeroOrgMembersContract, config);
|
|
15050
15094
|
const result = await client.members({ headers: {} });
|
|
15051
15095
|
if (result.status === 200) {
|
|
15052
15096
|
return result.body;
|
|
@@ -15055,7 +15099,7 @@ async function getZeroOrgMembers() {
|
|
|
15055
15099
|
}
|
|
15056
15100
|
async function inviteZeroOrgMember(email) {
|
|
15057
15101
|
const config = await getClientConfig();
|
|
15058
|
-
const client =
|
|
15102
|
+
const client = initClient6(zeroOrgInviteContract, config);
|
|
15059
15103
|
const result = await client.invite({
|
|
15060
15104
|
body: { email }
|
|
15061
15105
|
});
|
|
@@ -15066,7 +15110,7 @@ async function inviteZeroOrgMember(email) {
|
|
|
15066
15110
|
}
|
|
15067
15111
|
async function removeZeroOrgMember(email) {
|
|
15068
15112
|
const config = await getClientConfig();
|
|
15069
|
-
const client =
|
|
15113
|
+
const client = initClient6(zeroOrgMembersContract, config);
|
|
15070
15114
|
const result = await client.removeMember({
|
|
15071
15115
|
body: { email }
|
|
15072
15116
|
});
|
|
@@ -15077,7 +15121,7 @@ async function removeZeroOrgMember(email) {
|
|
|
15077
15121
|
}
|
|
15078
15122
|
async function leaveZeroOrg() {
|
|
15079
15123
|
const config = await getClientConfig();
|
|
15080
|
-
const client =
|
|
15124
|
+
const client = initClient6(zeroOrgLeaveContract, config);
|
|
15081
15125
|
const result = await client.leave({
|
|
15082
15126
|
body: {}
|
|
15083
15127
|
});
|
|
@@ -15088,7 +15132,7 @@ async function leaveZeroOrg() {
|
|
|
15088
15132
|
}
|
|
15089
15133
|
async function deleteZeroOrg(slug) {
|
|
15090
15134
|
const config = await getClientConfig();
|
|
15091
|
-
const client =
|
|
15135
|
+
const client = initClient6(zeroOrgDeleteContract, config);
|
|
15092
15136
|
const result = await client.delete({
|
|
15093
15137
|
body: { slug }
|
|
15094
15138
|
});
|
|
@@ -15099,10 +15143,10 @@ async function deleteZeroOrg(slug) {
|
|
|
15099
15143
|
}
|
|
15100
15144
|
|
|
15101
15145
|
// src/lib/api/domains/zero-secrets.ts
|
|
15102
|
-
import { initClient as
|
|
15146
|
+
import { initClient as initClient7 } from "@ts-rest/core";
|
|
15103
15147
|
async function listZeroSecrets() {
|
|
15104
15148
|
const config = await getClientConfig();
|
|
15105
|
-
const client =
|
|
15149
|
+
const client = initClient7(zeroSecretsContract, config);
|
|
15106
15150
|
const result = await client.list({ headers: {} });
|
|
15107
15151
|
if (result.status === 200) {
|
|
15108
15152
|
return result.body;
|
|
@@ -15111,7 +15155,7 @@ async function listZeroSecrets() {
|
|
|
15111
15155
|
}
|
|
15112
15156
|
async function setZeroSecret(body) {
|
|
15113
15157
|
const config = await getClientConfig();
|
|
15114
|
-
const client =
|
|
15158
|
+
const client = initClient7(zeroSecretsContract, config);
|
|
15115
15159
|
const result = await client.set({ body });
|
|
15116
15160
|
if (result.status === 200 || result.status === 201) {
|
|
15117
15161
|
return result.body;
|
|
@@ -15120,7 +15164,7 @@ async function setZeroSecret(body) {
|
|
|
15120
15164
|
}
|
|
15121
15165
|
async function deleteZeroSecret(name) {
|
|
15122
15166
|
const config = await getClientConfig();
|
|
15123
|
-
const client =
|
|
15167
|
+
const client = initClient7(zeroSecretsByNameContract, config);
|
|
15124
15168
|
const result = await client.delete({
|
|
15125
15169
|
params: { name }
|
|
15126
15170
|
});
|
|
@@ -15131,10 +15175,10 @@ async function deleteZeroSecret(name) {
|
|
|
15131
15175
|
}
|
|
15132
15176
|
|
|
15133
15177
|
// src/lib/api/domains/zero-variables.ts
|
|
15134
|
-
import { initClient as
|
|
15178
|
+
import { initClient as initClient8 } from "@ts-rest/core";
|
|
15135
15179
|
async function listZeroVariables() {
|
|
15136
15180
|
const config = await getClientConfig();
|
|
15137
|
-
const client =
|
|
15181
|
+
const client = initClient8(zeroVariablesContract, config);
|
|
15138
15182
|
const result = await client.list({ headers: {} });
|
|
15139
15183
|
if (result.status === 200) {
|
|
15140
15184
|
return result.body;
|
|
@@ -15143,7 +15187,7 @@ async function listZeroVariables() {
|
|
|
15143
15187
|
}
|
|
15144
15188
|
async function setZeroVariable(body) {
|
|
15145
15189
|
const config = await getClientConfig();
|
|
15146
|
-
const client =
|
|
15190
|
+
const client = initClient8(zeroVariablesContract, config);
|
|
15147
15191
|
const result = await client.set({ body });
|
|
15148
15192
|
if (result.status === 200 || result.status === 201) {
|
|
15149
15193
|
return result.body;
|
|
@@ -15152,7 +15196,7 @@ async function setZeroVariable(body) {
|
|
|
15152
15196
|
}
|
|
15153
15197
|
async function deleteZeroVariable(name) {
|
|
15154
15198
|
const config = await getClientConfig();
|
|
15155
|
-
const client =
|
|
15199
|
+
const client = initClient8(zeroVariablesByNameContract, config);
|
|
15156
15200
|
const result = await client.delete({
|
|
15157
15201
|
params: { name }
|
|
15158
15202
|
});
|
|
@@ -15163,10 +15207,10 @@ async function deleteZeroVariable(name) {
|
|
|
15163
15207
|
}
|
|
15164
15208
|
|
|
15165
15209
|
// src/lib/api/domains/zero-org-secrets.ts
|
|
15166
|
-
import { initClient as
|
|
15210
|
+
import { initClient as initClient9 } from "@ts-rest/core";
|
|
15167
15211
|
async function listZeroOrgSecrets() {
|
|
15168
15212
|
const config = await getClientConfig();
|
|
15169
|
-
const client =
|
|
15213
|
+
const client = initClient9(zeroSecretsContract, config);
|
|
15170
15214
|
const result = await client.list({ headers: {} });
|
|
15171
15215
|
if (result.status === 200) {
|
|
15172
15216
|
return result.body;
|
|
@@ -15175,7 +15219,7 @@ async function listZeroOrgSecrets() {
|
|
|
15175
15219
|
}
|
|
15176
15220
|
async function setZeroOrgSecret(body) {
|
|
15177
15221
|
const config = await getClientConfig();
|
|
15178
|
-
const client =
|
|
15222
|
+
const client = initClient9(zeroSecretsContract, config);
|
|
15179
15223
|
const result = await client.set({ body });
|
|
15180
15224
|
if (result.status === 200 || result.status === 201) {
|
|
15181
15225
|
return result.body;
|
|
@@ -15184,7 +15228,7 @@ async function setZeroOrgSecret(body) {
|
|
|
15184
15228
|
}
|
|
15185
15229
|
async function deleteZeroOrgSecret(name) {
|
|
15186
15230
|
const config = await getClientConfig();
|
|
15187
|
-
const client =
|
|
15231
|
+
const client = initClient9(zeroSecretsByNameContract, config);
|
|
15188
15232
|
const result = await client.delete({
|
|
15189
15233
|
params: { name }
|
|
15190
15234
|
});
|
|
@@ -15195,10 +15239,10 @@ async function deleteZeroOrgSecret(name) {
|
|
|
15195
15239
|
}
|
|
15196
15240
|
|
|
15197
15241
|
// src/lib/api/domains/zero-org-variables.ts
|
|
15198
|
-
import { initClient as
|
|
15242
|
+
import { initClient as initClient10 } from "@ts-rest/core";
|
|
15199
15243
|
async function listZeroOrgVariables() {
|
|
15200
15244
|
const config = await getClientConfig();
|
|
15201
|
-
const client =
|
|
15245
|
+
const client = initClient10(zeroVariablesContract, config);
|
|
15202
15246
|
const result = await client.list({ headers: {} });
|
|
15203
15247
|
if (result.status === 200) {
|
|
15204
15248
|
return result.body;
|
|
@@ -15207,7 +15251,7 @@ async function listZeroOrgVariables() {
|
|
|
15207
15251
|
}
|
|
15208
15252
|
async function setZeroOrgVariable(body) {
|
|
15209
15253
|
const config = await getClientConfig();
|
|
15210
|
-
const client =
|
|
15254
|
+
const client = initClient10(zeroVariablesContract, config);
|
|
15211
15255
|
const result = await client.set({ body });
|
|
15212
15256
|
if (result.status === 200 || result.status === 201) {
|
|
15213
15257
|
return result.body;
|
|
@@ -15216,7 +15260,7 @@ async function setZeroOrgVariable(body) {
|
|
|
15216
15260
|
}
|
|
15217
15261
|
async function deleteZeroOrgVariable(name) {
|
|
15218
15262
|
const config = await getClientConfig();
|
|
15219
|
-
const client =
|
|
15263
|
+
const client = initClient10(zeroVariablesByNameContract, config);
|
|
15220
15264
|
const result = await client.delete({
|
|
15221
15265
|
params: { name }
|
|
15222
15266
|
});
|
|
@@ -15227,10 +15271,10 @@ async function deleteZeroOrgVariable(name) {
|
|
|
15227
15271
|
}
|
|
15228
15272
|
|
|
15229
15273
|
// src/lib/api/domains/zero-org-model-providers.ts
|
|
15230
|
-
import { initClient as
|
|
15274
|
+
import { initClient as initClient11 } from "@ts-rest/core";
|
|
15231
15275
|
async function listZeroOrgModelProviders() {
|
|
15232
15276
|
const config = await getClientConfig();
|
|
15233
|
-
const client =
|
|
15277
|
+
const client = initClient11(zeroModelProvidersMainContract, config);
|
|
15234
15278
|
const result = await client.list({ headers: {} });
|
|
15235
15279
|
if (result.status === 200) {
|
|
15236
15280
|
return result.body;
|
|
@@ -15239,7 +15283,7 @@ async function listZeroOrgModelProviders() {
|
|
|
15239
15283
|
}
|
|
15240
15284
|
async function upsertZeroOrgModelProvider(body) {
|
|
15241
15285
|
const config = await getClientConfig();
|
|
15242
|
-
const client =
|
|
15286
|
+
const client = initClient11(zeroModelProvidersMainContract, config);
|
|
15243
15287
|
const result = await client.upsert({ body });
|
|
15244
15288
|
if (result.status === 200 || result.status === 201) {
|
|
15245
15289
|
return result.body;
|
|
@@ -15248,7 +15292,7 @@ async function upsertZeroOrgModelProvider(body) {
|
|
|
15248
15292
|
}
|
|
15249
15293
|
async function deleteZeroOrgModelProvider(type2) {
|
|
15250
15294
|
const config = await getClientConfig();
|
|
15251
|
-
const client =
|
|
15295
|
+
const client = initClient11(zeroModelProvidersByTypeContract, config);
|
|
15252
15296
|
const result = await client.delete({
|
|
15253
15297
|
params: { type: type2 }
|
|
15254
15298
|
});
|
|
@@ -15259,7 +15303,7 @@ async function deleteZeroOrgModelProvider(type2) {
|
|
|
15259
15303
|
}
|
|
15260
15304
|
async function setZeroOrgModelProviderDefault(type2) {
|
|
15261
15305
|
const config = await getClientConfig();
|
|
15262
|
-
const client =
|
|
15306
|
+
const client = initClient11(zeroModelProvidersDefaultContract, config);
|
|
15263
15307
|
const result = await client.setDefault({
|
|
15264
15308
|
params: { type: type2 }
|
|
15265
15309
|
});
|
|
@@ -15270,7 +15314,7 @@ async function setZeroOrgModelProviderDefault(type2) {
|
|
|
15270
15314
|
}
|
|
15271
15315
|
async function updateZeroOrgModelProviderModel(type2, selectedModel) {
|
|
15272
15316
|
const config = await getClientConfig();
|
|
15273
|
-
const client =
|
|
15317
|
+
const client = initClient11(zeroModelProvidersUpdateModelContract, config);
|
|
15274
15318
|
const result = await client.updateModel({
|
|
15275
15319
|
params: { type: type2 },
|
|
15276
15320
|
body: { selectedModel }
|
|
@@ -15282,52 +15326,52 @@ async function updateZeroOrgModelProviderModel(type2, selectedModel) {
|
|
|
15282
15326
|
}
|
|
15283
15327
|
|
|
15284
15328
|
// src/lib/api/domains/zero-agents.ts
|
|
15285
|
-
import { initClient as
|
|
15329
|
+
import { initClient as initClient12 } from "@ts-rest/core";
|
|
15286
15330
|
async function createZeroAgent(body) {
|
|
15287
15331
|
const config = await getClientConfig();
|
|
15288
|
-
const client =
|
|
15332
|
+
const client = initClient12(zeroAgentsMainContract, config);
|
|
15289
15333
|
const result = await client.create({ body });
|
|
15290
15334
|
if (result.status === 201) return result.body;
|
|
15291
15335
|
handleError(result, "Failed to create zero agent");
|
|
15292
15336
|
}
|
|
15293
15337
|
async function listZeroAgents() {
|
|
15294
15338
|
const config = await getClientConfig();
|
|
15295
|
-
const client =
|
|
15339
|
+
const client = initClient12(zeroAgentsMainContract, config);
|
|
15296
15340
|
const result = await client.list({ headers: {} });
|
|
15297
15341
|
if (result.status === 200) return result.body;
|
|
15298
15342
|
handleError(result, "Failed to list zero agents");
|
|
15299
15343
|
}
|
|
15300
15344
|
async function getZeroAgent(name) {
|
|
15301
15345
|
const config = await getClientConfig();
|
|
15302
|
-
const client =
|
|
15346
|
+
const client = initClient12(zeroAgentsByNameContract, config);
|
|
15303
15347
|
const result = await client.get({ params: { name } });
|
|
15304
15348
|
if (result.status === 200) return result.body;
|
|
15305
15349
|
handleError(result, `Zero agent "${name}" not found`);
|
|
15306
15350
|
}
|
|
15307
15351
|
async function updateZeroAgent(name, body) {
|
|
15308
15352
|
const config = await getClientConfig();
|
|
15309
|
-
const client =
|
|
15353
|
+
const client = initClient12(zeroAgentsByNameContract, config);
|
|
15310
15354
|
const result = await client.update({ params: { name }, body });
|
|
15311
15355
|
if (result.status === 200) return result.body;
|
|
15312
15356
|
handleError(result, `Failed to update zero agent "${name}"`);
|
|
15313
15357
|
}
|
|
15314
15358
|
async function deleteZeroAgent(name) {
|
|
15315
15359
|
const config = await getClientConfig();
|
|
15316
|
-
const client =
|
|
15360
|
+
const client = initClient12(zeroAgentsByNameContract, config);
|
|
15317
15361
|
const result = await client.delete({ params: { name } });
|
|
15318
15362
|
if (result.status === 204) return;
|
|
15319
15363
|
handleError(result, `Zero agent "${name}" not found`);
|
|
15320
15364
|
}
|
|
15321
15365
|
async function getZeroAgentInstructions(name) {
|
|
15322
15366
|
const config = await getClientConfig();
|
|
15323
|
-
const client =
|
|
15367
|
+
const client = initClient12(zeroAgentInstructionsContract, config);
|
|
15324
15368
|
const result = await client.get({ params: { name } });
|
|
15325
15369
|
if (result.status === 200) return result.body;
|
|
15326
15370
|
handleError(result, `Failed to get instructions for zero agent "${name}"`);
|
|
15327
15371
|
}
|
|
15328
15372
|
async function updateZeroAgentInstructions(name, content) {
|
|
15329
15373
|
const config = await getClientConfig();
|
|
15330
|
-
const client =
|
|
15374
|
+
const client = initClient12(zeroAgentInstructionsContract, config);
|
|
15331
15375
|
const result = await client.update({
|
|
15332
15376
|
params: { name },
|
|
15333
15377
|
body: { content }
|
|
@@ -15337,10 +15381,10 @@ async function updateZeroAgentInstructions(name, content) {
|
|
|
15337
15381
|
}
|
|
15338
15382
|
|
|
15339
15383
|
// src/lib/api/domains/zero-connectors.ts
|
|
15340
|
-
import { initClient as
|
|
15384
|
+
import { initClient as initClient13 } from "@ts-rest/core";
|
|
15341
15385
|
async function listZeroConnectors() {
|
|
15342
15386
|
const config = await getClientConfig();
|
|
15343
|
-
const client =
|
|
15387
|
+
const client = initClient13(zeroConnectorsMainContract, config);
|
|
15344
15388
|
const result = await client.list({ headers: {} });
|
|
15345
15389
|
if (result.status === 200) {
|
|
15346
15390
|
return result.body;
|
|
@@ -15349,7 +15393,7 @@ async function listZeroConnectors() {
|
|
|
15349
15393
|
}
|
|
15350
15394
|
async function getZeroConnector(type2) {
|
|
15351
15395
|
const config = await getClientConfig();
|
|
15352
|
-
const client =
|
|
15396
|
+
const client = initClient13(zeroConnectorsByTypeContract, config);
|
|
15353
15397
|
const result = await client.get({
|
|
15354
15398
|
params: { type: type2 }
|
|
15355
15399
|
});
|
|
@@ -15363,7 +15407,7 @@ async function getZeroConnector(type2) {
|
|
|
15363
15407
|
}
|
|
15364
15408
|
async function deleteZeroConnector(type2) {
|
|
15365
15409
|
const config = await getClientConfig();
|
|
15366
|
-
const client =
|
|
15410
|
+
const client = initClient13(zeroConnectorsByTypeContract, config);
|
|
15367
15411
|
const result = await client.delete({
|
|
15368
15412
|
params: { type: type2 }
|
|
15369
15413
|
});
|
|
@@ -15374,7 +15418,7 @@ async function deleteZeroConnector(type2) {
|
|
|
15374
15418
|
}
|
|
15375
15419
|
async function createZeroConnectorSession(type2) {
|
|
15376
15420
|
const config = await getClientConfig();
|
|
15377
|
-
const client =
|
|
15421
|
+
const client = initClient13(zeroConnectorSessionsContract, config);
|
|
15378
15422
|
const result = await client.create({
|
|
15379
15423
|
params: { type: type2 },
|
|
15380
15424
|
body: {}
|
|
@@ -15386,7 +15430,7 @@ async function createZeroConnectorSession(type2) {
|
|
|
15386
15430
|
}
|
|
15387
15431
|
async function getZeroConnectorSession(type2, sessionId) {
|
|
15388
15432
|
const config = await getClientConfig();
|
|
15389
|
-
const client =
|
|
15433
|
+
const client = initClient13(zeroConnectorSessionByIdContract, config);
|
|
15390
15434
|
const result = await client.get({
|
|
15391
15435
|
params: { type: type2, sessionId }
|
|
15392
15436
|
});
|
|
@@ -15397,7 +15441,7 @@ async function getZeroConnectorSession(type2, sessionId) {
|
|
|
15397
15441
|
}
|
|
15398
15442
|
async function createZeroComputerConnector() {
|
|
15399
15443
|
const config = await getClientConfig();
|
|
15400
|
-
const client =
|
|
15444
|
+
const client = initClient13(zeroComputerConnectorContract, config);
|
|
15401
15445
|
const result = await client.create({
|
|
15402
15446
|
body: {}
|
|
15403
15447
|
});
|
|
@@ -15408,7 +15452,7 @@ async function createZeroComputerConnector() {
|
|
|
15408
15452
|
}
|
|
15409
15453
|
async function deleteZeroComputerConnector() {
|
|
15410
15454
|
const config = await getClientConfig();
|
|
15411
|
-
const client =
|
|
15455
|
+
const client = initClient13(zeroComputerConnectorContract, config);
|
|
15412
15456
|
const result = await client.delete({});
|
|
15413
15457
|
if (result.status === 204) {
|
|
15414
15458
|
return;
|
|
@@ -15417,10 +15461,10 @@ async function deleteZeroComputerConnector() {
|
|
|
15417
15461
|
}
|
|
15418
15462
|
|
|
15419
15463
|
// src/lib/api/domains/zero-schedules.ts
|
|
15420
|
-
import { initClient as
|
|
15464
|
+
import { initClient as initClient14 } from "@ts-rest/core";
|
|
15421
15465
|
async function deployZeroSchedule(body) {
|
|
15422
15466
|
const config = await getClientConfig();
|
|
15423
|
-
const client =
|
|
15467
|
+
const client = initClient14(zeroSchedulesMainContract, config);
|
|
15424
15468
|
const result = await client.deploy({ body });
|
|
15425
15469
|
if (result.status === 200 || result.status === 201) {
|
|
15426
15470
|
return result.body;
|
|
@@ -15429,7 +15473,7 @@ async function deployZeroSchedule(body) {
|
|
|
15429
15473
|
}
|
|
15430
15474
|
async function listZeroSchedules() {
|
|
15431
15475
|
const config = await getClientConfig();
|
|
15432
|
-
const client =
|
|
15476
|
+
const client = initClient14(zeroSchedulesMainContract, config);
|
|
15433
15477
|
const result = await client.list({ headers: {} });
|
|
15434
15478
|
if (result.status === 200) {
|
|
15435
15479
|
return result.body;
|
|
@@ -15438,10 +15482,10 @@ async function listZeroSchedules() {
|
|
|
15438
15482
|
}
|
|
15439
15483
|
async function deleteZeroSchedule(params) {
|
|
15440
15484
|
const config = await getClientConfig();
|
|
15441
|
-
const client =
|
|
15485
|
+
const client = initClient14(zeroSchedulesByNameContract, config);
|
|
15442
15486
|
const result = await client.delete({
|
|
15443
15487
|
params: { name: params.name },
|
|
15444
|
-
query: {
|
|
15488
|
+
query: { agentId: params.agentId }
|
|
15445
15489
|
});
|
|
15446
15490
|
if (result.status === 204) {
|
|
15447
15491
|
return;
|
|
@@ -15450,10 +15494,10 @@ async function deleteZeroSchedule(params) {
|
|
|
15450
15494
|
}
|
|
15451
15495
|
async function enableZeroSchedule(params) {
|
|
15452
15496
|
const config = await getClientConfig();
|
|
15453
|
-
const client =
|
|
15497
|
+
const client = initClient14(zeroSchedulesEnableContract, config);
|
|
15454
15498
|
const result = await client.enable({
|
|
15455
15499
|
params: { name: params.name },
|
|
15456
|
-
body: {
|
|
15500
|
+
body: { agentId: params.agentId }
|
|
15457
15501
|
});
|
|
15458
15502
|
if (result.status === 200) {
|
|
15459
15503
|
return result.body;
|
|
@@ -15462,10 +15506,10 @@ async function enableZeroSchedule(params) {
|
|
|
15462
15506
|
}
|
|
15463
15507
|
async function disableZeroSchedule(params) {
|
|
15464
15508
|
const config = await getClientConfig();
|
|
15465
|
-
const client =
|
|
15509
|
+
const client = initClient14(zeroSchedulesEnableContract, config);
|
|
15466
15510
|
const result = await client.disable({
|
|
15467
15511
|
params: { name: params.name },
|
|
15468
|
-
body: {
|
|
15512
|
+
body: { agentId: params.agentId }
|
|
15469
15513
|
});
|
|
15470
15514
|
if (result.status === 200) {
|
|
15471
15515
|
return result.body;
|
|
@@ -16594,7 +16638,7 @@ async function checkAndPromptMissingItems(config, options) {
|
|
|
16594
16638
|
const [secretsResponse, variablesResponse, connectorsResponse] = await Promise.all([
|
|
16595
16639
|
requiredSecrets.size > 0 ? listZeroSecrets() : { secrets: [] },
|
|
16596
16640
|
requiredVars.size > 0 ? listZeroVariables() : { variables: [] },
|
|
16597
|
-
|
|
16641
|
+
listZeroConnectors()
|
|
16598
16642
|
]);
|
|
16599
16643
|
const existingSecretNames = new Set(
|
|
16600
16644
|
secretsResponse.secrets.map((s) => s.name)
|
|
@@ -16769,7 +16813,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
|
|
|
16769
16813
|
options.autoUpdate = false;
|
|
16770
16814
|
}
|
|
16771
16815
|
if (options.autoUpdate !== false) {
|
|
16772
|
-
await startSilentUpgrade("9.78.
|
|
16816
|
+
await startSilentUpgrade("9.78.1");
|
|
16773
16817
|
}
|
|
16774
16818
|
try {
|
|
16775
16819
|
let result;
|
|
@@ -17604,7 +17648,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
17604
17648
|
withErrorHandler(
|
|
17605
17649
|
async (identifier, prompt, options) => {
|
|
17606
17650
|
if (options.autoUpdate !== false) {
|
|
17607
|
-
await startSilentUpgrade("9.78.
|
|
17651
|
+
await startSilentUpgrade("9.78.1");
|
|
17608
17652
|
}
|
|
17609
17653
|
const { org, name, version } = parseIdentifier(identifier);
|
|
17610
17654
|
let composeId;
|
|
@@ -19360,7 +19404,7 @@ var cookAction = new Command35().name("cook").description("Quick start: prepare,
|
|
|
19360
19404
|
withErrorHandler(
|
|
19361
19405
|
async (prompt, options) => {
|
|
19362
19406
|
if (options.autoUpdate !== false) {
|
|
19363
|
-
const shouldExit = await checkAndUpgrade("9.78.
|
|
19407
|
+
const shouldExit = await checkAndUpgrade("9.78.1", prompt);
|
|
19364
19408
|
if (shouldExit) {
|
|
19365
19409
|
process.exit(0);
|
|
19366
19410
|
}
|
|
@@ -19546,7 +19590,7 @@ import { Command as Command40 } from "commander";
|
|
|
19546
19590
|
import chalk36 from "chalk";
|
|
19547
19591
|
|
|
19548
19592
|
// src/lib/api/api-client.ts
|
|
19549
|
-
import { initClient as
|
|
19593
|
+
import { initClient as initClient15 } from "@ts-rest/core";
|
|
19550
19594
|
var ApiClient = class {
|
|
19551
19595
|
async getHeaders() {
|
|
19552
19596
|
const token = await getActiveToken();
|
|
@@ -19572,7 +19616,7 @@ var ApiClient = class {
|
|
|
19572
19616
|
async getComposeByName(name, org) {
|
|
19573
19617
|
const baseUrl = await this.getBaseUrl();
|
|
19574
19618
|
const headers = await this.getHeaders();
|
|
19575
|
-
const client =
|
|
19619
|
+
const client = initClient15(composesMainContract, {
|
|
19576
19620
|
baseUrl,
|
|
19577
19621
|
baseHeaders: headers,
|
|
19578
19622
|
jsonQuery: false
|
|
@@ -19593,7 +19637,7 @@ var ApiClient = class {
|
|
|
19593
19637
|
async getComposeById(id) {
|
|
19594
19638
|
const baseUrl = await this.getBaseUrl();
|
|
19595
19639
|
const headers = await this.getHeaders();
|
|
19596
|
-
const client =
|
|
19640
|
+
const client = initClient15(composesByIdContract, {
|
|
19597
19641
|
baseUrl,
|
|
19598
19642
|
baseHeaders: headers,
|
|
19599
19643
|
jsonQuery: false
|
|
@@ -19615,7 +19659,7 @@ var ApiClient = class {
|
|
|
19615
19659
|
async getComposeVersion(composeId, version) {
|
|
19616
19660
|
const baseUrl = await this.getBaseUrl();
|
|
19617
19661
|
const headers = await this.getHeaders();
|
|
19618
|
-
const client =
|
|
19662
|
+
const client = initClient15(composesVersionsContract, {
|
|
19619
19663
|
baseUrl,
|
|
19620
19664
|
baseHeaders: headers,
|
|
19621
19665
|
jsonQuery: false
|
|
@@ -19636,7 +19680,7 @@ var ApiClient = class {
|
|
|
19636
19680
|
async createOrUpdateCompose(body) {
|
|
19637
19681
|
const baseUrl = await this.getBaseUrl();
|
|
19638
19682
|
const headers = await this.getHeaders();
|
|
19639
|
-
const client =
|
|
19683
|
+
const client = initClient15(composesMainContract, {
|
|
19640
19684
|
baseUrl,
|
|
19641
19685
|
baseHeaders: headers,
|
|
19642
19686
|
jsonQuery: false
|
|
@@ -19659,7 +19703,7 @@ var ApiClient = class {
|
|
|
19659
19703
|
async createRun(body) {
|
|
19660
19704
|
const baseUrl = await this.getBaseUrl();
|
|
19661
19705
|
const headers = await this.getHeaders();
|
|
19662
|
-
const client =
|
|
19706
|
+
const client = initClient15(runsMainContract, {
|
|
19663
19707
|
baseUrl,
|
|
19664
19708
|
baseHeaders: headers,
|
|
19665
19709
|
jsonQuery: false
|
|
@@ -19674,7 +19718,7 @@ var ApiClient = class {
|
|
|
19674
19718
|
}
|
|
19675
19719
|
async getEvents(runId, options) {
|
|
19676
19720
|
const config = await getClientConfig();
|
|
19677
|
-
const client =
|
|
19721
|
+
const client = initClient15(runEventsContract, config);
|
|
19678
19722
|
const result = await client.getEvents({
|
|
19679
19723
|
params: { id: runId },
|
|
19680
19724
|
query: {
|
|
@@ -19691,7 +19735,7 @@ var ApiClient = class {
|
|
|
19691
19735
|
}
|
|
19692
19736
|
async getSystemLog(runId, options) {
|
|
19693
19737
|
const config = await getClientConfig();
|
|
19694
|
-
const client =
|
|
19738
|
+
const client = initClient15(runSystemLogContract, config);
|
|
19695
19739
|
const result = await client.getSystemLog({
|
|
19696
19740
|
params: { id: runId },
|
|
19697
19741
|
query: {
|
|
@@ -19709,7 +19753,7 @@ var ApiClient = class {
|
|
|
19709
19753
|
}
|
|
19710
19754
|
async getMetrics(runId, options) {
|
|
19711
19755
|
const config = await getClientConfig();
|
|
19712
|
-
const client =
|
|
19756
|
+
const client = initClient15(runMetricsContract, config);
|
|
19713
19757
|
const result = await client.getMetrics({
|
|
19714
19758
|
params: { id: runId },
|
|
19715
19759
|
query: {
|
|
@@ -19727,7 +19771,7 @@ var ApiClient = class {
|
|
|
19727
19771
|
}
|
|
19728
19772
|
async getAgentEvents(runId, options) {
|
|
19729
19773
|
const config = await getClientConfig();
|
|
19730
|
-
const client =
|
|
19774
|
+
const client = initClient15(runAgentEventsContract, config);
|
|
19731
19775
|
const result = await client.getAgentEvents({
|
|
19732
19776
|
params: { id: runId },
|
|
19733
19777
|
query: {
|
|
@@ -19745,7 +19789,7 @@ var ApiClient = class {
|
|
|
19745
19789
|
}
|
|
19746
19790
|
async getNetworkLogs(runId, options) {
|
|
19747
19791
|
const config = await getClientConfig();
|
|
19748
|
-
const client =
|
|
19792
|
+
const client = initClient15(runNetworkLogsContract, config);
|
|
19749
19793
|
const result = await client.getNetworkLogs({
|
|
19750
19794
|
params: { id: runId },
|
|
19751
19795
|
query: {
|
|
@@ -19768,7 +19812,7 @@ var ApiClient = class {
|
|
|
19768
19812
|
async getSession(sessionId) {
|
|
19769
19813
|
const baseUrl = await this.getBaseUrl();
|
|
19770
19814
|
const headers = await this.getHeaders();
|
|
19771
|
-
const client =
|
|
19815
|
+
const client = initClient15(sessionsByIdContract, {
|
|
19772
19816
|
baseUrl,
|
|
19773
19817
|
baseHeaders: headers,
|
|
19774
19818
|
jsonQuery: false
|
|
@@ -19789,7 +19833,7 @@ var ApiClient = class {
|
|
|
19789
19833
|
*/
|
|
19790
19834
|
async getCheckpoint(checkpointId) {
|
|
19791
19835
|
const config = await getClientConfig();
|
|
19792
|
-
const client =
|
|
19836
|
+
const client = initClient15(checkpointsByIdContract, config);
|
|
19793
19837
|
const result = await client.getById({
|
|
19794
19838
|
params: { id: checkpointId }
|
|
19795
19839
|
});
|
|
@@ -19806,7 +19850,7 @@ var ApiClient = class {
|
|
|
19806
19850
|
async prepareStorage(body) {
|
|
19807
19851
|
const baseUrl = await this.getBaseUrl();
|
|
19808
19852
|
const headers = await this.getHeaders();
|
|
19809
|
-
const client =
|
|
19853
|
+
const client = initClient15(storagesPrepareContract, {
|
|
19810
19854
|
baseUrl,
|
|
19811
19855
|
baseHeaders: headers,
|
|
19812
19856
|
jsonQuery: false
|
|
@@ -19825,7 +19869,7 @@ var ApiClient = class {
|
|
|
19825
19869
|
async commitStorage(body) {
|
|
19826
19870
|
const baseUrl = await this.getBaseUrl();
|
|
19827
19871
|
const headers = await this.getHeaders();
|
|
19828
|
-
const client =
|
|
19872
|
+
const client = initClient15(storagesCommitContract, {
|
|
19829
19873
|
baseUrl,
|
|
19830
19874
|
baseHeaders: headers,
|
|
19831
19875
|
jsonQuery: false
|
|
@@ -19844,7 +19888,7 @@ var ApiClient = class {
|
|
|
19844
19888
|
async getStorageDownload(query) {
|
|
19845
19889
|
const baseUrl = await this.getBaseUrl();
|
|
19846
19890
|
const headers = await this.getHeaders();
|
|
19847
|
-
const client =
|
|
19891
|
+
const client = initClient15(storagesDownloadContract, {
|
|
19848
19892
|
baseUrl,
|
|
19849
19893
|
baseHeaders: headers,
|
|
19850
19894
|
jsonQuery: false
|
|
@@ -19869,7 +19913,7 @@ var ApiClient = class {
|
|
|
19869
19913
|
async listStorages(query) {
|
|
19870
19914
|
const baseUrl = await this.getBaseUrl();
|
|
19871
19915
|
const headers = await this.getHeaders();
|
|
19872
|
-
const client =
|
|
19916
|
+
const client = initClient15(storagesListContract, {
|
|
19873
19917
|
baseUrl,
|
|
19874
19918
|
baseHeaders: headers,
|
|
19875
19919
|
jsonQuery: false
|
|
@@ -19951,7 +19995,7 @@ var ApiClient = class {
|
|
|
19951
19995
|
}
|
|
19952
19996
|
async searchLogs(options) {
|
|
19953
19997
|
const config = await getClientConfig();
|
|
19954
|
-
const client =
|
|
19998
|
+
const client = initClient15(logsSearchContract, config);
|
|
19955
19999
|
const result = await client.searchLogs({
|
|
19956
20000
|
query: {
|
|
19957
20001
|
keyword: options.keyword,
|
|
@@ -20516,726 +20560,82 @@ var initCommand4 = new Command41().name("init").description("Initialize a new VM
|
|
|
20516
20560
|
})
|
|
20517
20561
|
);
|
|
20518
20562
|
|
|
20519
|
-
// src/commands/
|
|
20520
|
-
import { Command as Command46 } from "commander";
|
|
20521
|
-
|
|
20522
|
-
// src/commands/connector/connect.ts
|
|
20563
|
+
// src/commands/preference/index.ts
|
|
20523
20564
|
import { Command as Command42 } from "commander";
|
|
20524
|
-
import chalk39 from "chalk";
|
|
20525
|
-
import { initClient as initClient17 } from "@ts-rest/core";
|
|
20526
|
-
|
|
20527
|
-
// src/commands/connector/lib/computer/start-services.ts
|
|
20528
|
-
import { spawn as spawn2 } from "child_process";
|
|
20529
|
-
import { access as access2, constants } from "fs/promises";
|
|
20530
|
-
import { createServer } from "net";
|
|
20531
|
-
import { homedir as homedir4 } from "os";
|
|
20532
|
-
import { join as join10 } from "path";
|
|
20533
20565
|
import chalk38 from "chalk";
|
|
20534
|
-
|
|
20535
|
-
|
|
20536
|
-
import ngrok from "@ngrok/ngrok";
|
|
20537
|
-
async function startNgrokTunnels(ngrokToken, endpointPrefix, webdavPort, cdpPort) {
|
|
20538
|
-
await ngrok.forward({
|
|
20539
|
-
addr: `localhost:${webdavPort}`,
|
|
20540
|
-
authtoken: ngrokToken,
|
|
20541
|
-
domain: `webdav.${endpointPrefix}.internal`
|
|
20542
|
-
});
|
|
20543
|
-
await ngrok.forward({
|
|
20544
|
-
addr: `localhost:${cdpPort}`,
|
|
20545
|
-
authtoken: ngrokToken,
|
|
20546
|
-
domain: `chrome.${endpointPrefix}.internal`
|
|
20547
|
-
});
|
|
20566
|
+
function detectTimezone() {
|
|
20567
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
20548
20568
|
}
|
|
20549
|
-
|
|
20550
|
-
|
|
20569
|
+
function isValidTimezone(timezone) {
|
|
20570
|
+
try {
|
|
20571
|
+
Intl.DateTimeFormat(void 0, { timeZone: timezone });
|
|
20572
|
+
return true;
|
|
20573
|
+
} catch {
|
|
20574
|
+
return false;
|
|
20575
|
+
}
|
|
20551
20576
|
}
|
|
20552
|
-
|
|
20553
|
-
|
|
20554
|
-
|
|
20555
|
-
|
|
20556
|
-
|
|
20557
|
-
|
|
20558
|
-
|
|
20559
|
-
// Linux / PATH-based
|
|
20560
|
-
"google-chrome",
|
|
20561
|
-
"google-chrome-stable",
|
|
20562
|
-
"chromium-browser",
|
|
20563
|
-
"chromium",
|
|
20564
|
-
"chrome"
|
|
20565
|
-
];
|
|
20566
|
-
async function getRandomPort() {
|
|
20567
|
-
return new Promise((resolve, reject) => {
|
|
20568
|
-
const server = createServer();
|
|
20569
|
-
server.listen(0, "127.0.0.1", () => {
|
|
20570
|
-
const { port } = server.address();
|
|
20571
|
-
server.close(() => resolve(port));
|
|
20572
|
-
});
|
|
20573
|
-
server.on("error", reject);
|
|
20574
|
-
});
|
|
20577
|
+
function parseOnOff(flag, value) {
|
|
20578
|
+
const lower = value.toLowerCase();
|
|
20579
|
+
if (lower === "on" || lower === "true" || lower === "1") return true;
|
|
20580
|
+
if (lower === "off" || lower === "false" || lower === "0") return false;
|
|
20581
|
+
throw new Error(
|
|
20582
|
+
`Invalid value for --${flag}: "${value}". Use "on" or "off".`
|
|
20583
|
+
);
|
|
20575
20584
|
}
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20585
|
+
function displayPreferences(prefs) {
|
|
20586
|
+
console.log(chalk38.bold("Current preferences:"));
|
|
20587
|
+
console.log(
|
|
20588
|
+
` Timezone: ${prefs.timezone ? chalk38.cyan(prefs.timezone) : chalk38.dim("not set")}`
|
|
20589
|
+
);
|
|
20590
|
+
console.log(
|
|
20591
|
+
` Email notify: ${prefs.notifyEmail ? chalk38.green("on") : chalk38.dim("off")}`
|
|
20592
|
+
);
|
|
20593
|
+
console.log(
|
|
20594
|
+
` Slack notify: ${prefs.notifySlack ? chalk38.green("on") : chalk38.dim("off")}`
|
|
20595
|
+
);
|
|
20596
|
+
}
|
|
20597
|
+
function buildUpdates(opts) {
|
|
20598
|
+
const hasTimezone = opts.timezone !== void 0;
|
|
20599
|
+
const hasNotifyEmail = opts.notifyEmail !== void 0;
|
|
20600
|
+
const hasNotifySlack = opts.notifySlack !== void 0;
|
|
20601
|
+
if (!hasTimezone && !hasNotifyEmail && !hasNotifySlack) return null;
|
|
20602
|
+
const updates = {};
|
|
20603
|
+
if (hasTimezone) {
|
|
20604
|
+
if (!isValidTimezone(opts.timezone)) {
|
|
20605
|
+
throw new Error(`Invalid timezone: ${opts.timezone}`, {
|
|
20606
|
+
cause: new Error(
|
|
20607
|
+
"Use an IANA timezone identifier (e.g., America/New_York, Asia/Shanghai)"
|
|
20608
|
+
)
|
|
20588
20609
|
});
|
|
20589
|
-
if (found) return candidate;
|
|
20590
20610
|
}
|
|
20611
|
+
updates.timezone = opts.timezone;
|
|
20591
20612
|
}
|
|
20592
|
-
|
|
20593
|
-
|
|
20594
|
-
async function checkComputerDependencies() {
|
|
20595
|
-
const wsgidavBinary = await findBinary("wsgidav");
|
|
20596
|
-
if (!wsgidavBinary) {
|
|
20597
|
-
throw new Error(
|
|
20598
|
-
"wsgidav not found\n\nInstall with: pip install wsgidav[cheroot]"
|
|
20599
|
-
);
|
|
20613
|
+
if (hasNotifyEmail) {
|
|
20614
|
+
updates.notifyEmail = parseOnOff("notify-email", opts.notifyEmail);
|
|
20600
20615
|
}
|
|
20601
|
-
|
|
20602
|
-
|
|
20603
|
-
throw new Error("Chrome not found\n\nInstall Google Chrome or Chromium");
|
|
20616
|
+
if (hasNotifySlack) {
|
|
20617
|
+
updates.notifySlack = parseOnOff("notify-slack", opts.notifySlack);
|
|
20604
20618
|
}
|
|
20619
|
+
return updates;
|
|
20605
20620
|
}
|
|
20606
|
-
|
|
20607
|
-
|
|
20608
|
-
|
|
20609
|
-
|
|
20610
|
-
|
|
20611
|
-
|
|
20621
|
+
function printUpdateResult(updates, result) {
|
|
20622
|
+
if (updates.timezone !== void 0) {
|
|
20623
|
+
console.log(
|
|
20624
|
+
chalk38.green(
|
|
20625
|
+
`Timezone set to ${chalk38.cyan(result.timezone ?? updates.timezone)}`
|
|
20626
|
+
)
|
|
20612
20627
|
);
|
|
20613
20628
|
}
|
|
20614
|
-
|
|
20615
|
-
|
|
20616
|
-
|
|
20617
|
-
|
|
20618
|
-
|
|
20619
|
-
|
|
20620
|
-
const downloadsPath = join10(homedir4(), "Downloads");
|
|
20621
|
-
const wsgidav = spawn2(
|
|
20622
|
-
wsgidavBinary,
|
|
20623
|
-
[
|
|
20624
|
-
"--host=127.0.0.1",
|
|
20625
|
-
`--port=${webdavPort}`,
|
|
20626
|
-
`--root=${downloadsPath}`,
|
|
20627
|
-
"--auth=anonymous",
|
|
20628
|
-
"--no-config"
|
|
20629
|
-
],
|
|
20630
|
-
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
20631
|
-
);
|
|
20632
|
-
wsgidav.stdout?.on("data", (data) => process.stdout.write(data));
|
|
20633
|
-
wsgidav.stderr?.on("data", (data) => process.stderr.write(data));
|
|
20634
|
-
console.log(chalk38.green("\u2713 WebDAV server started"));
|
|
20635
|
-
const chrome = spawn2(
|
|
20636
|
-
chromeBinary,
|
|
20637
|
-
[
|
|
20638
|
-
`--remote-debugging-port=${cdpPort}`,
|
|
20639
|
-
"--remote-debugging-address=127.0.0.1",
|
|
20640
|
-
"--headless=new",
|
|
20641
|
-
"--no-sandbox",
|
|
20642
|
-
"--disable-gpu"
|
|
20643
|
-
],
|
|
20644
|
-
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
20645
|
-
);
|
|
20646
|
-
chrome.stdout?.on("data", (data) => process.stdout.write(data));
|
|
20647
|
-
chrome.stderr?.on("data", (data) => process.stderr.write(data));
|
|
20648
|
-
console.log(chalk38.green("\u2713 Chrome started"));
|
|
20649
|
-
try {
|
|
20650
|
-
await startNgrokTunnels(
|
|
20651
|
-
credentials.ngrokToken,
|
|
20652
|
-
credentials.endpointPrefix,
|
|
20653
|
-
webdavPort,
|
|
20654
|
-
cdpPort
|
|
20655
|
-
);
|
|
20656
|
-
console.log(
|
|
20657
|
-
chalk38.green(
|
|
20658
|
-
`\u2713 ngrok tunnels: webdav.${credentials.domain}, chrome.${credentials.domain}`
|
|
20659
|
-
)
|
|
20660
|
-
);
|
|
20661
|
-
console.log();
|
|
20662
|
-
console.log(chalk38.green("\u2713 Computer connector active"));
|
|
20663
|
-
console.log(` WebDAV: ~/Downloads \u2192 webdav.${credentials.domain}`);
|
|
20664
|
-
console.log(
|
|
20665
|
-
` Chrome CDP: port ${cdpPort} \u2192 chrome.${credentials.domain}`
|
|
20666
|
-
);
|
|
20667
|
-
console.log();
|
|
20668
|
-
console.log(chalk38.dim("Press ^C twice to disconnect"));
|
|
20669
|
-
console.log();
|
|
20670
|
-
let sigintCount = 0;
|
|
20671
|
-
await new Promise((resolve) => {
|
|
20672
|
-
const keepAlive = setInterval(() => {
|
|
20673
|
-
}, 6e4);
|
|
20674
|
-
const done = () => {
|
|
20675
|
-
clearInterval(keepAlive);
|
|
20676
|
-
process.removeListener("SIGINT", onSigint);
|
|
20677
|
-
resolve();
|
|
20678
|
-
};
|
|
20679
|
-
const onSigint = () => {
|
|
20680
|
-
sigintCount++;
|
|
20681
|
-
if (sigintCount === 1) {
|
|
20682
|
-
console.log(chalk38.dim("\nPress ^C again to disconnect and exit..."));
|
|
20683
|
-
} else {
|
|
20684
|
-
done();
|
|
20685
|
-
}
|
|
20686
|
-
};
|
|
20687
|
-
process.on("SIGINT", onSigint);
|
|
20688
|
-
process.once("SIGTERM", done);
|
|
20689
|
-
});
|
|
20690
|
-
} finally {
|
|
20691
|
-
console.log();
|
|
20692
|
-
console.log(chalk38.cyan("Stopping services..."));
|
|
20693
|
-
wsgidav.kill("SIGTERM");
|
|
20694
|
-
chrome.kill("SIGTERM");
|
|
20695
|
-
await stopNgrokTunnels();
|
|
20696
|
-
console.log(chalk38.green("\u2713 Services stopped"));
|
|
20697
|
-
}
|
|
20698
|
-
}
|
|
20699
|
-
|
|
20700
|
-
// src/commands/connector/connect.ts
|
|
20701
|
-
function delay2(ms) {
|
|
20702
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
20703
|
-
}
|
|
20704
|
-
async function getHeaders2() {
|
|
20705
|
-
const token = await getActiveToken();
|
|
20706
|
-
if (!token) {
|
|
20707
|
-
throw new Error("Not authenticated. Run: vm0 auth login");
|
|
20708
|
-
}
|
|
20709
|
-
const headers = {
|
|
20710
|
-
Authorization: `Bearer ${token}`
|
|
20711
|
-
};
|
|
20712
|
-
const bypassSecret = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;
|
|
20713
|
-
if (bypassSecret) {
|
|
20714
|
-
headers["x-vercel-protection-bypass"] = bypassSecret;
|
|
20715
|
-
}
|
|
20716
|
-
return headers;
|
|
20717
|
-
}
|
|
20718
|
-
function renderHelpText(text) {
|
|
20719
|
-
return text.replace(
|
|
20720
|
-
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
20721
|
-
(_m, label, url) => `${label} (${chalk39.cyan(url)})`
|
|
20722
|
-
).replace(/\*\*([^*]+)\*\*/g, (_m, content) => chalk39.bold(content)).replace(
|
|
20723
|
-
/^> (.+)$/gm,
|
|
20724
|
-
(_m, content) => chalk39.yellow(` ${content}`)
|
|
20725
|
-
);
|
|
20726
|
-
}
|
|
20727
|
-
async function connectViaApiToken(connectorType, tokenValue) {
|
|
20728
|
-
const config = CONNECTOR_TYPES[connectorType];
|
|
20729
|
-
const apiTokenConfig = config.authMethods["api-token"];
|
|
20730
|
-
if (!apiTokenConfig) {
|
|
20731
|
-
throw new Error(
|
|
20732
|
-
`${config.label} does not support API token authentication`
|
|
20733
|
-
);
|
|
20734
|
-
}
|
|
20735
|
-
const secretEntries = Object.entries(apiTokenConfig.secrets);
|
|
20736
|
-
const inputSecrets = {};
|
|
20737
|
-
if (tokenValue && secretEntries.length === 1) {
|
|
20738
|
-
const [secretName] = secretEntries[0];
|
|
20739
|
-
inputSecrets[secretName] = tokenValue;
|
|
20740
|
-
} else {
|
|
20741
|
-
if (apiTokenConfig.helpText) {
|
|
20742
|
-
console.log();
|
|
20743
|
-
console.log(renderHelpText(apiTokenConfig.helpText));
|
|
20744
|
-
console.log();
|
|
20745
|
-
}
|
|
20746
|
-
for (const [secretName, secretConfig] of secretEntries) {
|
|
20747
|
-
if (!secretConfig.required) continue;
|
|
20748
|
-
const value = await promptPassword(
|
|
20749
|
-
`${secretConfig.label}${secretConfig.placeholder ? chalk39.dim(` (${secretConfig.placeholder})`) : ""}:`
|
|
20750
|
-
);
|
|
20751
|
-
if (!value) {
|
|
20752
|
-
throw new Error("Cancelled");
|
|
20753
|
-
}
|
|
20754
|
-
inputSecrets[secretName] = value;
|
|
20755
|
-
}
|
|
20756
|
-
}
|
|
20757
|
-
for (const [name, value] of Object.entries(inputSecrets)) {
|
|
20758
|
-
await setZeroSecret({
|
|
20759
|
-
name,
|
|
20760
|
-
value,
|
|
20761
|
-
description: `API token for ${config.label} connector`
|
|
20762
|
-
});
|
|
20763
|
-
}
|
|
20764
|
-
console.log(
|
|
20765
|
-
chalk39.green(`
|
|
20766
|
-
\u2713 ${config.label} connected successfully via API token!`)
|
|
20767
|
-
);
|
|
20768
|
-
}
|
|
20769
|
-
async function connectComputer(apiUrl, headers) {
|
|
20770
|
-
await checkComputerDependencies();
|
|
20771
|
-
console.log(chalk39.cyan("Setting up computer connector..."));
|
|
20772
|
-
const computerClient = initClient17(computerConnectorContract, {
|
|
20773
|
-
baseUrl: apiUrl,
|
|
20774
|
-
baseHeaders: headers,
|
|
20775
|
-
jsonQuery: false
|
|
20776
|
-
});
|
|
20777
|
-
const createResult = await computerClient.create({
|
|
20778
|
-
body: {}
|
|
20779
|
-
});
|
|
20780
|
-
if (createResult.status !== 200) {
|
|
20781
|
-
const errorBody = createResult.body;
|
|
20782
|
-
throw new Error(`Failed to create connector: ${errorBody.error?.message}`);
|
|
20783
|
-
}
|
|
20784
|
-
const credentials = createResult.body;
|
|
20785
|
-
await startComputerServices(credentials);
|
|
20786
|
-
console.log(chalk39.cyan("Disconnecting computer connector..."));
|
|
20787
|
-
await deleteConnector("computer");
|
|
20788
|
-
console.log(chalk39.green("\u2713 Disconnected computer"));
|
|
20789
|
-
process.exit(0);
|
|
20790
|
-
}
|
|
20791
|
-
async function resolveAuthMethod(connectorType, tokenFlag) {
|
|
20792
|
-
const config = CONNECTOR_TYPES[connectorType];
|
|
20793
|
-
const oauthFlag = CONNECTOR_TYPES[connectorType].featureFlag;
|
|
20794
|
-
const oauthAvailable = "oauth" in config.authMethods && (!oauthFlag || await isFeatureEnabled(oauthFlag));
|
|
20795
|
-
const apiTokenAvailable = "api-token" in config.authMethods;
|
|
20796
|
-
if (tokenFlag) {
|
|
20797
|
-
if (!apiTokenAvailable) {
|
|
20798
|
-
throw new Error(
|
|
20799
|
-
`${config.label} does not support API token authentication`
|
|
20800
|
-
);
|
|
20801
|
-
}
|
|
20802
|
-
return "api-token";
|
|
20803
|
-
}
|
|
20804
|
-
if (oauthAvailable && apiTokenAvailable) {
|
|
20805
|
-
const selected = await promptSelect(
|
|
20806
|
-
`How would you like to connect ${config.label}?`,
|
|
20807
|
-
[
|
|
20808
|
-
{ title: "OAuth (Sign in with browser)", value: "oauth" },
|
|
20809
|
-
{
|
|
20810
|
-
title: `API Token (${config.authMethods["api-token"].label})`,
|
|
20811
|
-
value: "api-token"
|
|
20812
|
-
}
|
|
20813
|
-
]
|
|
20814
|
-
);
|
|
20815
|
-
if (!selected) {
|
|
20816
|
-
throw new Error("Cancelled");
|
|
20817
|
-
}
|
|
20818
|
-
return selected;
|
|
20819
|
-
}
|
|
20820
|
-
if (apiTokenAvailable) return "api-token";
|
|
20821
|
-
if (oauthAvailable) return "oauth";
|
|
20822
|
-
throw new Error(
|
|
20823
|
-
`${config.label} has no available auth methods. OAuth may not be enabled yet.`
|
|
20824
|
-
);
|
|
20825
|
-
}
|
|
20826
|
-
async function connectViaOAuth(connectorType, apiUrl, headers) {
|
|
20827
|
-
console.log(`Connecting ${chalk39.cyan(connectorType)}...`);
|
|
20828
|
-
const sessionsClient = initClient17(connectorSessionsContract, {
|
|
20829
|
-
baseUrl: apiUrl,
|
|
20830
|
-
baseHeaders: headers,
|
|
20831
|
-
jsonQuery: false
|
|
20832
|
-
});
|
|
20833
|
-
const createResult = await sessionsClient.create({
|
|
20834
|
-
params: { type: connectorType },
|
|
20835
|
-
body: {}
|
|
20836
|
-
});
|
|
20837
|
-
if (createResult.status !== 200) {
|
|
20838
|
-
const errorBody = createResult.body;
|
|
20839
|
-
throw new Error(`Failed to create session: ${errorBody.error?.message}`);
|
|
20840
|
-
}
|
|
20841
|
-
const session = createResult.body;
|
|
20842
|
-
const verificationUrl = `${apiUrl}${session.verificationUrl}`;
|
|
20843
|
-
console.log(chalk39.green("\nSession created"));
|
|
20844
|
-
console.log(chalk39.cyan(`
|
|
20845
|
-
To connect, visit: ${verificationUrl}`));
|
|
20846
|
-
console.log(
|
|
20847
|
-
`
|
|
20848
|
-
The session expires in ${Math.floor(session.expiresIn / 60)} minutes.`
|
|
20849
|
-
);
|
|
20850
|
-
console.log("\nWaiting for authorization...");
|
|
20851
|
-
const sessionClient = initClient17(connectorSessionByIdContract, {
|
|
20852
|
-
baseUrl: apiUrl,
|
|
20853
|
-
baseHeaders: headers,
|
|
20854
|
-
jsonQuery: false
|
|
20855
|
-
});
|
|
20856
|
-
const startTime = Date.now();
|
|
20857
|
-
const maxWaitTime = session.expiresIn * 1e3;
|
|
20858
|
-
const pollInterval = (session.interval || 5) * 1e3;
|
|
20859
|
-
let isFirstPoll = true;
|
|
20860
|
-
while (Date.now() - startTime < maxWaitTime) {
|
|
20861
|
-
if (!isFirstPoll) {
|
|
20862
|
-
await delay2(pollInterval);
|
|
20863
|
-
}
|
|
20864
|
-
isFirstPoll = false;
|
|
20865
|
-
const statusResult = await sessionClient.get({
|
|
20866
|
-
params: { type: connectorType, sessionId: session.id }
|
|
20867
|
-
});
|
|
20868
|
-
if (statusResult.status !== 200) {
|
|
20869
|
-
const errorBody = statusResult.body;
|
|
20870
|
-
throw new Error(`Failed to check status: ${errorBody.error?.message}`);
|
|
20871
|
-
}
|
|
20872
|
-
const status = statusResult.body;
|
|
20873
|
-
switch (status.status) {
|
|
20874
|
-
case "complete":
|
|
20875
|
-
console.log(
|
|
20876
|
-
chalk39.green(`
|
|
20877
|
-
|
|
20878
|
-
${connectorType} connected successfully!`)
|
|
20879
|
-
);
|
|
20880
|
-
return;
|
|
20881
|
-
case "expired":
|
|
20882
|
-
throw new Error("Session expired, please try again");
|
|
20883
|
-
case "error":
|
|
20884
|
-
throw new Error(
|
|
20885
|
-
`Connection failed: ${status.errorMessage || "Unknown error"}`
|
|
20886
|
-
);
|
|
20887
|
-
case "pending":
|
|
20888
|
-
process.stdout.write(chalk39.dim("."));
|
|
20889
|
-
break;
|
|
20890
|
-
}
|
|
20891
|
-
}
|
|
20892
|
-
throw new Error("Session timed out, please try again");
|
|
20893
|
-
}
|
|
20894
|
-
var connectCommand = new Command42().name("connect").description("Connect a third-party service (e.g., GitHub)").argument("<type>", "Connector type (e.g., github)").option("--token <value>", "API token value (skip interactive prompt)").action(
|
|
20895
|
-
withErrorHandler(async (type2, options) => {
|
|
20896
|
-
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
20897
|
-
if (!parseResult.success) {
|
|
20898
|
-
throw new Error(`Unknown connector type: ${type2}`, {
|
|
20899
|
-
cause: new Error("Available connectors: github")
|
|
20900
|
-
});
|
|
20901
|
-
}
|
|
20902
|
-
const connectorType = parseResult.data;
|
|
20903
|
-
const apiUrl = await getApiUrl();
|
|
20904
|
-
const headers = await getHeaders2();
|
|
20905
|
-
if (connectorType === "computer") {
|
|
20906
|
-
await connectComputer(apiUrl, headers);
|
|
20907
|
-
return;
|
|
20908
|
-
}
|
|
20909
|
-
const authMethod = await resolveAuthMethod(connectorType, options.token);
|
|
20910
|
-
if (authMethod === "api-token") {
|
|
20911
|
-
await connectViaApiToken(connectorType, options.token);
|
|
20912
|
-
return;
|
|
20913
|
-
}
|
|
20914
|
-
await connectViaOAuth(connectorType, apiUrl, headers);
|
|
20915
|
-
})
|
|
20916
|
-
);
|
|
20917
|
-
|
|
20918
|
-
// src/commands/connector/list.ts
|
|
20919
|
-
import { Command as Command43 } from "commander";
|
|
20920
|
-
import chalk40 from "chalk";
|
|
20921
|
-
var listCommand5 = new Command43().name("list").alias("ls").description("List all connectors and their status").action(
|
|
20922
|
-
withErrorHandler(async () => {
|
|
20923
|
-
const result = await listConnectors();
|
|
20924
|
-
const connectedMap = new Map(result.connectors.map((c33) => [c33.type, c33]));
|
|
20925
|
-
const allTypesRaw = Object.keys(CONNECTOR_TYPES);
|
|
20926
|
-
const allTypes = [];
|
|
20927
|
-
for (const type2 of allTypesRaw) {
|
|
20928
|
-
const flag = CONNECTOR_TYPES[type2].featureFlag;
|
|
20929
|
-
const hasApiToken = "api-token" in CONNECTOR_TYPES[type2].authMethods;
|
|
20930
|
-
if (flag && !await isFeatureEnabled(flag) && !hasApiToken) {
|
|
20931
|
-
continue;
|
|
20932
|
-
}
|
|
20933
|
-
allTypes.push(type2);
|
|
20934
|
-
}
|
|
20935
|
-
const typeWidth = Math.max(4, ...allTypes.map((t) => t.length));
|
|
20936
|
-
const statusText = "STATUS";
|
|
20937
|
-
const statusWidth = statusText.length;
|
|
20938
|
-
const header = [
|
|
20939
|
-
"TYPE".padEnd(typeWidth),
|
|
20940
|
-
statusText.padEnd(statusWidth),
|
|
20941
|
-
"ACCOUNT"
|
|
20942
|
-
].join(" ");
|
|
20943
|
-
console.log(chalk40.dim(header));
|
|
20944
|
-
for (const type2 of allTypes) {
|
|
20945
|
-
const connector = connectedMap.get(type2);
|
|
20946
|
-
const scopeMismatch = connector !== void 0 && connector.authMethod === "oauth" && !hasRequiredScopes(type2, connector.oauthScopes);
|
|
20947
|
-
const status = connector ? connector.needsReconnect ? chalk40.yellow("!".padEnd(statusWidth)) : scopeMismatch ? chalk40.yellow("!".padEnd(statusWidth)) : chalk40.green("\u2713".padEnd(statusWidth)) : chalk40.dim("-".padEnd(statusWidth));
|
|
20948
|
-
const account = connector?.needsReconnect ? chalk40.yellow("(reconnect needed)") : scopeMismatch ? chalk40.yellow("(permissions update available)") : connector?.externalUsername ? `@${connector.externalUsername}` : chalk40.dim("-");
|
|
20949
|
-
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
20950
|
-
console.log(row);
|
|
20951
|
-
}
|
|
20952
|
-
console.log();
|
|
20953
|
-
console.log(chalk40.dim("To connect a service:"));
|
|
20954
|
-
console.log(chalk40.dim(" vm0 connector connect <type>"));
|
|
20955
|
-
})
|
|
20956
|
-
);
|
|
20957
|
-
|
|
20958
|
-
// src/commands/connector/status.ts
|
|
20959
|
-
import { Command as Command44 } from "commander";
|
|
20960
|
-
import chalk41 from "chalk";
|
|
20961
|
-
|
|
20962
|
-
// src/lib/domain/schedule-utils.ts
|
|
20963
|
-
function formatRelativeTime2(dateStr) {
|
|
20964
|
-
if (!dateStr) return "-";
|
|
20965
|
-
const date = new Date(dateStr);
|
|
20966
|
-
const now = /* @__PURE__ */ new Date();
|
|
20967
|
-
const diffMs = date.getTime() - now.getTime();
|
|
20968
|
-
const diffAbs = Math.abs(diffMs);
|
|
20969
|
-
const minutes = Math.floor(diffAbs / (1e3 * 60));
|
|
20970
|
-
const hours = Math.floor(diffAbs / (1e3 * 60 * 60));
|
|
20971
|
-
const days = Math.floor(diffAbs / (1e3 * 60 * 60 * 24));
|
|
20972
|
-
const isPast = diffMs < 0;
|
|
20973
|
-
if (days > 0) {
|
|
20974
|
-
return isPast ? `${days}d ago` : `in ${days}d`;
|
|
20975
|
-
} else if (hours > 0) {
|
|
20976
|
-
return isPast ? `${hours}h ago` : `in ${hours}h`;
|
|
20977
|
-
} else if (minutes > 0) {
|
|
20978
|
-
return isPast ? `${minutes}m ago` : `in ${minutes}m`;
|
|
20979
|
-
} else {
|
|
20980
|
-
return isPast ? "just now" : "soon";
|
|
20981
|
-
}
|
|
20982
|
-
}
|
|
20983
|
-
function formatDateTime(dateStr) {
|
|
20984
|
-
if (!dateStr) return "-";
|
|
20985
|
-
const date = new Date(dateStr);
|
|
20986
|
-
const year = date.getFullYear();
|
|
20987
|
-
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
20988
|
-
const day = String(date.getDate()).padStart(2, "0");
|
|
20989
|
-
const hours = String(date.getHours()).padStart(2, "0");
|
|
20990
|
-
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
20991
|
-
const formatted = `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
20992
|
-
const relative2 = formatRelativeTime2(dateStr);
|
|
20993
|
-
return `${formatted} (${relative2})`;
|
|
20994
|
-
}
|
|
20995
|
-
function generateCronExpression(frequency, time, day) {
|
|
20996
|
-
const [hourStr, minuteStr] = time.split(":");
|
|
20997
|
-
const hour = parseInt(hourStr ?? "0", 10);
|
|
20998
|
-
const minute = parseInt(minuteStr ?? "0", 10);
|
|
20999
|
-
switch (frequency) {
|
|
21000
|
-
case "daily":
|
|
21001
|
-
return `${minute} ${hour} * * *`;
|
|
21002
|
-
case "weekly":
|
|
21003
|
-
return `${minute} ${hour} * * ${day ?? 1}`;
|
|
21004
|
-
case "monthly":
|
|
21005
|
-
return `${minute} ${hour} ${day ?? 1} * *`;
|
|
21006
|
-
}
|
|
21007
|
-
}
|
|
21008
|
-
function detectTimezone() {
|
|
21009
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
21010
|
-
}
|
|
21011
|
-
function validateTimeFormat(time) {
|
|
21012
|
-
const match = time.match(/^(\d{1,2}):(\d{2})$/);
|
|
21013
|
-
if (!match) {
|
|
21014
|
-
return "Invalid format. Use HH:MM (e.g., 09:00)";
|
|
21015
|
-
}
|
|
21016
|
-
const hour = parseInt(match[1], 10);
|
|
21017
|
-
const minute = parseInt(match[2], 10);
|
|
21018
|
-
if (hour < 0 || hour > 23) {
|
|
21019
|
-
return "Hour must be 0-23";
|
|
21020
|
-
}
|
|
21021
|
-
if (minute < 0 || minute > 59) {
|
|
21022
|
-
return "Minute must be 0-59";
|
|
21023
|
-
}
|
|
21024
|
-
if (minute % 5 !== 0) {
|
|
21025
|
-
return "Minute must be a multiple of 5 (0, 5, 10, ..., 55)";
|
|
21026
|
-
}
|
|
21027
|
-
return true;
|
|
21028
|
-
}
|
|
21029
|
-
function validateDateFormat(date) {
|
|
21030
|
-
const match = date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
21031
|
-
if (!match) {
|
|
21032
|
-
return "Invalid format. Use YYYY-MM-DD (e.g., 2025-01-15)";
|
|
21033
|
-
}
|
|
21034
|
-
const year = parseInt(match[1], 10);
|
|
21035
|
-
const month = parseInt(match[2], 10);
|
|
21036
|
-
const day = parseInt(match[3], 10);
|
|
21037
|
-
if (year < 2e3 || year > 2100) {
|
|
21038
|
-
return "Year must be between 2000 and 2100";
|
|
21039
|
-
}
|
|
21040
|
-
if (month < 1 || month > 12) {
|
|
21041
|
-
return "Month must be 1-12";
|
|
21042
|
-
}
|
|
21043
|
-
if (day < 1 || day > 31) {
|
|
21044
|
-
return "Day must be 1-31";
|
|
21045
|
-
}
|
|
21046
|
-
const testDate = new Date(year, month - 1, day);
|
|
21047
|
-
if (testDate.getFullYear() !== year || testDate.getMonth() !== month - 1 || testDate.getDate() !== day) {
|
|
21048
|
-
return "Invalid date";
|
|
21049
|
-
}
|
|
21050
|
-
return true;
|
|
21051
|
-
}
|
|
21052
|
-
function getTomorrowDateLocal() {
|
|
21053
|
-
const tomorrow = /* @__PURE__ */ new Date();
|
|
21054
|
-
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
21055
|
-
const year = tomorrow.getFullYear();
|
|
21056
|
-
const month = String(tomorrow.getMonth() + 1).padStart(2, "0");
|
|
21057
|
-
const day = String(tomorrow.getDate()).padStart(2, "0");
|
|
21058
|
-
return `${year}-${month}-${day}`;
|
|
21059
|
-
}
|
|
21060
|
-
function getCurrentTimeLocal() {
|
|
21061
|
-
const now = /* @__PURE__ */ new Date();
|
|
21062
|
-
const hours = String(now.getHours()).padStart(2, "0");
|
|
21063
|
-
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
21064
|
-
return `${hours}:${minutes}`;
|
|
21065
|
-
}
|
|
21066
|
-
function toISODateTime(dateTimeStr) {
|
|
21067
|
-
if (dateTimeStr.includes("T") && dateTimeStr.endsWith("Z")) {
|
|
21068
|
-
return dateTimeStr;
|
|
21069
|
-
}
|
|
21070
|
-
const isoStr = dateTimeStr.replace(" ", "T") + ":00";
|
|
21071
|
-
const date = new Date(isoStr);
|
|
21072
|
-
return date.toISOString();
|
|
21073
|
-
}
|
|
21074
|
-
|
|
21075
|
-
// src/commands/connector/status.ts
|
|
21076
|
-
var LABEL_WIDTH = 16;
|
|
21077
|
-
var statusCommand5 = new Command44().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(
|
|
21078
|
-
withErrorHandler(async (type2) => {
|
|
21079
|
-
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
21080
|
-
if (!parseResult.success) {
|
|
21081
|
-
const available = Object.keys(CONNECTOR_TYPES).join(", ");
|
|
21082
|
-
throw new Error(`Unknown connector type: ${type2}`, {
|
|
21083
|
-
cause: new Error(`Available connectors: ${available}`)
|
|
21084
|
-
});
|
|
21085
|
-
}
|
|
21086
|
-
const connector = await getConnector(parseResult.data);
|
|
21087
|
-
console.log(`Connector: ${chalk41.cyan(type2)}`);
|
|
21088
|
-
console.log();
|
|
21089
|
-
if (connector) {
|
|
21090
|
-
console.log(
|
|
21091
|
-
`${"Status:".padEnd(LABEL_WIDTH)}${chalk41.green("connected")}`
|
|
21092
|
-
);
|
|
21093
|
-
console.log(
|
|
21094
|
-
`${"Account:".padEnd(LABEL_WIDTH)}@${connector.externalUsername}`
|
|
21095
|
-
);
|
|
21096
|
-
console.log(
|
|
21097
|
-
`${"Auth Method:".padEnd(LABEL_WIDTH)}${connector.authMethod}`
|
|
21098
|
-
);
|
|
21099
|
-
if (connector.oauthScopes && connector.oauthScopes.length > 0) {
|
|
21100
|
-
console.log(
|
|
21101
|
-
`${"OAuth Scopes:".padEnd(LABEL_WIDTH)}${connector.oauthScopes.join(", ")}`
|
|
21102
|
-
);
|
|
21103
|
-
}
|
|
21104
|
-
if (connector.authMethod === "oauth" && !hasRequiredScopes(parseResult.data, connector.oauthScopes)) {
|
|
21105
|
-
const diff = getScopeDiff(parseResult.data, connector.oauthScopes);
|
|
21106
|
-
console.log(
|
|
21107
|
-
`${"Permissions:".padEnd(LABEL_WIDTH)}${chalk41.yellow("update available")}`
|
|
21108
|
-
);
|
|
21109
|
-
if (diff.addedScopes.length > 0) {
|
|
21110
|
-
console.log(
|
|
21111
|
-
`${" Added:".padEnd(LABEL_WIDTH)}${diff.addedScopes.join(", ")}`
|
|
21112
|
-
);
|
|
21113
|
-
}
|
|
21114
|
-
if (diff.removedScopes.length > 0) {
|
|
21115
|
-
console.log(
|
|
21116
|
-
`${" Removed:".padEnd(LABEL_WIDTH)}${diff.removedScopes.join(", ")}`
|
|
21117
|
-
);
|
|
21118
|
-
}
|
|
21119
|
-
}
|
|
21120
|
-
console.log(
|
|
21121
|
-
`${"Connected:".padEnd(LABEL_WIDTH)}${formatDateTime(connector.createdAt)}`
|
|
21122
|
-
);
|
|
21123
|
-
if (connector.updatedAt !== connector.createdAt) {
|
|
21124
|
-
console.log(
|
|
21125
|
-
`${"Last Updated:".padEnd(LABEL_WIDTH)}${formatDateTime(connector.updatedAt)}`
|
|
21126
|
-
);
|
|
21127
|
-
}
|
|
21128
|
-
console.log();
|
|
21129
|
-
console.log(chalk41.dim("To disconnect:"));
|
|
21130
|
-
console.log(chalk41.dim(` vm0 connector disconnect ${type2}`));
|
|
21131
|
-
} else {
|
|
21132
|
-
console.log(
|
|
21133
|
-
`${"Status:".padEnd(LABEL_WIDTH)}${chalk41.dim("not connected")}`
|
|
21134
|
-
);
|
|
21135
|
-
console.log();
|
|
21136
|
-
console.log(chalk41.dim("To connect:"));
|
|
21137
|
-
console.log(chalk41.dim(` vm0 connector connect ${type2}`));
|
|
21138
|
-
}
|
|
21139
|
-
})
|
|
21140
|
-
);
|
|
21141
|
-
|
|
21142
|
-
// src/commands/connector/disconnect.ts
|
|
21143
|
-
import { Command as Command45 } from "commander";
|
|
21144
|
-
import chalk42 from "chalk";
|
|
21145
|
-
var disconnectCommand = new Command45().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(
|
|
21146
|
-
withErrorHandler(async (type2) => {
|
|
21147
|
-
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
21148
|
-
if (!parseResult.success) {
|
|
21149
|
-
const available = Object.keys(CONNECTOR_TYPES).join(", ");
|
|
21150
|
-
throw new Error(`Unknown connector type: ${type2}`, {
|
|
21151
|
-
cause: new Error(`Available connectors: ${available}`)
|
|
21152
|
-
});
|
|
21153
|
-
}
|
|
21154
|
-
const connectorType = parseResult.data;
|
|
21155
|
-
await deleteConnector(connectorType);
|
|
21156
|
-
console.log(chalk42.green(`\u2713 Disconnected ${type2}`));
|
|
21157
|
-
})
|
|
21158
|
-
);
|
|
21159
|
-
|
|
21160
|
-
// src/commands/connector/index.ts
|
|
21161
|
-
var connectorCommand = new Command46().name("connector").description("Manage third-party service connections").addCommand(listCommand5).addCommand(statusCommand5).addCommand(connectCommand).addCommand(disconnectCommand);
|
|
21162
|
-
|
|
21163
|
-
// src/commands/preference/index.ts
|
|
21164
|
-
import { Command as Command47 } from "commander";
|
|
21165
|
-
import chalk43 from "chalk";
|
|
21166
|
-
function detectTimezone2() {
|
|
21167
|
-
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
21168
|
-
}
|
|
21169
|
-
function isValidTimezone(timezone) {
|
|
21170
|
-
try {
|
|
21171
|
-
Intl.DateTimeFormat(void 0, { timeZone: timezone });
|
|
21172
|
-
return true;
|
|
21173
|
-
} catch {
|
|
21174
|
-
return false;
|
|
21175
|
-
}
|
|
21176
|
-
}
|
|
21177
|
-
function parseOnOff(flag, value) {
|
|
21178
|
-
const lower = value.toLowerCase();
|
|
21179
|
-
if (lower === "on" || lower === "true" || lower === "1") return true;
|
|
21180
|
-
if (lower === "off" || lower === "false" || lower === "0") return false;
|
|
21181
|
-
throw new Error(
|
|
21182
|
-
`Invalid value for --${flag}: "${value}". Use "on" or "off".`
|
|
21183
|
-
);
|
|
21184
|
-
}
|
|
21185
|
-
function displayPreferences(prefs) {
|
|
21186
|
-
console.log(chalk43.bold("Current preferences:"));
|
|
21187
|
-
console.log(
|
|
21188
|
-
` Timezone: ${prefs.timezone ? chalk43.cyan(prefs.timezone) : chalk43.dim("not set")}`
|
|
21189
|
-
);
|
|
21190
|
-
console.log(
|
|
21191
|
-
` Email notify: ${prefs.notifyEmail ? chalk43.green("on") : chalk43.dim("off")}`
|
|
21192
|
-
);
|
|
21193
|
-
console.log(
|
|
21194
|
-
` Slack notify: ${prefs.notifySlack ? chalk43.green("on") : chalk43.dim("off")}`
|
|
21195
|
-
);
|
|
21196
|
-
}
|
|
21197
|
-
function buildUpdates(opts) {
|
|
21198
|
-
const hasTimezone = opts.timezone !== void 0;
|
|
21199
|
-
const hasNotifyEmail = opts.notifyEmail !== void 0;
|
|
21200
|
-
const hasNotifySlack = opts.notifySlack !== void 0;
|
|
21201
|
-
if (!hasTimezone && !hasNotifyEmail && !hasNotifySlack) return null;
|
|
21202
|
-
const updates = {};
|
|
21203
|
-
if (hasTimezone) {
|
|
21204
|
-
if (!isValidTimezone(opts.timezone)) {
|
|
21205
|
-
throw new Error(`Invalid timezone: ${opts.timezone}`, {
|
|
21206
|
-
cause: new Error(
|
|
21207
|
-
"Use an IANA timezone identifier (e.g., America/New_York, Asia/Shanghai)"
|
|
21208
|
-
)
|
|
21209
|
-
});
|
|
21210
|
-
}
|
|
21211
|
-
updates.timezone = opts.timezone;
|
|
21212
|
-
}
|
|
21213
|
-
if (hasNotifyEmail) {
|
|
21214
|
-
updates.notifyEmail = parseOnOff("notify-email", opts.notifyEmail);
|
|
21215
|
-
}
|
|
21216
|
-
if (hasNotifySlack) {
|
|
21217
|
-
updates.notifySlack = parseOnOff("notify-slack", opts.notifySlack);
|
|
21218
|
-
}
|
|
21219
|
-
return updates;
|
|
21220
|
-
}
|
|
21221
|
-
function printUpdateResult(updates, result) {
|
|
21222
|
-
if (updates.timezone !== void 0) {
|
|
21223
|
-
console.log(
|
|
21224
|
-
chalk43.green(
|
|
21225
|
-
`Timezone set to ${chalk43.cyan(result.timezone ?? updates.timezone)}`
|
|
21226
|
-
)
|
|
21227
|
-
);
|
|
21228
|
-
}
|
|
21229
|
-
if (updates.notifyEmail !== void 0) {
|
|
21230
|
-
console.log(
|
|
21231
|
-
chalk43.green(
|
|
21232
|
-
`Email notifications ${result.notifyEmail ? "enabled" : "disabled"}`
|
|
21233
|
-
)
|
|
21234
|
-
);
|
|
20629
|
+
if (updates.notifyEmail !== void 0) {
|
|
20630
|
+
console.log(
|
|
20631
|
+
chalk38.green(
|
|
20632
|
+
`Email notifications ${result.notifyEmail ? "enabled" : "disabled"}`
|
|
20633
|
+
)
|
|
20634
|
+
);
|
|
21235
20635
|
}
|
|
21236
20636
|
if (updates.notifySlack !== void 0) {
|
|
21237
20637
|
console.log(
|
|
21238
|
-
|
|
20638
|
+
chalk38.green(
|
|
21239
20639
|
`Slack notifications ${result.notifySlack ? "enabled" : "disabled"}`
|
|
21240
20640
|
)
|
|
21241
20641
|
);
|
|
@@ -21243,8 +20643,8 @@ function printUpdateResult(updates, result) {
|
|
|
21243
20643
|
}
|
|
21244
20644
|
async function interactiveSetup(prefs) {
|
|
21245
20645
|
if (!prefs.timezone) {
|
|
21246
|
-
const detectedTz =
|
|
21247
|
-
console.log(
|
|
20646
|
+
const detectedTz = detectTimezone();
|
|
20647
|
+
console.log(chalk38.dim(`
|
|
21248
20648
|
System timezone detected: ${detectedTz}`));
|
|
21249
20649
|
const tz = await promptText(
|
|
21250
20650
|
"Set timezone? (enter timezone or leave empty to skip)",
|
|
@@ -21255,7 +20655,7 @@ System timezone detected: ${detectedTz}`));
|
|
|
21255
20655
|
throw new Error(`Invalid timezone: ${tz.trim()}`);
|
|
21256
20656
|
}
|
|
21257
20657
|
await updateUserPreferences({ timezone: tz.trim() });
|
|
21258
|
-
console.log(
|
|
20658
|
+
console.log(chalk38.green(`Timezone set to ${chalk38.cyan(tz.trim())}`));
|
|
21259
20659
|
}
|
|
21260
20660
|
}
|
|
21261
20661
|
if (!prefs.notifyEmail) {
|
|
@@ -21265,11 +20665,11 @@ System timezone detected: ${detectedTz}`));
|
|
|
21265
20665
|
);
|
|
21266
20666
|
if (enable) {
|
|
21267
20667
|
await updateUserPreferences({ notifyEmail: true });
|
|
21268
|
-
console.log(
|
|
20668
|
+
console.log(chalk38.green("Email notifications enabled"));
|
|
21269
20669
|
}
|
|
21270
20670
|
}
|
|
21271
20671
|
}
|
|
21272
|
-
var preferenceCommand = new
|
|
20672
|
+
var preferenceCommand = new Command42().name("preference").description("View or update your preferences").option("--timezone <timezone>", "IANA timezone (e.g., America/New_York)").option("--notify-email <on|off>", "Enable or disable email notifications").option("--notify-slack <on|off>", "Enable or disable Slack notifications").action(
|
|
21273
20673
|
withErrorHandler(async (opts) => {
|
|
21274
20674
|
const updates = buildUpdates(opts);
|
|
21275
20675
|
if (updates) {
|
|
@@ -21284,32 +20684,32 @@ var preferenceCommand = new Command47().name("preference").description("View or
|
|
|
21284
20684
|
} else if (!prefs.timezone) {
|
|
21285
20685
|
console.log();
|
|
21286
20686
|
console.log(
|
|
21287
|
-
`To set timezone: ${
|
|
20687
|
+
`To set timezone: ${chalk38.cyan("vm0 preference --timezone <timezone>")}`
|
|
21288
20688
|
);
|
|
21289
20689
|
console.log(
|
|
21290
|
-
|
|
20690
|
+
chalk38.dim("Example: vm0 preference --timezone America/New_York")
|
|
21291
20691
|
);
|
|
21292
20692
|
}
|
|
21293
20693
|
})
|
|
21294
20694
|
);
|
|
21295
20695
|
|
|
21296
20696
|
// src/commands/upgrade/index.ts
|
|
21297
|
-
import { Command as
|
|
21298
|
-
import
|
|
21299
|
-
var upgradeCommand = new
|
|
20697
|
+
import { Command as Command43 } from "commander";
|
|
20698
|
+
import chalk39 from "chalk";
|
|
20699
|
+
var upgradeCommand = new Command43().name("upgrade").description("Upgrade vm0 CLI to the latest version").action(
|
|
21300
20700
|
withErrorHandler(async () => {
|
|
21301
20701
|
console.log("Checking for updates...");
|
|
21302
20702
|
const latestVersion = await getLatestVersion();
|
|
21303
20703
|
if (latestVersion === null) {
|
|
21304
20704
|
throw new Error("Could not check for updates. Please try again later.");
|
|
21305
20705
|
}
|
|
21306
|
-
if (latestVersion === "9.78.
|
|
21307
|
-
console.log(
|
|
20706
|
+
if (latestVersion === "9.78.1") {
|
|
20707
|
+
console.log(chalk39.green(`\u2713 Already up to date (${"9.78.1"})`));
|
|
21308
20708
|
return;
|
|
21309
20709
|
}
|
|
21310
20710
|
console.log(
|
|
21311
|
-
|
|
21312
|
-
`Current version: ${"9.78.
|
|
20711
|
+
chalk39.yellow(
|
|
20712
|
+
`Current version: ${"9.78.1"} -> Latest version: ${latestVersion}`
|
|
21313
20713
|
)
|
|
21314
20714
|
);
|
|
21315
20715
|
console.log();
|
|
@@ -21317,26 +20717,26 @@ var upgradeCommand = new Command48().name("upgrade").description("Upgrade vm0 CL
|
|
|
21317
20717
|
if (!isAutoUpgradeSupported(packageManager)) {
|
|
21318
20718
|
if (packageManager === "unknown") {
|
|
21319
20719
|
console.log(
|
|
21320
|
-
|
|
20720
|
+
chalk39.yellow(
|
|
21321
20721
|
"Could not detect your package manager for auto-upgrade."
|
|
21322
20722
|
)
|
|
21323
20723
|
);
|
|
21324
20724
|
} else {
|
|
21325
20725
|
console.log(
|
|
21326
|
-
|
|
20726
|
+
chalk39.yellow(
|
|
21327
20727
|
`Auto-upgrade is not supported for ${packageManager}.`
|
|
21328
20728
|
)
|
|
21329
20729
|
);
|
|
21330
20730
|
}
|
|
21331
|
-
console.log(
|
|
21332
|
-
console.log(
|
|
20731
|
+
console.log(chalk39.yellow("Please upgrade manually:"));
|
|
20732
|
+
console.log(chalk39.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
21333
20733
|
return;
|
|
21334
20734
|
}
|
|
21335
20735
|
console.log(`Upgrading via ${packageManager}...`);
|
|
21336
20736
|
const success = await performUpgrade(packageManager);
|
|
21337
20737
|
if (success) {
|
|
21338
20738
|
console.log(
|
|
21339
|
-
|
|
20739
|
+
chalk39.green(`\u2713 Upgraded from ${"9.78.1"} to ${latestVersion}`)
|
|
21340
20740
|
);
|
|
21341
20741
|
return;
|
|
21342
20742
|
}
|
|
@@ -21349,8 +20749,8 @@ var upgradeCommand = new Command48().name("upgrade").description("Upgrade vm0 CL
|
|
|
21349
20749
|
);
|
|
21350
20750
|
|
|
21351
20751
|
// src/commands/whoami.ts
|
|
21352
|
-
import { Command as
|
|
21353
|
-
import
|
|
20752
|
+
import { Command as Command44 } from "commander";
|
|
20753
|
+
import chalk40 from "chalk";
|
|
21354
20754
|
function isInsideSandbox() {
|
|
21355
20755
|
return !!process.env.VM0_RUN_ID;
|
|
21356
20756
|
}
|
|
@@ -21365,7 +20765,7 @@ async function showSandboxInfo() {
|
|
|
21365
20765
|
const apiUrl = process.env.VM0_API_URL;
|
|
21366
20766
|
const hasAgentInfo = agentName || agentVersion || agentComposeId || agentOrgSlug || cliAgentType;
|
|
21367
20767
|
if (hasAgentInfo) {
|
|
21368
|
-
console.log(
|
|
20768
|
+
console.log(chalk40.bold("Agent:"));
|
|
21369
20769
|
if (agentName) console.log(` Name: ${agentName}`);
|
|
21370
20770
|
if (agentVersion) console.log(` Version: ${agentVersion}`);
|
|
21371
20771
|
if (agentComposeId) console.log(` Compose ID: ${agentComposeId}`);
|
|
@@ -21373,7 +20773,7 @@ async function showSandboxInfo() {
|
|
|
21373
20773
|
if (cliAgentType) console.log(` Framework: ${cliAgentType}`);
|
|
21374
20774
|
console.log();
|
|
21375
20775
|
}
|
|
21376
|
-
console.log(
|
|
20776
|
+
console.log(chalk40.bold("Run:"));
|
|
21377
20777
|
if (runId) console.log(` ID: ${runId}`);
|
|
21378
20778
|
if (activeOrg) console.log(` Org: ${activeOrg}`);
|
|
21379
20779
|
if (apiUrl) console.log(` API: ${apiUrl}`);
|
|
@@ -21382,23 +20782,23 @@ async function showLocalInfo() {
|
|
|
21382
20782
|
const token = await getToken();
|
|
21383
20783
|
const apiUrl = await getApiUrl();
|
|
21384
20784
|
const activeOrg = await getActiveOrg();
|
|
21385
|
-
console.log(
|
|
20785
|
+
console.log(chalk40.bold("Auth:"));
|
|
21386
20786
|
if (token) {
|
|
21387
20787
|
const tokenSource = process.env.VM0_TOKEN ? "VM0_TOKEN env var" : "config file";
|
|
21388
20788
|
console.log(
|
|
21389
|
-
` Status: ${
|
|
20789
|
+
` Status: ${chalk40.green("Authenticated")} (via ${tokenSource})`
|
|
21390
20790
|
);
|
|
21391
20791
|
} else {
|
|
21392
|
-
console.log(` Status: ${
|
|
20792
|
+
console.log(` Status: ${chalk40.dim("Not authenticated")}`);
|
|
21393
20793
|
}
|
|
21394
20794
|
console.log(` API: ${apiUrl}`);
|
|
21395
20795
|
console.log();
|
|
21396
20796
|
if (activeOrg) {
|
|
21397
|
-
console.log(
|
|
20797
|
+
console.log(chalk40.bold("Org:"));
|
|
21398
20798
|
console.log(` Active: ${activeOrg}`);
|
|
21399
20799
|
}
|
|
21400
20800
|
}
|
|
21401
|
-
var whoamiCommand = new
|
|
20801
|
+
var whoamiCommand = new Command44().name("whoami").description("Show current identity and environment information").action(
|
|
21402
20802
|
withErrorHandler(async () => {
|
|
21403
20803
|
if (isInsideSandbox()) {
|
|
21404
20804
|
await showSandboxInfo();
|
|
@@ -21409,20 +20809,20 @@ var whoamiCommand = new Command49().name("whoami").description("Show current ide
|
|
|
21409
20809
|
);
|
|
21410
20810
|
|
|
21411
20811
|
// src/commands/zero/index.ts
|
|
21412
|
-
import { Command as
|
|
20812
|
+
import { Command as Command94 } from "commander";
|
|
21413
20813
|
|
|
21414
20814
|
// src/commands/zero/org/index.ts
|
|
21415
|
-
import { Command as
|
|
20815
|
+
import { Command as Command67 } from "commander";
|
|
21416
20816
|
|
|
21417
20817
|
// src/commands/zero/org/status.ts
|
|
21418
|
-
import { Command as
|
|
21419
|
-
import
|
|
21420
|
-
var
|
|
20818
|
+
import { Command as Command45 } from "commander";
|
|
20819
|
+
import chalk41 from "chalk";
|
|
20820
|
+
var statusCommand5 = new Command45().name("status").description("View current organization status").action(
|
|
21421
20821
|
withErrorHandler(async () => {
|
|
21422
20822
|
try {
|
|
21423
20823
|
const org = await getZeroOrg();
|
|
21424
|
-
console.log(
|
|
21425
|
-
console.log(` Slug: ${
|
|
20824
|
+
console.log(chalk41.bold("Organization Information:"));
|
|
20825
|
+
console.log(` Slug: ${chalk41.green(org.slug)}`);
|
|
21426
20826
|
} catch (error) {
|
|
21427
20827
|
if (error instanceof ApiRequestError && error.status === 404) {
|
|
21428
20828
|
throw new Error("No organization configured", {
|
|
@@ -21437,9 +20837,9 @@ var statusCommand6 = new Command50().name("status").description("View current or
|
|
|
21437
20837
|
);
|
|
21438
20838
|
|
|
21439
20839
|
// src/commands/zero/org/set.ts
|
|
21440
|
-
import { Command as
|
|
21441
|
-
import
|
|
21442
|
-
var setCommand = new
|
|
20840
|
+
import { Command as Command46 } from "commander";
|
|
20841
|
+
import chalk42 from "chalk";
|
|
20842
|
+
var setCommand = new Command46().name("set").description("Rename your organization slug").argument("<slug>", "The new organization slug").option(
|
|
21443
20843
|
"--force",
|
|
21444
20844
|
"Force change existing organization (may break references)"
|
|
21445
20845
|
).action(
|
|
@@ -21458,10 +20858,10 @@ var setCommand = new Command51().name("set").description("Rename your organizati
|
|
|
21458
20858
|
}
|
|
21459
20859
|
const org = await updateZeroOrg({ slug, force: true });
|
|
21460
20860
|
await saveConfig({ activeOrg: org.slug });
|
|
21461
|
-
console.log(
|
|
20861
|
+
console.log(chalk42.green(`\u2713 Organization updated to ${org.slug}`));
|
|
21462
20862
|
console.log();
|
|
21463
20863
|
console.log("Your agents will now be namespaced as:");
|
|
21464
|
-
console.log(
|
|
20864
|
+
console.log(chalk42.cyan(` ${org.slug}/<agent-name>`));
|
|
21465
20865
|
} catch (error) {
|
|
21466
20866
|
if (error instanceof Error && error.message.includes("already exists")) {
|
|
21467
20867
|
throw new Error(
|
|
@@ -21474,27 +20874,27 @@ var setCommand = new Command51().name("set").description("Rename your organizati
|
|
|
21474
20874
|
);
|
|
21475
20875
|
|
|
21476
20876
|
// src/commands/zero/org/list.ts
|
|
21477
|
-
import { Command as
|
|
21478
|
-
import
|
|
21479
|
-
var
|
|
20877
|
+
import { Command as Command47 } from "commander";
|
|
20878
|
+
import chalk43 from "chalk";
|
|
20879
|
+
var listCommand5 = new Command47().name("list").description("List all accessible organizations").action(
|
|
21480
20880
|
withErrorHandler(async () => {
|
|
21481
20881
|
const result = await listZeroOrgs();
|
|
21482
20882
|
const activeOrg = await getActiveOrg();
|
|
21483
|
-
console.log(
|
|
20883
|
+
console.log(chalk43.bold("Available organizations:"));
|
|
21484
20884
|
for (const org of result.orgs) {
|
|
21485
20885
|
const isCurrent = org.slug === activeOrg;
|
|
21486
|
-
const marker = isCurrent ?
|
|
20886
|
+
const marker = isCurrent ? chalk43.green("* ") : " ";
|
|
21487
20887
|
const roleLabel = org.role ? ` (${org.role})` : "";
|
|
21488
|
-
const currentLabel = isCurrent ?
|
|
20888
|
+
const currentLabel = isCurrent ? chalk43.dim(" \u2190 current") : "";
|
|
21489
20889
|
console.log(`${marker}${org.slug}${roleLabel}${currentLabel}`);
|
|
21490
20890
|
}
|
|
21491
20891
|
})
|
|
21492
20892
|
);
|
|
21493
20893
|
|
|
21494
20894
|
// src/commands/zero/org/use.ts
|
|
21495
|
-
import { Command as
|
|
21496
|
-
import
|
|
21497
|
-
var useCommand = new
|
|
20895
|
+
import { Command as Command48 } from "commander";
|
|
20896
|
+
import chalk44 from "chalk";
|
|
20897
|
+
var useCommand = new Command48().name("use").description("Switch to a different organization").argument("<slug>", "Organization slug to switch to").action(
|
|
21498
20898
|
withErrorHandler(async (slug) => {
|
|
21499
20899
|
const orgList = await listZeroOrgs();
|
|
21500
20900
|
const target = orgList.orgs.find((s) => s.slug === slug);
|
|
@@ -21502,119 +20902,119 @@ var useCommand = new Command53().name("use").description("Switch to a different
|
|
|
21502
20902
|
throw new Error(`Organization '${slug}' not found or not accessible.`);
|
|
21503
20903
|
}
|
|
21504
20904
|
await saveConfig({ activeOrg: slug });
|
|
21505
|
-
console.log(
|
|
20905
|
+
console.log(chalk44.green(`\u2713 Switched to organization: ${slug}`));
|
|
21506
20906
|
})
|
|
21507
20907
|
);
|
|
21508
20908
|
|
|
21509
20909
|
// src/commands/zero/org/members.ts
|
|
21510
|
-
import { Command as
|
|
21511
|
-
import
|
|
21512
|
-
var membersCommand = new
|
|
20910
|
+
import { Command as Command49 } from "commander";
|
|
20911
|
+
import chalk45 from "chalk";
|
|
20912
|
+
var membersCommand = new Command49().name("members").description("View organization members").action(
|
|
21513
20913
|
withErrorHandler(async () => {
|
|
21514
20914
|
const status = await getZeroOrgMembers();
|
|
21515
|
-
console.log(
|
|
20915
|
+
console.log(chalk45.bold(`Organization: ${status.slug}`));
|
|
21516
20916
|
console.log(` Role: ${status.role}`);
|
|
21517
20917
|
console.log(
|
|
21518
20918
|
` Created: ${new Date(status.createdAt).toLocaleDateString()}`
|
|
21519
20919
|
);
|
|
21520
20920
|
console.log();
|
|
21521
|
-
console.log(
|
|
20921
|
+
console.log(chalk45.bold("Members:"));
|
|
21522
20922
|
for (const member of status.members) {
|
|
21523
|
-
const roleTag = member.role === "admin" ?
|
|
20923
|
+
const roleTag = member.role === "admin" ? chalk45.yellow(` (${member.role})`) : chalk45.dim(` (${member.role})`);
|
|
21524
20924
|
console.log(` ${member.email}${roleTag}`);
|
|
21525
20925
|
}
|
|
21526
20926
|
})
|
|
21527
20927
|
);
|
|
21528
20928
|
|
|
21529
20929
|
// src/commands/zero/org/invite.ts
|
|
21530
|
-
import { Command as
|
|
21531
|
-
import
|
|
21532
|
-
var inviteCommand = new
|
|
20930
|
+
import { Command as Command50 } from "commander";
|
|
20931
|
+
import chalk46 from "chalk";
|
|
20932
|
+
var inviteCommand = new Command50().name("invite").description("Invite a member to the current organization").requiredOption("--email <email>", "Email address of the member to invite").action(
|
|
21533
20933
|
withErrorHandler(async (options) => {
|
|
21534
20934
|
await inviteZeroOrgMember(options.email);
|
|
21535
|
-
console.log(
|
|
20935
|
+
console.log(chalk46.green(`\u2713 Invitation sent to ${options.email}`));
|
|
21536
20936
|
})
|
|
21537
20937
|
);
|
|
21538
20938
|
|
|
21539
20939
|
// src/commands/zero/org/remove.ts
|
|
21540
|
-
import { Command as
|
|
21541
|
-
import
|
|
21542
|
-
var removeCommand = new
|
|
20940
|
+
import { Command as Command51 } from "commander";
|
|
20941
|
+
import chalk47 from "chalk";
|
|
20942
|
+
var removeCommand = new Command51().name("remove").description("Remove a member from the current organization").argument("<email>", "Email address of the member to remove").action(
|
|
21543
20943
|
withErrorHandler(async (email) => {
|
|
21544
20944
|
await removeZeroOrgMember(email);
|
|
21545
|
-
console.log(
|
|
20945
|
+
console.log(chalk47.green(`\u2713 Removed ${email} from organization`));
|
|
21546
20946
|
})
|
|
21547
20947
|
);
|
|
21548
20948
|
|
|
21549
20949
|
// src/commands/zero/org/leave.ts
|
|
21550
|
-
import { Command as
|
|
21551
|
-
import
|
|
21552
|
-
var leaveCommand = new
|
|
20950
|
+
import { Command as Command52 } from "commander";
|
|
20951
|
+
import chalk48 from "chalk";
|
|
20952
|
+
var leaveCommand = new Command52().name("leave").description("Leave the current organization").action(
|
|
21553
20953
|
withErrorHandler(async () => {
|
|
21554
20954
|
await leaveZeroOrg();
|
|
21555
20955
|
const { orgs } = await listZeroOrgs();
|
|
21556
20956
|
if (orgs.length === 0) {
|
|
21557
20957
|
await saveConfig({ activeOrg: void 0 });
|
|
21558
|
-
console.log(
|
|
20958
|
+
console.log(chalk48.green("\u2713 Left organization."));
|
|
21559
20959
|
console.log(
|
|
21560
|
-
|
|
20960
|
+
chalk48.yellow("No remaining organizations. Run: vm0 auth login")
|
|
21561
20961
|
);
|
|
21562
20962
|
return;
|
|
21563
20963
|
}
|
|
21564
20964
|
const nextOrg = orgs[0].slug;
|
|
21565
20965
|
await saveConfig({ activeOrg: nextOrg });
|
|
21566
|
-
console.log(
|
|
20966
|
+
console.log(chalk48.green(`\u2713 Left organization. Switched to: ${nextOrg}`));
|
|
21567
20967
|
})
|
|
21568
20968
|
);
|
|
21569
20969
|
|
|
21570
20970
|
// src/commands/zero/org/delete.ts
|
|
21571
|
-
import { Command as
|
|
21572
|
-
import
|
|
21573
|
-
var deleteCommand = new
|
|
20971
|
+
import { Command as Command53 } from "commander";
|
|
20972
|
+
import chalk49 from "chalk";
|
|
20973
|
+
var deleteCommand = new Command53().name("delete").description("Delete the current organization (admin only)").argument("<slug>", "Organization slug to confirm deletion").action(
|
|
21574
20974
|
withErrorHandler(async (slug) => {
|
|
21575
20975
|
await deleteZeroOrg(slug);
|
|
21576
|
-
console.log(
|
|
20976
|
+
console.log(chalk49.green(`\u2713 Organization '${slug}' has been deleted.`));
|
|
21577
20977
|
})
|
|
21578
20978
|
);
|
|
21579
20979
|
|
|
21580
20980
|
// src/commands/zero/org/secret/index.ts
|
|
21581
|
-
import { Command as
|
|
20981
|
+
import { Command as Command57 } from "commander";
|
|
21582
20982
|
|
|
21583
20983
|
// src/commands/zero/org/secret/list.ts
|
|
21584
|
-
import { Command as
|
|
21585
|
-
import
|
|
21586
|
-
var
|
|
20984
|
+
import { Command as Command54 } from "commander";
|
|
20985
|
+
import chalk50 from "chalk";
|
|
20986
|
+
var listCommand6 = new Command54().name("list").alias("ls").description("List all org-level secrets").action(
|
|
21587
20987
|
withErrorHandler(async () => {
|
|
21588
20988
|
const result = await listZeroOrgSecrets();
|
|
21589
20989
|
if (result.secrets.length === 0) {
|
|
21590
|
-
console.log(
|
|
20990
|
+
console.log(chalk50.dim("No org secrets found"));
|
|
21591
20991
|
console.log();
|
|
21592
20992
|
console.log("To add an org secret:");
|
|
21593
20993
|
console.log(
|
|
21594
|
-
|
|
20994
|
+
chalk50.cyan(" vm0 zero org secret set MY_API_KEY --body <value>")
|
|
21595
20995
|
);
|
|
21596
20996
|
return;
|
|
21597
20997
|
}
|
|
21598
|
-
console.log(
|
|
20998
|
+
console.log(chalk50.bold("Org Secrets:"));
|
|
21599
20999
|
console.log();
|
|
21600
21000
|
for (const secret of result.secrets) {
|
|
21601
|
-
console.log(` ${
|
|
21001
|
+
console.log(` ${chalk50.cyan(secret.name)}`);
|
|
21602
21002
|
if (secret.description) {
|
|
21603
|
-
console.log(` ${
|
|
21003
|
+
console.log(` ${chalk50.dim(secret.description)}`);
|
|
21604
21004
|
}
|
|
21605
21005
|
console.log(
|
|
21606
|
-
` ${
|
|
21006
|
+
` ${chalk50.dim(`Updated: ${new Date(secret.updatedAt).toLocaleString()}`)}`
|
|
21607
21007
|
);
|
|
21608
21008
|
console.log();
|
|
21609
21009
|
}
|
|
21610
|
-
console.log(
|
|
21010
|
+
console.log(chalk50.dim(`Total: ${result.secrets.length} secret(s)`));
|
|
21611
21011
|
})
|
|
21612
21012
|
);
|
|
21613
21013
|
|
|
21614
21014
|
// src/commands/zero/org/secret/set.ts
|
|
21615
|
-
import { Command as
|
|
21616
|
-
import
|
|
21617
|
-
var setCommand2 = new
|
|
21015
|
+
import { Command as Command55 } from "commander";
|
|
21016
|
+
import chalk51 from "chalk";
|
|
21017
|
+
var setCommand2 = new Command55().name("set").description("Create or update an org-level secret (admin only)").argument("<name>", "Secret name (uppercase, e.g., MY_API_KEY)").option(
|
|
21618
21018
|
"-b, --body <value>",
|
|
21619
21019
|
"Secret value (required in non-interactive mode)"
|
|
21620
21020
|
).option("-d, --description <description>", "Optional description").action(
|
|
@@ -21653,19 +21053,19 @@ var setCommand2 = new Command60().name("set").description("Create or update an o
|
|
|
21653
21053
|
}
|
|
21654
21054
|
throw error;
|
|
21655
21055
|
}
|
|
21656
|
-
console.log(
|
|
21056
|
+
console.log(chalk51.green(`\u2713 Org secret "${secret.name}" saved`));
|
|
21657
21057
|
console.log();
|
|
21658
21058
|
console.log("Use in vm0.yaml:");
|
|
21659
|
-
console.log(
|
|
21660
|
-
console.log(
|
|
21059
|
+
console.log(chalk51.cyan(` environment:`));
|
|
21060
|
+
console.log(chalk51.cyan(` ${name}: \${{ secrets.${name} }}`));
|
|
21661
21061
|
}
|
|
21662
21062
|
)
|
|
21663
21063
|
);
|
|
21664
21064
|
|
|
21665
21065
|
// src/commands/zero/org/secret/remove.ts
|
|
21666
|
-
import { Command as
|
|
21667
|
-
import
|
|
21668
|
-
var removeCommand2 = new
|
|
21066
|
+
import { Command as Command56 } from "commander";
|
|
21067
|
+
import chalk52 from "chalk";
|
|
21068
|
+
var removeCommand2 = new Command56().name("remove").description("Delete an org-level secret (admin only)").argument("<name>", "Secret name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
21669
21069
|
withErrorHandler(async (name, options) => {
|
|
21670
21070
|
if (!options.yes) {
|
|
21671
21071
|
if (!isInteractive()) {
|
|
@@ -21676,61 +21076,61 @@ var removeCommand2 = new Command61().name("remove").description("Delete an org-l
|
|
|
21676
21076
|
false
|
|
21677
21077
|
);
|
|
21678
21078
|
if (!confirmed) {
|
|
21679
|
-
console.log(
|
|
21079
|
+
console.log(chalk52.dim("Cancelled"));
|
|
21680
21080
|
return;
|
|
21681
21081
|
}
|
|
21682
21082
|
}
|
|
21683
21083
|
await deleteZeroOrgSecret(name);
|
|
21684
|
-
console.log(
|
|
21084
|
+
console.log(chalk52.green(`\u2713 Org secret "${name}" deleted`));
|
|
21685
21085
|
})
|
|
21686
21086
|
);
|
|
21687
21087
|
|
|
21688
21088
|
// src/commands/zero/org/secret/index.ts
|
|
21689
|
-
var zeroOrgSecretCommand = new
|
|
21089
|
+
var zeroOrgSecretCommand = new Command57().name("secret").description("Manage org-level secrets (admin)").addCommand(listCommand6).addCommand(setCommand2).addCommand(removeCommand2);
|
|
21690
21090
|
|
|
21691
21091
|
// src/commands/zero/org/variable/index.ts
|
|
21692
|
-
import { Command as
|
|
21092
|
+
import { Command as Command61 } from "commander";
|
|
21693
21093
|
|
|
21694
21094
|
// src/commands/zero/org/variable/list.ts
|
|
21695
|
-
import { Command as
|
|
21696
|
-
import
|
|
21095
|
+
import { Command as Command58 } from "commander";
|
|
21096
|
+
import chalk53 from "chalk";
|
|
21697
21097
|
function truncateValue(value, maxLength = 60) {
|
|
21698
21098
|
if (value.length <= maxLength) {
|
|
21699
21099
|
return value;
|
|
21700
21100
|
}
|
|
21701
21101
|
return value.slice(0, maxLength - 15) + "... [truncated]";
|
|
21702
21102
|
}
|
|
21703
|
-
var
|
|
21103
|
+
var listCommand7 = new Command58().name("list").alias("ls").description("List all org-level variables").action(
|
|
21704
21104
|
withErrorHandler(async () => {
|
|
21705
21105
|
const result = await listZeroOrgVariables();
|
|
21706
21106
|
if (result.variables.length === 0) {
|
|
21707
|
-
console.log(
|
|
21107
|
+
console.log(chalk53.dim("No org variables found"));
|
|
21708
21108
|
console.log();
|
|
21709
21109
|
console.log("To add an org variable:");
|
|
21710
|
-
console.log(
|
|
21110
|
+
console.log(chalk53.cyan(" vm0 zero org variable set MY_VAR <value>"));
|
|
21711
21111
|
return;
|
|
21712
21112
|
}
|
|
21713
|
-
console.log(
|
|
21113
|
+
console.log(chalk53.bold("Org Variables:"));
|
|
21714
21114
|
console.log();
|
|
21715
21115
|
for (const variable of result.variables) {
|
|
21716
21116
|
const displayValue = truncateValue(variable.value);
|
|
21717
|
-
console.log(` ${
|
|
21117
|
+
console.log(` ${chalk53.cyan(variable.name)} = ${displayValue}`);
|
|
21718
21118
|
if (variable.description) {
|
|
21719
|
-
console.log(` ${
|
|
21119
|
+
console.log(` ${chalk53.dim(variable.description)}`);
|
|
21720
21120
|
}
|
|
21721
21121
|
console.log(
|
|
21722
|
-
` ${
|
|
21122
|
+
` ${chalk53.dim(`Updated: ${new Date(variable.updatedAt).toLocaleString()}`)}`
|
|
21723
21123
|
);
|
|
21724
21124
|
console.log();
|
|
21725
21125
|
}
|
|
21726
|
-
console.log(
|
|
21126
|
+
console.log(chalk53.dim(`Total: ${result.variables.length} variable(s)`));
|
|
21727
21127
|
})
|
|
21728
21128
|
);
|
|
21729
21129
|
|
|
21730
21130
|
// src/commands/zero/org/variable/set.ts
|
|
21731
|
-
import { Command as
|
|
21732
|
-
import
|
|
21733
|
-
var setCommand3 = new
|
|
21131
|
+
import { Command as Command59 } from "commander";
|
|
21132
|
+
import chalk54 from "chalk";
|
|
21133
|
+
var setCommand3 = new Command59().name("set").description("Create or update an org-level variable (admin only)").argument("<name>", "Variable name (uppercase, e.g., MY_VAR)").argument("<value>", "Variable value").option("-d, --description <description>", "Optional description").action(
|
|
21734
21134
|
withErrorHandler(
|
|
21735
21135
|
async (name, value, options) => {
|
|
21736
21136
|
let variable;
|
|
@@ -21750,19 +21150,19 @@ var setCommand3 = new Command64().name("set").description("Create or update an o
|
|
|
21750
21150
|
}
|
|
21751
21151
|
throw error;
|
|
21752
21152
|
}
|
|
21753
|
-
console.log(
|
|
21153
|
+
console.log(chalk54.green(`\u2713 Org variable "${variable.name}" saved`));
|
|
21754
21154
|
console.log();
|
|
21755
21155
|
console.log("Use in vm0.yaml:");
|
|
21756
|
-
console.log(
|
|
21757
|
-
console.log(
|
|
21156
|
+
console.log(chalk54.cyan(` environment:`));
|
|
21157
|
+
console.log(chalk54.cyan(` ${name}: \${{ vars.${name} }}`));
|
|
21758
21158
|
}
|
|
21759
21159
|
)
|
|
21760
21160
|
);
|
|
21761
21161
|
|
|
21762
21162
|
// src/commands/zero/org/variable/remove.ts
|
|
21763
|
-
import { Command as
|
|
21764
|
-
import
|
|
21765
|
-
var removeCommand3 = new
|
|
21163
|
+
import { Command as Command60 } from "commander";
|
|
21164
|
+
import chalk55 from "chalk";
|
|
21165
|
+
var removeCommand3 = new Command60().name("remove").description("Delete an org-level variable (admin only)").argument("<name>", "Variable name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
21766
21166
|
withErrorHandler(async (name, options) => {
|
|
21767
21167
|
if (!options.yes) {
|
|
21768
21168
|
if (!isInteractive()) {
|
|
@@ -21773,32 +21173,32 @@ var removeCommand3 = new Command65().name("remove").description("Delete an org-l
|
|
|
21773
21173
|
false
|
|
21774
21174
|
);
|
|
21775
21175
|
if (!confirmed) {
|
|
21776
|
-
console.log(
|
|
21176
|
+
console.log(chalk55.dim("Cancelled"));
|
|
21777
21177
|
return;
|
|
21778
21178
|
}
|
|
21779
21179
|
}
|
|
21780
21180
|
await deleteZeroOrgVariable(name);
|
|
21781
|
-
console.log(
|
|
21181
|
+
console.log(chalk55.green(`\u2713 Org variable "${name}" deleted`));
|
|
21782
21182
|
})
|
|
21783
21183
|
);
|
|
21784
21184
|
|
|
21785
21185
|
// src/commands/zero/org/variable/index.ts
|
|
21786
|
-
var zeroOrgVariableCommand = new
|
|
21186
|
+
var zeroOrgVariableCommand = new Command61().name("variable").description("Manage org-level variables (admin)").addCommand(listCommand7).addCommand(setCommand3).addCommand(removeCommand3);
|
|
21787
21187
|
|
|
21788
21188
|
// src/commands/zero/org/model-provider/index.ts
|
|
21789
|
-
import { Command as
|
|
21189
|
+
import { Command as Command66 } from "commander";
|
|
21790
21190
|
|
|
21791
21191
|
// src/commands/zero/org/model-provider/list.ts
|
|
21792
|
-
import { Command as
|
|
21793
|
-
import
|
|
21794
|
-
var
|
|
21192
|
+
import { Command as Command62 } from "commander";
|
|
21193
|
+
import chalk56 from "chalk";
|
|
21194
|
+
var listCommand8 = new Command62().name("list").alias("ls").description("List all org-level model providers").action(
|
|
21795
21195
|
withErrorHandler(async () => {
|
|
21796
21196
|
const result = await listZeroOrgModelProviders();
|
|
21797
21197
|
if (result.modelProviders.length === 0) {
|
|
21798
|
-
console.log(
|
|
21198
|
+
console.log(chalk56.dim("No org-level model providers configured"));
|
|
21799
21199
|
console.log();
|
|
21800
21200
|
console.log("To add an org-level model provider:");
|
|
21801
|
-
console.log(
|
|
21201
|
+
console.log(chalk56.cyan(" vm0 zero org model-provider setup"));
|
|
21802
21202
|
return;
|
|
21803
21203
|
}
|
|
21804
21204
|
const byFramework = result.modelProviders.reduce(
|
|
@@ -21812,16 +21212,16 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
21812
21212
|
},
|
|
21813
21213
|
{}
|
|
21814
21214
|
);
|
|
21815
|
-
console.log(
|
|
21215
|
+
console.log(chalk56.bold("Org Model Providers:"));
|
|
21816
21216
|
console.log();
|
|
21817
21217
|
for (const [framework, providers] of Object.entries(byFramework)) {
|
|
21818
|
-
console.log(` ${
|
|
21218
|
+
console.log(` ${chalk56.cyan(framework)}:`);
|
|
21819
21219
|
for (const provider of providers) {
|
|
21820
|
-
const defaultTag = provider.isDefault ?
|
|
21821
|
-
const modelTag = provider.selectedModel ?
|
|
21220
|
+
const defaultTag = provider.isDefault ? chalk56.green(" (default)") : "";
|
|
21221
|
+
const modelTag = provider.selectedModel ? chalk56.dim(` [${provider.selectedModel}]`) : "";
|
|
21822
21222
|
console.log(` ${provider.type}${defaultTag}${modelTag}`);
|
|
21823
21223
|
console.log(
|
|
21824
|
-
|
|
21224
|
+
chalk56.dim(
|
|
21825
21225
|
` Updated: ${new Date(provider.updatedAt).toLocaleString()}`
|
|
21826
21226
|
)
|
|
21827
21227
|
);
|
|
@@ -21829,18 +21229,18 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
21829
21229
|
console.log();
|
|
21830
21230
|
}
|
|
21831
21231
|
console.log(
|
|
21832
|
-
|
|
21232
|
+
chalk56.dim(`Total: ${result.modelProviders.length} provider(s)`)
|
|
21833
21233
|
);
|
|
21834
21234
|
})
|
|
21835
21235
|
);
|
|
21836
21236
|
|
|
21837
21237
|
// src/commands/zero/org/model-provider/setup.ts
|
|
21838
|
-
import { Command as
|
|
21839
|
-
import
|
|
21238
|
+
import { Command as Command63 } from "commander";
|
|
21239
|
+
import chalk58 from "chalk";
|
|
21840
21240
|
import prompts3 from "prompts";
|
|
21841
21241
|
|
|
21842
21242
|
// src/lib/domain/model-provider/shared.ts
|
|
21843
|
-
import
|
|
21243
|
+
import chalk57 from "chalk";
|
|
21844
21244
|
import prompts2 from "prompts";
|
|
21845
21245
|
function validateProviderType(typeStr) {
|
|
21846
21246
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(typeStr)) {
|
|
@@ -22025,7 +21425,7 @@ async function promptForModelSelection(type2) {
|
|
|
22025
21425
|
if (selected === "__custom__") {
|
|
22026
21426
|
const placeholder = getCustomModelPlaceholder(type2);
|
|
22027
21427
|
if (placeholder) {
|
|
22028
|
-
console.log(
|
|
21428
|
+
console.log(chalk57.dim(`Example: ${placeholder}`));
|
|
22029
21429
|
}
|
|
22030
21430
|
const customResponse = await prompts2(
|
|
22031
21431
|
{
|
|
@@ -22075,7 +21475,7 @@ async function promptForSecrets(type2, authMethod) {
|
|
|
22075
21475
|
const secrets = {};
|
|
22076
21476
|
for (const [name, fieldConfig] of Object.entries(secretsConfig)) {
|
|
22077
21477
|
if (fieldConfig.helpText) {
|
|
22078
|
-
console.log(
|
|
21478
|
+
console.log(chalk57.dim(fieldConfig.helpText));
|
|
22079
21479
|
}
|
|
22080
21480
|
const isSensitive = isSensitiveSecret(name);
|
|
22081
21481
|
const placeholder = "placeholder" in fieldConfig ? fieldConfig.placeholder : "";
|
|
@@ -22132,7 +21532,7 @@ async function handleInteractiveMode() {
|
|
|
22132
21532
|
title = `${title} \u2713`;
|
|
22133
21533
|
}
|
|
22134
21534
|
if (isExperimental) {
|
|
22135
|
-
title = `${title} ${
|
|
21535
|
+
title = `${title} ${chalk58.dim("(experimental)")}`;
|
|
22136
21536
|
}
|
|
22137
21537
|
return {
|
|
22138
21538
|
title,
|
|
@@ -22179,7 +21579,7 @@ async function handleInteractiveMode() {
|
|
|
22179
21579
|
const config = MODEL_PROVIDER_TYPES[type2];
|
|
22180
21580
|
console.log();
|
|
22181
21581
|
if ("helpText" in config) {
|
|
22182
|
-
console.log(
|
|
21582
|
+
console.log(chalk58.dim(config.helpText));
|
|
22183
21583
|
}
|
|
22184
21584
|
console.log();
|
|
22185
21585
|
if (hasAuthMethods(type2)) {
|
|
@@ -22221,10 +21621,10 @@ async function promptSetAsDefault(type2, framework, isDefault) {
|
|
|
22221
21621
|
);
|
|
22222
21622
|
if (response.setDefault) {
|
|
22223
21623
|
await setZeroOrgModelProviderDefault(type2);
|
|
22224
|
-
console.log(
|
|
21624
|
+
console.log(chalk58.green(`\u2713 Default for ${framework} set to "${type2}"`));
|
|
22225
21625
|
}
|
|
22226
21626
|
}
|
|
22227
|
-
var setupCommand = new
|
|
21627
|
+
var setupCommand = new Command63().name("setup").description("Configure an org-level model provider").option("-t, --type <type>", "Provider type (for non-interactive mode)").option(
|
|
22228
21628
|
"-s, --secret <value>",
|
|
22229
21629
|
"Secret value (can be used multiple times, supports VALUE or KEY=VALUE format)",
|
|
22230
21630
|
collectSecrets,
|
|
@@ -22263,11 +21663,11 @@ var setupCommand = new Command68().name("setup").description("Configure an org-l
|
|
|
22263
21663
|
const modelNote2 = provider2.selectedModel ? ` with model: ${provider2.selectedModel}` : "";
|
|
22264
21664
|
if (!hasModelSelection(input.type)) {
|
|
22265
21665
|
console.log(
|
|
22266
|
-
|
|
21666
|
+
chalk58.green(`\u2713 Org model provider "${input.type}" unchanged`)
|
|
22267
21667
|
);
|
|
22268
21668
|
} else {
|
|
22269
21669
|
console.log(
|
|
22270
|
-
|
|
21670
|
+
chalk58.green(
|
|
22271
21671
|
`\u2713 Org model provider "${input.type}" updated${defaultNote2}${modelNote2}`
|
|
22272
21672
|
)
|
|
22273
21673
|
);
|
|
@@ -22292,7 +21692,7 @@ var setupCommand = new Command68().name("setup").description("Configure an org-l
|
|
|
22292
21692
|
const defaultNote = provider.isDefault ? ` (default for ${provider.framework})` : "";
|
|
22293
21693
|
const modelNote = provider.selectedModel ? ` with model: ${provider.selectedModel}` : "";
|
|
22294
21694
|
console.log(
|
|
22295
|
-
|
|
21695
|
+
chalk58.green(
|
|
22296
21696
|
`\u2713 Org model provider "${input.type}" ${action}${defaultNote}${modelNote}`
|
|
22297
21697
|
)
|
|
22298
21698
|
);
|
|
@@ -22308,9 +21708,9 @@ var setupCommand = new Command68().name("setup").description("Configure an org-l
|
|
|
22308
21708
|
);
|
|
22309
21709
|
|
|
22310
21710
|
// src/commands/zero/org/model-provider/remove.ts
|
|
22311
|
-
import { Command as
|
|
22312
|
-
import
|
|
22313
|
-
var removeCommand4 = new
|
|
21711
|
+
import { Command as Command64 } from "commander";
|
|
21712
|
+
import chalk59 from "chalk";
|
|
21713
|
+
var removeCommand4 = new Command64().name("remove").description("Remove an org-level model provider").argument("<type>", "Model provider type to remove").action(
|
|
22314
21714
|
withErrorHandler(async (type2) => {
|
|
22315
21715
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
22316
21716
|
const validTypes = Object.keys(MODEL_PROVIDER_TYPES).join(", ");
|
|
@@ -22319,14 +21719,14 @@ var removeCommand4 = new Command69().name("remove").description("Remove an org-l
|
|
|
22319
21719
|
});
|
|
22320
21720
|
}
|
|
22321
21721
|
await deleteZeroOrgModelProvider(type2);
|
|
22322
|
-
console.log(
|
|
21722
|
+
console.log(chalk59.green(`\u2713 Org model provider "${type2}" removed`));
|
|
22323
21723
|
})
|
|
22324
21724
|
);
|
|
22325
21725
|
|
|
22326
21726
|
// src/commands/zero/org/model-provider/set-default.ts
|
|
22327
|
-
import { Command as
|
|
22328
|
-
import
|
|
22329
|
-
var setDefaultCommand = new
|
|
21727
|
+
import { Command as Command65 } from "commander";
|
|
21728
|
+
import chalk60 from "chalk";
|
|
21729
|
+
var setDefaultCommand = new Command65().name("set-default").description("Set an org-level model provider as default for its framework").argument("<type>", "Model provider type to set as default").action(
|
|
22330
21730
|
withErrorHandler(async (type2) => {
|
|
22331
21731
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
22332
21732
|
const validTypes = Object.keys(MODEL_PROVIDER_TYPES).join(", ");
|
|
@@ -22338,7 +21738,7 @@ var setDefaultCommand = new Command70().name("set-default").description("Set an
|
|
|
22338
21738
|
type2
|
|
22339
21739
|
);
|
|
22340
21740
|
console.log(
|
|
22341
|
-
|
|
21741
|
+
chalk60.green(
|
|
22342
21742
|
`\u2713 Default for ${provider.framework} set to "${provider.type}"`
|
|
22343
21743
|
)
|
|
22344
21744
|
);
|
|
@@ -22346,19 +21746,19 @@ var setDefaultCommand = new Command70().name("set-default").description("Set an
|
|
|
22346
21746
|
);
|
|
22347
21747
|
|
|
22348
21748
|
// src/commands/zero/org/model-provider/index.ts
|
|
22349
|
-
var zeroOrgModelProviderCommand = new
|
|
21749
|
+
var zeroOrgModelProviderCommand = new Command66().name("model-provider").description("Manage org-level model providers").addCommand(listCommand8).addCommand(setupCommand).addCommand(removeCommand4).addCommand(setDefaultCommand);
|
|
22350
21750
|
|
|
22351
21751
|
// src/commands/zero/org/index.ts
|
|
22352
|
-
var zeroOrgCommand = new
|
|
21752
|
+
var zeroOrgCommand = new Command67().name("org").description("Manage your organization").addCommand(statusCommand5).addCommand(setCommand).addCommand(listCommand5).addCommand(useCommand).addCommand(membersCommand).addCommand(inviteCommand).addCommand(removeCommand).addCommand(leaveCommand).addCommand(deleteCommand).addCommand(zeroOrgSecretCommand).addCommand(zeroOrgVariableCommand).addCommand(zeroOrgModelProviderCommand);
|
|
22353
21753
|
|
|
22354
21754
|
// src/commands/zero/agent/index.ts
|
|
22355
|
-
import { Command as
|
|
21755
|
+
import { Command as Command73 } from "commander";
|
|
22356
21756
|
|
|
22357
21757
|
// src/commands/zero/agent/create.ts
|
|
22358
|
-
import { Command as
|
|
21758
|
+
import { Command as Command68 } from "commander";
|
|
22359
21759
|
import { readFileSync } from "fs";
|
|
22360
|
-
import
|
|
22361
|
-
var createCommand = new
|
|
21760
|
+
import chalk61 from "chalk";
|
|
21761
|
+
var createCommand = new Command68().name("create").description("Create a new zero agent").requiredOption(
|
|
22362
21762
|
"--connectors <items>",
|
|
22363
21763
|
"Comma-separated connector short names (e.g. github,linear)"
|
|
22364
21764
|
).option("--display-name <name>", "Agent display name").option("--description <text>", "Agent description").option(
|
|
@@ -22378,7 +21778,7 @@ var createCommand = new Command73().name("create").description("Create a new zer
|
|
|
22378
21778
|
const content = readFileSync(options.instructionsFile, "utf-8");
|
|
22379
21779
|
await updateZeroAgentInstructions(agent.name, content);
|
|
22380
21780
|
}
|
|
22381
|
-
console.log(
|
|
21781
|
+
console.log(chalk61.green(`\u2713 Zero agent '${agent.name}' created`));
|
|
22382
21782
|
console.log(` Compose ID: ${agent.agentComposeId}`);
|
|
22383
21783
|
console.log(` Connectors: ${agent.connectors.join(", ")}`);
|
|
22384
21784
|
if (agent.displayName) {
|
|
@@ -22389,10 +21789,10 @@ var createCommand = new Command73().name("create").description("Create a new zer
|
|
|
22389
21789
|
);
|
|
22390
21790
|
|
|
22391
21791
|
// src/commands/zero/agent/edit.ts
|
|
22392
|
-
import { Command as
|
|
21792
|
+
import { Command as Command69 } from "commander";
|
|
22393
21793
|
import { readFileSync as readFileSync2 } from "fs";
|
|
22394
|
-
import
|
|
22395
|
-
var editCommand = new
|
|
21794
|
+
import chalk62 from "chalk";
|
|
21795
|
+
var editCommand = new Command69().name("edit").description("Edit a zero agent").argument("<name>", "Agent name").option(
|
|
22396
21796
|
"--connectors <items>",
|
|
22397
21797
|
"Comma-separated connector short names (e.g. github,linear)"
|
|
22398
21798
|
).option("--display-name <name>", "New display name").option("--description <text>", "New description").option(
|
|
@@ -22421,20 +21821,20 @@ var editCommand = new Command74().name("edit").description("Edit a zero agent").
|
|
|
22421
21821
|
const content = readFileSync2(options.instructionsFile, "utf-8");
|
|
22422
21822
|
await updateZeroAgentInstructions(name, content);
|
|
22423
21823
|
}
|
|
22424
|
-
console.log(
|
|
21824
|
+
console.log(chalk62.green(`\u2713 Zero agent '${name}' updated`));
|
|
22425
21825
|
}
|
|
22426
21826
|
)
|
|
22427
21827
|
);
|
|
22428
21828
|
|
|
22429
21829
|
// src/commands/zero/agent/view.ts
|
|
22430
|
-
import { Command as
|
|
22431
|
-
import
|
|
22432
|
-
var viewCommand = new
|
|
21830
|
+
import { Command as Command70 } from "commander";
|
|
21831
|
+
import chalk63 from "chalk";
|
|
21832
|
+
var viewCommand = new Command70().name("view").description("View a zero agent").argument("<name>", "Agent name").option("--instructions", "Also show instructions content").action(
|
|
22433
21833
|
withErrorHandler(
|
|
22434
21834
|
async (name, options) => {
|
|
22435
21835
|
const agent = await getZeroAgent(name);
|
|
22436
|
-
console.log(
|
|
22437
|
-
if (agent.displayName) console.log(
|
|
21836
|
+
console.log(chalk63.bold(agent.name));
|
|
21837
|
+
if (agent.displayName) console.log(chalk63.dim(agent.displayName));
|
|
22438
21838
|
console.log();
|
|
22439
21839
|
console.log(`Compose ID: ${agent.agentComposeId}`);
|
|
22440
21840
|
console.log(`Connectors: ${agent.connectors.join(", ") || "-"}`);
|
|
@@ -22445,10 +21845,10 @@ var viewCommand = new Command75().name("view").description("View a zero agent").
|
|
|
22445
21845
|
console.log();
|
|
22446
21846
|
const result = await getZeroAgentInstructions(name);
|
|
22447
21847
|
if (result.content) {
|
|
22448
|
-
console.log(
|
|
21848
|
+
console.log(chalk63.dim("\u2500\u2500 Instructions \u2500\u2500"));
|
|
22449
21849
|
console.log(result.content);
|
|
22450
21850
|
} else {
|
|
22451
|
-
console.log(
|
|
21851
|
+
console.log(chalk63.dim("No instructions set"));
|
|
22452
21852
|
}
|
|
22453
21853
|
}
|
|
22454
21854
|
}
|
|
@@ -22456,15 +21856,15 @@ var viewCommand = new Command75().name("view").description("View a zero agent").
|
|
|
22456
21856
|
);
|
|
22457
21857
|
|
|
22458
21858
|
// src/commands/zero/agent/list.ts
|
|
22459
|
-
import { Command as
|
|
22460
|
-
import
|
|
22461
|
-
var
|
|
21859
|
+
import { Command as Command71 } from "commander";
|
|
21860
|
+
import chalk64 from "chalk";
|
|
21861
|
+
var listCommand9 = new Command71().name("list").alias("ls").description("List all zero agents").action(
|
|
22462
21862
|
withErrorHandler(async () => {
|
|
22463
21863
|
const agents = await listZeroAgents();
|
|
22464
21864
|
if (agents.length === 0) {
|
|
22465
|
-
console.log(
|
|
21865
|
+
console.log(chalk64.dim("No zero agents found"));
|
|
22466
21866
|
console.log(
|
|
22467
|
-
|
|
21867
|
+
chalk64.dim(
|
|
22468
21868
|
' Create one with: vm0 zero agent create --connectors github --display-name "My Agent"'
|
|
22469
21869
|
)
|
|
22470
21870
|
);
|
|
@@ -22480,7 +21880,7 @@ var listCommand10 = new Command76().name("list").alias("ls").description("List a
|
|
|
22480
21880
|
"DISPLAY NAME".padEnd(displayWidth),
|
|
22481
21881
|
"CONNECTORS"
|
|
22482
21882
|
].join(" ");
|
|
22483
|
-
console.log(
|
|
21883
|
+
console.log(chalk64.dim(header));
|
|
22484
21884
|
for (const agent of agents) {
|
|
22485
21885
|
const row = [
|
|
22486
21886
|
agent.name.padEnd(nameWidth),
|
|
@@ -22493,9 +21893,9 @@ var listCommand10 = new Command76().name("list").alias("ls").description("List a
|
|
|
22493
21893
|
);
|
|
22494
21894
|
|
|
22495
21895
|
// src/commands/zero/agent/delete.ts
|
|
22496
|
-
import { Command as
|
|
22497
|
-
import
|
|
22498
|
-
var deleteCommand2 = new
|
|
21896
|
+
import { Command as Command72 } from "commander";
|
|
21897
|
+
import chalk65 from "chalk";
|
|
21898
|
+
var deleteCommand2 = new Command72().name("delete").alias("rm").description("Delete a zero agent").argument("<name>", "Agent name").option("-y, --yes", "Skip confirmation prompt").action(
|
|
22499
21899
|
withErrorHandler(async (name, options) => {
|
|
22500
21900
|
await getZeroAgent(name);
|
|
22501
21901
|
if (!options.yes) {
|
|
@@ -22507,37 +21907,212 @@ var deleteCommand2 = new Command77().name("delete").alias("rm").description("Del
|
|
|
22507
21907
|
false
|
|
22508
21908
|
);
|
|
22509
21909
|
if (!confirmed) {
|
|
22510
|
-
console.log(
|
|
21910
|
+
console.log(chalk65.dim("Cancelled"));
|
|
22511
21911
|
return;
|
|
22512
21912
|
}
|
|
22513
21913
|
}
|
|
22514
21914
|
await deleteZeroAgent(name);
|
|
22515
|
-
console.log(
|
|
21915
|
+
console.log(chalk65.green(`\u2713 Zero agent '${name}' deleted`));
|
|
22516
21916
|
})
|
|
22517
21917
|
);
|
|
22518
21918
|
|
|
22519
21919
|
// src/commands/zero/agent/index.ts
|
|
22520
|
-
var agentCommand = new
|
|
21920
|
+
var agentCommand = new Command73("agent").description("Manage zero agents").addCommand(createCommand).addCommand(editCommand).addCommand(viewCommand).addCommand(listCommand9).addCommand(deleteCommand2);
|
|
22521
21921
|
|
|
22522
21922
|
// src/commands/zero/connector/index.ts
|
|
22523
|
-
import { Command as
|
|
21923
|
+
import { Command as Command78 } from "commander";
|
|
21924
|
+
|
|
21925
|
+
// src/commands/zero/connector/connect.ts
|
|
21926
|
+
import { Command as Command74 } from "commander";
|
|
21927
|
+
import chalk67 from "chalk";
|
|
21928
|
+
|
|
21929
|
+
// src/lib/computer/start-services.ts
|
|
21930
|
+
import { spawn as spawn2 } from "child_process";
|
|
21931
|
+
import { access as access2, constants } from "fs/promises";
|
|
21932
|
+
import { createServer } from "net";
|
|
21933
|
+
import { homedir as homedir4 } from "os";
|
|
21934
|
+
import { join as join10 } from "path";
|
|
21935
|
+
import chalk66 from "chalk";
|
|
21936
|
+
|
|
21937
|
+
// src/lib/computer/ngrok.ts
|
|
21938
|
+
import ngrok from "@ngrok/ngrok";
|
|
21939
|
+
async function startNgrokTunnels(ngrokToken, endpointPrefix, webdavPort, cdpPort) {
|
|
21940
|
+
await ngrok.forward({
|
|
21941
|
+
addr: `localhost:${webdavPort}`,
|
|
21942
|
+
authtoken: ngrokToken,
|
|
21943
|
+
domain: `webdav.${endpointPrefix}.internal`
|
|
21944
|
+
});
|
|
21945
|
+
await ngrok.forward({
|
|
21946
|
+
addr: `localhost:${cdpPort}`,
|
|
21947
|
+
authtoken: ngrokToken,
|
|
21948
|
+
domain: `chrome.${endpointPrefix}.internal`
|
|
21949
|
+
});
|
|
21950
|
+
}
|
|
21951
|
+
async function stopNgrokTunnels() {
|
|
21952
|
+
await ngrok.kill();
|
|
21953
|
+
}
|
|
21954
|
+
|
|
21955
|
+
// src/lib/computer/start-services.ts
|
|
21956
|
+
var CHROME_CANDIDATES = [
|
|
21957
|
+
// macOS absolute paths
|
|
21958
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
21959
|
+
"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
|
|
21960
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
21961
|
+
// Linux / PATH-based
|
|
21962
|
+
"google-chrome",
|
|
21963
|
+
"google-chrome-stable",
|
|
21964
|
+
"chromium-browser",
|
|
21965
|
+
"chromium",
|
|
21966
|
+
"chrome"
|
|
21967
|
+
];
|
|
21968
|
+
async function getRandomPort() {
|
|
21969
|
+
return new Promise((resolve, reject) => {
|
|
21970
|
+
const server = createServer();
|
|
21971
|
+
server.listen(0, "127.0.0.1", () => {
|
|
21972
|
+
const { port } = server.address();
|
|
21973
|
+
server.close(() => resolve(port));
|
|
21974
|
+
});
|
|
21975
|
+
server.on("error", reject);
|
|
21976
|
+
});
|
|
21977
|
+
}
|
|
21978
|
+
async function findBinary(...candidates) {
|
|
21979
|
+
for (const candidate of candidates) {
|
|
21980
|
+
if (candidate.startsWith("/")) {
|
|
21981
|
+
try {
|
|
21982
|
+
await access2(candidate, constants.X_OK);
|
|
21983
|
+
return candidate;
|
|
21984
|
+
} catch {
|
|
21985
|
+
}
|
|
21986
|
+
} else {
|
|
21987
|
+
const found = await new Promise((resolve) => {
|
|
21988
|
+
const child = spawn2("which", [candidate]);
|
|
21989
|
+
child.on("close", (code) => resolve(code === 0));
|
|
21990
|
+
});
|
|
21991
|
+
if (found) return candidate;
|
|
21992
|
+
}
|
|
21993
|
+
}
|
|
21994
|
+
return null;
|
|
21995
|
+
}
|
|
21996
|
+
async function checkComputerDependencies() {
|
|
21997
|
+
const wsgidavBinary = await findBinary("wsgidav");
|
|
21998
|
+
if (!wsgidavBinary) {
|
|
21999
|
+
throw new Error(
|
|
22000
|
+
"wsgidav not found\n\nInstall with: pip install wsgidav[cheroot]"
|
|
22001
|
+
);
|
|
22002
|
+
}
|
|
22003
|
+
const chromeBinary = await findBinary(...CHROME_CANDIDATES);
|
|
22004
|
+
if (!chromeBinary) {
|
|
22005
|
+
throw new Error("Chrome not found\n\nInstall Google Chrome or Chromium");
|
|
22006
|
+
}
|
|
22007
|
+
}
|
|
22008
|
+
async function startComputerServices(credentials) {
|
|
22009
|
+
console.log(chalk66.cyan("Starting computer connector services..."));
|
|
22010
|
+
const wsgidavBinary = await findBinary("wsgidav");
|
|
22011
|
+
if (!wsgidavBinary) {
|
|
22012
|
+
throw new Error(
|
|
22013
|
+
"wsgidav not found\n\nInstall with: pip install wsgidav[cheroot]"
|
|
22014
|
+
);
|
|
22015
|
+
}
|
|
22016
|
+
const chromeBinary = await findBinary(...CHROME_CANDIDATES);
|
|
22017
|
+
if (!chromeBinary) {
|
|
22018
|
+
throw new Error("Chrome not found\n\nInstall Google Chrome or Chromium");
|
|
22019
|
+
}
|
|
22020
|
+
const webdavPort = await getRandomPort();
|
|
22021
|
+
const cdpPort = await getRandomPort();
|
|
22022
|
+
const downloadsPath = join10(homedir4(), "Downloads");
|
|
22023
|
+
const wsgidav = spawn2(
|
|
22024
|
+
wsgidavBinary,
|
|
22025
|
+
[
|
|
22026
|
+
"--host=127.0.0.1",
|
|
22027
|
+
`--port=${webdavPort}`,
|
|
22028
|
+
`--root=${downloadsPath}`,
|
|
22029
|
+
"--auth=anonymous",
|
|
22030
|
+
"--no-config"
|
|
22031
|
+
],
|
|
22032
|
+
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
22033
|
+
);
|
|
22034
|
+
wsgidav.stdout?.on("data", (data) => process.stdout.write(data));
|
|
22035
|
+
wsgidav.stderr?.on("data", (data) => process.stderr.write(data));
|
|
22036
|
+
console.log(chalk66.green("\u2713 WebDAV server started"));
|
|
22037
|
+
const chrome = spawn2(
|
|
22038
|
+
chromeBinary,
|
|
22039
|
+
[
|
|
22040
|
+
`--remote-debugging-port=${cdpPort}`,
|
|
22041
|
+
"--remote-debugging-address=127.0.0.1",
|
|
22042
|
+
"--headless=new",
|
|
22043
|
+
"--no-sandbox",
|
|
22044
|
+
"--disable-gpu"
|
|
22045
|
+
],
|
|
22046
|
+
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
22047
|
+
);
|
|
22048
|
+
chrome.stdout?.on("data", (data) => process.stdout.write(data));
|
|
22049
|
+
chrome.stderr?.on("data", (data) => process.stderr.write(data));
|
|
22050
|
+
console.log(chalk66.green("\u2713 Chrome started"));
|
|
22051
|
+
try {
|
|
22052
|
+
await startNgrokTunnels(
|
|
22053
|
+
credentials.ngrokToken,
|
|
22054
|
+
credentials.endpointPrefix,
|
|
22055
|
+
webdavPort,
|
|
22056
|
+
cdpPort
|
|
22057
|
+
);
|
|
22058
|
+
console.log(
|
|
22059
|
+
chalk66.green(
|
|
22060
|
+
`\u2713 ngrok tunnels: webdav.${credentials.domain}, chrome.${credentials.domain}`
|
|
22061
|
+
)
|
|
22062
|
+
);
|
|
22063
|
+
console.log();
|
|
22064
|
+
console.log(chalk66.green("\u2713 Computer connector active"));
|
|
22065
|
+
console.log(` WebDAV: ~/Downloads \u2192 webdav.${credentials.domain}`);
|
|
22066
|
+
console.log(
|
|
22067
|
+
` Chrome CDP: port ${cdpPort} \u2192 chrome.${credentials.domain}`
|
|
22068
|
+
);
|
|
22069
|
+
console.log();
|
|
22070
|
+
console.log(chalk66.dim("Press ^C twice to disconnect"));
|
|
22071
|
+
console.log();
|
|
22072
|
+
let sigintCount = 0;
|
|
22073
|
+
await new Promise((resolve) => {
|
|
22074
|
+
const keepAlive = setInterval(() => {
|
|
22075
|
+
}, 6e4);
|
|
22076
|
+
const done = () => {
|
|
22077
|
+
clearInterval(keepAlive);
|
|
22078
|
+
process.removeListener("SIGINT", onSigint);
|
|
22079
|
+
resolve();
|
|
22080
|
+
};
|
|
22081
|
+
const onSigint = () => {
|
|
22082
|
+
sigintCount++;
|
|
22083
|
+
if (sigintCount === 1) {
|
|
22084
|
+
console.log(chalk66.dim("\nPress ^C again to disconnect and exit..."));
|
|
22085
|
+
} else {
|
|
22086
|
+
done();
|
|
22087
|
+
}
|
|
22088
|
+
};
|
|
22089
|
+
process.on("SIGINT", onSigint);
|
|
22090
|
+
process.once("SIGTERM", done);
|
|
22091
|
+
});
|
|
22092
|
+
} finally {
|
|
22093
|
+
console.log();
|
|
22094
|
+
console.log(chalk66.cyan("Stopping services..."));
|
|
22095
|
+
wsgidav.kill("SIGTERM");
|
|
22096
|
+
chrome.kill("SIGTERM");
|
|
22097
|
+
await stopNgrokTunnels();
|
|
22098
|
+
console.log(chalk66.green("\u2713 Services stopped"));
|
|
22099
|
+
}
|
|
22100
|
+
}
|
|
22524
22101
|
|
|
22525
22102
|
// src/commands/zero/connector/connect.ts
|
|
22526
|
-
|
|
22527
|
-
import chalk71 from "chalk";
|
|
22528
|
-
function delay3(ms) {
|
|
22103
|
+
function delay2(ms) {
|
|
22529
22104
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
22530
22105
|
}
|
|
22531
|
-
function
|
|
22106
|
+
function renderHelpText(text) {
|
|
22532
22107
|
return text.replace(
|
|
22533
22108
|
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
22534
|
-
(_m, label, url) => `${label} (${
|
|
22535
|
-
).replace(/\*\*([^*]+)\*\*/g, (_m, content) =>
|
|
22109
|
+
(_m, label, url) => `${label} (${chalk67.cyan(url)})`
|
|
22110
|
+
).replace(/\*\*([^*]+)\*\*/g, (_m, content) => chalk67.bold(content)).replace(
|
|
22536
22111
|
/^> (.+)$/gm,
|
|
22537
|
-
(_m, content) =>
|
|
22112
|
+
(_m, content) => chalk67.yellow(` ${content}`)
|
|
22538
22113
|
);
|
|
22539
22114
|
}
|
|
22540
|
-
async function
|
|
22115
|
+
async function connectViaApiToken(connectorType, tokenValue) {
|
|
22541
22116
|
const config = CONNECTOR_TYPES[connectorType];
|
|
22542
22117
|
const apiTokenConfig = config.authMethods["api-token"];
|
|
22543
22118
|
if (!apiTokenConfig) {
|
|
@@ -22553,13 +22128,13 @@ async function connectViaApiToken2(connectorType, tokenValue) {
|
|
|
22553
22128
|
} else {
|
|
22554
22129
|
if (apiTokenConfig.helpText) {
|
|
22555
22130
|
console.log();
|
|
22556
|
-
console.log(
|
|
22131
|
+
console.log(renderHelpText(apiTokenConfig.helpText));
|
|
22557
22132
|
console.log();
|
|
22558
22133
|
}
|
|
22559
22134
|
for (const [secretName, secretConfig] of secretEntries) {
|
|
22560
22135
|
if (!secretConfig.required) continue;
|
|
22561
22136
|
const value = await promptPassword(
|
|
22562
|
-
`${secretConfig.label}${secretConfig.placeholder ?
|
|
22137
|
+
`${secretConfig.label}${secretConfig.placeholder ? chalk67.dim(` (${secretConfig.placeholder})`) : ""}:`
|
|
22563
22138
|
);
|
|
22564
22139
|
if (!value) {
|
|
22565
22140
|
throw new Error("Cancelled");
|
|
@@ -22575,20 +22150,20 @@ async function connectViaApiToken2(connectorType, tokenValue) {
|
|
|
22575
22150
|
});
|
|
22576
22151
|
}
|
|
22577
22152
|
console.log(
|
|
22578
|
-
|
|
22153
|
+
chalk67.green(`
|
|
22579
22154
|
\u2713 ${config.label} connected successfully via API token!`)
|
|
22580
22155
|
);
|
|
22581
22156
|
}
|
|
22582
|
-
async function
|
|
22157
|
+
async function connectComputer() {
|
|
22583
22158
|
await checkComputerDependencies();
|
|
22584
|
-
console.log(
|
|
22159
|
+
console.log(chalk67.cyan("Setting up computer connector..."));
|
|
22585
22160
|
const credentials = await createZeroComputerConnector();
|
|
22586
22161
|
await startComputerServices(credentials);
|
|
22587
|
-
console.log(
|
|
22162
|
+
console.log(chalk67.cyan("Disconnecting computer connector..."));
|
|
22588
22163
|
await deleteZeroComputerConnector();
|
|
22589
|
-
console.log(
|
|
22164
|
+
console.log(chalk67.green("\u2713 Disconnected computer"));
|
|
22590
22165
|
}
|
|
22591
|
-
async function
|
|
22166
|
+
async function resolveAuthMethod(connectorType, tokenFlag) {
|
|
22592
22167
|
const config = CONNECTOR_TYPES[connectorType];
|
|
22593
22168
|
const oauthFlag = CONNECTOR_TYPES[connectorType].featureFlag;
|
|
22594
22169
|
const oauthAvailable = "oauth" in config.authMethods && (!oauthFlag || await isFeatureEnabled(oauthFlag));
|
|
@@ -22623,13 +22198,13 @@ async function resolveAuthMethod2(connectorType, tokenFlag) {
|
|
|
22623
22198
|
`${config.label} has no available auth methods. OAuth may not be enabled yet.`
|
|
22624
22199
|
);
|
|
22625
22200
|
}
|
|
22626
|
-
async function
|
|
22627
|
-
console.log(`Connecting ${
|
|
22201
|
+
async function connectViaOAuth(connectorType) {
|
|
22202
|
+
console.log(`Connecting ${chalk67.cyan(connectorType)}...`);
|
|
22628
22203
|
const session = await createZeroConnectorSession(connectorType);
|
|
22629
22204
|
const apiUrl = await getBaseUrl();
|
|
22630
22205
|
const verificationUrl = `${apiUrl}${session.verificationUrl}`;
|
|
22631
|
-
console.log(
|
|
22632
|
-
console.log(
|
|
22206
|
+
console.log(chalk67.green("\nSession created"));
|
|
22207
|
+
console.log(chalk67.cyan(`
|
|
22633
22208
|
To connect, visit: ${verificationUrl}`));
|
|
22634
22209
|
console.log(
|
|
22635
22210
|
`
|
|
@@ -22642,14 +22217,14 @@ The session expires in ${Math.floor(session.expiresIn / 60)} minutes.`
|
|
|
22642
22217
|
let isFirstPoll = true;
|
|
22643
22218
|
while (Date.now() - startTime < maxWaitTime) {
|
|
22644
22219
|
if (!isFirstPoll) {
|
|
22645
|
-
await
|
|
22220
|
+
await delay2(pollInterval);
|
|
22646
22221
|
}
|
|
22647
22222
|
isFirstPoll = false;
|
|
22648
22223
|
const status = await getZeroConnectorSession(connectorType, session.id);
|
|
22649
22224
|
switch (status.status) {
|
|
22650
22225
|
case "complete":
|
|
22651
22226
|
console.log(
|
|
22652
|
-
|
|
22227
|
+
chalk67.green(`
|
|
22653
22228
|
|
|
22654
22229
|
${connectorType} connected successfully!`)
|
|
22655
22230
|
);
|
|
@@ -22661,13 +22236,13 @@ ${connectorType} connected successfully!`)
|
|
|
22661
22236
|
`Connection failed: ${status.errorMessage || "Unknown error"}`
|
|
22662
22237
|
);
|
|
22663
22238
|
case "pending":
|
|
22664
|
-
process.stdout.write(
|
|
22239
|
+
process.stdout.write(chalk67.dim("."));
|
|
22665
22240
|
break;
|
|
22666
22241
|
}
|
|
22667
22242
|
}
|
|
22668
22243
|
throw new Error("Session timed out, please try again");
|
|
22669
22244
|
}
|
|
22670
|
-
var
|
|
22245
|
+
var connectCommand = new Command74().name("connect").description("Connect a third-party service (e.g., GitHub)").argument("<type>", "Connector type (e.g., github)").option("--token <value>", "API token value (skip interactive prompt)").action(
|
|
22671
22246
|
withErrorHandler(async (type2, options) => {
|
|
22672
22247
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
22673
22248
|
if (!parseResult.success) {
|
|
@@ -22678,22 +22253,22 @@ var connectCommand2 = new Command79().name("connect").description("Connect a thi
|
|
|
22678
22253
|
}
|
|
22679
22254
|
const connectorType = parseResult.data;
|
|
22680
22255
|
if (connectorType === "computer") {
|
|
22681
|
-
await
|
|
22256
|
+
await connectComputer();
|
|
22682
22257
|
return;
|
|
22683
22258
|
}
|
|
22684
|
-
const authMethod = await
|
|
22259
|
+
const authMethod = await resolveAuthMethod(connectorType, options.token);
|
|
22685
22260
|
if (authMethod === "api-token") {
|
|
22686
|
-
await
|
|
22261
|
+
await connectViaApiToken(connectorType, options.token);
|
|
22687
22262
|
return;
|
|
22688
22263
|
}
|
|
22689
|
-
await
|
|
22264
|
+
await connectViaOAuth(connectorType);
|
|
22690
22265
|
})
|
|
22691
22266
|
);
|
|
22692
22267
|
|
|
22693
22268
|
// src/commands/zero/connector/list.ts
|
|
22694
|
-
import { Command as
|
|
22695
|
-
import
|
|
22696
|
-
var
|
|
22269
|
+
import { Command as Command75 } from "commander";
|
|
22270
|
+
import chalk68 from "chalk";
|
|
22271
|
+
var listCommand10 = new Command75().name("list").alias("ls").description("List all connectors and their status").action(
|
|
22697
22272
|
withErrorHandler(async () => {
|
|
22698
22273
|
const result = await listZeroConnectors();
|
|
22699
22274
|
const connectedMap = new Map(result.connectors.map((c33) => [c33.type, c33]));
|
|
@@ -22715,26 +22290,141 @@ var listCommand11 = new Command80().name("list").alias("ls").description("List a
|
|
|
22715
22290
|
statusText.padEnd(statusWidth),
|
|
22716
22291
|
"ACCOUNT"
|
|
22717
22292
|
].join(" ");
|
|
22718
|
-
console.log(
|
|
22293
|
+
console.log(chalk68.dim(header));
|
|
22719
22294
|
for (const type2 of allTypes) {
|
|
22720
22295
|
const connector = connectedMap.get(type2);
|
|
22721
22296
|
const scopeMismatch = connector !== void 0 && connector.authMethod === "oauth" && !hasRequiredScopes(type2, connector.oauthScopes);
|
|
22722
|
-
const status = connector ? connector.needsReconnect ?
|
|
22723
|
-
const account = connector?.needsReconnect ?
|
|
22297
|
+
const status = connector ? connector.needsReconnect ? chalk68.yellow("!".padEnd(statusWidth)) : scopeMismatch ? chalk68.yellow("!".padEnd(statusWidth)) : chalk68.green("\u2713".padEnd(statusWidth)) : chalk68.dim("-".padEnd(statusWidth));
|
|
22298
|
+
const account = connector?.needsReconnect ? chalk68.yellow("(reconnect needed)") : scopeMismatch ? chalk68.yellow("(permissions update available)") : connector?.externalUsername ? `@${connector.externalUsername}` : chalk68.dim("-");
|
|
22724
22299
|
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
22725
22300
|
console.log(row);
|
|
22726
22301
|
}
|
|
22727
22302
|
console.log();
|
|
22728
|
-
console.log(
|
|
22729
|
-
console.log(
|
|
22303
|
+
console.log(chalk68.dim("To connect a service:"));
|
|
22304
|
+
console.log(chalk68.dim(" vm0 zero connector connect <type>"));
|
|
22730
22305
|
})
|
|
22731
22306
|
);
|
|
22732
22307
|
|
|
22733
22308
|
// src/commands/zero/connector/status.ts
|
|
22734
|
-
import { Command as
|
|
22735
|
-
import
|
|
22736
|
-
|
|
22737
|
-
|
|
22309
|
+
import { Command as Command76 } from "commander";
|
|
22310
|
+
import chalk69 from "chalk";
|
|
22311
|
+
|
|
22312
|
+
// src/lib/domain/schedule-utils.ts
|
|
22313
|
+
function formatRelativeTime2(dateStr) {
|
|
22314
|
+
if (!dateStr) return "-";
|
|
22315
|
+
const date = new Date(dateStr);
|
|
22316
|
+
const now = /* @__PURE__ */ new Date();
|
|
22317
|
+
const diffMs = date.getTime() - now.getTime();
|
|
22318
|
+
const diffAbs = Math.abs(diffMs);
|
|
22319
|
+
const minutes = Math.floor(diffAbs / (1e3 * 60));
|
|
22320
|
+
const hours = Math.floor(diffAbs / (1e3 * 60 * 60));
|
|
22321
|
+
const days = Math.floor(diffAbs / (1e3 * 60 * 60 * 24));
|
|
22322
|
+
const isPast = diffMs < 0;
|
|
22323
|
+
if (days > 0) {
|
|
22324
|
+
return isPast ? `${days}d ago` : `in ${days}d`;
|
|
22325
|
+
} else if (hours > 0) {
|
|
22326
|
+
return isPast ? `${hours}h ago` : `in ${hours}h`;
|
|
22327
|
+
} else if (minutes > 0) {
|
|
22328
|
+
return isPast ? `${minutes}m ago` : `in ${minutes}m`;
|
|
22329
|
+
} else {
|
|
22330
|
+
return isPast ? "just now" : "soon";
|
|
22331
|
+
}
|
|
22332
|
+
}
|
|
22333
|
+
function formatDateTime(dateStr) {
|
|
22334
|
+
if (!dateStr) return "-";
|
|
22335
|
+
const date = new Date(dateStr);
|
|
22336
|
+
const year = date.getFullYear();
|
|
22337
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
22338
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
22339
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
22340
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
22341
|
+
const formatted = `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
22342
|
+
const relative2 = formatRelativeTime2(dateStr);
|
|
22343
|
+
return `${formatted} (${relative2})`;
|
|
22344
|
+
}
|
|
22345
|
+
function generateCronExpression(frequency, time, day) {
|
|
22346
|
+
const [hourStr, minuteStr] = time.split(":");
|
|
22347
|
+
const hour = parseInt(hourStr ?? "0", 10);
|
|
22348
|
+
const minute = parseInt(minuteStr ?? "0", 10);
|
|
22349
|
+
switch (frequency) {
|
|
22350
|
+
case "daily":
|
|
22351
|
+
return `${minute} ${hour} * * *`;
|
|
22352
|
+
case "weekly":
|
|
22353
|
+
return `${minute} ${hour} * * ${day ?? 1}`;
|
|
22354
|
+
case "monthly":
|
|
22355
|
+
return `${minute} ${hour} ${day ?? 1} * *`;
|
|
22356
|
+
}
|
|
22357
|
+
}
|
|
22358
|
+
function detectTimezone2() {
|
|
22359
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
22360
|
+
}
|
|
22361
|
+
function validateTimeFormat(time) {
|
|
22362
|
+
const match = time.match(/^(\d{1,2}):(\d{2})$/);
|
|
22363
|
+
if (!match) {
|
|
22364
|
+
return "Invalid format. Use HH:MM (e.g., 09:00)";
|
|
22365
|
+
}
|
|
22366
|
+
const hour = parseInt(match[1], 10);
|
|
22367
|
+
const minute = parseInt(match[2], 10);
|
|
22368
|
+
if (hour < 0 || hour > 23) {
|
|
22369
|
+
return "Hour must be 0-23";
|
|
22370
|
+
}
|
|
22371
|
+
if (minute < 0 || minute > 59) {
|
|
22372
|
+
return "Minute must be 0-59";
|
|
22373
|
+
}
|
|
22374
|
+
if (minute % 5 !== 0) {
|
|
22375
|
+
return "Minute must be a multiple of 5 (0, 5, 10, ..., 55)";
|
|
22376
|
+
}
|
|
22377
|
+
return true;
|
|
22378
|
+
}
|
|
22379
|
+
function validateDateFormat(date) {
|
|
22380
|
+
const match = date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
22381
|
+
if (!match) {
|
|
22382
|
+
return "Invalid format. Use YYYY-MM-DD (e.g., 2025-01-15)";
|
|
22383
|
+
}
|
|
22384
|
+
const year = parseInt(match[1], 10);
|
|
22385
|
+
const month = parseInt(match[2], 10);
|
|
22386
|
+
const day = parseInt(match[3], 10);
|
|
22387
|
+
if (year < 2e3 || year > 2100) {
|
|
22388
|
+
return "Year must be between 2000 and 2100";
|
|
22389
|
+
}
|
|
22390
|
+
if (month < 1 || month > 12) {
|
|
22391
|
+
return "Month must be 1-12";
|
|
22392
|
+
}
|
|
22393
|
+
if (day < 1 || day > 31) {
|
|
22394
|
+
return "Day must be 1-31";
|
|
22395
|
+
}
|
|
22396
|
+
const testDate = new Date(year, month - 1, day);
|
|
22397
|
+
if (testDate.getFullYear() !== year || testDate.getMonth() !== month - 1 || testDate.getDate() !== day) {
|
|
22398
|
+
return "Invalid date";
|
|
22399
|
+
}
|
|
22400
|
+
return true;
|
|
22401
|
+
}
|
|
22402
|
+
function getTomorrowDateLocal() {
|
|
22403
|
+
const tomorrow = /* @__PURE__ */ new Date();
|
|
22404
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
22405
|
+
const year = tomorrow.getFullYear();
|
|
22406
|
+
const month = String(tomorrow.getMonth() + 1).padStart(2, "0");
|
|
22407
|
+
const day = String(tomorrow.getDate()).padStart(2, "0");
|
|
22408
|
+
return `${year}-${month}-${day}`;
|
|
22409
|
+
}
|
|
22410
|
+
function getCurrentTimeLocal() {
|
|
22411
|
+
const now = /* @__PURE__ */ new Date();
|
|
22412
|
+
const hours = String(now.getHours()).padStart(2, "0");
|
|
22413
|
+
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
22414
|
+
return `${hours}:${minutes}`;
|
|
22415
|
+
}
|
|
22416
|
+
function toISODateTime(dateTimeStr) {
|
|
22417
|
+
if (dateTimeStr.includes("T") && dateTimeStr.endsWith("Z")) {
|
|
22418
|
+
return dateTimeStr;
|
|
22419
|
+
}
|
|
22420
|
+
const isoStr = dateTimeStr.replace(" ", "T") + ":00";
|
|
22421
|
+
const date = new Date(isoStr);
|
|
22422
|
+
return date.toISOString();
|
|
22423
|
+
}
|
|
22424
|
+
|
|
22425
|
+
// src/commands/zero/connector/status.ts
|
|
22426
|
+
var LABEL_WIDTH = 16;
|
|
22427
|
+
var statusCommand6 = new Command76().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(
|
|
22738
22428
|
withErrorHandler(async (type2) => {
|
|
22739
22429
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
22740
22430
|
if (!parseResult.success) {
|
|
@@ -22744,65 +22434,65 @@ var statusCommand7 = new Command81().name("status").description("Show detailed s
|
|
|
22744
22434
|
});
|
|
22745
22435
|
}
|
|
22746
22436
|
const connector = await getZeroConnector(parseResult.data);
|
|
22747
|
-
console.log(`Connector: ${
|
|
22437
|
+
console.log(`Connector: ${chalk69.cyan(type2)}`);
|
|
22748
22438
|
console.log();
|
|
22749
22439
|
if (connector) {
|
|
22750
22440
|
console.log(
|
|
22751
|
-
`${"Status:".padEnd(
|
|
22441
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${chalk69.green("connected")}`
|
|
22752
22442
|
);
|
|
22753
22443
|
console.log(
|
|
22754
|
-
`${"Account:".padEnd(
|
|
22444
|
+
`${"Account:".padEnd(LABEL_WIDTH)}@${connector.externalUsername}`
|
|
22755
22445
|
);
|
|
22756
22446
|
console.log(
|
|
22757
|
-
`${"Auth Method:".padEnd(
|
|
22447
|
+
`${"Auth Method:".padEnd(LABEL_WIDTH)}${connector.authMethod}`
|
|
22758
22448
|
);
|
|
22759
22449
|
if (connector.oauthScopes && connector.oauthScopes.length > 0) {
|
|
22760
22450
|
console.log(
|
|
22761
|
-
`${"OAuth Scopes:".padEnd(
|
|
22451
|
+
`${"OAuth Scopes:".padEnd(LABEL_WIDTH)}${connector.oauthScopes.join(", ")}`
|
|
22762
22452
|
);
|
|
22763
22453
|
}
|
|
22764
22454
|
if (connector.authMethod === "oauth" && !hasRequiredScopes(parseResult.data, connector.oauthScopes)) {
|
|
22765
22455
|
const diff = getScopeDiff(parseResult.data, connector.oauthScopes);
|
|
22766
22456
|
console.log(
|
|
22767
|
-
`${"Permissions:".padEnd(
|
|
22457
|
+
`${"Permissions:".padEnd(LABEL_WIDTH)}${chalk69.yellow("update available")}`
|
|
22768
22458
|
);
|
|
22769
22459
|
if (diff.addedScopes.length > 0) {
|
|
22770
22460
|
console.log(
|
|
22771
|
-
`${" Added:".padEnd(
|
|
22461
|
+
`${" Added:".padEnd(LABEL_WIDTH)}${diff.addedScopes.join(", ")}`
|
|
22772
22462
|
);
|
|
22773
22463
|
}
|
|
22774
22464
|
if (diff.removedScopes.length > 0) {
|
|
22775
22465
|
console.log(
|
|
22776
|
-
`${" Removed:".padEnd(
|
|
22466
|
+
`${" Removed:".padEnd(LABEL_WIDTH)}${diff.removedScopes.join(", ")}`
|
|
22777
22467
|
);
|
|
22778
22468
|
}
|
|
22779
22469
|
}
|
|
22780
22470
|
console.log(
|
|
22781
|
-
`${"Connected:".padEnd(
|
|
22471
|
+
`${"Connected:".padEnd(LABEL_WIDTH)}${formatDateTime(connector.createdAt)}`
|
|
22782
22472
|
);
|
|
22783
22473
|
if (connector.updatedAt !== connector.createdAt) {
|
|
22784
22474
|
console.log(
|
|
22785
|
-
`${"Last Updated:".padEnd(
|
|
22475
|
+
`${"Last Updated:".padEnd(LABEL_WIDTH)}${formatDateTime(connector.updatedAt)}`
|
|
22786
22476
|
);
|
|
22787
22477
|
}
|
|
22788
22478
|
console.log();
|
|
22789
|
-
console.log(
|
|
22790
|
-
console.log(
|
|
22479
|
+
console.log(chalk69.dim("To disconnect:"));
|
|
22480
|
+
console.log(chalk69.dim(` vm0 zero connector disconnect ${type2}`));
|
|
22791
22481
|
} else {
|
|
22792
22482
|
console.log(
|
|
22793
|
-
`${"Status:".padEnd(
|
|
22483
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${chalk69.dim("not connected")}`
|
|
22794
22484
|
);
|
|
22795
22485
|
console.log();
|
|
22796
|
-
console.log(
|
|
22797
|
-
console.log(
|
|
22486
|
+
console.log(chalk69.dim("To connect:"));
|
|
22487
|
+
console.log(chalk69.dim(` vm0 zero connector connect ${type2}`));
|
|
22798
22488
|
}
|
|
22799
22489
|
})
|
|
22800
22490
|
);
|
|
22801
22491
|
|
|
22802
22492
|
// src/commands/zero/connector/disconnect.ts
|
|
22803
|
-
import { Command as
|
|
22804
|
-
import
|
|
22805
|
-
var
|
|
22493
|
+
import { Command as Command77 } from "commander";
|
|
22494
|
+
import chalk70 from "chalk";
|
|
22495
|
+
var disconnectCommand = new Command77().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(
|
|
22806
22496
|
withErrorHandler(async (type2) => {
|
|
22807
22497
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
22808
22498
|
if (!parseResult.success) {
|
|
@@ -22813,19 +22503,19 @@ var disconnectCommand2 = new Command82().name("disconnect").description("Disconn
|
|
|
22813
22503
|
}
|
|
22814
22504
|
const connectorType = parseResult.data;
|
|
22815
22505
|
await deleteZeroConnector(connectorType);
|
|
22816
|
-
console.log(
|
|
22506
|
+
console.log(chalk70.green(`\u2713 Disconnected ${type2}`));
|
|
22817
22507
|
})
|
|
22818
22508
|
);
|
|
22819
22509
|
|
|
22820
22510
|
// src/commands/zero/connector/index.ts
|
|
22821
|
-
var zeroConnectorCommand = new
|
|
22511
|
+
var zeroConnectorCommand = new Command78().name("connector").description("Manage third-party service connections (zero)").addCommand(listCommand10).addCommand(statusCommand6).addCommand(connectCommand).addCommand(disconnectCommand);
|
|
22822
22512
|
|
|
22823
22513
|
// src/commands/zero/schedule/index.ts
|
|
22824
|
-
import { Command as
|
|
22514
|
+
import { Command as Command85 } from "commander";
|
|
22825
22515
|
|
|
22826
22516
|
// src/commands/zero/schedule/setup.ts
|
|
22827
|
-
import { Command as
|
|
22828
|
-
import
|
|
22517
|
+
import { Command as Command79 } from "commander";
|
|
22518
|
+
import chalk71 from "chalk";
|
|
22829
22519
|
var FREQUENCY_CHOICES = [
|
|
22830
22520
|
{ title: "Daily", value: "daily", description: "Run every day" },
|
|
22831
22521
|
{
|
|
@@ -23035,10 +22725,10 @@ async function gatherTimezone(optionTimezone, existingTimezone) {
|
|
|
23035
22725
|
userTimezone = prefs.timezone;
|
|
23036
22726
|
} catch {
|
|
23037
22727
|
console.log(
|
|
23038
|
-
|
|
22728
|
+
chalk71.dim("Could not fetch timezone preference, using detected timezone")
|
|
23039
22729
|
);
|
|
23040
22730
|
}
|
|
23041
|
-
const defaultTimezone = userTimezone ||
|
|
22731
|
+
const defaultTimezone = userTimezone || detectTimezone2();
|
|
23042
22732
|
if (!isInteractive()) {
|
|
23043
22733
|
return defaultTimezone;
|
|
23044
22734
|
}
|
|
@@ -23160,11 +22850,11 @@ async function buildAndDeploy(params) {
|
|
|
23160
22850
|
}
|
|
23161
22851
|
console.log(
|
|
23162
22852
|
`
|
|
23163
|
-
Deploying schedule for agent ${
|
|
22853
|
+
Deploying schedule for agent ${chalk71.cyan(params.agentName)}...`
|
|
23164
22854
|
);
|
|
23165
22855
|
const deployResult = await deployZeroSchedule({
|
|
23166
22856
|
name: params.scheduleName,
|
|
23167
|
-
|
|
22857
|
+
agentId: params.agentId,
|
|
23168
22858
|
cronExpression,
|
|
23169
22859
|
atTime: atTimeISO,
|
|
23170
22860
|
intervalSeconds: params.intervalSeconds,
|
|
@@ -23183,81 +22873,75 @@ Deploying schedule for agent ${chalk75.cyan(params.agentName)}...`
|
|
|
23183
22873
|
function displayDeployResult(agentName, deployResult) {
|
|
23184
22874
|
if (deployResult.created) {
|
|
23185
22875
|
console.log(
|
|
23186
|
-
|
|
22876
|
+
chalk71.green(`\u2713 Created schedule for agent ${chalk71.cyan(agentName)}`)
|
|
23187
22877
|
);
|
|
23188
22878
|
} else {
|
|
23189
22879
|
console.log(
|
|
23190
|
-
|
|
22880
|
+
chalk71.green(`\u2713 Updated schedule for agent ${chalk71.cyan(agentName)}`)
|
|
23191
22881
|
);
|
|
23192
22882
|
}
|
|
23193
|
-
console.log(
|
|
22883
|
+
console.log(chalk71.dim(` Timezone: ${deployResult.schedule.timezone}`));
|
|
23194
22884
|
if (deployResult.schedule.triggerType === "loop" && deployResult.schedule.intervalSeconds != null) {
|
|
23195
22885
|
console.log(
|
|
23196
|
-
|
|
22886
|
+
chalk71.dim(
|
|
23197
22887
|
` Mode: Loop (interval ${deployResult.schedule.intervalSeconds}s)`
|
|
23198
22888
|
)
|
|
23199
22889
|
);
|
|
23200
22890
|
} else if (deployResult.schedule.cronExpression) {
|
|
23201
|
-
console.log(
|
|
22891
|
+
console.log(chalk71.dim(` Cron: ${deployResult.schedule.cronExpression}`));
|
|
23202
22892
|
if (deployResult.schedule.nextRunAt) {
|
|
23203
22893
|
const nextRun = formatInTimezone(
|
|
23204
22894
|
deployResult.schedule.nextRunAt,
|
|
23205
22895
|
deployResult.schedule.timezone
|
|
23206
22896
|
);
|
|
23207
|
-
console.log(
|
|
22897
|
+
console.log(chalk71.dim(` Next run: ${nextRun}`));
|
|
23208
22898
|
}
|
|
23209
22899
|
} else if (deployResult.schedule.atTime) {
|
|
23210
22900
|
const atTimeFormatted = formatInTimezone(
|
|
23211
22901
|
deployResult.schedule.atTime,
|
|
23212
22902
|
deployResult.schedule.timezone
|
|
23213
22903
|
);
|
|
23214
|
-
console.log(
|
|
22904
|
+
console.log(chalk71.dim(` At: ${atTimeFormatted}`));
|
|
23215
22905
|
}
|
|
23216
22906
|
}
|
|
23217
|
-
async function tryEnableSchedule(scheduleName,
|
|
22907
|
+
async function tryEnableSchedule(scheduleName, agentId, agentName) {
|
|
23218
22908
|
try {
|
|
23219
|
-
await enableZeroSchedule({ name: scheduleName,
|
|
22909
|
+
await enableZeroSchedule({ name: scheduleName, agentId });
|
|
23220
22910
|
console.log(
|
|
23221
|
-
|
|
22911
|
+
chalk71.green(`\u2713 Enabled schedule for agent ${chalk71.cyan(agentName)}`)
|
|
23222
22912
|
);
|
|
23223
22913
|
} catch (error) {
|
|
23224
|
-
console.error(
|
|
22914
|
+
console.error(chalk71.yellow("\u26A0 Failed to enable schedule"));
|
|
23225
22915
|
if (error instanceof ApiRequestError) {
|
|
23226
22916
|
if (error.code === "SCHEDULE_PAST") {
|
|
23227
|
-
console.error(
|
|
22917
|
+
console.error(chalk71.dim(" Scheduled time has already passed"));
|
|
23228
22918
|
} else {
|
|
23229
|
-
console.error(
|
|
22919
|
+
console.error(chalk71.dim(` ${error.message}`));
|
|
23230
22920
|
}
|
|
23231
22921
|
} else if (error instanceof Error) {
|
|
23232
|
-
console.error(
|
|
22922
|
+
console.error(chalk71.dim(` ${error.message}`));
|
|
23233
22923
|
}
|
|
23234
22924
|
console.log(
|
|
23235
|
-
` To enable manually: ${
|
|
22925
|
+
` To enable manually: ${chalk71.cyan(`vm0 zero schedule enable ${agentName}`)}`
|
|
23236
22926
|
);
|
|
23237
22927
|
}
|
|
23238
22928
|
}
|
|
23239
22929
|
function showEnableHint(agentName) {
|
|
23240
22930
|
console.log();
|
|
23241
22931
|
console.log(
|
|
23242
|
-
` To enable: ${
|
|
22932
|
+
` To enable: ${chalk71.cyan(`vm0 zero schedule enable ${agentName}`)}`
|
|
23243
22933
|
);
|
|
23244
22934
|
}
|
|
23245
22935
|
async function handleScheduleEnabling(params) {
|
|
23246
|
-
const {
|
|
23247
|
-
scheduleName,
|
|
23248
|
-
zeroAgentId,
|
|
23249
|
-
agentName,
|
|
23250
|
-
enableFlag,
|
|
23251
|
-
shouldPromptEnable
|
|
23252
|
-
} = params;
|
|
22936
|
+
const { scheduleName, agentId, agentName, enableFlag, shouldPromptEnable } = params;
|
|
23253
22937
|
if (enableFlag) {
|
|
23254
|
-
await tryEnableSchedule(scheduleName,
|
|
22938
|
+
await tryEnableSchedule(scheduleName, agentId, agentName);
|
|
23255
22939
|
return;
|
|
23256
22940
|
}
|
|
23257
22941
|
if (shouldPromptEnable && isInteractive()) {
|
|
23258
22942
|
const enableNow = await promptConfirm("Enable this schedule?", true);
|
|
23259
22943
|
if (enableNow) {
|
|
23260
|
-
await tryEnableSchedule(scheduleName,
|
|
22944
|
+
await tryEnableSchedule(scheduleName, agentId, agentName);
|
|
23261
22945
|
} else {
|
|
23262
22946
|
showEnableHint(agentName);
|
|
23263
22947
|
}
|
|
@@ -23267,17 +22951,17 @@ async function handleScheduleEnabling(params) {
|
|
|
23267
22951
|
showEnableHint(agentName);
|
|
23268
22952
|
}
|
|
23269
22953
|
}
|
|
23270
|
-
var setupCommand2 = new
|
|
22954
|
+
var setupCommand2 = new Command79().name("setup").description("Create or edit a schedule for a zero agent").argument("<agent-name>", "Agent name to configure schedule for").option("-n, --name <schedule-name>", 'Schedule name (default: "default")').option("-f, --frequency <type>", "Frequency: daily|weekly|monthly|once|loop").option("-t, --time <HH:MM>", "Time to run (24-hour format)").option("-d, --day <day>", "Day of week (mon-sun) or day of month (1-31)").option("-i, --interval <seconds>", "Interval in seconds for loop mode").option("-z, --timezone <tz>", "IANA timezone").option("-p, --prompt <text>", "Prompt to run").option("--artifact-name <name>", "Artifact name", "artifact").option("-e, --enable", "Enable schedule immediately after creation").option("--notify-email", "Enable email notifications (default: true)").option("--no-notify-email", "Disable email notifications").option("--notify-slack", "Enable Slack notifications (default: true)").option("--no-notify-slack", "Disable Slack notifications").action(
|
|
23271
22955
|
withErrorHandler(async (agentName, options) => {
|
|
23272
22956
|
const agent = await getZeroAgent(agentName);
|
|
23273
|
-
const
|
|
22957
|
+
const agentId = agent.agentComposeId;
|
|
23274
22958
|
const scheduleName = options.name || "default";
|
|
23275
22959
|
const existingSchedule = await findExistingSchedule(
|
|
23276
22960
|
agentName,
|
|
23277
22961
|
scheduleName
|
|
23278
22962
|
);
|
|
23279
22963
|
console.log(
|
|
23280
|
-
|
|
22964
|
+
chalk71.dim(
|
|
23281
22965
|
existingSchedule ? `Editing existing schedule for agent ${agentName}` : `Creating new schedule for agent ${agentName}`
|
|
23282
22966
|
)
|
|
23283
22967
|
);
|
|
@@ -23287,12 +22971,12 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23287
22971
|
defaults.frequency
|
|
23288
22972
|
);
|
|
23289
22973
|
if (!frequency) {
|
|
23290
|
-
console.log(
|
|
22974
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23291
22975
|
return;
|
|
23292
22976
|
}
|
|
23293
22977
|
const timing = await gatherTiming(frequency, options, defaults);
|
|
23294
22978
|
if (!timing) {
|
|
23295
|
-
console.log(
|
|
22979
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23296
22980
|
return;
|
|
23297
22981
|
}
|
|
23298
22982
|
const { day, time, atTime, intervalSeconds } = timing;
|
|
@@ -23301,7 +22985,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23301
22985
|
existingSchedule?.timezone
|
|
23302
22986
|
);
|
|
23303
22987
|
if (!timezone) {
|
|
23304
|
-
console.log(
|
|
22988
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23305
22989
|
return;
|
|
23306
22990
|
}
|
|
23307
22991
|
const promptText_ = await gatherPromptText(
|
|
@@ -23309,7 +22993,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23309
22993
|
existingSchedule?.prompt
|
|
23310
22994
|
);
|
|
23311
22995
|
if (!promptText_) {
|
|
23312
|
-
console.log(
|
|
22996
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23313
22997
|
return;
|
|
23314
22998
|
}
|
|
23315
22999
|
const { notifyEmail, notifySlack } = await gatherNotificationPreferences(
|
|
@@ -23319,7 +23003,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23319
23003
|
);
|
|
23320
23004
|
const deployResult = await buildAndDeploy({
|
|
23321
23005
|
scheduleName,
|
|
23322
|
-
|
|
23006
|
+
agentId,
|
|
23323
23007
|
agentName,
|
|
23324
23008
|
frequency,
|
|
23325
23009
|
time,
|
|
@@ -23336,7 +23020,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23336
23020
|
const shouldPromptEnable = deployResult.created || existingSchedule !== void 0 && !existingSchedule.enabled;
|
|
23337
23021
|
await handleScheduleEnabling({
|
|
23338
23022
|
scheduleName,
|
|
23339
|
-
|
|
23023
|
+
agentId,
|
|
23340
23024
|
agentName,
|
|
23341
23025
|
enableFlag: options.enable ?? false,
|
|
23342
23026
|
shouldPromptEnable
|
|
@@ -23345,15 +23029,15 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23345
23029
|
);
|
|
23346
23030
|
|
|
23347
23031
|
// src/commands/zero/schedule/list.ts
|
|
23348
|
-
import { Command as
|
|
23349
|
-
import
|
|
23350
|
-
var
|
|
23032
|
+
import { Command as Command80 } from "commander";
|
|
23033
|
+
import chalk72 from "chalk";
|
|
23034
|
+
var listCommand11 = new Command80().name("list").alias("ls").description("List all zero schedules").action(
|
|
23351
23035
|
withErrorHandler(async () => {
|
|
23352
23036
|
const result = await listZeroSchedules();
|
|
23353
23037
|
if (result.schedules.length === 0) {
|
|
23354
|
-
console.log(
|
|
23038
|
+
console.log(chalk72.dim("No schedules found"));
|
|
23355
23039
|
console.log(
|
|
23356
|
-
|
|
23040
|
+
chalk72.dim(" Create one with: vm0 zero schedule setup <agent-name>")
|
|
23357
23041
|
);
|
|
23358
23042
|
return;
|
|
23359
23043
|
}
|
|
@@ -23378,10 +23062,10 @@ var listCommand12 = new Command85().name("list").alias("ls").description("List a
|
|
|
23378
23062
|
"STATUS".padEnd(8),
|
|
23379
23063
|
"NEXT RUN"
|
|
23380
23064
|
].join(" ");
|
|
23381
|
-
console.log(
|
|
23065
|
+
console.log(chalk72.dim(header));
|
|
23382
23066
|
for (const schedule of result.schedules) {
|
|
23383
23067
|
const trigger = schedule.cronExpression ? `${schedule.cronExpression} (${schedule.timezone})` : schedule.atTime || "-";
|
|
23384
|
-
const status = schedule.enabled ?
|
|
23068
|
+
const status = schedule.enabled ? chalk72.green("enabled") : chalk72.yellow("disabled");
|
|
23385
23069
|
const nextRun = schedule.enabled ? formatRelativeTime2(schedule.nextRunAt) : "-";
|
|
23386
23070
|
const row = [
|
|
23387
23071
|
schedule.agentName.padEnd(agentWidth),
|
|
@@ -23396,33 +23080,33 @@ var listCommand12 = new Command85().name("list").alias("ls").description("List a
|
|
|
23396
23080
|
);
|
|
23397
23081
|
|
|
23398
23082
|
// src/commands/zero/schedule/status.ts
|
|
23399
|
-
import { Command as
|
|
23400
|
-
import
|
|
23083
|
+
import { Command as Command81 } from "commander";
|
|
23084
|
+
import chalk73 from "chalk";
|
|
23401
23085
|
function formatDateTimeStyled(dateStr) {
|
|
23402
|
-
if (!dateStr) return
|
|
23086
|
+
if (!dateStr) return chalk73.dim("-");
|
|
23403
23087
|
const formatted = formatDateTime(dateStr);
|
|
23404
|
-
return formatted.replace(/\(([^)]+)\)$/,
|
|
23088
|
+
return formatted.replace(/\(([^)]+)\)$/, chalk73.dim("($1)"));
|
|
23405
23089
|
}
|
|
23406
23090
|
function formatTrigger(schedule) {
|
|
23407
23091
|
if (schedule.triggerType === "loop" && schedule.intervalSeconds !== null) {
|
|
23408
|
-
return `interval ${schedule.intervalSeconds}s ${
|
|
23092
|
+
return `interval ${schedule.intervalSeconds}s ${chalk73.dim("(loop)")}`;
|
|
23409
23093
|
}
|
|
23410
23094
|
if (schedule.cronExpression) {
|
|
23411
23095
|
return schedule.cronExpression;
|
|
23412
23096
|
}
|
|
23413
23097
|
if (schedule.atTime) {
|
|
23414
|
-
return `${schedule.atTime} ${
|
|
23098
|
+
return `${schedule.atTime} ${chalk73.dim("(one-time)")}`;
|
|
23415
23099
|
}
|
|
23416
|
-
return
|
|
23100
|
+
return chalk73.dim("-");
|
|
23417
23101
|
}
|
|
23418
23102
|
function printRunConfiguration(schedule) {
|
|
23419
|
-
const statusText = schedule.enabled ?
|
|
23103
|
+
const statusText = schedule.enabled ? chalk73.green("enabled") : chalk73.yellow("disabled");
|
|
23420
23104
|
console.log(`${"Status:".padEnd(16)}${statusText}`);
|
|
23421
23105
|
console.log(
|
|
23422
|
-
`${"Agent:".padEnd(16)}${schedule.agentName} ${
|
|
23106
|
+
`${"Agent:".padEnd(16)}${schedule.agentName} ${chalk73.dim(`(${schedule.orgSlug})`)}`
|
|
23423
23107
|
);
|
|
23424
23108
|
const promptPreview = schedule.prompt.length > 60 ? schedule.prompt.slice(0, 57) + "..." : schedule.prompt;
|
|
23425
|
-
console.log(`${"Prompt:".padEnd(16)}${
|
|
23109
|
+
console.log(`${"Prompt:".padEnd(16)}${chalk73.dim(promptPreview)}`);
|
|
23426
23110
|
if (schedule.vars && Object.keys(schedule.vars).length > 0) {
|
|
23427
23111
|
console.log(
|
|
23428
23112
|
`${"Variables:".padEnd(16)}${Object.keys(schedule.vars).join(", ")}`
|
|
@@ -23444,18 +23128,18 @@ function printRunConfiguration(schedule) {
|
|
|
23444
23128
|
function printTimeSchedule(schedule) {
|
|
23445
23129
|
console.log();
|
|
23446
23130
|
console.log(`${"Trigger:".padEnd(16)}${formatTrigger(schedule)}`);
|
|
23447
|
-
console.log(`${"Timezone:".padEnd(16)}${
|
|
23131
|
+
console.log(`${"Timezone:".padEnd(16)}${detectTimezone2()}`);
|
|
23448
23132
|
if (schedule.enabled) {
|
|
23449
23133
|
console.log(
|
|
23450
23134
|
`${"Next Run:".padEnd(16)}${formatDateTimeStyled(schedule.nextRunAt)}`
|
|
23451
23135
|
);
|
|
23452
23136
|
}
|
|
23453
23137
|
if (schedule.triggerType === "loop") {
|
|
23454
|
-
const failureText = schedule.consecutiveFailures > 0 ?
|
|
23138
|
+
const failureText = schedule.consecutiveFailures > 0 ? chalk73.yellow(`${schedule.consecutiveFailures}/3`) : chalk73.dim("0/3");
|
|
23455
23139
|
console.log(`${"Failures:".padEnd(16)}${failureText}`);
|
|
23456
23140
|
}
|
|
23457
23141
|
}
|
|
23458
|
-
var
|
|
23142
|
+
var statusCommand7 = new Command81().name("status").description("Show detailed status of a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23459
23143
|
"-n, --name <schedule-name>",
|
|
23460
23144
|
"Schedule name (required when agent has multiple schedules)"
|
|
23461
23145
|
).action(
|
|
@@ -23465,8 +23149,8 @@ var statusCommand8 = new Command86().name("status").description("Show detailed s
|
|
|
23465
23149
|
options.name
|
|
23466
23150
|
);
|
|
23467
23151
|
console.log();
|
|
23468
|
-
console.log(`Schedule for agent: ${
|
|
23469
|
-
console.log(
|
|
23152
|
+
console.log(`Schedule for agent: ${chalk73.cyan(agentName)}`);
|
|
23153
|
+
console.log(chalk73.dim("\u2501".repeat(50)));
|
|
23470
23154
|
printRunConfiguration(schedule);
|
|
23471
23155
|
printTimeSchedule(schedule);
|
|
23472
23156
|
console.log();
|
|
@@ -23474,9 +23158,9 @@ var statusCommand8 = new Command86().name("status").description("Show detailed s
|
|
|
23474
23158
|
);
|
|
23475
23159
|
|
|
23476
23160
|
// src/commands/zero/schedule/delete.ts
|
|
23477
|
-
import { Command as
|
|
23478
|
-
import
|
|
23479
|
-
var deleteCommand3 = new
|
|
23161
|
+
import { Command as Command82 } from "commander";
|
|
23162
|
+
import chalk74 from "chalk";
|
|
23163
|
+
var deleteCommand3 = new Command82().name("delete").alias("rm").description("Delete a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23480
23164
|
"-n, --name <schedule-name>",
|
|
23481
23165
|
"Schedule name (required when agent has multiple schedules)"
|
|
23482
23166
|
).option("-y, --yes", "Skip confirmation prompt").action(
|
|
@@ -23491,29 +23175,29 @@ var deleteCommand3 = new Command87().name("delete").alias("rm").description("Del
|
|
|
23491
23175
|
throw new Error("--yes flag is required in non-interactive mode");
|
|
23492
23176
|
}
|
|
23493
23177
|
const confirmed = await promptConfirm(
|
|
23494
|
-
`Delete schedule for agent ${
|
|
23178
|
+
`Delete schedule for agent ${chalk74.cyan(agentName)}?`,
|
|
23495
23179
|
false
|
|
23496
23180
|
);
|
|
23497
23181
|
if (!confirmed) {
|
|
23498
|
-
console.log(
|
|
23182
|
+
console.log(chalk74.dim("Cancelled"));
|
|
23499
23183
|
return;
|
|
23500
23184
|
}
|
|
23501
23185
|
}
|
|
23502
23186
|
await deleteZeroSchedule({
|
|
23503
23187
|
name: resolved.name,
|
|
23504
|
-
|
|
23188
|
+
agentId: resolved.agentId
|
|
23505
23189
|
});
|
|
23506
23190
|
console.log(
|
|
23507
|
-
|
|
23191
|
+
chalk74.green(`\u2713 Deleted schedule for agent ${chalk74.cyan(agentName)}`)
|
|
23508
23192
|
);
|
|
23509
23193
|
}
|
|
23510
23194
|
)
|
|
23511
23195
|
);
|
|
23512
23196
|
|
|
23513
23197
|
// src/commands/zero/schedule/enable.ts
|
|
23514
|
-
import { Command as
|
|
23515
|
-
import
|
|
23516
|
-
var enableCommand = new
|
|
23198
|
+
import { Command as Command83 } from "commander";
|
|
23199
|
+
import chalk75 from "chalk";
|
|
23200
|
+
var enableCommand = new Command83().name("enable").description("Enable a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23517
23201
|
"-n, --name <schedule-name>",
|
|
23518
23202
|
"Schedule name (required when agent has multiple schedules)"
|
|
23519
23203
|
).action(
|
|
@@ -23524,18 +23208,18 @@ var enableCommand = new Command88().name("enable").description("Enable a zero sc
|
|
|
23524
23208
|
);
|
|
23525
23209
|
await enableZeroSchedule({
|
|
23526
23210
|
name: resolved.name,
|
|
23527
|
-
|
|
23211
|
+
agentId: resolved.agentId
|
|
23528
23212
|
});
|
|
23529
23213
|
console.log(
|
|
23530
|
-
|
|
23214
|
+
chalk75.green(`\u2713 Enabled schedule for agent ${chalk75.cyan(agentName)}`)
|
|
23531
23215
|
);
|
|
23532
23216
|
})
|
|
23533
23217
|
);
|
|
23534
23218
|
|
|
23535
23219
|
// src/commands/zero/schedule/disable.ts
|
|
23536
|
-
import { Command as
|
|
23537
|
-
import
|
|
23538
|
-
var disableCommand = new
|
|
23220
|
+
import { Command as Command84 } from "commander";
|
|
23221
|
+
import chalk76 from "chalk";
|
|
23222
|
+
var disableCommand = new Command84().name("disable").description("Disable a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23539
23223
|
"-n, --name <schedule-name>",
|
|
23540
23224
|
"Schedule name (required when agent has multiple schedules)"
|
|
23541
23225
|
).action(
|
|
@@ -23546,81 +23230,81 @@ var disableCommand = new Command89().name("disable").description("Disable a zero
|
|
|
23546
23230
|
);
|
|
23547
23231
|
await disableZeroSchedule({
|
|
23548
23232
|
name: resolved.name,
|
|
23549
|
-
|
|
23233
|
+
agentId: resolved.agentId
|
|
23550
23234
|
});
|
|
23551
23235
|
console.log(
|
|
23552
|
-
|
|
23236
|
+
chalk76.green(`\u2713 Disabled schedule for agent ${chalk76.cyan(agentName)}`)
|
|
23553
23237
|
);
|
|
23554
23238
|
})
|
|
23555
23239
|
);
|
|
23556
23240
|
|
|
23557
23241
|
// src/commands/zero/schedule/index.ts
|
|
23558
|
-
var zeroScheduleCommand = new
|
|
23242
|
+
var zeroScheduleCommand = new Command85().name("schedule").description("Manage zero agent schedules").addCommand(setupCommand2).addCommand(listCommand11).addCommand(statusCommand7).addCommand(deleteCommand3).addCommand(enableCommand).addCommand(disableCommand);
|
|
23559
23243
|
|
|
23560
23244
|
// src/commands/zero/secret/index.ts
|
|
23561
|
-
import { Command as
|
|
23245
|
+
import { Command as Command89 } from "commander";
|
|
23562
23246
|
|
|
23563
23247
|
// src/commands/zero/secret/list.ts
|
|
23564
|
-
import { Command as
|
|
23565
|
-
import
|
|
23566
|
-
var
|
|
23248
|
+
import { Command as Command86 } from "commander";
|
|
23249
|
+
import chalk77 from "chalk";
|
|
23250
|
+
var listCommand12 = new Command86().name("list").alias("ls").description("List all secrets").action(
|
|
23567
23251
|
withErrorHandler(async () => {
|
|
23568
23252
|
const result = await listZeroSecrets();
|
|
23569
23253
|
if (result.secrets.length === 0) {
|
|
23570
|
-
console.log(
|
|
23254
|
+
console.log(chalk77.dim("No secrets found"));
|
|
23571
23255
|
console.log();
|
|
23572
23256
|
console.log("To add a secret:");
|
|
23573
23257
|
console.log(
|
|
23574
|
-
|
|
23258
|
+
chalk77.cyan(" vm0 zero secret set MY_API_KEY --body <value>")
|
|
23575
23259
|
);
|
|
23576
23260
|
return;
|
|
23577
23261
|
}
|
|
23578
|
-
console.log(
|
|
23262
|
+
console.log(chalk77.bold("Secrets:"));
|
|
23579
23263
|
console.log();
|
|
23580
23264
|
for (const secret of result.secrets) {
|
|
23581
23265
|
let typeIndicator = "";
|
|
23582
23266
|
let derivedLine = null;
|
|
23583
23267
|
if (secret.type === "model-provider") {
|
|
23584
|
-
typeIndicator =
|
|
23268
|
+
typeIndicator = chalk77.dim(" [model-provider]");
|
|
23585
23269
|
} else if (secret.type === "connector") {
|
|
23586
23270
|
const derived = getConnectorDerivedNames(secret.name);
|
|
23587
23271
|
if (derived) {
|
|
23588
|
-
typeIndicator =
|
|
23589
|
-
derivedLine =
|
|
23272
|
+
typeIndicator = chalk77.dim(` [${derived.connectorLabel} connector]`);
|
|
23273
|
+
derivedLine = chalk77.dim(
|
|
23590
23274
|
`Available as: ${derived.envVarNames.join(", ")}`
|
|
23591
23275
|
);
|
|
23592
23276
|
} else {
|
|
23593
|
-
typeIndicator =
|
|
23277
|
+
typeIndicator = chalk77.dim(" [connector]");
|
|
23594
23278
|
}
|
|
23595
23279
|
} else if (secret.type === "user") {
|
|
23596
23280
|
const derived = getConnectorDerivedNames(secret.name);
|
|
23597
23281
|
if (derived) {
|
|
23598
|
-
typeIndicator =
|
|
23599
|
-
derivedLine =
|
|
23282
|
+
typeIndicator = chalk77.dim(` [${derived.connectorLabel} connector]`);
|
|
23283
|
+
derivedLine = chalk77.dim(
|
|
23600
23284
|
`Available as: ${derived.envVarNames.join(", ")}`
|
|
23601
23285
|
);
|
|
23602
23286
|
}
|
|
23603
23287
|
}
|
|
23604
|
-
console.log(` ${
|
|
23288
|
+
console.log(` ${chalk77.cyan(secret.name)}${typeIndicator}`);
|
|
23605
23289
|
if (derivedLine) {
|
|
23606
23290
|
console.log(` ${derivedLine}`);
|
|
23607
23291
|
}
|
|
23608
23292
|
if (secret.description) {
|
|
23609
|
-
console.log(` ${
|
|
23293
|
+
console.log(` ${chalk77.dim(secret.description)}`);
|
|
23610
23294
|
}
|
|
23611
23295
|
console.log(
|
|
23612
|
-
` ${
|
|
23296
|
+
` ${chalk77.dim(`Updated: ${new Date(secret.updatedAt).toLocaleString()}`)}`
|
|
23613
23297
|
);
|
|
23614
23298
|
console.log();
|
|
23615
23299
|
}
|
|
23616
|
-
console.log(
|
|
23300
|
+
console.log(chalk77.dim(`Total: ${result.secrets.length} secret(s)`));
|
|
23617
23301
|
})
|
|
23618
23302
|
);
|
|
23619
23303
|
|
|
23620
23304
|
// src/commands/zero/secret/set.ts
|
|
23621
|
-
import { Command as
|
|
23622
|
-
import
|
|
23623
|
-
var setCommand4 = new
|
|
23305
|
+
import { Command as Command87 } from "commander";
|
|
23306
|
+
import chalk78 from "chalk";
|
|
23307
|
+
var setCommand4 = new Command87().name("set").description("Create or update a secret").argument("<name>", "Secret name (uppercase, e.g., MY_API_KEY)").option(
|
|
23624
23308
|
"-b, --body <value>",
|
|
23625
23309
|
"Secret value (required in non-interactive mode)"
|
|
23626
23310
|
).option("-d, --description <description>", "Optional description").action(
|
|
@@ -23659,19 +23343,19 @@ var setCommand4 = new Command92().name("set").description("Create or update a se
|
|
|
23659
23343
|
}
|
|
23660
23344
|
throw error;
|
|
23661
23345
|
}
|
|
23662
|
-
console.log(
|
|
23346
|
+
console.log(chalk78.green(`\u2713 Secret "${secret.name}" saved`));
|
|
23663
23347
|
console.log();
|
|
23664
23348
|
console.log("Use in vm0.yaml:");
|
|
23665
|
-
console.log(
|
|
23666
|
-
console.log(
|
|
23349
|
+
console.log(chalk78.cyan(` environment:`));
|
|
23350
|
+
console.log(chalk78.cyan(` ${name}: \${{ secrets.${name} }}`));
|
|
23667
23351
|
}
|
|
23668
23352
|
)
|
|
23669
23353
|
);
|
|
23670
23354
|
|
|
23671
23355
|
// src/commands/zero/secret/delete.ts
|
|
23672
|
-
import { Command as
|
|
23673
|
-
import
|
|
23674
|
-
var deleteCommand4 = new
|
|
23356
|
+
import { Command as Command88 } from "commander";
|
|
23357
|
+
import chalk79 from "chalk";
|
|
23358
|
+
var deleteCommand4 = new Command88().name("delete").description("Delete a secret").argument("<name>", "Secret name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
23675
23359
|
withErrorHandler(async (name, options) => {
|
|
23676
23360
|
if (!options.yes) {
|
|
23677
23361
|
if (!isInteractive()) {
|
|
@@ -23682,61 +23366,61 @@ var deleteCommand4 = new Command93().name("delete").description("Delete a secret
|
|
|
23682
23366
|
false
|
|
23683
23367
|
);
|
|
23684
23368
|
if (!confirmed) {
|
|
23685
|
-
console.log(
|
|
23369
|
+
console.log(chalk79.dim("Cancelled"));
|
|
23686
23370
|
return;
|
|
23687
23371
|
}
|
|
23688
23372
|
}
|
|
23689
23373
|
await deleteZeroSecret(name);
|
|
23690
|
-
console.log(
|
|
23374
|
+
console.log(chalk79.green(`\u2713 Secret "${name}" deleted`));
|
|
23691
23375
|
})
|
|
23692
23376
|
);
|
|
23693
23377
|
|
|
23694
23378
|
// src/commands/zero/secret/index.ts
|
|
23695
|
-
var zeroSecretCommand = new
|
|
23379
|
+
var zeroSecretCommand = new Command89().name("secret").description("Manage secrets").addCommand(listCommand12).addCommand(setCommand4).addCommand(deleteCommand4);
|
|
23696
23380
|
|
|
23697
23381
|
// src/commands/zero/variable/index.ts
|
|
23698
|
-
import { Command as
|
|
23382
|
+
import { Command as Command93 } from "commander";
|
|
23699
23383
|
|
|
23700
23384
|
// src/commands/zero/variable/list.ts
|
|
23701
|
-
import { Command as
|
|
23702
|
-
import
|
|
23385
|
+
import { Command as Command90 } from "commander";
|
|
23386
|
+
import chalk80 from "chalk";
|
|
23703
23387
|
function truncateValue2(value, maxLength = 60) {
|
|
23704
23388
|
if (value.length <= maxLength) {
|
|
23705
23389
|
return value;
|
|
23706
23390
|
}
|
|
23707
23391
|
return value.slice(0, maxLength - 15) + "... [truncated]";
|
|
23708
23392
|
}
|
|
23709
|
-
var
|
|
23393
|
+
var listCommand13 = new Command90().name("list").alias("ls").description("List all variables").action(
|
|
23710
23394
|
withErrorHandler(async () => {
|
|
23711
23395
|
const result = await listZeroVariables();
|
|
23712
23396
|
if (result.variables.length === 0) {
|
|
23713
|
-
console.log(
|
|
23397
|
+
console.log(chalk80.dim("No variables found"));
|
|
23714
23398
|
console.log();
|
|
23715
23399
|
console.log("To add a variable:");
|
|
23716
|
-
console.log(
|
|
23400
|
+
console.log(chalk80.cyan(" vm0 zero variable set MY_VAR <value>"));
|
|
23717
23401
|
return;
|
|
23718
23402
|
}
|
|
23719
|
-
console.log(
|
|
23403
|
+
console.log(chalk80.bold("Variables:"));
|
|
23720
23404
|
console.log();
|
|
23721
23405
|
for (const variable of result.variables) {
|
|
23722
23406
|
const displayValue = truncateValue2(variable.value);
|
|
23723
|
-
console.log(` ${
|
|
23407
|
+
console.log(` ${chalk80.cyan(variable.name)} = ${displayValue}`);
|
|
23724
23408
|
if (variable.description) {
|
|
23725
|
-
console.log(` ${
|
|
23409
|
+
console.log(` ${chalk80.dim(variable.description)}`);
|
|
23726
23410
|
}
|
|
23727
23411
|
console.log(
|
|
23728
|
-
` ${
|
|
23412
|
+
` ${chalk80.dim(`Updated: ${new Date(variable.updatedAt).toLocaleString()}`)}`
|
|
23729
23413
|
);
|
|
23730
23414
|
console.log();
|
|
23731
23415
|
}
|
|
23732
|
-
console.log(
|
|
23416
|
+
console.log(chalk80.dim(`Total: ${result.variables.length} variable(s)`));
|
|
23733
23417
|
})
|
|
23734
23418
|
);
|
|
23735
23419
|
|
|
23736
23420
|
// src/commands/zero/variable/set.ts
|
|
23737
|
-
import { Command as
|
|
23738
|
-
import
|
|
23739
|
-
var setCommand5 = new
|
|
23421
|
+
import { Command as Command91 } from "commander";
|
|
23422
|
+
import chalk81 from "chalk";
|
|
23423
|
+
var setCommand5 = new Command91().name("set").description("Create or update a variable").argument("<name>", "Variable name (uppercase, e.g., MY_VAR)").argument("<value>", "Variable value").option("-d, --description <description>", "Optional description").action(
|
|
23740
23424
|
withErrorHandler(
|
|
23741
23425
|
async (name, value, options) => {
|
|
23742
23426
|
let variable;
|
|
@@ -23756,19 +23440,19 @@ var setCommand5 = new Command96().name("set").description("Create or update a va
|
|
|
23756
23440
|
}
|
|
23757
23441
|
throw error;
|
|
23758
23442
|
}
|
|
23759
|
-
console.log(
|
|
23443
|
+
console.log(chalk81.green(`\u2713 Variable "${variable.name}" saved`));
|
|
23760
23444
|
console.log();
|
|
23761
23445
|
console.log("Use in vm0.yaml:");
|
|
23762
|
-
console.log(
|
|
23763
|
-
console.log(
|
|
23446
|
+
console.log(chalk81.cyan(` environment:`));
|
|
23447
|
+
console.log(chalk81.cyan(` ${name}: \${{ vars.${name} }}`));
|
|
23764
23448
|
}
|
|
23765
23449
|
)
|
|
23766
23450
|
);
|
|
23767
23451
|
|
|
23768
23452
|
// src/commands/zero/variable/delete.ts
|
|
23769
|
-
import { Command as
|
|
23770
|
-
import
|
|
23771
|
-
var deleteCommand5 = new
|
|
23453
|
+
import { Command as Command92 } from "commander";
|
|
23454
|
+
import chalk82 from "chalk";
|
|
23455
|
+
var deleteCommand5 = new Command92().name("delete").description("Delete a variable").argument("<name>", "Variable name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
23772
23456
|
withErrorHandler(async (name, options) => {
|
|
23773
23457
|
if (!options.yes) {
|
|
23774
23458
|
if (!isInteractive()) {
|
|
@@ -23779,24 +23463,24 @@ var deleteCommand5 = new Command97().name("delete").description("Delete a variab
|
|
|
23779
23463
|
false
|
|
23780
23464
|
);
|
|
23781
23465
|
if (!confirmed) {
|
|
23782
|
-
console.log(
|
|
23466
|
+
console.log(chalk82.dim("Cancelled"));
|
|
23783
23467
|
return;
|
|
23784
23468
|
}
|
|
23785
23469
|
}
|
|
23786
23470
|
await deleteZeroVariable(name);
|
|
23787
|
-
console.log(
|
|
23471
|
+
console.log(chalk82.green(`\u2713 Variable "${name}" deleted`));
|
|
23788
23472
|
})
|
|
23789
23473
|
);
|
|
23790
23474
|
|
|
23791
23475
|
// src/commands/zero/variable/index.ts
|
|
23792
|
-
var zeroVariableCommand = new
|
|
23476
|
+
var zeroVariableCommand = new Command93().name("variable").description("Manage variables").addCommand(listCommand13).addCommand(setCommand5).addCommand(deleteCommand5);
|
|
23793
23477
|
|
|
23794
23478
|
// src/commands/zero/index.ts
|
|
23795
|
-
var zeroCommand = new
|
|
23479
|
+
var zeroCommand = new Command94("zero").description("Zero platform commands").addCommand(zeroOrgCommand).addCommand(agentCommand).addCommand(zeroConnectorCommand).addCommand(zeroScheduleCommand).addCommand(zeroSecretCommand).addCommand(zeroVariableCommand);
|
|
23796
23480
|
|
|
23797
23481
|
// src/index.ts
|
|
23798
|
-
var program = new
|
|
23799
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.78.
|
|
23482
|
+
var program = new Command95();
|
|
23483
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.78.1");
|
|
23800
23484
|
program.addCommand(authCommand);
|
|
23801
23485
|
program.addCommand(infoCommand);
|
|
23802
23486
|
program.addCommand(composeCommand);
|
|
@@ -23807,7 +23491,6 @@ program.addCommand(memoryCommand);
|
|
|
23807
23491
|
program.addCommand(cookCommand);
|
|
23808
23492
|
program.addCommand(logsCommand2);
|
|
23809
23493
|
program.addCommand(initCommand4);
|
|
23810
|
-
program.addCommand(connectorCommand);
|
|
23811
23494
|
program.addCommand(preferenceCommand);
|
|
23812
23495
|
program.addCommand(upgradeCommand);
|
|
23813
23496
|
program.addCommand(whoamiCommand);
|