@vm0/cli 9.78.0 → 9.78.2
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 +1197 -1498
- 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.2",
|
|
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.2",
|
|
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,84 @@ 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
|
+
|
|
6687
|
+
// ../../packages/core/src/firewalls/airtable.generated.ts
|
|
6688
|
+
var airtableFirewall = {
|
|
6689
|
+
name: "airtable",
|
|
6690
|
+
description: "Airtable API",
|
|
6691
|
+
placeholders: {
|
|
6692
|
+
AIRTABLE_TOKEN: "patVm0PlaceHolder.0000000000000000000000000000000000000000000000000000000000000000"
|
|
6693
|
+
},
|
|
6694
|
+
apis: [
|
|
6695
|
+
{
|
|
6696
|
+
base: "https://api.airtable.com",
|
|
6697
|
+
auth: {
|
|
6698
|
+
headers: {
|
|
6699
|
+
Authorization: "Bearer ${{ secrets.AIRTABLE_TOKEN }}"
|
|
6700
|
+
}
|
|
6701
|
+
},
|
|
6702
|
+
permissions: [
|
|
6703
|
+
{
|
|
6704
|
+
name: "unrestricted",
|
|
6705
|
+
description: "Allow all endpoints",
|
|
6706
|
+
rules: ["ANY /{path*}"]
|
|
6707
|
+
}
|
|
6708
|
+
]
|
|
6709
|
+
}
|
|
6710
|
+
]
|
|
6711
|
+
};
|
|
6712
|
+
|
|
6635
6713
|
// ../../packages/core/src/firewalls/confluence.generated.ts
|
|
6636
6714
|
var confluenceFirewall = {
|
|
6637
6715
|
name: "confluence",
|
|
@@ -12458,8 +12536,63 @@ var vercelFirewall = {
|
|
|
12458
12536
|
]
|
|
12459
12537
|
};
|
|
12460
12538
|
|
|
12539
|
+
// ../../packages/core/src/firewalls/zapsign.generated.ts
|
|
12540
|
+
var zapsignFirewall = {
|
|
12541
|
+
name: "zapsign",
|
|
12542
|
+
description: "ZapSign API",
|
|
12543
|
+
placeholders: {
|
|
12544
|
+
ZAPSIGN_TOKEN: "00000000-0000-0000-0000-00000000"
|
|
12545
|
+
},
|
|
12546
|
+
apis: [
|
|
12547
|
+
{
|
|
12548
|
+
base: "https://api.zapsign.com.br",
|
|
12549
|
+
auth: {
|
|
12550
|
+
headers: {
|
|
12551
|
+
Authorization: "Bearer ${{ secrets.ZAPSIGN_TOKEN }}"
|
|
12552
|
+
}
|
|
12553
|
+
},
|
|
12554
|
+
permissions: [
|
|
12555
|
+
{
|
|
12556
|
+
name: "unrestricted",
|
|
12557
|
+
description: "Allow all endpoints",
|
|
12558
|
+
rules: ["ANY /{path*}"]
|
|
12559
|
+
}
|
|
12560
|
+
]
|
|
12561
|
+
}
|
|
12562
|
+
]
|
|
12563
|
+
};
|
|
12564
|
+
|
|
12565
|
+
// ../../packages/core/src/firewalls/zeptomail.generated.ts
|
|
12566
|
+
var zeptomailFirewall = {
|
|
12567
|
+
name: "zeptomail",
|
|
12568
|
+
description: "ZeptoMail API",
|
|
12569
|
+
placeholders: {
|
|
12570
|
+
ZEPTOMAIL_TOKEN: "vm0placeholder00000000000000000a"
|
|
12571
|
+
},
|
|
12572
|
+
apis: [
|
|
12573
|
+
{
|
|
12574
|
+
base: "https://api.zeptomail.com",
|
|
12575
|
+
auth: {
|
|
12576
|
+
headers: {
|
|
12577
|
+
Authorization: "Zoho-enczapikey ${{ secrets.ZEPTOMAIL_TOKEN }}"
|
|
12578
|
+
}
|
|
12579
|
+
},
|
|
12580
|
+
permissions: [
|
|
12581
|
+
{
|
|
12582
|
+
name: "unrestricted",
|
|
12583
|
+
description: "Allow all endpoints",
|
|
12584
|
+
rules: ["ANY /{path*}"]
|
|
12585
|
+
}
|
|
12586
|
+
]
|
|
12587
|
+
}
|
|
12588
|
+
]
|
|
12589
|
+
};
|
|
12590
|
+
|
|
12461
12591
|
// ../../packages/core/src/firewalls/index.ts
|
|
12462
12592
|
var builtinFirewalls = {
|
|
12593
|
+
agentmail: agentmailFirewall,
|
|
12594
|
+
ahrefs: ahrefsFirewall,
|
|
12595
|
+
airtable: airtableFirewall,
|
|
12463
12596
|
confluence: confluenceFirewall,
|
|
12464
12597
|
figma: figmaFirewall,
|
|
12465
12598
|
github: githubFirewall,
|
|
@@ -12471,7 +12604,9 @@ var builtinFirewalls = {
|
|
|
12471
12604
|
jira: jiraFirewall,
|
|
12472
12605
|
notion: notionFirewall,
|
|
12473
12606
|
slack: slackFirewall,
|
|
12474
|
-
vercel: vercelFirewall
|
|
12607
|
+
vercel: vercelFirewall,
|
|
12608
|
+
zapsign: zapsignFirewall,
|
|
12609
|
+
zeptomail: zeptomailFirewall
|
|
12475
12610
|
};
|
|
12476
12611
|
|
|
12477
12612
|
// ../../packages/core/src/firewall-loader.ts
|
|
@@ -12702,7 +12837,7 @@ async function expandFirewallConfigs(config, fetchFn) {
|
|
|
12702
12837
|
}
|
|
12703
12838
|
}
|
|
12704
12839
|
|
|
12705
|
-
// ../../packages/core/src/contracts/user-preferences.ts
|
|
12840
|
+
// ../../packages/core/src/contracts/zero-user-preferences.ts
|
|
12706
12841
|
import { z as z22 } from "zod";
|
|
12707
12842
|
var c15 = initContract();
|
|
12708
12843
|
var sendModeSchema = z22.enum(["enter", "cmd-enter"]);
|
|
@@ -12725,14 +12860,10 @@ var updateUserPreferencesRequestSchema = z22.object({
|
|
|
12725
12860
|
message: "At least one preference must be provided"
|
|
12726
12861
|
}
|
|
12727
12862
|
);
|
|
12728
|
-
var
|
|
12729
|
-
/**
|
|
12730
|
-
* GET /api/user/preferences
|
|
12731
|
-
* Get current user's preferences
|
|
12732
|
-
*/
|
|
12863
|
+
var zeroUserPreferencesContract = c15.router({
|
|
12733
12864
|
get: {
|
|
12734
12865
|
method: "GET",
|
|
12735
|
-
path: "/api/user
|
|
12866
|
+
path: "/api/zero/user-preferences",
|
|
12736
12867
|
headers: authHeadersSchema,
|
|
12737
12868
|
responses: {
|
|
12738
12869
|
200: userPreferencesResponseSchema,
|
|
@@ -12741,13 +12872,9 @@ var userPreferencesContract = c15.router({
|
|
|
12741
12872
|
},
|
|
12742
12873
|
summary: "Get user preferences"
|
|
12743
12874
|
},
|
|
12744
|
-
/**
|
|
12745
|
-
* PUT /api/user/preferences
|
|
12746
|
-
* Update user preferences
|
|
12747
|
-
*/
|
|
12748
12875
|
update: {
|
|
12749
|
-
method: "
|
|
12750
|
-
path: "/api/user
|
|
12876
|
+
method: "POST",
|
|
12877
|
+
path: "/api/zero/user-preferences",
|
|
12751
12878
|
headers: authHeadersSchema,
|
|
12752
12879
|
body: updateUserPreferencesRequestSchema,
|
|
12753
12880
|
responses: {
|
|
@@ -13467,7 +13594,7 @@ import { z as z31 } from "zod";
|
|
|
13467
13594
|
var c25 = initContract();
|
|
13468
13595
|
var scheduleResponseSchema = z31.object({
|
|
13469
13596
|
id: z31.string().uuid(),
|
|
13470
|
-
|
|
13597
|
+
agentId: z31.string().uuid(),
|
|
13471
13598
|
agentName: z31.string(),
|
|
13472
13599
|
orgSlug: z31.string(),
|
|
13473
13600
|
userId: z31.string(),
|
|
@@ -13514,13 +13641,13 @@ var zeroDeployScheduleRequestSchema = z31.object({
|
|
|
13514
13641
|
artifactName: z31.string().optional(),
|
|
13515
13642
|
artifactVersion: z31.string().optional(),
|
|
13516
13643
|
volumeVersions: z31.record(z31.string(), z31.string()).optional(),
|
|
13517
|
-
|
|
13644
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13518
13645
|
composeId: z31.string().uuid("Invalid compose ID").optional(),
|
|
13519
13646
|
enabled: z31.boolean().optional(),
|
|
13520
13647
|
notifyEmail: z31.boolean().optional(),
|
|
13521
13648
|
notifySlack: z31.boolean().optional()
|
|
13522
|
-
}).refine((data) => Boolean(data.
|
|
13523
|
-
message: "Either '
|
|
13649
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13650
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13524
13651
|
}).refine(
|
|
13525
13652
|
(data) => {
|
|
13526
13653
|
const triggers = [
|
|
@@ -13571,10 +13698,10 @@ var zeroSchedulesByNameContract = c25.router({
|
|
|
13571
13698
|
name: z31.string().min(1, "Schedule name required")
|
|
13572
13699
|
}),
|
|
13573
13700
|
query: z31.object({
|
|
13574
|
-
|
|
13701
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13575
13702
|
composeId: z31.string().uuid("Invalid compose ID").optional()
|
|
13576
|
-
}).refine((data) => Boolean(data.
|
|
13577
|
-
message: "Either '
|
|
13703
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13704
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13578
13705
|
}),
|
|
13579
13706
|
responses: {
|
|
13580
13707
|
204: c25.noBody(),
|
|
@@ -13594,10 +13721,10 @@ var zeroSchedulesEnableContract = c25.router({
|
|
|
13594
13721
|
name: z31.string().min(1, "Schedule name required")
|
|
13595
13722
|
}),
|
|
13596
13723
|
body: z31.object({
|
|
13597
|
-
|
|
13724
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13598
13725
|
composeId: z31.string().uuid("Invalid compose ID").optional()
|
|
13599
|
-
}).refine((data) => Boolean(data.
|
|
13600
|
-
message: "Either '
|
|
13726
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13727
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13601
13728
|
}),
|
|
13602
13729
|
responses: {
|
|
13603
13730
|
200: scheduleResponseSchema,
|
|
@@ -13616,10 +13743,10 @@ var zeroSchedulesEnableContract = c25.router({
|
|
|
13616
13743
|
name: z31.string().min(1, "Schedule name required")
|
|
13617
13744
|
}),
|
|
13618
13745
|
body: z31.object({
|
|
13619
|
-
|
|
13746
|
+
agentId: z31.string().uuid("Invalid agent ID").optional(),
|
|
13620
13747
|
composeId: z31.string().uuid("Invalid compose ID").optional()
|
|
13621
|
-
}).refine((data) => Boolean(data.
|
|
13622
|
-
message: "Either '
|
|
13748
|
+
}).refine((data) => Boolean(data.agentId ?? data.composeId), {
|
|
13749
|
+
message: "Either 'agentId' or 'composeId' must be provided"
|
|
13623
13750
|
}),
|
|
13624
13751
|
responses: {
|
|
13625
13752
|
200: scheduleResponseSchema,
|
|
@@ -13720,39 +13847,10 @@ var zeroModelProvidersUpdateModelContract = c26.router({
|
|
|
13720
13847
|
}
|
|
13721
13848
|
});
|
|
13722
13849
|
|
|
13723
|
-
// ../../packages/core/src/contracts/zero-user-preferences.ts
|
|
13724
|
-
var c27 = initContract();
|
|
13725
|
-
var zeroUserPreferencesContract = c27.router({
|
|
13726
|
-
get: {
|
|
13727
|
-
method: "GET",
|
|
13728
|
-
path: "/api/zero/user-preferences",
|
|
13729
|
-
headers: authHeadersSchema,
|
|
13730
|
-
responses: {
|
|
13731
|
-
200: userPreferencesResponseSchema,
|
|
13732
|
-
401: apiErrorSchema,
|
|
13733
|
-
500: apiErrorSchema
|
|
13734
|
-
},
|
|
13735
|
-
summary: "Get user preferences"
|
|
13736
|
-
},
|
|
13737
|
-
update: {
|
|
13738
|
-
method: "POST",
|
|
13739
|
-
path: "/api/zero/user-preferences",
|
|
13740
|
-
headers: authHeadersSchema,
|
|
13741
|
-
body: updateUserPreferencesRequestSchema,
|
|
13742
|
-
responses: {
|
|
13743
|
-
200: userPreferencesResponseSchema,
|
|
13744
|
-
400: apiErrorSchema,
|
|
13745
|
-
401: apiErrorSchema,
|
|
13746
|
-
500: apiErrorSchema
|
|
13747
|
-
},
|
|
13748
|
-
summary: "Update user preferences"
|
|
13749
|
-
}
|
|
13750
|
-
});
|
|
13751
|
-
|
|
13752
13850
|
// ../../packages/core/src/contracts/zero-secrets.ts
|
|
13753
13851
|
import { z as z33 } from "zod";
|
|
13754
|
-
var
|
|
13755
|
-
var zeroSecretsContract =
|
|
13852
|
+
var c27 = initContract();
|
|
13853
|
+
var zeroSecretsContract = c27.router({
|
|
13756
13854
|
list: {
|
|
13757
13855
|
method: "GET",
|
|
13758
13856
|
path: "/api/zero/secrets",
|
|
@@ -13779,7 +13877,7 @@ var zeroSecretsContract = c28.router({
|
|
|
13779
13877
|
summary: "Create or update a secret"
|
|
13780
13878
|
}
|
|
13781
13879
|
});
|
|
13782
|
-
var zeroSecretsByNameContract =
|
|
13880
|
+
var zeroSecretsByNameContract = c27.router({
|
|
13783
13881
|
delete: {
|
|
13784
13882
|
method: "DELETE",
|
|
13785
13883
|
path: "/api/zero/secrets/:name",
|
|
@@ -13788,7 +13886,7 @@ var zeroSecretsByNameContract = c28.router({
|
|
|
13788
13886
|
name: secretNameSchema
|
|
13789
13887
|
}),
|
|
13790
13888
|
responses: {
|
|
13791
|
-
204:
|
|
13889
|
+
204: c27.noBody(),
|
|
13792
13890
|
401: apiErrorSchema,
|
|
13793
13891
|
404: apiErrorSchema,
|
|
13794
13892
|
500: apiErrorSchema
|
|
@@ -13796,7 +13894,7 @@ var zeroSecretsByNameContract = c28.router({
|
|
|
13796
13894
|
summary: "Delete a secret by name"
|
|
13797
13895
|
}
|
|
13798
13896
|
});
|
|
13799
|
-
var zeroVariablesContract =
|
|
13897
|
+
var zeroVariablesContract = c27.router({
|
|
13800
13898
|
list: {
|
|
13801
13899
|
method: "GET",
|
|
13802
13900
|
path: "/api/zero/variables",
|
|
@@ -13823,7 +13921,7 @@ var zeroVariablesContract = c28.router({
|
|
|
13823
13921
|
summary: "Create or update a variable"
|
|
13824
13922
|
}
|
|
13825
13923
|
});
|
|
13826
|
-
var zeroVariablesByNameContract =
|
|
13924
|
+
var zeroVariablesByNameContract = c27.router({
|
|
13827
13925
|
delete: {
|
|
13828
13926
|
method: "DELETE",
|
|
13829
13927
|
path: "/api/zero/variables/:name",
|
|
@@ -13832,7 +13930,7 @@ var zeroVariablesByNameContract = c28.router({
|
|
|
13832
13930
|
name: variableNameSchema
|
|
13833
13931
|
}),
|
|
13834
13932
|
responses: {
|
|
13835
|
-
204:
|
|
13933
|
+
204: c27.noBody(),
|
|
13836
13934
|
401: apiErrorSchema,
|
|
13837
13935
|
404: apiErrorSchema,
|
|
13838
13936
|
500: apiErrorSchema
|
|
@@ -13843,8 +13941,8 @@ var zeroVariablesByNameContract = c28.router({
|
|
|
13843
13941
|
|
|
13844
13942
|
// ../../packages/core/src/contracts/zero-sessions.ts
|
|
13845
13943
|
import { z as z34 } from "zod";
|
|
13846
|
-
var
|
|
13847
|
-
var zeroSessionsByIdContract =
|
|
13944
|
+
var c28 = initContract();
|
|
13945
|
+
var zeroSessionsByIdContract = c28.router({
|
|
13848
13946
|
getById: {
|
|
13849
13947
|
method: "GET",
|
|
13850
13948
|
path: "/api/zero/sessions/:id",
|
|
@@ -13864,8 +13962,8 @@ var zeroSessionsByIdContract = c29.router({
|
|
|
13864
13962
|
|
|
13865
13963
|
// ../../packages/core/src/contracts/integrations.ts
|
|
13866
13964
|
import { z as z35 } from "zod";
|
|
13867
|
-
var
|
|
13868
|
-
var integrationsSlackMessageContract =
|
|
13965
|
+
var c29 = initContract();
|
|
13966
|
+
var integrationsSlackMessageContract = c29.router({
|
|
13869
13967
|
sendMessage: {
|
|
13870
13968
|
method: "POST",
|
|
13871
13969
|
path: "/api/zero/integrations/slack/message",
|
|
@@ -13893,7 +13991,7 @@ var integrationsSlackMessageContract = c30.router({
|
|
|
13893
13991
|
|
|
13894
13992
|
// ../../packages/core/src/contracts/zero-billing.ts
|
|
13895
13993
|
import { z as z36 } from "zod";
|
|
13896
|
-
var
|
|
13994
|
+
var c30 = initContract();
|
|
13897
13995
|
var autoRechargeSchema = z36.object({
|
|
13898
13996
|
enabled: z36.boolean(),
|
|
13899
13997
|
threshold: z36.number().nullable(),
|
|
@@ -13926,7 +14024,7 @@ var autoRechargeUpdateRequestSchema = z36.object({
|
|
|
13926
14024
|
threshold: z36.number().int().positive().optional(),
|
|
13927
14025
|
amount: z36.number().int().min(1e3).optional()
|
|
13928
14026
|
});
|
|
13929
|
-
var zeroBillingStatusContract =
|
|
14027
|
+
var zeroBillingStatusContract = c30.router({
|
|
13930
14028
|
get: {
|
|
13931
14029
|
method: "GET",
|
|
13932
14030
|
path: "/api/zero/billing/status",
|
|
@@ -13939,7 +14037,7 @@ var zeroBillingStatusContract = c31.router({
|
|
|
13939
14037
|
summary: "Get billing status for current org"
|
|
13940
14038
|
}
|
|
13941
14039
|
});
|
|
13942
|
-
var zeroBillingCheckoutContract =
|
|
14040
|
+
var zeroBillingCheckoutContract = c30.router({
|
|
13943
14041
|
create: {
|
|
13944
14042
|
method: "POST",
|
|
13945
14043
|
path: "/api/zero/billing/checkout",
|
|
@@ -13955,7 +14053,7 @@ var zeroBillingCheckoutContract = c31.router({
|
|
|
13955
14053
|
summary: "Create Stripe checkout session"
|
|
13956
14054
|
}
|
|
13957
14055
|
});
|
|
13958
|
-
var zeroBillingPortalContract =
|
|
14056
|
+
var zeroBillingPortalContract = c30.router({
|
|
13959
14057
|
create: {
|
|
13960
14058
|
method: "POST",
|
|
13961
14059
|
path: "/api/zero/billing/portal",
|
|
@@ -13971,7 +14069,7 @@ var zeroBillingPortalContract = c31.router({
|
|
|
13971
14069
|
summary: "Create Stripe billing portal session"
|
|
13972
14070
|
}
|
|
13973
14071
|
});
|
|
13974
|
-
var zeroBillingAutoRechargeContract =
|
|
14072
|
+
var zeroBillingAutoRechargeContract = c30.router({
|
|
13975
14073
|
get: {
|
|
13976
14074
|
method: "GET",
|
|
13977
14075
|
path: "/api/zero/billing/auto-recharge",
|
|
@@ -14001,7 +14099,7 @@ var zeroBillingAutoRechargeContract = c31.router({
|
|
|
14001
14099
|
|
|
14002
14100
|
// ../../packages/core/src/contracts/zero-usage.ts
|
|
14003
14101
|
import { z as z37 } from "zod";
|
|
14004
|
-
var
|
|
14102
|
+
var c31 = initContract();
|
|
14005
14103
|
var memberUsageSchema = z37.object({
|
|
14006
14104
|
userId: z37.string(),
|
|
14007
14105
|
email: z37.string(),
|
|
@@ -14018,7 +14116,7 @@ var usageMembersResponseSchema = z37.object({
|
|
|
14018
14116
|
}).nullable(),
|
|
14019
14117
|
members: z37.array(memberUsageSchema)
|
|
14020
14118
|
});
|
|
14021
|
-
var zeroUsageMembersContract =
|
|
14119
|
+
var zeroUsageMembersContract = c31.router({
|
|
14022
14120
|
get: {
|
|
14023
14121
|
method: "GET",
|
|
14024
14122
|
path: "/api/zero/usage/members",
|
|
@@ -14637,7 +14735,7 @@ function getConfigPath() {
|
|
|
14637
14735
|
return join2(homedir2(), ".vm0", "config.json");
|
|
14638
14736
|
}
|
|
14639
14737
|
var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
|
|
14640
|
-
console.log(chalk4.bold(`VM0 CLI v${"9.78.
|
|
14738
|
+
console.log(chalk4.bold(`VM0 CLI v${"9.78.2"}`));
|
|
14641
14739
|
console.log();
|
|
14642
14740
|
const config = await loadConfig();
|
|
14643
14741
|
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
@@ -14860,57 +14958,20 @@ async function listStorages(query) {
|
|
|
14860
14958
|
handleError(result, `Failed to list ${query.type}s`);
|
|
14861
14959
|
}
|
|
14862
14960
|
|
|
14863
|
-
// src/lib/api/domains/
|
|
14961
|
+
// src/lib/api/domains/zero-user-preferences.ts
|
|
14864
14962
|
import { initClient as initClient5 } from "@ts-rest/core";
|
|
14865
|
-
async function
|
|
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
|
-
// src/lib/api/domains/user-preferences.ts
|
|
14901
|
-
import { initClient as initClient6 } from "@ts-rest/core";
|
|
14902
|
-
async function getUserPreferences() {
|
|
14963
|
+
async function getZeroUserPreferences() {
|
|
14903
14964
|
const config = await getClientConfig();
|
|
14904
|
-
const client =
|
|
14965
|
+
const client = initClient5(zeroUserPreferencesContract, config);
|
|
14905
14966
|
const result = await client.get({ headers: {} });
|
|
14906
14967
|
if (result.status === 200) {
|
|
14907
14968
|
return result.body;
|
|
14908
14969
|
}
|
|
14909
14970
|
handleError(result, "Failed to get user preferences");
|
|
14910
14971
|
}
|
|
14911
|
-
async function
|
|
14972
|
+
async function updateZeroUserPreferences(body) {
|
|
14912
14973
|
const config = await getClientConfig();
|
|
14913
|
-
const client =
|
|
14974
|
+
const client = initClient5(zeroUserPreferencesContract, config);
|
|
14914
14975
|
const result = await client.update({ body });
|
|
14915
14976
|
if (result.status === 200) {
|
|
14916
14977
|
return result.body;
|
|
@@ -15001,7 +15062,7 @@ async function resolveSkills(skillUrls) {
|
|
|
15001
15062
|
}
|
|
15002
15063
|
|
|
15003
15064
|
// src/lib/api/domains/zero-orgs.ts
|
|
15004
|
-
import { initClient as
|
|
15065
|
+
import { initClient as initClient6 } from "@ts-rest/core";
|
|
15005
15066
|
async function getUserTokenClientConfig() {
|
|
15006
15067
|
const baseUrl = await getBaseUrl();
|
|
15007
15068
|
const token = await getToken();
|
|
@@ -15019,7 +15080,7 @@ async function getUserTokenClientConfig() {
|
|
|
15019
15080
|
}
|
|
15020
15081
|
async function getZeroOrg() {
|
|
15021
15082
|
const config = await getClientConfig();
|
|
15022
|
-
const client =
|
|
15083
|
+
const client = initClient6(zeroOrgContract, config);
|
|
15023
15084
|
const result = await client.get({ headers: {} });
|
|
15024
15085
|
if (result.status === 200) {
|
|
15025
15086
|
return result.body;
|
|
@@ -15028,7 +15089,7 @@ async function getZeroOrg() {
|
|
|
15028
15089
|
}
|
|
15029
15090
|
async function updateZeroOrg(body) {
|
|
15030
15091
|
const config = await getClientConfig();
|
|
15031
|
-
const client =
|
|
15092
|
+
const client = initClient6(zeroOrgContract, config);
|
|
15032
15093
|
const result = await client.update({ body });
|
|
15033
15094
|
if (result.status === 200) {
|
|
15034
15095
|
return result.body;
|
|
@@ -15037,7 +15098,7 @@ async function updateZeroOrg(body) {
|
|
|
15037
15098
|
}
|
|
15038
15099
|
async function listZeroOrgs() {
|
|
15039
15100
|
const config = await getUserTokenClientConfig();
|
|
15040
|
-
const client =
|
|
15101
|
+
const client = initClient6(zeroOrgListContract, config);
|
|
15041
15102
|
const result = await client.list({ headers: {} });
|
|
15042
15103
|
if (result.status === 200) {
|
|
15043
15104
|
return result.body;
|
|
@@ -15046,7 +15107,7 @@ async function listZeroOrgs() {
|
|
|
15046
15107
|
}
|
|
15047
15108
|
async function getZeroOrgMembers() {
|
|
15048
15109
|
const config = await getClientConfig();
|
|
15049
|
-
const client =
|
|
15110
|
+
const client = initClient6(zeroOrgMembersContract, config);
|
|
15050
15111
|
const result = await client.members({ headers: {} });
|
|
15051
15112
|
if (result.status === 200) {
|
|
15052
15113
|
return result.body;
|
|
@@ -15055,7 +15116,7 @@ async function getZeroOrgMembers() {
|
|
|
15055
15116
|
}
|
|
15056
15117
|
async function inviteZeroOrgMember(email) {
|
|
15057
15118
|
const config = await getClientConfig();
|
|
15058
|
-
const client =
|
|
15119
|
+
const client = initClient6(zeroOrgInviteContract, config);
|
|
15059
15120
|
const result = await client.invite({
|
|
15060
15121
|
body: { email }
|
|
15061
15122
|
});
|
|
@@ -15066,7 +15127,7 @@ async function inviteZeroOrgMember(email) {
|
|
|
15066
15127
|
}
|
|
15067
15128
|
async function removeZeroOrgMember(email) {
|
|
15068
15129
|
const config = await getClientConfig();
|
|
15069
|
-
const client =
|
|
15130
|
+
const client = initClient6(zeroOrgMembersContract, config);
|
|
15070
15131
|
const result = await client.removeMember({
|
|
15071
15132
|
body: { email }
|
|
15072
15133
|
});
|
|
@@ -15077,7 +15138,7 @@ async function removeZeroOrgMember(email) {
|
|
|
15077
15138
|
}
|
|
15078
15139
|
async function leaveZeroOrg() {
|
|
15079
15140
|
const config = await getClientConfig();
|
|
15080
|
-
const client =
|
|
15141
|
+
const client = initClient6(zeroOrgLeaveContract, config);
|
|
15081
15142
|
const result = await client.leave({
|
|
15082
15143
|
body: {}
|
|
15083
15144
|
});
|
|
@@ -15088,7 +15149,7 @@ async function leaveZeroOrg() {
|
|
|
15088
15149
|
}
|
|
15089
15150
|
async function deleteZeroOrg(slug) {
|
|
15090
15151
|
const config = await getClientConfig();
|
|
15091
|
-
const client =
|
|
15152
|
+
const client = initClient6(zeroOrgDeleteContract, config);
|
|
15092
15153
|
const result = await client.delete({
|
|
15093
15154
|
body: { slug }
|
|
15094
15155
|
});
|
|
@@ -15099,10 +15160,10 @@ async function deleteZeroOrg(slug) {
|
|
|
15099
15160
|
}
|
|
15100
15161
|
|
|
15101
15162
|
// src/lib/api/domains/zero-secrets.ts
|
|
15102
|
-
import { initClient as
|
|
15163
|
+
import { initClient as initClient7 } from "@ts-rest/core";
|
|
15103
15164
|
async function listZeroSecrets() {
|
|
15104
15165
|
const config = await getClientConfig();
|
|
15105
|
-
const client =
|
|
15166
|
+
const client = initClient7(zeroSecretsContract, config);
|
|
15106
15167
|
const result = await client.list({ headers: {} });
|
|
15107
15168
|
if (result.status === 200) {
|
|
15108
15169
|
return result.body;
|
|
@@ -15111,7 +15172,7 @@ async function listZeroSecrets() {
|
|
|
15111
15172
|
}
|
|
15112
15173
|
async function setZeroSecret(body) {
|
|
15113
15174
|
const config = await getClientConfig();
|
|
15114
|
-
const client =
|
|
15175
|
+
const client = initClient7(zeroSecretsContract, config);
|
|
15115
15176
|
const result = await client.set({ body });
|
|
15116
15177
|
if (result.status === 200 || result.status === 201) {
|
|
15117
15178
|
return result.body;
|
|
@@ -15120,7 +15181,7 @@ async function setZeroSecret(body) {
|
|
|
15120
15181
|
}
|
|
15121
15182
|
async function deleteZeroSecret(name) {
|
|
15122
15183
|
const config = await getClientConfig();
|
|
15123
|
-
const client =
|
|
15184
|
+
const client = initClient7(zeroSecretsByNameContract, config);
|
|
15124
15185
|
const result = await client.delete({
|
|
15125
15186
|
params: { name }
|
|
15126
15187
|
});
|
|
@@ -15131,10 +15192,10 @@ async function deleteZeroSecret(name) {
|
|
|
15131
15192
|
}
|
|
15132
15193
|
|
|
15133
15194
|
// src/lib/api/domains/zero-variables.ts
|
|
15134
|
-
import { initClient as
|
|
15195
|
+
import { initClient as initClient8 } from "@ts-rest/core";
|
|
15135
15196
|
async function listZeroVariables() {
|
|
15136
15197
|
const config = await getClientConfig();
|
|
15137
|
-
const client =
|
|
15198
|
+
const client = initClient8(zeroVariablesContract, config);
|
|
15138
15199
|
const result = await client.list({ headers: {} });
|
|
15139
15200
|
if (result.status === 200) {
|
|
15140
15201
|
return result.body;
|
|
@@ -15143,7 +15204,7 @@ async function listZeroVariables() {
|
|
|
15143
15204
|
}
|
|
15144
15205
|
async function setZeroVariable(body) {
|
|
15145
15206
|
const config = await getClientConfig();
|
|
15146
|
-
const client =
|
|
15207
|
+
const client = initClient8(zeroVariablesContract, config);
|
|
15147
15208
|
const result = await client.set({ body });
|
|
15148
15209
|
if (result.status === 200 || result.status === 201) {
|
|
15149
15210
|
return result.body;
|
|
@@ -15152,7 +15213,7 @@ async function setZeroVariable(body) {
|
|
|
15152
15213
|
}
|
|
15153
15214
|
async function deleteZeroVariable(name) {
|
|
15154
15215
|
const config = await getClientConfig();
|
|
15155
|
-
const client =
|
|
15216
|
+
const client = initClient8(zeroVariablesByNameContract, config);
|
|
15156
15217
|
const result = await client.delete({
|
|
15157
15218
|
params: { name }
|
|
15158
15219
|
});
|
|
@@ -15163,10 +15224,10 @@ async function deleteZeroVariable(name) {
|
|
|
15163
15224
|
}
|
|
15164
15225
|
|
|
15165
15226
|
// src/lib/api/domains/zero-org-secrets.ts
|
|
15166
|
-
import { initClient as
|
|
15227
|
+
import { initClient as initClient9 } from "@ts-rest/core";
|
|
15167
15228
|
async function listZeroOrgSecrets() {
|
|
15168
15229
|
const config = await getClientConfig();
|
|
15169
|
-
const client =
|
|
15230
|
+
const client = initClient9(zeroSecretsContract, config);
|
|
15170
15231
|
const result = await client.list({ headers: {} });
|
|
15171
15232
|
if (result.status === 200) {
|
|
15172
15233
|
return result.body;
|
|
@@ -15175,7 +15236,7 @@ async function listZeroOrgSecrets() {
|
|
|
15175
15236
|
}
|
|
15176
15237
|
async function setZeroOrgSecret(body) {
|
|
15177
15238
|
const config = await getClientConfig();
|
|
15178
|
-
const client =
|
|
15239
|
+
const client = initClient9(zeroSecretsContract, config);
|
|
15179
15240
|
const result = await client.set({ body });
|
|
15180
15241
|
if (result.status === 200 || result.status === 201) {
|
|
15181
15242
|
return result.body;
|
|
@@ -15184,7 +15245,7 @@ async function setZeroOrgSecret(body) {
|
|
|
15184
15245
|
}
|
|
15185
15246
|
async function deleteZeroOrgSecret(name) {
|
|
15186
15247
|
const config = await getClientConfig();
|
|
15187
|
-
const client =
|
|
15248
|
+
const client = initClient9(zeroSecretsByNameContract, config);
|
|
15188
15249
|
const result = await client.delete({
|
|
15189
15250
|
params: { name }
|
|
15190
15251
|
});
|
|
@@ -15195,10 +15256,10 @@ async function deleteZeroOrgSecret(name) {
|
|
|
15195
15256
|
}
|
|
15196
15257
|
|
|
15197
15258
|
// src/lib/api/domains/zero-org-variables.ts
|
|
15198
|
-
import { initClient as
|
|
15259
|
+
import { initClient as initClient10 } from "@ts-rest/core";
|
|
15199
15260
|
async function listZeroOrgVariables() {
|
|
15200
15261
|
const config = await getClientConfig();
|
|
15201
|
-
const client =
|
|
15262
|
+
const client = initClient10(zeroVariablesContract, config);
|
|
15202
15263
|
const result = await client.list({ headers: {} });
|
|
15203
15264
|
if (result.status === 200) {
|
|
15204
15265
|
return result.body;
|
|
@@ -15207,7 +15268,7 @@ async function listZeroOrgVariables() {
|
|
|
15207
15268
|
}
|
|
15208
15269
|
async function setZeroOrgVariable(body) {
|
|
15209
15270
|
const config = await getClientConfig();
|
|
15210
|
-
const client =
|
|
15271
|
+
const client = initClient10(zeroVariablesContract, config);
|
|
15211
15272
|
const result = await client.set({ body });
|
|
15212
15273
|
if (result.status === 200 || result.status === 201) {
|
|
15213
15274
|
return result.body;
|
|
@@ -15216,7 +15277,7 @@ async function setZeroOrgVariable(body) {
|
|
|
15216
15277
|
}
|
|
15217
15278
|
async function deleteZeroOrgVariable(name) {
|
|
15218
15279
|
const config = await getClientConfig();
|
|
15219
|
-
const client =
|
|
15280
|
+
const client = initClient10(zeroVariablesByNameContract, config);
|
|
15220
15281
|
const result = await client.delete({
|
|
15221
15282
|
params: { name }
|
|
15222
15283
|
});
|
|
@@ -15227,10 +15288,10 @@ async function deleteZeroOrgVariable(name) {
|
|
|
15227
15288
|
}
|
|
15228
15289
|
|
|
15229
15290
|
// src/lib/api/domains/zero-org-model-providers.ts
|
|
15230
|
-
import { initClient as
|
|
15291
|
+
import { initClient as initClient11 } from "@ts-rest/core";
|
|
15231
15292
|
async function listZeroOrgModelProviders() {
|
|
15232
15293
|
const config = await getClientConfig();
|
|
15233
|
-
const client =
|
|
15294
|
+
const client = initClient11(zeroModelProvidersMainContract, config);
|
|
15234
15295
|
const result = await client.list({ headers: {} });
|
|
15235
15296
|
if (result.status === 200) {
|
|
15236
15297
|
return result.body;
|
|
@@ -15239,7 +15300,7 @@ async function listZeroOrgModelProviders() {
|
|
|
15239
15300
|
}
|
|
15240
15301
|
async function upsertZeroOrgModelProvider(body) {
|
|
15241
15302
|
const config = await getClientConfig();
|
|
15242
|
-
const client =
|
|
15303
|
+
const client = initClient11(zeroModelProvidersMainContract, config);
|
|
15243
15304
|
const result = await client.upsert({ body });
|
|
15244
15305
|
if (result.status === 200 || result.status === 201) {
|
|
15245
15306
|
return result.body;
|
|
@@ -15248,7 +15309,7 @@ async function upsertZeroOrgModelProvider(body) {
|
|
|
15248
15309
|
}
|
|
15249
15310
|
async function deleteZeroOrgModelProvider(type2) {
|
|
15250
15311
|
const config = await getClientConfig();
|
|
15251
|
-
const client =
|
|
15312
|
+
const client = initClient11(zeroModelProvidersByTypeContract, config);
|
|
15252
15313
|
const result = await client.delete({
|
|
15253
15314
|
params: { type: type2 }
|
|
15254
15315
|
});
|
|
@@ -15259,7 +15320,7 @@ async function deleteZeroOrgModelProvider(type2) {
|
|
|
15259
15320
|
}
|
|
15260
15321
|
async function setZeroOrgModelProviderDefault(type2) {
|
|
15261
15322
|
const config = await getClientConfig();
|
|
15262
|
-
const client =
|
|
15323
|
+
const client = initClient11(zeroModelProvidersDefaultContract, config);
|
|
15263
15324
|
const result = await client.setDefault({
|
|
15264
15325
|
params: { type: type2 }
|
|
15265
15326
|
});
|
|
@@ -15270,7 +15331,7 @@ async function setZeroOrgModelProviderDefault(type2) {
|
|
|
15270
15331
|
}
|
|
15271
15332
|
async function updateZeroOrgModelProviderModel(type2, selectedModel) {
|
|
15272
15333
|
const config = await getClientConfig();
|
|
15273
|
-
const client =
|
|
15334
|
+
const client = initClient11(zeroModelProvidersUpdateModelContract, config);
|
|
15274
15335
|
const result = await client.updateModel({
|
|
15275
15336
|
params: { type: type2 },
|
|
15276
15337
|
body: { selectedModel }
|
|
@@ -15282,52 +15343,52 @@ async function updateZeroOrgModelProviderModel(type2, selectedModel) {
|
|
|
15282
15343
|
}
|
|
15283
15344
|
|
|
15284
15345
|
// src/lib/api/domains/zero-agents.ts
|
|
15285
|
-
import { initClient as
|
|
15346
|
+
import { initClient as initClient12 } from "@ts-rest/core";
|
|
15286
15347
|
async function createZeroAgent(body) {
|
|
15287
15348
|
const config = await getClientConfig();
|
|
15288
|
-
const client =
|
|
15349
|
+
const client = initClient12(zeroAgentsMainContract, config);
|
|
15289
15350
|
const result = await client.create({ body });
|
|
15290
15351
|
if (result.status === 201) return result.body;
|
|
15291
15352
|
handleError(result, "Failed to create zero agent");
|
|
15292
15353
|
}
|
|
15293
15354
|
async function listZeroAgents() {
|
|
15294
15355
|
const config = await getClientConfig();
|
|
15295
|
-
const client =
|
|
15356
|
+
const client = initClient12(zeroAgentsMainContract, config);
|
|
15296
15357
|
const result = await client.list({ headers: {} });
|
|
15297
15358
|
if (result.status === 200) return result.body;
|
|
15298
15359
|
handleError(result, "Failed to list zero agents");
|
|
15299
15360
|
}
|
|
15300
15361
|
async function getZeroAgent(name) {
|
|
15301
15362
|
const config = await getClientConfig();
|
|
15302
|
-
const client =
|
|
15363
|
+
const client = initClient12(zeroAgentsByNameContract, config);
|
|
15303
15364
|
const result = await client.get({ params: { name } });
|
|
15304
15365
|
if (result.status === 200) return result.body;
|
|
15305
15366
|
handleError(result, `Zero agent "${name}" not found`);
|
|
15306
15367
|
}
|
|
15307
15368
|
async function updateZeroAgent(name, body) {
|
|
15308
15369
|
const config = await getClientConfig();
|
|
15309
|
-
const client =
|
|
15370
|
+
const client = initClient12(zeroAgentsByNameContract, config);
|
|
15310
15371
|
const result = await client.update({ params: { name }, body });
|
|
15311
15372
|
if (result.status === 200) return result.body;
|
|
15312
15373
|
handleError(result, `Failed to update zero agent "${name}"`);
|
|
15313
15374
|
}
|
|
15314
15375
|
async function deleteZeroAgent(name) {
|
|
15315
15376
|
const config = await getClientConfig();
|
|
15316
|
-
const client =
|
|
15377
|
+
const client = initClient12(zeroAgentsByNameContract, config);
|
|
15317
15378
|
const result = await client.delete({ params: { name } });
|
|
15318
15379
|
if (result.status === 204) return;
|
|
15319
15380
|
handleError(result, `Zero agent "${name}" not found`);
|
|
15320
15381
|
}
|
|
15321
15382
|
async function getZeroAgentInstructions(name) {
|
|
15322
15383
|
const config = await getClientConfig();
|
|
15323
|
-
const client =
|
|
15384
|
+
const client = initClient12(zeroAgentInstructionsContract, config);
|
|
15324
15385
|
const result = await client.get({ params: { name } });
|
|
15325
15386
|
if (result.status === 200) return result.body;
|
|
15326
15387
|
handleError(result, `Failed to get instructions for zero agent "${name}"`);
|
|
15327
15388
|
}
|
|
15328
15389
|
async function updateZeroAgentInstructions(name, content) {
|
|
15329
15390
|
const config = await getClientConfig();
|
|
15330
|
-
const client =
|
|
15391
|
+
const client = initClient12(zeroAgentInstructionsContract, config);
|
|
15331
15392
|
const result = await client.update({
|
|
15332
15393
|
params: { name },
|
|
15333
15394
|
body: { content }
|
|
@@ -15337,10 +15398,10 @@ async function updateZeroAgentInstructions(name, content) {
|
|
|
15337
15398
|
}
|
|
15338
15399
|
|
|
15339
15400
|
// src/lib/api/domains/zero-connectors.ts
|
|
15340
|
-
import { initClient as
|
|
15401
|
+
import { initClient as initClient13 } from "@ts-rest/core";
|
|
15341
15402
|
async function listZeroConnectors() {
|
|
15342
15403
|
const config = await getClientConfig();
|
|
15343
|
-
const client =
|
|
15404
|
+
const client = initClient13(zeroConnectorsMainContract, config);
|
|
15344
15405
|
const result = await client.list({ headers: {} });
|
|
15345
15406
|
if (result.status === 200) {
|
|
15346
15407
|
return result.body;
|
|
@@ -15349,7 +15410,7 @@ async function listZeroConnectors() {
|
|
|
15349
15410
|
}
|
|
15350
15411
|
async function getZeroConnector(type2) {
|
|
15351
15412
|
const config = await getClientConfig();
|
|
15352
|
-
const client =
|
|
15413
|
+
const client = initClient13(zeroConnectorsByTypeContract, config);
|
|
15353
15414
|
const result = await client.get({
|
|
15354
15415
|
params: { type: type2 }
|
|
15355
15416
|
});
|
|
@@ -15363,7 +15424,7 @@ async function getZeroConnector(type2) {
|
|
|
15363
15424
|
}
|
|
15364
15425
|
async function deleteZeroConnector(type2) {
|
|
15365
15426
|
const config = await getClientConfig();
|
|
15366
|
-
const client =
|
|
15427
|
+
const client = initClient13(zeroConnectorsByTypeContract, config);
|
|
15367
15428
|
const result = await client.delete({
|
|
15368
15429
|
params: { type: type2 }
|
|
15369
15430
|
});
|
|
@@ -15374,7 +15435,7 @@ async function deleteZeroConnector(type2) {
|
|
|
15374
15435
|
}
|
|
15375
15436
|
async function createZeroConnectorSession(type2) {
|
|
15376
15437
|
const config = await getClientConfig();
|
|
15377
|
-
const client =
|
|
15438
|
+
const client = initClient13(zeroConnectorSessionsContract, config);
|
|
15378
15439
|
const result = await client.create({
|
|
15379
15440
|
params: { type: type2 },
|
|
15380
15441
|
body: {}
|
|
@@ -15386,7 +15447,7 @@ async function createZeroConnectorSession(type2) {
|
|
|
15386
15447
|
}
|
|
15387
15448
|
async function getZeroConnectorSession(type2, sessionId) {
|
|
15388
15449
|
const config = await getClientConfig();
|
|
15389
|
-
const client =
|
|
15450
|
+
const client = initClient13(zeroConnectorSessionByIdContract, config);
|
|
15390
15451
|
const result = await client.get({
|
|
15391
15452
|
params: { type: type2, sessionId }
|
|
15392
15453
|
});
|
|
@@ -15397,7 +15458,7 @@ async function getZeroConnectorSession(type2, sessionId) {
|
|
|
15397
15458
|
}
|
|
15398
15459
|
async function createZeroComputerConnector() {
|
|
15399
15460
|
const config = await getClientConfig();
|
|
15400
|
-
const client =
|
|
15461
|
+
const client = initClient13(zeroComputerConnectorContract, config);
|
|
15401
15462
|
const result = await client.create({
|
|
15402
15463
|
body: {}
|
|
15403
15464
|
});
|
|
@@ -15408,7 +15469,7 @@ async function createZeroComputerConnector() {
|
|
|
15408
15469
|
}
|
|
15409
15470
|
async function deleteZeroComputerConnector() {
|
|
15410
15471
|
const config = await getClientConfig();
|
|
15411
|
-
const client =
|
|
15472
|
+
const client = initClient13(zeroComputerConnectorContract, config);
|
|
15412
15473
|
const result = await client.delete({});
|
|
15413
15474
|
if (result.status === 204) {
|
|
15414
15475
|
return;
|
|
@@ -15417,10 +15478,10 @@ async function deleteZeroComputerConnector() {
|
|
|
15417
15478
|
}
|
|
15418
15479
|
|
|
15419
15480
|
// src/lib/api/domains/zero-schedules.ts
|
|
15420
|
-
import { initClient as
|
|
15481
|
+
import { initClient as initClient14 } from "@ts-rest/core";
|
|
15421
15482
|
async function deployZeroSchedule(body) {
|
|
15422
15483
|
const config = await getClientConfig();
|
|
15423
|
-
const client =
|
|
15484
|
+
const client = initClient14(zeroSchedulesMainContract, config);
|
|
15424
15485
|
const result = await client.deploy({ body });
|
|
15425
15486
|
if (result.status === 200 || result.status === 201) {
|
|
15426
15487
|
return result.body;
|
|
@@ -15429,7 +15490,7 @@ async function deployZeroSchedule(body) {
|
|
|
15429
15490
|
}
|
|
15430
15491
|
async function listZeroSchedules() {
|
|
15431
15492
|
const config = await getClientConfig();
|
|
15432
|
-
const client =
|
|
15493
|
+
const client = initClient14(zeroSchedulesMainContract, config);
|
|
15433
15494
|
const result = await client.list({ headers: {} });
|
|
15434
15495
|
if (result.status === 200) {
|
|
15435
15496
|
return result.body;
|
|
@@ -15438,10 +15499,10 @@ async function listZeroSchedules() {
|
|
|
15438
15499
|
}
|
|
15439
15500
|
async function deleteZeroSchedule(params) {
|
|
15440
15501
|
const config = await getClientConfig();
|
|
15441
|
-
const client =
|
|
15502
|
+
const client = initClient14(zeroSchedulesByNameContract, config);
|
|
15442
15503
|
const result = await client.delete({
|
|
15443
15504
|
params: { name: params.name },
|
|
15444
|
-
query: {
|
|
15505
|
+
query: { agentId: params.agentId }
|
|
15445
15506
|
});
|
|
15446
15507
|
if (result.status === 204) {
|
|
15447
15508
|
return;
|
|
@@ -15450,10 +15511,10 @@ async function deleteZeroSchedule(params) {
|
|
|
15450
15511
|
}
|
|
15451
15512
|
async function enableZeroSchedule(params) {
|
|
15452
15513
|
const config = await getClientConfig();
|
|
15453
|
-
const client =
|
|
15514
|
+
const client = initClient14(zeroSchedulesEnableContract, config);
|
|
15454
15515
|
const result = await client.enable({
|
|
15455
15516
|
params: { name: params.name },
|
|
15456
|
-
body: {
|
|
15517
|
+
body: { agentId: params.agentId }
|
|
15457
15518
|
});
|
|
15458
15519
|
if (result.status === 200) {
|
|
15459
15520
|
return result.body;
|
|
@@ -15462,10 +15523,10 @@ async function enableZeroSchedule(params) {
|
|
|
15462
15523
|
}
|
|
15463
15524
|
async function disableZeroSchedule(params) {
|
|
15464
15525
|
const config = await getClientConfig();
|
|
15465
|
-
const client =
|
|
15526
|
+
const client = initClient14(zeroSchedulesEnableContract, config);
|
|
15466
15527
|
const result = await client.disable({
|
|
15467
15528
|
params: { name: params.name },
|
|
15468
|
-
body: {
|
|
15529
|
+
body: { agentId: params.agentId }
|
|
15469
15530
|
});
|
|
15470
15531
|
if (result.status === 200) {
|
|
15471
15532
|
return result.body;
|
|
@@ -16594,7 +16655,7 @@ async function checkAndPromptMissingItems(config, options) {
|
|
|
16594
16655
|
const [secretsResponse, variablesResponse, connectorsResponse] = await Promise.all([
|
|
16595
16656
|
requiredSecrets.size > 0 ? listZeroSecrets() : { secrets: [] },
|
|
16596
16657
|
requiredVars.size > 0 ? listZeroVariables() : { variables: [] },
|
|
16597
|
-
|
|
16658
|
+
listZeroConnectors()
|
|
16598
16659
|
]);
|
|
16599
16660
|
const existingSecretNames = new Set(
|
|
16600
16661
|
secretsResponse.secrets.map((s) => s.name)
|
|
@@ -16769,7 +16830,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
|
|
|
16769
16830
|
options.autoUpdate = false;
|
|
16770
16831
|
}
|
|
16771
16832
|
if (options.autoUpdate !== false) {
|
|
16772
|
-
await startSilentUpgrade("9.78.
|
|
16833
|
+
await startSilentUpgrade("9.78.2");
|
|
16773
16834
|
}
|
|
16774
16835
|
try {
|
|
16775
16836
|
let result;
|
|
@@ -17604,7 +17665,7 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
17604
17665
|
withErrorHandler(
|
|
17605
17666
|
async (identifier, prompt, options) => {
|
|
17606
17667
|
if (options.autoUpdate !== false) {
|
|
17607
|
-
await startSilentUpgrade("9.78.
|
|
17668
|
+
await startSilentUpgrade("9.78.2");
|
|
17608
17669
|
}
|
|
17609
17670
|
const { org, name, version } = parseIdentifier(identifier);
|
|
17610
17671
|
let composeId;
|
|
@@ -19360,7 +19421,7 @@ var cookAction = new Command35().name("cook").description("Quick start: prepare,
|
|
|
19360
19421
|
withErrorHandler(
|
|
19361
19422
|
async (prompt, options) => {
|
|
19362
19423
|
if (options.autoUpdate !== false) {
|
|
19363
|
-
const shouldExit = await checkAndUpgrade("9.78.
|
|
19424
|
+
const shouldExit = await checkAndUpgrade("9.78.2", prompt);
|
|
19364
19425
|
if (shouldExit) {
|
|
19365
19426
|
process.exit(0);
|
|
19366
19427
|
}
|
|
@@ -19546,7 +19607,7 @@ import { Command as Command40 } from "commander";
|
|
|
19546
19607
|
import chalk36 from "chalk";
|
|
19547
19608
|
|
|
19548
19609
|
// src/lib/api/api-client.ts
|
|
19549
|
-
import { initClient as
|
|
19610
|
+
import { initClient as initClient15 } from "@ts-rest/core";
|
|
19550
19611
|
var ApiClient = class {
|
|
19551
19612
|
async getHeaders() {
|
|
19552
19613
|
const token = await getActiveToken();
|
|
@@ -19572,7 +19633,7 @@ var ApiClient = class {
|
|
|
19572
19633
|
async getComposeByName(name, org) {
|
|
19573
19634
|
const baseUrl = await this.getBaseUrl();
|
|
19574
19635
|
const headers = await this.getHeaders();
|
|
19575
|
-
const client =
|
|
19636
|
+
const client = initClient15(composesMainContract, {
|
|
19576
19637
|
baseUrl,
|
|
19577
19638
|
baseHeaders: headers,
|
|
19578
19639
|
jsonQuery: false
|
|
@@ -19593,7 +19654,7 @@ var ApiClient = class {
|
|
|
19593
19654
|
async getComposeById(id) {
|
|
19594
19655
|
const baseUrl = await this.getBaseUrl();
|
|
19595
19656
|
const headers = await this.getHeaders();
|
|
19596
|
-
const client =
|
|
19657
|
+
const client = initClient15(composesByIdContract, {
|
|
19597
19658
|
baseUrl,
|
|
19598
19659
|
baseHeaders: headers,
|
|
19599
19660
|
jsonQuery: false
|
|
@@ -19615,7 +19676,7 @@ var ApiClient = class {
|
|
|
19615
19676
|
async getComposeVersion(composeId, version) {
|
|
19616
19677
|
const baseUrl = await this.getBaseUrl();
|
|
19617
19678
|
const headers = await this.getHeaders();
|
|
19618
|
-
const client =
|
|
19679
|
+
const client = initClient15(composesVersionsContract, {
|
|
19619
19680
|
baseUrl,
|
|
19620
19681
|
baseHeaders: headers,
|
|
19621
19682
|
jsonQuery: false
|
|
@@ -19636,7 +19697,7 @@ var ApiClient = class {
|
|
|
19636
19697
|
async createOrUpdateCompose(body) {
|
|
19637
19698
|
const baseUrl = await this.getBaseUrl();
|
|
19638
19699
|
const headers = await this.getHeaders();
|
|
19639
|
-
const client =
|
|
19700
|
+
const client = initClient15(composesMainContract, {
|
|
19640
19701
|
baseUrl,
|
|
19641
19702
|
baseHeaders: headers,
|
|
19642
19703
|
jsonQuery: false
|
|
@@ -19659,7 +19720,7 @@ var ApiClient = class {
|
|
|
19659
19720
|
async createRun(body) {
|
|
19660
19721
|
const baseUrl = await this.getBaseUrl();
|
|
19661
19722
|
const headers = await this.getHeaders();
|
|
19662
|
-
const client =
|
|
19723
|
+
const client = initClient15(runsMainContract, {
|
|
19663
19724
|
baseUrl,
|
|
19664
19725
|
baseHeaders: headers,
|
|
19665
19726
|
jsonQuery: false
|
|
@@ -19674,7 +19735,7 @@ var ApiClient = class {
|
|
|
19674
19735
|
}
|
|
19675
19736
|
async getEvents(runId, options) {
|
|
19676
19737
|
const config = await getClientConfig();
|
|
19677
|
-
const client =
|
|
19738
|
+
const client = initClient15(runEventsContract, config);
|
|
19678
19739
|
const result = await client.getEvents({
|
|
19679
19740
|
params: { id: runId },
|
|
19680
19741
|
query: {
|
|
@@ -19691,7 +19752,7 @@ var ApiClient = class {
|
|
|
19691
19752
|
}
|
|
19692
19753
|
async getSystemLog(runId, options) {
|
|
19693
19754
|
const config = await getClientConfig();
|
|
19694
|
-
const client =
|
|
19755
|
+
const client = initClient15(runSystemLogContract, config);
|
|
19695
19756
|
const result = await client.getSystemLog({
|
|
19696
19757
|
params: { id: runId },
|
|
19697
19758
|
query: {
|
|
@@ -19709,7 +19770,7 @@ var ApiClient = class {
|
|
|
19709
19770
|
}
|
|
19710
19771
|
async getMetrics(runId, options) {
|
|
19711
19772
|
const config = await getClientConfig();
|
|
19712
|
-
const client =
|
|
19773
|
+
const client = initClient15(runMetricsContract, config);
|
|
19713
19774
|
const result = await client.getMetrics({
|
|
19714
19775
|
params: { id: runId },
|
|
19715
19776
|
query: {
|
|
@@ -19727,7 +19788,7 @@ var ApiClient = class {
|
|
|
19727
19788
|
}
|
|
19728
19789
|
async getAgentEvents(runId, options) {
|
|
19729
19790
|
const config = await getClientConfig();
|
|
19730
|
-
const client =
|
|
19791
|
+
const client = initClient15(runAgentEventsContract, config);
|
|
19731
19792
|
const result = await client.getAgentEvents({
|
|
19732
19793
|
params: { id: runId },
|
|
19733
19794
|
query: {
|
|
@@ -19745,7 +19806,7 @@ var ApiClient = class {
|
|
|
19745
19806
|
}
|
|
19746
19807
|
async getNetworkLogs(runId, options) {
|
|
19747
19808
|
const config = await getClientConfig();
|
|
19748
|
-
const client =
|
|
19809
|
+
const client = initClient15(runNetworkLogsContract, config);
|
|
19749
19810
|
const result = await client.getNetworkLogs({
|
|
19750
19811
|
params: { id: runId },
|
|
19751
19812
|
query: {
|
|
@@ -19768,7 +19829,7 @@ var ApiClient = class {
|
|
|
19768
19829
|
async getSession(sessionId) {
|
|
19769
19830
|
const baseUrl = await this.getBaseUrl();
|
|
19770
19831
|
const headers = await this.getHeaders();
|
|
19771
|
-
const client =
|
|
19832
|
+
const client = initClient15(sessionsByIdContract, {
|
|
19772
19833
|
baseUrl,
|
|
19773
19834
|
baseHeaders: headers,
|
|
19774
19835
|
jsonQuery: false
|
|
@@ -19789,7 +19850,7 @@ var ApiClient = class {
|
|
|
19789
19850
|
*/
|
|
19790
19851
|
async getCheckpoint(checkpointId) {
|
|
19791
19852
|
const config = await getClientConfig();
|
|
19792
|
-
const client =
|
|
19853
|
+
const client = initClient15(checkpointsByIdContract, config);
|
|
19793
19854
|
const result = await client.getById({
|
|
19794
19855
|
params: { id: checkpointId }
|
|
19795
19856
|
});
|
|
@@ -19806,7 +19867,7 @@ var ApiClient = class {
|
|
|
19806
19867
|
async prepareStorage(body) {
|
|
19807
19868
|
const baseUrl = await this.getBaseUrl();
|
|
19808
19869
|
const headers = await this.getHeaders();
|
|
19809
|
-
const client =
|
|
19870
|
+
const client = initClient15(storagesPrepareContract, {
|
|
19810
19871
|
baseUrl,
|
|
19811
19872
|
baseHeaders: headers,
|
|
19812
19873
|
jsonQuery: false
|
|
@@ -19825,7 +19886,7 @@ var ApiClient = class {
|
|
|
19825
19886
|
async commitStorage(body) {
|
|
19826
19887
|
const baseUrl = await this.getBaseUrl();
|
|
19827
19888
|
const headers = await this.getHeaders();
|
|
19828
|
-
const client =
|
|
19889
|
+
const client = initClient15(storagesCommitContract, {
|
|
19829
19890
|
baseUrl,
|
|
19830
19891
|
baseHeaders: headers,
|
|
19831
19892
|
jsonQuery: false
|
|
@@ -19844,7 +19905,7 @@ var ApiClient = class {
|
|
|
19844
19905
|
async getStorageDownload(query) {
|
|
19845
19906
|
const baseUrl = await this.getBaseUrl();
|
|
19846
19907
|
const headers = await this.getHeaders();
|
|
19847
|
-
const client =
|
|
19908
|
+
const client = initClient15(storagesDownloadContract, {
|
|
19848
19909
|
baseUrl,
|
|
19849
19910
|
baseHeaders: headers,
|
|
19850
19911
|
jsonQuery: false
|
|
@@ -19869,7 +19930,7 @@ var ApiClient = class {
|
|
|
19869
19930
|
async listStorages(query) {
|
|
19870
19931
|
const baseUrl = await this.getBaseUrl();
|
|
19871
19932
|
const headers = await this.getHeaders();
|
|
19872
|
-
const client =
|
|
19933
|
+
const client = initClient15(storagesListContract, {
|
|
19873
19934
|
baseUrl,
|
|
19874
19935
|
baseHeaders: headers,
|
|
19875
19936
|
jsonQuery: false
|
|
@@ -19951,7 +20012,7 @@ var ApiClient = class {
|
|
|
19951
20012
|
}
|
|
19952
20013
|
async searchLogs(options) {
|
|
19953
20014
|
const config = await getClientConfig();
|
|
19954
|
-
const client =
|
|
20015
|
+
const client = initClient15(logsSearchContract, config);
|
|
19955
20016
|
const result = await client.searchLogs({
|
|
19956
20017
|
query: {
|
|
19957
20018
|
keyword: options.keyword,
|
|
@@ -20516,841 +20577,64 @@ var initCommand4 = new Command41().name("init").description("Initialize a new VM
|
|
|
20516
20577
|
})
|
|
20517
20578
|
);
|
|
20518
20579
|
|
|
20519
|
-
// src/commands/
|
|
20520
|
-
import { Command as Command46 } from "commander";
|
|
20521
|
-
|
|
20522
|
-
// src/commands/connector/connect.ts
|
|
20580
|
+
// src/commands/upgrade/index.ts
|
|
20523
20581
|
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
20582
|
import chalk38 from "chalk";
|
|
20534
|
-
|
|
20535
|
-
|
|
20536
|
-
|
|
20537
|
-
|
|
20538
|
-
|
|
20539
|
-
|
|
20540
|
-
|
|
20541
|
-
|
|
20542
|
-
|
|
20543
|
-
|
|
20544
|
-
|
|
20545
|
-
|
|
20546
|
-
|
|
20547
|
-
|
|
20548
|
-
|
|
20549
|
-
|
|
20550
|
-
|
|
20551
|
-
|
|
20552
|
-
|
|
20553
|
-
|
|
20554
|
-
|
|
20555
|
-
|
|
20556
|
-
|
|
20557
|
-
|
|
20558
|
-
|
|
20559
|
-
|
|
20560
|
-
|
|
20561
|
-
|
|
20562
|
-
|
|
20563
|
-
|
|
20564
|
-
|
|
20565
|
-
|
|
20566
|
-
|
|
20567
|
-
|
|
20568
|
-
|
|
20569
|
-
|
|
20570
|
-
|
|
20571
|
-
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20575
|
-
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
const found = await new Promise((resolve) => {
|
|
20586
|
-
const child = spawn2("which", [candidate]);
|
|
20587
|
-
child.on("close", (code) => resolve(code === 0));
|
|
20588
|
-
});
|
|
20589
|
-
if (found) return candidate;
|
|
20590
|
-
}
|
|
20591
|
-
}
|
|
20592
|
-
return null;
|
|
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
|
-
);
|
|
20600
|
-
}
|
|
20601
|
-
const chromeBinary = await findBinary(...CHROME_CANDIDATES);
|
|
20602
|
-
if (!chromeBinary) {
|
|
20603
|
-
throw new Error("Chrome not found\n\nInstall Google Chrome or Chromium");
|
|
20604
|
-
}
|
|
20605
|
-
}
|
|
20606
|
-
async function startComputerServices(credentials) {
|
|
20607
|
-
console.log(chalk38.cyan("Starting computer connector services..."));
|
|
20608
|
-
const wsgidavBinary = await findBinary("wsgidav");
|
|
20609
|
-
if (!wsgidavBinary) {
|
|
20610
|
-
throw new Error(
|
|
20611
|
-
"wsgidav not found\n\nInstall with: pip install wsgidav[cheroot]"
|
|
20612
|
-
);
|
|
20613
|
-
}
|
|
20614
|
-
const chromeBinary = await findBinary(...CHROME_CANDIDATES);
|
|
20615
|
-
if (!chromeBinary) {
|
|
20616
|
-
throw new Error("Chrome not found\n\nInstall Google Chrome or Chromium");
|
|
20617
|
-
}
|
|
20618
|
-
const webdavPort = await getRandomPort();
|
|
20619
|
-
const cdpPort = await getRandomPort();
|
|
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
|
-
);
|
|
21235
|
-
}
|
|
21236
|
-
if (updates.notifySlack !== void 0) {
|
|
21237
|
-
console.log(
|
|
21238
|
-
chalk43.green(
|
|
21239
|
-
`Slack notifications ${result.notifySlack ? "enabled" : "disabled"}`
|
|
21240
|
-
)
|
|
21241
|
-
);
|
|
21242
|
-
}
|
|
21243
|
-
}
|
|
21244
|
-
async function interactiveSetup(prefs) {
|
|
21245
|
-
if (!prefs.timezone) {
|
|
21246
|
-
const detectedTz = detectTimezone2();
|
|
21247
|
-
console.log(chalk43.dim(`
|
|
21248
|
-
System timezone detected: ${detectedTz}`));
|
|
21249
|
-
const tz = await promptText(
|
|
21250
|
-
"Set timezone? (enter timezone or leave empty to skip)",
|
|
21251
|
-
detectedTz
|
|
21252
|
-
);
|
|
21253
|
-
if (tz?.trim()) {
|
|
21254
|
-
if (!isValidTimezone(tz.trim())) {
|
|
21255
|
-
throw new Error(`Invalid timezone: ${tz.trim()}`);
|
|
21256
|
-
}
|
|
21257
|
-
await updateUserPreferences({ timezone: tz.trim() });
|
|
21258
|
-
console.log(chalk43.green(`Timezone set to ${chalk43.cyan(tz.trim())}`));
|
|
21259
|
-
}
|
|
21260
|
-
}
|
|
21261
|
-
if (!prefs.notifyEmail) {
|
|
21262
|
-
const enable = await promptConfirm(
|
|
21263
|
-
"\nEnable email notifications for scheduled runs?",
|
|
21264
|
-
false
|
|
21265
|
-
);
|
|
21266
|
-
if (enable) {
|
|
21267
|
-
await updateUserPreferences({ notifyEmail: true });
|
|
21268
|
-
console.log(chalk43.green("Email notifications enabled"));
|
|
21269
|
-
}
|
|
21270
|
-
}
|
|
21271
|
-
}
|
|
21272
|
-
var preferenceCommand = new Command47().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
|
-
withErrorHandler(async (opts) => {
|
|
21274
|
-
const updates = buildUpdates(opts);
|
|
21275
|
-
if (updates) {
|
|
21276
|
-
const result = await updateUserPreferences(updates);
|
|
21277
|
-
printUpdateResult(updates, result);
|
|
21278
|
-
return;
|
|
21279
|
-
}
|
|
21280
|
-
const prefs = await getUserPreferences();
|
|
21281
|
-
displayPreferences(prefs);
|
|
21282
|
-
if (isInteractive()) {
|
|
21283
|
-
await interactiveSetup(prefs);
|
|
21284
|
-
} else if (!prefs.timezone) {
|
|
21285
|
-
console.log();
|
|
21286
|
-
console.log(
|
|
21287
|
-
`To set timezone: ${chalk43.cyan("vm0 preference --timezone <timezone>")}`
|
|
21288
|
-
);
|
|
21289
|
-
console.log(
|
|
21290
|
-
chalk43.dim("Example: vm0 preference --timezone America/New_York")
|
|
21291
|
-
);
|
|
21292
|
-
}
|
|
21293
|
-
})
|
|
21294
|
-
);
|
|
21295
|
-
|
|
21296
|
-
// src/commands/upgrade/index.ts
|
|
21297
|
-
import { Command as Command48 } from "commander";
|
|
21298
|
-
import chalk44 from "chalk";
|
|
21299
|
-
var upgradeCommand = new Command48().name("upgrade").description("Upgrade vm0 CLI to the latest version").action(
|
|
21300
|
-
withErrorHandler(async () => {
|
|
21301
|
-
console.log("Checking for updates...");
|
|
21302
|
-
const latestVersion = await getLatestVersion();
|
|
21303
|
-
if (latestVersion === null) {
|
|
21304
|
-
throw new Error("Could not check for updates. Please try again later.");
|
|
21305
|
-
}
|
|
21306
|
-
if (latestVersion === "9.78.0") {
|
|
21307
|
-
console.log(chalk44.green(`\u2713 Already up to date (${"9.78.0"})`));
|
|
21308
|
-
return;
|
|
21309
|
-
}
|
|
21310
|
-
console.log(
|
|
21311
|
-
chalk44.yellow(
|
|
21312
|
-
`Current version: ${"9.78.0"} -> Latest version: ${latestVersion}`
|
|
21313
|
-
)
|
|
21314
|
-
);
|
|
21315
|
-
console.log();
|
|
21316
|
-
const packageManager = detectPackageManager();
|
|
21317
|
-
if (!isAutoUpgradeSupported(packageManager)) {
|
|
21318
|
-
if (packageManager === "unknown") {
|
|
21319
|
-
console.log(
|
|
21320
|
-
chalk44.yellow(
|
|
21321
|
-
"Could not detect your package manager for auto-upgrade."
|
|
21322
|
-
)
|
|
21323
|
-
);
|
|
21324
|
-
} else {
|
|
21325
|
-
console.log(
|
|
21326
|
-
chalk44.yellow(
|
|
21327
|
-
`Auto-upgrade is not supported for ${packageManager}.`
|
|
21328
|
-
)
|
|
21329
|
-
);
|
|
21330
|
-
}
|
|
21331
|
-
console.log(chalk44.yellow("Please upgrade manually:"));
|
|
21332
|
-
console.log(chalk44.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
21333
|
-
return;
|
|
21334
|
-
}
|
|
21335
|
-
console.log(`Upgrading via ${packageManager}...`);
|
|
21336
|
-
const success = await performUpgrade(packageManager);
|
|
21337
|
-
if (success) {
|
|
21338
|
-
console.log(
|
|
21339
|
-
chalk44.green(`\u2713 Upgraded from ${"9.78.0"} to ${latestVersion}`)
|
|
21340
|
-
);
|
|
21341
|
-
return;
|
|
21342
|
-
}
|
|
21343
|
-
throw new Error("Upgrade failed", {
|
|
21344
|
-
cause: new Error(
|
|
21345
|
-
`Please run manually: ${getManualUpgradeCommand(packageManager)}`
|
|
21346
|
-
)
|
|
21347
|
-
});
|
|
21348
|
-
})
|
|
21349
|
-
);
|
|
20583
|
+
var upgradeCommand = new Command42().name("upgrade").description("Upgrade vm0 CLI to the latest version").action(
|
|
20584
|
+
withErrorHandler(async () => {
|
|
20585
|
+
console.log("Checking for updates...");
|
|
20586
|
+
const latestVersion = await getLatestVersion();
|
|
20587
|
+
if (latestVersion === null) {
|
|
20588
|
+
throw new Error("Could not check for updates. Please try again later.");
|
|
20589
|
+
}
|
|
20590
|
+
if (latestVersion === "9.78.2") {
|
|
20591
|
+
console.log(chalk38.green(`\u2713 Already up to date (${"9.78.2"})`));
|
|
20592
|
+
return;
|
|
20593
|
+
}
|
|
20594
|
+
console.log(
|
|
20595
|
+
chalk38.yellow(
|
|
20596
|
+
`Current version: ${"9.78.2"} -> Latest version: ${latestVersion}`
|
|
20597
|
+
)
|
|
20598
|
+
);
|
|
20599
|
+
console.log();
|
|
20600
|
+
const packageManager = detectPackageManager();
|
|
20601
|
+
if (!isAutoUpgradeSupported(packageManager)) {
|
|
20602
|
+
if (packageManager === "unknown") {
|
|
20603
|
+
console.log(
|
|
20604
|
+
chalk38.yellow(
|
|
20605
|
+
"Could not detect your package manager for auto-upgrade."
|
|
20606
|
+
)
|
|
20607
|
+
);
|
|
20608
|
+
} else {
|
|
20609
|
+
console.log(
|
|
20610
|
+
chalk38.yellow(
|
|
20611
|
+
`Auto-upgrade is not supported for ${packageManager}.`
|
|
20612
|
+
)
|
|
20613
|
+
);
|
|
20614
|
+
}
|
|
20615
|
+
console.log(chalk38.yellow("Please upgrade manually:"));
|
|
20616
|
+
console.log(chalk38.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
20617
|
+
return;
|
|
20618
|
+
}
|
|
20619
|
+
console.log(`Upgrading via ${packageManager}...`);
|
|
20620
|
+
const success = await performUpgrade(packageManager);
|
|
20621
|
+
if (success) {
|
|
20622
|
+
console.log(
|
|
20623
|
+
chalk38.green(`\u2713 Upgraded from ${"9.78.2"} to ${latestVersion}`)
|
|
20624
|
+
);
|
|
20625
|
+
return;
|
|
20626
|
+
}
|
|
20627
|
+
throw new Error("Upgrade failed", {
|
|
20628
|
+
cause: new Error(
|
|
20629
|
+
`Please run manually: ${getManualUpgradeCommand(packageManager)}`
|
|
20630
|
+
)
|
|
20631
|
+
});
|
|
20632
|
+
})
|
|
20633
|
+
);
|
|
21350
20634
|
|
|
21351
20635
|
// src/commands/whoami.ts
|
|
21352
|
-
import { Command as
|
|
21353
|
-
import
|
|
20636
|
+
import { Command as Command43 } from "commander";
|
|
20637
|
+
import chalk39 from "chalk";
|
|
21354
20638
|
function isInsideSandbox() {
|
|
21355
20639
|
return !!process.env.VM0_RUN_ID;
|
|
21356
20640
|
}
|
|
@@ -21365,7 +20649,7 @@ async function showSandboxInfo() {
|
|
|
21365
20649
|
const apiUrl = process.env.VM0_API_URL;
|
|
21366
20650
|
const hasAgentInfo = agentName || agentVersion || agentComposeId || agentOrgSlug || cliAgentType;
|
|
21367
20651
|
if (hasAgentInfo) {
|
|
21368
|
-
console.log(
|
|
20652
|
+
console.log(chalk39.bold("Agent:"));
|
|
21369
20653
|
if (agentName) console.log(` Name: ${agentName}`);
|
|
21370
20654
|
if (agentVersion) console.log(` Version: ${agentVersion}`);
|
|
21371
20655
|
if (agentComposeId) console.log(` Compose ID: ${agentComposeId}`);
|
|
@@ -21373,7 +20657,7 @@ async function showSandboxInfo() {
|
|
|
21373
20657
|
if (cliAgentType) console.log(` Framework: ${cliAgentType}`);
|
|
21374
20658
|
console.log();
|
|
21375
20659
|
}
|
|
21376
|
-
console.log(
|
|
20660
|
+
console.log(chalk39.bold("Run:"));
|
|
21377
20661
|
if (runId) console.log(` ID: ${runId}`);
|
|
21378
20662
|
if (activeOrg) console.log(` Org: ${activeOrg}`);
|
|
21379
20663
|
if (apiUrl) console.log(` API: ${apiUrl}`);
|
|
@@ -21382,23 +20666,23 @@ async function showLocalInfo() {
|
|
|
21382
20666
|
const token = await getToken();
|
|
21383
20667
|
const apiUrl = await getApiUrl();
|
|
21384
20668
|
const activeOrg = await getActiveOrg();
|
|
21385
|
-
console.log(
|
|
20669
|
+
console.log(chalk39.bold("Auth:"));
|
|
21386
20670
|
if (token) {
|
|
21387
20671
|
const tokenSource = process.env.VM0_TOKEN ? "VM0_TOKEN env var" : "config file";
|
|
21388
20672
|
console.log(
|
|
21389
|
-
` Status: ${
|
|
20673
|
+
` Status: ${chalk39.green("Authenticated")} (via ${tokenSource})`
|
|
21390
20674
|
);
|
|
21391
20675
|
} else {
|
|
21392
|
-
console.log(` Status: ${
|
|
20676
|
+
console.log(` Status: ${chalk39.dim("Not authenticated")}`);
|
|
21393
20677
|
}
|
|
21394
20678
|
console.log(` API: ${apiUrl}`);
|
|
21395
20679
|
console.log();
|
|
21396
20680
|
if (activeOrg) {
|
|
21397
|
-
console.log(
|
|
20681
|
+
console.log(chalk39.bold("Org:"));
|
|
21398
20682
|
console.log(` Active: ${activeOrg}`);
|
|
21399
20683
|
}
|
|
21400
20684
|
}
|
|
21401
|
-
var whoamiCommand = new
|
|
20685
|
+
var whoamiCommand = new Command43().name("whoami").description("Show current identity and environment information").action(
|
|
21402
20686
|
withErrorHandler(async () => {
|
|
21403
20687
|
if (isInsideSandbox()) {
|
|
21404
20688
|
await showSandboxInfo();
|
|
@@ -21409,20 +20693,20 @@ var whoamiCommand = new Command49().name("whoami").description("Show current ide
|
|
|
21409
20693
|
);
|
|
21410
20694
|
|
|
21411
20695
|
// src/commands/zero/index.ts
|
|
21412
|
-
import { Command as
|
|
20696
|
+
import { Command as Command94 } from "commander";
|
|
21413
20697
|
|
|
21414
20698
|
// src/commands/zero/org/index.ts
|
|
21415
|
-
import { Command as
|
|
20699
|
+
import { Command as Command66 } from "commander";
|
|
21416
20700
|
|
|
21417
20701
|
// src/commands/zero/org/status.ts
|
|
21418
|
-
import { Command as
|
|
21419
|
-
import
|
|
21420
|
-
var
|
|
20702
|
+
import { Command as Command44 } from "commander";
|
|
20703
|
+
import chalk40 from "chalk";
|
|
20704
|
+
var statusCommand5 = new Command44().name("status").description("View current organization status").action(
|
|
21421
20705
|
withErrorHandler(async () => {
|
|
21422
20706
|
try {
|
|
21423
20707
|
const org = await getZeroOrg();
|
|
21424
|
-
console.log(
|
|
21425
|
-
console.log(` Slug: ${
|
|
20708
|
+
console.log(chalk40.bold("Organization Information:"));
|
|
20709
|
+
console.log(` Slug: ${chalk40.green(org.slug)}`);
|
|
21426
20710
|
} catch (error) {
|
|
21427
20711
|
if (error instanceof ApiRequestError && error.status === 404) {
|
|
21428
20712
|
throw new Error("No organization configured", {
|
|
@@ -21437,9 +20721,9 @@ var statusCommand6 = new Command50().name("status").description("View current or
|
|
|
21437
20721
|
);
|
|
21438
20722
|
|
|
21439
20723
|
// src/commands/zero/org/set.ts
|
|
21440
|
-
import { Command as
|
|
21441
|
-
import
|
|
21442
|
-
var setCommand = new
|
|
20724
|
+
import { Command as Command45 } from "commander";
|
|
20725
|
+
import chalk41 from "chalk";
|
|
20726
|
+
var setCommand = new Command45().name("set").description("Rename your organization slug").argument("<slug>", "The new organization slug").option(
|
|
21443
20727
|
"--force",
|
|
21444
20728
|
"Force change existing organization (may break references)"
|
|
21445
20729
|
).action(
|
|
@@ -21458,10 +20742,10 @@ var setCommand = new Command51().name("set").description("Rename your organizati
|
|
|
21458
20742
|
}
|
|
21459
20743
|
const org = await updateZeroOrg({ slug, force: true });
|
|
21460
20744
|
await saveConfig({ activeOrg: org.slug });
|
|
21461
|
-
console.log(
|
|
20745
|
+
console.log(chalk41.green(`\u2713 Organization updated to ${org.slug}`));
|
|
21462
20746
|
console.log();
|
|
21463
20747
|
console.log("Your agents will now be namespaced as:");
|
|
21464
|
-
console.log(
|
|
20748
|
+
console.log(chalk41.cyan(` ${org.slug}/<agent-name>`));
|
|
21465
20749
|
} catch (error) {
|
|
21466
20750
|
if (error instanceof Error && error.message.includes("already exists")) {
|
|
21467
20751
|
throw new Error(
|
|
@@ -21474,27 +20758,27 @@ var setCommand = new Command51().name("set").description("Rename your organizati
|
|
|
21474
20758
|
);
|
|
21475
20759
|
|
|
21476
20760
|
// src/commands/zero/org/list.ts
|
|
21477
|
-
import { Command as
|
|
21478
|
-
import
|
|
21479
|
-
var
|
|
20761
|
+
import { Command as Command46 } from "commander";
|
|
20762
|
+
import chalk42 from "chalk";
|
|
20763
|
+
var listCommand5 = new Command46().name("list").description("List all accessible organizations").action(
|
|
21480
20764
|
withErrorHandler(async () => {
|
|
21481
20765
|
const result = await listZeroOrgs();
|
|
21482
20766
|
const activeOrg = await getActiveOrg();
|
|
21483
|
-
console.log(
|
|
20767
|
+
console.log(chalk42.bold("Available organizations:"));
|
|
21484
20768
|
for (const org of result.orgs) {
|
|
21485
20769
|
const isCurrent = org.slug === activeOrg;
|
|
21486
|
-
const marker = isCurrent ?
|
|
20770
|
+
const marker = isCurrent ? chalk42.green("* ") : " ";
|
|
21487
20771
|
const roleLabel = org.role ? ` (${org.role})` : "";
|
|
21488
|
-
const currentLabel = isCurrent ?
|
|
20772
|
+
const currentLabel = isCurrent ? chalk42.dim(" \u2190 current") : "";
|
|
21489
20773
|
console.log(`${marker}${org.slug}${roleLabel}${currentLabel}`);
|
|
21490
20774
|
}
|
|
21491
20775
|
})
|
|
21492
20776
|
);
|
|
21493
20777
|
|
|
21494
20778
|
// src/commands/zero/org/use.ts
|
|
21495
|
-
import { Command as
|
|
21496
|
-
import
|
|
21497
|
-
var useCommand = new
|
|
20779
|
+
import { Command as Command47 } from "commander";
|
|
20780
|
+
import chalk43 from "chalk";
|
|
20781
|
+
var useCommand = new Command47().name("use").description("Switch to a different organization").argument("<slug>", "Organization slug to switch to").action(
|
|
21498
20782
|
withErrorHandler(async (slug) => {
|
|
21499
20783
|
const orgList = await listZeroOrgs();
|
|
21500
20784
|
const target = orgList.orgs.find((s) => s.slug === slug);
|
|
@@ -21502,119 +20786,119 @@ var useCommand = new Command53().name("use").description("Switch to a different
|
|
|
21502
20786
|
throw new Error(`Organization '${slug}' not found or not accessible.`);
|
|
21503
20787
|
}
|
|
21504
20788
|
await saveConfig({ activeOrg: slug });
|
|
21505
|
-
console.log(
|
|
20789
|
+
console.log(chalk43.green(`\u2713 Switched to organization: ${slug}`));
|
|
21506
20790
|
})
|
|
21507
20791
|
);
|
|
21508
20792
|
|
|
21509
20793
|
// src/commands/zero/org/members.ts
|
|
21510
|
-
import { Command as
|
|
21511
|
-
import
|
|
21512
|
-
var membersCommand = new
|
|
20794
|
+
import { Command as Command48 } from "commander";
|
|
20795
|
+
import chalk44 from "chalk";
|
|
20796
|
+
var membersCommand = new Command48().name("members").description("View organization members").action(
|
|
21513
20797
|
withErrorHandler(async () => {
|
|
21514
20798
|
const status = await getZeroOrgMembers();
|
|
21515
|
-
console.log(
|
|
20799
|
+
console.log(chalk44.bold(`Organization: ${status.slug}`));
|
|
21516
20800
|
console.log(` Role: ${status.role}`);
|
|
21517
20801
|
console.log(
|
|
21518
20802
|
` Created: ${new Date(status.createdAt).toLocaleDateString()}`
|
|
21519
20803
|
);
|
|
21520
20804
|
console.log();
|
|
21521
|
-
console.log(
|
|
20805
|
+
console.log(chalk44.bold("Members:"));
|
|
21522
20806
|
for (const member of status.members) {
|
|
21523
|
-
const roleTag = member.role === "admin" ?
|
|
20807
|
+
const roleTag = member.role === "admin" ? chalk44.yellow(` (${member.role})`) : chalk44.dim(` (${member.role})`);
|
|
21524
20808
|
console.log(` ${member.email}${roleTag}`);
|
|
21525
20809
|
}
|
|
21526
20810
|
})
|
|
21527
20811
|
);
|
|
21528
20812
|
|
|
21529
20813
|
// src/commands/zero/org/invite.ts
|
|
21530
|
-
import { Command as
|
|
21531
|
-
import
|
|
21532
|
-
var inviteCommand = new
|
|
20814
|
+
import { Command as Command49 } from "commander";
|
|
20815
|
+
import chalk45 from "chalk";
|
|
20816
|
+
var inviteCommand = new Command49().name("invite").description("Invite a member to the current organization").requiredOption("--email <email>", "Email address of the member to invite").action(
|
|
21533
20817
|
withErrorHandler(async (options) => {
|
|
21534
20818
|
await inviteZeroOrgMember(options.email);
|
|
21535
|
-
console.log(
|
|
20819
|
+
console.log(chalk45.green(`\u2713 Invitation sent to ${options.email}`));
|
|
21536
20820
|
})
|
|
21537
20821
|
);
|
|
21538
20822
|
|
|
21539
20823
|
// src/commands/zero/org/remove.ts
|
|
21540
|
-
import { Command as
|
|
21541
|
-
import
|
|
21542
|
-
var removeCommand = new
|
|
20824
|
+
import { Command as Command50 } from "commander";
|
|
20825
|
+
import chalk46 from "chalk";
|
|
20826
|
+
var removeCommand = new Command50().name("remove").description("Remove a member from the current organization").argument("<email>", "Email address of the member to remove").action(
|
|
21543
20827
|
withErrorHandler(async (email) => {
|
|
21544
20828
|
await removeZeroOrgMember(email);
|
|
21545
|
-
console.log(
|
|
20829
|
+
console.log(chalk46.green(`\u2713 Removed ${email} from organization`));
|
|
21546
20830
|
})
|
|
21547
20831
|
);
|
|
21548
20832
|
|
|
21549
20833
|
// src/commands/zero/org/leave.ts
|
|
21550
|
-
import { Command as
|
|
21551
|
-
import
|
|
21552
|
-
var leaveCommand = new
|
|
20834
|
+
import { Command as Command51 } from "commander";
|
|
20835
|
+
import chalk47 from "chalk";
|
|
20836
|
+
var leaveCommand = new Command51().name("leave").description("Leave the current organization").action(
|
|
21553
20837
|
withErrorHandler(async () => {
|
|
21554
20838
|
await leaveZeroOrg();
|
|
21555
20839
|
const { orgs } = await listZeroOrgs();
|
|
21556
20840
|
if (orgs.length === 0) {
|
|
21557
20841
|
await saveConfig({ activeOrg: void 0 });
|
|
21558
|
-
console.log(
|
|
20842
|
+
console.log(chalk47.green("\u2713 Left organization."));
|
|
21559
20843
|
console.log(
|
|
21560
|
-
|
|
20844
|
+
chalk47.yellow("No remaining organizations. Run: vm0 auth login")
|
|
21561
20845
|
);
|
|
21562
20846
|
return;
|
|
21563
20847
|
}
|
|
21564
20848
|
const nextOrg = orgs[0].slug;
|
|
21565
20849
|
await saveConfig({ activeOrg: nextOrg });
|
|
21566
|
-
console.log(
|
|
20850
|
+
console.log(chalk47.green(`\u2713 Left organization. Switched to: ${nextOrg}`));
|
|
21567
20851
|
})
|
|
21568
20852
|
);
|
|
21569
20853
|
|
|
21570
20854
|
// src/commands/zero/org/delete.ts
|
|
21571
|
-
import { Command as
|
|
21572
|
-
import
|
|
21573
|
-
var deleteCommand = new
|
|
20855
|
+
import { Command as Command52 } from "commander";
|
|
20856
|
+
import chalk48 from "chalk";
|
|
20857
|
+
var deleteCommand = new Command52().name("delete").description("Delete the current organization (admin only)").argument("<slug>", "Organization slug to confirm deletion").action(
|
|
21574
20858
|
withErrorHandler(async (slug) => {
|
|
21575
20859
|
await deleteZeroOrg(slug);
|
|
21576
|
-
console.log(
|
|
20860
|
+
console.log(chalk48.green(`\u2713 Organization '${slug}' has been deleted.`));
|
|
21577
20861
|
})
|
|
21578
20862
|
);
|
|
21579
20863
|
|
|
21580
20864
|
// src/commands/zero/org/secret/index.ts
|
|
21581
|
-
import { Command as
|
|
20865
|
+
import { Command as Command56 } from "commander";
|
|
21582
20866
|
|
|
21583
20867
|
// src/commands/zero/org/secret/list.ts
|
|
21584
|
-
import { Command as
|
|
21585
|
-
import
|
|
21586
|
-
var
|
|
20868
|
+
import { Command as Command53 } from "commander";
|
|
20869
|
+
import chalk49 from "chalk";
|
|
20870
|
+
var listCommand6 = new Command53().name("list").alias("ls").description("List all org-level secrets").action(
|
|
21587
20871
|
withErrorHandler(async () => {
|
|
21588
20872
|
const result = await listZeroOrgSecrets();
|
|
21589
20873
|
if (result.secrets.length === 0) {
|
|
21590
|
-
console.log(
|
|
20874
|
+
console.log(chalk49.dim("No org secrets found"));
|
|
21591
20875
|
console.log();
|
|
21592
20876
|
console.log("To add an org secret:");
|
|
21593
20877
|
console.log(
|
|
21594
|
-
|
|
20878
|
+
chalk49.cyan(" vm0 zero org secret set MY_API_KEY --body <value>")
|
|
21595
20879
|
);
|
|
21596
20880
|
return;
|
|
21597
20881
|
}
|
|
21598
|
-
console.log(
|
|
20882
|
+
console.log(chalk49.bold("Org Secrets:"));
|
|
21599
20883
|
console.log();
|
|
21600
20884
|
for (const secret of result.secrets) {
|
|
21601
|
-
console.log(` ${
|
|
20885
|
+
console.log(` ${chalk49.cyan(secret.name)}`);
|
|
21602
20886
|
if (secret.description) {
|
|
21603
|
-
console.log(` ${
|
|
20887
|
+
console.log(` ${chalk49.dim(secret.description)}`);
|
|
21604
20888
|
}
|
|
21605
20889
|
console.log(
|
|
21606
|
-
` ${
|
|
20890
|
+
` ${chalk49.dim(`Updated: ${new Date(secret.updatedAt).toLocaleString()}`)}`
|
|
21607
20891
|
);
|
|
21608
20892
|
console.log();
|
|
21609
20893
|
}
|
|
21610
|
-
console.log(
|
|
20894
|
+
console.log(chalk49.dim(`Total: ${result.secrets.length} secret(s)`));
|
|
21611
20895
|
})
|
|
21612
20896
|
);
|
|
21613
20897
|
|
|
21614
20898
|
// src/commands/zero/org/secret/set.ts
|
|
21615
|
-
import { Command as
|
|
21616
|
-
import
|
|
21617
|
-
var setCommand2 = new
|
|
20899
|
+
import { Command as Command54 } from "commander";
|
|
20900
|
+
import chalk50 from "chalk";
|
|
20901
|
+
var setCommand2 = new Command54().name("set").description("Create or update an org-level secret (admin only)").argument("<name>", "Secret name (uppercase, e.g., MY_API_KEY)").option(
|
|
21618
20902
|
"-b, --body <value>",
|
|
21619
20903
|
"Secret value (required in non-interactive mode)"
|
|
21620
20904
|
).option("-d, --description <description>", "Optional description").action(
|
|
@@ -21653,19 +20937,19 @@ var setCommand2 = new Command60().name("set").description("Create or update an o
|
|
|
21653
20937
|
}
|
|
21654
20938
|
throw error;
|
|
21655
20939
|
}
|
|
21656
|
-
console.log(
|
|
20940
|
+
console.log(chalk50.green(`\u2713 Org secret "${secret.name}" saved`));
|
|
21657
20941
|
console.log();
|
|
21658
20942
|
console.log("Use in vm0.yaml:");
|
|
21659
|
-
console.log(
|
|
21660
|
-
console.log(
|
|
20943
|
+
console.log(chalk50.cyan(` environment:`));
|
|
20944
|
+
console.log(chalk50.cyan(` ${name}: \${{ secrets.${name} }}`));
|
|
21661
20945
|
}
|
|
21662
20946
|
)
|
|
21663
20947
|
);
|
|
21664
20948
|
|
|
21665
20949
|
// src/commands/zero/org/secret/remove.ts
|
|
21666
|
-
import { Command as
|
|
21667
|
-
import
|
|
21668
|
-
var removeCommand2 = new
|
|
20950
|
+
import { Command as Command55 } from "commander";
|
|
20951
|
+
import chalk51 from "chalk";
|
|
20952
|
+
var removeCommand2 = new Command55().name("remove").description("Delete an org-level secret (admin only)").argument("<name>", "Secret name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
21669
20953
|
withErrorHandler(async (name, options) => {
|
|
21670
20954
|
if (!options.yes) {
|
|
21671
20955
|
if (!isInteractive()) {
|
|
@@ -21676,61 +20960,61 @@ var removeCommand2 = new Command61().name("remove").description("Delete an org-l
|
|
|
21676
20960
|
false
|
|
21677
20961
|
);
|
|
21678
20962
|
if (!confirmed) {
|
|
21679
|
-
console.log(
|
|
20963
|
+
console.log(chalk51.dim("Cancelled"));
|
|
21680
20964
|
return;
|
|
21681
20965
|
}
|
|
21682
20966
|
}
|
|
21683
20967
|
await deleteZeroOrgSecret(name);
|
|
21684
|
-
console.log(
|
|
20968
|
+
console.log(chalk51.green(`\u2713 Org secret "${name}" deleted`));
|
|
21685
20969
|
})
|
|
21686
20970
|
);
|
|
21687
20971
|
|
|
21688
20972
|
// src/commands/zero/org/secret/index.ts
|
|
21689
|
-
var zeroOrgSecretCommand = new
|
|
20973
|
+
var zeroOrgSecretCommand = new Command56().name("secret").description("Manage org-level secrets (admin)").addCommand(listCommand6).addCommand(setCommand2).addCommand(removeCommand2);
|
|
21690
20974
|
|
|
21691
20975
|
// src/commands/zero/org/variable/index.ts
|
|
21692
|
-
import { Command as
|
|
20976
|
+
import { Command as Command60 } from "commander";
|
|
21693
20977
|
|
|
21694
20978
|
// src/commands/zero/org/variable/list.ts
|
|
21695
|
-
import { Command as
|
|
21696
|
-
import
|
|
20979
|
+
import { Command as Command57 } from "commander";
|
|
20980
|
+
import chalk52 from "chalk";
|
|
21697
20981
|
function truncateValue(value, maxLength = 60) {
|
|
21698
20982
|
if (value.length <= maxLength) {
|
|
21699
20983
|
return value;
|
|
21700
20984
|
}
|
|
21701
20985
|
return value.slice(0, maxLength - 15) + "... [truncated]";
|
|
21702
20986
|
}
|
|
21703
|
-
var
|
|
20987
|
+
var listCommand7 = new Command57().name("list").alias("ls").description("List all org-level variables").action(
|
|
21704
20988
|
withErrorHandler(async () => {
|
|
21705
20989
|
const result = await listZeroOrgVariables();
|
|
21706
20990
|
if (result.variables.length === 0) {
|
|
21707
|
-
console.log(
|
|
20991
|
+
console.log(chalk52.dim("No org variables found"));
|
|
21708
20992
|
console.log();
|
|
21709
20993
|
console.log("To add an org variable:");
|
|
21710
|
-
console.log(
|
|
20994
|
+
console.log(chalk52.cyan(" vm0 zero org variable set MY_VAR <value>"));
|
|
21711
20995
|
return;
|
|
21712
20996
|
}
|
|
21713
|
-
console.log(
|
|
20997
|
+
console.log(chalk52.bold("Org Variables:"));
|
|
21714
20998
|
console.log();
|
|
21715
20999
|
for (const variable of result.variables) {
|
|
21716
21000
|
const displayValue = truncateValue(variable.value);
|
|
21717
|
-
console.log(` ${
|
|
21001
|
+
console.log(` ${chalk52.cyan(variable.name)} = ${displayValue}`);
|
|
21718
21002
|
if (variable.description) {
|
|
21719
|
-
console.log(` ${
|
|
21003
|
+
console.log(` ${chalk52.dim(variable.description)}`);
|
|
21720
21004
|
}
|
|
21721
21005
|
console.log(
|
|
21722
|
-
` ${
|
|
21006
|
+
` ${chalk52.dim(`Updated: ${new Date(variable.updatedAt).toLocaleString()}`)}`
|
|
21723
21007
|
);
|
|
21724
21008
|
console.log();
|
|
21725
21009
|
}
|
|
21726
|
-
console.log(
|
|
21010
|
+
console.log(chalk52.dim(`Total: ${result.variables.length} variable(s)`));
|
|
21727
21011
|
})
|
|
21728
21012
|
);
|
|
21729
21013
|
|
|
21730
21014
|
// src/commands/zero/org/variable/set.ts
|
|
21731
|
-
import { Command as
|
|
21732
|
-
import
|
|
21733
|
-
var setCommand3 = new
|
|
21015
|
+
import { Command as Command58 } from "commander";
|
|
21016
|
+
import chalk53 from "chalk";
|
|
21017
|
+
var setCommand3 = new Command58().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
21018
|
withErrorHandler(
|
|
21735
21019
|
async (name, value, options) => {
|
|
21736
21020
|
let variable;
|
|
@@ -21750,19 +21034,19 @@ var setCommand3 = new Command64().name("set").description("Create or update an o
|
|
|
21750
21034
|
}
|
|
21751
21035
|
throw error;
|
|
21752
21036
|
}
|
|
21753
|
-
console.log(
|
|
21037
|
+
console.log(chalk53.green(`\u2713 Org variable "${variable.name}" saved`));
|
|
21754
21038
|
console.log();
|
|
21755
21039
|
console.log("Use in vm0.yaml:");
|
|
21756
|
-
console.log(
|
|
21757
|
-
console.log(
|
|
21040
|
+
console.log(chalk53.cyan(` environment:`));
|
|
21041
|
+
console.log(chalk53.cyan(` ${name}: \${{ vars.${name} }}`));
|
|
21758
21042
|
}
|
|
21759
21043
|
)
|
|
21760
21044
|
);
|
|
21761
21045
|
|
|
21762
21046
|
// src/commands/zero/org/variable/remove.ts
|
|
21763
|
-
import { Command as
|
|
21764
|
-
import
|
|
21765
|
-
var removeCommand3 = new
|
|
21047
|
+
import { Command as Command59 } from "commander";
|
|
21048
|
+
import chalk54 from "chalk";
|
|
21049
|
+
var removeCommand3 = new Command59().name("remove").description("Delete an org-level variable (admin only)").argument("<name>", "Variable name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
21766
21050
|
withErrorHandler(async (name, options) => {
|
|
21767
21051
|
if (!options.yes) {
|
|
21768
21052
|
if (!isInteractive()) {
|
|
@@ -21773,32 +21057,32 @@ var removeCommand3 = new Command65().name("remove").description("Delete an org-l
|
|
|
21773
21057
|
false
|
|
21774
21058
|
);
|
|
21775
21059
|
if (!confirmed) {
|
|
21776
|
-
console.log(
|
|
21060
|
+
console.log(chalk54.dim("Cancelled"));
|
|
21777
21061
|
return;
|
|
21778
21062
|
}
|
|
21779
21063
|
}
|
|
21780
21064
|
await deleteZeroOrgVariable(name);
|
|
21781
|
-
console.log(
|
|
21065
|
+
console.log(chalk54.green(`\u2713 Org variable "${name}" deleted`));
|
|
21782
21066
|
})
|
|
21783
21067
|
);
|
|
21784
21068
|
|
|
21785
21069
|
// src/commands/zero/org/variable/index.ts
|
|
21786
|
-
var zeroOrgVariableCommand = new
|
|
21070
|
+
var zeroOrgVariableCommand = new Command60().name("variable").description("Manage org-level variables (admin)").addCommand(listCommand7).addCommand(setCommand3).addCommand(removeCommand3);
|
|
21787
21071
|
|
|
21788
21072
|
// src/commands/zero/org/model-provider/index.ts
|
|
21789
|
-
import { Command as
|
|
21073
|
+
import { Command as Command65 } from "commander";
|
|
21790
21074
|
|
|
21791
21075
|
// src/commands/zero/org/model-provider/list.ts
|
|
21792
|
-
import { Command as
|
|
21793
|
-
import
|
|
21794
|
-
var
|
|
21076
|
+
import { Command as Command61 } from "commander";
|
|
21077
|
+
import chalk55 from "chalk";
|
|
21078
|
+
var listCommand8 = new Command61().name("list").alias("ls").description("List all org-level model providers").action(
|
|
21795
21079
|
withErrorHandler(async () => {
|
|
21796
21080
|
const result = await listZeroOrgModelProviders();
|
|
21797
21081
|
if (result.modelProviders.length === 0) {
|
|
21798
|
-
console.log(
|
|
21082
|
+
console.log(chalk55.dim("No org-level model providers configured"));
|
|
21799
21083
|
console.log();
|
|
21800
21084
|
console.log("To add an org-level model provider:");
|
|
21801
|
-
console.log(
|
|
21085
|
+
console.log(chalk55.cyan(" vm0 zero org model-provider setup"));
|
|
21802
21086
|
return;
|
|
21803
21087
|
}
|
|
21804
21088
|
const byFramework = result.modelProviders.reduce(
|
|
@@ -21812,16 +21096,16 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
21812
21096
|
},
|
|
21813
21097
|
{}
|
|
21814
21098
|
);
|
|
21815
|
-
console.log(
|
|
21099
|
+
console.log(chalk55.bold("Org Model Providers:"));
|
|
21816
21100
|
console.log();
|
|
21817
21101
|
for (const [framework, providers] of Object.entries(byFramework)) {
|
|
21818
|
-
console.log(` ${
|
|
21102
|
+
console.log(` ${chalk55.cyan(framework)}:`);
|
|
21819
21103
|
for (const provider of providers) {
|
|
21820
|
-
const defaultTag = provider.isDefault ?
|
|
21821
|
-
const modelTag = provider.selectedModel ?
|
|
21104
|
+
const defaultTag = provider.isDefault ? chalk55.green(" (default)") : "";
|
|
21105
|
+
const modelTag = provider.selectedModel ? chalk55.dim(` [${provider.selectedModel}]`) : "";
|
|
21822
21106
|
console.log(` ${provider.type}${defaultTag}${modelTag}`);
|
|
21823
21107
|
console.log(
|
|
21824
|
-
|
|
21108
|
+
chalk55.dim(
|
|
21825
21109
|
` Updated: ${new Date(provider.updatedAt).toLocaleString()}`
|
|
21826
21110
|
)
|
|
21827
21111
|
);
|
|
@@ -21829,18 +21113,18 @@ var listCommand9 = new Command67().name("list").alias("ls").description("List al
|
|
|
21829
21113
|
console.log();
|
|
21830
21114
|
}
|
|
21831
21115
|
console.log(
|
|
21832
|
-
|
|
21116
|
+
chalk55.dim(`Total: ${result.modelProviders.length} provider(s)`)
|
|
21833
21117
|
);
|
|
21834
21118
|
})
|
|
21835
21119
|
);
|
|
21836
21120
|
|
|
21837
21121
|
// src/commands/zero/org/model-provider/setup.ts
|
|
21838
|
-
import { Command as
|
|
21839
|
-
import
|
|
21122
|
+
import { Command as Command62 } from "commander";
|
|
21123
|
+
import chalk57 from "chalk";
|
|
21840
21124
|
import prompts3 from "prompts";
|
|
21841
21125
|
|
|
21842
21126
|
// src/lib/domain/model-provider/shared.ts
|
|
21843
|
-
import
|
|
21127
|
+
import chalk56 from "chalk";
|
|
21844
21128
|
import prompts2 from "prompts";
|
|
21845
21129
|
function validateProviderType(typeStr) {
|
|
21846
21130
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(typeStr)) {
|
|
@@ -22025,7 +21309,7 @@ async function promptForModelSelection(type2) {
|
|
|
22025
21309
|
if (selected === "__custom__") {
|
|
22026
21310
|
const placeholder = getCustomModelPlaceholder(type2);
|
|
22027
21311
|
if (placeholder) {
|
|
22028
|
-
console.log(
|
|
21312
|
+
console.log(chalk56.dim(`Example: ${placeholder}`));
|
|
22029
21313
|
}
|
|
22030
21314
|
const customResponse = await prompts2(
|
|
22031
21315
|
{
|
|
@@ -22075,7 +21359,7 @@ async function promptForSecrets(type2, authMethod) {
|
|
|
22075
21359
|
const secrets = {};
|
|
22076
21360
|
for (const [name, fieldConfig] of Object.entries(secretsConfig)) {
|
|
22077
21361
|
if (fieldConfig.helpText) {
|
|
22078
|
-
console.log(
|
|
21362
|
+
console.log(chalk56.dim(fieldConfig.helpText));
|
|
22079
21363
|
}
|
|
22080
21364
|
const isSensitive = isSensitiveSecret(name);
|
|
22081
21365
|
const placeholder = "placeholder" in fieldConfig ? fieldConfig.placeholder : "";
|
|
@@ -22132,7 +21416,7 @@ async function handleInteractiveMode() {
|
|
|
22132
21416
|
title = `${title} \u2713`;
|
|
22133
21417
|
}
|
|
22134
21418
|
if (isExperimental) {
|
|
22135
|
-
title = `${title} ${
|
|
21419
|
+
title = `${title} ${chalk57.dim("(experimental)")}`;
|
|
22136
21420
|
}
|
|
22137
21421
|
return {
|
|
22138
21422
|
title,
|
|
@@ -22179,7 +21463,7 @@ async function handleInteractiveMode() {
|
|
|
22179
21463
|
const config = MODEL_PROVIDER_TYPES[type2];
|
|
22180
21464
|
console.log();
|
|
22181
21465
|
if ("helpText" in config) {
|
|
22182
|
-
console.log(
|
|
21466
|
+
console.log(chalk57.dim(config.helpText));
|
|
22183
21467
|
}
|
|
22184
21468
|
console.log();
|
|
22185
21469
|
if (hasAuthMethods(type2)) {
|
|
@@ -22221,10 +21505,10 @@ async function promptSetAsDefault(type2, framework, isDefault) {
|
|
|
22221
21505
|
);
|
|
22222
21506
|
if (response.setDefault) {
|
|
22223
21507
|
await setZeroOrgModelProviderDefault(type2);
|
|
22224
|
-
console.log(
|
|
21508
|
+
console.log(chalk57.green(`\u2713 Default for ${framework} set to "${type2}"`));
|
|
22225
21509
|
}
|
|
22226
21510
|
}
|
|
22227
|
-
var setupCommand = new
|
|
21511
|
+
var setupCommand = new Command62().name("setup").description("Configure an org-level model provider").option("-t, --type <type>", "Provider type (for non-interactive mode)").option(
|
|
22228
21512
|
"-s, --secret <value>",
|
|
22229
21513
|
"Secret value (can be used multiple times, supports VALUE or KEY=VALUE format)",
|
|
22230
21514
|
collectSecrets,
|
|
@@ -22263,11 +21547,11 @@ var setupCommand = new Command68().name("setup").description("Configure an org-l
|
|
|
22263
21547
|
const modelNote2 = provider2.selectedModel ? ` with model: ${provider2.selectedModel}` : "";
|
|
22264
21548
|
if (!hasModelSelection(input.type)) {
|
|
22265
21549
|
console.log(
|
|
22266
|
-
|
|
21550
|
+
chalk57.green(`\u2713 Org model provider "${input.type}" unchanged`)
|
|
22267
21551
|
);
|
|
22268
21552
|
} else {
|
|
22269
21553
|
console.log(
|
|
22270
|
-
|
|
21554
|
+
chalk57.green(
|
|
22271
21555
|
`\u2713 Org model provider "${input.type}" updated${defaultNote2}${modelNote2}`
|
|
22272
21556
|
)
|
|
22273
21557
|
);
|
|
@@ -22292,7 +21576,7 @@ var setupCommand = new Command68().name("setup").description("Configure an org-l
|
|
|
22292
21576
|
const defaultNote = provider.isDefault ? ` (default for ${provider.framework})` : "";
|
|
22293
21577
|
const modelNote = provider.selectedModel ? ` with model: ${provider.selectedModel}` : "";
|
|
22294
21578
|
console.log(
|
|
22295
|
-
|
|
21579
|
+
chalk57.green(
|
|
22296
21580
|
`\u2713 Org model provider "${input.type}" ${action}${defaultNote}${modelNote}`
|
|
22297
21581
|
)
|
|
22298
21582
|
);
|
|
@@ -22308,9 +21592,9 @@ var setupCommand = new Command68().name("setup").description("Configure an org-l
|
|
|
22308
21592
|
);
|
|
22309
21593
|
|
|
22310
21594
|
// src/commands/zero/org/model-provider/remove.ts
|
|
22311
|
-
import { Command as
|
|
22312
|
-
import
|
|
22313
|
-
var removeCommand4 = new
|
|
21595
|
+
import { Command as Command63 } from "commander";
|
|
21596
|
+
import chalk58 from "chalk";
|
|
21597
|
+
var removeCommand4 = new Command63().name("remove").description("Remove an org-level model provider").argument("<type>", "Model provider type to remove").action(
|
|
22314
21598
|
withErrorHandler(async (type2) => {
|
|
22315
21599
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
22316
21600
|
const validTypes = Object.keys(MODEL_PROVIDER_TYPES).join(", ");
|
|
@@ -22319,14 +21603,14 @@ var removeCommand4 = new Command69().name("remove").description("Remove an org-l
|
|
|
22319
21603
|
});
|
|
22320
21604
|
}
|
|
22321
21605
|
await deleteZeroOrgModelProvider(type2);
|
|
22322
|
-
console.log(
|
|
21606
|
+
console.log(chalk58.green(`\u2713 Org model provider "${type2}" removed`));
|
|
22323
21607
|
})
|
|
22324
21608
|
);
|
|
22325
21609
|
|
|
22326
21610
|
// src/commands/zero/org/model-provider/set-default.ts
|
|
22327
|
-
import { Command as
|
|
22328
|
-
import
|
|
22329
|
-
var setDefaultCommand = new
|
|
21611
|
+
import { Command as Command64 } from "commander";
|
|
21612
|
+
import chalk59 from "chalk";
|
|
21613
|
+
var setDefaultCommand = new Command64().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
21614
|
withErrorHandler(async (type2) => {
|
|
22331
21615
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
22332
21616
|
const validTypes = Object.keys(MODEL_PROVIDER_TYPES).join(", ");
|
|
@@ -22338,7 +21622,7 @@ var setDefaultCommand = new Command70().name("set-default").description("Set an
|
|
|
22338
21622
|
type2
|
|
22339
21623
|
);
|
|
22340
21624
|
console.log(
|
|
22341
|
-
|
|
21625
|
+
chalk59.green(
|
|
22342
21626
|
`\u2713 Default for ${provider.framework} set to "${provider.type}"`
|
|
22343
21627
|
)
|
|
22344
21628
|
);
|
|
@@ -22346,19 +21630,19 @@ var setDefaultCommand = new Command70().name("set-default").description("Set an
|
|
|
22346
21630
|
);
|
|
22347
21631
|
|
|
22348
21632
|
// src/commands/zero/org/model-provider/index.ts
|
|
22349
|
-
var zeroOrgModelProviderCommand = new
|
|
21633
|
+
var zeroOrgModelProviderCommand = new Command65().name("model-provider").description("Manage org-level model providers").addCommand(listCommand8).addCommand(setupCommand).addCommand(removeCommand4).addCommand(setDefaultCommand);
|
|
22350
21634
|
|
|
22351
21635
|
// src/commands/zero/org/index.ts
|
|
22352
|
-
var zeroOrgCommand = new
|
|
21636
|
+
var zeroOrgCommand = new Command66().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
21637
|
|
|
22354
21638
|
// src/commands/zero/agent/index.ts
|
|
22355
|
-
import { Command as
|
|
21639
|
+
import { Command as Command72 } from "commander";
|
|
22356
21640
|
|
|
22357
21641
|
// src/commands/zero/agent/create.ts
|
|
22358
|
-
import { Command as
|
|
21642
|
+
import { Command as Command67 } from "commander";
|
|
22359
21643
|
import { readFileSync } from "fs";
|
|
22360
|
-
import
|
|
22361
|
-
var createCommand = new
|
|
21644
|
+
import chalk60 from "chalk";
|
|
21645
|
+
var createCommand = new Command67().name("create").description("Create a new zero agent").requiredOption(
|
|
22362
21646
|
"--connectors <items>",
|
|
22363
21647
|
"Comma-separated connector short names (e.g. github,linear)"
|
|
22364
21648
|
).option("--display-name <name>", "Agent display name").option("--description <text>", "Agent description").option(
|
|
@@ -22378,7 +21662,7 @@ var createCommand = new Command73().name("create").description("Create a new zer
|
|
|
22378
21662
|
const content = readFileSync(options.instructionsFile, "utf-8");
|
|
22379
21663
|
await updateZeroAgentInstructions(agent.name, content);
|
|
22380
21664
|
}
|
|
22381
|
-
console.log(
|
|
21665
|
+
console.log(chalk60.green(`\u2713 Zero agent '${agent.name}' created`));
|
|
22382
21666
|
console.log(` Compose ID: ${agent.agentComposeId}`);
|
|
22383
21667
|
console.log(` Connectors: ${agent.connectors.join(", ")}`);
|
|
22384
21668
|
if (agent.displayName) {
|
|
@@ -22389,10 +21673,10 @@ var createCommand = new Command73().name("create").description("Create a new zer
|
|
|
22389
21673
|
);
|
|
22390
21674
|
|
|
22391
21675
|
// src/commands/zero/agent/edit.ts
|
|
22392
|
-
import { Command as
|
|
21676
|
+
import { Command as Command68 } from "commander";
|
|
22393
21677
|
import { readFileSync as readFileSync2 } from "fs";
|
|
22394
|
-
import
|
|
22395
|
-
var editCommand = new
|
|
21678
|
+
import chalk61 from "chalk";
|
|
21679
|
+
var editCommand = new Command68().name("edit").description("Edit a zero agent").argument("<name>", "Agent name").option(
|
|
22396
21680
|
"--connectors <items>",
|
|
22397
21681
|
"Comma-separated connector short names (e.g. github,linear)"
|
|
22398
21682
|
).option("--display-name <name>", "New display name").option("--description <text>", "New description").option(
|
|
@@ -22421,20 +21705,20 @@ var editCommand = new Command74().name("edit").description("Edit a zero agent").
|
|
|
22421
21705
|
const content = readFileSync2(options.instructionsFile, "utf-8");
|
|
22422
21706
|
await updateZeroAgentInstructions(name, content);
|
|
22423
21707
|
}
|
|
22424
|
-
console.log(
|
|
21708
|
+
console.log(chalk61.green(`\u2713 Zero agent '${name}' updated`));
|
|
22425
21709
|
}
|
|
22426
21710
|
)
|
|
22427
21711
|
);
|
|
22428
21712
|
|
|
22429
21713
|
// src/commands/zero/agent/view.ts
|
|
22430
|
-
import { Command as
|
|
22431
|
-
import
|
|
22432
|
-
var viewCommand = new
|
|
21714
|
+
import { Command as Command69 } from "commander";
|
|
21715
|
+
import chalk62 from "chalk";
|
|
21716
|
+
var viewCommand = new Command69().name("view").description("View a zero agent").argument("<name>", "Agent name").option("--instructions", "Also show instructions content").action(
|
|
22433
21717
|
withErrorHandler(
|
|
22434
21718
|
async (name, options) => {
|
|
22435
21719
|
const agent = await getZeroAgent(name);
|
|
22436
|
-
console.log(
|
|
22437
|
-
if (agent.displayName) console.log(
|
|
21720
|
+
console.log(chalk62.bold(agent.name));
|
|
21721
|
+
if (agent.displayName) console.log(chalk62.dim(agent.displayName));
|
|
22438
21722
|
console.log();
|
|
22439
21723
|
console.log(`Compose ID: ${agent.agentComposeId}`);
|
|
22440
21724
|
console.log(`Connectors: ${agent.connectors.join(", ") || "-"}`);
|
|
@@ -22445,99 +21729,274 @@ var viewCommand = new Command75().name("view").description("View a zero agent").
|
|
|
22445
21729
|
console.log();
|
|
22446
21730
|
const result = await getZeroAgentInstructions(name);
|
|
22447
21731
|
if (result.content) {
|
|
22448
|
-
console.log(
|
|
21732
|
+
console.log(chalk62.dim("\u2500\u2500 Instructions \u2500\u2500"));
|
|
22449
21733
|
console.log(result.content);
|
|
22450
21734
|
} else {
|
|
22451
|
-
console.log(
|
|
21735
|
+
console.log(chalk62.dim("No instructions set"));
|
|
21736
|
+
}
|
|
21737
|
+
}
|
|
21738
|
+
}
|
|
21739
|
+
)
|
|
21740
|
+
);
|
|
21741
|
+
|
|
21742
|
+
// src/commands/zero/agent/list.ts
|
|
21743
|
+
import { Command as Command70 } from "commander";
|
|
21744
|
+
import chalk63 from "chalk";
|
|
21745
|
+
var listCommand9 = new Command70().name("list").alias("ls").description("List all zero agents").action(
|
|
21746
|
+
withErrorHandler(async () => {
|
|
21747
|
+
const agents = await listZeroAgents();
|
|
21748
|
+
if (agents.length === 0) {
|
|
21749
|
+
console.log(chalk63.dim("No zero agents found"));
|
|
21750
|
+
console.log(
|
|
21751
|
+
chalk63.dim(
|
|
21752
|
+
' Create one with: vm0 zero agent create --connectors github --display-name "My Agent"'
|
|
21753
|
+
)
|
|
21754
|
+
);
|
|
21755
|
+
return;
|
|
21756
|
+
}
|
|
21757
|
+
const nameWidth = Math.max(4, ...agents.map((a) => a.name.length));
|
|
21758
|
+
const displayWidth = Math.max(
|
|
21759
|
+
12,
|
|
21760
|
+
...agents.map((a) => (a.displayName ?? "").length)
|
|
21761
|
+
);
|
|
21762
|
+
const header = [
|
|
21763
|
+
"NAME".padEnd(nameWidth),
|
|
21764
|
+
"DISPLAY NAME".padEnd(displayWidth),
|
|
21765
|
+
"CONNECTORS"
|
|
21766
|
+
].join(" ");
|
|
21767
|
+
console.log(chalk63.dim(header));
|
|
21768
|
+
for (const agent of agents) {
|
|
21769
|
+
const row = [
|
|
21770
|
+
agent.name.padEnd(nameWidth),
|
|
21771
|
+
(agent.displayName ?? "-").padEnd(displayWidth),
|
|
21772
|
+
agent.connectors.join(", ") || "-"
|
|
21773
|
+
].join(" ");
|
|
21774
|
+
console.log(row);
|
|
21775
|
+
}
|
|
21776
|
+
})
|
|
21777
|
+
);
|
|
21778
|
+
|
|
21779
|
+
// src/commands/zero/agent/delete.ts
|
|
21780
|
+
import { Command as Command71 } from "commander";
|
|
21781
|
+
import chalk64 from "chalk";
|
|
21782
|
+
var deleteCommand2 = new Command71().name("delete").alias("rm").description("Delete a zero agent").argument("<name>", "Agent name").option("-y, --yes", "Skip confirmation prompt").action(
|
|
21783
|
+
withErrorHandler(async (name, options) => {
|
|
21784
|
+
await getZeroAgent(name);
|
|
21785
|
+
if (!options.yes) {
|
|
21786
|
+
if (!isInteractive()) {
|
|
21787
|
+
throw new Error("--yes flag is required in non-interactive mode");
|
|
21788
|
+
}
|
|
21789
|
+
const confirmed = await promptConfirm(
|
|
21790
|
+
`Delete zero agent '${name}'?`,
|
|
21791
|
+
false
|
|
21792
|
+
);
|
|
21793
|
+
if (!confirmed) {
|
|
21794
|
+
console.log(chalk64.dim("Cancelled"));
|
|
21795
|
+
return;
|
|
21796
|
+
}
|
|
21797
|
+
}
|
|
21798
|
+
await deleteZeroAgent(name);
|
|
21799
|
+
console.log(chalk64.green(`\u2713 Zero agent '${name}' deleted`));
|
|
21800
|
+
})
|
|
21801
|
+
);
|
|
21802
|
+
|
|
21803
|
+
// src/commands/zero/agent/index.ts
|
|
21804
|
+
var agentCommand = new Command72("agent").description("Manage zero agents").addCommand(createCommand).addCommand(editCommand).addCommand(viewCommand).addCommand(listCommand9).addCommand(deleteCommand2);
|
|
21805
|
+
|
|
21806
|
+
// src/commands/zero/connector/index.ts
|
|
21807
|
+
import { Command as Command77 } from "commander";
|
|
21808
|
+
|
|
21809
|
+
// src/commands/zero/connector/connect.ts
|
|
21810
|
+
import { Command as Command73 } from "commander";
|
|
21811
|
+
import chalk66 from "chalk";
|
|
21812
|
+
|
|
21813
|
+
// src/lib/computer/start-services.ts
|
|
21814
|
+
import { spawn as spawn2 } from "child_process";
|
|
21815
|
+
import { access as access2, constants } from "fs/promises";
|
|
21816
|
+
import { createServer } from "net";
|
|
21817
|
+
import { homedir as homedir4 } from "os";
|
|
21818
|
+
import { join as join10 } from "path";
|
|
21819
|
+
import chalk65 from "chalk";
|
|
21820
|
+
|
|
21821
|
+
// src/lib/computer/ngrok.ts
|
|
21822
|
+
import ngrok from "@ngrok/ngrok";
|
|
21823
|
+
async function startNgrokTunnels(ngrokToken, endpointPrefix, webdavPort, cdpPort) {
|
|
21824
|
+
await ngrok.forward({
|
|
21825
|
+
addr: `localhost:${webdavPort}`,
|
|
21826
|
+
authtoken: ngrokToken,
|
|
21827
|
+
domain: `webdav.${endpointPrefix}.internal`
|
|
21828
|
+
});
|
|
21829
|
+
await ngrok.forward({
|
|
21830
|
+
addr: `localhost:${cdpPort}`,
|
|
21831
|
+
authtoken: ngrokToken,
|
|
21832
|
+
domain: `chrome.${endpointPrefix}.internal`
|
|
21833
|
+
});
|
|
21834
|
+
}
|
|
21835
|
+
async function stopNgrokTunnels() {
|
|
21836
|
+
await ngrok.kill();
|
|
21837
|
+
}
|
|
21838
|
+
|
|
21839
|
+
// src/lib/computer/start-services.ts
|
|
21840
|
+
var CHROME_CANDIDATES = [
|
|
21841
|
+
// macOS absolute paths
|
|
21842
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
21843
|
+
"/Applications/Google Chrome Canary.app/Contents/MacOS/Google Chrome Canary",
|
|
21844
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
21845
|
+
// Linux / PATH-based
|
|
21846
|
+
"google-chrome",
|
|
21847
|
+
"google-chrome-stable",
|
|
21848
|
+
"chromium-browser",
|
|
21849
|
+
"chromium",
|
|
21850
|
+
"chrome"
|
|
21851
|
+
];
|
|
21852
|
+
async function getRandomPort() {
|
|
21853
|
+
return new Promise((resolve, reject) => {
|
|
21854
|
+
const server = createServer();
|
|
21855
|
+
server.listen(0, "127.0.0.1", () => {
|
|
21856
|
+
const { port } = server.address();
|
|
21857
|
+
server.close(() => resolve(port));
|
|
21858
|
+
});
|
|
21859
|
+
server.on("error", reject);
|
|
21860
|
+
});
|
|
21861
|
+
}
|
|
21862
|
+
async function findBinary(...candidates) {
|
|
21863
|
+
for (const candidate of candidates) {
|
|
21864
|
+
if (candidate.startsWith("/")) {
|
|
21865
|
+
try {
|
|
21866
|
+
await access2(candidate, constants.X_OK);
|
|
21867
|
+
return candidate;
|
|
21868
|
+
} catch {
|
|
21869
|
+
}
|
|
21870
|
+
} else {
|
|
21871
|
+
const found = await new Promise((resolve) => {
|
|
21872
|
+
const child = spawn2("which", [candidate]);
|
|
21873
|
+
child.on("close", (code) => resolve(code === 0));
|
|
21874
|
+
});
|
|
21875
|
+
if (found) return candidate;
|
|
21876
|
+
}
|
|
21877
|
+
}
|
|
21878
|
+
return null;
|
|
21879
|
+
}
|
|
21880
|
+
async function checkComputerDependencies() {
|
|
21881
|
+
const wsgidavBinary = await findBinary("wsgidav");
|
|
21882
|
+
if (!wsgidavBinary) {
|
|
21883
|
+
throw new Error(
|
|
21884
|
+
"wsgidav not found\n\nInstall with: pip install wsgidav[cheroot]"
|
|
21885
|
+
);
|
|
21886
|
+
}
|
|
21887
|
+
const chromeBinary = await findBinary(...CHROME_CANDIDATES);
|
|
21888
|
+
if (!chromeBinary) {
|
|
21889
|
+
throw new Error("Chrome not found\n\nInstall Google Chrome or Chromium");
|
|
21890
|
+
}
|
|
21891
|
+
}
|
|
21892
|
+
async function startComputerServices(credentials) {
|
|
21893
|
+
console.log(chalk65.cyan("Starting computer connector services..."));
|
|
21894
|
+
const wsgidavBinary = await findBinary("wsgidav");
|
|
21895
|
+
if (!wsgidavBinary) {
|
|
21896
|
+
throw new Error(
|
|
21897
|
+
"wsgidav not found\n\nInstall with: pip install wsgidav[cheroot]"
|
|
21898
|
+
);
|
|
21899
|
+
}
|
|
21900
|
+
const chromeBinary = await findBinary(...CHROME_CANDIDATES);
|
|
21901
|
+
if (!chromeBinary) {
|
|
21902
|
+
throw new Error("Chrome not found\n\nInstall Google Chrome or Chromium");
|
|
21903
|
+
}
|
|
21904
|
+
const webdavPort = await getRandomPort();
|
|
21905
|
+
const cdpPort = await getRandomPort();
|
|
21906
|
+
const downloadsPath = join10(homedir4(), "Downloads");
|
|
21907
|
+
const wsgidav = spawn2(
|
|
21908
|
+
wsgidavBinary,
|
|
21909
|
+
[
|
|
21910
|
+
"--host=127.0.0.1",
|
|
21911
|
+
`--port=${webdavPort}`,
|
|
21912
|
+
`--root=${downloadsPath}`,
|
|
21913
|
+
"--auth=anonymous",
|
|
21914
|
+
"--no-config"
|
|
21915
|
+
],
|
|
21916
|
+
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
21917
|
+
);
|
|
21918
|
+
wsgidav.stdout?.on("data", (data) => process.stdout.write(data));
|
|
21919
|
+
wsgidav.stderr?.on("data", (data) => process.stderr.write(data));
|
|
21920
|
+
console.log(chalk65.green("\u2713 WebDAV server started"));
|
|
21921
|
+
const chrome = spawn2(
|
|
21922
|
+
chromeBinary,
|
|
21923
|
+
[
|
|
21924
|
+
`--remote-debugging-port=${cdpPort}`,
|
|
21925
|
+
"--remote-debugging-address=127.0.0.1",
|
|
21926
|
+
"--headless=new",
|
|
21927
|
+
"--no-sandbox",
|
|
21928
|
+
"--disable-gpu"
|
|
21929
|
+
],
|
|
21930
|
+
{ stdio: ["ignore", "pipe", "pipe"] }
|
|
21931
|
+
);
|
|
21932
|
+
chrome.stdout?.on("data", (data) => process.stdout.write(data));
|
|
21933
|
+
chrome.stderr?.on("data", (data) => process.stderr.write(data));
|
|
21934
|
+
console.log(chalk65.green("\u2713 Chrome started"));
|
|
21935
|
+
try {
|
|
21936
|
+
await startNgrokTunnels(
|
|
21937
|
+
credentials.ngrokToken,
|
|
21938
|
+
credentials.endpointPrefix,
|
|
21939
|
+
webdavPort,
|
|
21940
|
+
cdpPort
|
|
21941
|
+
);
|
|
21942
|
+
console.log(
|
|
21943
|
+
chalk65.green(
|
|
21944
|
+
`\u2713 ngrok tunnels: webdav.${credentials.domain}, chrome.${credentials.domain}`
|
|
21945
|
+
)
|
|
21946
|
+
);
|
|
21947
|
+
console.log();
|
|
21948
|
+
console.log(chalk65.green("\u2713 Computer connector active"));
|
|
21949
|
+
console.log(` WebDAV: ~/Downloads \u2192 webdav.${credentials.domain}`);
|
|
21950
|
+
console.log(
|
|
21951
|
+
` Chrome CDP: port ${cdpPort} \u2192 chrome.${credentials.domain}`
|
|
21952
|
+
);
|
|
21953
|
+
console.log();
|
|
21954
|
+
console.log(chalk65.dim("Press ^C twice to disconnect"));
|
|
21955
|
+
console.log();
|
|
21956
|
+
let sigintCount = 0;
|
|
21957
|
+
await new Promise((resolve) => {
|
|
21958
|
+
const keepAlive = setInterval(() => {
|
|
21959
|
+
}, 6e4);
|
|
21960
|
+
const done = () => {
|
|
21961
|
+
clearInterval(keepAlive);
|
|
21962
|
+
process.removeListener("SIGINT", onSigint);
|
|
21963
|
+
resolve();
|
|
21964
|
+
};
|
|
21965
|
+
const onSigint = () => {
|
|
21966
|
+
sigintCount++;
|
|
21967
|
+
if (sigintCount === 1) {
|
|
21968
|
+
console.log(chalk65.dim("\nPress ^C again to disconnect and exit..."));
|
|
21969
|
+
} else {
|
|
21970
|
+
done();
|
|
22452
21971
|
}
|
|
22453
|
-
}
|
|
22454
|
-
|
|
22455
|
-
|
|
22456
|
-
);
|
|
22457
|
-
|
|
22458
|
-
|
|
22459
|
-
|
|
22460
|
-
|
|
22461
|
-
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
|
|
22465
|
-
|
|
22466
|
-
console.log(
|
|
22467
|
-
chalk69.dim(
|
|
22468
|
-
' Create one with: vm0 zero agent create --connectors github --display-name "My Agent"'
|
|
22469
|
-
)
|
|
22470
|
-
);
|
|
22471
|
-
return;
|
|
22472
|
-
}
|
|
22473
|
-
const nameWidth = Math.max(4, ...agents.map((a) => a.name.length));
|
|
22474
|
-
const displayWidth = Math.max(
|
|
22475
|
-
12,
|
|
22476
|
-
...agents.map((a) => (a.displayName ?? "").length)
|
|
22477
|
-
);
|
|
22478
|
-
const header = [
|
|
22479
|
-
"NAME".padEnd(nameWidth),
|
|
22480
|
-
"DISPLAY NAME".padEnd(displayWidth),
|
|
22481
|
-
"CONNECTORS"
|
|
22482
|
-
].join(" ");
|
|
22483
|
-
console.log(chalk69.dim(header));
|
|
22484
|
-
for (const agent of agents) {
|
|
22485
|
-
const row = [
|
|
22486
|
-
agent.name.padEnd(nameWidth),
|
|
22487
|
-
(agent.displayName ?? "-").padEnd(displayWidth),
|
|
22488
|
-
agent.connectors.join(", ") || "-"
|
|
22489
|
-
].join(" ");
|
|
22490
|
-
console.log(row);
|
|
22491
|
-
}
|
|
22492
|
-
})
|
|
22493
|
-
);
|
|
22494
|
-
|
|
22495
|
-
// src/commands/zero/agent/delete.ts
|
|
22496
|
-
import { Command as Command77 } from "commander";
|
|
22497
|
-
import chalk70 from "chalk";
|
|
22498
|
-
var deleteCommand2 = new Command77().name("delete").alias("rm").description("Delete a zero agent").argument("<name>", "Agent name").option("-y, --yes", "Skip confirmation prompt").action(
|
|
22499
|
-
withErrorHandler(async (name, options) => {
|
|
22500
|
-
await getZeroAgent(name);
|
|
22501
|
-
if (!options.yes) {
|
|
22502
|
-
if (!isInteractive()) {
|
|
22503
|
-
throw new Error("--yes flag is required in non-interactive mode");
|
|
22504
|
-
}
|
|
22505
|
-
const confirmed = await promptConfirm(
|
|
22506
|
-
`Delete zero agent '${name}'?`,
|
|
22507
|
-
false
|
|
22508
|
-
);
|
|
22509
|
-
if (!confirmed) {
|
|
22510
|
-
console.log(chalk70.dim("Cancelled"));
|
|
22511
|
-
return;
|
|
22512
|
-
}
|
|
22513
|
-
}
|
|
22514
|
-
await deleteZeroAgent(name);
|
|
22515
|
-
console.log(chalk70.green(`\u2713 Zero agent '${name}' deleted`));
|
|
22516
|
-
})
|
|
22517
|
-
);
|
|
22518
|
-
|
|
22519
|
-
// src/commands/zero/agent/index.ts
|
|
22520
|
-
var agentCommand = new Command78("agent").description("Manage zero agents").addCommand(createCommand).addCommand(editCommand).addCommand(viewCommand).addCommand(listCommand10).addCommand(deleteCommand2);
|
|
22521
|
-
|
|
22522
|
-
// src/commands/zero/connector/index.ts
|
|
22523
|
-
import { Command as Command83 } from "commander";
|
|
21972
|
+
};
|
|
21973
|
+
process.on("SIGINT", onSigint);
|
|
21974
|
+
process.once("SIGTERM", done);
|
|
21975
|
+
});
|
|
21976
|
+
} finally {
|
|
21977
|
+
console.log();
|
|
21978
|
+
console.log(chalk65.cyan("Stopping services..."));
|
|
21979
|
+
wsgidav.kill("SIGTERM");
|
|
21980
|
+
chrome.kill("SIGTERM");
|
|
21981
|
+
await stopNgrokTunnels();
|
|
21982
|
+
console.log(chalk65.green("\u2713 Services stopped"));
|
|
21983
|
+
}
|
|
21984
|
+
}
|
|
22524
21985
|
|
|
22525
21986
|
// src/commands/zero/connector/connect.ts
|
|
22526
|
-
|
|
22527
|
-
import chalk71 from "chalk";
|
|
22528
|
-
function delay3(ms) {
|
|
21987
|
+
function delay2(ms) {
|
|
22529
21988
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
22530
21989
|
}
|
|
22531
|
-
function
|
|
21990
|
+
function renderHelpText(text) {
|
|
22532
21991
|
return text.replace(
|
|
22533
21992
|
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
22534
|
-
(_m, label, url) => `${label} (${
|
|
22535
|
-
).replace(/\*\*([^*]+)\*\*/g, (_m, content) =>
|
|
21993
|
+
(_m, label, url) => `${label} (${chalk66.cyan(url)})`
|
|
21994
|
+
).replace(/\*\*([^*]+)\*\*/g, (_m, content) => chalk66.bold(content)).replace(
|
|
22536
21995
|
/^> (.+)$/gm,
|
|
22537
|
-
(_m, content) =>
|
|
21996
|
+
(_m, content) => chalk66.yellow(` ${content}`)
|
|
22538
21997
|
);
|
|
22539
21998
|
}
|
|
22540
|
-
async function
|
|
21999
|
+
async function connectViaApiToken(connectorType, tokenValue) {
|
|
22541
22000
|
const config = CONNECTOR_TYPES[connectorType];
|
|
22542
22001
|
const apiTokenConfig = config.authMethods["api-token"];
|
|
22543
22002
|
if (!apiTokenConfig) {
|
|
@@ -22553,13 +22012,13 @@ async function connectViaApiToken2(connectorType, tokenValue) {
|
|
|
22553
22012
|
} else {
|
|
22554
22013
|
if (apiTokenConfig.helpText) {
|
|
22555
22014
|
console.log();
|
|
22556
|
-
console.log(
|
|
22015
|
+
console.log(renderHelpText(apiTokenConfig.helpText));
|
|
22557
22016
|
console.log();
|
|
22558
22017
|
}
|
|
22559
22018
|
for (const [secretName, secretConfig] of secretEntries) {
|
|
22560
22019
|
if (!secretConfig.required) continue;
|
|
22561
22020
|
const value = await promptPassword(
|
|
22562
|
-
`${secretConfig.label}${secretConfig.placeholder ?
|
|
22021
|
+
`${secretConfig.label}${secretConfig.placeholder ? chalk66.dim(` (${secretConfig.placeholder})`) : ""}:`
|
|
22563
22022
|
);
|
|
22564
22023
|
if (!value) {
|
|
22565
22024
|
throw new Error("Cancelled");
|
|
@@ -22575,20 +22034,20 @@ async function connectViaApiToken2(connectorType, tokenValue) {
|
|
|
22575
22034
|
});
|
|
22576
22035
|
}
|
|
22577
22036
|
console.log(
|
|
22578
|
-
|
|
22037
|
+
chalk66.green(`
|
|
22579
22038
|
\u2713 ${config.label} connected successfully via API token!`)
|
|
22580
22039
|
);
|
|
22581
22040
|
}
|
|
22582
|
-
async function
|
|
22041
|
+
async function connectComputer() {
|
|
22583
22042
|
await checkComputerDependencies();
|
|
22584
|
-
console.log(
|
|
22043
|
+
console.log(chalk66.cyan("Setting up computer connector..."));
|
|
22585
22044
|
const credentials = await createZeroComputerConnector();
|
|
22586
22045
|
await startComputerServices(credentials);
|
|
22587
|
-
console.log(
|
|
22046
|
+
console.log(chalk66.cyan("Disconnecting computer connector..."));
|
|
22588
22047
|
await deleteZeroComputerConnector();
|
|
22589
|
-
console.log(
|
|
22048
|
+
console.log(chalk66.green("\u2713 Disconnected computer"));
|
|
22590
22049
|
}
|
|
22591
|
-
async function
|
|
22050
|
+
async function resolveAuthMethod(connectorType, tokenFlag) {
|
|
22592
22051
|
const config = CONNECTOR_TYPES[connectorType];
|
|
22593
22052
|
const oauthFlag = CONNECTOR_TYPES[connectorType].featureFlag;
|
|
22594
22053
|
const oauthAvailable = "oauth" in config.authMethods && (!oauthFlag || await isFeatureEnabled(oauthFlag));
|
|
@@ -22623,13 +22082,13 @@ async function resolveAuthMethod2(connectorType, tokenFlag) {
|
|
|
22623
22082
|
`${config.label} has no available auth methods. OAuth may not be enabled yet.`
|
|
22624
22083
|
);
|
|
22625
22084
|
}
|
|
22626
|
-
async function
|
|
22627
|
-
console.log(`Connecting ${
|
|
22085
|
+
async function connectViaOAuth(connectorType) {
|
|
22086
|
+
console.log(`Connecting ${chalk66.cyan(connectorType)}...`);
|
|
22628
22087
|
const session = await createZeroConnectorSession(connectorType);
|
|
22629
22088
|
const apiUrl = await getBaseUrl();
|
|
22630
22089
|
const verificationUrl = `${apiUrl}${session.verificationUrl}`;
|
|
22631
|
-
console.log(
|
|
22632
|
-
console.log(
|
|
22090
|
+
console.log(chalk66.green("\nSession created"));
|
|
22091
|
+
console.log(chalk66.cyan(`
|
|
22633
22092
|
To connect, visit: ${verificationUrl}`));
|
|
22634
22093
|
console.log(
|
|
22635
22094
|
`
|
|
@@ -22642,14 +22101,14 @@ The session expires in ${Math.floor(session.expiresIn / 60)} minutes.`
|
|
|
22642
22101
|
let isFirstPoll = true;
|
|
22643
22102
|
while (Date.now() - startTime < maxWaitTime) {
|
|
22644
22103
|
if (!isFirstPoll) {
|
|
22645
|
-
await
|
|
22104
|
+
await delay2(pollInterval);
|
|
22646
22105
|
}
|
|
22647
22106
|
isFirstPoll = false;
|
|
22648
22107
|
const status = await getZeroConnectorSession(connectorType, session.id);
|
|
22649
22108
|
switch (status.status) {
|
|
22650
22109
|
case "complete":
|
|
22651
22110
|
console.log(
|
|
22652
|
-
|
|
22111
|
+
chalk66.green(`
|
|
22653
22112
|
|
|
22654
22113
|
${connectorType} connected successfully!`)
|
|
22655
22114
|
);
|
|
@@ -22661,80 +22120,195 @@ ${connectorType} connected successfully!`)
|
|
|
22661
22120
|
`Connection failed: ${status.errorMessage || "Unknown error"}`
|
|
22662
22121
|
);
|
|
22663
22122
|
case "pending":
|
|
22664
|
-
process.stdout.write(
|
|
22123
|
+
process.stdout.write(chalk66.dim("."));
|
|
22665
22124
|
break;
|
|
22666
22125
|
}
|
|
22667
22126
|
}
|
|
22668
|
-
throw new Error("Session timed out, please try again");
|
|
22127
|
+
throw new Error("Session timed out, please try again");
|
|
22128
|
+
}
|
|
22129
|
+
var connectCommand = new Command73().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(
|
|
22130
|
+
withErrorHandler(async (type2, options) => {
|
|
22131
|
+
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
22132
|
+
if (!parseResult.success) {
|
|
22133
|
+
const available = Object.keys(CONNECTOR_TYPES).join(", ");
|
|
22134
|
+
throw new Error(`Unknown connector type: ${type2}`, {
|
|
22135
|
+
cause: new Error(`Available connectors: ${available}`)
|
|
22136
|
+
});
|
|
22137
|
+
}
|
|
22138
|
+
const connectorType = parseResult.data;
|
|
22139
|
+
if (connectorType === "computer") {
|
|
22140
|
+
await connectComputer();
|
|
22141
|
+
return;
|
|
22142
|
+
}
|
|
22143
|
+
const authMethod = await resolveAuthMethod(connectorType, options.token);
|
|
22144
|
+
if (authMethod === "api-token") {
|
|
22145
|
+
await connectViaApiToken(connectorType, options.token);
|
|
22146
|
+
return;
|
|
22147
|
+
}
|
|
22148
|
+
await connectViaOAuth(connectorType);
|
|
22149
|
+
})
|
|
22150
|
+
);
|
|
22151
|
+
|
|
22152
|
+
// src/commands/zero/connector/list.ts
|
|
22153
|
+
import { Command as Command74 } from "commander";
|
|
22154
|
+
import chalk67 from "chalk";
|
|
22155
|
+
var listCommand10 = new Command74().name("list").alias("ls").description("List all connectors and their status").action(
|
|
22156
|
+
withErrorHandler(async () => {
|
|
22157
|
+
const result = await listZeroConnectors();
|
|
22158
|
+
const connectedMap = new Map(result.connectors.map((c32) => [c32.type, c32]));
|
|
22159
|
+
const allTypesRaw = Object.keys(CONNECTOR_TYPES);
|
|
22160
|
+
const allTypes = [];
|
|
22161
|
+
for (const type2 of allTypesRaw) {
|
|
22162
|
+
const flag = CONNECTOR_TYPES[type2].featureFlag;
|
|
22163
|
+
const hasApiToken = "api-token" in CONNECTOR_TYPES[type2].authMethods;
|
|
22164
|
+
if (flag && !await isFeatureEnabled(flag) && !hasApiToken) {
|
|
22165
|
+
continue;
|
|
22166
|
+
}
|
|
22167
|
+
allTypes.push(type2);
|
|
22168
|
+
}
|
|
22169
|
+
const typeWidth = Math.max(4, ...allTypes.map((t) => t.length));
|
|
22170
|
+
const statusText = "STATUS";
|
|
22171
|
+
const statusWidth = statusText.length;
|
|
22172
|
+
const header = [
|
|
22173
|
+
"TYPE".padEnd(typeWidth),
|
|
22174
|
+
statusText.padEnd(statusWidth),
|
|
22175
|
+
"ACCOUNT"
|
|
22176
|
+
].join(" ");
|
|
22177
|
+
console.log(chalk67.dim(header));
|
|
22178
|
+
for (const type2 of allTypes) {
|
|
22179
|
+
const connector = connectedMap.get(type2);
|
|
22180
|
+
const scopeMismatch = connector !== void 0 && connector.authMethod === "oauth" && !hasRequiredScopes(type2, connector.oauthScopes);
|
|
22181
|
+
const status = connector ? connector.needsReconnect ? chalk67.yellow("!".padEnd(statusWidth)) : scopeMismatch ? chalk67.yellow("!".padEnd(statusWidth)) : chalk67.green("\u2713".padEnd(statusWidth)) : chalk67.dim("-".padEnd(statusWidth));
|
|
22182
|
+
const account = connector?.needsReconnect ? chalk67.yellow("(reconnect needed)") : scopeMismatch ? chalk67.yellow("(permissions update available)") : connector?.externalUsername ? `@${connector.externalUsername}` : chalk67.dim("-");
|
|
22183
|
+
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
22184
|
+
console.log(row);
|
|
22185
|
+
}
|
|
22186
|
+
console.log();
|
|
22187
|
+
console.log(chalk67.dim("To connect a service:"));
|
|
22188
|
+
console.log(chalk67.dim(" vm0 zero connector connect <type>"));
|
|
22189
|
+
})
|
|
22190
|
+
);
|
|
22191
|
+
|
|
22192
|
+
// src/commands/zero/connector/status.ts
|
|
22193
|
+
import { Command as Command75 } from "commander";
|
|
22194
|
+
import chalk68 from "chalk";
|
|
22195
|
+
|
|
22196
|
+
// src/lib/domain/schedule-utils.ts
|
|
22197
|
+
function formatRelativeTime2(dateStr) {
|
|
22198
|
+
if (!dateStr) return "-";
|
|
22199
|
+
const date = new Date(dateStr);
|
|
22200
|
+
const now = /* @__PURE__ */ new Date();
|
|
22201
|
+
const diffMs = date.getTime() - now.getTime();
|
|
22202
|
+
const diffAbs = Math.abs(diffMs);
|
|
22203
|
+
const minutes = Math.floor(diffAbs / (1e3 * 60));
|
|
22204
|
+
const hours = Math.floor(diffAbs / (1e3 * 60 * 60));
|
|
22205
|
+
const days = Math.floor(diffAbs / (1e3 * 60 * 60 * 24));
|
|
22206
|
+
const isPast = diffMs < 0;
|
|
22207
|
+
if (days > 0) {
|
|
22208
|
+
return isPast ? `${days}d ago` : `in ${days}d`;
|
|
22209
|
+
} else if (hours > 0) {
|
|
22210
|
+
return isPast ? `${hours}h ago` : `in ${hours}h`;
|
|
22211
|
+
} else if (minutes > 0) {
|
|
22212
|
+
return isPast ? `${minutes}m ago` : `in ${minutes}m`;
|
|
22213
|
+
} else {
|
|
22214
|
+
return isPast ? "just now" : "soon";
|
|
22215
|
+
}
|
|
22216
|
+
}
|
|
22217
|
+
function formatDateTime(dateStr) {
|
|
22218
|
+
if (!dateStr) return "-";
|
|
22219
|
+
const date = new Date(dateStr);
|
|
22220
|
+
const year = date.getFullYear();
|
|
22221
|
+
const month = String(date.getMonth() + 1).padStart(2, "0");
|
|
22222
|
+
const day = String(date.getDate()).padStart(2, "0");
|
|
22223
|
+
const hours = String(date.getHours()).padStart(2, "0");
|
|
22224
|
+
const minutes = String(date.getMinutes()).padStart(2, "0");
|
|
22225
|
+
const formatted = `${year}-${month}-${day} ${hours}:${minutes}`;
|
|
22226
|
+
const relative2 = formatRelativeTime2(dateStr);
|
|
22227
|
+
return `${formatted} (${relative2})`;
|
|
22228
|
+
}
|
|
22229
|
+
function generateCronExpression(frequency, time, day) {
|
|
22230
|
+
const [hourStr, minuteStr] = time.split(":");
|
|
22231
|
+
const hour = parseInt(hourStr ?? "0", 10);
|
|
22232
|
+
const minute = parseInt(minuteStr ?? "0", 10);
|
|
22233
|
+
switch (frequency) {
|
|
22234
|
+
case "daily":
|
|
22235
|
+
return `${minute} ${hour} * * *`;
|
|
22236
|
+
case "weekly":
|
|
22237
|
+
return `${minute} ${hour} * * ${day ?? 1}`;
|
|
22238
|
+
case "monthly":
|
|
22239
|
+
return `${minute} ${hour} ${day ?? 1} * *`;
|
|
22240
|
+
}
|
|
22241
|
+
}
|
|
22242
|
+
function detectTimezone() {
|
|
22243
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
22244
|
+
}
|
|
22245
|
+
function validateTimeFormat(time) {
|
|
22246
|
+
const match = time.match(/^(\d{1,2}):(\d{2})$/);
|
|
22247
|
+
if (!match) {
|
|
22248
|
+
return "Invalid format. Use HH:MM (e.g., 09:00)";
|
|
22249
|
+
}
|
|
22250
|
+
const hour = parseInt(match[1], 10);
|
|
22251
|
+
const minute = parseInt(match[2], 10);
|
|
22252
|
+
if (hour < 0 || hour > 23) {
|
|
22253
|
+
return "Hour must be 0-23";
|
|
22254
|
+
}
|
|
22255
|
+
if (minute < 0 || minute > 59) {
|
|
22256
|
+
return "Minute must be 0-59";
|
|
22257
|
+
}
|
|
22258
|
+
if (minute % 5 !== 0) {
|
|
22259
|
+
return "Minute must be a multiple of 5 (0, 5, 10, ..., 55)";
|
|
22260
|
+
}
|
|
22261
|
+
return true;
|
|
22262
|
+
}
|
|
22263
|
+
function validateDateFormat(date) {
|
|
22264
|
+
const match = date.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
22265
|
+
if (!match) {
|
|
22266
|
+
return "Invalid format. Use YYYY-MM-DD (e.g., 2025-01-15)";
|
|
22267
|
+
}
|
|
22268
|
+
const year = parseInt(match[1], 10);
|
|
22269
|
+
const month = parseInt(match[2], 10);
|
|
22270
|
+
const day = parseInt(match[3], 10);
|
|
22271
|
+
if (year < 2e3 || year > 2100) {
|
|
22272
|
+
return "Year must be between 2000 and 2100";
|
|
22273
|
+
}
|
|
22274
|
+
if (month < 1 || month > 12) {
|
|
22275
|
+
return "Month must be 1-12";
|
|
22276
|
+
}
|
|
22277
|
+
if (day < 1 || day > 31) {
|
|
22278
|
+
return "Day must be 1-31";
|
|
22279
|
+
}
|
|
22280
|
+
const testDate = new Date(year, month - 1, day);
|
|
22281
|
+
if (testDate.getFullYear() !== year || testDate.getMonth() !== month - 1 || testDate.getDate() !== day) {
|
|
22282
|
+
return "Invalid date";
|
|
22283
|
+
}
|
|
22284
|
+
return true;
|
|
22285
|
+
}
|
|
22286
|
+
function getTomorrowDateLocal() {
|
|
22287
|
+
const tomorrow = /* @__PURE__ */ new Date();
|
|
22288
|
+
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
22289
|
+
const year = tomorrow.getFullYear();
|
|
22290
|
+
const month = String(tomorrow.getMonth() + 1).padStart(2, "0");
|
|
22291
|
+
const day = String(tomorrow.getDate()).padStart(2, "0");
|
|
22292
|
+
return `${year}-${month}-${day}`;
|
|
22293
|
+
}
|
|
22294
|
+
function getCurrentTimeLocal() {
|
|
22295
|
+
const now = /* @__PURE__ */ new Date();
|
|
22296
|
+
const hours = String(now.getHours()).padStart(2, "0");
|
|
22297
|
+
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
22298
|
+
return `${hours}:${minutes}`;
|
|
22299
|
+
}
|
|
22300
|
+
function toISODateTime(dateTimeStr) {
|
|
22301
|
+
if (dateTimeStr.includes("T") && dateTimeStr.endsWith("Z")) {
|
|
22302
|
+
return dateTimeStr;
|
|
22303
|
+
}
|
|
22304
|
+
const isoStr = dateTimeStr.replace(" ", "T") + ":00";
|
|
22305
|
+
const date = new Date(isoStr);
|
|
22306
|
+
return date.toISOString();
|
|
22669
22307
|
}
|
|
22670
|
-
var connectCommand2 = new Command79().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
|
-
withErrorHandler(async (type2, options) => {
|
|
22672
|
-
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
22673
|
-
if (!parseResult.success) {
|
|
22674
|
-
const available = Object.keys(CONNECTOR_TYPES).join(", ");
|
|
22675
|
-
throw new Error(`Unknown connector type: ${type2}`, {
|
|
22676
|
-
cause: new Error(`Available connectors: ${available}`)
|
|
22677
|
-
});
|
|
22678
|
-
}
|
|
22679
|
-
const connectorType = parseResult.data;
|
|
22680
|
-
if (connectorType === "computer") {
|
|
22681
|
-
await connectComputer2();
|
|
22682
|
-
return;
|
|
22683
|
-
}
|
|
22684
|
-
const authMethod = await resolveAuthMethod2(connectorType, options.token);
|
|
22685
|
-
if (authMethod === "api-token") {
|
|
22686
|
-
await connectViaApiToken2(connectorType, options.token);
|
|
22687
|
-
return;
|
|
22688
|
-
}
|
|
22689
|
-
await connectViaOAuth2(connectorType);
|
|
22690
|
-
})
|
|
22691
|
-
);
|
|
22692
|
-
|
|
22693
|
-
// src/commands/zero/connector/list.ts
|
|
22694
|
-
import { Command as Command80 } from "commander";
|
|
22695
|
-
import chalk72 from "chalk";
|
|
22696
|
-
var listCommand11 = new Command80().name("list").alias("ls").description("List all connectors and their status").action(
|
|
22697
|
-
withErrorHandler(async () => {
|
|
22698
|
-
const result = await listZeroConnectors();
|
|
22699
|
-
const connectedMap = new Map(result.connectors.map((c33) => [c33.type, c33]));
|
|
22700
|
-
const allTypesRaw = Object.keys(CONNECTOR_TYPES);
|
|
22701
|
-
const allTypes = [];
|
|
22702
|
-
for (const type2 of allTypesRaw) {
|
|
22703
|
-
const flag = CONNECTOR_TYPES[type2].featureFlag;
|
|
22704
|
-
const hasApiToken = "api-token" in CONNECTOR_TYPES[type2].authMethods;
|
|
22705
|
-
if (flag && !await isFeatureEnabled(flag) && !hasApiToken) {
|
|
22706
|
-
continue;
|
|
22707
|
-
}
|
|
22708
|
-
allTypes.push(type2);
|
|
22709
|
-
}
|
|
22710
|
-
const typeWidth = Math.max(4, ...allTypes.map((t) => t.length));
|
|
22711
|
-
const statusText = "STATUS";
|
|
22712
|
-
const statusWidth = statusText.length;
|
|
22713
|
-
const header = [
|
|
22714
|
-
"TYPE".padEnd(typeWidth),
|
|
22715
|
-
statusText.padEnd(statusWidth),
|
|
22716
|
-
"ACCOUNT"
|
|
22717
|
-
].join(" ");
|
|
22718
|
-
console.log(chalk72.dim(header));
|
|
22719
|
-
for (const type2 of allTypes) {
|
|
22720
|
-
const connector = connectedMap.get(type2);
|
|
22721
|
-
const scopeMismatch = connector !== void 0 && connector.authMethod === "oauth" && !hasRequiredScopes(type2, connector.oauthScopes);
|
|
22722
|
-
const status = connector ? connector.needsReconnect ? chalk72.yellow("!".padEnd(statusWidth)) : scopeMismatch ? chalk72.yellow("!".padEnd(statusWidth)) : chalk72.green("\u2713".padEnd(statusWidth)) : chalk72.dim("-".padEnd(statusWidth));
|
|
22723
|
-
const account = connector?.needsReconnect ? chalk72.yellow("(reconnect needed)") : scopeMismatch ? chalk72.yellow("(permissions update available)") : connector?.externalUsername ? `@${connector.externalUsername}` : chalk72.dim("-");
|
|
22724
|
-
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
22725
|
-
console.log(row);
|
|
22726
|
-
}
|
|
22727
|
-
console.log();
|
|
22728
|
-
console.log(chalk72.dim("To connect a service:"));
|
|
22729
|
-
console.log(chalk72.dim(" vm0 zero connector connect <type>"));
|
|
22730
|
-
})
|
|
22731
|
-
);
|
|
22732
22308
|
|
|
22733
22309
|
// src/commands/zero/connector/status.ts
|
|
22734
|
-
|
|
22735
|
-
|
|
22736
|
-
var LABEL_WIDTH2 = 16;
|
|
22737
|
-
var statusCommand7 = new Command81().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(
|
|
22310
|
+
var LABEL_WIDTH = 16;
|
|
22311
|
+
var statusCommand6 = new Command75().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(
|
|
22738
22312
|
withErrorHandler(async (type2) => {
|
|
22739
22313
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
22740
22314
|
if (!parseResult.success) {
|
|
@@ -22744,65 +22318,65 @@ var statusCommand7 = new Command81().name("status").description("Show detailed s
|
|
|
22744
22318
|
});
|
|
22745
22319
|
}
|
|
22746
22320
|
const connector = await getZeroConnector(parseResult.data);
|
|
22747
|
-
console.log(`Connector: ${
|
|
22321
|
+
console.log(`Connector: ${chalk68.cyan(type2)}`);
|
|
22748
22322
|
console.log();
|
|
22749
22323
|
if (connector) {
|
|
22750
22324
|
console.log(
|
|
22751
|
-
`${"Status:".padEnd(
|
|
22325
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${chalk68.green("connected")}`
|
|
22752
22326
|
);
|
|
22753
22327
|
console.log(
|
|
22754
|
-
`${"Account:".padEnd(
|
|
22328
|
+
`${"Account:".padEnd(LABEL_WIDTH)}@${connector.externalUsername}`
|
|
22755
22329
|
);
|
|
22756
22330
|
console.log(
|
|
22757
|
-
`${"Auth Method:".padEnd(
|
|
22331
|
+
`${"Auth Method:".padEnd(LABEL_WIDTH)}${connector.authMethod}`
|
|
22758
22332
|
);
|
|
22759
22333
|
if (connector.oauthScopes && connector.oauthScopes.length > 0) {
|
|
22760
22334
|
console.log(
|
|
22761
|
-
`${"OAuth Scopes:".padEnd(
|
|
22335
|
+
`${"OAuth Scopes:".padEnd(LABEL_WIDTH)}${connector.oauthScopes.join(", ")}`
|
|
22762
22336
|
);
|
|
22763
22337
|
}
|
|
22764
22338
|
if (connector.authMethod === "oauth" && !hasRequiredScopes(parseResult.data, connector.oauthScopes)) {
|
|
22765
22339
|
const diff = getScopeDiff(parseResult.data, connector.oauthScopes);
|
|
22766
22340
|
console.log(
|
|
22767
|
-
`${"Permissions:".padEnd(
|
|
22341
|
+
`${"Permissions:".padEnd(LABEL_WIDTH)}${chalk68.yellow("update available")}`
|
|
22768
22342
|
);
|
|
22769
22343
|
if (diff.addedScopes.length > 0) {
|
|
22770
22344
|
console.log(
|
|
22771
|
-
`${" Added:".padEnd(
|
|
22345
|
+
`${" Added:".padEnd(LABEL_WIDTH)}${diff.addedScopes.join(", ")}`
|
|
22772
22346
|
);
|
|
22773
22347
|
}
|
|
22774
22348
|
if (diff.removedScopes.length > 0) {
|
|
22775
22349
|
console.log(
|
|
22776
|
-
`${" Removed:".padEnd(
|
|
22350
|
+
`${" Removed:".padEnd(LABEL_WIDTH)}${diff.removedScopes.join(", ")}`
|
|
22777
22351
|
);
|
|
22778
22352
|
}
|
|
22779
22353
|
}
|
|
22780
22354
|
console.log(
|
|
22781
|
-
`${"Connected:".padEnd(
|
|
22355
|
+
`${"Connected:".padEnd(LABEL_WIDTH)}${formatDateTime(connector.createdAt)}`
|
|
22782
22356
|
);
|
|
22783
22357
|
if (connector.updatedAt !== connector.createdAt) {
|
|
22784
22358
|
console.log(
|
|
22785
|
-
`${"Last Updated:".padEnd(
|
|
22359
|
+
`${"Last Updated:".padEnd(LABEL_WIDTH)}${formatDateTime(connector.updatedAt)}`
|
|
22786
22360
|
);
|
|
22787
22361
|
}
|
|
22788
22362
|
console.log();
|
|
22789
|
-
console.log(
|
|
22790
|
-
console.log(
|
|
22363
|
+
console.log(chalk68.dim("To disconnect:"));
|
|
22364
|
+
console.log(chalk68.dim(` vm0 zero connector disconnect ${type2}`));
|
|
22791
22365
|
} else {
|
|
22792
22366
|
console.log(
|
|
22793
|
-
`${"Status:".padEnd(
|
|
22367
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${chalk68.dim("not connected")}`
|
|
22794
22368
|
);
|
|
22795
22369
|
console.log();
|
|
22796
|
-
console.log(
|
|
22797
|
-
console.log(
|
|
22370
|
+
console.log(chalk68.dim("To connect:"));
|
|
22371
|
+
console.log(chalk68.dim(` vm0 zero connector connect ${type2}`));
|
|
22798
22372
|
}
|
|
22799
22373
|
})
|
|
22800
22374
|
);
|
|
22801
22375
|
|
|
22802
22376
|
// src/commands/zero/connector/disconnect.ts
|
|
22803
|
-
import { Command as
|
|
22804
|
-
import
|
|
22805
|
-
var
|
|
22377
|
+
import { Command as Command76 } from "commander";
|
|
22378
|
+
import chalk69 from "chalk";
|
|
22379
|
+
var disconnectCommand = new Command76().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(
|
|
22806
22380
|
withErrorHandler(async (type2) => {
|
|
22807
22381
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
22808
22382
|
if (!parseResult.success) {
|
|
@@ -22813,19 +22387,152 @@ var disconnectCommand2 = new Command82().name("disconnect").description("Disconn
|
|
|
22813
22387
|
}
|
|
22814
22388
|
const connectorType = parseResult.data;
|
|
22815
22389
|
await deleteZeroConnector(connectorType);
|
|
22816
|
-
console.log(
|
|
22390
|
+
console.log(chalk69.green(`\u2713 Disconnected ${type2}`));
|
|
22817
22391
|
})
|
|
22818
22392
|
);
|
|
22819
22393
|
|
|
22820
22394
|
// src/commands/zero/connector/index.ts
|
|
22821
|
-
var zeroConnectorCommand = new
|
|
22395
|
+
var zeroConnectorCommand = new Command77().name("connector").description("Manage third-party service connections (zero)").addCommand(listCommand10).addCommand(statusCommand6).addCommand(connectCommand).addCommand(disconnectCommand);
|
|
22396
|
+
|
|
22397
|
+
// src/commands/zero/preference/index.ts
|
|
22398
|
+
import { Command as Command78 } from "commander";
|
|
22399
|
+
import chalk70 from "chalk";
|
|
22400
|
+
function detectTimezone2() {
|
|
22401
|
+
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
22402
|
+
}
|
|
22403
|
+
function isValidTimezone(timezone) {
|
|
22404
|
+
try {
|
|
22405
|
+
Intl.DateTimeFormat(void 0, { timeZone: timezone });
|
|
22406
|
+
return true;
|
|
22407
|
+
} catch {
|
|
22408
|
+
return false;
|
|
22409
|
+
}
|
|
22410
|
+
}
|
|
22411
|
+
function parseOnOff(flag, value) {
|
|
22412
|
+
const lower = value.toLowerCase();
|
|
22413
|
+
if (lower === "on" || lower === "true" || lower === "1") return true;
|
|
22414
|
+
if (lower === "off" || lower === "false" || lower === "0") return false;
|
|
22415
|
+
throw new Error(
|
|
22416
|
+
`Invalid value for --${flag}: "${value}". Use "on" or "off".`
|
|
22417
|
+
);
|
|
22418
|
+
}
|
|
22419
|
+
function displayPreferences(prefs) {
|
|
22420
|
+
console.log(chalk70.bold("Current preferences:"));
|
|
22421
|
+
console.log(
|
|
22422
|
+
` Timezone: ${prefs.timezone ? chalk70.cyan(prefs.timezone) : chalk70.dim("not set")}`
|
|
22423
|
+
);
|
|
22424
|
+
console.log(
|
|
22425
|
+
` Email notify: ${prefs.notifyEmail ? chalk70.green("on") : chalk70.dim("off")}`
|
|
22426
|
+
);
|
|
22427
|
+
console.log(
|
|
22428
|
+
` Slack notify: ${prefs.notifySlack ? chalk70.green("on") : chalk70.dim("off")}`
|
|
22429
|
+
);
|
|
22430
|
+
}
|
|
22431
|
+
function buildUpdates(opts) {
|
|
22432
|
+
const hasTimezone = opts.timezone !== void 0;
|
|
22433
|
+
const hasNotifyEmail = opts.notifyEmail !== void 0;
|
|
22434
|
+
const hasNotifySlack = opts.notifySlack !== void 0;
|
|
22435
|
+
if (!hasTimezone && !hasNotifyEmail && !hasNotifySlack) return null;
|
|
22436
|
+
const updates = {};
|
|
22437
|
+
if (hasTimezone) {
|
|
22438
|
+
if (!isValidTimezone(opts.timezone)) {
|
|
22439
|
+
throw new Error(`Invalid timezone: ${opts.timezone}`, {
|
|
22440
|
+
cause: new Error(
|
|
22441
|
+
"Use an IANA timezone identifier (e.g., America/New_York, Asia/Shanghai)"
|
|
22442
|
+
)
|
|
22443
|
+
});
|
|
22444
|
+
}
|
|
22445
|
+
updates.timezone = opts.timezone;
|
|
22446
|
+
}
|
|
22447
|
+
if (hasNotifyEmail) {
|
|
22448
|
+
updates.notifyEmail = parseOnOff("notify-email", opts.notifyEmail);
|
|
22449
|
+
}
|
|
22450
|
+
if (hasNotifySlack) {
|
|
22451
|
+
updates.notifySlack = parseOnOff("notify-slack", opts.notifySlack);
|
|
22452
|
+
}
|
|
22453
|
+
return updates;
|
|
22454
|
+
}
|
|
22455
|
+
function printUpdateResult(updates, result) {
|
|
22456
|
+
if (updates.timezone !== void 0) {
|
|
22457
|
+
console.log(
|
|
22458
|
+
chalk70.green(
|
|
22459
|
+
`Timezone set to ${chalk70.cyan(result.timezone ?? updates.timezone)}`
|
|
22460
|
+
)
|
|
22461
|
+
);
|
|
22462
|
+
}
|
|
22463
|
+
if (updates.notifyEmail !== void 0) {
|
|
22464
|
+
console.log(
|
|
22465
|
+
chalk70.green(
|
|
22466
|
+
`Email notifications ${result.notifyEmail ? "enabled" : "disabled"}`
|
|
22467
|
+
)
|
|
22468
|
+
);
|
|
22469
|
+
}
|
|
22470
|
+
if (updates.notifySlack !== void 0) {
|
|
22471
|
+
console.log(
|
|
22472
|
+
chalk70.green(
|
|
22473
|
+
`Slack notifications ${result.notifySlack ? "enabled" : "disabled"}`
|
|
22474
|
+
)
|
|
22475
|
+
);
|
|
22476
|
+
}
|
|
22477
|
+
}
|
|
22478
|
+
async function interactiveSetup(prefs) {
|
|
22479
|
+
if (!prefs.timezone) {
|
|
22480
|
+
const detectedTz = detectTimezone2();
|
|
22481
|
+
console.log(chalk70.dim(`
|
|
22482
|
+
System timezone detected: ${detectedTz}`));
|
|
22483
|
+
const tz = await promptText(
|
|
22484
|
+
"Set timezone? (enter timezone or leave empty to skip)",
|
|
22485
|
+
detectedTz
|
|
22486
|
+
);
|
|
22487
|
+
if (tz?.trim()) {
|
|
22488
|
+
if (!isValidTimezone(tz.trim())) {
|
|
22489
|
+
throw new Error(`Invalid timezone: ${tz.trim()}`);
|
|
22490
|
+
}
|
|
22491
|
+
await updateZeroUserPreferences({ timezone: tz.trim() });
|
|
22492
|
+
console.log(chalk70.green(`Timezone set to ${chalk70.cyan(tz.trim())}`));
|
|
22493
|
+
}
|
|
22494
|
+
}
|
|
22495
|
+
if (!prefs.notifyEmail) {
|
|
22496
|
+
const enable = await promptConfirm(
|
|
22497
|
+
"\nEnable email notifications for scheduled runs?",
|
|
22498
|
+
false
|
|
22499
|
+
);
|
|
22500
|
+
if (enable) {
|
|
22501
|
+
await updateZeroUserPreferences({ notifyEmail: true });
|
|
22502
|
+
console.log(chalk70.green("Email notifications enabled"));
|
|
22503
|
+
}
|
|
22504
|
+
}
|
|
22505
|
+
}
|
|
22506
|
+
var zeroPreferenceCommand = new Command78().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(
|
|
22507
|
+
withErrorHandler(async (opts) => {
|
|
22508
|
+
const updates = buildUpdates(opts);
|
|
22509
|
+
if (updates) {
|
|
22510
|
+
const result = await updateZeroUserPreferences(updates);
|
|
22511
|
+
printUpdateResult(updates, result);
|
|
22512
|
+
return;
|
|
22513
|
+
}
|
|
22514
|
+
const prefs = await getZeroUserPreferences();
|
|
22515
|
+
displayPreferences(prefs);
|
|
22516
|
+
if (isInteractive()) {
|
|
22517
|
+
await interactiveSetup(prefs);
|
|
22518
|
+
} else if (!prefs.timezone) {
|
|
22519
|
+
console.log();
|
|
22520
|
+
console.log(
|
|
22521
|
+
`To set timezone: ${chalk70.cyan("vm0 zero preference --timezone <timezone>")}`
|
|
22522
|
+
);
|
|
22523
|
+
console.log(
|
|
22524
|
+
chalk70.dim("Example: vm0 zero preference --timezone America/New_York")
|
|
22525
|
+
);
|
|
22526
|
+
}
|
|
22527
|
+
})
|
|
22528
|
+
);
|
|
22822
22529
|
|
|
22823
22530
|
// src/commands/zero/schedule/index.ts
|
|
22824
|
-
import { Command as
|
|
22531
|
+
import { Command as Command85 } from "commander";
|
|
22825
22532
|
|
|
22826
22533
|
// src/commands/zero/schedule/setup.ts
|
|
22827
|
-
import { Command as
|
|
22828
|
-
import
|
|
22534
|
+
import { Command as Command79 } from "commander";
|
|
22535
|
+
import chalk71 from "chalk";
|
|
22829
22536
|
var FREQUENCY_CHOICES = [
|
|
22830
22537
|
{ title: "Daily", value: "daily", description: "Run every day" },
|
|
22831
22538
|
{
|
|
@@ -22931,7 +22638,7 @@ async function gatherFrequency(optionFrequency, existingFrequency) {
|
|
|
22931
22638
|
if (!isInteractive()) {
|
|
22932
22639
|
throw new Error("--frequency is required (daily|weekly|monthly|once|loop)");
|
|
22933
22640
|
}
|
|
22934
|
-
const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((
|
|
22641
|
+
const defaultIndex = existingFrequency ? FREQUENCY_CHOICES.findIndex((c32) => c32.value === existingFrequency) : 0;
|
|
22935
22642
|
frequency = await promptSelect(
|
|
22936
22643
|
"Schedule frequency",
|
|
22937
22644
|
FREQUENCY_CHOICES,
|
|
@@ -22956,7 +22663,7 @@ async function gatherDay(frequency, optionDay, existingDay) {
|
|
|
22956
22663
|
throw new Error("--day is required for weekly/monthly");
|
|
22957
22664
|
}
|
|
22958
22665
|
if (frequency === "weekly") {
|
|
22959
|
-
const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((
|
|
22666
|
+
const defaultDayIndex = existingDay !== void 0 ? DAY_OF_WEEK_CHOICES.findIndex((c32) => c32.value === existingDay) : 0;
|
|
22960
22667
|
const day2 = await promptSelect(
|
|
22961
22668
|
"Day of week",
|
|
22962
22669
|
DAY_OF_WEEK_CHOICES,
|
|
@@ -23031,11 +22738,11 @@ async function gatherTimezone(optionTimezone, existingTimezone) {
|
|
|
23031
22738
|
if (optionTimezone) return optionTimezone;
|
|
23032
22739
|
let userTimezone = null;
|
|
23033
22740
|
try {
|
|
23034
|
-
const prefs = await
|
|
22741
|
+
const prefs = await getZeroUserPreferences();
|
|
23035
22742
|
userTimezone = prefs.timezone;
|
|
23036
22743
|
} catch {
|
|
23037
22744
|
console.log(
|
|
23038
|
-
|
|
22745
|
+
chalk71.dim("Could not fetch timezone preference, using detected timezone")
|
|
23039
22746
|
);
|
|
23040
22747
|
}
|
|
23041
22748
|
const defaultTimezone = userTimezone || detectTimezone();
|
|
@@ -23160,11 +22867,11 @@ async function buildAndDeploy(params) {
|
|
|
23160
22867
|
}
|
|
23161
22868
|
console.log(
|
|
23162
22869
|
`
|
|
23163
|
-
Deploying schedule for agent ${
|
|
22870
|
+
Deploying schedule for agent ${chalk71.cyan(params.agentName)}...`
|
|
23164
22871
|
);
|
|
23165
22872
|
const deployResult = await deployZeroSchedule({
|
|
23166
22873
|
name: params.scheduleName,
|
|
23167
|
-
|
|
22874
|
+
agentId: params.agentId,
|
|
23168
22875
|
cronExpression,
|
|
23169
22876
|
atTime: atTimeISO,
|
|
23170
22877
|
intervalSeconds: params.intervalSeconds,
|
|
@@ -23183,81 +22890,75 @@ Deploying schedule for agent ${chalk75.cyan(params.agentName)}...`
|
|
|
23183
22890
|
function displayDeployResult(agentName, deployResult) {
|
|
23184
22891
|
if (deployResult.created) {
|
|
23185
22892
|
console.log(
|
|
23186
|
-
|
|
22893
|
+
chalk71.green(`\u2713 Created schedule for agent ${chalk71.cyan(agentName)}`)
|
|
23187
22894
|
);
|
|
23188
22895
|
} else {
|
|
23189
22896
|
console.log(
|
|
23190
|
-
|
|
22897
|
+
chalk71.green(`\u2713 Updated schedule for agent ${chalk71.cyan(agentName)}`)
|
|
23191
22898
|
);
|
|
23192
22899
|
}
|
|
23193
|
-
console.log(
|
|
22900
|
+
console.log(chalk71.dim(` Timezone: ${deployResult.schedule.timezone}`));
|
|
23194
22901
|
if (deployResult.schedule.triggerType === "loop" && deployResult.schedule.intervalSeconds != null) {
|
|
23195
22902
|
console.log(
|
|
23196
|
-
|
|
22903
|
+
chalk71.dim(
|
|
23197
22904
|
` Mode: Loop (interval ${deployResult.schedule.intervalSeconds}s)`
|
|
23198
22905
|
)
|
|
23199
22906
|
);
|
|
23200
22907
|
} else if (deployResult.schedule.cronExpression) {
|
|
23201
|
-
console.log(
|
|
22908
|
+
console.log(chalk71.dim(` Cron: ${deployResult.schedule.cronExpression}`));
|
|
23202
22909
|
if (deployResult.schedule.nextRunAt) {
|
|
23203
22910
|
const nextRun = formatInTimezone(
|
|
23204
22911
|
deployResult.schedule.nextRunAt,
|
|
23205
22912
|
deployResult.schedule.timezone
|
|
23206
22913
|
);
|
|
23207
|
-
console.log(
|
|
22914
|
+
console.log(chalk71.dim(` Next run: ${nextRun}`));
|
|
23208
22915
|
}
|
|
23209
22916
|
} else if (deployResult.schedule.atTime) {
|
|
23210
22917
|
const atTimeFormatted = formatInTimezone(
|
|
23211
22918
|
deployResult.schedule.atTime,
|
|
23212
22919
|
deployResult.schedule.timezone
|
|
23213
22920
|
);
|
|
23214
|
-
console.log(
|
|
22921
|
+
console.log(chalk71.dim(` At: ${atTimeFormatted}`));
|
|
23215
22922
|
}
|
|
23216
22923
|
}
|
|
23217
|
-
async function tryEnableSchedule(scheduleName,
|
|
22924
|
+
async function tryEnableSchedule(scheduleName, agentId, agentName) {
|
|
23218
22925
|
try {
|
|
23219
|
-
await enableZeroSchedule({ name: scheduleName,
|
|
22926
|
+
await enableZeroSchedule({ name: scheduleName, agentId });
|
|
23220
22927
|
console.log(
|
|
23221
|
-
|
|
22928
|
+
chalk71.green(`\u2713 Enabled schedule for agent ${chalk71.cyan(agentName)}`)
|
|
23222
22929
|
);
|
|
23223
22930
|
} catch (error) {
|
|
23224
|
-
console.error(
|
|
22931
|
+
console.error(chalk71.yellow("\u26A0 Failed to enable schedule"));
|
|
23225
22932
|
if (error instanceof ApiRequestError) {
|
|
23226
22933
|
if (error.code === "SCHEDULE_PAST") {
|
|
23227
|
-
console.error(
|
|
22934
|
+
console.error(chalk71.dim(" Scheduled time has already passed"));
|
|
23228
22935
|
} else {
|
|
23229
|
-
console.error(
|
|
22936
|
+
console.error(chalk71.dim(` ${error.message}`));
|
|
23230
22937
|
}
|
|
23231
22938
|
} else if (error instanceof Error) {
|
|
23232
|
-
console.error(
|
|
22939
|
+
console.error(chalk71.dim(` ${error.message}`));
|
|
23233
22940
|
}
|
|
23234
22941
|
console.log(
|
|
23235
|
-
` To enable manually: ${
|
|
22942
|
+
` To enable manually: ${chalk71.cyan(`vm0 zero schedule enable ${agentName}`)}`
|
|
23236
22943
|
);
|
|
23237
22944
|
}
|
|
23238
22945
|
}
|
|
23239
22946
|
function showEnableHint(agentName) {
|
|
23240
22947
|
console.log();
|
|
23241
22948
|
console.log(
|
|
23242
|
-
` To enable: ${
|
|
22949
|
+
` To enable: ${chalk71.cyan(`vm0 zero schedule enable ${agentName}`)}`
|
|
23243
22950
|
);
|
|
23244
22951
|
}
|
|
23245
22952
|
async function handleScheduleEnabling(params) {
|
|
23246
|
-
const {
|
|
23247
|
-
scheduleName,
|
|
23248
|
-
zeroAgentId,
|
|
23249
|
-
agentName,
|
|
23250
|
-
enableFlag,
|
|
23251
|
-
shouldPromptEnable
|
|
23252
|
-
} = params;
|
|
22953
|
+
const { scheduleName, agentId, agentName, enableFlag, shouldPromptEnable } = params;
|
|
23253
22954
|
if (enableFlag) {
|
|
23254
|
-
await tryEnableSchedule(scheduleName,
|
|
22955
|
+
await tryEnableSchedule(scheduleName, agentId, agentName);
|
|
23255
22956
|
return;
|
|
23256
22957
|
}
|
|
23257
22958
|
if (shouldPromptEnable && isInteractive()) {
|
|
23258
22959
|
const enableNow = await promptConfirm("Enable this schedule?", true);
|
|
23259
22960
|
if (enableNow) {
|
|
23260
|
-
await tryEnableSchedule(scheduleName,
|
|
22961
|
+
await tryEnableSchedule(scheduleName, agentId, agentName);
|
|
23261
22962
|
} else {
|
|
23262
22963
|
showEnableHint(agentName);
|
|
23263
22964
|
}
|
|
@@ -23267,17 +22968,17 @@ async function handleScheduleEnabling(params) {
|
|
|
23267
22968
|
showEnableHint(agentName);
|
|
23268
22969
|
}
|
|
23269
22970
|
}
|
|
23270
|
-
var setupCommand2 = new
|
|
22971
|
+
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
22972
|
withErrorHandler(async (agentName, options) => {
|
|
23272
22973
|
const agent = await getZeroAgent(agentName);
|
|
23273
|
-
const
|
|
22974
|
+
const agentId = agent.agentComposeId;
|
|
23274
22975
|
const scheduleName = options.name || "default";
|
|
23275
22976
|
const existingSchedule = await findExistingSchedule(
|
|
23276
22977
|
agentName,
|
|
23277
22978
|
scheduleName
|
|
23278
22979
|
);
|
|
23279
22980
|
console.log(
|
|
23280
|
-
|
|
22981
|
+
chalk71.dim(
|
|
23281
22982
|
existingSchedule ? `Editing existing schedule for agent ${agentName}` : `Creating new schedule for agent ${agentName}`
|
|
23282
22983
|
)
|
|
23283
22984
|
);
|
|
@@ -23287,12 +22988,12 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23287
22988
|
defaults.frequency
|
|
23288
22989
|
);
|
|
23289
22990
|
if (!frequency) {
|
|
23290
|
-
console.log(
|
|
22991
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23291
22992
|
return;
|
|
23292
22993
|
}
|
|
23293
22994
|
const timing = await gatherTiming(frequency, options, defaults);
|
|
23294
22995
|
if (!timing) {
|
|
23295
|
-
console.log(
|
|
22996
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23296
22997
|
return;
|
|
23297
22998
|
}
|
|
23298
22999
|
const { day, time, atTime, intervalSeconds } = timing;
|
|
@@ -23301,7 +23002,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23301
23002
|
existingSchedule?.timezone
|
|
23302
23003
|
);
|
|
23303
23004
|
if (!timezone) {
|
|
23304
|
-
console.log(
|
|
23005
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23305
23006
|
return;
|
|
23306
23007
|
}
|
|
23307
23008
|
const promptText_ = await gatherPromptText(
|
|
@@ -23309,7 +23010,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23309
23010
|
existingSchedule?.prompt
|
|
23310
23011
|
);
|
|
23311
23012
|
if (!promptText_) {
|
|
23312
|
-
console.log(
|
|
23013
|
+
console.log(chalk71.dim("Cancelled"));
|
|
23313
23014
|
return;
|
|
23314
23015
|
}
|
|
23315
23016
|
const { notifyEmail, notifySlack } = await gatherNotificationPreferences(
|
|
@@ -23319,7 +23020,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23319
23020
|
);
|
|
23320
23021
|
const deployResult = await buildAndDeploy({
|
|
23321
23022
|
scheduleName,
|
|
23322
|
-
|
|
23023
|
+
agentId,
|
|
23323
23024
|
agentName,
|
|
23324
23025
|
frequency,
|
|
23325
23026
|
time,
|
|
@@ -23336,7 +23037,7 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23336
23037
|
const shouldPromptEnable = deployResult.created || existingSchedule !== void 0 && !existingSchedule.enabled;
|
|
23337
23038
|
await handleScheduleEnabling({
|
|
23338
23039
|
scheduleName,
|
|
23339
|
-
|
|
23040
|
+
agentId,
|
|
23340
23041
|
agentName,
|
|
23341
23042
|
enableFlag: options.enable ?? false,
|
|
23342
23043
|
shouldPromptEnable
|
|
@@ -23345,15 +23046,15 @@ var setupCommand2 = new Command84().name("setup").description("Create or edit a
|
|
|
23345
23046
|
);
|
|
23346
23047
|
|
|
23347
23048
|
// src/commands/zero/schedule/list.ts
|
|
23348
|
-
import { Command as
|
|
23349
|
-
import
|
|
23350
|
-
var
|
|
23049
|
+
import { Command as Command80 } from "commander";
|
|
23050
|
+
import chalk72 from "chalk";
|
|
23051
|
+
var listCommand11 = new Command80().name("list").alias("ls").description("List all zero schedules").action(
|
|
23351
23052
|
withErrorHandler(async () => {
|
|
23352
23053
|
const result = await listZeroSchedules();
|
|
23353
23054
|
if (result.schedules.length === 0) {
|
|
23354
|
-
console.log(
|
|
23055
|
+
console.log(chalk72.dim("No schedules found"));
|
|
23355
23056
|
console.log(
|
|
23356
|
-
|
|
23057
|
+
chalk72.dim(" Create one with: vm0 zero schedule setup <agent-name>")
|
|
23357
23058
|
);
|
|
23358
23059
|
return;
|
|
23359
23060
|
}
|
|
@@ -23378,10 +23079,10 @@ var listCommand12 = new Command85().name("list").alias("ls").description("List a
|
|
|
23378
23079
|
"STATUS".padEnd(8),
|
|
23379
23080
|
"NEXT RUN"
|
|
23380
23081
|
].join(" ");
|
|
23381
|
-
console.log(
|
|
23082
|
+
console.log(chalk72.dim(header));
|
|
23382
23083
|
for (const schedule of result.schedules) {
|
|
23383
23084
|
const trigger = schedule.cronExpression ? `${schedule.cronExpression} (${schedule.timezone})` : schedule.atTime || "-";
|
|
23384
|
-
const status = schedule.enabled ?
|
|
23085
|
+
const status = schedule.enabled ? chalk72.green("enabled") : chalk72.yellow("disabled");
|
|
23385
23086
|
const nextRun = schedule.enabled ? formatRelativeTime2(schedule.nextRunAt) : "-";
|
|
23386
23087
|
const row = [
|
|
23387
23088
|
schedule.agentName.padEnd(agentWidth),
|
|
@@ -23396,33 +23097,33 @@ var listCommand12 = new Command85().name("list").alias("ls").description("List a
|
|
|
23396
23097
|
);
|
|
23397
23098
|
|
|
23398
23099
|
// src/commands/zero/schedule/status.ts
|
|
23399
|
-
import { Command as
|
|
23400
|
-
import
|
|
23100
|
+
import { Command as Command81 } from "commander";
|
|
23101
|
+
import chalk73 from "chalk";
|
|
23401
23102
|
function formatDateTimeStyled(dateStr) {
|
|
23402
|
-
if (!dateStr) return
|
|
23103
|
+
if (!dateStr) return chalk73.dim("-");
|
|
23403
23104
|
const formatted = formatDateTime(dateStr);
|
|
23404
|
-
return formatted.replace(/\(([^)]+)\)$/,
|
|
23105
|
+
return formatted.replace(/\(([^)]+)\)$/, chalk73.dim("($1)"));
|
|
23405
23106
|
}
|
|
23406
23107
|
function formatTrigger(schedule) {
|
|
23407
23108
|
if (schedule.triggerType === "loop" && schedule.intervalSeconds !== null) {
|
|
23408
|
-
return `interval ${schedule.intervalSeconds}s ${
|
|
23109
|
+
return `interval ${schedule.intervalSeconds}s ${chalk73.dim("(loop)")}`;
|
|
23409
23110
|
}
|
|
23410
23111
|
if (schedule.cronExpression) {
|
|
23411
23112
|
return schedule.cronExpression;
|
|
23412
23113
|
}
|
|
23413
23114
|
if (schedule.atTime) {
|
|
23414
|
-
return `${schedule.atTime} ${
|
|
23115
|
+
return `${schedule.atTime} ${chalk73.dim("(one-time)")}`;
|
|
23415
23116
|
}
|
|
23416
|
-
return
|
|
23117
|
+
return chalk73.dim("-");
|
|
23417
23118
|
}
|
|
23418
23119
|
function printRunConfiguration(schedule) {
|
|
23419
|
-
const statusText = schedule.enabled ?
|
|
23120
|
+
const statusText = schedule.enabled ? chalk73.green("enabled") : chalk73.yellow("disabled");
|
|
23420
23121
|
console.log(`${"Status:".padEnd(16)}${statusText}`);
|
|
23421
23122
|
console.log(
|
|
23422
|
-
`${"Agent:".padEnd(16)}${schedule.agentName} ${
|
|
23123
|
+
`${"Agent:".padEnd(16)}${schedule.agentName} ${chalk73.dim(`(${schedule.orgSlug})`)}`
|
|
23423
23124
|
);
|
|
23424
23125
|
const promptPreview = schedule.prompt.length > 60 ? schedule.prompt.slice(0, 57) + "..." : schedule.prompt;
|
|
23425
|
-
console.log(`${"Prompt:".padEnd(16)}${
|
|
23126
|
+
console.log(`${"Prompt:".padEnd(16)}${chalk73.dim(promptPreview)}`);
|
|
23426
23127
|
if (schedule.vars && Object.keys(schedule.vars).length > 0) {
|
|
23427
23128
|
console.log(
|
|
23428
23129
|
`${"Variables:".padEnd(16)}${Object.keys(schedule.vars).join(", ")}`
|
|
@@ -23451,11 +23152,11 @@ function printTimeSchedule(schedule) {
|
|
|
23451
23152
|
);
|
|
23452
23153
|
}
|
|
23453
23154
|
if (schedule.triggerType === "loop") {
|
|
23454
|
-
const failureText = schedule.consecutiveFailures > 0 ?
|
|
23155
|
+
const failureText = schedule.consecutiveFailures > 0 ? chalk73.yellow(`${schedule.consecutiveFailures}/3`) : chalk73.dim("0/3");
|
|
23455
23156
|
console.log(`${"Failures:".padEnd(16)}${failureText}`);
|
|
23456
23157
|
}
|
|
23457
23158
|
}
|
|
23458
|
-
var
|
|
23159
|
+
var statusCommand7 = new Command81().name("status").description("Show detailed status of a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23459
23160
|
"-n, --name <schedule-name>",
|
|
23460
23161
|
"Schedule name (required when agent has multiple schedules)"
|
|
23461
23162
|
).action(
|
|
@@ -23465,8 +23166,8 @@ var statusCommand8 = new Command86().name("status").description("Show detailed s
|
|
|
23465
23166
|
options.name
|
|
23466
23167
|
);
|
|
23467
23168
|
console.log();
|
|
23468
|
-
console.log(`Schedule for agent: ${
|
|
23469
|
-
console.log(
|
|
23169
|
+
console.log(`Schedule for agent: ${chalk73.cyan(agentName)}`);
|
|
23170
|
+
console.log(chalk73.dim("\u2501".repeat(50)));
|
|
23470
23171
|
printRunConfiguration(schedule);
|
|
23471
23172
|
printTimeSchedule(schedule);
|
|
23472
23173
|
console.log();
|
|
@@ -23474,9 +23175,9 @@ var statusCommand8 = new Command86().name("status").description("Show detailed s
|
|
|
23474
23175
|
);
|
|
23475
23176
|
|
|
23476
23177
|
// src/commands/zero/schedule/delete.ts
|
|
23477
|
-
import { Command as
|
|
23478
|
-
import
|
|
23479
|
-
var deleteCommand3 = new
|
|
23178
|
+
import { Command as Command82 } from "commander";
|
|
23179
|
+
import chalk74 from "chalk";
|
|
23180
|
+
var deleteCommand3 = new Command82().name("delete").alias("rm").description("Delete a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23480
23181
|
"-n, --name <schedule-name>",
|
|
23481
23182
|
"Schedule name (required when agent has multiple schedules)"
|
|
23482
23183
|
).option("-y, --yes", "Skip confirmation prompt").action(
|
|
@@ -23491,29 +23192,29 @@ var deleteCommand3 = new Command87().name("delete").alias("rm").description("Del
|
|
|
23491
23192
|
throw new Error("--yes flag is required in non-interactive mode");
|
|
23492
23193
|
}
|
|
23493
23194
|
const confirmed = await promptConfirm(
|
|
23494
|
-
`Delete schedule for agent ${
|
|
23195
|
+
`Delete schedule for agent ${chalk74.cyan(agentName)}?`,
|
|
23495
23196
|
false
|
|
23496
23197
|
);
|
|
23497
23198
|
if (!confirmed) {
|
|
23498
|
-
console.log(
|
|
23199
|
+
console.log(chalk74.dim("Cancelled"));
|
|
23499
23200
|
return;
|
|
23500
23201
|
}
|
|
23501
23202
|
}
|
|
23502
23203
|
await deleteZeroSchedule({
|
|
23503
23204
|
name: resolved.name,
|
|
23504
|
-
|
|
23205
|
+
agentId: resolved.agentId
|
|
23505
23206
|
});
|
|
23506
23207
|
console.log(
|
|
23507
|
-
|
|
23208
|
+
chalk74.green(`\u2713 Deleted schedule for agent ${chalk74.cyan(agentName)}`)
|
|
23508
23209
|
);
|
|
23509
23210
|
}
|
|
23510
23211
|
)
|
|
23511
23212
|
);
|
|
23512
23213
|
|
|
23513
23214
|
// src/commands/zero/schedule/enable.ts
|
|
23514
|
-
import { Command as
|
|
23515
|
-
import
|
|
23516
|
-
var enableCommand = new
|
|
23215
|
+
import { Command as Command83 } from "commander";
|
|
23216
|
+
import chalk75 from "chalk";
|
|
23217
|
+
var enableCommand = new Command83().name("enable").description("Enable a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23517
23218
|
"-n, --name <schedule-name>",
|
|
23518
23219
|
"Schedule name (required when agent has multiple schedules)"
|
|
23519
23220
|
).action(
|
|
@@ -23524,18 +23225,18 @@ var enableCommand = new Command88().name("enable").description("Enable a zero sc
|
|
|
23524
23225
|
);
|
|
23525
23226
|
await enableZeroSchedule({
|
|
23526
23227
|
name: resolved.name,
|
|
23527
|
-
|
|
23228
|
+
agentId: resolved.agentId
|
|
23528
23229
|
});
|
|
23529
23230
|
console.log(
|
|
23530
|
-
|
|
23231
|
+
chalk75.green(`\u2713 Enabled schedule for agent ${chalk75.cyan(agentName)}`)
|
|
23531
23232
|
);
|
|
23532
23233
|
})
|
|
23533
23234
|
);
|
|
23534
23235
|
|
|
23535
23236
|
// src/commands/zero/schedule/disable.ts
|
|
23536
|
-
import { Command as
|
|
23537
|
-
import
|
|
23538
|
-
var disableCommand = new
|
|
23237
|
+
import { Command as Command84 } from "commander";
|
|
23238
|
+
import chalk76 from "chalk";
|
|
23239
|
+
var disableCommand = new Command84().name("disable").description("Disable a zero schedule").argument("<agent-name>", "Agent name").option(
|
|
23539
23240
|
"-n, --name <schedule-name>",
|
|
23540
23241
|
"Schedule name (required when agent has multiple schedules)"
|
|
23541
23242
|
).action(
|
|
@@ -23546,81 +23247,81 @@ var disableCommand = new Command89().name("disable").description("Disable a zero
|
|
|
23546
23247
|
);
|
|
23547
23248
|
await disableZeroSchedule({
|
|
23548
23249
|
name: resolved.name,
|
|
23549
|
-
|
|
23250
|
+
agentId: resolved.agentId
|
|
23550
23251
|
});
|
|
23551
23252
|
console.log(
|
|
23552
|
-
|
|
23253
|
+
chalk76.green(`\u2713 Disabled schedule for agent ${chalk76.cyan(agentName)}`)
|
|
23553
23254
|
);
|
|
23554
23255
|
})
|
|
23555
23256
|
);
|
|
23556
23257
|
|
|
23557
23258
|
// src/commands/zero/schedule/index.ts
|
|
23558
|
-
var zeroScheduleCommand = new
|
|
23259
|
+
var zeroScheduleCommand = new Command85().name("schedule").description("Manage zero agent schedules").addCommand(setupCommand2).addCommand(listCommand11).addCommand(statusCommand7).addCommand(deleteCommand3).addCommand(enableCommand).addCommand(disableCommand);
|
|
23559
23260
|
|
|
23560
23261
|
// src/commands/zero/secret/index.ts
|
|
23561
|
-
import { Command as
|
|
23262
|
+
import { Command as Command89 } from "commander";
|
|
23562
23263
|
|
|
23563
23264
|
// src/commands/zero/secret/list.ts
|
|
23564
|
-
import { Command as
|
|
23565
|
-
import
|
|
23566
|
-
var
|
|
23265
|
+
import { Command as Command86 } from "commander";
|
|
23266
|
+
import chalk77 from "chalk";
|
|
23267
|
+
var listCommand12 = new Command86().name("list").alias("ls").description("List all secrets").action(
|
|
23567
23268
|
withErrorHandler(async () => {
|
|
23568
23269
|
const result = await listZeroSecrets();
|
|
23569
23270
|
if (result.secrets.length === 0) {
|
|
23570
|
-
console.log(
|
|
23271
|
+
console.log(chalk77.dim("No secrets found"));
|
|
23571
23272
|
console.log();
|
|
23572
23273
|
console.log("To add a secret:");
|
|
23573
23274
|
console.log(
|
|
23574
|
-
|
|
23275
|
+
chalk77.cyan(" vm0 zero secret set MY_API_KEY --body <value>")
|
|
23575
23276
|
);
|
|
23576
23277
|
return;
|
|
23577
23278
|
}
|
|
23578
|
-
console.log(
|
|
23279
|
+
console.log(chalk77.bold("Secrets:"));
|
|
23579
23280
|
console.log();
|
|
23580
23281
|
for (const secret of result.secrets) {
|
|
23581
23282
|
let typeIndicator = "";
|
|
23582
23283
|
let derivedLine = null;
|
|
23583
23284
|
if (secret.type === "model-provider") {
|
|
23584
|
-
typeIndicator =
|
|
23285
|
+
typeIndicator = chalk77.dim(" [model-provider]");
|
|
23585
23286
|
} else if (secret.type === "connector") {
|
|
23586
23287
|
const derived = getConnectorDerivedNames(secret.name);
|
|
23587
23288
|
if (derived) {
|
|
23588
|
-
typeIndicator =
|
|
23589
|
-
derivedLine =
|
|
23289
|
+
typeIndicator = chalk77.dim(` [${derived.connectorLabel} connector]`);
|
|
23290
|
+
derivedLine = chalk77.dim(
|
|
23590
23291
|
`Available as: ${derived.envVarNames.join(", ")}`
|
|
23591
23292
|
);
|
|
23592
23293
|
} else {
|
|
23593
|
-
typeIndicator =
|
|
23294
|
+
typeIndicator = chalk77.dim(" [connector]");
|
|
23594
23295
|
}
|
|
23595
23296
|
} else if (secret.type === "user") {
|
|
23596
23297
|
const derived = getConnectorDerivedNames(secret.name);
|
|
23597
23298
|
if (derived) {
|
|
23598
|
-
typeIndicator =
|
|
23599
|
-
derivedLine =
|
|
23299
|
+
typeIndicator = chalk77.dim(` [${derived.connectorLabel} connector]`);
|
|
23300
|
+
derivedLine = chalk77.dim(
|
|
23600
23301
|
`Available as: ${derived.envVarNames.join(", ")}`
|
|
23601
23302
|
);
|
|
23602
23303
|
}
|
|
23603
23304
|
}
|
|
23604
|
-
console.log(` ${
|
|
23305
|
+
console.log(` ${chalk77.cyan(secret.name)}${typeIndicator}`);
|
|
23605
23306
|
if (derivedLine) {
|
|
23606
23307
|
console.log(` ${derivedLine}`);
|
|
23607
23308
|
}
|
|
23608
23309
|
if (secret.description) {
|
|
23609
|
-
console.log(` ${
|
|
23310
|
+
console.log(` ${chalk77.dim(secret.description)}`);
|
|
23610
23311
|
}
|
|
23611
23312
|
console.log(
|
|
23612
|
-
` ${
|
|
23313
|
+
` ${chalk77.dim(`Updated: ${new Date(secret.updatedAt).toLocaleString()}`)}`
|
|
23613
23314
|
);
|
|
23614
23315
|
console.log();
|
|
23615
23316
|
}
|
|
23616
|
-
console.log(
|
|
23317
|
+
console.log(chalk77.dim(`Total: ${result.secrets.length} secret(s)`));
|
|
23617
23318
|
})
|
|
23618
23319
|
);
|
|
23619
23320
|
|
|
23620
23321
|
// src/commands/zero/secret/set.ts
|
|
23621
|
-
import { Command as
|
|
23622
|
-
import
|
|
23623
|
-
var setCommand4 = new
|
|
23322
|
+
import { Command as Command87 } from "commander";
|
|
23323
|
+
import chalk78 from "chalk";
|
|
23324
|
+
var setCommand4 = new Command87().name("set").description("Create or update a secret").argument("<name>", "Secret name (uppercase, e.g., MY_API_KEY)").option(
|
|
23624
23325
|
"-b, --body <value>",
|
|
23625
23326
|
"Secret value (required in non-interactive mode)"
|
|
23626
23327
|
).option("-d, --description <description>", "Optional description").action(
|
|
@@ -23659,19 +23360,19 @@ var setCommand4 = new Command92().name("set").description("Create or update a se
|
|
|
23659
23360
|
}
|
|
23660
23361
|
throw error;
|
|
23661
23362
|
}
|
|
23662
|
-
console.log(
|
|
23363
|
+
console.log(chalk78.green(`\u2713 Secret "${secret.name}" saved`));
|
|
23663
23364
|
console.log();
|
|
23664
23365
|
console.log("Use in vm0.yaml:");
|
|
23665
|
-
console.log(
|
|
23666
|
-
console.log(
|
|
23366
|
+
console.log(chalk78.cyan(` environment:`));
|
|
23367
|
+
console.log(chalk78.cyan(` ${name}: \${{ secrets.${name} }}`));
|
|
23667
23368
|
}
|
|
23668
23369
|
)
|
|
23669
23370
|
);
|
|
23670
23371
|
|
|
23671
23372
|
// src/commands/zero/secret/delete.ts
|
|
23672
|
-
import { Command as
|
|
23673
|
-
import
|
|
23674
|
-
var deleteCommand4 = new
|
|
23373
|
+
import { Command as Command88 } from "commander";
|
|
23374
|
+
import chalk79 from "chalk";
|
|
23375
|
+
var deleteCommand4 = new Command88().name("delete").description("Delete a secret").argument("<name>", "Secret name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
23675
23376
|
withErrorHandler(async (name, options) => {
|
|
23676
23377
|
if (!options.yes) {
|
|
23677
23378
|
if (!isInteractive()) {
|
|
@@ -23682,61 +23383,61 @@ var deleteCommand4 = new Command93().name("delete").description("Delete a secret
|
|
|
23682
23383
|
false
|
|
23683
23384
|
);
|
|
23684
23385
|
if (!confirmed) {
|
|
23685
|
-
console.log(
|
|
23386
|
+
console.log(chalk79.dim("Cancelled"));
|
|
23686
23387
|
return;
|
|
23687
23388
|
}
|
|
23688
23389
|
}
|
|
23689
23390
|
await deleteZeroSecret(name);
|
|
23690
|
-
console.log(
|
|
23391
|
+
console.log(chalk79.green(`\u2713 Secret "${name}" deleted`));
|
|
23691
23392
|
})
|
|
23692
23393
|
);
|
|
23693
23394
|
|
|
23694
23395
|
// src/commands/zero/secret/index.ts
|
|
23695
|
-
var zeroSecretCommand = new
|
|
23396
|
+
var zeroSecretCommand = new Command89().name("secret").description("Manage secrets").addCommand(listCommand12).addCommand(setCommand4).addCommand(deleteCommand4);
|
|
23696
23397
|
|
|
23697
23398
|
// src/commands/zero/variable/index.ts
|
|
23698
|
-
import { Command as
|
|
23399
|
+
import { Command as Command93 } from "commander";
|
|
23699
23400
|
|
|
23700
23401
|
// src/commands/zero/variable/list.ts
|
|
23701
|
-
import { Command as
|
|
23702
|
-
import
|
|
23402
|
+
import { Command as Command90 } from "commander";
|
|
23403
|
+
import chalk80 from "chalk";
|
|
23703
23404
|
function truncateValue2(value, maxLength = 60) {
|
|
23704
23405
|
if (value.length <= maxLength) {
|
|
23705
23406
|
return value;
|
|
23706
23407
|
}
|
|
23707
23408
|
return value.slice(0, maxLength - 15) + "... [truncated]";
|
|
23708
23409
|
}
|
|
23709
|
-
var
|
|
23410
|
+
var listCommand13 = new Command90().name("list").alias("ls").description("List all variables").action(
|
|
23710
23411
|
withErrorHandler(async () => {
|
|
23711
23412
|
const result = await listZeroVariables();
|
|
23712
23413
|
if (result.variables.length === 0) {
|
|
23713
|
-
console.log(
|
|
23414
|
+
console.log(chalk80.dim("No variables found"));
|
|
23714
23415
|
console.log();
|
|
23715
23416
|
console.log("To add a variable:");
|
|
23716
|
-
console.log(
|
|
23417
|
+
console.log(chalk80.cyan(" vm0 zero variable set MY_VAR <value>"));
|
|
23717
23418
|
return;
|
|
23718
23419
|
}
|
|
23719
|
-
console.log(
|
|
23420
|
+
console.log(chalk80.bold("Variables:"));
|
|
23720
23421
|
console.log();
|
|
23721
23422
|
for (const variable of result.variables) {
|
|
23722
23423
|
const displayValue = truncateValue2(variable.value);
|
|
23723
|
-
console.log(` ${
|
|
23424
|
+
console.log(` ${chalk80.cyan(variable.name)} = ${displayValue}`);
|
|
23724
23425
|
if (variable.description) {
|
|
23725
|
-
console.log(` ${
|
|
23426
|
+
console.log(` ${chalk80.dim(variable.description)}`);
|
|
23726
23427
|
}
|
|
23727
23428
|
console.log(
|
|
23728
|
-
` ${
|
|
23429
|
+
` ${chalk80.dim(`Updated: ${new Date(variable.updatedAt).toLocaleString()}`)}`
|
|
23729
23430
|
);
|
|
23730
23431
|
console.log();
|
|
23731
23432
|
}
|
|
23732
|
-
console.log(
|
|
23433
|
+
console.log(chalk80.dim(`Total: ${result.variables.length} variable(s)`));
|
|
23733
23434
|
})
|
|
23734
23435
|
);
|
|
23735
23436
|
|
|
23736
23437
|
// src/commands/zero/variable/set.ts
|
|
23737
|
-
import { Command as
|
|
23738
|
-
import
|
|
23739
|
-
var setCommand5 = new
|
|
23438
|
+
import { Command as Command91 } from "commander";
|
|
23439
|
+
import chalk81 from "chalk";
|
|
23440
|
+
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
23441
|
withErrorHandler(
|
|
23741
23442
|
async (name, value, options) => {
|
|
23742
23443
|
let variable;
|
|
@@ -23756,19 +23457,19 @@ var setCommand5 = new Command96().name("set").description("Create or update a va
|
|
|
23756
23457
|
}
|
|
23757
23458
|
throw error;
|
|
23758
23459
|
}
|
|
23759
|
-
console.log(
|
|
23460
|
+
console.log(chalk81.green(`\u2713 Variable "${variable.name}" saved`));
|
|
23760
23461
|
console.log();
|
|
23761
23462
|
console.log("Use in vm0.yaml:");
|
|
23762
|
-
console.log(
|
|
23763
|
-
console.log(
|
|
23463
|
+
console.log(chalk81.cyan(` environment:`));
|
|
23464
|
+
console.log(chalk81.cyan(` ${name}: \${{ vars.${name} }}`));
|
|
23764
23465
|
}
|
|
23765
23466
|
)
|
|
23766
23467
|
);
|
|
23767
23468
|
|
|
23768
23469
|
// src/commands/zero/variable/delete.ts
|
|
23769
|
-
import { Command as
|
|
23770
|
-
import
|
|
23771
|
-
var deleteCommand5 = new
|
|
23470
|
+
import { Command as Command92 } from "commander";
|
|
23471
|
+
import chalk82 from "chalk";
|
|
23472
|
+
var deleteCommand5 = new Command92().name("delete").description("Delete a variable").argument("<name>", "Variable name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
23772
23473
|
withErrorHandler(async (name, options) => {
|
|
23773
23474
|
if (!options.yes) {
|
|
23774
23475
|
if (!isInteractive()) {
|
|
@@ -23779,24 +23480,24 @@ var deleteCommand5 = new Command97().name("delete").description("Delete a variab
|
|
|
23779
23480
|
false
|
|
23780
23481
|
);
|
|
23781
23482
|
if (!confirmed) {
|
|
23782
|
-
console.log(
|
|
23483
|
+
console.log(chalk82.dim("Cancelled"));
|
|
23783
23484
|
return;
|
|
23784
23485
|
}
|
|
23785
23486
|
}
|
|
23786
23487
|
await deleteZeroVariable(name);
|
|
23787
|
-
console.log(
|
|
23488
|
+
console.log(chalk82.green(`\u2713 Variable "${name}" deleted`));
|
|
23788
23489
|
})
|
|
23789
23490
|
);
|
|
23790
23491
|
|
|
23791
23492
|
// src/commands/zero/variable/index.ts
|
|
23792
|
-
var zeroVariableCommand = new
|
|
23493
|
+
var zeroVariableCommand = new Command93().name("variable").description("Manage variables").addCommand(listCommand13).addCommand(setCommand5).addCommand(deleteCommand5);
|
|
23793
23494
|
|
|
23794
23495
|
// src/commands/zero/index.ts
|
|
23795
|
-
var zeroCommand = new
|
|
23496
|
+
var zeroCommand = new Command94("zero").description("Zero platform commands").addCommand(zeroOrgCommand).addCommand(agentCommand).addCommand(zeroConnectorCommand).addCommand(zeroPreferenceCommand).addCommand(zeroScheduleCommand).addCommand(zeroSecretCommand).addCommand(zeroVariableCommand);
|
|
23796
23497
|
|
|
23797
23498
|
// src/index.ts
|
|
23798
|
-
var program = new
|
|
23799
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.78.
|
|
23499
|
+
var program = new Command95();
|
|
23500
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.78.2");
|
|
23800
23501
|
program.addCommand(authCommand);
|
|
23801
23502
|
program.addCommand(infoCommand);
|
|
23802
23503
|
program.addCommand(composeCommand);
|
|
@@ -23807,8 +23508,6 @@ program.addCommand(memoryCommand);
|
|
|
23807
23508
|
program.addCommand(cookCommand);
|
|
23808
23509
|
program.addCommand(logsCommand2);
|
|
23809
23510
|
program.addCommand(initCommand4);
|
|
23810
|
-
program.addCommand(connectorCommand);
|
|
23811
|
-
program.addCommand(preferenceCommand);
|
|
23812
23511
|
program.addCommand(upgradeCommand);
|
|
23813
23512
|
program.addCommand(whoamiCommand);
|
|
23814
23513
|
program.addCommand(zeroCommand);
|