@vm0/cli 9.59.5 → 9.60.0
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 +1267 -1497
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -45,7 +45,7 @@ if (DSN) {
|
|
|
45
45
|
Sentry.init({
|
|
46
46
|
dsn: DSN,
|
|
47
47
|
environment: process.env.SENTRY_ENVIRONMENT ?? "production",
|
|
48
|
-
release: "9.
|
|
48
|
+
release: "9.60.0",
|
|
49
49
|
sendDefaultPii: false,
|
|
50
50
|
tracesSampleRate: 0,
|
|
51
51
|
shutdownTimeout: 500,
|
|
@@ -64,7 +64,7 @@ if (DSN) {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
Sentry.setContext("cli", {
|
|
67
|
-
version: "9.
|
|
67
|
+
version: "9.60.0",
|
|
68
68
|
command: process.argv.slice(2).join(" ")
|
|
69
69
|
});
|
|
70
70
|
Sentry.setContext("runtime", {
|
|
@@ -83,7 +83,7 @@ process.stdout.on("error", handleEpipe);
|
|
|
83
83
|
process.stderr.on("error", handleEpipe);
|
|
84
84
|
|
|
85
85
|
// src/index.ts
|
|
86
|
-
import { Command as
|
|
86
|
+
import { Command as Command86 } from "commander";
|
|
87
87
|
|
|
88
88
|
// src/lib/network/proxy.ts
|
|
89
89
|
import { EnvHttpProxyAgent, setGlobalDispatcher } from "undici";
|
|
@@ -673,7 +673,7 @@ function getConfigPath() {
|
|
|
673
673
|
return join2(homedir2(), ".vm0", "config.json");
|
|
674
674
|
}
|
|
675
675
|
var infoCommand = new Command6().name("info").description("Display environment and debug information").action(async () => {
|
|
676
|
-
console.log(chalk4.bold(`VM0 CLI v${"9.
|
|
676
|
+
console.log(chalk4.bold(`VM0 CLI v${"9.60.0"}`));
|
|
677
677
|
console.log();
|
|
678
678
|
const config = await loadConfig();
|
|
679
679
|
const hasEnvToken = !!process.env.VM0_TOKEN;
|
|
@@ -780,161 +780,9 @@ var apiErrorSchema = z2.object({
|
|
|
780
780
|
});
|
|
781
781
|
|
|
782
782
|
// ../../packages/core/src/contracts/composes.ts
|
|
783
|
-
import { z as z4 } from "zod";
|
|
784
|
-
|
|
785
|
-
// ../../packages/core/src/contracts/runners.ts
|
|
786
783
|
import { z as z3 } from "zod";
|
|
787
784
|
var c = initContract();
|
|
788
|
-
var
|
|
789
|
-
/^[a-z0-9-]+\/[a-z0-9-]+$/,
|
|
790
|
-
"Runner group must be in org/name format (e.g., acme/production)"
|
|
791
|
-
);
|
|
792
|
-
var jobSchema = z3.object({
|
|
793
|
-
runId: z3.string().uuid(),
|
|
794
|
-
prompt: z3.string(),
|
|
795
|
-
agentComposeVersionId: z3.string().nullable(),
|
|
796
|
-
vars: z3.record(z3.string(), z3.string()).nullable(),
|
|
797
|
-
checkpointId: z3.string().uuid().nullable()
|
|
798
|
-
});
|
|
799
|
-
var runnersPollContract = c.router({
|
|
800
|
-
poll: {
|
|
801
|
-
method: "POST",
|
|
802
|
-
path: "/api/runners/poll",
|
|
803
|
-
headers: authHeadersSchema,
|
|
804
|
-
body: z3.object({
|
|
805
|
-
group: runnerGroupSchema
|
|
806
|
-
}),
|
|
807
|
-
responses: {
|
|
808
|
-
200: z3.object({
|
|
809
|
-
job: jobSchema.nullable()
|
|
810
|
-
}),
|
|
811
|
-
400: apiErrorSchema,
|
|
812
|
-
401: apiErrorSchema,
|
|
813
|
-
500: apiErrorSchema
|
|
814
|
-
},
|
|
815
|
-
summary: "Poll for pending jobs (long-polling with 30s timeout)"
|
|
816
|
-
}
|
|
817
|
-
});
|
|
818
|
-
var servicePermissionSchema = z3.object({
|
|
819
|
-
name: z3.string(),
|
|
820
|
-
description: z3.string().optional(),
|
|
821
|
-
rules: z3.array(z3.string())
|
|
822
|
-
});
|
|
823
|
-
var serviceApiEntrySchema = z3.object({
|
|
824
|
-
base: z3.string(),
|
|
825
|
-
auth: z3.object({
|
|
826
|
-
headers: z3.record(z3.string(), z3.string())
|
|
827
|
-
}),
|
|
828
|
-
permissions: z3.array(servicePermissionSchema).optional()
|
|
829
|
-
});
|
|
830
|
-
var serviceEntrySchema = z3.object({
|
|
831
|
-
name: z3.string(),
|
|
832
|
-
ref: z3.string(),
|
|
833
|
-
apis: z3.array(serviceApiEntrySchema)
|
|
834
|
-
});
|
|
835
|
-
var experimentalServicesSchema = z3.array(serviceEntrySchema);
|
|
836
|
-
var storageEntrySchema = z3.object({
|
|
837
|
-
mountPath: z3.string(),
|
|
838
|
-
archiveUrl: z3.string().nullable()
|
|
839
|
-
});
|
|
840
|
-
var artifactEntrySchema = z3.object({
|
|
841
|
-
mountPath: z3.string(),
|
|
842
|
-
archiveUrl: z3.string().nullable(),
|
|
843
|
-
vasStorageName: z3.string(),
|
|
844
|
-
vasVersionId: z3.string()
|
|
845
|
-
});
|
|
846
|
-
var storageManifestSchema = z3.object({
|
|
847
|
-
storages: z3.array(storageEntrySchema),
|
|
848
|
-
artifact: artifactEntrySchema.nullable(),
|
|
849
|
-
memory: artifactEntrySchema.nullable()
|
|
850
|
-
});
|
|
851
|
-
var resumeSessionSchema = z3.object({
|
|
852
|
-
sessionId: z3.string(),
|
|
853
|
-
sessionHistory: z3.string()
|
|
854
|
-
});
|
|
855
|
-
var storedExecutionContextSchema = z3.object({
|
|
856
|
-
workingDir: z3.string(),
|
|
857
|
-
storageManifest: storageManifestSchema.nullable(),
|
|
858
|
-
environment: z3.record(z3.string(), z3.string()).nullable(),
|
|
859
|
-
resumeSession: resumeSessionSchema.nullable(),
|
|
860
|
-
encryptedSecrets: z3.string().nullable(),
|
|
861
|
-
// AES-256-GCM encrypted Record<string, string> (secret name → value)
|
|
862
|
-
// Maps secret names to OAuth connector types for runtime token refresh (e.g. { "GMAIL_ACCESS_TOKEN": "gmail" })
|
|
863
|
-
secretConnectorMap: z3.record(z3.string(), z3.string()).nullable().optional(),
|
|
864
|
-
cliAgentType: z3.string(),
|
|
865
|
-
// Debug flag to force real Claude in mock environments (internal use only)
|
|
866
|
-
debugNoMockClaude: z3.boolean().optional(),
|
|
867
|
-
// Dispatch timestamp for E2E timing metrics
|
|
868
|
-
apiStartTime: z3.number().optional(),
|
|
869
|
-
// User's timezone preference (IANA format, e.g., "Asia/Shanghai")
|
|
870
|
-
userTimezone: z3.string().optional(),
|
|
871
|
-
// Agent metadata for VM0_AGENT_NAME and VM0_AGENT_ORG env vars
|
|
872
|
-
agentName: z3.string().optional(),
|
|
873
|
-
agentOrgSlug: z3.string().optional(),
|
|
874
|
-
// Memory storage name (for first-run when manifest.memory is null)
|
|
875
|
-
memoryName: z3.string().optional(),
|
|
876
|
-
// Experimental services for proxy-side token replacement
|
|
877
|
-
experimentalServices: experimentalServicesSchema.optional()
|
|
878
|
-
});
|
|
879
|
-
var executionContextSchema = z3.object({
|
|
880
|
-
runId: z3.string().uuid(),
|
|
881
|
-
prompt: z3.string(),
|
|
882
|
-
agentComposeVersionId: z3.string().nullable(),
|
|
883
|
-
vars: z3.record(z3.string(), z3.string()).nullable(),
|
|
884
|
-
checkpointId: z3.string().uuid().nullable(),
|
|
885
|
-
sandboxToken: z3.string(),
|
|
886
|
-
// New fields for E2B parity:
|
|
887
|
-
workingDir: z3.string(),
|
|
888
|
-
storageManifest: storageManifestSchema.nullable(),
|
|
889
|
-
environment: z3.record(z3.string(), z3.string()).nullable(),
|
|
890
|
-
resumeSession: resumeSessionSchema.nullable(),
|
|
891
|
-
secretValues: z3.array(z3.string()).nullable(),
|
|
892
|
-
// AES-256-GCM encrypted Record<string, string> — passed through to mitm-addon for auth resolution
|
|
893
|
-
encryptedSecrets: z3.string().nullable(),
|
|
894
|
-
// Maps secret names to OAuth connector types for runtime token refresh
|
|
895
|
-
secretConnectorMap: z3.record(z3.string(), z3.string()).nullable().optional(),
|
|
896
|
-
cliAgentType: z3.string(),
|
|
897
|
-
// Debug flag to force real Claude in mock environments (internal use only)
|
|
898
|
-
debugNoMockClaude: z3.boolean().optional(),
|
|
899
|
-
// Dispatch timestamp for E2E timing metrics
|
|
900
|
-
apiStartTime: z3.number().optional(),
|
|
901
|
-
// User's timezone preference (IANA format, e.g., "Asia/Shanghai")
|
|
902
|
-
userTimezone: z3.string().optional(),
|
|
903
|
-
// Agent metadata
|
|
904
|
-
agentName: z3.string().optional(),
|
|
905
|
-
agentOrgSlug: z3.string().optional(),
|
|
906
|
-
// Memory storage name (for first-run when manifest.memory is null)
|
|
907
|
-
memoryName: z3.string().optional(),
|
|
908
|
-
// Experimental services for proxy-side token replacement
|
|
909
|
-
experimentalServices: experimentalServicesSchema.optional()
|
|
910
|
-
});
|
|
911
|
-
var runnersJobClaimContract = c.router({
|
|
912
|
-
claim: {
|
|
913
|
-
method: "POST",
|
|
914
|
-
path: "/api/runners/jobs/:id/claim",
|
|
915
|
-
headers: authHeadersSchema,
|
|
916
|
-
pathParams: z3.object({
|
|
917
|
-
id: z3.string().uuid()
|
|
918
|
-
}),
|
|
919
|
-
body: z3.object({}),
|
|
920
|
-
responses: {
|
|
921
|
-
200: executionContextSchema,
|
|
922
|
-
400: apiErrorSchema,
|
|
923
|
-
401: apiErrorSchema,
|
|
924
|
-
403: apiErrorSchema,
|
|
925
|
-
// Job does not belong to user
|
|
926
|
-
404: apiErrorSchema,
|
|
927
|
-
409: apiErrorSchema,
|
|
928
|
-
// Already claimed
|
|
929
|
-
500: apiErrorSchema
|
|
930
|
-
},
|
|
931
|
-
summary: "Claim a pending job for execution"
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
|
|
935
|
-
// ../../packages/core/src/contracts/composes.ts
|
|
936
|
-
var c2 = initContract();
|
|
937
|
-
var composeVersionQuerySchema = z4.string().min(1, "Missing version query parameter").regex(
|
|
785
|
+
var composeVersionQuerySchema = z3.string().min(1, "Missing version query parameter").regex(
|
|
938
786
|
/^[a-f0-9]{8,64}$|^latest$/i,
|
|
939
787
|
"Version must be 8-64 hex characters or 'latest'"
|
|
940
788
|
);
|
|
@@ -953,26 +801,31 @@ var VALID_CAPABILITIES = [
|
|
|
953
801
|
"schedule:read",
|
|
954
802
|
"schedule:write"
|
|
955
803
|
];
|
|
956
|
-
var
|
|
804
|
+
var firewallPermissionSchema = z3.object({
|
|
805
|
+
name: z3.string(),
|
|
806
|
+
description: z3.string().optional(),
|
|
807
|
+
rules: z3.array(z3.string())
|
|
808
|
+
});
|
|
809
|
+
var agentNameSchema = z3.string().min(3, "Agent name must be at least 3 characters").max(64, "Agent name must be 64 characters or less").regex(
|
|
957
810
|
AGENT_NAME_REGEX,
|
|
958
811
|
"Agent name must start and end with letter or number, and contain only letters, numbers, and hyphens"
|
|
959
812
|
);
|
|
960
|
-
var volumeConfigSchema =
|
|
961
|
-
name:
|
|
962
|
-
version:
|
|
813
|
+
var volumeConfigSchema = z3.object({
|
|
814
|
+
name: z3.string().min(1, "Volume name is required"),
|
|
815
|
+
version: z3.string().min(1, "Volume version is required"),
|
|
963
816
|
/** When true, skip mounting without error if volume doesn't exist */
|
|
964
|
-
optional:
|
|
817
|
+
optional: z3.boolean().optional()
|
|
965
818
|
});
|
|
966
|
-
var agentDefinitionSchema =
|
|
967
|
-
description:
|
|
968
|
-
framework:
|
|
969
|
-
volumes:
|
|
970
|
-
environment:
|
|
819
|
+
var agentDefinitionSchema = z3.object({
|
|
820
|
+
description: z3.string().optional(),
|
|
821
|
+
framework: z3.string().min(1, "Framework is required"),
|
|
822
|
+
volumes: z3.array(z3.string()).optional(),
|
|
823
|
+
environment: z3.record(z3.string(), z3.string()).optional(),
|
|
971
824
|
/**
|
|
972
825
|
* Path to instructions file (e.g., AGENTS.md).
|
|
973
826
|
* Auto-uploaded as volume and mounted at /home/user/.claude/CLAUDE.md
|
|
974
827
|
*/
|
|
975
|
-
instructions:
|
|
828
|
+
instructions: z3.string().min(1, "Instructions path cannot be empty").refine(
|
|
976
829
|
(val) => !val.includes("..") && !val.startsWith("/") && !val.startsWith("\\"),
|
|
977
830
|
"Instructions path must be a relative path without '..' segments"
|
|
978
831
|
).optional(),
|
|
@@ -980,33 +833,33 @@ var agentDefinitionSchema = z4.object({
|
|
|
980
833
|
* Array of GitHub tree URLs for agent skills.
|
|
981
834
|
* Each skill is auto-downloaded and mounted at /home/user/.claude/skills/{skillName}/
|
|
982
835
|
*/
|
|
983
|
-
skills:
|
|
836
|
+
skills: z3.array(z3.string()).optional(),
|
|
984
837
|
/**
|
|
985
838
|
* Route this agent to a self-hosted runner instead of E2B.
|
|
986
839
|
* When specified, runs will be queued for the specified runner group.
|
|
987
840
|
*/
|
|
988
|
-
experimental_runner:
|
|
989
|
-
group:
|
|
841
|
+
experimental_runner: z3.object({
|
|
842
|
+
group: z3.string().regex(
|
|
990
843
|
/^[a-z0-9-]+\/[a-z0-9-]+$/,
|
|
991
844
|
"Runner group must be in org/name format (e.g., acme/production)"
|
|
992
845
|
)
|
|
993
846
|
}).optional(),
|
|
994
847
|
/**
|
|
995
|
-
* External
|
|
848
|
+
* External firewall rules for proxy-side token replacement.
|
|
996
849
|
* CLI input: map format { slack: { permissions: [...] | "all" } }
|
|
997
|
-
* — expanded by CLI to full
|
|
850
|
+
* — expanded by CLI to full ExpandedFirewallConfig[] before API call.
|
|
998
851
|
*/
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
permissions:
|
|
852
|
+
experimental_firewall: z3.record(
|
|
853
|
+
z3.string(),
|
|
854
|
+
z3.object({
|
|
855
|
+
permissions: z3.union([z3.literal("all"), z3.array(z3.string()).min(1)])
|
|
1003
856
|
})
|
|
1004
857
|
).optional(),
|
|
1005
858
|
/**
|
|
1006
859
|
* Capabilities that the agent is allowed to use.
|
|
1007
860
|
* Validated against VALID_CAPABILITIES at compose time.
|
|
1008
861
|
*/
|
|
1009
|
-
experimental_capabilities:
|
|
862
|
+
experimental_capabilities: z3.array(z3.enum(VALID_CAPABILITIES)).refine((arr) => new Set(arr).size === arr.length, {
|
|
1010
863
|
message: "Duplicate capabilities are not allowed"
|
|
1011
864
|
}).optional(),
|
|
1012
865
|
/**
|
|
@@ -1014,68 +867,68 @@ var agentDefinitionSchema = z4.object({
|
|
|
1014
867
|
* - displayName: Human-readable name shown in the UI (preserves original casing).
|
|
1015
868
|
* - sound: Communication tone (e.g., "professional", "friendly").
|
|
1016
869
|
*/
|
|
1017
|
-
metadata:
|
|
1018
|
-
displayName:
|
|
1019
|
-
description:
|
|
1020
|
-
sound:
|
|
870
|
+
metadata: z3.object({
|
|
871
|
+
displayName: z3.string().optional(),
|
|
872
|
+
description: z3.string().optional(),
|
|
873
|
+
sound: z3.string().optional()
|
|
1021
874
|
}).optional(),
|
|
1022
875
|
/**
|
|
1023
876
|
* @deprecated Server-resolved field. User input is ignored.
|
|
1024
877
|
* @internal
|
|
1025
878
|
*/
|
|
1026
|
-
image:
|
|
879
|
+
image: z3.string().optional(),
|
|
1027
880
|
/**
|
|
1028
881
|
* @deprecated Server-resolved field. User input is ignored.
|
|
1029
882
|
* @internal
|
|
1030
883
|
*/
|
|
1031
|
-
working_dir:
|
|
884
|
+
working_dir: z3.string().optional()
|
|
1032
885
|
});
|
|
1033
|
-
var agentComposeContentSchema =
|
|
1034
|
-
version:
|
|
1035
|
-
agents:
|
|
1036
|
-
volumes:
|
|
886
|
+
var agentComposeContentSchema = z3.object({
|
|
887
|
+
version: z3.string().min(1, "Version is required"),
|
|
888
|
+
agents: z3.record(z3.string(), agentDefinitionSchema),
|
|
889
|
+
volumes: z3.record(z3.string(), volumeConfigSchema).optional()
|
|
1037
890
|
});
|
|
1038
|
-
var
|
|
1039
|
-
name:
|
|
1040
|
-
ref:
|
|
1041
|
-
description:
|
|
1042
|
-
apis:
|
|
1043
|
-
|
|
1044
|
-
base:
|
|
1045
|
-
auth:
|
|
1046
|
-
headers:
|
|
891
|
+
var expandedFirewallConfigSchema = z3.object({
|
|
892
|
+
name: z3.string(),
|
|
893
|
+
ref: z3.string(),
|
|
894
|
+
description: z3.string().optional(),
|
|
895
|
+
apis: z3.array(
|
|
896
|
+
z3.object({
|
|
897
|
+
base: z3.string(),
|
|
898
|
+
auth: z3.object({
|
|
899
|
+
headers: z3.record(z3.string(), z3.string())
|
|
1047
900
|
}),
|
|
1048
|
-
permissions:
|
|
901
|
+
permissions: z3.array(firewallPermissionSchema).optional()
|
|
1049
902
|
})
|
|
1050
903
|
),
|
|
1051
|
-
placeholders:
|
|
904
|
+
placeholders: z3.record(z3.string(), z3.string()).optional()
|
|
1052
905
|
});
|
|
1053
|
-
var agentComposeApiContentSchema =
|
|
1054
|
-
version:
|
|
1055
|
-
agents:
|
|
1056
|
-
|
|
906
|
+
var agentComposeApiContentSchema = z3.object({
|
|
907
|
+
version: z3.string().min(1, "Version is required"),
|
|
908
|
+
agents: z3.record(
|
|
909
|
+
z3.string(),
|
|
1057
910
|
agentDefinitionSchema.extend({
|
|
1058
|
-
|
|
911
|
+
experimental_firewall: z3.array(expandedFirewallConfigSchema).optional()
|
|
1059
912
|
})
|
|
1060
913
|
),
|
|
1061
|
-
volumes:
|
|
914
|
+
volumes: z3.record(z3.string(), volumeConfigSchema).optional()
|
|
1062
915
|
});
|
|
1063
|
-
var composeResponseSchema =
|
|
1064
|
-
id:
|
|
1065
|
-
name:
|
|
1066
|
-
headVersionId:
|
|
916
|
+
var composeResponseSchema = z3.object({
|
|
917
|
+
id: z3.string(),
|
|
918
|
+
name: z3.string(),
|
|
919
|
+
headVersionId: z3.string().nullable(),
|
|
1067
920
|
content: agentComposeApiContentSchema.nullable(),
|
|
1068
|
-
createdAt:
|
|
1069
|
-
updatedAt:
|
|
921
|
+
createdAt: z3.string(),
|
|
922
|
+
updatedAt: z3.string()
|
|
1070
923
|
});
|
|
1071
|
-
var createComposeResponseSchema =
|
|
1072
|
-
composeId:
|
|
1073
|
-
name:
|
|
1074
|
-
versionId:
|
|
1075
|
-
action:
|
|
1076
|
-
updatedAt:
|
|
924
|
+
var createComposeResponseSchema = z3.object({
|
|
925
|
+
composeId: z3.string(),
|
|
926
|
+
name: z3.string(),
|
|
927
|
+
versionId: z3.string(),
|
|
928
|
+
action: z3.enum(["created", "existing"]),
|
|
929
|
+
updatedAt: z3.string()
|
|
1077
930
|
});
|
|
1078
|
-
var composesMainContract =
|
|
931
|
+
var composesMainContract = c.router({
|
|
1079
932
|
/**
|
|
1080
933
|
* GET /api/agent/composes?name={name}&org={org}
|
|
1081
934
|
* Get agent compose by name with HEAD version content
|
|
@@ -1085,9 +938,9 @@ var composesMainContract = c2.router({
|
|
|
1085
938
|
method: "GET",
|
|
1086
939
|
path: "/api/agent/composes",
|
|
1087
940
|
headers: authHeadersSchema,
|
|
1088
|
-
query:
|
|
1089
|
-
name:
|
|
1090
|
-
org:
|
|
941
|
+
query: z3.object({
|
|
942
|
+
name: z3.string().min(1, "Missing name query parameter"),
|
|
943
|
+
org: z3.string().optional()
|
|
1091
944
|
}),
|
|
1092
945
|
responses: {
|
|
1093
946
|
200: composeResponseSchema,
|
|
@@ -1107,7 +960,7 @@ var composesMainContract = c2.router({
|
|
|
1107
960
|
method: "POST",
|
|
1108
961
|
path: "/api/agent/composes",
|
|
1109
962
|
headers: authHeadersSchema,
|
|
1110
|
-
body:
|
|
963
|
+
body: z3.object({
|
|
1111
964
|
content: agentComposeApiContentSchema
|
|
1112
965
|
}),
|
|
1113
966
|
responses: {
|
|
@@ -1119,7 +972,7 @@ var composesMainContract = c2.router({
|
|
|
1119
972
|
summary: "Create or update agent compose version"
|
|
1120
973
|
}
|
|
1121
974
|
});
|
|
1122
|
-
var composesByIdContract =
|
|
975
|
+
var composesByIdContract = c.router({
|
|
1123
976
|
/**
|
|
1124
977
|
* GET /api/agent/composes/:id
|
|
1125
978
|
* Get agent compose by ID with HEAD version content
|
|
@@ -1128,8 +981,8 @@ var composesByIdContract = c2.router({
|
|
|
1128
981
|
method: "GET",
|
|
1129
982
|
path: "/api/agent/composes/:id",
|
|
1130
983
|
headers: authHeadersSchema,
|
|
1131
|
-
pathParams:
|
|
1132
|
-
id:
|
|
984
|
+
pathParams: z3.object({
|
|
985
|
+
id: z3.string().min(1, "Compose ID is required")
|
|
1133
986
|
}),
|
|
1134
987
|
responses: {
|
|
1135
988
|
200: composeResponseSchema,
|
|
@@ -1147,12 +1000,12 @@ var composesByIdContract = c2.router({
|
|
|
1147
1000
|
method: "DELETE",
|
|
1148
1001
|
path: "/api/agent/composes/:id",
|
|
1149
1002
|
headers: authHeadersSchema,
|
|
1150
|
-
pathParams:
|
|
1151
|
-
id:
|
|
1003
|
+
pathParams: z3.object({
|
|
1004
|
+
id: z3.string().uuid("Compose ID is required")
|
|
1152
1005
|
}),
|
|
1153
|
-
body:
|
|
1006
|
+
body: c.noBody(),
|
|
1154
1007
|
responses: {
|
|
1155
|
-
204:
|
|
1008
|
+
204: c.noBody(),
|
|
1156
1009
|
401: apiErrorSchema,
|
|
1157
1010
|
404: apiErrorSchema,
|
|
1158
1011
|
409: apiErrorSchema
|
|
@@ -1160,7 +1013,7 @@ var composesByIdContract = c2.router({
|
|
|
1160
1013
|
summary: "Delete agent compose"
|
|
1161
1014
|
}
|
|
1162
1015
|
});
|
|
1163
|
-
var composesVersionsContract =
|
|
1016
|
+
var composesVersionsContract = c.router({
|
|
1164
1017
|
/**
|
|
1165
1018
|
* GET /api/agent/composes/versions?composeId={id}&version={hash|tag}
|
|
1166
1019
|
* Resolve a version specifier to a full version ID
|
|
@@ -1169,14 +1022,14 @@ var composesVersionsContract = c2.router({
|
|
|
1169
1022
|
method: "GET",
|
|
1170
1023
|
path: "/api/agent/composes/versions",
|
|
1171
1024
|
headers: authHeadersSchema,
|
|
1172
|
-
query:
|
|
1173
|
-
composeId:
|
|
1025
|
+
query: z3.object({
|
|
1026
|
+
composeId: z3.string().min(1, "Missing composeId query parameter"),
|
|
1174
1027
|
version: composeVersionQuerySchema
|
|
1175
1028
|
}),
|
|
1176
1029
|
responses: {
|
|
1177
|
-
200:
|
|
1178
|
-
versionId:
|
|
1179
|
-
tag:
|
|
1030
|
+
200: z3.object({
|
|
1031
|
+
versionId: z3.string(),
|
|
1032
|
+
tag: z3.string().optional()
|
|
1180
1033
|
}),
|
|
1181
1034
|
400: apiErrorSchema,
|
|
1182
1035
|
401: apiErrorSchema,
|
|
@@ -1185,16 +1038,16 @@ var composesVersionsContract = c2.router({
|
|
|
1185
1038
|
summary: "Resolve version specifier to full version ID"
|
|
1186
1039
|
}
|
|
1187
1040
|
});
|
|
1188
|
-
var composeListItemSchema =
|
|
1189
|
-
id:
|
|
1190
|
-
name:
|
|
1191
|
-
displayName:
|
|
1192
|
-
description:
|
|
1193
|
-
headVersionId:
|
|
1194
|
-
updatedAt:
|
|
1195
|
-
isOwner:
|
|
1041
|
+
var composeListItemSchema = z3.object({
|
|
1042
|
+
id: z3.string(),
|
|
1043
|
+
name: z3.string(),
|
|
1044
|
+
displayName: z3.string().nullable().optional(),
|
|
1045
|
+
description: z3.string().nullable().optional(),
|
|
1046
|
+
headVersionId: z3.string().nullable(),
|
|
1047
|
+
updatedAt: z3.string(),
|
|
1048
|
+
isOwner: z3.boolean()
|
|
1196
1049
|
});
|
|
1197
|
-
var composesListContract =
|
|
1050
|
+
var composesListContract = c.router({
|
|
1198
1051
|
/**
|
|
1199
1052
|
* GET /api/agent/composes/list?org={org}
|
|
1200
1053
|
* List all agent composes for an org
|
|
@@ -1204,12 +1057,12 @@ var composesListContract = c2.router({
|
|
|
1204
1057
|
method: "GET",
|
|
1205
1058
|
path: "/api/agent/composes/list",
|
|
1206
1059
|
headers: authHeadersSchema,
|
|
1207
|
-
query:
|
|
1208
|
-
org:
|
|
1060
|
+
query: z3.object({
|
|
1061
|
+
org: z3.string().optional()
|
|
1209
1062
|
}),
|
|
1210
1063
|
responses: {
|
|
1211
|
-
200:
|
|
1212
|
-
composes:
|
|
1064
|
+
200: z3.object({
|
|
1065
|
+
composes: z3.array(composeListItemSchema)
|
|
1213
1066
|
}),
|
|
1214
1067
|
400: apiErrorSchema,
|
|
1215
1068
|
401: apiErrorSchema
|
|
@@ -1219,8 +1072,8 @@ var composesListContract = c2.router({
|
|
|
1219
1072
|
});
|
|
1220
1073
|
|
|
1221
1074
|
// ../../packages/core/src/contracts/runs.ts
|
|
1222
|
-
import { z as
|
|
1223
|
-
var
|
|
1075
|
+
import { z as z4 } from "zod";
|
|
1076
|
+
var c2 = initContract();
|
|
1224
1077
|
var ALL_RUN_STATUSES = [
|
|
1225
1078
|
"queued",
|
|
1226
1079
|
"pending",
|
|
@@ -1230,94 +1083,94 @@ var ALL_RUN_STATUSES = [
|
|
|
1230
1083
|
"timeout",
|
|
1231
1084
|
"cancelled"
|
|
1232
1085
|
];
|
|
1233
|
-
var runStatusSchema =
|
|
1234
|
-
var unifiedRunRequestSchema =
|
|
1086
|
+
var runStatusSchema = z4.enum(ALL_RUN_STATUSES);
|
|
1087
|
+
var unifiedRunRequestSchema = z4.object({
|
|
1235
1088
|
// High-level shortcuts (mutually exclusive with each other)
|
|
1236
|
-
checkpointId:
|
|
1237
|
-
sessionId:
|
|
1089
|
+
checkpointId: z4.string().optional(),
|
|
1090
|
+
sessionId: z4.string().optional(),
|
|
1238
1091
|
// Base parameters (can be used directly or overridden after shortcut expansion)
|
|
1239
|
-
agentComposeId:
|
|
1240
|
-
agentComposeVersionId:
|
|
1241
|
-
conversationId:
|
|
1242
|
-
artifactName:
|
|
1243
|
-
artifactVersion:
|
|
1244
|
-
vars:
|
|
1245
|
-
secrets:
|
|
1246
|
-
volumeVersions:
|
|
1247
|
-
memoryName:
|
|
1092
|
+
agentComposeId: z4.string().optional(),
|
|
1093
|
+
agentComposeVersionId: z4.string().optional(),
|
|
1094
|
+
conversationId: z4.string().optional(),
|
|
1095
|
+
artifactName: z4.string().optional(),
|
|
1096
|
+
artifactVersion: z4.string().optional(),
|
|
1097
|
+
vars: z4.record(z4.string(), z4.string()).optional(),
|
|
1098
|
+
secrets: z4.record(z4.string(), z4.string()).optional(),
|
|
1099
|
+
volumeVersions: z4.record(z4.string(), z4.string()).optional(),
|
|
1100
|
+
memoryName: z4.string().optional(),
|
|
1248
1101
|
// Debug flag to force real Claude in mock environments (internal use only)
|
|
1249
|
-
debugNoMockClaude:
|
|
1102
|
+
debugNoMockClaude: z4.boolean().optional(),
|
|
1250
1103
|
// Model provider for automatic secret injection
|
|
1251
|
-
modelProvider:
|
|
1104
|
+
modelProvider: z4.string().optional(),
|
|
1252
1105
|
// Environment validation flag - when true, validates secrets/vars before running
|
|
1253
|
-
checkEnv:
|
|
1106
|
+
checkEnv: z4.boolean().optional(),
|
|
1254
1107
|
// Required
|
|
1255
|
-
prompt:
|
|
1108
|
+
prompt: z4.string().min(1, "Missing prompt")
|
|
1256
1109
|
});
|
|
1257
|
-
var createRunResponseSchema =
|
|
1258
|
-
runId:
|
|
1110
|
+
var createRunResponseSchema = z4.object({
|
|
1111
|
+
runId: z4.string(),
|
|
1259
1112
|
status: runStatusSchema,
|
|
1260
|
-
sandboxId:
|
|
1261
|
-
output:
|
|
1262
|
-
error:
|
|
1263
|
-
executionTimeMs:
|
|
1264
|
-
createdAt:
|
|
1113
|
+
sandboxId: z4.string().optional(),
|
|
1114
|
+
output: z4.string().optional(),
|
|
1115
|
+
error: z4.string().optional(),
|
|
1116
|
+
executionTimeMs: z4.number().optional(),
|
|
1117
|
+
createdAt: z4.string()
|
|
1265
1118
|
});
|
|
1266
|
-
var getRunResponseSchema =
|
|
1267
|
-
runId:
|
|
1268
|
-
agentComposeVersionId:
|
|
1119
|
+
var getRunResponseSchema = z4.object({
|
|
1120
|
+
runId: z4.string(),
|
|
1121
|
+
agentComposeVersionId: z4.string().nullable(),
|
|
1269
1122
|
status: runStatusSchema,
|
|
1270
|
-
prompt:
|
|
1271
|
-
vars:
|
|
1272
|
-
sandboxId:
|
|
1273
|
-
result:
|
|
1274
|
-
output:
|
|
1275
|
-
executionTimeMs:
|
|
1123
|
+
prompt: z4.string(),
|
|
1124
|
+
vars: z4.record(z4.string(), z4.string()).optional(),
|
|
1125
|
+
sandboxId: z4.string().optional(),
|
|
1126
|
+
result: z4.object({
|
|
1127
|
+
output: z4.string(),
|
|
1128
|
+
executionTimeMs: z4.number()
|
|
1276
1129
|
}).optional(),
|
|
1277
|
-
error:
|
|
1278
|
-
createdAt:
|
|
1279
|
-
startedAt:
|
|
1280
|
-
completedAt:
|
|
1130
|
+
error: z4.string().optional(),
|
|
1131
|
+
createdAt: z4.string(),
|
|
1132
|
+
startedAt: z4.string().optional(),
|
|
1133
|
+
completedAt: z4.string().optional()
|
|
1281
1134
|
});
|
|
1282
|
-
var runEventSchema =
|
|
1283
|
-
sequenceNumber:
|
|
1284
|
-
eventType:
|
|
1285
|
-
eventData:
|
|
1286
|
-
createdAt:
|
|
1135
|
+
var runEventSchema = z4.object({
|
|
1136
|
+
sequenceNumber: z4.number(),
|
|
1137
|
+
eventType: z4.string(),
|
|
1138
|
+
eventData: z4.unknown(),
|
|
1139
|
+
createdAt: z4.string()
|
|
1287
1140
|
});
|
|
1288
|
-
var runResultSchema =
|
|
1289
|
-
checkpointId:
|
|
1290
|
-
agentSessionId:
|
|
1291
|
-
conversationId:
|
|
1292
|
-
artifact:
|
|
1141
|
+
var runResultSchema = z4.object({
|
|
1142
|
+
checkpointId: z4.string(),
|
|
1143
|
+
agentSessionId: z4.string(),
|
|
1144
|
+
conversationId: z4.string(),
|
|
1145
|
+
artifact: z4.record(z4.string(), z4.string()).optional(),
|
|
1293
1146
|
// optional when run has no artifact
|
|
1294
|
-
volumes:
|
|
1295
|
-
memory:
|
|
1147
|
+
volumes: z4.record(z4.string(), z4.string()).optional(),
|
|
1148
|
+
memory: z4.record(z4.string(), z4.string()).optional()
|
|
1296
1149
|
});
|
|
1297
|
-
var runStateSchema =
|
|
1150
|
+
var runStateSchema = z4.object({
|
|
1298
1151
|
status: runStatusSchema,
|
|
1299
1152
|
result: runResultSchema.optional(),
|
|
1300
|
-
error:
|
|
1153
|
+
error: z4.string().optional()
|
|
1301
1154
|
});
|
|
1302
|
-
var eventsResponseSchema =
|
|
1303
|
-
events:
|
|
1304
|
-
hasMore:
|
|
1305
|
-
nextSequence:
|
|
1155
|
+
var eventsResponseSchema = z4.object({
|
|
1156
|
+
events: z4.array(runEventSchema),
|
|
1157
|
+
hasMore: z4.boolean(),
|
|
1158
|
+
nextSequence: z4.number(),
|
|
1306
1159
|
run: runStateSchema,
|
|
1307
|
-
framework:
|
|
1160
|
+
framework: z4.string()
|
|
1308
1161
|
});
|
|
1309
|
-
var runListItemSchema =
|
|
1310
|
-
id:
|
|
1311
|
-
agentName:
|
|
1162
|
+
var runListItemSchema = z4.object({
|
|
1163
|
+
id: z4.string(),
|
|
1164
|
+
agentName: z4.string(),
|
|
1312
1165
|
status: runStatusSchema,
|
|
1313
|
-
prompt:
|
|
1314
|
-
createdAt:
|
|
1315
|
-
startedAt:
|
|
1166
|
+
prompt: z4.string(),
|
|
1167
|
+
createdAt: z4.string(),
|
|
1168
|
+
startedAt: z4.string().nullable()
|
|
1316
1169
|
});
|
|
1317
|
-
var runsListResponseSchema =
|
|
1318
|
-
runs:
|
|
1170
|
+
var runsListResponseSchema = z4.object({
|
|
1171
|
+
runs: z4.array(runListItemSchema)
|
|
1319
1172
|
});
|
|
1320
|
-
var runsMainContract =
|
|
1173
|
+
var runsMainContract = c2.router({
|
|
1321
1174
|
/**
|
|
1322
1175
|
* GET /api/agent/runs
|
|
1323
1176
|
* List agent runs (pending and running by default)
|
|
@@ -1326,16 +1179,16 @@ var runsMainContract = c3.router({
|
|
|
1326
1179
|
method: "GET",
|
|
1327
1180
|
path: "/api/agent/runs",
|
|
1328
1181
|
headers: authHeadersSchema,
|
|
1329
|
-
query:
|
|
1330
|
-
status:
|
|
1182
|
+
query: z4.object({
|
|
1183
|
+
status: z4.string().optional(),
|
|
1331
1184
|
// comma-separated: "pending,running"
|
|
1332
|
-
agent:
|
|
1185
|
+
agent: z4.string().optional(),
|
|
1333
1186
|
// agent name filter
|
|
1334
|
-
since:
|
|
1187
|
+
since: z4.string().optional(),
|
|
1335
1188
|
// ISO timestamp
|
|
1336
|
-
until:
|
|
1189
|
+
until: z4.string().optional(),
|
|
1337
1190
|
// ISO timestamp
|
|
1338
|
-
limit:
|
|
1191
|
+
limit: z4.coerce.number().min(1).max(100).default(50)
|
|
1339
1192
|
}),
|
|
1340
1193
|
responses: {
|
|
1341
1194
|
200: runsListResponseSchema,
|
|
@@ -1362,7 +1215,7 @@ var runsMainContract = c3.router({
|
|
|
1362
1215
|
summary: "Create and execute agent run"
|
|
1363
1216
|
}
|
|
1364
1217
|
});
|
|
1365
|
-
var runsByIdContract =
|
|
1218
|
+
var runsByIdContract = c2.router({
|
|
1366
1219
|
/**
|
|
1367
1220
|
* GET /api/agent/runs/:id
|
|
1368
1221
|
* Get agent run status and results
|
|
@@ -1371,8 +1224,8 @@ var runsByIdContract = c3.router({
|
|
|
1371
1224
|
method: "GET",
|
|
1372
1225
|
path: "/api/agent/runs/:id",
|
|
1373
1226
|
headers: authHeadersSchema,
|
|
1374
|
-
pathParams:
|
|
1375
|
-
id:
|
|
1227
|
+
pathParams: z4.object({
|
|
1228
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1376
1229
|
}),
|
|
1377
1230
|
responses: {
|
|
1378
1231
|
200: getRunResponseSchema,
|
|
@@ -1383,12 +1236,12 @@ var runsByIdContract = c3.router({
|
|
|
1383
1236
|
summary: "Get agent run by ID"
|
|
1384
1237
|
}
|
|
1385
1238
|
});
|
|
1386
|
-
var cancelRunResponseSchema =
|
|
1387
|
-
id:
|
|
1388
|
-
status:
|
|
1389
|
-
message:
|
|
1239
|
+
var cancelRunResponseSchema = z4.object({
|
|
1240
|
+
id: z4.string(),
|
|
1241
|
+
status: z4.literal("cancelled"),
|
|
1242
|
+
message: z4.string()
|
|
1390
1243
|
});
|
|
1391
|
-
var runsCancelContract =
|
|
1244
|
+
var runsCancelContract = c2.router({
|
|
1392
1245
|
/**
|
|
1393
1246
|
* POST /api/agent/runs/:id/cancel
|
|
1394
1247
|
* Cancel a pending or running run
|
|
@@ -1397,10 +1250,10 @@ var runsCancelContract = c3.router({
|
|
|
1397
1250
|
method: "POST",
|
|
1398
1251
|
path: "/api/agent/runs/:id/cancel",
|
|
1399
1252
|
headers: authHeadersSchema,
|
|
1400
|
-
pathParams:
|
|
1401
|
-
id:
|
|
1253
|
+
pathParams: z4.object({
|
|
1254
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1402
1255
|
}),
|
|
1403
|
-
body:
|
|
1256
|
+
body: z4.undefined(),
|
|
1404
1257
|
responses: {
|
|
1405
1258
|
200: cancelRunResponseSchema,
|
|
1406
1259
|
400: apiErrorSchema,
|
|
@@ -1410,7 +1263,7 @@ var runsCancelContract = c3.router({
|
|
|
1410
1263
|
summary: "Cancel a pending or running run"
|
|
1411
1264
|
}
|
|
1412
1265
|
});
|
|
1413
|
-
var runEventsContract =
|
|
1266
|
+
var runEventsContract = c2.router({
|
|
1414
1267
|
/**
|
|
1415
1268
|
* GET /api/agent/runs/:id/events
|
|
1416
1269
|
* Poll for agent run events with pagination
|
|
@@ -1419,12 +1272,12 @@ var runEventsContract = c3.router({
|
|
|
1419
1272
|
method: "GET",
|
|
1420
1273
|
path: "/api/agent/runs/:id/events",
|
|
1421
1274
|
headers: authHeadersSchema,
|
|
1422
|
-
pathParams:
|
|
1423
|
-
id:
|
|
1275
|
+
pathParams: z4.object({
|
|
1276
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1424
1277
|
}),
|
|
1425
|
-
query:
|
|
1426
|
-
since:
|
|
1427
|
-
limit:
|
|
1278
|
+
query: z4.object({
|
|
1279
|
+
since: z4.coerce.number().default(-1),
|
|
1280
|
+
limit: z4.coerce.number().default(100)
|
|
1428
1281
|
}),
|
|
1429
1282
|
responses: {
|
|
1430
1283
|
200: eventsResponseSchema,
|
|
@@ -1434,50 +1287,50 @@ var runEventsContract = c3.router({
|
|
|
1434
1287
|
summary: "Get agent run events"
|
|
1435
1288
|
}
|
|
1436
1289
|
});
|
|
1437
|
-
var telemetryMetricSchema =
|
|
1438
|
-
ts:
|
|
1439
|
-
cpu:
|
|
1440
|
-
mem_used:
|
|
1441
|
-
mem_total:
|
|
1442
|
-
disk_used:
|
|
1443
|
-
disk_total:
|
|
1290
|
+
var telemetryMetricSchema = z4.object({
|
|
1291
|
+
ts: z4.string(),
|
|
1292
|
+
cpu: z4.number(),
|
|
1293
|
+
mem_used: z4.number(),
|
|
1294
|
+
mem_total: z4.number(),
|
|
1295
|
+
disk_used: z4.number(),
|
|
1296
|
+
disk_total: z4.number()
|
|
1444
1297
|
});
|
|
1445
|
-
var systemLogResponseSchema =
|
|
1446
|
-
systemLog:
|
|
1447
|
-
hasMore:
|
|
1298
|
+
var systemLogResponseSchema = z4.object({
|
|
1299
|
+
systemLog: z4.string(),
|
|
1300
|
+
hasMore: z4.boolean()
|
|
1448
1301
|
});
|
|
1449
|
-
var metricsResponseSchema =
|
|
1450
|
-
metrics:
|
|
1451
|
-
hasMore:
|
|
1302
|
+
var metricsResponseSchema = z4.object({
|
|
1303
|
+
metrics: z4.array(telemetryMetricSchema),
|
|
1304
|
+
hasMore: z4.boolean()
|
|
1452
1305
|
});
|
|
1453
|
-
var agentEventsResponseSchema =
|
|
1454
|
-
events:
|
|
1455
|
-
hasMore:
|
|
1456
|
-
framework:
|
|
1306
|
+
var agentEventsResponseSchema = z4.object({
|
|
1307
|
+
events: z4.array(runEventSchema),
|
|
1308
|
+
hasMore: z4.boolean(),
|
|
1309
|
+
framework: z4.string()
|
|
1457
1310
|
});
|
|
1458
|
-
var networkLogEntrySchema =
|
|
1459
|
-
timestamp:
|
|
1460
|
-
mode:
|
|
1461
|
-
action:
|
|
1462
|
-
host:
|
|
1463
|
-
port:
|
|
1464
|
-
rule_matched:
|
|
1465
|
-
method:
|
|
1466
|
-
url:
|
|
1467
|
-
status:
|
|
1468
|
-
latency_ms:
|
|
1469
|
-
request_size:
|
|
1470
|
-
response_size:
|
|
1311
|
+
var networkLogEntrySchema = z4.object({
|
|
1312
|
+
timestamp: z4.string(),
|
|
1313
|
+
mode: z4.literal("mitm").optional(),
|
|
1314
|
+
action: z4.enum(["ALLOW", "DENY"]).optional(),
|
|
1315
|
+
host: z4.string().optional(),
|
|
1316
|
+
port: z4.number().optional(),
|
|
1317
|
+
rule_matched: z4.string().nullable().optional(),
|
|
1318
|
+
method: z4.string().optional(),
|
|
1319
|
+
url: z4.string().optional(),
|
|
1320
|
+
status: z4.number().optional(),
|
|
1321
|
+
latency_ms: z4.number().optional(),
|
|
1322
|
+
request_size: z4.number().optional(),
|
|
1323
|
+
response_size: z4.number().optional()
|
|
1471
1324
|
});
|
|
1472
|
-
var networkLogsResponseSchema =
|
|
1473
|
-
networkLogs:
|
|
1474
|
-
hasMore:
|
|
1325
|
+
var networkLogsResponseSchema = z4.object({
|
|
1326
|
+
networkLogs: z4.array(networkLogEntrySchema),
|
|
1327
|
+
hasMore: z4.boolean()
|
|
1475
1328
|
});
|
|
1476
|
-
var telemetryResponseSchema =
|
|
1477
|
-
systemLog:
|
|
1478
|
-
metrics:
|
|
1329
|
+
var telemetryResponseSchema = z4.object({
|
|
1330
|
+
systemLog: z4.string(),
|
|
1331
|
+
metrics: z4.array(telemetryMetricSchema)
|
|
1479
1332
|
});
|
|
1480
|
-
var runTelemetryContract =
|
|
1333
|
+
var runTelemetryContract = c2.router({
|
|
1481
1334
|
/**
|
|
1482
1335
|
* GET /api/agent/runs/:id/telemetry
|
|
1483
1336
|
* Get aggregated telemetry data for a run (legacy combined format)
|
|
@@ -1486,8 +1339,8 @@ var runTelemetryContract = c3.router({
|
|
|
1486
1339
|
method: "GET",
|
|
1487
1340
|
path: "/api/agent/runs/:id/telemetry",
|
|
1488
1341
|
headers: authHeadersSchema,
|
|
1489
|
-
pathParams:
|
|
1490
|
-
id:
|
|
1342
|
+
pathParams: z4.object({
|
|
1343
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1491
1344
|
}),
|
|
1492
1345
|
responses: {
|
|
1493
1346
|
200: telemetryResponseSchema,
|
|
@@ -1497,7 +1350,7 @@ var runTelemetryContract = c3.router({
|
|
|
1497
1350
|
summary: "Get run telemetry data"
|
|
1498
1351
|
}
|
|
1499
1352
|
});
|
|
1500
|
-
var runSystemLogContract =
|
|
1353
|
+
var runSystemLogContract = c2.router({
|
|
1501
1354
|
/**
|
|
1502
1355
|
* GET /api/agent/runs/:id/telemetry/system-log
|
|
1503
1356
|
* Get system log with pagination
|
|
@@ -1506,13 +1359,13 @@ var runSystemLogContract = c3.router({
|
|
|
1506
1359
|
method: "GET",
|
|
1507
1360
|
path: "/api/agent/runs/:id/telemetry/system-log",
|
|
1508
1361
|
headers: authHeadersSchema,
|
|
1509
|
-
pathParams:
|
|
1510
|
-
id:
|
|
1362
|
+
pathParams: z4.object({
|
|
1363
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1511
1364
|
}),
|
|
1512
|
-
query:
|
|
1513
|
-
since:
|
|
1514
|
-
limit:
|
|
1515
|
-
order:
|
|
1365
|
+
query: z4.object({
|
|
1366
|
+
since: z4.coerce.number().optional(),
|
|
1367
|
+
limit: z4.coerce.number().min(1).max(100).default(5),
|
|
1368
|
+
order: z4.enum(["asc", "desc"]).default("desc")
|
|
1516
1369
|
}),
|
|
1517
1370
|
responses: {
|
|
1518
1371
|
200: systemLogResponseSchema,
|
|
@@ -1522,7 +1375,7 @@ var runSystemLogContract = c3.router({
|
|
|
1522
1375
|
summary: "Get system log with pagination"
|
|
1523
1376
|
}
|
|
1524
1377
|
});
|
|
1525
|
-
var runMetricsContract =
|
|
1378
|
+
var runMetricsContract = c2.router({
|
|
1526
1379
|
/**
|
|
1527
1380
|
* GET /api/agent/runs/:id/telemetry/metrics
|
|
1528
1381
|
* Get metrics with pagination
|
|
@@ -1531,13 +1384,13 @@ var runMetricsContract = c3.router({
|
|
|
1531
1384
|
method: "GET",
|
|
1532
1385
|
path: "/api/agent/runs/:id/telemetry/metrics",
|
|
1533
1386
|
headers: authHeadersSchema,
|
|
1534
|
-
pathParams:
|
|
1535
|
-
id:
|
|
1387
|
+
pathParams: z4.object({
|
|
1388
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1536
1389
|
}),
|
|
1537
|
-
query:
|
|
1538
|
-
since:
|
|
1539
|
-
limit:
|
|
1540
|
-
order:
|
|
1390
|
+
query: z4.object({
|
|
1391
|
+
since: z4.coerce.number().optional(),
|
|
1392
|
+
limit: z4.coerce.number().min(1).max(100).default(5),
|
|
1393
|
+
order: z4.enum(["asc", "desc"]).default("desc")
|
|
1541
1394
|
}),
|
|
1542
1395
|
responses: {
|
|
1543
1396
|
200: metricsResponseSchema,
|
|
@@ -1547,7 +1400,7 @@ var runMetricsContract = c3.router({
|
|
|
1547
1400
|
summary: "Get metrics with pagination"
|
|
1548
1401
|
}
|
|
1549
1402
|
});
|
|
1550
|
-
var runAgentEventsContract =
|
|
1403
|
+
var runAgentEventsContract = c2.router({
|
|
1551
1404
|
/**
|
|
1552
1405
|
* GET /api/agent/runs/:id/telemetry/agent
|
|
1553
1406
|
* Get agent events with pagination (for vm0 logs default)
|
|
@@ -1556,13 +1409,13 @@ var runAgentEventsContract = c3.router({
|
|
|
1556
1409
|
method: "GET",
|
|
1557
1410
|
path: "/api/agent/runs/:id/telemetry/agent",
|
|
1558
1411
|
headers: authHeadersSchema,
|
|
1559
|
-
pathParams:
|
|
1560
|
-
id:
|
|
1412
|
+
pathParams: z4.object({
|
|
1413
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1561
1414
|
}),
|
|
1562
|
-
query:
|
|
1563
|
-
since:
|
|
1564
|
-
limit:
|
|
1565
|
-
order:
|
|
1415
|
+
query: z4.object({
|
|
1416
|
+
since: z4.coerce.number().optional(),
|
|
1417
|
+
limit: z4.coerce.number().min(1).max(100).default(5),
|
|
1418
|
+
order: z4.enum(["asc", "desc"]).default("desc")
|
|
1566
1419
|
}),
|
|
1567
1420
|
responses: {
|
|
1568
1421
|
200: agentEventsResponseSchema,
|
|
@@ -1572,7 +1425,7 @@ var runAgentEventsContract = c3.router({
|
|
|
1572
1425
|
summary: "Get agent events with pagination"
|
|
1573
1426
|
}
|
|
1574
1427
|
});
|
|
1575
|
-
var runNetworkLogsContract =
|
|
1428
|
+
var runNetworkLogsContract = c2.router({
|
|
1576
1429
|
/**
|
|
1577
1430
|
* GET /api/agent/runs/:id/telemetry/network
|
|
1578
1431
|
* Get network logs with pagination (for vm0 logs --network)
|
|
@@ -1581,13 +1434,13 @@ var runNetworkLogsContract = c3.router({
|
|
|
1581
1434
|
method: "GET",
|
|
1582
1435
|
path: "/api/agent/runs/:id/telemetry/network",
|
|
1583
1436
|
headers: authHeadersSchema,
|
|
1584
|
-
pathParams:
|
|
1585
|
-
id:
|
|
1437
|
+
pathParams: z4.object({
|
|
1438
|
+
id: z4.string().min(1, "Run ID is required")
|
|
1586
1439
|
}),
|
|
1587
|
-
query:
|
|
1588
|
-
since:
|
|
1589
|
-
limit:
|
|
1590
|
-
order:
|
|
1440
|
+
query: z4.object({
|
|
1441
|
+
since: z4.coerce.number().optional(),
|
|
1442
|
+
limit: z4.coerce.number().min(1).max(100).default(5),
|
|
1443
|
+
order: z4.enum(["asc", "desc"]).default("desc")
|
|
1591
1444
|
}),
|
|
1592
1445
|
responses: {
|
|
1593
1446
|
200: networkLogsResponseSchema,
|
|
@@ -1597,18 +1450,18 @@ var runNetworkLogsContract = c3.router({
|
|
|
1597
1450
|
summary: "Get network logs with pagination"
|
|
1598
1451
|
}
|
|
1599
1452
|
});
|
|
1600
|
-
var searchResultSchema =
|
|
1601
|
-
runId:
|
|
1602
|
-
agentName:
|
|
1453
|
+
var searchResultSchema = z4.object({
|
|
1454
|
+
runId: z4.string(),
|
|
1455
|
+
agentName: z4.string(),
|
|
1603
1456
|
matchedEvent: runEventSchema,
|
|
1604
|
-
contextBefore:
|
|
1605
|
-
contextAfter:
|
|
1457
|
+
contextBefore: z4.array(runEventSchema),
|
|
1458
|
+
contextAfter: z4.array(runEventSchema)
|
|
1606
1459
|
});
|
|
1607
|
-
var logsSearchResponseSchema =
|
|
1608
|
-
results:
|
|
1609
|
-
hasMore:
|
|
1460
|
+
var logsSearchResponseSchema = z4.object({
|
|
1461
|
+
results: z4.array(searchResultSchema),
|
|
1462
|
+
hasMore: z4.boolean()
|
|
1610
1463
|
});
|
|
1611
|
-
var logsSearchContract =
|
|
1464
|
+
var logsSearchContract = c2.router({
|
|
1612
1465
|
/**
|
|
1613
1466
|
* GET /api/logs/search
|
|
1614
1467
|
* Search agent events across runs using keyword matching
|
|
@@ -1617,14 +1470,14 @@ var logsSearchContract = c3.router({
|
|
|
1617
1470
|
method: "GET",
|
|
1618
1471
|
path: "/api/logs/search",
|
|
1619
1472
|
headers: authHeadersSchema,
|
|
1620
|
-
query:
|
|
1621
|
-
keyword:
|
|
1622
|
-
agent:
|
|
1623
|
-
runId:
|
|
1624
|
-
since:
|
|
1625
|
-
limit:
|
|
1626
|
-
before:
|
|
1627
|
-
after:
|
|
1473
|
+
query: z4.object({
|
|
1474
|
+
keyword: z4.string().min(1),
|
|
1475
|
+
agent: z4.string().optional(),
|
|
1476
|
+
runId: z4.string().optional(),
|
|
1477
|
+
since: z4.coerce.number().optional(),
|
|
1478
|
+
limit: z4.coerce.number().min(1).max(50).default(20),
|
|
1479
|
+
before: z4.coerce.number().min(0).max(10).default(0),
|
|
1480
|
+
after: z4.coerce.number().min(0).max(10).default(0)
|
|
1628
1481
|
}),
|
|
1629
1482
|
responses: {
|
|
1630
1483
|
200: logsSearchResponseSchema,
|
|
@@ -1635,19 +1488,19 @@ var logsSearchContract = c3.router({
|
|
|
1635
1488
|
});
|
|
1636
1489
|
|
|
1637
1490
|
// ../../packages/core/src/contracts/storages.ts
|
|
1638
|
-
import { z as
|
|
1639
|
-
var
|
|
1640
|
-
var storageTypeSchema =
|
|
1641
|
-
var versionQuerySchema =
|
|
1642
|
-
var uploadStorageResponseSchema =
|
|
1643
|
-
name:
|
|
1644
|
-
versionId:
|
|
1645
|
-
size:
|
|
1646
|
-
fileCount:
|
|
1491
|
+
import { z as z5 } from "zod";
|
|
1492
|
+
var c3 = initContract();
|
|
1493
|
+
var storageTypeSchema = z5.enum(["volume", "artifact", "memory"]);
|
|
1494
|
+
var versionQuerySchema = z5.string().regex(/^[a-f0-9]{8,64}$/i, "Version must be 8-64 hex characters").optional();
|
|
1495
|
+
var uploadStorageResponseSchema = z5.object({
|
|
1496
|
+
name: z5.string(),
|
|
1497
|
+
versionId: z5.string(),
|
|
1498
|
+
size: z5.number(),
|
|
1499
|
+
fileCount: z5.number(),
|
|
1647
1500
|
type: storageTypeSchema,
|
|
1648
|
-
deduplicated:
|
|
1501
|
+
deduplicated: z5.boolean()
|
|
1649
1502
|
});
|
|
1650
|
-
var storagesContract =
|
|
1503
|
+
var storagesContract = c3.router({
|
|
1651
1504
|
/**
|
|
1652
1505
|
* POST /api/storages
|
|
1653
1506
|
* Upload a storage (tar.gz file)
|
|
@@ -1664,7 +1517,7 @@ var storagesContract = c4.router({
|
|
|
1664
1517
|
path: "/api/storages",
|
|
1665
1518
|
headers: authHeadersSchema,
|
|
1666
1519
|
contentType: "multipart/form-data",
|
|
1667
|
-
body:
|
|
1520
|
+
body: c3.type(),
|
|
1668
1521
|
responses: {
|
|
1669
1522
|
200: uploadStorageResponseSchema,
|
|
1670
1523
|
400: apiErrorSchema,
|
|
@@ -1687,15 +1540,15 @@ var storagesContract = c4.router({
|
|
|
1687
1540
|
method: "GET",
|
|
1688
1541
|
path: "/api/storages",
|
|
1689
1542
|
headers: authHeadersSchema,
|
|
1690
|
-
query:
|
|
1691
|
-
name:
|
|
1543
|
+
query: z5.object({
|
|
1544
|
+
name: z5.string().min(1, "Storage name is required"),
|
|
1692
1545
|
version: versionQuerySchema
|
|
1693
1546
|
}),
|
|
1694
1547
|
responses: {
|
|
1695
1548
|
// Binary response - actual handling done at route level
|
|
1696
|
-
200:
|
|
1549
|
+
200: c3.otherResponse({
|
|
1697
1550
|
contentType: "application/gzip",
|
|
1698
|
-
body:
|
|
1551
|
+
body: c3.type()
|
|
1699
1552
|
}),
|
|
1700
1553
|
400: apiErrorSchema,
|
|
1701
1554
|
401: apiErrorSchema,
|
|
@@ -1706,41 +1559,41 @@ var storagesContract = c4.router({
|
|
|
1706
1559
|
}
|
|
1707
1560
|
});
|
|
1708
1561
|
var MAX_FILE_SIZE_BYTES = 104857600;
|
|
1709
|
-
var fileEntryWithHashSchema =
|
|
1710
|
-
path:
|
|
1711
|
-
hash:
|
|
1712
|
-
size:
|
|
1562
|
+
var fileEntryWithHashSchema = z5.object({
|
|
1563
|
+
path: z5.string().min(1, "File path is required"),
|
|
1564
|
+
hash: z5.string().length(64, "Hash must be SHA-256 (64 hex chars)"),
|
|
1565
|
+
size: z5.number().int().min(0, "Size must be non-negative").max(MAX_FILE_SIZE_BYTES, "File size exceeds 100MB limit")
|
|
1713
1566
|
});
|
|
1714
|
-
var storageChangesSchema =
|
|
1715
|
-
added:
|
|
1716
|
-
modified:
|
|
1717
|
-
deleted:
|
|
1567
|
+
var storageChangesSchema = z5.object({
|
|
1568
|
+
added: z5.array(z5.string()),
|
|
1569
|
+
modified: z5.array(z5.string()),
|
|
1570
|
+
deleted: z5.array(z5.string())
|
|
1718
1571
|
});
|
|
1719
|
-
var presignedUploadSchema =
|
|
1720
|
-
key:
|
|
1721
|
-
presignedUrl:
|
|
1572
|
+
var presignedUploadSchema = z5.object({
|
|
1573
|
+
key: z5.string(),
|
|
1574
|
+
presignedUrl: z5.string().url()
|
|
1722
1575
|
});
|
|
1723
|
-
var storagesPrepareContract =
|
|
1576
|
+
var storagesPrepareContract = c3.router({
|
|
1724
1577
|
prepare: {
|
|
1725
1578
|
method: "POST",
|
|
1726
1579
|
path: "/api/storages/prepare",
|
|
1727
1580
|
headers: authHeadersSchema,
|
|
1728
|
-
body:
|
|
1729
|
-
storageName:
|
|
1581
|
+
body: z5.object({
|
|
1582
|
+
storageName: z5.string().min(1, "Storage name is required"),
|
|
1730
1583
|
storageType: storageTypeSchema,
|
|
1731
|
-
files:
|
|
1732
|
-
force:
|
|
1733
|
-
runId:
|
|
1584
|
+
files: z5.array(fileEntryWithHashSchema),
|
|
1585
|
+
force: z5.boolean().optional(),
|
|
1586
|
+
runId: z5.string().optional(),
|
|
1734
1587
|
// For sandbox auth
|
|
1735
|
-
baseVersion:
|
|
1588
|
+
baseVersion: z5.string().optional(),
|
|
1736
1589
|
// For incremental uploads
|
|
1737
1590
|
changes: storageChangesSchema.optional()
|
|
1738
1591
|
}),
|
|
1739
1592
|
responses: {
|
|
1740
|
-
200:
|
|
1741
|
-
versionId:
|
|
1742
|
-
existing:
|
|
1743
|
-
uploads:
|
|
1593
|
+
200: z5.object({
|
|
1594
|
+
versionId: z5.string(),
|
|
1595
|
+
existing: z5.boolean(),
|
|
1596
|
+
uploads: z5.object({
|
|
1744
1597
|
archive: presignedUploadSchema,
|
|
1745
1598
|
manifest: presignedUploadSchema
|
|
1746
1599
|
}).optional()
|
|
@@ -1754,27 +1607,27 @@ var storagesPrepareContract = c4.router({
|
|
|
1754
1607
|
summary: "Prepare for direct S3 upload"
|
|
1755
1608
|
}
|
|
1756
1609
|
});
|
|
1757
|
-
var storagesCommitContract =
|
|
1610
|
+
var storagesCommitContract = c3.router({
|
|
1758
1611
|
commit: {
|
|
1759
1612
|
method: "POST",
|
|
1760
1613
|
path: "/api/storages/commit",
|
|
1761
1614
|
headers: authHeadersSchema,
|
|
1762
|
-
body:
|
|
1763
|
-
storageName:
|
|
1615
|
+
body: z5.object({
|
|
1616
|
+
storageName: z5.string().min(1, "Storage name is required"),
|
|
1764
1617
|
storageType: storageTypeSchema,
|
|
1765
|
-
versionId:
|
|
1766
|
-
files:
|
|
1767
|
-
runId:
|
|
1768
|
-
message:
|
|
1618
|
+
versionId: z5.string().min(1, "Version ID is required"),
|
|
1619
|
+
files: z5.array(fileEntryWithHashSchema),
|
|
1620
|
+
runId: z5.string().optional(),
|
|
1621
|
+
message: z5.string().optional()
|
|
1769
1622
|
}),
|
|
1770
1623
|
responses: {
|
|
1771
|
-
200:
|
|
1772
|
-
success:
|
|
1773
|
-
versionId:
|
|
1774
|
-
storageName:
|
|
1775
|
-
size:
|
|
1776
|
-
fileCount:
|
|
1777
|
-
deduplicated:
|
|
1624
|
+
200: z5.object({
|
|
1625
|
+
success: z5.literal(true),
|
|
1626
|
+
versionId: z5.string(),
|
|
1627
|
+
storageName: z5.string(),
|
|
1628
|
+
size: z5.number(),
|
|
1629
|
+
fileCount: z5.number(),
|
|
1630
|
+
deduplicated: z5.boolean().optional()
|
|
1778
1631
|
}),
|
|
1779
1632
|
400: apiErrorSchema,
|
|
1780
1633
|
401: apiErrorSchema,
|
|
@@ -1787,31 +1640,31 @@ var storagesCommitContract = c4.router({
|
|
|
1787
1640
|
summary: "Commit uploaded storage"
|
|
1788
1641
|
}
|
|
1789
1642
|
});
|
|
1790
|
-
var storagesDownloadContract =
|
|
1643
|
+
var storagesDownloadContract = c3.router({
|
|
1791
1644
|
download: {
|
|
1792
1645
|
method: "GET",
|
|
1793
1646
|
path: "/api/storages/download",
|
|
1794
1647
|
headers: authHeadersSchema,
|
|
1795
|
-
query:
|
|
1796
|
-
name:
|
|
1648
|
+
query: z5.object({
|
|
1649
|
+
name: z5.string().min(1, "Storage name is required"),
|
|
1797
1650
|
type: storageTypeSchema,
|
|
1798
1651
|
version: versionQuerySchema
|
|
1799
1652
|
}),
|
|
1800
1653
|
responses: {
|
|
1801
1654
|
// Normal response with presigned URL
|
|
1802
|
-
200:
|
|
1803
|
-
|
|
1804
|
-
url:
|
|
1805
|
-
versionId:
|
|
1806
|
-
fileCount:
|
|
1807
|
-
size:
|
|
1655
|
+
200: z5.union([
|
|
1656
|
+
z5.object({
|
|
1657
|
+
url: z5.string().url(),
|
|
1658
|
+
versionId: z5.string(),
|
|
1659
|
+
fileCount: z5.number(),
|
|
1660
|
+
size: z5.number()
|
|
1808
1661
|
}),
|
|
1809
1662
|
// Empty artifact response
|
|
1810
|
-
|
|
1811
|
-
empty:
|
|
1812
|
-
versionId:
|
|
1813
|
-
fileCount:
|
|
1814
|
-
size:
|
|
1663
|
+
z5.object({
|
|
1664
|
+
empty: z5.literal(true),
|
|
1665
|
+
versionId: z5.string(),
|
|
1666
|
+
fileCount: z5.literal(0),
|
|
1667
|
+
size: z5.literal(0)
|
|
1815
1668
|
})
|
|
1816
1669
|
]),
|
|
1817
1670
|
400: apiErrorSchema,
|
|
@@ -1822,21 +1675,21 @@ var storagesDownloadContract = c4.router({
|
|
|
1822
1675
|
summary: "Get presigned download URL"
|
|
1823
1676
|
}
|
|
1824
1677
|
});
|
|
1825
|
-
var storagesListContract =
|
|
1678
|
+
var storagesListContract = c3.router({
|
|
1826
1679
|
list: {
|
|
1827
1680
|
method: "GET",
|
|
1828
1681
|
path: "/api/storages/list",
|
|
1829
1682
|
headers: authHeadersSchema,
|
|
1830
|
-
query:
|
|
1683
|
+
query: z5.object({
|
|
1831
1684
|
type: storageTypeSchema
|
|
1832
1685
|
}),
|
|
1833
1686
|
responses: {
|
|
1834
|
-
200:
|
|
1835
|
-
|
|
1836
|
-
name:
|
|
1837
|
-
size:
|
|
1838
|
-
fileCount:
|
|
1839
|
-
updatedAt:
|
|
1687
|
+
200: z5.array(
|
|
1688
|
+
z5.object({
|
|
1689
|
+
name: z5.string(),
|
|
1690
|
+
size: z5.number(),
|
|
1691
|
+
fileCount: z5.number(),
|
|
1692
|
+
updatedAt: z5.string()
|
|
1840
1693
|
})
|
|
1841
1694
|
),
|
|
1842
1695
|
401: apiErrorSchema,
|
|
@@ -1847,24 +1700,24 @@ var storagesListContract = c4.router({
|
|
|
1847
1700
|
});
|
|
1848
1701
|
|
|
1849
1702
|
// ../../packages/core/src/contracts/webhooks.ts
|
|
1850
|
-
import { z as
|
|
1851
|
-
var
|
|
1852
|
-
var agentEventSchema =
|
|
1853
|
-
type:
|
|
1854
|
-
sequenceNumber:
|
|
1703
|
+
import { z as z6 } from "zod";
|
|
1704
|
+
var c4 = initContract();
|
|
1705
|
+
var agentEventSchema = z6.object({
|
|
1706
|
+
type: z6.string(),
|
|
1707
|
+
sequenceNumber: z6.number().int().nonnegative()
|
|
1855
1708
|
}).passthrough();
|
|
1856
|
-
var artifactSnapshotSchema =
|
|
1857
|
-
artifactName:
|
|
1858
|
-
artifactVersion:
|
|
1709
|
+
var artifactSnapshotSchema = z6.object({
|
|
1710
|
+
artifactName: z6.string(),
|
|
1711
|
+
artifactVersion: z6.string()
|
|
1859
1712
|
});
|
|
1860
|
-
var memorySnapshotSchema =
|
|
1861
|
-
memoryName:
|
|
1862
|
-
memoryVersion:
|
|
1713
|
+
var memorySnapshotSchema = z6.object({
|
|
1714
|
+
memoryName: z6.string(),
|
|
1715
|
+
memoryVersion: z6.string()
|
|
1863
1716
|
});
|
|
1864
|
-
var volumeVersionsSnapshotSchema =
|
|
1865
|
-
versions:
|
|
1717
|
+
var volumeVersionsSnapshotSchema = z6.object({
|
|
1718
|
+
versions: z6.record(z6.string(), z6.string())
|
|
1866
1719
|
});
|
|
1867
|
-
var webhookEventsContract =
|
|
1720
|
+
var webhookEventsContract = c4.router({
|
|
1868
1721
|
/**
|
|
1869
1722
|
* POST /api/webhooks/agent/events
|
|
1870
1723
|
* Receive agent events from sandbox
|
|
@@ -1873,15 +1726,15 @@ var webhookEventsContract = c5.router({
|
|
|
1873
1726
|
method: "POST",
|
|
1874
1727
|
path: "/api/webhooks/agent/events",
|
|
1875
1728
|
headers: authHeadersSchema,
|
|
1876
|
-
body:
|
|
1877
|
-
runId:
|
|
1878
|
-
events:
|
|
1729
|
+
body: z6.object({
|
|
1730
|
+
runId: z6.string().min(1, "runId is required"),
|
|
1731
|
+
events: z6.array(agentEventSchema).min(1, "events array cannot be empty")
|
|
1879
1732
|
}),
|
|
1880
1733
|
responses: {
|
|
1881
|
-
200:
|
|
1882
|
-
received:
|
|
1883
|
-
firstSequence:
|
|
1884
|
-
lastSequence:
|
|
1734
|
+
200: z6.object({
|
|
1735
|
+
received: z6.number(),
|
|
1736
|
+
firstSequence: z6.number(),
|
|
1737
|
+
lastSequence: z6.number()
|
|
1885
1738
|
}),
|
|
1886
1739
|
400: apiErrorSchema,
|
|
1887
1740
|
401: apiErrorSchema,
|
|
@@ -1891,7 +1744,7 @@ var webhookEventsContract = c5.router({
|
|
|
1891
1744
|
summary: "Receive agent events from sandbox"
|
|
1892
1745
|
}
|
|
1893
1746
|
});
|
|
1894
|
-
var webhookCompleteContract =
|
|
1747
|
+
var webhookCompleteContract = c4.router({
|
|
1895
1748
|
/**
|
|
1896
1749
|
* POST /api/webhooks/agent/complete
|
|
1897
1750
|
* Handle agent run completion (success or failure)
|
|
@@ -1900,15 +1753,15 @@ var webhookCompleteContract = c5.router({
|
|
|
1900
1753
|
method: "POST",
|
|
1901
1754
|
path: "/api/webhooks/agent/complete",
|
|
1902
1755
|
headers: authHeadersSchema,
|
|
1903
|
-
body:
|
|
1904
|
-
runId:
|
|
1905
|
-
exitCode:
|
|
1906
|
-
error:
|
|
1756
|
+
body: z6.object({
|
|
1757
|
+
runId: z6.string().min(1, "runId is required"),
|
|
1758
|
+
exitCode: z6.number(),
|
|
1759
|
+
error: z6.string().optional()
|
|
1907
1760
|
}),
|
|
1908
1761
|
responses: {
|
|
1909
|
-
200:
|
|
1910
|
-
success:
|
|
1911
|
-
status:
|
|
1762
|
+
200: z6.object({
|
|
1763
|
+
success: z6.boolean(),
|
|
1764
|
+
status: z6.enum(["completed", "failed"])
|
|
1912
1765
|
}),
|
|
1913
1766
|
400: apiErrorSchema,
|
|
1914
1767
|
401: apiErrorSchema,
|
|
@@ -1918,7 +1771,7 @@ var webhookCompleteContract = c5.router({
|
|
|
1918
1771
|
summary: "Handle agent run completion"
|
|
1919
1772
|
}
|
|
1920
1773
|
});
|
|
1921
|
-
var webhookCheckpointsContract =
|
|
1774
|
+
var webhookCheckpointsContract = c4.router({
|
|
1922
1775
|
/**
|
|
1923
1776
|
* POST /api/webhooks/agent/checkpoints
|
|
1924
1777
|
* Create checkpoint for completed agent run
|
|
@@ -1927,23 +1780,23 @@ var webhookCheckpointsContract = c5.router({
|
|
|
1927
1780
|
method: "POST",
|
|
1928
1781
|
path: "/api/webhooks/agent/checkpoints",
|
|
1929
1782
|
headers: authHeadersSchema,
|
|
1930
|
-
body:
|
|
1931
|
-
runId:
|
|
1932
|
-
cliAgentType:
|
|
1933
|
-
cliAgentSessionId:
|
|
1934
|
-
cliAgentSessionHistory:
|
|
1783
|
+
body: z6.object({
|
|
1784
|
+
runId: z6.string().min(1, "runId is required"),
|
|
1785
|
+
cliAgentType: z6.string().min(1, "cliAgentType is required"),
|
|
1786
|
+
cliAgentSessionId: z6.string().min(1, "cliAgentSessionId is required"),
|
|
1787
|
+
cliAgentSessionHistory: z6.string().min(1, "cliAgentSessionHistory is required"),
|
|
1935
1788
|
artifactSnapshot: artifactSnapshotSchema.optional(),
|
|
1936
1789
|
memorySnapshot: memorySnapshotSchema.optional(),
|
|
1937
1790
|
volumeVersionsSnapshot: volumeVersionsSnapshotSchema.optional()
|
|
1938
1791
|
}),
|
|
1939
1792
|
responses: {
|
|
1940
|
-
200:
|
|
1941
|
-
checkpointId:
|
|
1942
|
-
agentSessionId:
|
|
1943
|
-
conversationId:
|
|
1793
|
+
200: z6.object({
|
|
1794
|
+
checkpointId: z6.string(),
|
|
1795
|
+
agentSessionId: z6.string(),
|
|
1796
|
+
conversationId: z6.string(),
|
|
1944
1797
|
artifact: artifactSnapshotSchema.optional(),
|
|
1945
1798
|
memory: memorySnapshotSchema.optional(),
|
|
1946
|
-
volumes:
|
|
1799
|
+
volumes: z6.record(z6.string(), z6.string()).optional()
|
|
1947
1800
|
}),
|
|
1948
1801
|
400: apiErrorSchema,
|
|
1949
1802
|
401: apiErrorSchema,
|
|
@@ -1953,7 +1806,7 @@ var webhookCheckpointsContract = c5.router({
|
|
|
1953
1806
|
summary: "Create checkpoint for agent run"
|
|
1954
1807
|
}
|
|
1955
1808
|
});
|
|
1956
|
-
var webhookHeartbeatContract =
|
|
1809
|
+
var webhookHeartbeatContract = c4.router({
|
|
1957
1810
|
/**
|
|
1958
1811
|
* POST /api/webhooks/agent/heartbeat
|
|
1959
1812
|
* Receive heartbeat signals from sandbox
|
|
@@ -1962,12 +1815,12 @@ var webhookHeartbeatContract = c5.router({
|
|
|
1962
1815
|
method: "POST",
|
|
1963
1816
|
path: "/api/webhooks/agent/heartbeat",
|
|
1964
1817
|
headers: authHeadersSchema,
|
|
1965
|
-
body:
|
|
1966
|
-
runId:
|
|
1818
|
+
body: z6.object({
|
|
1819
|
+
runId: z6.string().min(1, "runId is required")
|
|
1967
1820
|
}),
|
|
1968
1821
|
responses: {
|
|
1969
|
-
200:
|
|
1970
|
-
ok:
|
|
1822
|
+
200: z6.object({
|
|
1823
|
+
ok: z6.boolean()
|
|
1971
1824
|
}),
|
|
1972
1825
|
400: apiErrorSchema,
|
|
1973
1826
|
401: apiErrorSchema,
|
|
@@ -1977,7 +1830,7 @@ var webhookHeartbeatContract = c5.router({
|
|
|
1977
1830
|
summary: "Receive heartbeat from sandbox"
|
|
1978
1831
|
}
|
|
1979
1832
|
});
|
|
1980
|
-
var webhookStoragesContract =
|
|
1833
|
+
var webhookStoragesContract = c4.router({
|
|
1981
1834
|
/**
|
|
1982
1835
|
* POST /api/webhooks/agent/storages
|
|
1983
1836
|
* Create a new version of a storage from sandbox
|
|
@@ -1993,13 +1846,13 @@ var webhookStoragesContract = c5.router({
|
|
|
1993
1846
|
path: "/api/webhooks/agent/storages",
|
|
1994
1847
|
headers: authHeadersSchema,
|
|
1995
1848
|
contentType: "multipart/form-data",
|
|
1996
|
-
body:
|
|
1849
|
+
body: c4.type(),
|
|
1997
1850
|
responses: {
|
|
1998
|
-
200:
|
|
1999
|
-
versionId:
|
|
2000
|
-
storageName:
|
|
2001
|
-
size:
|
|
2002
|
-
fileCount:
|
|
1851
|
+
200: z6.object({
|
|
1852
|
+
versionId: z6.string(),
|
|
1853
|
+
storageName: z6.string(),
|
|
1854
|
+
size: z6.number(),
|
|
1855
|
+
fileCount: z6.number()
|
|
2003
1856
|
}),
|
|
2004
1857
|
400: apiErrorSchema,
|
|
2005
1858
|
401: apiErrorSchema,
|
|
@@ -2009,7 +1862,7 @@ var webhookStoragesContract = c5.router({
|
|
|
2009
1862
|
summary: "Upload storage version from sandbox"
|
|
2010
1863
|
}
|
|
2011
1864
|
});
|
|
2012
|
-
var webhookStoragesIncrementalContract =
|
|
1865
|
+
var webhookStoragesIncrementalContract = c4.router({
|
|
2013
1866
|
/**
|
|
2014
1867
|
* POST /api/webhooks/agent/storages/incremental
|
|
2015
1868
|
* Create a new version using incremental upload
|
|
@@ -2027,19 +1880,19 @@ var webhookStoragesIncrementalContract = c5.router({
|
|
|
2027
1880
|
path: "/api/webhooks/agent/storages/incremental",
|
|
2028
1881
|
headers: authHeadersSchema,
|
|
2029
1882
|
contentType: "multipart/form-data",
|
|
2030
|
-
body:
|
|
1883
|
+
body: c4.type(),
|
|
2031
1884
|
responses: {
|
|
2032
|
-
200:
|
|
2033
|
-
versionId:
|
|
2034
|
-
storageName:
|
|
2035
|
-
size:
|
|
2036
|
-
fileCount:
|
|
2037
|
-
incrementalStats:
|
|
2038
|
-
addedFiles:
|
|
2039
|
-
modifiedFiles:
|
|
2040
|
-
deletedFiles:
|
|
2041
|
-
unchangedFiles:
|
|
2042
|
-
bytesUploaded:
|
|
1885
|
+
200: z6.object({
|
|
1886
|
+
versionId: z6.string(),
|
|
1887
|
+
storageName: z6.string(),
|
|
1888
|
+
size: z6.number(),
|
|
1889
|
+
fileCount: z6.number(),
|
|
1890
|
+
incrementalStats: z6.object({
|
|
1891
|
+
addedFiles: z6.number(),
|
|
1892
|
+
modifiedFiles: z6.number(),
|
|
1893
|
+
deletedFiles: z6.number(),
|
|
1894
|
+
unchangedFiles: z6.number(),
|
|
1895
|
+
bytesUploaded: z6.number()
|
|
2043
1896
|
}).optional()
|
|
2044
1897
|
}),
|
|
2045
1898
|
400: apiErrorSchema,
|
|
@@ -2050,36 +1903,36 @@ var webhookStoragesIncrementalContract = c5.router({
|
|
|
2050
1903
|
summary: "Upload storage version incrementally from sandbox"
|
|
2051
1904
|
}
|
|
2052
1905
|
});
|
|
2053
|
-
var metricDataSchema =
|
|
2054
|
-
ts:
|
|
2055
|
-
cpu:
|
|
2056
|
-
mem_used:
|
|
2057
|
-
mem_total:
|
|
2058
|
-
disk_used:
|
|
2059
|
-
disk_total:
|
|
1906
|
+
var metricDataSchema = z6.object({
|
|
1907
|
+
ts: z6.string(),
|
|
1908
|
+
cpu: z6.number(),
|
|
1909
|
+
mem_used: z6.number(),
|
|
1910
|
+
mem_total: z6.number(),
|
|
1911
|
+
disk_used: z6.number(),
|
|
1912
|
+
disk_total: z6.number()
|
|
2060
1913
|
});
|
|
2061
|
-
var sandboxOperationSchema =
|
|
2062
|
-
ts:
|
|
2063
|
-
action_type:
|
|
2064
|
-
duration_ms:
|
|
2065
|
-
success:
|
|
2066
|
-
error:
|
|
1914
|
+
var sandboxOperationSchema = z6.object({
|
|
1915
|
+
ts: z6.string(),
|
|
1916
|
+
action_type: z6.string(),
|
|
1917
|
+
duration_ms: z6.number(),
|
|
1918
|
+
success: z6.boolean(),
|
|
1919
|
+
error: z6.string().optional()
|
|
2067
1920
|
});
|
|
2068
|
-
var networkLogSchema =
|
|
2069
|
-
timestamp:
|
|
2070
|
-
mode:
|
|
2071
|
-
action:
|
|
2072
|
-
host:
|
|
2073
|
-
port:
|
|
2074
|
-
rule_matched:
|
|
2075
|
-
method:
|
|
2076
|
-
url:
|
|
2077
|
-
status:
|
|
2078
|
-
latency_ms:
|
|
2079
|
-
request_size:
|
|
2080
|
-
response_size:
|
|
1921
|
+
var networkLogSchema = z6.object({
|
|
1922
|
+
timestamp: z6.string(),
|
|
1923
|
+
mode: z6.literal("mitm").optional(),
|
|
1924
|
+
action: z6.enum(["ALLOW", "DENY"]).optional(),
|
|
1925
|
+
host: z6.string().optional(),
|
|
1926
|
+
port: z6.number().optional(),
|
|
1927
|
+
rule_matched: z6.string().nullable().optional(),
|
|
1928
|
+
method: z6.string().optional(),
|
|
1929
|
+
url: z6.string().optional(),
|
|
1930
|
+
status: z6.number().optional(),
|
|
1931
|
+
latency_ms: z6.number().optional(),
|
|
1932
|
+
request_size: z6.number().optional(),
|
|
1933
|
+
response_size: z6.number().optional()
|
|
2081
1934
|
});
|
|
2082
|
-
var webhookTelemetryContract =
|
|
1935
|
+
var webhookTelemetryContract = c4.router({
|
|
2083
1936
|
/**
|
|
2084
1937
|
* POST /api/webhooks/agent/telemetry
|
|
2085
1938
|
* Receive telemetry data (system log, metrics, network logs, and sandbox operations) from sandbox
|
|
@@ -2088,17 +1941,17 @@ var webhookTelemetryContract = c5.router({
|
|
|
2088
1941
|
method: "POST",
|
|
2089
1942
|
path: "/api/webhooks/agent/telemetry",
|
|
2090
1943
|
headers: authHeadersSchema,
|
|
2091
|
-
body:
|
|
2092
|
-
runId:
|
|
2093
|
-
systemLog:
|
|
2094
|
-
metrics:
|
|
2095
|
-
networkLogs:
|
|
2096
|
-
sandboxOperations:
|
|
1944
|
+
body: z6.object({
|
|
1945
|
+
runId: z6.string().min(1, "runId is required"),
|
|
1946
|
+
systemLog: z6.string().optional(),
|
|
1947
|
+
metrics: z6.array(metricDataSchema).optional(),
|
|
1948
|
+
networkLogs: z6.array(networkLogSchema).optional(),
|
|
1949
|
+
sandboxOperations: z6.array(sandboxOperationSchema).optional()
|
|
2097
1950
|
}),
|
|
2098
1951
|
responses: {
|
|
2099
|
-
200:
|
|
2100
|
-
success:
|
|
2101
|
-
id:
|
|
1952
|
+
200: z6.object({
|
|
1953
|
+
success: z6.boolean(),
|
|
1954
|
+
id: z6.string()
|
|
2102
1955
|
}),
|
|
2103
1956
|
400: apiErrorSchema,
|
|
2104
1957
|
401: apiErrorSchema,
|
|
@@ -2108,26 +1961,26 @@ var webhookTelemetryContract = c5.router({
|
|
|
2108
1961
|
summary: "Receive telemetry data from sandbox"
|
|
2109
1962
|
}
|
|
2110
1963
|
});
|
|
2111
|
-
var webhookStoragesPrepareContract =
|
|
1964
|
+
var webhookStoragesPrepareContract = c4.router({
|
|
2112
1965
|
prepare: {
|
|
2113
1966
|
method: "POST",
|
|
2114
1967
|
path: "/api/webhooks/agent/storages/prepare",
|
|
2115
1968
|
headers: authHeadersSchema,
|
|
2116
|
-
body:
|
|
2117
|
-
runId:
|
|
1969
|
+
body: z6.object({
|
|
1970
|
+
runId: z6.string().min(1, "runId is required"),
|
|
2118
1971
|
// Required for webhook auth
|
|
2119
|
-
storageName:
|
|
1972
|
+
storageName: z6.string().min(1, "Storage name is required"),
|
|
2120
1973
|
storageType: storageTypeSchema,
|
|
2121
|
-
files:
|
|
2122
|
-
force:
|
|
2123
|
-
baseVersion:
|
|
1974
|
+
files: z6.array(fileEntryWithHashSchema),
|
|
1975
|
+
force: z6.boolean().optional(),
|
|
1976
|
+
baseVersion: z6.string().optional(),
|
|
2124
1977
|
changes: storageChangesSchema.optional()
|
|
2125
1978
|
}),
|
|
2126
1979
|
responses: {
|
|
2127
|
-
200:
|
|
2128
|
-
versionId:
|
|
2129
|
-
existing:
|
|
2130
|
-
uploads:
|
|
1980
|
+
200: z6.object({
|
|
1981
|
+
versionId: z6.string(),
|
|
1982
|
+
existing: z6.boolean(),
|
|
1983
|
+
uploads: z6.object({
|
|
2131
1984
|
archive: presignedUploadSchema,
|
|
2132
1985
|
manifest: presignedUploadSchema
|
|
2133
1986
|
}).optional()
|
|
@@ -2141,28 +1994,28 @@ var webhookStoragesPrepareContract = c5.router({
|
|
|
2141
1994
|
summary: "Prepare for direct S3 upload from sandbox"
|
|
2142
1995
|
}
|
|
2143
1996
|
});
|
|
2144
|
-
var webhookStoragesCommitContract =
|
|
1997
|
+
var webhookStoragesCommitContract = c4.router({
|
|
2145
1998
|
commit: {
|
|
2146
1999
|
method: "POST",
|
|
2147
2000
|
path: "/api/webhooks/agent/storages/commit",
|
|
2148
2001
|
headers: authHeadersSchema,
|
|
2149
|
-
body:
|
|
2150
|
-
runId:
|
|
2002
|
+
body: z6.object({
|
|
2003
|
+
runId: z6.string().min(1, "runId is required"),
|
|
2151
2004
|
// Required for webhook auth
|
|
2152
|
-
storageName:
|
|
2005
|
+
storageName: z6.string().min(1, "Storage name is required"),
|
|
2153
2006
|
storageType: storageTypeSchema,
|
|
2154
|
-
versionId:
|
|
2155
|
-
files:
|
|
2156
|
-
message:
|
|
2007
|
+
versionId: z6.string().min(1, "Version ID is required"),
|
|
2008
|
+
files: z6.array(fileEntryWithHashSchema),
|
|
2009
|
+
message: z6.string().optional()
|
|
2157
2010
|
}),
|
|
2158
2011
|
responses: {
|
|
2159
|
-
200:
|
|
2160
|
-
success:
|
|
2161
|
-
versionId:
|
|
2162
|
-
storageName:
|
|
2163
|
-
size:
|
|
2164
|
-
fileCount:
|
|
2165
|
-
deduplicated:
|
|
2012
|
+
200: z6.object({
|
|
2013
|
+
success: z6.literal(true),
|
|
2014
|
+
versionId: z6.string(),
|
|
2015
|
+
storageName: z6.string(),
|
|
2016
|
+
size: z6.number(),
|
|
2017
|
+
fileCount: z6.number(),
|
|
2018
|
+
deduplicated: z6.boolean().optional()
|
|
2166
2019
|
}),
|
|
2167
2020
|
400: apiErrorSchema,
|
|
2168
2021
|
401: apiErrorSchema,
|
|
@@ -2177,13 +2030,13 @@ var webhookStoragesCommitContract = c5.router({
|
|
|
2177
2030
|
});
|
|
2178
2031
|
|
|
2179
2032
|
// ../../packages/core/src/contracts/cli-auth.ts
|
|
2180
|
-
import { z as
|
|
2181
|
-
var
|
|
2182
|
-
var oauthErrorSchema =
|
|
2183
|
-
error:
|
|
2184
|
-
error_description:
|
|
2033
|
+
import { z as z7 } from "zod";
|
|
2034
|
+
var c5 = initContract();
|
|
2035
|
+
var oauthErrorSchema = z7.object({
|
|
2036
|
+
error: z7.string(),
|
|
2037
|
+
error_description: z7.string()
|
|
2185
2038
|
});
|
|
2186
|
-
var cliAuthDeviceContract =
|
|
2039
|
+
var cliAuthDeviceContract = c5.router({
|
|
2187
2040
|
/**
|
|
2188
2041
|
* POST /api/cli/auth/device
|
|
2189
2042
|
* Initiate device authorization flow
|
|
@@ -2191,21 +2044,21 @@ var cliAuthDeviceContract = c6.router({
|
|
|
2191
2044
|
create: {
|
|
2192
2045
|
method: "POST",
|
|
2193
2046
|
path: "/api/cli/auth/device",
|
|
2194
|
-
body:
|
|
2047
|
+
body: z7.object({}).optional(),
|
|
2195
2048
|
responses: {
|
|
2196
|
-
200:
|
|
2197
|
-
device_code:
|
|
2198
|
-
user_code:
|
|
2199
|
-
verification_path:
|
|
2200
|
-
expires_in:
|
|
2201
|
-
interval:
|
|
2049
|
+
200: z7.object({
|
|
2050
|
+
device_code: z7.string(),
|
|
2051
|
+
user_code: z7.string(),
|
|
2052
|
+
verification_path: z7.string(),
|
|
2053
|
+
expires_in: z7.number(),
|
|
2054
|
+
interval: z7.number()
|
|
2202
2055
|
}),
|
|
2203
2056
|
500: oauthErrorSchema
|
|
2204
2057
|
},
|
|
2205
2058
|
summary: "Initiate device authorization flow"
|
|
2206
2059
|
}
|
|
2207
2060
|
});
|
|
2208
|
-
var cliAuthTokenContract =
|
|
2061
|
+
var cliAuthTokenContract = c5.router({
|
|
2209
2062
|
/**
|
|
2210
2063
|
* POST /api/cli/auth/token
|
|
2211
2064
|
* Exchange device code for access token
|
|
@@ -2213,16 +2066,16 @@ var cliAuthTokenContract = c6.router({
|
|
|
2213
2066
|
exchange: {
|
|
2214
2067
|
method: "POST",
|
|
2215
2068
|
path: "/api/cli/auth/token",
|
|
2216
|
-
body:
|
|
2217
|
-
device_code:
|
|
2069
|
+
body: z7.object({
|
|
2070
|
+
device_code: z7.string().min(1, "device_code is required")
|
|
2218
2071
|
}),
|
|
2219
2072
|
responses: {
|
|
2220
2073
|
// Success - token issued
|
|
2221
|
-
200:
|
|
2222
|
-
access_token:
|
|
2223
|
-
token_type:
|
|
2224
|
-
expires_in:
|
|
2225
|
-
org_slug:
|
|
2074
|
+
200: z7.object({
|
|
2075
|
+
access_token: z7.string(),
|
|
2076
|
+
token_type: z7.literal("Bearer"),
|
|
2077
|
+
expires_in: z7.number(),
|
|
2078
|
+
org_slug: z7.string().optional()
|
|
2226
2079
|
}),
|
|
2227
2080
|
// Authorization pending
|
|
2228
2081
|
202: oauthErrorSchema,
|
|
@@ -2235,9 +2088,9 @@ var cliAuthTokenContract = c6.router({
|
|
|
2235
2088
|
});
|
|
2236
2089
|
|
|
2237
2090
|
// ../../packages/core/src/contracts/auth.ts
|
|
2238
|
-
import { z as
|
|
2239
|
-
var
|
|
2240
|
-
var authContract =
|
|
2091
|
+
import { z as z8 } from "zod";
|
|
2092
|
+
var c6 = initContract();
|
|
2093
|
+
var authContract = c6.router({
|
|
2241
2094
|
/**
|
|
2242
2095
|
* GET /api/auth/me
|
|
2243
2096
|
* Get current user information
|
|
@@ -2247,9 +2100,9 @@ var authContract = c7.router({
|
|
|
2247
2100
|
path: "/api/auth/me",
|
|
2248
2101
|
headers: authHeadersSchema,
|
|
2249
2102
|
responses: {
|
|
2250
|
-
200:
|
|
2251
|
-
userId:
|
|
2252
|
-
email:
|
|
2103
|
+
200: z8.object({
|
|
2104
|
+
userId: z8.string(),
|
|
2105
|
+
email: z8.string()
|
|
2253
2106
|
}),
|
|
2254
2107
|
401: apiErrorSchema,
|
|
2255
2108
|
404: apiErrorSchema,
|
|
@@ -2260,23 +2113,23 @@ var authContract = c7.router({
|
|
|
2260
2113
|
});
|
|
2261
2114
|
|
|
2262
2115
|
// ../../packages/core/src/contracts/cron.ts
|
|
2263
|
-
import { z as
|
|
2264
|
-
var
|
|
2265
|
-
var cleanupResultSchema =
|
|
2266
|
-
runId:
|
|
2267
|
-
sandboxId:
|
|
2268
|
-
status:
|
|
2269
|
-
error:
|
|
2270
|
-
reason:
|
|
2116
|
+
import { z as z9 } from "zod";
|
|
2117
|
+
var c7 = initContract();
|
|
2118
|
+
var cleanupResultSchema = z9.object({
|
|
2119
|
+
runId: z9.string(),
|
|
2120
|
+
sandboxId: z9.string().nullable(),
|
|
2121
|
+
status: z9.enum(["cleaned", "error"]),
|
|
2122
|
+
error: z9.string().optional(),
|
|
2123
|
+
reason: z9.string().optional()
|
|
2271
2124
|
});
|
|
2272
|
-
var cleanupResponseSchema =
|
|
2273
|
-
cleaned:
|
|
2274
|
-
errors:
|
|
2275
|
-
results:
|
|
2276
|
-
composeJobsCleaned:
|
|
2277
|
-
composeJobErrors:
|
|
2125
|
+
var cleanupResponseSchema = z9.object({
|
|
2126
|
+
cleaned: z9.number(),
|
|
2127
|
+
errors: z9.number(),
|
|
2128
|
+
results: z9.array(cleanupResultSchema),
|
|
2129
|
+
composeJobsCleaned: z9.number(),
|
|
2130
|
+
composeJobErrors: z9.number()
|
|
2278
2131
|
});
|
|
2279
|
-
var cronCleanupSandboxesContract =
|
|
2132
|
+
var cronCleanupSandboxesContract = c7.router({
|
|
2280
2133
|
/**
|
|
2281
2134
|
* GET /api/cron/cleanup-sandboxes
|
|
2282
2135
|
* Cron job to cleanup sandboxes that have stopped sending heartbeats
|
|
@@ -2295,23 +2148,23 @@ var cronCleanupSandboxesContract = c8.router({
|
|
|
2295
2148
|
});
|
|
2296
2149
|
|
|
2297
2150
|
// ../../packages/core/src/contracts/orgs.ts
|
|
2298
|
-
import { z as
|
|
2299
|
-
var
|
|
2300
|
-
var orgTierSchema =
|
|
2301
|
-
var orgSlugSchema =
|
|
2151
|
+
import { z as z10 } from "zod";
|
|
2152
|
+
var c8 = initContract();
|
|
2153
|
+
var orgTierSchema = z10.enum(["free", "pro", "max"]);
|
|
2154
|
+
var orgSlugSchema = z10.string().min(3, "Org slug must be at least 3 characters").max(64, "Org slug must be at most 64 characters").regex(
|
|
2302
2155
|
/^[a-z0-9][a-z0-9-]*[a-z0-9]$|^[a-z0-9]{1,2}$/,
|
|
2303
2156
|
"Org slug must contain only lowercase letters, numbers, and hyphens, and must start and end with an alphanumeric character"
|
|
2304
2157
|
).transform((s) => s.toLowerCase());
|
|
2305
|
-
var orgResponseSchema =
|
|
2306
|
-
id:
|
|
2307
|
-
slug:
|
|
2308
|
-
tier:
|
|
2158
|
+
var orgResponseSchema = z10.object({
|
|
2159
|
+
id: z10.string(),
|
|
2160
|
+
slug: z10.string(),
|
|
2161
|
+
tier: z10.string().optional()
|
|
2309
2162
|
});
|
|
2310
|
-
var updateOrgRequestSchema =
|
|
2163
|
+
var updateOrgRequestSchema = z10.object({
|
|
2311
2164
|
slug: orgSlugSchema,
|
|
2312
|
-
force:
|
|
2165
|
+
force: z10.boolean().optional().default(false)
|
|
2313
2166
|
});
|
|
2314
|
-
var orgContract =
|
|
2167
|
+
var orgContract = c8.router({
|
|
2315
2168
|
/**
|
|
2316
2169
|
* GET /api/org
|
|
2317
2170
|
* Get current user's default org
|
|
@@ -2349,7 +2202,7 @@ var orgContract = c9.router({
|
|
|
2349
2202
|
summary: "Update org slug"
|
|
2350
2203
|
}
|
|
2351
2204
|
});
|
|
2352
|
-
var orgDefaultAgentContract =
|
|
2205
|
+
var orgDefaultAgentContract = c8.router({
|
|
2353
2206
|
/**
|
|
2354
2207
|
* PUT /api/orgs/default-agent?org={slug}
|
|
2355
2208
|
* Set or unset the default agent for an org.
|
|
@@ -2360,15 +2213,15 @@ var orgDefaultAgentContract = c9.router({
|
|
|
2360
2213
|
method: "PUT",
|
|
2361
2214
|
path: "/api/orgs/default-agent",
|
|
2362
2215
|
headers: authHeadersSchema,
|
|
2363
|
-
query:
|
|
2364
|
-
org:
|
|
2216
|
+
query: z10.object({
|
|
2217
|
+
org: z10.string().optional()
|
|
2365
2218
|
}),
|
|
2366
|
-
body:
|
|
2367
|
-
agentComposeId:
|
|
2219
|
+
body: z10.object({
|
|
2220
|
+
agentComposeId: z10.string().uuid().nullable()
|
|
2368
2221
|
}),
|
|
2369
2222
|
responses: {
|
|
2370
|
-
200:
|
|
2371
|
-
agentComposeId:
|
|
2223
|
+
200: z10.object({
|
|
2224
|
+
agentComposeId: z10.string().uuid().nullable()
|
|
2372
2225
|
}),
|
|
2373
2226
|
400: apiErrorSchema,
|
|
2374
2227
|
401: apiErrorSchema,
|
|
@@ -2380,30 +2233,30 @@ var orgDefaultAgentContract = c9.router({
|
|
|
2380
2233
|
});
|
|
2381
2234
|
|
|
2382
2235
|
// ../../packages/core/src/contracts/secrets.ts
|
|
2383
|
-
import { z as
|
|
2384
|
-
var
|
|
2385
|
-
var secretNameSchema =
|
|
2236
|
+
import { z as z11 } from "zod";
|
|
2237
|
+
var c9 = initContract();
|
|
2238
|
+
var secretNameSchema = z11.string().min(1, "Secret name is required").max(255, "Secret name must be at most 255 characters").regex(
|
|
2386
2239
|
/^[A-Z][A-Z0-9_]*$/,
|
|
2387
2240
|
"Secret name must contain only uppercase letters, numbers, and underscores, and must start with a letter (e.g., MY_API_KEY)"
|
|
2388
2241
|
);
|
|
2389
|
-
var secretTypeSchema =
|
|
2390
|
-
var secretResponseSchema =
|
|
2391
|
-
id:
|
|
2392
|
-
name:
|
|
2393
|
-
description:
|
|
2242
|
+
var secretTypeSchema = z11.enum(["user", "model-provider", "connector"]);
|
|
2243
|
+
var secretResponseSchema = z11.object({
|
|
2244
|
+
id: z11.string().uuid(),
|
|
2245
|
+
name: z11.string(),
|
|
2246
|
+
description: z11.string().nullable(),
|
|
2394
2247
|
type: secretTypeSchema,
|
|
2395
|
-
createdAt:
|
|
2396
|
-
updatedAt:
|
|
2248
|
+
createdAt: z11.string(),
|
|
2249
|
+
updatedAt: z11.string()
|
|
2397
2250
|
});
|
|
2398
|
-
var secretListResponseSchema =
|
|
2399
|
-
secrets:
|
|
2251
|
+
var secretListResponseSchema = z11.object({
|
|
2252
|
+
secrets: z11.array(secretResponseSchema)
|
|
2400
2253
|
});
|
|
2401
|
-
var setSecretRequestSchema =
|
|
2254
|
+
var setSecretRequestSchema = z11.object({
|
|
2402
2255
|
name: secretNameSchema,
|
|
2403
|
-
value:
|
|
2404
|
-
description:
|
|
2256
|
+
value: z11.string().min(1, "Secret value is required"),
|
|
2257
|
+
description: z11.string().max(1e3).optional()
|
|
2405
2258
|
});
|
|
2406
|
-
var secretsMainContract =
|
|
2259
|
+
var secretsMainContract = c9.router({
|
|
2407
2260
|
/**
|
|
2408
2261
|
* GET /api/secrets
|
|
2409
2262
|
* List all secrets for the current user's org (metadata only)
|
|
@@ -2438,7 +2291,7 @@ var secretsMainContract = c10.router({
|
|
|
2438
2291
|
summary: "Create or update a secret"
|
|
2439
2292
|
}
|
|
2440
2293
|
});
|
|
2441
|
-
var secretsByNameContract =
|
|
2294
|
+
var secretsByNameContract = c9.router({
|
|
2442
2295
|
/**
|
|
2443
2296
|
* GET /api/secrets/:name
|
|
2444
2297
|
* Get a secret by name (metadata only)
|
|
@@ -2447,7 +2300,7 @@ var secretsByNameContract = c10.router({
|
|
|
2447
2300
|
method: "GET",
|
|
2448
2301
|
path: "/api/secrets/:name",
|
|
2449
2302
|
headers: authHeadersSchema,
|
|
2450
|
-
pathParams:
|
|
2303
|
+
pathParams: z11.object({
|
|
2451
2304
|
name: secretNameSchema
|
|
2452
2305
|
}),
|
|
2453
2306
|
responses: {
|
|
@@ -2466,11 +2319,11 @@ var secretsByNameContract = c10.router({
|
|
|
2466
2319
|
method: "DELETE",
|
|
2467
2320
|
path: "/api/secrets/:name",
|
|
2468
2321
|
headers: authHeadersSchema,
|
|
2469
|
-
pathParams:
|
|
2322
|
+
pathParams: z11.object({
|
|
2470
2323
|
name: secretNameSchema
|
|
2471
2324
|
}),
|
|
2472
2325
|
responses: {
|
|
2473
|
-
204:
|
|
2326
|
+
204: c9.noBody(),
|
|
2474
2327
|
401: apiErrorSchema,
|
|
2475
2328
|
404: apiErrorSchema,
|
|
2476
2329
|
500: apiErrorSchema
|
|
@@ -2480,29 +2333,29 @@ var secretsByNameContract = c10.router({
|
|
|
2480
2333
|
});
|
|
2481
2334
|
|
|
2482
2335
|
// ../../packages/core/src/contracts/variables.ts
|
|
2483
|
-
import { z as
|
|
2484
|
-
var
|
|
2485
|
-
var variableNameSchema =
|
|
2336
|
+
import { z as z12 } from "zod";
|
|
2337
|
+
var c10 = initContract();
|
|
2338
|
+
var variableNameSchema = z12.string().min(1, "Variable name is required").max(255, "Variable name must be at most 255 characters").regex(
|
|
2486
2339
|
/^[A-Z][A-Z0-9_]*$/,
|
|
2487
2340
|
"Variable name must contain only uppercase letters, numbers, and underscores, and must start with a letter (e.g., MY_VAR)"
|
|
2488
2341
|
);
|
|
2489
|
-
var variableResponseSchema =
|
|
2490
|
-
id:
|
|
2491
|
-
name:
|
|
2492
|
-
value:
|
|
2493
|
-
description:
|
|
2494
|
-
createdAt:
|
|
2495
|
-
updatedAt:
|
|
2342
|
+
var variableResponseSchema = z12.object({
|
|
2343
|
+
id: z12.string().uuid(),
|
|
2344
|
+
name: z12.string(),
|
|
2345
|
+
value: z12.string(),
|
|
2346
|
+
description: z12.string().nullable(),
|
|
2347
|
+
createdAt: z12.string(),
|
|
2348
|
+
updatedAt: z12.string()
|
|
2496
2349
|
});
|
|
2497
|
-
var variableListResponseSchema =
|
|
2498
|
-
variables:
|
|
2350
|
+
var variableListResponseSchema = z12.object({
|
|
2351
|
+
variables: z12.array(variableResponseSchema)
|
|
2499
2352
|
});
|
|
2500
|
-
var setVariableRequestSchema =
|
|
2353
|
+
var setVariableRequestSchema = z12.object({
|
|
2501
2354
|
name: variableNameSchema,
|
|
2502
|
-
value:
|
|
2503
|
-
description:
|
|
2355
|
+
value: z12.string().min(1, "Variable value is required"),
|
|
2356
|
+
description: z12.string().max(1e3).optional()
|
|
2504
2357
|
});
|
|
2505
|
-
var variablesMainContract =
|
|
2358
|
+
var variablesMainContract = c10.router({
|
|
2506
2359
|
/**
|
|
2507
2360
|
* GET /api/variables
|
|
2508
2361
|
* List all variables for the current user's org (includes values)
|
|
@@ -2537,7 +2390,7 @@ var variablesMainContract = c11.router({
|
|
|
2537
2390
|
summary: "Create or update a variable"
|
|
2538
2391
|
}
|
|
2539
2392
|
});
|
|
2540
|
-
var variablesByNameContract =
|
|
2393
|
+
var variablesByNameContract = c10.router({
|
|
2541
2394
|
/**
|
|
2542
2395
|
* GET /api/variables/:name
|
|
2543
2396
|
* Get a variable by name (includes value)
|
|
@@ -2546,7 +2399,7 @@ var variablesByNameContract = c11.router({
|
|
|
2546
2399
|
method: "GET",
|
|
2547
2400
|
path: "/api/variables/:name",
|
|
2548
2401
|
headers: authHeadersSchema,
|
|
2549
|
-
pathParams:
|
|
2402
|
+
pathParams: z12.object({
|
|
2550
2403
|
name: variableNameSchema
|
|
2551
2404
|
}),
|
|
2552
2405
|
responses: {
|
|
@@ -2565,11 +2418,11 @@ var variablesByNameContract = c11.router({
|
|
|
2565
2418
|
method: "DELETE",
|
|
2566
2419
|
path: "/api/variables/:name",
|
|
2567
2420
|
headers: authHeadersSchema,
|
|
2568
|
-
pathParams:
|
|
2421
|
+
pathParams: z12.object({
|
|
2569
2422
|
name: variableNameSchema
|
|
2570
2423
|
}),
|
|
2571
2424
|
responses: {
|
|
2572
|
-
204:
|
|
2425
|
+
204: c10.noBody(),
|
|
2573
2426
|
401: apiErrorSchema,
|
|
2574
2427
|
404: apiErrorSchema,
|
|
2575
2428
|
500: apiErrorSchema
|
|
@@ -2579,8 +2432,8 @@ var variablesByNameContract = c11.router({
|
|
|
2579
2432
|
});
|
|
2580
2433
|
|
|
2581
2434
|
// ../../packages/core/src/contracts/model-providers.ts
|
|
2582
|
-
import { z as
|
|
2583
|
-
var
|
|
2435
|
+
import { z as z13 } from "zod";
|
|
2436
|
+
var c11 = initContract();
|
|
2584
2437
|
var MODEL_PROVIDER_TYPES = {
|
|
2585
2438
|
"claude-code-oauth-token": {
|
|
2586
2439
|
framework: "claude-code",
|
|
@@ -2801,7 +2654,7 @@ var MODEL_PROVIDER_TYPES = {
|
|
|
2801
2654
|
customModelPlaceholder: "anthropic.claude-sonnet-4-20250514-v1:0"
|
|
2802
2655
|
}
|
|
2803
2656
|
};
|
|
2804
|
-
var modelProviderTypeSchema =
|
|
2657
|
+
var modelProviderTypeSchema = z13.enum([
|
|
2805
2658
|
"claude-code-oauth-token",
|
|
2806
2659
|
"anthropic-api-key",
|
|
2807
2660
|
"openrouter-api-key",
|
|
@@ -2812,7 +2665,7 @@ var modelProviderTypeSchema = z14.enum([
|
|
|
2812
2665
|
"azure-foundry",
|
|
2813
2666
|
"aws-bedrock"
|
|
2814
2667
|
]);
|
|
2815
|
-
var modelProviderFrameworkSchema =
|
|
2668
|
+
var modelProviderFrameworkSchema = z13.enum(["claude-code", "codex"]);
|
|
2816
2669
|
function hasAuthMethods(type2) {
|
|
2817
2670
|
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2818
2671
|
return "authMethods" in config;
|
|
@@ -2853,43 +2706,43 @@ function getCustomModelPlaceholder(type2) {
|
|
|
2853
2706
|
const config = MODEL_PROVIDER_TYPES[type2];
|
|
2854
2707
|
return "customModelPlaceholder" in config ? config.customModelPlaceholder : void 0;
|
|
2855
2708
|
}
|
|
2856
|
-
var modelProviderResponseSchema =
|
|
2857
|
-
id:
|
|
2709
|
+
var modelProviderResponseSchema = z13.object({
|
|
2710
|
+
id: z13.string().uuid(),
|
|
2858
2711
|
type: modelProviderTypeSchema,
|
|
2859
2712
|
framework: modelProviderFrameworkSchema,
|
|
2860
|
-
secretName:
|
|
2713
|
+
secretName: z13.string().nullable(),
|
|
2861
2714
|
// Legacy single-secret (deprecated for multi-auth)
|
|
2862
|
-
authMethod:
|
|
2715
|
+
authMethod: z13.string().nullable(),
|
|
2863
2716
|
// For multi-auth providers
|
|
2864
|
-
secretNames:
|
|
2717
|
+
secretNames: z13.array(z13.string()).nullable(),
|
|
2865
2718
|
// For multi-auth providers
|
|
2866
|
-
isDefault:
|
|
2867
|
-
selectedModel:
|
|
2868
|
-
createdAt:
|
|
2869
|
-
updatedAt:
|
|
2719
|
+
isDefault: z13.boolean(),
|
|
2720
|
+
selectedModel: z13.string().nullable(),
|
|
2721
|
+
createdAt: z13.string(),
|
|
2722
|
+
updatedAt: z13.string()
|
|
2870
2723
|
});
|
|
2871
|
-
var modelProviderListResponseSchema =
|
|
2872
|
-
modelProviders:
|
|
2724
|
+
var modelProviderListResponseSchema = z13.object({
|
|
2725
|
+
modelProviders: z13.array(modelProviderResponseSchema)
|
|
2873
2726
|
});
|
|
2874
|
-
var upsertModelProviderRequestSchema =
|
|
2727
|
+
var upsertModelProviderRequestSchema = z13.object({
|
|
2875
2728
|
type: modelProviderTypeSchema,
|
|
2876
|
-
secret:
|
|
2729
|
+
secret: z13.string().min(1).optional(),
|
|
2877
2730
|
// Legacy single secret
|
|
2878
|
-
authMethod:
|
|
2731
|
+
authMethod: z13.string().optional(),
|
|
2879
2732
|
// For multi-auth providers
|
|
2880
|
-
secrets:
|
|
2733
|
+
secrets: z13.record(z13.string(), z13.string()).optional(),
|
|
2881
2734
|
// For multi-auth providers
|
|
2882
|
-
selectedModel:
|
|
2735
|
+
selectedModel: z13.string().optional()
|
|
2883
2736
|
});
|
|
2884
|
-
var upsertModelProviderResponseSchema =
|
|
2737
|
+
var upsertModelProviderResponseSchema = z13.object({
|
|
2885
2738
|
provider: modelProviderResponseSchema,
|
|
2886
|
-
created:
|
|
2739
|
+
created: z13.boolean()
|
|
2887
2740
|
});
|
|
2888
|
-
var checkSecretResponseSchema =
|
|
2889
|
-
exists:
|
|
2890
|
-
secretName:
|
|
2741
|
+
var checkSecretResponseSchema = z13.object({
|
|
2742
|
+
exists: z13.boolean(),
|
|
2743
|
+
secretName: z13.string()
|
|
2891
2744
|
});
|
|
2892
|
-
var modelProvidersMainContract =
|
|
2745
|
+
var modelProvidersMainContract = c11.router({
|
|
2893
2746
|
list: {
|
|
2894
2747
|
method: "GET",
|
|
2895
2748
|
path: "/api/model-providers",
|
|
@@ -2917,12 +2770,12 @@ var modelProvidersMainContract = c12.router({
|
|
|
2917
2770
|
summary: "Create or update a model provider"
|
|
2918
2771
|
}
|
|
2919
2772
|
});
|
|
2920
|
-
var modelProvidersCheckContract =
|
|
2773
|
+
var modelProvidersCheckContract = c11.router({
|
|
2921
2774
|
check: {
|
|
2922
2775
|
method: "GET",
|
|
2923
2776
|
path: "/api/model-providers/check/:type",
|
|
2924
2777
|
headers: authHeadersSchema,
|
|
2925
|
-
pathParams:
|
|
2778
|
+
pathParams: z13.object({
|
|
2926
2779
|
type: modelProviderTypeSchema
|
|
2927
2780
|
}),
|
|
2928
2781
|
responses: {
|
|
@@ -2933,16 +2786,16 @@ var modelProvidersCheckContract = c12.router({
|
|
|
2933
2786
|
summary: "Check if secret exists for a model provider type"
|
|
2934
2787
|
}
|
|
2935
2788
|
});
|
|
2936
|
-
var modelProvidersByTypeContract =
|
|
2789
|
+
var modelProvidersByTypeContract = c11.router({
|
|
2937
2790
|
delete: {
|
|
2938
2791
|
method: "DELETE",
|
|
2939
2792
|
path: "/api/model-providers/:type",
|
|
2940
2793
|
headers: authHeadersSchema,
|
|
2941
|
-
pathParams:
|
|
2794
|
+
pathParams: z13.object({
|
|
2942
2795
|
type: modelProviderTypeSchema
|
|
2943
2796
|
}),
|
|
2944
2797
|
responses: {
|
|
2945
|
-
204:
|
|
2798
|
+
204: c11.noBody(),
|
|
2946
2799
|
401: apiErrorSchema,
|
|
2947
2800
|
404: apiErrorSchema,
|
|
2948
2801
|
500: apiErrorSchema
|
|
@@ -2950,15 +2803,15 @@ var modelProvidersByTypeContract = c12.router({
|
|
|
2950
2803
|
summary: "Delete a model provider"
|
|
2951
2804
|
}
|
|
2952
2805
|
});
|
|
2953
|
-
var modelProvidersConvertContract =
|
|
2806
|
+
var modelProvidersConvertContract = c11.router({
|
|
2954
2807
|
convert: {
|
|
2955
2808
|
method: "POST",
|
|
2956
2809
|
path: "/api/model-providers/:type/convert",
|
|
2957
2810
|
headers: authHeadersSchema,
|
|
2958
|
-
pathParams:
|
|
2811
|
+
pathParams: z13.object({
|
|
2959
2812
|
type: modelProviderTypeSchema
|
|
2960
2813
|
}),
|
|
2961
|
-
body:
|
|
2814
|
+
body: z13.undefined(),
|
|
2962
2815
|
responses: {
|
|
2963
2816
|
200: modelProviderResponseSchema,
|
|
2964
2817
|
400: apiErrorSchema,
|
|
@@ -2969,15 +2822,15 @@ var modelProvidersConvertContract = c12.router({
|
|
|
2969
2822
|
summary: "Convert existing user secret to model provider"
|
|
2970
2823
|
}
|
|
2971
2824
|
});
|
|
2972
|
-
var modelProvidersSetDefaultContract =
|
|
2825
|
+
var modelProvidersSetDefaultContract = c11.router({
|
|
2973
2826
|
setDefault: {
|
|
2974
2827
|
method: "POST",
|
|
2975
2828
|
path: "/api/model-providers/:type/set-default",
|
|
2976
2829
|
headers: authHeadersSchema,
|
|
2977
|
-
pathParams:
|
|
2830
|
+
pathParams: z13.object({
|
|
2978
2831
|
type: modelProviderTypeSchema
|
|
2979
2832
|
}),
|
|
2980
|
-
body:
|
|
2833
|
+
body: z13.undefined(),
|
|
2981
2834
|
responses: {
|
|
2982
2835
|
200: modelProviderResponseSchema,
|
|
2983
2836
|
401: apiErrorSchema,
|
|
@@ -2987,15 +2840,15 @@ var modelProvidersSetDefaultContract = c12.router({
|
|
|
2987
2840
|
summary: "Set a model provider as default for its framework"
|
|
2988
2841
|
}
|
|
2989
2842
|
});
|
|
2990
|
-
var updateModelRequestSchema =
|
|
2991
|
-
selectedModel:
|
|
2843
|
+
var updateModelRequestSchema = z13.object({
|
|
2844
|
+
selectedModel: z13.string().optional()
|
|
2992
2845
|
});
|
|
2993
|
-
var modelProvidersUpdateModelContract =
|
|
2846
|
+
var modelProvidersUpdateModelContract = c11.router({
|
|
2994
2847
|
updateModel: {
|
|
2995
2848
|
method: "PATCH",
|
|
2996
2849
|
path: "/api/model-providers/:type/model",
|
|
2997
2850
|
headers: authHeadersSchema,
|
|
2998
|
-
pathParams:
|
|
2851
|
+
pathParams: z13.object({
|
|
2999
2852
|
type: modelProviderTypeSchema
|
|
3000
2853
|
}),
|
|
3001
2854
|
body: updateModelRequestSchema,
|
|
@@ -3010,53 +2863,53 @@ var modelProvidersUpdateModelContract = c12.router({
|
|
|
3010
2863
|
});
|
|
3011
2864
|
|
|
3012
2865
|
// ../../packages/core/src/contracts/sessions.ts
|
|
3013
|
-
import { z as
|
|
3014
|
-
var
|
|
3015
|
-
var storedChatMessageSchema =
|
|
3016
|
-
role:
|
|
3017
|
-
content:
|
|
3018
|
-
runId:
|
|
3019
|
-
createdAt:
|
|
2866
|
+
import { z as z14 } from "zod";
|
|
2867
|
+
var c12 = initContract();
|
|
2868
|
+
var storedChatMessageSchema = z14.object({
|
|
2869
|
+
role: z14.enum(["user", "assistant"]),
|
|
2870
|
+
content: z14.string(),
|
|
2871
|
+
runId: z14.string().optional(),
|
|
2872
|
+
createdAt: z14.string()
|
|
3020
2873
|
});
|
|
3021
|
-
var sessionResponseSchema =
|
|
3022
|
-
id:
|
|
3023
|
-
agentComposeId:
|
|
3024
|
-
conversationId:
|
|
3025
|
-
artifactName:
|
|
3026
|
-
secretNames:
|
|
3027
|
-
chatMessages:
|
|
3028
|
-
createdAt:
|
|
3029
|
-
updatedAt:
|
|
2874
|
+
var sessionResponseSchema = z14.object({
|
|
2875
|
+
id: z14.string(),
|
|
2876
|
+
agentComposeId: z14.string(),
|
|
2877
|
+
conversationId: z14.string().nullable(),
|
|
2878
|
+
artifactName: z14.string().nullable(),
|
|
2879
|
+
secretNames: z14.array(z14.string()).nullable(),
|
|
2880
|
+
chatMessages: z14.array(storedChatMessageSchema).optional(),
|
|
2881
|
+
createdAt: z14.string(),
|
|
2882
|
+
updatedAt: z14.string()
|
|
3030
2883
|
});
|
|
3031
|
-
var sessionListItemSchema =
|
|
3032
|
-
id:
|
|
3033
|
-
createdAt:
|
|
3034
|
-
updatedAt:
|
|
3035
|
-
messageCount:
|
|
3036
|
-
preview:
|
|
2884
|
+
var sessionListItemSchema = z14.object({
|
|
2885
|
+
id: z14.string(),
|
|
2886
|
+
createdAt: z14.string(),
|
|
2887
|
+
updatedAt: z14.string(),
|
|
2888
|
+
messageCount: z14.number(),
|
|
2889
|
+
preview: z14.string().nullable()
|
|
3037
2890
|
});
|
|
3038
|
-
var agentComposeSnapshotSchema =
|
|
3039
|
-
agentComposeVersionId:
|
|
3040
|
-
vars:
|
|
3041
|
-
secretNames:
|
|
2891
|
+
var agentComposeSnapshotSchema = z14.object({
|
|
2892
|
+
agentComposeVersionId: z14.string(),
|
|
2893
|
+
vars: z14.record(z14.string(), z14.string()).optional(),
|
|
2894
|
+
secretNames: z14.array(z14.string()).optional()
|
|
3042
2895
|
});
|
|
3043
|
-
var artifactSnapshotSchema2 =
|
|
3044
|
-
artifactName:
|
|
3045
|
-
artifactVersion:
|
|
2896
|
+
var artifactSnapshotSchema2 = z14.object({
|
|
2897
|
+
artifactName: z14.string(),
|
|
2898
|
+
artifactVersion: z14.string()
|
|
3046
2899
|
});
|
|
3047
|
-
var volumeVersionsSnapshotSchema2 =
|
|
3048
|
-
versions:
|
|
2900
|
+
var volumeVersionsSnapshotSchema2 = z14.object({
|
|
2901
|
+
versions: z14.record(z14.string(), z14.string())
|
|
3049
2902
|
});
|
|
3050
|
-
var checkpointResponseSchema =
|
|
3051
|
-
id:
|
|
3052
|
-
runId:
|
|
3053
|
-
conversationId:
|
|
2903
|
+
var checkpointResponseSchema = z14.object({
|
|
2904
|
+
id: z14.string(),
|
|
2905
|
+
runId: z14.string(),
|
|
2906
|
+
conversationId: z14.string(),
|
|
3054
2907
|
agentComposeSnapshot: agentComposeSnapshotSchema,
|
|
3055
2908
|
artifactSnapshot: artifactSnapshotSchema2.nullable(),
|
|
3056
2909
|
volumeVersionsSnapshot: volumeVersionsSnapshotSchema2.nullable(),
|
|
3057
|
-
createdAt:
|
|
2910
|
+
createdAt: z14.string()
|
|
3058
2911
|
});
|
|
3059
|
-
var sessionsContract =
|
|
2912
|
+
var sessionsContract = c12.router({
|
|
3060
2913
|
/**
|
|
3061
2914
|
* GET /api/agent/sessions?agentComposeId=X
|
|
3062
2915
|
* List chat sessions for an agent
|
|
@@ -3065,17 +2918,17 @@ var sessionsContract = c13.router({
|
|
|
3065
2918
|
method: "GET",
|
|
3066
2919
|
path: "/api/agent/sessions",
|
|
3067
2920
|
headers: authHeadersSchema,
|
|
3068
|
-
query:
|
|
3069
|
-
agentComposeId:
|
|
2921
|
+
query: z14.object({
|
|
2922
|
+
agentComposeId: z14.string().min(1, "agentComposeId is required")
|
|
3070
2923
|
}),
|
|
3071
2924
|
responses: {
|
|
3072
|
-
200:
|
|
2925
|
+
200: z14.object({ sessions: z14.array(sessionListItemSchema) }),
|
|
3073
2926
|
401: apiErrorSchema
|
|
3074
2927
|
},
|
|
3075
2928
|
summary: "List chat sessions for an agent"
|
|
3076
2929
|
}
|
|
3077
2930
|
});
|
|
3078
|
-
var sessionsByIdContract =
|
|
2931
|
+
var sessionsByIdContract = c12.router({
|
|
3079
2932
|
/**
|
|
3080
2933
|
* GET /api/agent/sessions/:id
|
|
3081
2934
|
* Get session by ID
|
|
@@ -3084,8 +2937,8 @@ var sessionsByIdContract = c13.router({
|
|
|
3084
2937
|
method: "GET",
|
|
3085
2938
|
path: "/api/agent/sessions/:id",
|
|
3086
2939
|
headers: authHeadersSchema,
|
|
3087
|
-
pathParams:
|
|
3088
|
-
id:
|
|
2940
|
+
pathParams: z14.object({
|
|
2941
|
+
id: z14.string().min(1, "Session ID is required")
|
|
3089
2942
|
}),
|
|
3090
2943
|
responses: {
|
|
3091
2944
|
200: sessionResponseSchema,
|
|
@@ -3096,7 +2949,7 @@ var sessionsByIdContract = c13.router({
|
|
|
3096
2949
|
summary: "Get session by ID"
|
|
3097
2950
|
}
|
|
3098
2951
|
});
|
|
3099
|
-
var sessionMessagesContract =
|
|
2952
|
+
var sessionMessagesContract = c12.router({
|
|
3100
2953
|
/**
|
|
3101
2954
|
* POST /api/agent/sessions/:id/messages
|
|
3102
2955
|
* Append chat messages to a session
|
|
@@ -3105,20 +2958,20 @@ var sessionMessagesContract = c13.router({
|
|
|
3105
2958
|
method: "POST",
|
|
3106
2959
|
path: "/api/agent/sessions/:id/messages",
|
|
3107
2960
|
headers: authHeadersSchema,
|
|
3108
|
-
pathParams:
|
|
3109
|
-
id:
|
|
2961
|
+
pathParams: z14.object({
|
|
2962
|
+
id: z14.string().min(1, "Session ID is required")
|
|
3110
2963
|
}),
|
|
3111
|
-
body:
|
|
3112
|
-
messages:
|
|
3113
|
-
|
|
3114
|
-
role:
|
|
3115
|
-
content:
|
|
3116
|
-
runId:
|
|
2964
|
+
body: z14.object({
|
|
2965
|
+
messages: z14.array(
|
|
2966
|
+
z14.object({
|
|
2967
|
+
role: z14.enum(["user", "assistant"]),
|
|
2968
|
+
content: z14.string(),
|
|
2969
|
+
runId: z14.string().optional()
|
|
3117
2970
|
})
|
|
3118
2971
|
)
|
|
3119
2972
|
}),
|
|
3120
2973
|
responses: {
|
|
3121
|
-
200:
|
|
2974
|
+
200: z14.object({ success: z14.literal(true) }),
|
|
3122
2975
|
401: apiErrorSchema,
|
|
3123
2976
|
403: apiErrorSchema,
|
|
3124
2977
|
404: apiErrorSchema
|
|
@@ -3126,7 +2979,7 @@ var sessionMessagesContract = c13.router({
|
|
|
3126
2979
|
summary: "Append chat messages to a session"
|
|
3127
2980
|
}
|
|
3128
2981
|
});
|
|
3129
|
-
var checkpointsByIdContract =
|
|
2982
|
+
var checkpointsByIdContract = c12.router({
|
|
3130
2983
|
/**
|
|
3131
2984
|
* GET /api/agent/checkpoints/:id
|
|
3132
2985
|
* Get checkpoint by ID
|
|
@@ -3135,8 +2988,8 @@ var checkpointsByIdContract = c13.router({
|
|
|
3135
2988
|
method: "GET",
|
|
3136
2989
|
path: "/api/agent/checkpoints/:id",
|
|
3137
2990
|
headers: authHeadersSchema,
|
|
3138
|
-
pathParams:
|
|
3139
|
-
id:
|
|
2991
|
+
pathParams: z14.object({
|
|
2992
|
+
id: z14.string().min(1, "Checkpoint ID is required")
|
|
3140
2993
|
}),
|
|
3141
2994
|
responses: {
|
|
3142
2995
|
200: checkpointResponseSchema,
|
|
@@ -3148,6 +3001,155 @@ var checkpointsByIdContract = c13.router({
|
|
|
3148
3001
|
}
|
|
3149
3002
|
});
|
|
3150
3003
|
|
|
3004
|
+
// ../../packages/core/src/contracts/runners.ts
|
|
3005
|
+
import { z as z15 } from "zod";
|
|
3006
|
+
var c13 = initContract();
|
|
3007
|
+
var runnerGroupSchema = z15.string().regex(
|
|
3008
|
+
/^[a-z0-9-]+\/[a-z0-9-]+$/,
|
|
3009
|
+
"Runner group must be in org/name format (e.g., acme/production)"
|
|
3010
|
+
);
|
|
3011
|
+
var jobSchema = z15.object({
|
|
3012
|
+
runId: z15.string().uuid(),
|
|
3013
|
+
prompt: z15.string(),
|
|
3014
|
+
agentComposeVersionId: z15.string().nullable(),
|
|
3015
|
+
vars: z15.record(z15.string(), z15.string()).nullable(),
|
|
3016
|
+
checkpointId: z15.string().uuid().nullable()
|
|
3017
|
+
});
|
|
3018
|
+
var runnersPollContract = c13.router({
|
|
3019
|
+
poll: {
|
|
3020
|
+
method: "POST",
|
|
3021
|
+
path: "/api/runners/poll",
|
|
3022
|
+
headers: authHeadersSchema,
|
|
3023
|
+
body: z15.object({
|
|
3024
|
+
group: runnerGroupSchema
|
|
3025
|
+
}),
|
|
3026
|
+
responses: {
|
|
3027
|
+
200: z15.object({
|
|
3028
|
+
job: jobSchema.nullable()
|
|
3029
|
+
}),
|
|
3030
|
+
400: apiErrorSchema,
|
|
3031
|
+
401: apiErrorSchema,
|
|
3032
|
+
500: apiErrorSchema
|
|
3033
|
+
},
|
|
3034
|
+
summary: "Poll for pending jobs (long-polling with 30s timeout)"
|
|
3035
|
+
}
|
|
3036
|
+
});
|
|
3037
|
+
var firewallApiSchema = z15.object({
|
|
3038
|
+
base: z15.string(),
|
|
3039
|
+
auth: z15.object({
|
|
3040
|
+
headers: z15.record(z15.string(), z15.string())
|
|
3041
|
+
}),
|
|
3042
|
+
permissions: z15.array(firewallPermissionSchema).optional()
|
|
3043
|
+
});
|
|
3044
|
+
var firewallSchema = z15.object({
|
|
3045
|
+
name: z15.string(),
|
|
3046
|
+
ref: z15.string(),
|
|
3047
|
+
apis: z15.array(firewallApiSchema)
|
|
3048
|
+
});
|
|
3049
|
+
var experimentalFirewallSchema = z15.array(firewallSchema);
|
|
3050
|
+
var storageEntrySchema = z15.object({
|
|
3051
|
+
mountPath: z15.string(),
|
|
3052
|
+
archiveUrl: z15.string().nullable()
|
|
3053
|
+
});
|
|
3054
|
+
var artifactEntrySchema = z15.object({
|
|
3055
|
+
mountPath: z15.string(),
|
|
3056
|
+
archiveUrl: z15.string().nullable(),
|
|
3057
|
+
vasStorageName: z15.string(),
|
|
3058
|
+
vasVersionId: z15.string()
|
|
3059
|
+
});
|
|
3060
|
+
var storageManifestSchema = z15.object({
|
|
3061
|
+
storages: z15.array(storageEntrySchema),
|
|
3062
|
+
artifact: artifactEntrySchema.nullable(),
|
|
3063
|
+
memory: artifactEntrySchema.nullable()
|
|
3064
|
+
});
|
|
3065
|
+
var resumeSessionSchema = z15.object({
|
|
3066
|
+
sessionId: z15.string(),
|
|
3067
|
+
sessionHistory: z15.string()
|
|
3068
|
+
});
|
|
3069
|
+
var storedExecutionContextSchema = z15.object({
|
|
3070
|
+
workingDir: z15.string(),
|
|
3071
|
+
storageManifest: storageManifestSchema.nullable(),
|
|
3072
|
+
environment: z15.record(z15.string(), z15.string()).nullable(),
|
|
3073
|
+
resumeSession: resumeSessionSchema.nullable(),
|
|
3074
|
+
encryptedSecrets: z15.string().nullable(),
|
|
3075
|
+
// AES-256-GCM encrypted Record<string, string> (secret name → value)
|
|
3076
|
+
// Maps secret names to OAuth connector types for runtime token refresh (e.g. { "GMAIL_ACCESS_TOKEN": "gmail" })
|
|
3077
|
+
secretConnectorMap: z15.record(z15.string(), z15.string()).nullable().optional(),
|
|
3078
|
+
cliAgentType: z15.string(),
|
|
3079
|
+
// Debug flag to force real Claude in mock environments (internal use only)
|
|
3080
|
+
debugNoMockClaude: z15.boolean().optional(),
|
|
3081
|
+
// Dispatch timestamp for E2E timing metrics
|
|
3082
|
+
apiStartTime: z15.number().optional(),
|
|
3083
|
+
// User's timezone preference (IANA format, e.g., "Asia/Shanghai")
|
|
3084
|
+
userTimezone: z15.string().optional(),
|
|
3085
|
+
// Agent metadata for VM0_AGENT_NAME and VM0_AGENT_ORG env vars
|
|
3086
|
+
agentName: z15.string().optional(),
|
|
3087
|
+
agentOrgSlug: z15.string().optional(),
|
|
3088
|
+
// Memory storage name (for first-run when manifest.memory is null)
|
|
3089
|
+
memoryName: z15.string().optional(),
|
|
3090
|
+
// Experimental firewall for proxy-side token replacement
|
|
3091
|
+
experimentalFirewall: experimentalFirewallSchema.optional(),
|
|
3092
|
+
// Experimental capabilities for agent permission enforcement
|
|
3093
|
+
experimentalCapabilities: z15.array(z15.enum(VALID_CAPABILITIES)).optional()
|
|
3094
|
+
});
|
|
3095
|
+
var executionContextSchema = z15.object({
|
|
3096
|
+
runId: z15.string().uuid(),
|
|
3097
|
+
prompt: z15.string(),
|
|
3098
|
+
agentComposeVersionId: z15.string().nullable(),
|
|
3099
|
+
vars: z15.record(z15.string(), z15.string()).nullable(),
|
|
3100
|
+
checkpointId: z15.string().uuid().nullable(),
|
|
3101
|
+
sandboxToken: z15.string(),
|
|
3102
|
+
// New fields for E2B parity:
|
|
3103
|
+
workingDir: z15.string(),
|
|
3104
|
+
storageManifest: storageManifestSchema.nullable(),
|
|
3105
|
+
environment: z15.record(z15.string(), z15.string()).nullable(),
|
|
3106
|
+
resumeSession: resumeSessionSchema.nullable(),
|
|
3107
|
+
secretValues: z15.array(z15.string()).nullable(),
|
|
3108
|
+
// AES-256-GCM encrypted Record<string, string> — passed through to mitm-addon for auth resolution
|
|
3109
|
+
encryptedSecrets: z15.string().nullable(),
|
|
3110
|
+
// Maps secret names to OAuth connector types for runtime token refresh
|
|
3111
|
+
secretConnectorMap: z15.record(z15.string(), z15.string()).nullable().optional(),
|
|
3112
|
+
cliAgentType: z15.string(),
|
|
3113
|
+
// Debug flag to force real Claude in mock environments (internal use only)
|
|
3114
|
+
debugNoMockClaude: z15.boolean().optional(),
|
|
3115
|
+
// Dispatch timestamp for E2E timing metrics
|
|
3116
|
+
apiStartTime: z15.number().optional(),
|
|
3117
|
+
// User's timezone preference (IANA format, e.g., "Asia/Shanghai")
|
|
3118
|
+
userTimezone: z15.string().optional(),
|
|
3119
|
+
// Agent metadata
|
|
3120
|
+
agentName: z15.string().optional(),
|
|
3121
|
+
agentOrgSlug: z15.string().optional(),
|
|
3122
|
+
// Memory storage name (for first-run when manifest.memory is null)
|
|
3123
|
+
memoryName: z15.string().optional(),
|
|
3124
|
+
// Experimental firewall for proxy-side token replacement
|
|
3125
|
+
experimentalFirewall: experimentalFirewallSchema.optional(),
|
|
3126
|
+
// Experimental capabilities for agent permission enforcement
|
|
3127
|
+
experimentalCapabilities: z15.array(z15.enum(VALID_CAPABILITIES)).optional()
|
|
3128
|
+
});
|
|
3129
|
+
var runnersJobClaimContract = c13.router({
|
|
3130
|
+
claim: {
|
|
3131
|
+
method: "POST",
|
|
3132
|
+
path: "/api/runners/jobs/:id/claim",
|
|
3133
|
+
headers: authHeadersSchema,
|
|
3134
|
+
pathParams: z15.object({
|
|
3135
|
+
id: z15.string().uuid()
|
|
3136
|
+
}),
|
|
3137
|
+
body: z15.object({}),
|
|
3138
|
+
responses: {
|
|
3139
|
+
200: executionContextSchema,
|
|
3140
|
+
400: apiErrorSchema,
|
|
3141
|
+
401: apiErrorSchema,
|
|
3142
|
+
403: apiErrorSchema,
|
|
3143
|
+
// Job does not belong to user
|
|
3144
|
+
404: apiErrorSchema,
|
|
3145
|
+
409: apiErrorSchema,
|
|
3146
|
+
// Already claimed
|
|
3147
|
+
500: apiErrorSchema
|
|
3148
|
+
},
|
|
3149
|
+
summary: "Claim a pending job for execution"
|
|
3150
|
+
}
|
|
3151
|
+
});
|
|
3152
|
+
|
|
3151
3153
|
// ../../packages/core/src/contracts/schedules.ts
|
|
3152
3154
|
import { z as z16 } from "zod";
|
|
3153
3155
|
var c14 = initContract();
|
|
@@ -3196,7 +3198,10 @@ var deployScheduleRequestSchema = z16.object({
|
|
|
3196
3198
|
// Resolved agent compose ID (CLI resolves org/name:version → composeId)
|
|
3197
3199
|
composeId: z16.string().uuid("Invalid compose ID"),
|
|
3198
3200
|
// Enable schedule immediately upon creation
|
|
3199
|
-
enabled: z16.boolean().optional()
|
|
3201
|
+
enabled: z16.boolean().optional(),
|
|
3202
|
+
// Per-schedule notification control (AND'd with user global preferences)
|
|
3203
|
+
notifyEmail: z16.boolean().optional(),
|
|
3204
|
+
notifySlack: z16.boolean().optional()
|
|
3200
3205
|
}).refine(
|
|
3201
3206
|
(data) => {
|
|
3202
3207
|
const triggers = [
|
|
@@ -3230,6 +3235,8 @@ var scheduleResponseSchema = z16.object({
|
|
|
3230
3235
|
artifactVersion: z16.string().nullable(),
|
|
3231
3236
|
volumeVersions: z16.record(z16.string(), z16.string()).nullable(),
|
|
3232
3237
|
enabled: z16.boolean(),
|
|
3238
|
+
notifyEmail: z16.boolean(),
|
|
3239
|
+
notifySlack: z16.boolean(),
|
|
3233
3240
|
nextRunAt: z16.string().nullable(),
|
|
3234
3241
|
lastRunAt: z16.string().nullable(),
|
|
3235
3242
|
retryStartedAt: z16.string().nullable(),
|
|
@@ -6449,7 +6456,7 @@ var computerConnectorContract = c18.router({
|
|
|
6449
6456
|
}
|
|
6450
6457
|
});
|
|
6451
6458
|
|
|
6452
|
-
// ../../packages/core/src/contracts/
|
|
6459
|
+
// ../../packages/core/src/contracts/firewall.ts
|
|
6453
6460
|
function bearerAuth(secretName) {
|
|
6454
6461
|
return { headers: { Authorization: `Bearer \${{ secrets.${secretName} }}` } };
|
|
6455
6462
|
}
|
|
@@ -6460,7 +6467,7 @@ var FULL_ACCESS_PERMISSION = {
|
|
|
6460
6467
|
function api(base, auth) {
|
|
6461
6468
|
return { base, auth, permissions: [FULL_ACCESS_PERMISSION] };
|
|
6462
6469
|
}
|
|
6463
|
-
var
|
|
6470
|
+
var FIREWALL_CONFIGS = {
|
|
6464
6471
|
ahrefs: {
|
|
6465
6472
|
apis: [api("https://api.ahrefs.com", bearerAuth("AHREFS_TOKEN"))]
|
|
6466
6473
|
},
|
|
@@ -7027,13 +7034,13 @@ var SERVICE_CONFIGS = {
|
|
|
7027
7034
|
]
|
|
7028
7035
|
}
|
|
7029
7036
|
};
|
|
7030
|
-
function
|
|
7031
|
-
const config =
|
|
7037
|
+
function getFirewallConfig(type2) {
|
|
7038
|
+
const config = FIREWALL_CONFIGS[type2];
|
|
7032
7039
|
if (!config) return void 0;
|
|
7033
7040
|
return { ...config, name: type2 };
|
|
7034
7041
|
}
|
|
7035
7042
|
|
|
7036
|
-
// ../../packages/core/src/contracts/
|
|
7043
|
+
// ../../packages/core/src/contracts/firewall-expander.ts
|
|
7037
7044
|
var VALID_RULE_METHODS = /* @__PURE__ */ new Set([
|
|
7038
7045
|
"GET",
|
|
7039
7046
|
"POST",
|
|
@@ -7048,23 +7055,23 @@ function validateRule(rule, permName, serviceName) {
|
|
|
7048
7055
|
const parts = rule.split(" ", 2);
|
|
7049
7056
|
if (parts.length !== 2 || !parts[1]) {
|
|
7050
7057
|
throw new Error(
|
|
7051
|
-
`Invalid rule "${rule}" in permission "${permName}" of
|
|
7058
|
+
`Invalid rule "${rule}" in permission "${permName}" of firewall "${serviceName}": must be "METHOD /path"`
|
|
7052
7059
|
);
|
|
7053
7060
|
}
|
|
7054
7061
|
const [method, path18] = parts;
|
|
7055
7062
|
if (!VALID_RULE_METHODS.has(method)) {
|
|
7056
7063
|
throw new Error(
|
|
7057
|
-
`Invalid rule "${rule}" in permission "${permName}" of
|
|
7064
|
+
`Invalid rule "${rule}" in permission "${permName}" of firewall "${serviceName}": unknown method "${method}" (must be uppercase)`
|
|
7058
7065
|
);
|
|
7059
7066
|
}
|
|
7060
7067
|
if (!path18.startsWith("/")) {
|
|
7061
7068
|
throw new Error(
|
|
7062
|
-
`Invalid rule "${rule}" in permission "${permName}" of
|
|
7069
|
+
`Invalid rule "${rule}" in permission "${permName}" of firewall "${serviceName}": path must start with "/"`
|
|
7063
7070
|
);
|
|
7064
7071
|
}
|
|
7065
7072
|
if (path18.includes("?") || path18.includes("#")) {
|
|
7066
7073
|
throw new Error(
|
|
7067
|
-
`Invalid rule "${rule}" in permission "${permName}" of
|
|
7074
|
+
`Invalid rule "${rule}" in permission "${permName}" of firewall "${serviceName}": path must not contain query string or fragment`
|
|
7068
7075
|
);
|
|
7069
7076
|
}
|
|
7070
7077
|
const segments = path18.split("/").filter(Boolean);
|
|
@@ -7076,18 +7083,18 @@ function validateRule(rule, permName, serviceName) {
|
|
|
7076
7083
|
const baseName = name.endsWith("+") ? name.slice(0, -1) : name;
|
|
7077
7084
|
if (!baseName) {
|
|
7078
7085
|
throw new Error(
|
|
7079
|
-
`Invalid rule "${rule}" in permission "${permName}" of
|
|
7086
|
+
`Invalid rule "${rule}" in permission "${permName}" of firewall "${serviceName}": empty parameter name`
|
|
7080
7087
|
);
|
|
7081
7088
|
}
|
|
7082
7089
|
if (paramNames.has(baseName)) {
|
|
7083
7090
|
throw new Error(
|
|
7084
|
-
`Invalid rule "${rule}" in permission "${permName}" of
|
|
7091
|
+
`Invalid rule "${rule}" in permission "${permName}" of firewall "${serviceName}": duplicate parameter name "{${baseName}}"`
|
|
7085
7092
|
);
|
|
7086
7093
|
}
|
|
7087
7094
|
paramNames.add(baseName);
|
|
7088
7095
|
if (name.endsWith("+") && i !== segments.length - 1) {
|
|
7089
7096
|
throw new Error(
|
|
7090
|
-
`Invalid rule "${rule}" in permission "${permName}" of
|
|
7097
|
+
`Invalid rule "${rule}" in permission "${permName}" of firewall "${serviceName}": {${name}} must be the last segment`
|
|
7091
7098
|
);
|
|
7092
7099
|
}
|
|
7093
7100
|
}
|
|
@@ -7099,31 +7106,31 @@ function validateBaseUrl(base, serviceName) {
|
|
|
7099
7106
|
url = new URL(base);
|
|
7100
7107
|
} catch {
|
|
7101
7108
|
throw new Error(
|
|
7102
|
-
`Invalid base URL "${base}" in
|
|
7109
|
+
`Invalid base URL "${base}" in firewall "${serviceName}": not a valid URL`
|
|
7103
7110
|
);
|
|
7104
7111
|
}
|
|
7105
7112
|
if (url.search) {
|
|
7106
7113
|
throw new Error(
|
|
7107
|
-
`Invalid base URL "${base}" in
|
|
7114
|
+
`Invalid base URL "${base}" in firewall "${serviceName}": must not contain query string`
|
|
7108
7115
|
);
|
|
7109
7116
|
}
|
|
7110
7117
|
if (url.hash) {
|
|
7111
7118
|
throw new Error(
|
|
7112
|
-
`Invalid base URL "${base}" in
|
|
7119
|
+
`Invalid base URL "${base}" in firewall "${serviceName}": must not contain fragment`
|
|
7113
7120
|
);
|
|
7114
7121
|
}
|
|
7115
7122
|
}
|
|
7116
|
-
function
|
|
7123
|
+
function resolveFirewallConfig(ref) {
|
|
7117
7124
|
const parsed = connectorTypeSchema.safeParse(ref);
|
|
7118
7125
|
if (!parsed.success) {
|
|
7119
7126
|
throw new Error(
|
|
7120
|
-
`Cannot resolve
|
|
7127
|
+
`Cannot resolve firewall ref "${ref}": no built-in firewall config with this name`
|
|
7121
7128
|
);
|
|
7122
7129
|
}
|
|
7123
|
-
const serviceConfig =
|
|
7130
|
+
const serviceConfig = getFirewallConfig(parsed.data);
|
|
7124
7131
|
if (!serviceConfig) {
|
|
7125
7132
|
throw new Error(
|
|
7126
|
-
`
|
|
7133
|
+
`Firewall ref "${ref}" resolved to "${parsed.data}" but it does not support proxy-side token replacement`
|
|
7127
7134
|
);
|
|
7128
7135
|
}
|
|
7129
7136
|
return serviceConfig;
|
|
@@ -7131,7 +7138,7 @@ function resolveServiceConfig(ref) {
|
|
|
7131
7138
|
function collectAndValidatePermissions(ref, serviceConfig) {
|
|
7132
7139
|
if (serviceConfig.apis.length === 0) {
|
|
7133
7140
|
throw new Error(
|
|
7134
|
-
`
|
|
7141
|
+
`Firewall "${serviceConfig.name}" (ref "${ref}") has no api entries`
|
|
7135
7142
|
);
|
|
7136
7143
|
}
|
|
7137
7144
|
const available = /* @__PURE__ */ new Set();
|
|
@@ -7139,29 +7146,29 @@ function collectAndValidatePermissions(ref, serviceConfig) {
|
|
|
7139
7146
|
validateBaseUrl(api2.base, serviceConfig.name);
|
|
7140
7147
|
if (!api2.permissions || api2.permissions.length === 0) {
|
|
7141
7148
|
throw new Error(
|
|
7142
|
-
`API entry "${api2.base}" in
|
|
7149
|
+
`API entry "${api2.base}" in firewall "${serviceConfig.name}" (ref "${ref}") has no permissions`
|
|
7143
7150
|
);
|
|
7144
7151
|
}
|
|
7145
7152
|
const seen = /* @__PURE__ */ new Set();
|
|
7146
7153
|
for (const perm of api2.permissions) {
|
|
7147
7154
|
if (!perm.name) {
|
|
7148
7155
|
throw new Error(
|
|
7149
|
-
`
|
|
7156
|
+
`Firewall "${serviceConfig.name}" (ref "${ref}") has a permission with empty name`
|
|
7150
7157
|
);
|
|
7151
7158
|
}
|
|
7152
7159
|
if (perm.name === "all") {
|
|
7153
7160
|
throw new Error(
|
|
7154
|
-
`
|
|
7161
|
+
`Firewall "${serviceConfig.name}" (ref "${ref}") has a permission named "all", which is a reserved keyword`
|
|
7155
7162
|
);
|
|
7156
7163
|
}
|
|
7157
7164
|
if (seen.has(perm.name)) {
|
|
7158
7165
|
throw new Error(
|
|
7159
|
-
`Duplicate permission name "${perm.name}" in API entry "${api2.base}" of
|
|
7166
|
+
`Duplicate permission name "${perm.name}" in API entry "${api2.base}" of firewall "${serviceConfig.name}" (ref "${ref}")`
|
|
7160
7167
|
);
|
|
7161
7168
|
}
|
|
7162
7169
|
if (perm.rules.length === 0) {
|
|
7163
7170
|
throw new Error(
|
|
7164
|
-
`Permission "${perm.name}" in
|
|
7171
|
+
`Permission "${perm.name}" in firewall "${serviceConfig.name}" (ref "${ref}") has no rules`
|
|
7165
7172
|
);
|
|
7166
7173
|
}
|
|
7167
7174
|
for (const rule of perm.rules) {
|
|
@@ -7173,16 +7180,16 @@ function collectAndValidatePermissions(ref, serviceConfig) {
|
|
|
7173
7180
|
}
|
|
7174
7181
|
return available;
|
|
7175
7182
|
}
|
|
7176
|
-
function
|
|
7183
|
+
function expandFirewallConfigs(config) {
|
|
7177
7184
|
const compose = config;
|
|
7178
7185
|
if (!compose?.agents) return;
|
|
7179
7186
|
for (const agent of Object.values(compose.agents)) {
|
|
7180
|
-
const
|
|
7181
|
-
if (!
|
|
7182
|
-
if (Array.isArray(
|
|
7187
|
+
const configs = agent.experimental_firewall;
|
|
7188
|
+
if (!configs) continue;
|
|
7189
|
+
if (Array.isArray(configs)) continue;
|
|
7183
7190
|
const expanded = [];
|
|
7184
|
-
for (const [ref, selection] of Object.entries(
|
|
7185
|
-
const serviceConfig =
|
|
7191
|
+
for (const [ref, selection] of Object.entries(configs)) {
|
|
7192
|
+
const serviceConfig = resolveFirewallConfig(ref);
|
|
7186
7193
|
const availablePermissions = collectAndValidatePermissions(
|
|
7187
7194
|
ref,
|
|
7188
7195
|
serviceConfig
|
|
@@ -7192,7 +7199,7 @@ function expandServiceConfigs(config) {
|
|
|
7192
7199
|
if (!availablePermissions.has(name)) {
|
|
7193
7200
|
const available = [...availablePermissions].join(", ");
|
|
7194
7201
|
throw new Error(
|
|
7195
|
-
`Permission "${name}" does not exist in
|
|
7202
|
+
`Permission "${name}" does not exist in firewall "${serviceConfig.name}" (ref "${ref}"). Available: ${available}`
|
|
7196
7203
|
);
|
|
7197
7204
|
}
|
|
7198
7205
|
}
|
|
@@ -7214,7 +7221,7 @@ function expandServiceConfigs(config) {
|
|
|
7214
7221
|
entry.placeholders = serviceConfig.placeholders;
|
|
7215
7222
|
expanded.push(entry);
|
|
7216
7223
|
}
|
|
7217
|
-
agent.
|
|
7224
|
+
agent.experimental_firewall = expanded;
|
|
7218
7225
|
}
|
|
7219
7226
|
}
|
|
7220
7227
|
|
|
@@ -7810,7 +7817,8 @@ var FEATURE_SWITCHES = {
|
|
|
7810
7817
|
},
|
|
7811
7818
|
["zero" /* Zero */]: {
|
|
7812
7819
|
maintainer: "ethan@vm0.ai",
|
|
7813
|
-
enabled: false
|
|
7820
|
+
enabled: false,
|
|
7821
|
+
enabledUserHashes: STAFF_USER_HASHES
|
|
7814
7822
|
}
|
|
7815
7823
|
};
|
|
7816
7824
|
async function isFeatureEnabled(key, userId) {
|
|
@@ -7998,15 +8006,6 @@ async function httpPost(path18, body) {
|
|
|
7998
8006
|
body: JSON.stringify(body)
|
|
7999
8007
|
});
|
|
8000
8008
|
}
|
|
8001
|
-
async function httpDelete(path18) {
|
|
8002
|
-
const baseUrl = await getBaseUrl();
|
|
8003
|
-
const headers = await getRawHeaders();
|
|
8004
|
-
const orgPath = await appendOrgParam(path18);
|
|
8005
|
-
return fetch(`${baseUrl}${orgPath}`, {
|
|
8006
|
-
method: "DELETE",
|
|
8007
|
-
headers
|
|
8008
|
-
});
|
|
8009
|
-
}
|
|
8010
8009
|
|
|
8011
8010
|
// src/lib/api/domains/composes.ts
|
|
8012
8011
|
import { initClient } from "@ts-rest/core";
|
|
@@ -9805,7 +9804,7 @@ async function finalizeCompose(config, agent, variables, options) {
|
|
|
9805
9804
|
process.exit(0);
|
|
9806
9805
|
}
|
|
9807
9806
|
mergeSkillVariables(agent, variables);
|
|
9808
|
-
|
|
9807
|
+
expandFirewallConfigs(config);
|
|
9809
9808
|
if (!options.json) {
|
|
9810
9809
|
console.log("Uploading compose...");
|
|
9811
9810
|
}
|
|
@@ -9945,7 +9944,7 @@ var composeCommand = new Command7().name("compose").description("Create or updat
|
|
|
9945
9944
|
options.autoUpdate = false;
|
|
9946
9945
|
}
|
|
9947
9946
|
if (options.autoUpdate !== false) {
|
|
9948
|
-
await startSilentUpgrade("9.
|
|
9947
|
+
await startSilentUpgrade("9.60.0");
|
|
9949
9948
|
}
|
|
9950
9949
|
try {
|
|
9951
9950
|
let result;
|
|
@@ -11112,30 +11111,13 @@ var mainRunCommand = new Command8().name("run").description("Run an agent").argu
|
|
|
11112
11111
|
).option(
|
|
11113
11112
|
"--model-provider <type>",
|
|
11114
11113
|
"Override model provider (e.g., anthropic-api-key)"
|
|
11115
|
-
).option("--verbose", "Show full tool inputs and outputs").option(
|
|
11116
|
-
"--experimental-shared-agent",
|
|
11117
|
-
"Allow running agents shared by other users (required when running org/agent format)"
|
|
11118
|
-
).option("--check-env", "Validate secrets and vars before running").addOption(new Option2("--debug-no-mock-claude").hideHelp()).addOption(new Option2("--no-auto-update").hideHelp()).action(
|
|
11114
|
+
).option("--verbose", "Show full tool inputs and outputs").option("--check-env", "Validate secrets and vars before running").addOption(new Option2("--debug-no-mock-claude").hideHelp()).addOption(new Option2("--no-auto-update").hideHelp()).action(
|
|
11119
11115
|
withErrorHandler(
|
|
11120
11116
|
async (identifier, prompt, options) => {
|
|
11121
11117
|
if (options.autoUpdate !== false) {
|
|
11122
|
-
await startSilentUpgrade("9.
|
|
11118
|
+
await startSilentUpgrade("9.60.0");
|
|
11123
11119
|
}
|
|
11124
11120
|
const { org, name, version } = parseIdentifier(identifier);
|
|
11125
|
-
if (org && !options.experimentalSharedAgent) {
|
|
11126
|
-
const defaultOrg = await getOrg();
|
|
11127
|
-
const isOwnOrg = defaultOrg.slug === org;
|
|
11128
|
-
if (!isOwnOrg) {
|
|
11129
|
-
throw new Error(
|
|
11130
|
-
"Running shared agents requires --experimental-shared-agent flag",
|
|
11131
|
-
{
|
|
11132
|
-
cause: new Error(
|
|
11133
|
-
`Use: vm0 run ${identifier} --experimental-shared-agent "your prompt"`
|
|
11134
|
-
)
|
|
11135
|
-
}
|
|
11136
|
-
);
|
|
11137
|
-
}
|
|
11138
|
-
}
|
|
11139
11121
|
let composeId;
|
|
11140
11122
|
let composeContent;
|
|
11141
11123
|
if (isUUID(name)) {
|
|
@@ -12806,7 +12788,7 @@ var cookAction = new Command34().name("cook").description("Quick start: prepare,
|
|
|
12806
12788
|
withErrorHandler(
|
|
12807
12789
|
async (prompt, options) => {
|
|
12808
12790
|
if (options.autoUpdate !== false) {
|
|
12809
|
-
const shouldExit = await checkAndUpgrade("9.
|
|
12791
|
+
const shouldExit = await checkAndUpgrade("9.60.0", prompt);
|
|
12810
12792
|
if (shouldExit) {
|
|
12811
12793
|
process.exit(0);
|
|
12812
12794
|
}
|
|
@@ -14252,7 +14234,7 @@ var leaveCommand = new Command47().name("leave").description("Leave the current
|
|
|
14252
14234
|
var orgCommand = new Command48().name("org").description("Manage your organization (namespace for agents)").addCommand(statusCommand5).addCommand(setCommand).addCommand(listCommand5).addCommand(useCommand).addCommand(membersCommand).addCommand(inviteCommand).addCommand(removeCommand).addCommand(leaveCommand);
|
|
14253
14235
|
|
|
14254
14236
|
// src/commands/agent/index.ts
|
|
14255
|
-
import { Command as
|
|
14237
|
+
import { Command as Command53 } from "commander";
|
|
14256
14238
|
|
|
14257
14239
|
// src/commands/agent/clone.ts
|
|
14258
14240
|
import { Command as Command49 } from "commander";
|
|
@@ -14594,326 +14576,78 @@ function formatComposeOutput(name, versionId, content, variableSources) {
|
|
|
14594
14576
|
}
|
|
14595
14577
|
var statusCommand6 = new Command52().name("status").description("Show status of agent compose").argument(
|
|
14596
14578
|
"<name[:version]>",
|
|
14597
|
-
"Agent name with optional version (e.g., my-agent:latest or my-agent:a1b2c3d4)"
|
|
14598
|
-
).option("--no-sources", "Skip fetching skills to determine variable sources").action(
|
|
14599
|
-
withErrorHandler(
|
|
14600
|
-
async (argument, options) => {
|
|
14601
|
-
const colonIndex = argument.lastIndexOf(":");
|
|
14602
|
-
let name;
|
|
14603
|
-
let version;
|
|
14604
|
-
if (colonIndex === -1) {
|
|
14605
|
-
name = argument;
|
|
14606
|
-
version = "latest";
|
|
14607
|
-
} else {
|
|
14608
|
-
name = argument.slice(0, colonIndex);
|
|
14609
|
-
version = argument.slice(colonIndex + 1) || "latest";
|
|
14610
|
-
}
|
|
14611
|
-
const compose = await getComposeByName(name);
|
|
14612
|
-
if (!compose) {
|
|
14613
|
-
throw new Error(`Agent compose not found: ${name}`, {
|
|
14614
|
-
cause: new Error("Run: vm0 agent list")
|
|
14615
|
-
});
|
|
14616
|
-
}
|
|
14617
|
-
let resolvedVersionId = compose.headVersionId;
|
|
14618
|
-
if (version !== "latest" && compose.headVersionId) {
|
|
14619
|
-
if (version.length < 64) {
|
|
14620
|
-
try {
|
|
14621
|
-
const versionInfo = await getComposeVersion(compose.id, version);
|
|
14622
|
-
resolvedVersionId = versionInfo.versionId;
|
|
14623
|
-
} catch (error) {
|
|
14624
|
-
if (error instanceof Error && error.message.includes("not found")) {
|
|
14625
|
-
throw new Error(`Version not found: ${version}`, {
|
|
14626
|
-
cause: new Error(
|
|
14627
|
-
`HEAD version: ${compose.headVersionId?.slice(0, 8)}`
|
|
14628
|
-
)
|
|
14629
|
-
});
|
|
14630
|
-
}
|
|
14631
|
-
throw error;
|
|
14632
|
-
}
|
|
14633
|
-
} else {
|
|
14634
|
-
resolvedVersionId = version;
|
|
14635
|
-
}
|
|
14636
|
-
}
|
|
14637
|
-
if (!resolvedVersionId || !compose.content) {
|
|
14638
|
-
throw new Error(`No version found for: ${name}`);
|
|
14639
|
-
}
|
|
14640
|
-
const content = compose.content;
|
|
14641
|
-
let variableSources;
|
|
14642
|
-
try {
|
|
14643
|
-
variableSources = await deriveComposeVariableSources(content, {
|
|
14644
|
-
skipNetwork: options.sources === false
|
|
14645
|
-
});
|
|
14646
|
-
} catch {
|
|
14647
|
-
console.error(
|
|
14648
|
-
chalk48.yellow(
|
|
14649
|
-
"\u26A0 Warning: Failed to fetch skill sources, showing basic info"
|
|
14650
|
-
)
|
|
14651
|
-
);
|
|
14652
|
-
}
|
|
14653
|
-
formatComposeOutput(
|
|
14654
|
-
compose.name,
|
|
14655
|
-
resolvedVersionId,
|
|
14656
|
-
content,
|
|
14657
|
-
variableSources
|
|
14658
|
-
);
|
|
14659
|
-
}
|
|
14660
|
-
)
|
|
14661
|
-
);
|
|
14662
|
-
|
|
14663
|
-
// src/commands/agent/public.ts
|
|
14664
|
-
import { Command as Command53 } from "commander";
|
|
14665
|
-
import chalk49 from "chalk";
|
|
14666
|
-
var publicCommand = new Command53().name("public").description("Make an agent public (accessible to all authenticated users)").argument("<name>", "Agent name").option(
|
|
14667
|
-
"--experimental-shared-agent",
|
|
14668
|
-
"Enable experimental agent sharing feature"
|
|
14669
|
-
).action(
|
|
14670
|
-
withErrorHandler(
|
|
14671
|
-
async (name, options) => {
|
|
14672
|
-
if (!options.experimentalSharedAgent) {
|
|
14673
|
-
throw new Error(
|
|
14674
|
-
"This command requires --experimental-shared-agent flag",
|
|
14675
|
-
{
|
|
14676
|
-
cause: new Error(
|
|
14677
|
-
`Use: vm0 agent public ${name} --experimental-shared-agent`
|
|
14678
|
-
)
|
|
14679
|
-
}
|
|
14680
|
-
);
|
|
14681
|
-
}
|
|
14682
|
-
const compose = await getComposeByName(name);
|
|
14683
|
-
if (!compose) {
|
|
14684
|
-
throw new Error(`Agent not found: ${name}`);
|
|
14685
|
-
}
|
|
14686
|
-
const org = await getOrg();
|
|
14687
|
-
const response = await httpPost(
|
|
14688
|
-
`/api/agent/composes/${compose.id}/permissions`,
|
|
14689
|
-
{ granteeType: "public" }
|
|
14690
|
-
);
|
|
14691
|
-
if (!response.ok) {
|
|
14692
|
-
const error = await response.json();
|
|
14693
|
-
if (response.status === 409) {
|
|
14694
|
-
console.log(chalk49.yellow(`Agent "${name}" is already public`));
|
|
14695
|
-
return;
|
|
14696
|
-
}
|
|
14697
|
-
throw new Error(
|
|
14698
|
-
error.error?.message || "Failed to make agent public"
|
|
14699
|
-
);
|
|
14700
|
-
}
|
|
14701
|
-
const fullName = `${org.slug}/${name}`;
|
|
14702
|
-
console.log(chalk49.green(`\u2713 Agent "${name}" is now public`));
|
|
14703
|
-
console.log();
|
|
14704
|
-
console.log("Others can now run your agent with:");
|
|
14705
|
-
console.log(
|
|
14706
|
-
chalk49.cyan(
|
|
14707
|
-
` vm0 run ${fullName} --experimental-shared-agent "your prompt"`
|
|
14708
|
-
)
|
|
14709
|
-
);
|
|
14710
|
-
}
|
|
14711
|
-
)
|
|
14712
|
-
);
|
|
14713
|
-
|
|
14714
|
-
// src/commands/agent/private.ts
|
|
14715
|
-
import { Command as Command54 } from "commander";
|
|
14716
|
-
import chalk50 from "chalk";
|
|
14717
|
-
var privateCommand = new Command54().name("private").description("Make an agent private (remove public access)").argument("<name>", "Agent name").option(
|
|
14718
|
-
"--experimental-shared-agent",
|
|
14719
|
-
"Enable experimental agent sharing feature"
|
|
14720
|
-
).action(
|
|
14721
|
-
withErrorHandler(
|
|
14722
|
-
async (name, options) => {
|
|
14723
|
-
if (!options.experimentalSharedAgent) {
|
|
14724
|
-
throw new Error(
|
|
14725
|
-
"This command requires --experimental-shared-agent flag",
|
|
14726
|
-
{
|
|
14727
|
-
cause: new Error(
|
|
14728
|
-
`Use: vm0 agent private ${name} --experimental-shared-agent`
|
|
14729
|
-
)
|
|
14730
|
-
}
|
|
14731
|
-
);
|
|
14732
|
-
}
|
|
14733
|
-
const compose = await getComposeByName(name);
|
|
14734
|
-
if (!compose) {
|
|
14735
|
-
throw new Error(`Agent not found: ${name}`);
|
|
14736
|
-
}
|
|
14737
|
-
const response = await httpDelete(
|
|
14738
|
-
`/api/agent/composes/${compose.id}/permissions?type=public`
|
|
14739
|
-
);
|
|
14740
|
-
if (!response.ok) {
|
|
14741
|
-
const error = await response.json();
|
|
14742
|
-
if (response.status === 404) {
|
|
14743
|
-
console.log(chalk50.yellow(`Agent "${name}" is already private`));
|
|
14744
|
-
return;
|
|
14745
|
-
}
|
|
14746
|
-
throw new Error(
|
|
14747
|
-
error.error?.message || "Failed to make agent private"
|
|
14748
|
-
);
|
|
14749
|
-
}
|
|
14750
|
-
console.log(chalk50.green(`\u2713 Agent "${name}" is now private`));
|
|
14751
|
-
}
|
|
14752
|
-
)
|
|
14753
|
-
);
|
|
14754
|
-
|
|
14755
|
-
// src/commands/agent/share.ts
|
|
14756
|
-
import { Command as Command55 } from "commander";
|
|
14757
|
-
import chalk51 from "chalk";
|
|
14758
|
-
var shareCommand = new Command55().name("share").description("Share an agent with a user by email").argument("<name>", "Agent name").requiredOption("--email <email>", "Email address to share with").option(
|
|
14759
|
-
"--experimental-shared-agent",
|
|
14760
|
-
"Enable experimental agent sharing feature"
|
|
14761
|
-
).action(
|
|
14579
|
+
"Agent name with optional version (e.g., my-agent:latest or my-agent:a1b2c3d4)"
|
|
14580
|
+
).option("--no-sources", "Skip fetching skills to determine variable sources").action(
|
|
14762
14581
|
withErrorHandler(
|
|
14763
|
-
async (
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
|
|
14769
|
-
|
|
14770
|
-
|
|
14771
|
-
|
|
14772
|
-
);
|
|
14582
|
+
async (argument, options) => {
|
|
14583
|
+
const colonIndex = argument.lastIndexOf(":");
|
|
14584
|
+
let name;
|
|
14585
|
+
let version;
|
|
14586
|
+
if (colonIndex === -1) {
|
|
14587
|
+
name = argument;
|
|
14588
|
+
version = "latest";
|
|
14589
|
+
} else {
|
|
14590
|
+
name = argument.slice(0, colonIndex);
|
|
14591
|
+
version = argument.slice(colonIndex + 1) || "latest";
|
|
14773
14592
|
}
|
|
14774
14593
|
const compose = await getComposeByName(name);
|
|
14775
14594
|
if (!compose) {
|
|
14776
|
-
throw new Error(`Agent not found: ${name}
|
|
14777
|
-
|
|
14778
|
-
|
|
14779
|
-
const response = await httpPost(
|
|
14780
|
-
`/api/agent/composes/${compose.id}/permissions`,
|
|
14781
|
-
{ granteeType: "email", granteeEmail: options.email }
|
|
14782
|
-
);
|
|
14783
|
-
if (!response.ok) {
|
|
14784
|
-
const error = await response.json();
|
|
14785
|
-
if (response.status === 409) {
|
|
14786
|
-
console.log(
|
|
14787
|
-
chalk51.yellow(
|
|
14788
|
-
`Agent "${name}" is already shared with ${options.email}`
|
|
14789
|
-
)
|
|
14790
|
-
);
|
|
14791
|
-
return;
|
|
14792
|
-
}
|
|
14793
|
-
throw new Error(error.error?.message || "Failed to share agent");
|
|
14595
|
+
throw new Error(`Agent compose not found: ${name}`, {
|
|
14596
|
+
cause: new Error("Run: vm0 agent list")
|
|
14597
|
+
});
|
|
14794
14598
|
}
|
|
14795
|
-
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14799
|
-
|
|
14800
|
-
|
|
14801
|
-
|
|
14802
|
-
|
|
14803
|
-
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
|
|
14809
|
-
|
|
14810
|
-
// src/commands/agent/unshare.ts
|
|
14811
|
-
import { Command as Command56 } from "commander";
|
|
14812
|
-
import chalk52 from "chalk";
|
|
14813
|
-
var unshareCommand = new Command56().name("unshare").description("Remove sharing from a user").argument("<name>", "Agent name").requiredOption("--email <email>", "Email address to unshare").option(
|
|
14814
|
-
"--experimental-shared-agent",
|
|
14815
|
-
"Enable experimental agent sharing feature"
|
|
14816
|
-
).action(
|
|
14817
|
-
withErrorHandler(
|
|
14818
|
-
async (name, options) => {
|
|
14819
|
-
if (!options.experimentalSharedAgent) {
|
|
14820
|
-
throw new Error(
|
|
14821
|
-
"This command requires --experimental-shared-agent flag",
|
|
14822
|
-
{
|
|
14823
|
-
cause: new Error(
|
|
14824
|
-
`Use: vm0 agent unshare ${name} --email ${options.email} --experimental-shared-agent`
|
|
14825
|
-
)
|
|
14599
|
+
let resolvedVersionId = compose.headVersionId;
|
|
14600
|
+
if (version !== "latest" && compose.headVersionId) {
|
|
14601
|
+
if (version.length < 64) {
|
|
14602
|
+
try {
|
|
14603
|
+
const versionInfo = await getComposeVersion(compose.id, version);
|
|
14604
|
+
resolvedVersionId = versionInfo.versionId;
|
|
14605
|
+
} catch (error) {
|
|
14606
|
+
if (error instanceof Error && error.message.includes("not found")) {
|
|
14607
|
+
throw new Error(`Version not found: ${version}`, {
|
|
14608
|
+
cause: new Error(
|
|
14609
|
+
`HEAD version: ${compose.headVersionId?.slice(0, 8)}`
|
|
14610
|
+
)
|
|
14611
|
+
});
|
|
14612
|
+
}
|
|
14613
|
+
throw error;
|
|
14826
14614
|
}
|
|
14827
|
-
|
|
14828
|
-
|
|
14829
|
-
const compose = await getComposeByName(name);
|
|
14830
|
-
if (!compose) {
|
|
14831
|
-
throw new Error(`Agent not found: ${name}`);
|
|
14832
|
-
}
|
|
14833
|
-
const response = await httpDelete(
|
|
14834
|
-
`/api/agent/composes/${compose.id}/permissions?type=email&email=${encodeURIComponent(options.email)}`
|
|
14835
|
-
);
|
|
14836
|
-
if (!response.ok) {
|
|
14837
|
-
const error = await response.json();
|
|
14838
|
-
if (response.status === 404) {
|
|
14839
|
-
console.log(
|
|
14840
|
-
chalk52.yellow(
|
|
14841
|
-
`Agent "${name}" is not shared with ${options.email}`
|
|
14842
|
-
)
|
|
14843
|
-
);
|
|
14844
|
-
return;
|
|
14615
|
+
} else {
|
|
14616
|
+
resolvedVersionId = version;
|
|
14845
14617
|
}
|
|
14846
|
-
throw new Error(error.error?.message || "Failed to unshare agent");
|
|
14847
|
-
}
|
|
14848
|
-
console.log(
|
|
14849
|
-
chalk52.green(`\u2713 Removed sharing of "${name}" from ${options.email}`)
|
|
14850
|
-
);
|
|
14851
|
-
}
|
|
14852
|
-
)
|
|
14853
|
-
);
|
|
14854
|
-
|
|
14855
|
-
// src/commands/agent/permission.ts
|
|
14856
|
-
import { Command as Command57 } from "commander";
|
|
14857
|
-
import chalk53 from "chalk";
|
|
14858
|
-
var permissionCommand = new Command57().name("permission").description("List all permissions for an agent").argument("<name>", "Agent name").option(
|
|
14859
|
-
"--experimental-shared-agent",
|
|
14860
|
-
"Enable experimental agent sharing feature"
|
|
14861
|
-
).action(
|
|
14862
|
-
withErrorHandler(
|
|
14863
|
-
async (name, options) => {
|
|
14864
|
-
if (!options.experimentalSharedAgent) {
|
|
14865
|
-
throw new Error(
|
|
14866
|
-
"This command requires --experimental-shared-agent flag",
|
|
14867
|
-
{
|
|
14868
|
-
cause: new Error(
|
|
14869
|
-
`Use: vm0 agent permission ${name} --experimental-shared-agent`
|
|
14870
|
-
)
|
|
14871
|
-
}
|
|
14872
|
-
);
|
|
14873
|
-
}
|
|
14874
|
-
const compose = await getComposeByName(name);
|
|
14875
|
-
if (!compose) {
|
|
14876
|
-
throw new Error(`Agent not found: ${name}`);
|
|
14877
14618
|
}
|
|
14878
|
-
|
|
14879
|
-
|
|
14880
|
-
);
|
|
14881
|
-
if (!response.ok) {
|
|
14882
|
-
const error = await response.json();
|
|
14883
|
-
throw new Error(error.error?.message || "Failed to list permissions");
|
|
14619
|
+
if (!resolvedVersionId || !compose.content) {
|
|
14620
|
+
throw new Error(`No version found for: ${name}`);
|
|
14884
14621
|
}
|
|
14885
|
-
const
|
|
14886
|
-
|
|
14887
|
-
|
|
14888
|
-
|
|
14622
|
+
const content = compose.content;
|
|
14623
|
+
let variableSources;
|
|
14624
|
+
try {
|
|
14625
|
+
variableSources = await deriveComposeVariableSources(content, {
|
|
14626
|
+
skipNetwork: options.sources === false
|
|
14627
|
+
});
|
|
14628
|
+
} catch {
|
|
14629
|
+
console.error(
|
|
14630
|
+
chalk48.yellow(
|
|
14631
|
+
"\u26A0 Warning: Failed to fetch skill sources, showing basic info"
|
|
14632
|
+
)
|
|
14633
|
+
);
|
|
14889
14634
|
}
|
|
14890
|
-
|
|
14891
|
-
|
|
14892
|
-
|
|
14893
|
-
|
|
14894
|
-
|
|
14895
|
-
console.log(
|
|
14896
|
-
chalk53.dim(
|
|
14897
|
-
"------- ----------------------------- ---------- ----------"
|
|
14898
|
-
)
|
|
14635
|
+
formatComposeOutput(
|
|
14636
|
+
compose.name,
|
|
14637
|
+
resolvedVersionId,
|
|
14638
|
+
content,
|
|
14639
|
+
variableSources
|
|
14899
14640
|
);
|
|
14900
|
-
for (const p of data.permissions) {
|
|
14901
|
-
const type2 = p.granteeType.padEnd(7);
|
|
14902
|
-
const email = (p.granteeEmail ?? "-").padEnd(29);
|
|
14903
|
-
const permission = p.permission.padEnd(10);
|
|
14904
|
-
const granted = formatRelativeTime(p.createdAt);
|
|
14905
|
-
console.log(`${type2} ${email} ${permission} ${granted}`);
|
|
14906
|
-
}
|
|
14907
14641
|
}
|
|
14908
14642
|
)
|
|
14909
14643
|
);
|
|
14910
14644
|
|
|
14911
14645
|
// src/commands/agent/index.ts
|
|
14912
|
-
var agentCommand = new
|
|
14646
|
+
var agentCommand = new Command53().name("agent").description("Manage agent composes").addCommand(cloneCommand4).addCommand(deleteCommand).addCommand(listCommand6).addCommand(statusCommand6);
|
|
14913
14647
|
|
|
14914
14648
|
// src/commands/init/index.ts
|
|
14915
|
-
import { Command as
|
|
14916
|
-
import
|
|
14649
|
+
import { Command as Command54 } from "commander";
|
|
14650
|
+
import chalk49 from "chalk";
|
|
14917
14651
|
import path17 from "path";
|
|
14918
14652
|
import { existsSync as existsSync11 } from "fs";
|
|
14919
14653
|
import { writeFile as writeFile7 } from "fs/promises";
|
|
@@ -14951,7 +14685,7 @@ function checkExistingFiles() {
|
|
|
14951
14685
|
if (existsSync11(AGENTS_MD_FILE)) existingFiles.push(AGENTS_MD_FILE);
|
|
14952
14686
|
return existingFiles;
|
|
14953
14687
|
}
|
|
14954
|
-
var initCommand4 = new
|
|
14688
|
+
var initCommand4 = new Command54().name("init").description("Initialize a new VM0 project in the current directory").option("-f, --force", "Overwrite existing files").option("-n, --name <name>", "Agent name (required in non-interactive mode)").action(
|
|
14955
14689
|
withErrorHandler(async (options) => {
|
|
14956
14690
|
const existingFiles = checkExistingFiles();
|
|
14957
14691
|
if (existingFiles.length > 0 && !options.force) {
|
|
@@ -14980,7 +14714,7 @@ var initCommand4 = new Command59().name("init").description("Initialize a new VM
|
|
|
14980
14714
|
}
|
|
14981
14715
|
);
|
|
14982
14716
|
if (name === void 0) {
|
|
14983
|
-
console.log(
|
|
14717
|
+
console.log(chalk49.dim("Cancelled"));
|
|
14984
14718
|
return;
|
|
14985
14719
|
}
|
|
14986
14720
|
agentName = name;
|
|
@@ -14994,33 +14728,33 @@ var initCommand4 = new Command59().name("init").description("Initialize a new VM
|
|
|
14994
14728
|
}
|
|
14995
14729
|
await writeFile7(VM0_YAML_FILE, generateVm0Yaml(agentName));
|
|
14996
14730
|
const vm0Status = existingFiles.includes(VM0_YAML_FILE) ? " (overwritten)" : "";
|
|
14997
|
-
console.log(
|
|
14731
|
+
console.log(chalk49.green(`\u2713 Created ${VM0_YAML_FILE}${vm0Status}`));
|
|
14998
14732
|
await writeFile7(AGENTS_MD_FILE, generateAgentsMd());
|
|
14999
14733
|
const agentsStatus = existingFiles.includes(AGENTS_MD_FILE) ? " (overwritten)" : "";
|
|
15000
|
-
console.log(
|
|
14734
|
+
console.log(chalk49.green(`\u2713 Created ${AGENTS_MD_FILE}${agentsStatus}`));
|
|
15001
14735
|
console.log();
|
|
15002
14736
|
console.log("Next steps:");
|
|
15003
14737
|
console.log(
|
|
15004
|
-
` 1. Set up model provider (one-time): ${
|
|
14738
|
+
` 1. Set up model provider (one-time): ${chalk49.cyan("vm0 model-provider setup")}`
|
|
15005
14739
|
);
|
|
15006
14740
|
console.log(
|
|
15007
|
-
` 2. Edit ${
|
|
14741
|
+
` 2. Edit ${chalk49.cyan("AGENTS.md")} to customize your agent's workflow`
|
|
15008
14742
|
);
|
|
15009
14743
|
console.log(
|
|
15010
|
-
` Or install Claude plugin: ${
|
|
14744
|
+
` Or install Claude plugin: ${chalk49.cyan(`vm0 setup-claude && claude "/vm0-agent let's build an agent"`)}`
|
|
15011
14745
|
);
|
|
15012
14746
|
console.log(
|
|
15013
|
-
` 3. Run your agent: ${
|
|
14747
|
+
` 3. Run your agent: ${chalk49.cyan(`vm0 cook "let's start working"`)}`
|
|
15014
14748
|
);
|
|
15015
14749
|
})
|
|
15016
14750
|
);
|
|
15017
14751
|
|
|
15018
14752
|
// src/commands/schedule/index.ts
|
|
15019
|
-
import { Command as
|
|
14753
|
+
import { Command as Command61 } from "commander";
|
|
15020
14754
|
|
|
15021
14755
|
// src/commands/schedule/setup.ts
|
|
15022
|
-
import { Command as
|
|
15023
|
-
import
|
|
14756
|
+
import { Command as Command55 } from "commander";
|
|
14757
|
+
import chalk50 from "chalk";
|
|
15024
14758
|
|
|
15025
14759
|
// src/lib/domain/schedule-utils.ts
|
|
15026
14760
|
import { parse as parseYaml5 } from "yaml";
|
|
@@ -15391,6 +15125,29 @@ async function gatherPromptText(optionPrompt, existingPrompt) {
|
|
|
15391
15125
|
existingPrompt || "let's start working."
|
|
15392
15126
|
);
|
|
15393
15127
|
}
|
|
15128
|
+
async function gatherNotificationPreferences(optionNotifyEmail, optionNotifySlack, existingSchedule) {
|
|
15129
|
+
if (optionNotifyEmail !== void 0 && optionNotifySlack !== void 0) {
|
|
15130
|
+
return {
|
|
15131
|
+
notifyEmail: optionNotifyEmail,
|
|
15132
|
+
notifySlack: optionNotifySlack
|
|
15133
|
+
};
|
|
15134
|
+
}
|
|
15135
|
+
if (!isInteractive()) {
|
|
15136
|
+
return {
|
|
15137
|
+
notifyEmail: optionNotifyEmail,
|
|
15138
|
+
notifySlack: optionNotifySlack
|
|
15139
|
+
};
|
|
15140
|
+
}
|
|
15141
|
+
const notifyEmail = optionNotifyEmail ?? await promptConfirm(
|
|
15142
|
+
"Enable email notifications?",
|
|
15143
|
+
existingSchedule?.notifyEmail ?? true
|
|
15144
|
+
);
|
|
15145
|
+
const notifySlack = optionNotifySlack ?? await promptConfirm(
|
|
15146
|
+
"Enable Slack notifications?",
|
|
15147
|
+
existingSchedule?.notifySlack ?? true
|
|
15148
|
+
);
|
|
15149
|
+
return { notifyEmail, notifySlack };
|
|
15150
|
+
}
|
|
15394
15151
|
async function resolveAgent(agentName, scheduleName) {
|
|
15395
15152
|
const compose = await getComposeByName(agentName);
|
|
15396
15153
|
if (!compose) {
|
|
@@ -15487,7 +15244,7 @@ async function buildAndDeploy(params) {
|
|
|
15487
15244
|
}
|
|
15488
15245
|
console.log(
|
|
15489
15246
|
`
|
|
15490
|
-
Deploying schedule for agent ${
|
|
15247
|
+
Deploying schedule for agent ${chalk50.cyan(params.agentName)}...`
|
|
15491
15248
|
);
|
|
15492
15249
|
const deployResult = await deploySchedule({
|
|
15493
15250
|
name: params.scheduleName,
|
|
@@ -15497,69 +15254,75 @@ Deploying schedule for agent ${chalk55.cyan(params.agentName)}...`
|
|
|
15497
15254
|
intervalSeconds: params.intervalSeconds,
|
|
15498
15255
|
timezone: params.timezone,
|
|
15499
15256
|
prompt: params.prompt,
|
|
15500
|
-
artifactName: params.artifactName
|
|
15257
|
+
artifactName: params.artifactName,
|
|
15258
|
+
...params.notifyEmail !== void 0 && {
|
|
15259
|
+
notifyEmail: params.notifyEmail
|
|
15260
|
+
},
|
|
15261
|
+
...params.notifySlack !== void 0 && {
|
|
15262
|
+
notifySlack: params.notifySlack
|
|
15263
|
+
}
|
|
15501
15264
|
});
|
|
15502
15265
|
return deployResult;
|
|
15503
15266
|
}
|
|
15504
15267
|
function displayDeployResult(agentName, deployResult) {
|
|
15505
15268
|
if (deployResult.created) {
|
|
15506
15269
|
console.log(
|
|
15507
|
-
|
|
15270
|
+
chalk50.green(`\u2713 Created schedule for agent ${chalk50.cyan(agentName)}`)
|
|
15508
15271
|
);
|
|
15509
15272
|
} else {
|
|
15510
15273
|
console.log(
|
|
15511
|
-
|
|
15274
|
+
chalk50.green(`\u2713 Updated schedule for agent ${chalk50.cyan(agentName)}`)
|
|
15512
15275
|
);
|
|
15513
15276
|
}
|
|
15514
|
-
console.log(
|
|
15277
|
+
console.log(chalk50.dim(` Timezone: ${deployResult.schedule.timezone}`));
|
|
15515
15278
|
if (deployResult.schedule.triggerType === "loop" && deployResult.schedule.intervalSeconds != null) {
|
|
15516
15279
|
console.log(
|
|
15517
|
-
|
|
15280
|
+
chalk50.dim(
|
|
15518
15281
|
` Mode: Loop (interval ${deployResult.schedule.intervalSeconds}s)`
|
|
15519
15282
|
)
|
|
15520
15283
|
);
|
|
15521
15284
|
} else if (deployResult.schedule.cronExpression) {
|
|
15522
|
-
console.log(
|
|
15285
|
+
console.log(chalk50.dim(` Cron: ${deployResult.schedule.cronExpression}`));
|
|
15523
15286
|
if (deployResult.schedule.nextRunAt) {
|
|
15524
15287
|
const nextRun = formatInTimezone(
|
|
15525
15288
|
deployResult.schedule.nextRunAt,
|
|
15526
15289
|
deployResult.schedule.timezone
|
|
15527
15290
|
);
|
|
15528
|
-
console.log(
|
|
15291
|
+
console.log(chalk50.dim(` Next run: ${nextRun}`));
|
|
15529
15292
|
}
|
|
15530
15293
|
} else if (deployResult.schedule.atTime) {
|
|
15531
15294
|
const atTimeFormatted = formatInTimezone(
|
|
15532
15295
|
deployResult.schedule.atTime,
|
|
15533
15296
|
deployResult.schedule.timezone
|
|
15534
15297
|
);
|
|
15535
|
-
console.log(
|
|
15298
|
+
console.log(chalk50.dim(` At: ${atTimeFormatted}`));
|
|
15536
15299
|
}
|
|
15537
15300
|
}
|
|
15538
15301
|
async function tryEnableSchedule(scheduleName, composeId, agentName) {
|
|
15539
15302
|
try {
|
|
15540
15303
|
await enableSchedule({ name: scheduleName, composeId });
|
|
15541
15304
|
console.log(
|
|
15542
|
-
|
|
15305
|
+
chalk50.green(`\u2713 Enabled schedule for agent ${chalk50.cyan(agentName)}`)
|
|
15543
15306
|
);
|
|
15544
15307
|
} catch (error) {
|
|
15545
|
-
console.error(
|
|
15308
|
+
console.error(chalk50.yellow("\u26A0 Failed to enable schedule"));
|
|
15546
15309
|
if (error instanceof ApiRequestError) {
|
|
15547
15310
|
if (error.code === "SCHEDULE_PAST") {
|
|
15548
|
-
console.error(
|
|
15311
|
+
console.error(chalk50.dim(" Scheduled time has already passed"));
|
|
15549
15312
|
} else {
|
|
15550
|
-
console.error(
|
|
15313
|
+
console.error(chalk50.dim(` ${error.message}`));
|
|
15551
15314
|
}
|
|
15552
15315
|
} else if (error instanceof Error) {
|
|
15553
|
-
console.error(
|
|
15316
|
+
console.error(chalk50.dim(` ${error.message}`));
|
|
15554
15317
|
}
|
|
15555
15318
|
console.log(
|
|
15556
|
-
` To enable manually: ${
|
|
15319
|
+
` To enable manually: ${chalk50.cyan(`vm0 schedule enable ${agentName}`)}`
|
|
15557
15320
|
);
|
|
15558
15321
|
}
|
|
15559
15322
|
}
|
|
15560
15323
|
function showEnableHint(agentName) {
|
|
15561
15324
|
console.log();
|
|
15562
|
-
console.log(` To enable: ${
|
|
15325
|
+
console.log(` To enable: ${chalk50.cyan(`vm0 schedule enable ${agentName}`)}`);
|
|
15563
15326
|
}
|
|
15564
15327
|
async function handleScheduleEnabling(params) {
|
|
15565
15328
|
const { scheduleName, composeId, agentName, enableFlag, shouldPromptEnable } = params;
|
|
@@ -15580,7 +15343,7 @@ async function handleScheduleEnabling(params) {
|
|
|
15580
15343
|
showEnableHint(agentName);
|
|
15581
15344
|
}
|
|
15582
15345
|
}
|
|
15583
|
-
var setupCommand = new
|
|
15346
|
+
var setupCommand = new Command55().name("setup").description("Create or edit a schedule for an 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(
|
|
15584
15347
|
withErrorHandler(async (agentName, options) => {
|
|
15585
15348
|
const { composeId, scheduleName } = await resolveAgent(
|
|
15586
15349
|
agentName,
|
|
@@ -15591,7 +15354,7 @@ var setupCommand = new Command60().name("setup").description("Create or edit a s
|
|
|
15591
15354
|
scheduleName
|
|
15592
15355
|
);
|
|
15593
15356
|
console.log(
|
|
15594
|
-
|
|
15357
|
+
chalk50.dim(
|
|
15595
15358
|
existingSchedule ? `Editing existing schedule for agent ${agentName}` : `Creating new schedule for agent ${agentName}`
|
|
15596
15359
|
)
|
|
15597
15360
|
);
|
|
@@ -15601,12 +15364,12 @@ var setupCommand = new Command60().name("setup").description("Create or edit a s
|
|
|
15601
15364
|
defaults.frequency
|
|
15602
15365
|
);
|
|
15603
15366
|
if (!frequency) {
|
|
15604
|
-
console.log(
|
|
15367
|
+
console.log(chalk50.dim("Cancelled"));
|
|
15605
15368
|
return;
|
|
15606
15369
|
}
|
|
15607
15370
|
const timing = await gatherTiming(frequency, options, defaults);
|
|
15608
15371
|
if (!timing) {
|
|
15609
|
-
console.log(
|
|
15372
|
+
console.log(chalk50.dim("Cancelled"));
|
|
15610
15373
|
return;
|
|
15611
15374
|
}
|
|
15612
15375
|
const { day, time, atTime, intervalSeconds } = timing;
|
|
@@ -15615,7 +15378,7 @@ var setupCommand = new Command60().name("setup").description("Create or edit a s
|
|
|
15615
15378
|
existingSchedule?.timezone
|
|
15616
15379
|
);
|
|
15617
15380
|
if (!timezone) {
|
|
15618
|
-
console.log(
|
|
15381
|
+
console.log(chalk50.dim("Cancelled"));
|
|
15619
15382
|
return;
|
|
15620
15383
|
}
|
|
15621
15384
|
const promptText_ = await gatherPromptText(
|
|
@@ -15623,9 +15386,14 @@ var setupCommand = new Command60().name("setup").description("Create or edit a s
|
|
|
15623
15386
|
existingSchedule?.prompt
|
|
15624
15387
|
);
|
|
15625
15388
|
if (!promptText_) {
|
|
15626
|
-
console.log(
|
|
15389
|
+
console.log(chalk50.dim("Cancelled"));
|
|
15627
15390
|
return;
|
|
15628
15391
|
}
|
|
15392
|
+
const { notifyEmail, notifySlack } = await gatherNotificationPreferences(
|
|
15393
|
+
options.notifyEmail,
|
|
15394
|
+
options.notifySlack,
|
|
15395
|
+
existingSchedule
|
|
15396
|
+
);
|
|
15629
15397
|
const deployResult = await buildAndDeploy({
|
|
15630
15398
|
scheduleName,
|
|
15631
15399
|
composeId,
|
|
@@ -15637,7 +15405,9 @@ var setupCommand = new Command60().name("setup").description("Create or edit a s
|
|
|
15637
15405
|
intervalSeconds,
|
|
15638
15406
|
timezone,
|
|
15639
15407
|
prompt: promptText_,
|
|
15640
|
-
artifactName: options.artifactName
|
|
15408
|
+
artifactName: options.artifactName,
|
|
15409
|
+
notifyEmail,
|
|
15410
|
+
notifySlack
|
|
15641
15411
|
});
|
|
15642
15412
|
displayDeployResult(agentName, deployResult);
|
|
15643
15413
|
const shouldPromptEnable = deployResult.created || existingSchedule !== void 0 && !existingSchedule.enabled;
|
|
@@ -15652,15 +15422,15 @@ var setupCommand = new Command60().name("setup").description("Create or edit a s
|
|
|
15652
15422
|
);
|
|
15653
15423
|
|
|
15654
15424
|
// src/commands/schedule/list.ts
|
|
15655
|
-
import { Command as
|
|
15656
|
-
import
|
|
15657
|
-
var listCommand7 = new
|
|
15425
|
+
import { Command as Command56 } from "commander";
|
|
15426
|
+
import chalk51 from "chalk";
|
|
15427
|
+
var listCommand7 = new Command56().name("list").alias("ls").description("List all schedules").action(
|
|
15658
15428
|
withErrorHandler(async () => {
|
|
15659
15429
|
const result = await listSchedules();
|
|
15660
15430
|
if (result.schedules.length === 0) {
|
|
15661
|
-
console.log(
|
|
15431
|
+
console.log(chalk51.dim("No schedules found"));
|
|
15662
15432
|
console.log(
|
|
15663
|
-
|
|
15433
|
+
chalk51.dim(" Create one with: vm0 schedule setup <agent-name>")
|
|
15664
15434
|
);
|
|
15665
15435
|
return;
|
|
15666
15436
|
}
|
|
@@ -15685,10 +15455,10 @@ var listCommand7 = new Command61().name("list").alias("ls").description("List al
|
|
|
15685
15455
|
"STATUS".padEnd(8),
|
|
15686
15456
|
"NEXT RUN"
|
|
15687
15457
|
].join(" ");
|
|
15688
|
-
console.log(
|
|
15458
|
+
console.log(chalk51.dim(header));
|
|
15689
15459
|
for (const schedule of result.schedules) {
|
|
15690
15460
|
const trigger = schedule.cronExpression ? `${schedule.cronExpression} (${schedule.timezone})` : schedule.atTime || "-";
|
|
15691
|
-
const status = schedule.enabled ?
|
|
15461
|
+
const status = schedule.enabled ? chalk51.green("enabled") : chalk51.yellow("disabled");
|
|
15692
15462
|
const nextRun = schedule.enabled ? formatRelativeTime2(schedule.nextRunAt) : "-";
|
|
15693
15463
|
const row = [
|
|
15694
15464
|
schedule.composeName.padEnd(agentWidth),
|
|
@@ -15704,48 +15474,48 @@ var listCommand7 = new Command61().name("list").alias("ls").description("List al
|
|
|
15704
15474
|
);
|
|
15705
15475
|
|
|
15706
15476
|
// src/commands/schedule/status.ts
|
|
15707
|
-
import { Command as
|
|
15708
|
-
import
|
|
15477
|
+
import { Command as Command57 } from "commander";
|
|
15478
|
+
import chalk52 from "chalk";
|
|
15709
15479
|
function formatDateTimeStyled(dateStr) {
|
|
15710
|
-
if (!dateStr) return
|
|
15480
|
+
if (!dateStr) return chalk52.dim("-");
|
|
15711
15481
|
const formatted = formatDateTime(dateStr);
|
|
15712
|
-
return formatted.replace(/\(([^)]+)\)$/,
|
|
15482
|
+
return formatted.replace(/\(([^)]+)\)$/, chalk52.dim("($1)"));
|
|
15713
15483
|
}
|
|
15714
15484
|
function formatTrigger(schedule) {
|
|
15715
15485
|
if (schedule.triggerType === "loop" && schedule.intervalSeconds !== null) {
|
|
15716
|
-
return `interval ${schedule.intervalSeconds}s ${
|
|
15486
|
+
return `interval ${schedule.intervalSeconds}s ${chalk52.dim("(loop)")}`;
|
|
15717
15487
|
}
|
|
15718
15488
|
if (schedule.cronExpression) {
|
|
15719
15489
|
return schedule.cronExpression;
|
|
15720
15490
|
}
|
|
15721
15491
|
if (schedule.atTime) {
|
|
15722
|
-
return `${schedule.atTime} ${
|
|
15492
|
+
return `${schedule.atTime} ${chalk52.dim("(one-time)")}`;
|
|
15723
15493
|
}
|
|
15724
|
-
return
|
|
15494
|
+
return chalk52.dim("-");
|
|
15725
15495
|
}
|
|
15726
15496
|
function formatRunStatus2(status) {
|
|
15727
15497
|
switch (status) {
|
|
15728
15498
|
case "completed":
|
|
15729
|
-
return
|
|
15499
|
+
return chalk52.green(status);
|
|
15730
15500
|
case "failed":
|
|
15731
15501
|
case "timeout":
|
|
15732
|
-
return
|
|
15502
|
+
return chalk52.red(status);
|
|
15733
15503
|
case "running":
|
|
15734
|
-
return
|
|
15504
|
+
return chalk52.cyan(status);
|
|
15735
15505
|
case "pending":
|
|
15736
|
-
return
|
|
15506
|
+
return chalk52.yellow(status);
|
|
15737
15507
|
default:
|
|
15738
15508
|
return status;
|
|
15739
15509
|
}
|
|
15740
15510
|
}
|
|
15741
15511
|
function printRunConfiguration(schedule) {
|
|
15742
|
-
const statusText = schedule.enabled ?
|
|
15512
|
+
const statusText = schedule.enabled ? chalk52.green("enabled") : chalk52.yellow("disabled");
|
|
15743
15513
|
console.log(`${"Status:".padEnd(16)}${statusText}`);
|
|
15744
15514
|
console.log(
|
|
15745
|
-
`${"Agent:".padEnd(16)}${schedule.composeName} ${
|
|
15515
|
+
`${"Agent:".padEnd(16)}${schedule.composeName} ${chalk52.dim(`(${schedule.orgSlug})`)}`
|
|
15746
15516
|
);
|
|
15747
15517
|
const promptPreview = schedule.prompt.length > 60 ? schedule.prompt.slice(0, 57) + "..." : schedule.prompt;
|
|
15748
|
-
console.log(`${"Prompt:".padEnd(16)}${
|
|
15518
|
+
console.log(`${"Prompt:".padEnd(16)}${chalk52.dim(promptPreview)}`);
|
|
15749
15519
|
if (schedule.vars && Object.keys(schedule.vars).length > 0) {
|
|
15750
15520
|
console.log(
|
|
15751
15521
|
`${"Variables:".padEnd(16)}${Object.keys(schedule.vars).join(", ")}`
|
|
@@ -15774,7 +15544,7 @@ function printTimeSchedule(schedule) {
|
|
|
15774
15544
|
);
|
|
15775
15545
|
}
|
|
15776
15546
|
if (schedule.triggerType === "loop") {
|
|
15777
|
-
const failureText = schedule.consecutiveFailures > 0 ?
|
|
15547
|
+
const failureText = schedule.consecutiveFailures > 0 ? chalk52.yellow(`${schedule.consecutiveFailures}/3`) : chalk52.dim("0/3");
|
|
15778
15548
|
console.log(`${"Failures:".padEnd(16)}${failureText}`);
|
|
15779
15549
|
}
|
|
15780
15550
|
}
|
|
@@ -15790,7 +15560,7 @@ async function printRecentRuns(name, composeId, limit) {
|
|
|
15790
15560
|
console.log();
|
|
15791
15561
|
console.log("Recent Runs:");
|
|
15792
15562
|
console.log(
|
|
15793
|
-
|
|
15563
|
+
chalk52.dim("RUN ID STATUS CREATED")
|
|
15794
15564
|
);
|
|
15795
15565
|
for (const run of runs) {
|
|
15796
15566
|
const id = run.id;
|
|
@@ -15801,10 +15571,10 @@ async function printRecentRuns(name, composeId, limit) {
|
|
|
15801
15571
|
}
|
|
15802
15572
|
} catch {
|
|
15803
15573
|
console.log();
|
|
15804
|
-
console.log(
|
|
15574
|
+
console.log(chalk52.dim("Recent Runs: (unable to fetch)"));
|
|
15805
15575
|
}
|
|
15806
15576
|
}
|
|
15807
|
-
var statusCommand7 = new
|
|
15577
|
+
var statusCommand7 = new Command57().name("status").description("Show detailed status of a schedule").argument("<agent-name>", "Agent name").option(
|
|
15808
15578
|
"-n, --name <schedule-name>",
|
|
15809
15579
|
"Schedule name (required when agent has multiple schedules)"
|
|
15810
15580
|
).option(
|
|
@@ -15818,8 +15588,8 @@ var statusCommand7 = new Command62().name("status").description("Show detailed s
|
|
|
15818
15588
|
const { name, composeId } = resolved;
|
|
15819
15589
|
const schedule = await getScheduleByName({ name, composeId });
|
|
15820
15590
|
console.log();
|
|
15821
|
-
console.log(`Schedule for agent: ${
|
|
15822
|
-
console.log(
|
|
15591
|
+
console.log(`Schedule for agent: ${chalk52.cyan(agentName)}`);
|
|
15592
|
+
console.log(chalk52.dim("\u2501".repeat(50)));
|
|
15823
15593
|
printRunConfiguration(schedule);
|
|
15824
15594
|
printTimeSchedule(schedule);
|
|
15825
15595
|
const parsed = parseInt(options.limit, 10);
|
|
@@ -15834,9 +15604,9 @@ var statusCommand7 = new Command62().name("status").description("Show detailed s
|
|
|
15834
15604
|
);
|
|
15835
15605
|
|
|
15836
15606
|
// src/commands/schedule/delete.ts
|
|
15837
|
-
import { Command as
|
|
15838
|
-
import
|
|
15839
|
-
var deleteCommand2 = new
|
|
15607
|
+
import { Command as Command58 } from "commander";
|
|
15608
|
+
import chalk53 from "chalk";
|
|
15609
|
+
var deleteCommand2 = new Command58().name("delete").alias("rm").description("Delete a schedule").argument("<agent-name>", "Agent name").option(
|
|
15840
15610
|
"-n, --name <schedule-name>",
|
|
15841
15611
|
"Schedule name (required when agent has multiple schedules)"
|
|
15842
15612
|
).option("-y, --yes", "Skip confirmation prompt").action(
|
|
@@ -15848,11 +15618,11 @@ var deleteCommand2 = new Command63().name("delete").alias("rm").description("Del
|
|
|
15848
15618
|
throw new Error("--yes flag is required in non-interactive mode");
|
|
15849
15619
|
}
|
|
15850
15620
|
const confirmed = await promptConfirm(
|
|
15851
|
-
`Delete schedule for agent ${
|
|
15621
|
+
`Delete schedule for agent ${chalk53.cyan(agentName)}?`,
|
|
15852
15622
|
false
|
|
15853
15623
|
);
|
|
15854
15624
|
if (!confirmed) {
|
|
15855
|
-
console.log(
|
|
15625
|
+
console.log(chalk53.dim("Cancelled"));
|
|
15856
15626
|
return;
|
|
15857
15627
|
}
|
|
15858
15628
|
}
|
|
@@ -15861,16 +15631,16 @@ var deleteCommand2 = new Command63().name("delete").alias("rm").description("Del
|
|
|
15861
15631
|
composeId: resolved.composeId
|
|
15862
15632
|
});
|
|
15863
15633
|
console.log(
|
|
15864
|
-
|
|
15634
|
+
chalk53.green(`\u2713 Deleted schedule for agent ${chalk53.cyan(agentName)}`)
|
|
15865
15635
|
);
|
|
15866
15636
|
}
|
|
15867
15637
|
)
|
|
15868
15638
|
);
|
|
15869
15639
|
|
|
15870
15640
|
// src/commands/schedule/enable.ts
|
|
15871
|
-
import { Command as
|
|
15872
|
-
import
|
|
15873
|
-
var enableCommand = new
|
|
15641
|
+
import { Command as Command59 } from "commander";
|
|
15642
|
+
import chalk54 from "chalk";
|
|
15643
|
+
var enableCommand = new Command59().name("enable").description("Enable a schedule").argument("<agent-name>", "Agent name").option(
|
|
15874
15644
|
"-n, --name <schedule-name>",
|
|
15875
15645
|
"Schedule name (required when agent has multiple schedules)"
|
|
15876
15646
|
).action(
|
|
@@ -15881,15 +15651,15 @@ var enableCommand = new Command64().name("enable").description("Enable a schedul
|
|
|
15881
15651
|
composeId: resolved.composeId
|
|
15882
15652
|
});
|
|
15883
15653
|
console.log(
|
|
15884
|
-
|
|
15654
|
+
chalk54.green(`\u2713 Enabled schedule for agent ${chalk54.cyan(agentName)}`)
|
|
15885
15655
|
);
|
|
15886
15656
|
})
|
|
15887
15657
|
);
|
|
15888
15658
|
|
|
15889
15659
|
// src/commands/schedule/disable.ts
|
|
15890
|
-
import { Command as
|
|
15891
|
-
import
|
|
15892
|
-
var disableCommand = new
|
|
15660
|
+
import { Command as Command60 } from "commander";
|
|
15661
|
+
import chalk55 from "chalk";
|
|
15662
|
+
var disableCommand = new Command60().name("disable").description("Disable a schedule").argument("<agent-name>", "Agent name").option(
|
|
15893
15663
|
"-n, --name <schedule-name>",
|
|
15894
15664
|
"Schedule name (required when agent has multiple schedules)"
|
|
15895
15665
|
).action(
|
|
@@ -15900,17 +15670,17 @@ var disableCommand = new Command65().name("disable").description("Disable a sche
|
|
|
15900
15670
|
composeId: resolved.composeId
|
|
15901
15671
|
});
|
|
15902
15672
|
console.log(
|
|
15903
|
-
|
|
15673
|
+
chalk55.green(`\u2713 Disabled schedule for agent ${chalk55.cyan(agentName)}`)
|
|
15904
15674
|
);
|
|
15905
15675
|
})
|
|
15906
15676
|
);
|
|
15907
15677
|
|
|
15908
15678
|
// src/commands/schedule/index.ts
|
|
15909
|
-
var scheduleCommand = new
|
|
15679
|
+
var scheduleCommand = new Command61().name("schedule").description("Manage agent schedules").addCommand(setupCommand).addCommand(listCommand7).addCommand(statusCommand7).addCommand(deleteCommand2).addCommand(enableCommand).addCommand(disableCommand);
|
|
15910
15680
|
|
|
15911
15681
|
// src/commands/usage/index.ts
|
|
15912
|
-
import { Command as
|
|
15913
|
-
import
|
|
15682
|
+
import { Command as Command62 } from "commander";
|
|
15683
|
+
import chalk56 from "chalk";
|
|
15914
15684
|
|
|
15915
15685
|
// src/lib/utils/duration-formatter.ts
|
|
15916
15686
|
function formatDuration(ms) {
|
|
@@ -15983,7 +15753,7 @@ function fillMissingDates(daily, startDate, endDate) {
|
|
|
15983
15753
|
result.sort((a, b) => b.date.localeCompare(a.date));
|
|
15984
15754
|
return result;
|
|
15985
15755
|
}
|
|
15986
|
-
var usageCommand = new
|
|
15756
|
+
var usageCommand = new Command62().name("usage").description("View usage statistics").option("--since <date>", "Start date (ISO format or relative: 7d, 30d)").option(
|
|
15987
15757
|
"--until <date>",
|
|
15988
15758
|
"End date (ISO format or relative, defaults to now)"
|
|
15989
15759
|
).action(
|
|
@@ -16035,19 +15805,19 @@ var usageCommand = new Command67().name("usage").description("View usage statist
|
|
|
16035
15805
|
);
|
|
16036
15806
|
console.log();
|
|
16037
15807
|
console.log(
|
|
16038
|
-
|
|
15808
|
+
chalk56.bold(
|
|
16039
15809
|
`Usage Summary (${formatDateRange(usage.period.start, usage.period.end)})`
|
|
16040
15810
|
)
|
|
16041
15811
|
);
|
|
16042
15812
|
console.log();
|
|
16043
|
-
console.log(
|
|
15813
|
+
console.log(chalk56.dim("DATE RUNS RUN TIME"));
|
|
16044
15814
|
for (const day of filledDaily) {
|
|
16045
15815
|
const dateDisplay = formatDateDisplay(day.date).padEnd(10);
|
|
16046
15816
|
const runsDisplay = String(day.run_count).padStart(6);
|
|
16047
15817
|
const timeDisplay = formatDuration(day.run_time_ms);
|
|
16048
15818
|
console.log(`${dateDisplay}${runsDisplay} ${timeDisplay}`);
|
|
16049
15819
|
}
|
|
16050
|
-
console.log(
|
|
15820
|
+
console.log(chalk56.dim("\u2500".repeat(29)));
|
|
16051
15821
|
const totalRunsDisplay = String(usage.summary.total_runs).padStart(6);
|
|
16052
15822
|
const totalTimeDisplay = formatDuration(usage.summary.total_run_time_ms);
|
|
16053
15823
|
console.log(
|
|
@@ -16058,67 +15828,67 @@ var usageCommand = new Command67().name("usage").description("View usage statist
|
|
|
16058
15828
|
);
|
|
16059
15829
|
|
|
16060
15830
|
// src/commands/secret/index.ts
|
|
16061
|
-
import { Command as
|
|
15831
|
+
import { Command as Command66 } from "commander";
|
|
16062
15832
|
|
|
16063
15833
|
// src/commands/secret/list.ts
|
|
16064
|
-
import { Command as
|
|
16065
|
-
import
|
|
16066
|
-
var listCommand8 = new
|
|
15834
|
+
import { Command as Command63 } from "commander";
|
|
15835
|
+
import chalk57 from "chalk";
|
|
15836
|
+
var listCommand8 = new Command63().name("list").alias("ls").description("List all secrets").action(
|
|
16067
15837
|
withErrorHandler(async () => {
|
|
16068
15838
|
const result = await listSecrets();
|
|
16069
15839
|
if (result.secrets.length === 0) {
|
|
16070
|
-
console.log(
|
|
15840
|
+
console.log(chalk57.dim("No secrets found"));
|
|
16071
15841
|
console.log();
|
|
16072
15842
|
console.log("To add a secret:");
|
|
16073
|
-
console.log(
|
|
15843
|
+
console.log(chalk57.cyan(" vm0 secret set MY_API_KEY --body <value>"));
|
|
16074
15844
|
return;
|
|
16075
15845
|
}
|
|
16076
|
-
console.log(
|
|
15846
|
+
console.log(chalk57.bold("Secrets:"));
|
|
16077
15847
|
console.log();
|
|
16078
15848
|
for (const secret of result.secrets) {
|
|
16079
15849
|
let typeIndicator = "";
|
|
16080
15850
|
let derivedLine = null;
|
|
16081
15851
|
if (secret.type === "model-provider") {
|
|
16082
|
-
typeIndicator =
|
|
15852
|
+
typeIndicator = chalk57.dim(" [model-provider]");
|
|
16083
15853
|
} else if (secret.type === "connector") {
|
|
16084
15854
|
const derived = getConnectorDerivedNames(secret.name);
|
|
16085
15855
|
if (derived) {
|
|
16086
|
-
typeIndicator =
|
|
16087
|
-
derivedLine =
|
|
15856
|
+
typeIndicator = chalk57.dim(` [${derived.connectorLabel} connector]`);
|
|
15857
|
+
derivedLine = chalk57.dim(
|
|
16088
15858
|
`Available as: ${derived.envVarNames.join(", ")}`
|
|
16089
15859
|
);
|
|
16090
15860
|
} else {
|
|
16091
|
-
typeIndicator =
|
|
15861
|
+
typeIndicator = chalk57.dim(" [connector]");
|
|
16092
15862
|
}
|
|
16093
15863
|
} else if (secret.type === "user") {
|
|
16094
15864
|
const derived = getConnectorDerivedNames(secret.name);
|
|
16095
15865
|
if (derived) {
|
|
16096
|
-
typeIndicator =
|
|
16097
|
-
derivedLine =
|
|
15866
|
+
typeIndicator = chalk57.dim(` [${derived.connectorLabel} connector]`);
|
|
15867
|
+
derivedLine = chalk57.dim(
|
|
16098
15868
|
`Available as: ${derived.envVarNames.join(", ")}`
|
|
16099
15869
|
);
|
|
16100
15870
|
}
|
|
16101
15871
|
}
|
|
16102
|
-
console.log(` ${
|
|
15872
|
+
console.log(` ${chalk57.cyan(secret.name)}${typeIndicator}`);
|
|
16103
15873
|
if (derivedLine) {
|
|
16104
15874
|
console.log(` ${derivedLine}`);
|
|
16105
15875
|
}
|
|
16106
15876
|
if (secret.description) {
|
|
16107
|
-
console.log(` ${
|
|
15877
|
+
console.log(` ${chalk57.dim(secret.description)}`);
|
|
16108
15878
|
}
|
|
16109
15879
|
console.log(
|
|
16110
|
-
` ${
|
|
15880
|
+
` ${chalk57.dim(`Updated: ${new Date(secret.updatedAt).toLocaleString()}`)}`
|
|
16111
15881
|
);
|
|
16112
15882
|
console.log();
|
|
16113
15883
|
}
|
|
16114
|
-
console.log(
|
|
15884
|
+
console.log(chalk57.dim(`Total: ${result.secrets.length} secret(s)`));
|
|
16115
15885
|
})
|
|
16116
15886
|
);
|
|
16117
15887
|
|
|
16118
15888
|
// src/commands/secret/set.ts
|
|
16119
|
-
import { Command as
|
|
16120
|
-
import
|
|
16121
|
-
var setCommand2 = new
|
|
15889
|
+
import { Command as Command64 } from "commander";
|
|
15890
|
+
import chalk58 from "chalk";
|
|
15891
|
+
var setCommand2 = new Command64().name("set").description("Create or update a secret").argument("<name>", "Secret name (uppercase, e.g., MY_API_KEY)").option(
|
|
16122
15892
|
"-b, --body <value>",
|
|
16123
15893
|
"Secret value (required in non-interactive mode)"
|
|
16124
15894
|
).option("-d, --description <description>", "Optional description").action(
|
|
@@ -16157,19 +15927,19 @@ var setCommand2 = new Command69().name("set").description("Create or update a se
|
|
|
16157
15927
|
}
|
|
16158
15928
|
throw error;
|
|
16159
15929
|
}
|
|
16160
|
-
console.log(
|
|
15930
|
+
console.log(chalk58.green(`\u2713 Secret "${secret.name}" saved`));
|
|
16161
15931
|
console.log();
|
|
16162
15932
|
console.log("Use in vm0.yaml:");
|
|
16163
|
-
console.log(
|
|
16164
|
-
console.log(
|
|
15933
|
+
console.log(chalk58.cyan(` environment:`));
|
|
15934
|
+
console.log(chalk58.cyan(` ${name}: \${{ secrets.${name} }}`));
|
|
16165
15935
|
}
|
|
16166
15936
|
)
|
|
16167
15937
|
);
|
|
16168
15938
|
|
|
16169
15939
|
// src/commands/secret/delete.ts
|
|
16170
|
-
import { Command as
|
|
16171
|
-
import
|
|
16172
|
-
var deleteCommand3 = new
|
|
15940
|
+
import { Command as Command65 } from "commander";
|
|
15941
|
+
import chalk59 from "chalk";
|
|
15942
|
+
var deleteCommand3 = new Command65().name("delete").description("Delete a secret").argument("<name>", "Secret name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
16173
15943
|
withErrorHandler(async (name, options) => {
|
|
16174
15944
|
try {
|
|
16175
15945
|
await getSecret(name);
|
|
@@ -16188,61 +15958,61 @@ var deleteCommand3 = new Command70().name("delete").description("Delete a secret
|
|
|
16188
15958
|
false
|
|
16189
15959
|
);
|
|
16190
15960
|
if (!confirmed) {
|
|
16191
|
-
console.log(
|
|
15961
|
+
console.log(chalk59.dim("Cancelled"));
|
|
16192
15962
|
return;
|
|
16193
15963
|
}
|
|
16194
15964
|
}
|
|
16195
15965
|
await deleteSecret(name);
|
|
16196
|
-
console.log(
|
|
15966
|
+
console.log(chalk59.green(`\u2713 Secret "${name}" deleted`));
|
|
16197
15967
|
})
|
|
16198
15968
|
);
|
|
16199
15969
|
|
|
16200
15970
|
// src/commands/secret/index.ts
|
|
16201
|
-
var secretCommand = new
|
|
15971
|
+
var secretCommand = new Command66().name("secret").description("Manage stored secrets for agent runs").addCommand(listCommand8).addCommand(setCommand2).addCommand(deleteCommand3);
|
|
16202
15972
|
|
|
16203
15973
|
// src/commands/variable/index.ts
|
|
16204
|
-
import { Command as
|
|
15974
|
+
import { Command as Command70 } from "commander";
|
|
16205
15975
|
|
|
16206
15976
|
// src/commands/variable/list.ts
|
|
16207
|
-
import { Command as
|
|
16208
|
-
import
|
|
15977
|
+
import { Command as Command67 } from "commander";
|
|
15978
|
+
import chalk60 from "chalk";
|
|
16209
15979
|
function truncateValue(value, maxLength = 60) {
|
|
16210
15980
|
if (value.length <= maxLength) {
|
|
16211
15981
|
return value;
|
|
16212
15982
|
}
|
|
16213
15983
|
return value.slice(0, maxLength - 15) + "... [truncated]";
|
|
16214
15984
|
}
|
|
16215
|
-
var listCommand9 = new
|
|
15985
|
+
var listCommand9 = new Command67().name("list").alias("ls").description("List all variables").action(
|
|
16216
15986
|
withErrorHandler(async () => {
|
|
16217
15987
|
const result = await listVariables();
|
|
16218
15988
|
if (result.variables.length === 0) {
|
|
16219
|
-
console.log(
|
|
15989
|
+
console.log(chalk60.dim("No variables found"));
|
|
16220
15990
|
console.log();
|
|
16221
15991
|
console.log("To add a variable:");
|
|
16222
|
-
console.log(
|
|
15992
|
+
console.log(chalk60.cyan(" vm0 variable set MY_VAR <value>"));
|
|
16223
15993
|
return;
|
|
16224
15994
|
}
|
|
16225
|
-
console.log(
|
|
15995
|
+
console.log(chalk60.bold("Variables:"));
|
|
16226
15996
|
console.log();
|
|
16227
15997
|
for (const variable of result.variables) {
|
|
16228
15998
|
const displayValue = truncateValue(variable.value);
|
|
16229
|
-
console.log(` ${
|
|
15999
|
+
console.log(` ${chalk60.cyan(variable.name)} = ${displayValue}`);
|
|
16230
16000
|
if (variable.description) {
|
|
16231
|
-
console.log(` ${
|
|
16001
|
+
console.log(` ${chalk60.dim(variable.description)}`);
|
|
16232
16002
|
}
|
|
16233
16003
|
console.log(
|
|
16234
|
-
` ${
|
|
16004
|
+
` ${chalk60.dim(`Updated: ${new Date(variable.updatedAt).toLocaleString()}`)}`
|
|
16235
16005
|
);
|
|
16236
16006
|
console.log();
|
|
16237
16007
|
}
|
|
16238
|
-
console.log(
|
|
16008
|
+
console.log(chalk60.dim(`Total: ${result.variables.length} variable(s)`));
|
|
16239
16009
|
})
|
|
16240
16010
|
);
|
|
16241
16011
|
|
|
16242
16012
|
// src/commands/variable/set.ts
|
|
16243
|
-
import { Command as
|
|
16244
|
-
import
|
|
16245
|
-
var setCommand3 = new
|
|
16013
|
+
import { Command as Command68 } from "commander";
|
|
16014
|
+
import chalk61 from "chalk";
|
|
16015
|
+
var setCommand3 = new Command68().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(
|
|
16246
16016
|
withErrorHandler(
|
|
16247
16017
|
async (name, value, options) => {
|
|
16248
16018
|
let variable;
|
|
@@ -16262,19 +16032,19 @@ var setCommand3 = new Command73().name("set").description("Create or update a va
|
|
|
16262
16032
|
}
|
|
16263
16033
|
throw error;
|
|
16264
16034
|
}
|
|
16265
|
-
console.log(
|
|
16035
|
+
console.log(chalk61.green(`\u2713 Variable "${variable.name}" saved`));
|
|
16266
16036
|
console.log();
|
|
16267
16037
|
console.log("Use in vm0.yaml:");
|
|
16268
|
-
console.log(
|
|
16269
|
-
console.log(
|
|
16038
|
+
console.log(chalk61.cyan(` environment:`));
|
|
16039
|
+
console.log(chalk61.cyan(` ${name}: \${{ vars.${name} }}`));
|
|
16270
16040
|
}
|
|
16271
16041
|
)
|
|
16272
16042
|
);
|
|
16273
16043
|
|
|
16274
16044
|
// src/commands/variable/delete.ts
|
|
16275
|
-
import { Command as
|
|
16276
|
-
import
|
|
16277
|
-
var deleteCommand4 = new
|
|
16045
|
+
import { Command as Command69 } from "commander";
|
|
16046
|
+
import chalk62 from "chalk";
|
|
16047
|
+
var deleteCommand4 = new Command69().name("delete").description("Delete a variable").argument("<name>", "Variable name to delete").option("-y, --yes", "Skip confirmation prompt").action(
|
|
16278
16048
|
withErrorHandler(async (name, options) => {
|
|
16279
16049
|
try {
|
|
16280
16050
|
await getVariable(name);
|
|
@@ -16293,32 +16063,32 @@ var deleteCommand4 = new Command74().name("delete").description("Delete a variab
|
|
|
16293
16063
|
false
|
|
16294
16064
|
);
|
|
16295
16065
|
if (!confirmed) {
|
|
16296
|
-
console.log(
|
|
16066
|
+
console.log(chalk62.dim("Cancelled"));
|
|
16297
16067
|
return;
|
|
16298
16068
|
}
|
|
16299
16069
|
}
|
|
16300
16070
|
await deleteVariable(name);
|
|
16301
|
-
console.log(
|
|
16071
|
+
console.log(chalk62.green(`\u2713 Variable "${name}" deleted`));
|
|
16302
16072
|
})
|
|
16303
16073
|
);
|
|
16304
16074
|
|
|
16305
16075
|
// src/commands/variable/index.ts
|
|
16306
|
-
var variableCommand = new
|
|
16076
|
+
var variableCommand = new Command70().name("variable").description("Manage stored variables for agent runs").addCommand(listCommand9).addCommand(setCommand3).addCommand(deleteCommand4);
|
|
16307
16077
|
|
|
16308
16078
|
// src/commands/model-provider/index.ts
|
|
16309
|
-
import { Command as
|
|
16079
|
+
import { Command as Command75 } from "commander";
|
|
16310
16080
|
|
|
16311
16081
|
// src/commands/model-provider/list.ts
|
|
16312
|
-
import { Command as
|
|
16313
|
-
import
|
|
16314
|
-
var listCommand10 = new
|
|
16082
|
+
import { Command as Command71 } from "commander";
|
|
16083
|
+
import chalk63 from "chalk";
|
|
16084
|
+
var listCommand10 = new Command71().name("list").alias("ls").description("List all model providers").action(
|
|
16315
16085
|
withErrorHandler(async () => {
|
|
16316
16086
|
const result = await listModelProviders();
|
|
16317
16087
|
if (result.modelProviders.length === 0) {
|
|
16318
|
-
console.log(
|
|
16088
|
+
console.log(chalk63.dim("No model providers configured"));
|
|
16319
16089
|
console.log();
|
|
16320
16090
|
console.log("To add a model provider:");
|
|
16321
|
-
console.log(
|
|
16091
|
+
console.log(chalk63.cyan(" vm0 model-provider setup"));
|
|
16322
16092
|
return;
|
|
16323
16093
|
}
|
|
16324
16094
|
const byFramework = result.modelProviders.reduce(
|
|
@@ -16332,16 +16102,16 @@ var listCommand10 = new Command76().name("list").alias("ls").description("List a
|
|
|
16332
16102
|
},
|
|
16333
16103
|
{}
|
|
16334
16104
|
);
|
|
16335
|
-
console.log(
|
|
16105
|
+
console.log(chalk63.bold("Model Providers:"));
|
|
16336
16106
|
console.log();
|
|
16337
16107
|
for (const [framework, providers] of Object.entries(byFramework)) {
|
|
16338
|
-
console.log(` ${
|
|
16108
|
+
console.log(` ${chalk63.cyan(framework)}:`);
|
|
16339
16109
|
for (const provider of providers) {
|
|
16340
|
-
const defaultTag = provider.isDefault ?
|
|
16341
|
-
const modelTag = provider.selectedModel ?
|
|
16110
|
+
const defaultTag = provider.isDefault ? chalk63.green(" (default)") : "";
|
|
16111
|
+
const modelTag = provider.selectedModel ? chalk63.dim(` [${provider.selectedModel}]`) : "";
|
|
16342
16112
|
console.log(` ${provider.type}${defaultTag}${modelTag}`);
|
|
16343
16113
|
console.log(
|
|
16344
|
-
|
|
16114
|
+
chalk63.dim(
|
|
16345
16115
|
` Updated: ${new Date(provider.updatedAt).toLocaleString()}`
|
|
16346
16116
|
)
|
|
16347
16117
|
);
|
|
@@ -16349,14 +16119,14 @@ var listCommand10 = new Command76().name("list").alias("ls").description("List a
|
|
|
16349
16119
|
console.log();
|
|
16350
16120
|
}
|
|
16351
16121
|
console.log(
|
|
16352
|
-
|
|
16122
|
+
chalk63.dim(`Total: ${result.modelProviders.length} provider(s)`)
|
|
16353
16123
|
);
|
|
16354
16124
|
})
|
|
16355
16125
|
);
|
|
16356
16126
|
|
|
16357
16127
|
// src/commands/model-provider/setup.ts
|
|
16358
|
-
import { Command as
|
|
16359
|
-
import
|
|
16128
|
+
import { Command as Command72 } from "commander";
|
|
16129
|
+
import chalk64 from "chalk";
|
|
16360
16130
|
import prompts2 from "prompts";
|
|
16361
16131
|
function validateProviderType(typeStr) {
|
|
16362
16132
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(typeStr)) {
|
|
@@ -16540,7 +16310,7 @@ async function promptForModelSelection(type2) {
|
|
|
16540
16310
|
if (selected === "__custom__") {
|
|
16541
16311
|
const placeholder = getCustomModelPlaceholder(type2);
|
|
16542
16312
|
if (placeholder) {
|
|
16543
|
-
console.log(
|
|
16313
|
+
console.log(chalk64.dim(`Example: ${placeholder}`));
|
|
16544
16314
|
}
|
|
16545
16315
|
const customResponse = await prompts2(
|
|
16546
16316
|
{
|
|
@@ -16590,7 +16360,7 @@ async function promptForSecrets(type2, authMethod) {
|
|
|
16590
16360
|
const secrets = {};
|
|
16591
16361
|
for (const [name, fieldConfig] of Object.entries(secretsConfig)) {
|
|
16592
16362
|
if (fieldConfig.helpText) {
|
|
16593
|
-
console.log(
|
|
16363
|
+
console.log(chalk64.dim(fieldConfig.helpText));
|
|
16594
16364
|
}
|
|
16595
16365
|
const isSensitive = isSensitiveSecret(name);
|
|
16596
16366
|
const placeholder = "placeholder" in fieldConfig ? fieldConfig.placeholder : "";
|
|
@@ -16642,7 +16412,7 @@ async function handleInteractiveMode() {
|
|
|
16642
16412
|
title = `${title} \u2713`;
|
|
16643
16413
|
}
|
|
16644
16414
|
if (isExperimental) {
|
|
16645
|
-
title = `${title} ${
|
|
16415
|
+
title = `${title} ${chalk64.dim("(experimental)")}`;
|
|
16646
16416
|
}
|
|
16647
16417
|
return {
|
|
16648
16418
|
title,
|
|
@@ -16689,7 +16459,7 @@ async function handleInteractiveMode() {
|
|
|
16689
16459
|
}
|
|
16690
16460
|
const config = MODEL_PROVIDER_TYPES[type2];
|
|
16691
16461
|
console.log();
|
|
16692
|
-
console.log(
|
|
16462
|
+
console.log(chalk64.dim(config.helpText));
|
|
16693
16463
|
console.log();
|
|
16694
16464
|
if (hasAuthMethods(type2)) {
|
|
16695
16465
|
const authMethod = await promptForAuthMethod(type2);
|
|
@@ -16730,13 +16500,13 @@ async function promptSetAsDefault(type2, framework, isDefault) {
|
|
|
16730
16500
|
);
|
|
16731
16501
|
if (response.setDefault) {
|
|
16732
16502
|
await setModelProviderDefault(type2);
|
|
16733
|
-
console.log(
|
|
16503
|
+
console.log(chalk64.green(`\u2713 Default for ${framework} set to "${type2}"`));
|
|
16734
16504
|
}
|
|
16735
16505
|
}
|
|
16736
16506
|
function collectSecrets(value, previous) {
|
|
16737
16507
|
return previous.concat([value]);
|
|
16738
16508
|
}
|
|
16739
|
-
var setupCommand2 = new
|
|
16509
|
+
var setupCommand2 = new Command72().name("setup").description("Configure a model provider").option("-t, --type <type>", "Provider type (for non-interactive mode)").option(
|
|
16740
16510
|
"-s, --secret <value>",
|
|
16741
16511
|
"Secret value (can be used multiple times, supports VALUE or KEY=VALUE format)",
|
|
16742
16512
|
collectSecrets,
|
|
@@ -16774,11 +16544,11 @@ var setupCommand2 = new Command77().name("setup").description("Configure a model
|
|
|
16774
16544
|
const modelNote2 = provider2.selectedModel ? ` with model: ${provider2.selectedModel}` : "";
|
|
16775
16545
|
if (!hasModelSelection(input.type)) {
|
|
16776
16546
|
console.log(
|
|
16777
|
-
|
|
16547
|
+
chalk64.green(`\u2713 Model provider "${input.type}" unchanged`)
|
|
16778
16548
|
);
|
|
16779
16549
|
} else {
|
|
16780
16550
|
console.log(
|
|
16781
|
-
|
|
16551
|
+
chalk64.green(
|
|
16782
16552
|
`\u2713 Model provider "${input.type}" updated${defaultNote2}${modelNote2}`
|
|
16783
16553
|
)
|
|
16784
16554
|
);
|
|
@@ -16803,7 +16573,7 @@ var setupCommand2 = new Command77().name("setup").description("Configure a model
|
|
|
16803
16573
|
const defaultNote = provider.isDefault ? ` (default for ${provider.framework})` : "";
|
|
16804
16574
|
const modelNote = provider.selectedModel ? ` with model: ${provider.selectedModel}` : "";
|
|
16805
16575
|
console.log(
|
|
16806
|
-
|
|
16576
|
+
chalk64.green(
|
|
16807
16577
|
`\u2713 Model provider "${input.type}" ${action}${defaultNote}${modelNote}`
|
|
16808
16578
|
)
|
|
16809
16579
|
);
|
|
@@ -16819,9 +16589,9 @@ var setupCommand2 = new Command77().name("setup").description("Configure a model
|
|
|
16819
16589
|
);
|
|
16820
16590
|
|
|
16821
16591
|
// src/commands/model-provider/delete.ts
|
|
16822
|
-
import { Command as
|
|
16823
|
-
import
|
|
16824
|
-
var deleteCommand5 = new
|
|
16592
|
+
import { Command as Command73 } from "commander";
|
|
16593
|
+
import chalk65 from "chalk";
|
|
16594
|
+
var deleteCommand5 = new Command73().name("delete").description("Delete a model provider").argument("<type>", "Model provider type to delete").action(
|
|
16825
16595
|
withErrorHandler(async (type2) => {
|
|
16826
16596
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
16827
16597
|
const validTypes = Object.keys(MODEL_PROVIDER_TYPES).join(", ");
|
|
@@ -16830,14 +16600,14 @@ var deleteCommand5 = new Command78().name("delete").description("Delete a model
|
|
|
16830
16600
|
});
|
|
16831
16601
|
}
|
|
16832
16602
|
await deleteModelProvider(type2);
|
|
16833
|
-
console.log(
|
|
16603
|
+
console.log(chalk65.green(`\u2713 Model provider "${type2}" deleted`));
|
|
16834
16604
|
})
|
|
16835
16605
|
);
|
|
16836
16606
|
|
|
16837
16607
|
// src/commands/model-provider/set-default.ts
|
|
16838
|
-
import { Command as
|
|
16839
|
-
import
|
|
16840
|
-
var setDefaultCommand = new
|
|
16608
|
+
import { Command as Command74 } from "commander";
|
|
16609
|
+
import chalk66 from "chalk";
|
|
16610
|
+
var setDefaultCommand = new Command74().name("set-default").description("Set a model provider as default for its framework").argument("<type>", "Model provider type to set as default").action(
|
|
16841
16611
|
withErrorHandler(async (type2) => {
|
|
16842
16612
|
if (!Object.keys(MODEL_PROVIDER_TYPES).includes(type2)) {
|
|
16843
16613
|
const validTypes = Object.keys(MODEL_PROVIDER_TYPES).join(", ");
|
|
@@ -16847,7 +16617,7 @@ var setDefaultCommand = new Command79().name("set-default").description("Set a m
|
|
|
16847
16617
|
}
|
|
16848
16618
|
const provider = await setModelProviderDefault(type2);
|
|
16849
16619
|
console.log(
|
|
16850
|
-
|
|
16620
|
+
chalk66.green(
|
|
16851
16621
|
`\u2713 Default for ${provider.framework} set to "${provider.type}"`
|
|
16852
16622
|
)
|
|
16853
16623
|
);
|
|
@@ -16855,14 +16625,14 @@ var setDefaultCommand = new Command79().name("set-default").description("Set a m
|
|
|
16855
16625
|
);
|
|
16856
16626
|
|
|
16857
16627
|
// src/commands/model-provider/index.ts
|
|
16858
|
-
var modelProviderCommand = new
|
|
16628
|
+
var modelProviderCommand = new Command75().name("model-provider").description("Manage model providers for agent runs").addCommand(listCommand10).addCommand(setupCommand2).addCommand(deleteCommand5).addCommand(setDefaultCommand);
|
|
16859
16629
|
|
|
16860
16630
|
// src/commands/connector/index.ts
|
|
16861
|
-
import { Command as
|
|
16631
|
+
import { Command as Command80 } from "commander";
|
|
16862
16632
|
|
|
16863
16633
|
// src/commands/connector/connect.ts
|
|
16864
|
-
import { Command as
|
|
16865
|
-
import
|
|
16634
|
+
import { Command as Command76 } from "commander";
|
|
16635
|
+
import chalk68 from "chalk";
|
|
16866
16636
|
import { initClient as initClient13 } from "@ts-rest/core";
|
|
16867
16637
|
|
|
16868
16638
|
// src/commands/connector/lib/computer/start-services.ts
|
|
@@ -16871,7 +16641,7 @@ import { access as access2, constants } from "fs/promises";
|
|
|
16871
16641
|
import { createServer } from "net";
|
|
16872
16642
|
import { homedir as homedir4 } from "os";
|
|
16873
16643
|
import { join as join12 } from "path";
|
|
16874
|
-
import
|
|
16644
|
+
import chalk67 from "chalk";
|
|
16875
16645
|
|
|
16876
16646
|
// src/commands/connector/lib/computer/ngrok.ts
|
|
16877
16647
|
import ngrok from "@ngrok/ngrok";
|
|
@@ -16945,7 +16715,7 @@ async function checkComputerDependencies() {
|
|
|
16945
16715
|
}
|
|
16946
16716
|
}
|
|
16947
16717
|
async function startComputerServices(credentials) {
|
|
16948
|
-
console.log(
|
|
16718
|
+
console.log(chalk67.cyan("Starting computer connector services..."));
|
|
16949
16719
|
const wsgidavBinary = await findBinary("wsgidav");
|
|
16950
16720
|
if (!wsgidavBinary) {
|
|
16951
16721
|
throw new Error(
|
|
@@ -16972,7 +16742,7 @@ async function startComputerServices(credentials) {
|
|
|
16972
16742
|
);
|
|
16973
16743
|
wsgidav.stdout?.on("data", (data) => process.stdout.write(data));
|
|
16974
16744
|
wsgidav.stderr?.on("data", (data) => process.stderr.write(data));
|
|
16975
|
-
console.log(
|
|
16745
|
+
console.log(chalk67.green("\u2713 WebDAV server started"));
|
|
16976
16746
|
const chrome = spawn2(
|
|
16977
16747
|
chromeBinary,
|
|
16978
16748
|
[
|
|
@@ -16986,7 +16756,7 @@ async function startComputerServices(credentials) {
|
|
|
16986
16756
|
);
|
|
16987
16757
|
chrome.stdout?.on("data", (data) => process.stdout.write(data));
|
|
16988
16758
|
chrome.stderr?.on("data", (data) => process.stderr.write(data));
|
|
16989
|
-
console.log(
|
|
16759
|
+
console.log(chalk67.green("\u2713 Chrome started"));
|
|
16990
16760
|
try {
|
|
16991
16761
|
await startNgrokTunnels(
|
|
16992
16762
|
credentials.ngrokToken,
|
|
@@ -16995,18 +16765,18 @@ async function startComputerServices(credentials) {
|
|
|
16995
16765
|
cdpPort
|
|
16996
16766
|
);
|
|
16997
16767
|
console.log(
|
|
16998
|
-
|
|
16768
|
+
chalk67.green(
|
|
16999
16769
|
`\u2713 ngrok tunnels: webdav.${credentials.domain}, chrome.${credentials.domain}`
|
|
17000
16770
|
)
|
|
17001
16771
|
);
|
|
17002
16772
|
console.log();
|
|
17003
|
-
console.log(
|
|
16773
|
+
console.log(chalk67.green("\u2713 Computer connector active"));
|
|
17004
16774
|
console.log(` WebDAV: ~/Downloads \u2192 webdav.${credentials.domain}`);
|
|
17005
16775
|
console.log(
|
|
17006
16776
|
` Chrome CDP: port ${cdpPort} \u2192 chrome.${credentials.domain}`
|
|
17007
16777
|
);
|
|
17008
16778
|
console.log();
|
|
17009
|
-
console.log(
|
|
16779
|
+
console.log(chalk67.dim("Press ^C twice to disconnect"));
|
|
17010
16780
|
console.log();
|
|
17011
16781
|
let sigintCount = 0;
|
|
17012
16782
|
await new Promise((resolve2) => {
|
|
@@ -17020,7 +16790,7 @@ async function startComputerServices(credentials) {
|
|
|
17020
16790
|
const onSigint = () => {
|
|
17021
16791
|
sigintCount++;
|
|
17022
16792
|
if (sigintCount === 1) {
|
|
17023
|
-
console.log(
|
|
16793
|
+
console.log(chalk67.dim("\nPress ^C again to disconnect and exit..."));
|
|
17024
16794
|
} else {
|
|
17025
16795
|
done();
|
|
17026
16796
|
}
|
|
@@ -17030,11 +16800,11 @@ async function startComputerServices(credentials) {
|
|
|
17030
16800
|
});
|
|
17031
16801
|
} finally {
|
|
17032
16802
|
console.log();
|
|
17033
|
-
console.log(
|
|
16803
|
+
console.log(chalk67.cyan("Stopping services..."));
|
|
17034
16804
|
wsgidav.kill("SIGTERM");
|
|
17035
16805
|
chrome.kill("SIGTERM");
|
|
17036
16806
|
await stopNgrokTunnels();
|
|
17037
|
-
console.log(
|
|
16807
|
+
console.log(chalk67.green("\u2713 Services stopped"));
|
|
17038
16808
|
}
|
|
17039
16809
|
}
|
|
17040
16810
|
|
|
@@ -17059,10 +16829,10 @@ async function getHeaders2() {
|
|
|
17059
16829
|
function renderHelpText(text) {
|
|
17060
16830
|
return text.replace(
|
|
17061
16831
|
/\[([^\]]+)\]\(([^)]+)\)/g,
|
|
17062
|
-
(_m, label, url) => `${label} (${
|
|
17063
|
-
).replace(/\*\*([^*]+)\*\*/g, (_m, content) =>
|
|
16832
|
+
(_m, label, url) => `${label} (${chalk68.cyan(url)})`
|
|
16833
|
+
).replace(/\*\*([^*]+)\*\*/g, (_m, content) => chalk68.bold(content)).replace(
|
|
17064
16834
|
/^> (.+)$/gm,
|
|
17065
|
-
(_m, content) =>
|
|
16835
|
+
(_m, content) => chalk68.yellow(` ${content}`)
|
|
17066
16836
|
);
|
|
17067
16837
|
}
|
|
17068
16838
|
async function connectViaApiToken(connectorType, tokenValue) {
|
|
@@ -17087,7 +16857,7 @@ async function connectViaApiToken(connectorType, tokenValue) {
|
|
|
17087
16857
|
for (const [secretName, secretConfig] of secretEntries) {
|
|
17088
16858
|
if (!secretConfig.required) continue;
|
|
17089
16859
|
const value = await promptPassword(
|
|
17090
|
-
`${secretConfig.label}${secretConfig.placeholder ?
|
|
16860
|
+
`${secretConfig.label}${secretConfig.placeholder ? chalk68.dim(` (${secretConfig.placeholder})`) : ""}:`
|
|
17091
16861
|
);
|
|
17092
16862
|
if (!value) {
|
|
17093
16863
|
throw new Error("Cancelled");
|
|
@@ -17103,13 +16873,13 @@ async function connectViaApiToken(connectorType, tokenValue) {
|
|
|
17103
16873
|
});
|
|
17104
16874
|
}
|
|
17105
16875
|
console.log(
|
|
17106
|
-
|
|
16876
|
+
chalk68.green(`
|
|
17107
16877
|
\u2713 ${config.label} connected successfully via API token!`)
|
|
17108
16878
|
);
|
|
17109
16879
|
}
|
|
17110
16880
|
async function connectComputer(apiUrl, headers) {
|
|
17111
16881
|
await checkComputerDependencies();
|
|
17112
|
-
console.log(
|
|
16882
|
+
console.log(chalk68.cyan("Setting up computer connector..."));
|
|
17113
16883
|
const computerClient = initClient13(computerConnectorContract, {
|
|
17114
16884
|
baseUrl: apiUrl,
|
|
17115
16885
|
baseHeaders: headers,
|
|
@@ -17124,9 +16894,9 @@ async function connectComputer(apiUrl, headers) {
|
|
|
17124
16894
|
}
|
|
17125
16895
|
const credentials = createResult.body;
|
|
17126
16896
|
await startComputerServices(credentials);
|
|
17127
|
-
console.log(
|
|
16897
|
+
console.log(chalk68.cyan("Disconnecting computer connector..."));
|
|
17128
16898
|
await deleteConnector("computer");
|
|
17129
|
-
console.log(
|
|
16899
|
+
console.log(chalk68.green("\u2713 Disconnected computer"));
|
|
17130
16900
|
process.exit(0);
|
|
17131
16901
|
}
|
|
17132
16902
|
async function resolveAuthMethod(connectorType, tokenFlag) {
|
|
@@ -17165,7 +16935,7 @@ async function resolveAuthMethod(connectorType, tokenFlag) {
|
|
|
17165
16935
|
);
|
|
17166
16936
|
}
|
|
17167
16937
|
async function connectViaOAuth(connectorType, apiUrl, headers) {
|
|
17168
|
-
console.log(`Connecting ${
|
|
16938
|
+
console.log(`Connecting ${chalk68.cyan(connectorType)}...`);
|
|
17169
16939
|
const sessionsClient = initClient13(connectorSessionsContract, {
|
|
17170
16940
|
baseUrl: apiUrl,
|
|
17171
16941
|
baseHeaders: headers,
|
|
@@ -17181,8 +16951,8 @@ async function connectViaOAuth(connectorType, apiUrl, headers) {
|
|
|
17181
16951
|
}
|
|
17182
16952
|
const session = createResult.body;
|
|
17183
16953
|
const verificationUrl = `${apiUrl}${session.verificationUrl}`;
|
|
17184
|
-
console.log(
|
|
17185
|
-
console.log(
|
|
16954
|
+
console.log(chalk68.green("\nSession created"));
|
|
16955
|
+
console.log(chalk68.cyan(`
|
|
17186
16956
|
To connect, visit: ${verificationUrl}`));
|
|
17187
16957
|
console.log(
|
|
17188
16958
|
`
|
|
@@ -17214,7 +16984,7 @@ The session expires in ${Math.floor(session.expiresIn / 60)} minutes.`
|
|
|
17214
16984
|
switch (status.status) {
|
|
17215
16985
|
case "complete":
|
|
17216
16986
|
console.log(
|
|
17217
|
-
|
|
16987
|
+
chalk68.green(`
|
|
17218
16988
|
|
|
17219
16989
|
${connectorType} connected successfully!`)
|
|
17220
16990
|
);
|
|
@@ -17226,13 +16996,13 @@ ${connectorType} connected successfully!`)
|
|
|
17226
16996
|
`Connection failed: ${status.errorMessage || "Unknown error"}`
|
|
17227
16997
|
);
|
|
17228
16998
|
case "pending":
|
|
17229
|
-
process.stdout.write(
|
|
16999
|
+
process.stdout.write(chalk68.dim("."));
|
|
17230
17000
|
break;
|
|
17231
17001
|
}
|
|
17232
17002
|
}
|
|
17233
17003
|
throw new Error("Session timed out, please try again");
|
|
17234
17004
|
}
|
|
17235
|
-
var connectCommand = new
|
|
17005
|
+
var connectCommand = new Command76().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(
|
|
17236
17006
|
withErrorHandler(async (type2, options) => {
|
|
17237
17007
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
17238
17008
|
if (!parseResult.success) {
|
|
@@ -17257,9 +17027,9 @@ var connectCommand = new Command81().name("connect").description("Connect a thir
|
|
|
17257
17027
|
);
|
|
17258
17028
|
|
|
17259
17029
|
// src/commands/connector/list.ts
|
|
17260
|
-
import { Command as
|
|
17261
|
-
import
|
|
17262
|
-
var listCommand11 = new
|
|
17030
|
+
import { Command as Command77 } from "commander";
|
|
17031
|
+
import chalk69 from "chalk";
|
|
17032
|
+
var listCommand11 = new Command77().name("list").alias("ls").description("List all connectors and their status").action(
|
|
17263
17033
|
withErrorHandler(async () => {
|
|
17264
17034
|
const result = await listConnectors();
|
|
17265
17035
|
const connectedMap = new Map(result.connectors.map((c24) => [c24.type, c24]));
|
|
@@ -17281,25 +17051,25 @@ var listCommand11 = new Command82().name("list").alias("ls").description("List a
|
|
|
17281
17051
|
statusText.padEnd(statusWidth),
|
|
17282
17052
|
"ACCOUNT"
|
|
17283
17053
|
].join(" ");
|
|
17284
|
-
console.log(
|
|
17054
|
+
console.log(chalk69.dim(header));
|
|
17285
17055
|
for (const type2 of allTypes) {
|
|
17286
17056
|
const connector = connectedMap.get(type2);
|
|
17287
|
-
const status = connector ?
|
|
17288
|
-
const account = connector?.externalUsername ? `@${connector.externalUsername}` :
|
|
17057
|
+
const status = connector ? chalk69.green("\u2713".padEnd(statusWidth)) : chalk69.dim("-".padEnd(statusWidth));
|
|
17058
|
+
const account = connector?.externalUsername ? `@${connector.externalUsername}` : chalk69.dim("-");
|
|
17289
17059
|
const row = [type2.padEnd(typeWidth), status, account].join(" ");
|
|
17290
17060
|
console.log(row);
|
|
17291
17061
|
}
|
|
17292
17062
|
console.log();
|
|
17293
|
-
console.log(
|
|
17294
|
-
console.log(
|
|
17063
|
+
console.log(chalk69.dim("To connect a service:"));
|
|
17064
|
+
console.log(chalk69.dim(" vm0 connector connect <type>"));
|
|
17295
17065
|
})
|
|
17296
17066
|
);
|
|
17297
17067
|
|
|
17298
17068
|
// src/commands/connector/status.ts
|
|
17299
|
-
import { Command as
|
|
17300
|
-
import
|
|
17069
|
+
import { Command as Command78 } from "commander";
|
|
17070
|
+
import chalk70 from "chalk";
|
|
17301
17071
|
var LABEL_WIDTH = 16;
|
|
17302
|
-
var statusCommand8 = new
|
|
17072
|
+
var statusCommand8 = new Command78().name("status").description("Show detailed status of a connector").argument("<type>", "Connector type (e.g., github)").action(
|
|
17303
17073
|
withErrorHandler(async (type2) => {
|
|
17304
17074
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
17305
17075
|
if (!parseResult.success) {
|
|
@@ -17309,11 +17079,11 @@ var statusCommand8 = new Command83().name("status").description("Show detailed s
|
|
|
17309
17079
|
});
|
|
17310
17080
|
}
|
|
17311
17081
|
const connector = await getConnector(parseResult.data);
|
|
17312
|
-
console.log(`Connector: ${
|
|
17082
|
+
console.log(`Connector: ${chalk70.cyan(type2)}`);
|
|
17313
17083
|
console.log();
|
|
17314
17084
|
if (connector) {
|
|
17315
17085
|
console.log(
|
|
17316
|
-
`${"Status:".padEnd(LABEL_WIDTH)}${
|
|
17086
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${chalk70.green("connected")}`
|
|
17317
17087
|
);
|
|
17318
17088
|
console.log(
|
|
17319
17089
|
`${"Account:".padEnd(LABEL_WIDTH)}@${connector.externalUsername}`
|
|
@@ -17335,23 +17105,23 @@ var statusCommand8 = new Command83().name("status").description("Show detailed s
|
|
|
17335
17105
|
);
|
|
17336
17106
|
}
|
|
17337
17107
|
console.log();
|
|
17338
|
-
console.log(
|
|
17339
|
-
console.log(
|
|
17108
|
+
console.log(chalk70.dim("To disconnect:"));
|
|
17109
|
+
console.log(chalk70.dim(` vm0 connector disconnect ${type2}`));
|
|
17340
17110
|
} else {
|
|
17341
17111
|
console.log(
|
|
17342
|
-
`${"Status:".padEnd(LABEL_WIDTH)}${
|
|
17112
|
+
`${"Status:".padEnd(LABEL_WIDTH)}${chalk70.dim("not connected")}`
|
|
17343
17113
|
);
|
|
17344
17114
|
console.log();
|
|
17345
|
-
console.log(
|
|
17346
|
-
console.log(
|
|
17115
|
+
console.log(chalk70.dim("To connect:"));
|
|
17116
|
+
console.log(chalk70.dim(` vm0 connector connect ${type2}`));
|
|
17347
17117
|
}
|
|
17348
17118
|
})
|
|
17349
17119
|
);
|
|
17350
17120
|
|
|
17351
17121
|
// src/commands/connector/disconnect.ts
|
|
17352
|
-
import { Command as
|
|
17353
|
-
import
|
|
17354
|
-
var disconnectCommand = new
|
|
17122
|
+
import { Command as Command79 } from "commander";
|
|
17123
|
+
import chalk71 from "chalk";
|
|
17124
|
+
var disconnectCommand = new Command79().name("disconnect").description("Disconnect a third-party service").argument("<type>", "Connector type to disconnect (e.g., github)").action(
|
|
17355
17125
|
withErrorHandler(async (type2) => {
|
|
17356
17126
|
const parseResult = connectorTypeSchema.safeParse(type2);
|
|
17357
17127
|
if (!parseResult.success) {
|
|
@@ -17362,33 +17132,33 @@ var disconnectCommand = new Command84().name("disconnect").description("Disconne
|
|
|
17362
17132
|
}
|
|
17363
17133
|
const connectorType = parseResult.data;
|
|
17364
17134
|
await deleteConnector(connectorType);
|
|
17365
|
-
console.log(
|
|
17135
|
+
console.log(chalk71.green(`\u2713 Disconnected ${type2}`));
|
|
17366
17136
|
})
|
|
17367
17137
|
);
|
|
17368
17138
|
|
|
17369
17139
|
// src/commands/connector/index.ts
|
|
17370
|
-
var connectorCommand = new
|
|
17140
|
+
var connectorCommand = new Command80().name("connector").description("Manage third-party service connections").addCommand(listCommand11).addCommand(statusCommand8).addCommand(connectCommand).addCommand(disconnectCommand);
|
|
17371
17141
|
|
|
17372
17142
|
// src/commands/onboard/index.ts
|
|
17373
|
-
import { Command as
|
|
17374
|
-
import
|
|
17143
|
+
import { Command as Command81 } from "commander";
|
|
17144
|
+
import chalk75 from "chalk";
|
|
17375
17145
|
import { mkdir as mkdir8 } from "fs/promises";
|
|
17376
17146
|
import { existsSync as existsSync12 } from "fs";
|
|
17377
17147
|
|
|
17378
17148
|
// src/lib/ui/welcome-box.ts
|
|
17379
|
-
import
|
|
17149
|
+
import chalk72 from "chalk";
|
|
17380
17150
|
var gradientColors = [
|
|
17381
|
-
|
|
17151
|
+
chalk72.hex("#FFAB5E"),
|
|
17382
17152
|
// Line 1 - lightest
|
|
17383
|
-
|
|
17153
|
+
chalk72.hex("#FF9642"),
|
|
17384
17154
|
// Line 2
|
|
17385
|
-
|
|
17155
|
+
chalk72.hex("#FF8228"),
|
|
17386
17156
|
// Line 3
|
|
17387
|
-
|
|
17157
|
+
chalk72.hex("#FF6D0A"),
|
|
17388
17158
|
// Line 4
|
|
17389
|
-
|
|
17159
|
+
chalk72.hex("#E85D00"),
|
|
17390
17160
|
// Line 5
|
|
17391
|
-
|
|
17161
|
+
chalk72.hex("#CC4E00")
|
|
17392
17162
|
// Line 6 - darkest
|
|
17393
17163
|
];
|
|
17394
17164
|
var vm0LogoLines = [
|
|
@@ -17410,15 +17180,15 @@ function renderVm0Banner() {
|
|
|
17410
17180
|
function renderOnboardWelcome() {
|
|
17411
17181
|
renderVm0Banner();
|
|
17412
17182
|
console.log(` Build agentic workflows using natural language.`);
|
|
17413
|
-
console.log(` ${
|
|
17183
|
+
console.log(` ${chalk72.dim("Currently in beta, enjoy it free")}`);
|
|
17414
17184
|
console.log(
|
|
17415
|
-
` ${
|
|
17185
|
+
` ${chalk72.dim("Star us on GitHub: https://github.com/vm0-ai/vm0")}`
|
|
17416
17186
|
);
|
|
17417
17187
|
console.log();
|
|
17418
17188
|
}
|
|
17419
17189
|
|
|
17420
17190
|
// src/lib/ui/step-runner.ts
|
|
17421
|
-
import
|
|
17191
|
+
import chalk73 from "chalk";
|
|
17422
17192
|
function createStepRunner(options = true) {
|
|
17423
17193
|
const opts = typeof options === "boolean" ? { interactive: options } : options;
|
|
17424
17194
|
const interactive = opts.interactive ?? true;
|
|
@@ -17433,25 +17203,25 @@ function createStepRunner(options = true) {
|
|
|
17433
17203
|
}
|
|
17434
17204
|
for (const [i, step] of completedSteps.entries()) {
|
|
17435
17205
|
if (step.failed) {
|
|
17436
|
-
console.log(
|
|
17206
|
+
console.log(chalk73.red(`\u2717 ${step.label}`));
|
|
17437
17207
|
} else {
|
|
17438
|
-
console.log(
|
|
17208
|
+
console.log(chalk73.green(`\u25CF ${step.label}`));
|
|
17439
17209
|
}
|
|
17440
17210
|
const isLastStep = i === completedSteps.length - 1;
|
|
17441
17211
|
if (!isLastStep || !isFinal) {
|
|
17442
|
-
console.log(
|
|
17212
|
+
console.log(chalk73.dim("\u2502"));
|
|
17443
17213
|
}
|
|
17444
17214
|
}
|
|
17445
17215
|
}
|
|
17446
17216
|
async function executeStep(label, fn, isFinal) {
|
|
17447
17217
|
let stepFailed = false;
|
|
17448
|
-
console.log(
|
|
17218
|
+
console.log(chalk73.yellow(`\u25CB ${label}`));
|
|
17449
17219
|
const ctx = {
|
|
17450
17220
|
connector() {
|
|
17451
|
-
console.log(
|
|
17221
|
+
console.log(chalk73.dim("\u2502"));
|
|
17452
17222
|
},
|
|
17453
17223
|
detail(message) {
|
|
17454
|
-
console.log(`${
|
|
17224
|
+
console.log(`${chalk73.dim("\u2502")} ${message}`);
|
|
17455
17225
|
},
|
|
17456
17226
|
async prompt(promptFn) {
|
|
17457
17227
|
return await promptFn();
|
|
@@ -17468,12 +17238,12 @@ function createStepRunner(options = true) {
|
|
|
17468
17238
|
redrawCompletedSteps(isFinal);
|
|
17469
17239
|
} else {
|
|
17470
17240
|
if (stepFailed) {
|
|
17471
|
-
console.log(
|
|
17241
|
+
console.log(chalk73.red(`\u2717 ${label}`));
|
|
17472
17242
|
} else {
|
|
17473
|
-
console.log(
|
|
17243
|
+
console.log(chalk73.green(`\u25CF ${label}`));
|
|
17474
17244
|
}
|
|
17475
17245
|
if (!isFinal) {
|
|
17476
|
-
console.log(
|
|
17246
|
+
console.log(chalk73.dim("\u2502"));
|
|
17477
17247
|
}
|
|
17478
17248
|
}
|
|
17479
17249
|
}
|
|
@@ -17633,7 +17403,7 @@ async function setupModelProvider(type2, secret, options) {
|
|
|
17633
17403
|
|
|
17634
17404
|
// src/lib/domain/onboard/claude-setup.ts
|
|
17635
17405
|
import { spawn as spawn3 } from "child_process";
|
|
17636
|
-
import
|
|
17406
|
+
import chalk74 from "chalk";
|
|
17637
17407
|
var MARKETPLACE_NAME = "vm0-skills";
|
|
17638
17408
|
var MARKETPLACE_REPO = "vm0-ai/vm0-skills";
|
|
17639
17409
|
var PLUGIN_ID = "vm0@vm0-skills";
|
|
@@ -17670,12 +17440,12 @@ async function runClaudeCommand(args, cwd) {
|
|
|
17670
17440
|
}
|
|
17671
17441
|
function handlePluginError(error, context) {
|
|
17672
17442
|
const displayContext = context ?? "Claude plugin";
|
|
17673
|
-
console.error(
|
|
17443
|
+
console.error(chalk74.red(`\u2717 Failed to install ${displayContext}`));
|
|
17674
17444
|
if (error instanceof Error) {
|
|
17675
|
-
console.error(
|
|
17445
|
+
console.error(chalk74.red(`\u2717 ${error.message}`));
|
|
17676
17446
|
}
|
|
17677
17447
|
console.error(
|
|
17678
|
-
|
|
17448
|
+
chalk74.dim("Please ensure Claude CLI is installed and accessible.")
|
|
17679
17449
|
);
|
|
17680
17450
|
process.exit(1);
|
|
17681
17451
|
}
|
|
@@ -17718,7 +17488,7 @@ async function updateMarketplace() {
|
|
|
17718
17488
|
]);
|
|
17719
17489
|
if (!result.success) {
|
|
17720
17490
|
console.warn(
|
|
17721
|
-
|
|
17491
|
+
chalk74.yellow(
|
|
17722
17492
|
`Warning: Could not update marketplace: ${result.error ?? "unknown error"}`
|
|
17723
17493
|
)
|
|
17724
17494
|
);
|
|
@@ -17764,9 +17534,9 @@ async function handleAuthentication(ctx) {
|
|
|
17764
17534
|
onInitiating: () => {
|
|
17765
17535
|
},
|
|
17766
17536
|
onDeviceCodeReady: (url, code, expiresIn) => {
|
|
17767
|
-
step.detail(`Copy code: ${
|
|
17768
|
-
step.detail(`Open: ${
|
|
17769
|
-
step.detail(
|
|
17537
|
+
step.detail(`Copy code: ${chalk75.cyan.bold(code)}`);
|
|
17538
|
+
step.detail(`Open: ${chalk75.cyan(url)}`);
|
|
17539
|
+
step.detail(chalk75.dim(`Expires in ${expiresIn} minutes`));
|
|
17770
17540
|
},
|
|
17771
17541
|
onPolling: () => {
|
|
17772
17542
|
},
|
|
@@ -17806,14 +17576,14 @@ async function handleModelProvider(ctx) {
|
|
|
17806
17576
|
const selectedChoice = choices.find((c24) => c24.type === providerType);
|
|
17807
17577
|
if (selectedChoice?.helpText) {
|
|
17808
17578
|
for (const line of selectedChoice.helpText.split("\n")) {
|
|
17809
|
-
step.detail(
|
|
17579
|
+
step.detail(chalk75.dim(line));
|
|
17810
17580
|
}
|
|
17811
17581
|
}
|
|
17812
17582
|
const secret = await step.prompt(
|
|
17813
17583
|
() => promptPassword(`Enter your ${selectedChoice?.secretLabel ?? "secret"}:`)
|
|
17814
17584
|
);
|
|
17815
17585
|
if (!secret) {
|
|
17816
|
-
console.log(
|
|
17586
|
+
console.log(chalk75.dim("Cancelled"));
|
|
17817
17587
|
process.exit(0);
|
|
17818
17588
|
}
|
|
17819
17589
|
let selectedModel;
|
|
@@ -17832,7 +17602,7 @@ async function handleModelProvider(ctx) {
|
|
|
17832
17602
|
() => promptSelect("Select model:", modelChoices)
|
|
17833
17603
|
);
|
|
17834
17604
|
if (modelSelection === void 0) {
|
|
17835
|
-
console.log(
|
|
17605
|
+
console.log(chalk75.dim("Cancelled"));
|
|
17836
17606
|
process.exit(0);
|
|
17837
17607
|
}
|
|
17838
17608
|
selectedModel = modelSelection === "" ? void 0 : modelSelection;
|
|
@@ -17842,7 +17612,7 @@ async function handleModelProvider(ctx) {
|
|
|
17842
17612
|
});
|
|
17843
17613
|
const modelNote = result.provider.selectedModel ? ` with model: ${result.provider.selectedModel}` : "";
|
|
17844
17614
|
step.detail(
|
|
17845
|
-
|
|
17615
|
+
chalk75.green(
|
|
17846
17616
|
`${providerType} ${result.created ? "created" : "updated"}${result.isDefault ? ` (default for ${result.framework})` : ""}${modelNote}`
|
|
17847
17617
|
)
|
|
17848
17618
|
);
|
|
@@ -17873,7 +17643,7 @@ async function handleAgentCreation(ctx) {
|
|
|
17873
17643
|
agentName = inputName;
|
|
17874
17644
|
if (existsSync12(agentName)) {
|
|
17875
17645
|
step.detail(
|
|
17876
|
-
|
|
17646
|
+
chalk75.yellow(`${agentName}/ already exists, choose another name`)
|
|
17877
17647
|
);
|
|
17878
17648
|
} else {
|
|
17879
17649
|
folderExists = false;
|
|
@@ -17894,7 +17664,7 @@ async function handleAgentCreation(ctx) {
|
|
|
17894
17664
|
}
|
|
17895
17665
|
}
|
|
17896
17666
|
await mkdir8(agentName, { recursive: true });
|
|
17897
|
-
step.detail(
|
|
17667
|
+
step.detail(chalk75.green(`Created ${agentName}/`));
|
|
17898
17668
|
});
|
|
17899
17669
|
return agentName;
|
|
17900
17670
|
}
|
|
@@ -17910,7 +17680,7 @@ async function handlePluginInstallation(ctx, agentName) {
|
|
|
17910
17680
|
shouldInstall = confirmed ?? true;
|
|
17911
17681
|
}
|
|
17912
17682
|
if (!shouldInstall) {
|
|
17913
|
-
step.detail(
|
|
17683
|
+
step.detail(chalk75.dim("Skipped"));
|
|
17914
17684
|
return;
|
|
17915
17685
|
}
|
|
17916
17686
|
const scope = "project";
|
|
@@ -17918,7 +17688,7 @@ async function handlePluginInstallation(ctx, agentName) {
|
|
|
17918
17688
|
const agentDir = `${process.cwd()}/${agentName}`;
|
|
17919
17689
|
const result = await installVm0Plugin(scope, agentDir);
|
|
17920
17690
|
step.detail(
|
|
17921
|
-
|
|
17691
|
+
chalk75.green(`Installed ${result.pluginId} (scope: ${result.scope})`)
|
|
17922
17692
|
);
|
|
17923
17693
|
pluginInstalled = true;
|
|
17924
17694
|
} catch (error) {
|
|
@@ -17929,18 +17699,18 @@ async function handlePluginInstallation(ctx, agentName) {
|
|
|
17929
17699
|
}
|
|
17930
17700
|
function printNextSteps(agentName, pluginInstalled) {
|
|
17931
17701
|
console.log();
|
|
17932
|
-
console.log(
|
|
17702
|
+
console.log(chalk75.bold("Next step:"));
|
|
17933
17703
|
console.log();
|
|
17934
17704
|
if (pluginInstalled) {
|
|
17935
17705
|
console.log(
|
|
17936
|
-
` ${
|
|
17706
|
+
` ${chalk75.cyan(`cd ${agentName} && claude "/${PRIMARY_SKILL_NAME} let's build an agent"`)}`
|
|
17937
17707
|
);
|
|
17938
17708
|
} else {
|
|
17939
|
-
console.log(` ${
|
|
17709
|
+
console.log(` ${chalk75.cyan(`cd ${agentName} && vm0 init`)}`);
|
|
17940
17710
|
}
|
|
17941
17711
|
console.log();
|
|
17942
17712
|
}
|
|
17943
|
-
var onboardCommand = new
|
|
17713
|
+
var onboardCommand = new Command81().name("onboard").description("Guided setup for new VM0 users").option("-y, --yes", "Skip confirmation prompts").option("--name <name>", `Agent name (default: ${DEFAULT_AGENT_NAME})`).action(
|
|
17944
17714
|
withErrorHandler(async (options) => {
|
|
17945
17715
|
const interactive = isInteractive();
|
|
17946
17716
|
if (interactive) {
|
|
@@ -17965,21 +17735,21 @@ var onboardCommand = new Command86().name("onboard").description("Guided setup f
|
|
|
17965
17735
|
);
|
|
17966
17736
|
|
|
17967
17737
|
// src/commands/setup-claude/index.ts
|
|
17968
|
-
import { Command as
|
|
17969
|
-
import
|
|
17970
|
-
var setupClaudeCommand = new
|
|
17738
|
+
import { Command as Command82 } from "commander";
|
|
17739
|
+
import chalk76 from "chalk";
|
|
17740
|
+
var setupClaudeCommand = new Command82().name("setup-claude").description("Install VM0 Claude Plugin").option("--agent-dir <dir>", "Agent directory to run install in").option("--scope <scope>", "Installation scope (user or project)", "project").action(
|
|
17971
17741
|
withErrorHandler(async (options) => {
|
|
17972
|
-
console.log(
|
|
17742
|
+
console.log(chalk76.dim("Installing VM0 Claude Plugin..."));
|
|
17973
17743
|
const scope = options.scope === "user" ? "user" : "project";
|
|
17974
17744
|
const result = await installVm0Plugin(scope, options.agentDir);
|
|
17975
17745
|
console.log(
|
|
17976
|
-
|
|
17746
|
+
chalk76.green(`\u2713 Installed ${result.pluginId} (scope: ${result.scope})`)
|
|
17977
17747
|
);
|
|
17978
17748
|
console.log();
|
|
17979
17749
|
console.log("Next step:");
|
|
17980
17750
|
const cdPrefix = options.agentDir ? `cd ${options.agentDir} && ` : "";
|
|
17981
17751
|
console.log(
|
|
17982
|
-
|
|
17752
|
+
chalk76.cyan(
|
|
17983
17753
|
` ${cdPrefix}claude "/${PRIMARY_SKILL_NAME} let's build a workflow"`
|
|
17984
17754
|
)
|
|
17985
17755
|
);
|
|
@@ -17987,36 +17757,36 @@ var setupClaudeCommand = new Command87().name("setup-claude").description("Insta
|
|
|
17987
17757
|
);
|
|
17988
17758
|
|
|
17989
17759
|
// src/commands/dashboard/index.ts
|
|
17990
|
-
import { Command as
|
|
17991
|
-
import
|
|
17992
|
-
var dashboardCommand = new
|
|
17760
|
+
import { Command as Command83 } from "commander";
|
|
17761
|
+
import chalk77 from "chalk";
|
|
17762
|
+
var dashboardCommand = new Command83().name("dashboard").description("Quick reference for common query commands").action(() => {
|
|
17993
17763
|
console.log();
|
|
17994
|
-
console.log(
|
|
17764
|
+
console.log(chalk77.bold("VM0 Dashboard"));
|
|
17995
17765
|
console.log();
|
|
17996
|
-
console.log(
|
|
17997
|
-
console.log(
|
|
17766
|
+
console.log(chalk77.bold("Agents"));
|
|
17767
|
+
console.log(chalk77.dim(" List agents: ") + "vm0 agent list");
|
|
17998
17768
|
console.log();
|
|
17999
|
-
console.log(
|
|
18000
|
-
console.log(
|
|
18001
|
-
console.log(
|
|
17769
|
+
console.log(chalk77.bold("Runs"));
|
|
17770
|
+
console.log(chalk77.dim(" Recent runs: ") + "vm0 run list");
|
|
17771
|
+
console.log(chalk77.dim(" View run logs: ") + "vm0 logs <run-id>");
|
|
18002
17772
|
console.log();
|
|
18003
|
-
console.log(
|
|
18004
|
-
console.log(
|
|
17773
|
+
console.log(chalk77.bold("Schedules"));
|
|
17774
|
+
console.log(chalk77.dim(" List schedules: ") + "vm0 schedule list");
|
|
18005
17775
|
console.log();
|
|
18006
|
-
console.log(
|
|
18007
|
-
console.log(
|
|
18008
|
-
console.log(
|
|
18009
|
-
console.log(
|
|
17776
|
+
console.log(chalk77.bold("Account"));
|
|
17777
|
+
console.log(chalk77.dim(" Usage stats: ") + "vm0 usage");
|
|
17778
|
+
console.log(chalk77.dim(" List secrets: ") + "vm0 secret list");
|
|
17779
|
+
console.log(chalk77.dim(" List variables: ") + "vm0 variable list");
|
|
18010
17780
|
console.log();
|
|
18011
17781
|
console.log(
|
|
18012
|
-
|
|
17782
|
+
chalk77.dim("Not logged in? Run: ") + chalk77.cyan("vm0 auth login")
|
|
18013
17783
|
);
|
|
18014
17784
|
console.log();
|
|
18015
17785
|
});
|
|
18016
17786
|
|
|
18017
17787
|
// src/commands/preference/index.ts
|
|
18018
|
-
import { Command as
|
|
18019
|
-
import
|
|
17788
|
+
import { Command as Command84 } from "commander";
|
|
17789
|
+
import chalk78 from "chalk";
|
|
18020
17790
|
function detectTimezone2() {
|
|
18021
17791
|
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
18022
17792
|
}
|
|
@@ -18037,15 +17807,15 @@ function parseOnOff(flag, value) {
|
|
|
18037
17807
|
);
|
|
18038
17808
|
}
|
|
18039
17809
|
function displayPreferences(prefs) {
|
|
18040
|
-
console.log(
|
|
17810
|
+
console.log(chalk78.bold("Current preferences:"));
|
|
18041
17811
|
console.log(
|
|
18042
|
-
` Timezone: ${prefs.timezone ?
|
|
17812
|
+
` Timezone: ${prefs.timezone ? chalk78.cyan(prefs.timezone) : chalk78.dim("not set")}`
|
|
18043
17813
|
);
|
|
18044
17814
|
console.log(
|
|
18045
|
-
` Email notify: ${prefs.notifyEmail ?
|
|
17815
|
+
` Email notify: ${prefs.notifyEmail ? chalk78.green("on") : chalk78.dim("off")}`
|
|
18046
17816
|
);
|
|
18047
17817
|
console.log(
|
|
18048
|
-
` Slack notify: ${prefs.notifySlack ?
|
|
17818
|
+
` Slack notify: ${prefs.notifySlack ? chalk78.green("on") : chalk78.dim("off")}`
|
|
18049
17819
|
);
|
|
18050
17820
|
}
|
|
18051
17821
|
function buildUpdates(opts) {
|
|
@@ -18075,21 +17845,21 @@ function buildUpdates(opts) {
|
|
|
18075
17845
|
function printUpdateResult(updates, result) {
|
|
18076
17846
|
if (updates.timezone !== void 0) {
|
|
18077
17847
|
console.log(
|
|
18078
|
-
|
|
18079
|
-
`Timezone set to ${
|
|
17848
|
+
chalk78.green(
|
|
17849
|
+
`Timezone set to ${chalk78.cyan(result.timezone ?? updates.timezone)}`
|
|
18080
17850
|
)
|
|
18081
17851
|
);
|
|
18082
17852
|
}
|
|
18083
17853
|
if (updates.notifyEmail !== void 0) {
|
|
18084
17854
|
console.log(
|
|
18085
|
-
|
|
17855
|
+
chalk78.green(
|
|
18086
17856
|
`Email notifications ${result.notifyEmail ? "enabled" : "disabled"}`
|
|
18087
17857
|
)
|
|
18088
17858
|
);
|
|
18089
17859
|
}
|
|
18090
17860
|
if (updates.notifySlack !== void 0) {
|
|
18091
17861
|
console.log(
|
|
18092
|
-
|
|
17862
|
+
chalk78.green(
|
|
18093
17863
|
`Slack notifications ${result.notifySlack ? "enabled" : "disabled"}`
|
|
18094
17864
|
)
|
|
18095
17865
|
);
|
|
@@ -18098,7 +17868,7 @@ function printUpdateResult(updates, result) {
|
|
|
18098
17868
|
async function interactiveSetup(prefs) {
|
|
18099
17869
|
if (!prefs.timezone) {
|
|
18100
17870
|
const detectedTz = detectTimezone2();
|
|
18101
|
-
console.log(
|
|
17871
|
+
console.log(chalk78.dim(`
|
|
18102
17872
|
System timezone detected: ${detectedTz}`));
|
|
18103
17873
|
const tz = await promptText(
|
|
18104
17874
|
"Set timezone? (enter timezone or leave empty to skip)",
|
|
@@ -18109,7 +17879,7 @@ System timezone detected: ${detectedTz}`));
|
|
|
18109
17879
|
throw new Error(`Invalid timezone: ${tz.trim()}`);
|
|
18110
17880
|
}
|
|
18111
17881
|
await updateUserPreferences({ timezone: tz.trim() });
|
|
18112
|
-
console.log(
|
|
17882
|
+
console.log(chalk78.green(`Timezone set to ${chalk78.cyan(tz.trim())}`));
|
|
18113
17883
|
}
|
|
18114
17884
|
}
|
|
18115
17885
|
if (!prefs.notifyEmail) {
|
|
@@ -18119,11 +17889,11 @@ System timezone detected: ${detectedTz}`));
|
|
|
18119
17889
|
);
|
|
18120
17890
|
if (enable) {
|
|
18121
17891
|
await updateUserPreferences({ notifyEmail: true });
|
|
18122
|
-
console.log(
|
|
17892
|
+
console.log(chalk78.green("Email notifications enabled"));
|
|
18123
17893
|
}
|
|
18124
17894
|
}
|
|
18125
17895
|
}
|
|
18126
|
-
var preferenceCommand = new
|
|
17896
|
+
var preferenceCommand = new Command84().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(
|
|
18127
17897
|
withErrorHandler(async (opts) => {
|
|
18128
17898
|
const updates = buildUpdates(opts);
|
|
18129
17899
|
if (updates) {
|
|
@@ -18138,32 +17908,32 @@ var preferenceCommand = new Command89().name("preference").description("View or
|
|
|
18138
17908
|
} else if (!prefs.timezone) {
|
|
18139
17909
|
console.log();
|
|
18140
17910
|
console.log(
|
|
18141
|
-
`To set timezone: ${
|
|
17911
|
+
`To set timezone: ${chalk78.cyan("vm0 preference --timezone <timezone>")}`
|
|
18142
17912
|
);
|
|
18143
17913
|
console.log(
|
|
18144
|
-
|
|
17914
|
+
chalk78.dim("Example: vm0 preference --timezone America/New_York")
|
|
18145
17915
|
);
|
|
18146
17916
|
}
|
|
18147
17917
|
})
|
|
18148
17918
|
);
|
|
18149
17919
|
|
|
18150
17920
|
// src/commands/upgrade/index.ts
|
|
18151
|
-
import { Command as
|
|
18152
|
-
import
|
|
18153
|
-
var upgradeCommand = new
|
|
17921
|
+
import { Command as Command85 } from "commander";
|
|
17922
|
+
import chalk79 from "chalk";
|
|
17923
|
+
var upgradeCommand = new Command85().name("upgrade").description("Upgrade vm0 CLI to the latest version").action(
|
|
18154
17924
|
withErrorHandler(async () => {
|
|
18155
17925
|
console.log("Checking for updates...");
|
|
18156
17926
|
const latestVersion = await getLatestVersion();
|
|
18157
17927
|
if (latestVersion === null) {
|
|
18158
17928
|
throw new Error("Could not check for updates. Please try again later.");
|
|
18159
17929
|
}
|
|
18160
|
-
if (latestVersion === "9.
|
|
18161
|
-
console.log(
|
|
17930
|
+
if (latestVersion === "9.60.0") {
|
|
17931
|
+
console.log(chalk79.green(`\u2713 Already up to date (${"9.60.0"})`));
|
|
18162
17932
|
return;
|
|
18163
17933
|
}
|
|
18164
17934
|
console.log(
|
|
18165
|
-
|
|
18166
|
-
`Current version: ${"9.
|
|
17935
|
+
chalk79.yellow(
|
|
17936
|
+
`Current version: ${"9.60.0"} -> Latest version: ${latestVersion}`
|
|
18167
17937
|
)
|
|
18168
17938
|
);
|
|
18169
17939
|
console.log();
|
|
@@ -18171,26 +17941,26 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
|
|
|
18171
17941
|
if (!isAutoUpgradeSupported(packageManager)) {
|
|
18172
17942
|
if (packageManager === "unknown") {
|
|
18173
17943
|
console.log(
|
|
18174
|
-
|
|
17944
|
+
chalk79.yellow(
|
|
18175
17945
|
"Could not detect your package manager for auto-upgrade."
|
|
18176
17946
|
)
|
|
18177
17947
|
);
|
|
18178
17948
|
} else {
|
|
18179
17949
|
console.log(
|
|
18180
|
-
|
|
17950
|
+
chalk79.yellow(
|
|
18181
17951
|
`Auto-upgrade is not supported for ${packageManager}.`
|
|
18182
17952
|
)
|
|
18183
17953
|
);
|
|
18184
17954
|
}
|
|
18185
|
-
console.log(
|
|
18186
|
-
console.log(
|
|
17955
|
+
console.log(chalk79.yellow("Please upgrade manually:"));
|
|
17956
|
+
console.log(chalk79.cyan(` ${getManualUpgradeCommand(packageManager)}`));
|
|
18187
17957
|
return;
|
|
18188
17958
|
}
|
|
18189
17959
|
console.log(`Upgrading via ${packageManager}...`);
|
|
18190
17960
|
const success = await performUpgrade(packageManager);
|
|
18191
17961
|
if (success) {
|
|
18192
17962
|
console.log(
|
|
18193
|
-
|
|
17963
|
+
chalk79.green(`\u2713 Upgraded from ${"9.60.0"} to ${latestVersion}`)
|
|
18194
17964
|
);
|
|
18195
17965
|
return;
|
|
18196
17966
|
}
|
|
@@ -18203,8 +17973,8 @@ var upgradeCommand = new Command90().name("upgrade").description("Upgrade vm0 CL
|
|
|
18203
17973
|
);
|
|
18204
17974
|
|
|
18205
17975
|
// src/index.ts
|
|
18206
|
-
var program = new
|
|
18207
|
-
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.
|
|
17976
|
+
var program = new Command86();
|
|
17977
|
+
program.name("vm0").description("VM0 CLI - Build and run agents with natural language").version("9.60.0");
|
|
18208
17978
|
program.addCommand(authCommand);
|
|
18209
17979
|
program.addCommand(infoCommand);
|
|
18210
17980
|
program.addCommand(composeCommand);
|