@autohq/cli 0.1.609 → 0.1.611

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -15474,6 +15474,8 @@ var init_auth = __esm({
15474
15474
  "tools:write",
15475
15475
  "environments:read",
15476
15476
  "environments:write",
15477
+ "runtimes:read",
15478
+ "runtimes:write",
15477
15479
  "profiles:read",
15478
15480
  "profiles:write",
15479
15481
  "sessions:read",
@@ -15592,6 +15594,7 @@ var init_auth = __esm({
15592
15594
  });
15593
15595
  SERVICE_ACCOUNT_READ_ONLY_SCOPES = [
15594
15596
  "environments:read",
15597
+ "runtimes:read",
15595
15598
  "tools:read",
15596
15599
  "agents:read",
15597
15600
  "sessions:read",
@@ -18943,6 +18946,289 @@ var init_secrets = __esm({
18943
18946
  }
18944
18947
  });
18945
18948
 
18949
+ // ../../packages/schemas/src/environments.ts
18950
+ function environmentSetupSchema(cachePathSchema) {
18951
+ return external_exports.object({
18952
+ name: ResourceNameSchema,
18953
+ commands: external_exports.array(external_exports.string().trim().min(1)).min(1),
18954
+ cache: external_exports.object({
18955
+ key: ResourceNameSchema.optional(),
18956
+ files: external_exports.array(
18957
+ external_exports.string().trim().refine(isSafeRelativePath, {
18958
+ message: "Expected a relative path without traversal"
18959
+ })
18960
+ ).default([]),
18961
+ paths: external_exports.array(cachePathSchema).default([])
18962
+ }).strict().default({ files: [], paths: [] })
18963
+ }).strict();
18964
+ }
18965
+ function environmentSpecSchema({
18966
+ imageSchema,
18967
+ setupSchema
18968
+ }) {
18969
+ return external_exports.object({
18970
+ image: imageSchema,
18971
+ env: SecretEnvSchema.default({}),
18972
+ resources: EnvironmentResourcesSchema.optional(),
18973
+ steps: external_exports.array(external_exports.string()).default([]),
18974
+ setup: external_exports.array(setupSchema).default([]),
18975
+ setupCache: EnvironmentSetupCacheSchema.optional(),
18976
+ // Optional rather than defaulted: a default would materialize the key
18977
+ // into stored specs and session environment snapshots the moment the web
18978
+ // app deploys, and this strict schema on a not-yet-deployed worker would
18979
+ // reject those rows (web and workers do not deploy atomically). Absent
18980
+ // means `bypass`; consumers default at the read boundary.
18981
+ approvals: EnvironmentApprovalsSchema.optional()
18982
+ }).strict();
18983
+ }
18984
+ function isSafeSandboxUserHomePath(value, options = {}) {
18985
+ return (options.allowedHomes ?? [CURRENT_SANDBOX_USER_HOME]).some(
18986
+ (home) => isSafePathUnderHome(value, home)
18987
+ );
18988
+ }
18989
+ function isSafePathUnderHome(value, home) {
18990
+ const prefix = `${home}/`;
18991
+ if (!value.startsWith(prefix)) {
18992
+ return false;
18993
+ }
18994
+ const relative2 = value.slice(prefix.length);
18995
+ return relative2.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
18996
+ }
18997
+ function isSafeRelativePath(value) {
18998
+ if (!value || value.startsWith("/")) {
18999
+ return false;
19000
+ }
19001
+ return value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
19002
+ }
19003
+ function isSafeBaseImageRef(value) {
19004
+ return !value.startsWith("-") && /^[^\s#\\]+$/.test(value);
19005
+ }
19006
+ function isSetupCacheTtl(value) {
19007
+ return /^[1-9][0-9]*(s|m|h|d)$/.test(value);
19008
+ }
19009
+ var RESOURCE_KIND_ENVIRONMENT, CURRENT_SANDBOX_USER_HOME, LEGACY_SANDBOX_USER_HOMES, STORED_SANDBOX_USER_HOMES, EnvironmentSetupCachePathSchema, StoredEnvironmentSetupCachePathSchema, EnvironmentImageSchema, StoredEnvironmentImageSchema, ENVIRONMENT_APPROVALS_MODES, EnvironmentApprovalsSchema, EnvironmentSetupSchema, EnvironmentApplySetupSchema, EnvironmentSetupCacheSchema, EnvironmentResourcesSchema, EnvironmentSpecSchema, EnvironmentApplySpecSchema, EnvironmentCandidateSpecSchema, EnvironmentResourceSchema, EnvironmentApplyRequestSchema;
19010
+ var init_environments = __esm({
19011
+ "../../packages/schemas/src/environments.ts"() {
19012
+ "use strict";
19013
+ init_zod();
19014
+ init_resources();
19015
+ init_secrets();
19016
+ RESOURCE_KIND_ENVIRONMENT = "environment";
19017
+ CURRENT_SANDBOX_USER_HOME = "/home/user";
19018
+ LEGACY_SANDBOX_USER_HOMES = ["/home/auto", "/home/node"];
19019
+ STORED_SANDBOX_USER_HOMES = [
19020
+ CURRENT_SANDBOX_USER_HOME,
19021
+ ...LEGACY_SANDBOX_USER_HOMES
19022
+ ];
19023
+ EnvironmentSetupCachePathSchema = external_exports.string().trim().refine((value) => isSafeSandboxUserHomePath(value), {
19024
+ message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
19025
+ });
19026
+ StoredEnvironmentSetupCachePathSchema = external_exports.string().trim().refine(
19027
+ (value) => isSafeSandboxUserHomePath(value, {
19028
+ allowedHomes: STORED_SANDBOX_USER_HOMES
19029
+ }),
19030
+ {
19031
+ message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
19032
+ }
19033
+ );
19034
+ EnvironmentImageSchema = external_exports.discriminatedUnion("kind", [
19035
+ external_exports.object({
19036
+ kind: external_exports.literal("preset"),
19037
+ name: ResourceNameSchema
19038
+ }).strict(),
19039
+ external_exports.object({
19040
+ kind: external_exports.literal("base"),
19041
+ ref: external_exports.string().trim().min(1).max(512).refine(isSafeBaseImageRef, {
19042
+ message: "Expected a single Docker/OCI image reference"
19043
+ })
19044
+ }).strict()
19045
+ ]);
19046
+ StoredEnvironmentImageSchema = external_exports.discriminatedUnion("kind", [
19047
+ external_exports.object({
19048
+ kind: external_exports.literal("preset"),
19049
+ name: external_exports.string().trim().min(1)
19050
+ }).strict(),
19051
+ external_exports.object({
19052
+ kind: external_exports.literal("base"),
19053
+ ref: external_exports.string().trim().min(1).refine(isSafeBaseImageRef, {
19054
+ message: "Expected a single Docker/OCI image reference"
19055
+ })
19056
+ }).strict()
19057
+ ]);
19058
+ ENVIRONMENT_APPROVALS_MODES = ["bypass", "prompt"];
19059
+ EnvironmentApprovalsSchema = external_exports.enum(ENVIRONMENT_APPROVALS_MODES);
19060
+ EnvironmentSetupSchema = environmentSetupSchema(
19061
+ StoredEnvironmentSetupCachePathSchema
19062
+ );
19063
+ EnvironmentApplySetupSchema = environmentSetupSchema(
19064
+ EnvironmentSetupCachePathSchema
19065
+ );
19066
+ EnvironmentSetupCacheSchema = external_exports.object({
19067
+ ttl: external_exports.string().trim().refine(isSetupCacheTtl, {
19068
+ message: "Expected a positive setup cache TTL such as 30m, 24h, or 7d"
19069
+ })
19070
+ }).strict();
19071
+ EnvironmentResourcesSchema = external_exports.object({
19072
+ cpuCount: external_exports.number().int().min(1).optional(),
19073
+ memoryMB: external_exports.number().int().min(128).optional()
19074
+ }).strict().refine(
19075
+ (resources) => resources.cpuCount !== void 0 || resources.memoryMB !== void 0,
19076
+ {
19077
+ message: "Expected at least one runtime resource setting"
19078
+ }
19079
+ );
19080
+ EnvironmentSpecSchema = environmentSpecSchema({
19081
+ imageSchema: StoredEnvironmentImageSchema,
19082
+ setupSchema: EnvironmentSetupSchema
19083
+ });
19084
+ EnvironmentApplySpecSchema = environmentSpecSchema({
19085
+ imageSchema: EnvironmentImageSchema,
19086
+ setupSchema: EnvironmentApplySetupSchema
19087
+ });
19088
+ EnvironmentCandidateSpecSchema = EnvironmentApplySpecSchema;
19089
+ EnvironmentResourceSchema = resourceEnvelopeSchema(
19090
+ EnvironmentSpecSchema
19091
+ );
19092
+ EnvironmentApplyRequestSchema = resourceApplySchema(
19093
+ EnvironmentApplySpecSchema
19094
+ );
19095
+ }
19096
+ });
19097
+
19098
+ // ../../packages/schemas/src/hosted-runtimes.ts
19099
+ var HOSTED_RUNTIME_STATUSES, HOSTED_RUNTIME_OUTCOMES, HOSTED_RUNTIME_COMMAND_STATUSES, HOSTED_RUNTIME_CLOSE_REASONS, HOSTED_RUNTIME_MAX_COMMAND_BUDGET_SECONDS, HostedRuntimeEnvironmentInputSchema, HostedRuntimeEnvironmentSourceSchema, HostedRuntimeEnvironmentSnapshotSchema, HostedRuntimeCommandInputSchema, HostedRuntimeIdempotencyKeySchema, CreateHostedRuntimeRequestSchema, HostedRuntimeStatusSchema, HostedRuntimeOutcomeSchema, HostedRuntimeCommandStatusSchema, HostedRuntimeCloseReasonSchema, HostedRuntimeCommandRecordSchema, HostedRuntimeRecordSchema, HostedRuntimeDispatchStatusSchema, HostedRuntimeReceiptSchema, HostedRuntimeWorkflowInputSchema;
19100
+ var init_hosted_runtimes = __esm({
19101
+ "../../packages/schemas/src/hosted-runtimes.ts"() {
19102
+ "use strict";
19103
+ init_zod();
19104
+ init_environments();
19105
+ init_ids();
19106
+ init_resources();
19107
+ HOSTED_RUNTIME_STATUSES = [
19108
+ "queued",
19109
+ "provisioning",
19110
+ "running",
19111
+ "closing",
19112
+ "closed"
19113
+ ];
19114
+ HOSTED_RUNTIME_OUTCOMES = [
19115
+ "succeeded",
19116
+ "failed",
19117
+ "cancelled"
19118
+ ];
19119
+ HOSTED_RUNTIME_COMMAND_STATUSES = [
19120
+ "pending",
19121
+ "running",
19122
+ "succeeded",
19123
+ "failed",
19124
+ "cancelled"
19125
+ ];
19126
+ HOSTED_RUNTIME_CLOSE_REASONS = [
19127
+ "completed",
19128
+ "command_failed",
19129
+ "provision_failed",
19130
+ "requested",
19131
+ "internal_error"
19132
+ ];
19133
+ HOSTED_RUNTIME_MAX_COMMAND_BUDGET_SECONDS = 45 * 60;
19134
+ HostedRuntimeEnvironmentInputSchema = external_exports.discriminatedUnion(
19135
+ "kind",
19136
+ [
19137
+ external_exports.object({
19138
+ kind: external_exports.literal("inline"),
19139
+ spec: EnvironmentCandidateSpecSchema
19140
+ }).strict(),
19141
+ external_exports.object({
19142
+ kind: external_exports.literal("applied"),
19143
+ name: ResourceNameSchema
19144
+ }).strict()
19145
+ ]
19146
+ );
19147
+ HostedRuntimeEnvironmentSourceSchema = external_exports.discriminatedUnion(
19148
+ "kind",
19149
+ [
19150
+ external_exports.object({ kind: external_exports.literal("inline") }).strict(),
19151
+ external_exports.object({
19152
+ kind: external_exports.literal("applied"),
19153
+ name: ResourceNameSchema,
19154
+ resourceId: external_exports.string().trim().min(1),
19155
+ generation: external_exports.number().int().positive()
19156
+ }).strict()
19157
+ ]
19158
+ );
19159
+ HostedRuntimeEnvironmentSnapshotSchema = external_exports.object({
19160
+ source: HostedRuntimeEnvironmentSourceSchema,
19161
+ spec: EnvironmentSpecSchema
19162
+ }).strict();
19163
+ HostedRuntimeCommandInputSchema = external_exports.object({
19164
+ command: external_exports.string().trim().min(1).max(4096),
19165
+ timeoutSeconds: external_exports.number().int().min(1).max(300).default(60)
19166
+ }).strict();
19167
+ HostedRuntimeIdempotencyKeySchema = external_exports.string().trim().min(1).max(200);
19168
+ CreateHostedRuntimeRequestSchema = external_exports.object({
19169
+ environment: HostedRuntimeEnvironmentInputSchema,
19170
+ commands: external_exports.array(HostedRuntimeCommandInputSchema).min(1).max(20)
19171
+ }).strict().superRefine((request, context) => {
19172
+ const totalTimeoutSeconds = request.commands.reduce(
19173
+ (total, command) => total + command.timeoutSeconds,
19174
+ 0
19175
+ );
19176
+ if (totalTimeoutSeconds > HOSTED_RUNTIME_MAX_COMMAND_BUDGET_SECONDS) {
19177
+ context.addIssue({
19178
+ code: "custom",
19179
+ message: `Total command timeout must not exceed ${HOSTED_RUNTIME_MAX_COMMAND_BUDGET_SECONDS} seconds`,
19180
+ path: ["commands"]
19181
+ });
19182
+ }
19183
+ });
19184
+ HostedRuntimeStatusSchema = external_exports.enum(HOSTED_RUNTIME_STATUSES);
19185
+ HostedRuntimeOutcomeSchema = external_exports.enum(HOSTED_RUNTIME_OUTCOMES);
19186
+ HostedRuntimeCommandStatusSchema = external_exports.enum(
19187
+ HOSTED_RUNTIME_COMMAND_STATUSES
19188
+ );
19189
+ HostedRuntimeCloseReasonSchema = external_exports.enum(
19190
+ HOSTED_RUNTIME_CLOSE_REASONS
19191
+ );
19192
+ HostedRuntimeCommandRecordSchema = external_exports.object({
19193
+ ordinal: external_exports.number().int().positive(),
19194
+ command: external_exports.string(),
19195
+ timeoutSeconds: external_exports.number().int().positive(),
19196
+ status: HostedRuntimeCommandStatusSchema,
19197
+ startedAt: external_exports.string().datetime().nullable(),
19198
+ finishedAt: external_exports.string().datetime().nullable(),
19199
+ durationMs: external_exports.number().int().nonnegative().nullable(),
19200
+ exitCode: external_exports.number().int().nullable(),
19201
+ stdout: external_exports.string().nullable(),
19202
+ stderr: external_exports.string().nullable(),
19203
+ error: external_exports.string().nullable()
19204
+ }).strict();
19205
+ HostedRuntimeRecordSchema = external_exports.object({
19206
+ id: RuntimeIdSchema,
19207
+ status: HostedRuntimeStatusSchema,
19208
+ outcome: HostedRuntimeOutcomeSchema.nullable(),
19209
+ environment: HostedRuntimeEnvironmentSourceSchema,
19210
+ commands: external_exports.array(HostedRuntimeCommandRecordSchema),
19211
+ error: external_exports.string().nullable(),
19212
+ closeReason: HostedRuntimeCloseReasonSchema.nullable(),
19213
+ closeRequestedAt: external_exports.string().datetime().nullable(),
19214
+ startedAt: external_exports.string().datetime().nullable(),
19215
+ finishedAt: external_exports.string().datetime().nullable(),
19216
+ createdAt: external_exports.string().datetime(),
19217
+ updatedAt: external_exports.string().datetime()
19218
+ }).strict();
19219
+ HostedRuntimeDispatchStatusSchema = external_exports.enum([
19220
+ "started",
19221
+ "deferred"
19222
+ ]);
19223
+ HostedRuntimeReceiptSchema = external_exports.object({
19224
+ runtime: HostedRuntimeRecordSchema,
19225
+ workflowId: external_exports.string().trim().min(1),
19226
+ dispatchStatus: HostedRuntimeDispatchStatusSchema
19227
+ }).strict();
19228
+ HostedRuntimeWorkflowInputSchema = external_exports.object({ runtimeId: RuntimeIdSchema }).strip();
19229
+ }
19230
+ });
19231
+
18946
19232
  // ../../packages/schemas/src/session-bindings.ts
18947
19233
  var BINDING_TARGET_TYPES, TRIGGER_BINDING_TARGET_TYPES, OWNER_RELEASABLE_HELD_BINDING_TARGET_TYPES, OBSERVED_TARGET_EVENT_KEYS, SESSION_BINDING_SOURCES, SESSION_BINDING_STATUSES, SESSION_BINDING_RELEASE_POLICIES, SESSION_BINDING_CONTINUITIES, SESSION_BINDING_RELEASED_BY, BINDING_TRANSITION_CAUSES, BindingTargetTypeSchema, TriggerBindingTargetTypeSchema, OwnerReleasableHeldBindingTargetTypeSchema, SessionBindingSourceSchema, SessionBindingStatusSchema, SessionBindingReleasePolicySchema, SessionBindingContinuitySchema, SessionBindingReleasedBySchema, BindingTransitionCauseSchema, BindingTargetSchema, BINDING_AUTO_BIND_VALUES, BindingAutoBindSchema, AUTO_BIND_LEGAL_TARGETS;
18948
19234
  var init_session_bindings = __esm({
@@ -20883,154 +21169,6 @@ var init_identities = __esm({
20883
21169
  }
20884
21170
  });
20885
21171
 
20886
- // ../../packages/schemas/src/environments.ts
20887
- function environmentSetupSchema(cachePathSchema) {
20888
- return external_exports.object({
20889
- name: ResourceNameSchema,
20890
- commands: external_exports.array(external_exports.string().trim().min(1)).min(1),
20891
- cache: external_exports.object({
20892
- key: ResourceNameSchema.optional(),
20893
- files: external_exports.array(
20894
- external_exports.string().trim().refine(isSafeRelativePath, {
20895
- message: "Expected a relative path without traversal"
20896
- })
20897
- ).default([]),
20898
- paths: external_exports.array(cachePathSchema).default([])
20899
- }).strict().default({ files: [], paths: [] })
20900
- }).strict();
20901
- }
20902
- function environmentSpecSchema({
20903
- imageSchema,
20904
- setupSchema
20905
- }) {
20906
- return external_exports.object({
20907
- image: imageSchema,
20908
- env: SecretEnvSchema.default({}),
20909
- resources: EnvironmentResourcesSchema.optional(),
20910
- steps: external_exports.array(external_exports.string()).default([]),
20911
- setup: external_exports.array(setupSchema).default([]),
20912
- setupCache: EnvironmentSetupCacheSchema.optional(),
20913
- // Optional rather than defaulted: a default would materialize the key
20914
- // into stored specs and session environment snapshots the moment the web
20915
- // app deploys, and this strict schema on a not-yet-deployed worker would
20916
- // reject those rows (web and workers do not deploy atomically). Absent
20917
- // means `bypass`; consumers default at the read boundary.
20918
- approvals: EnvironmentApprovalsSchema.optional()
20919
- }).strict();
20920
- }
20921
- function isSafeSandboxUserHomePath(value, options = {}) {
20922
- return (options.allowedHomes ?? [CURRENT_SANDBOX_USER_HOME]).some(
20923
- (home) => isSafePathUnderHome(value, home)
20924
- );
20925
- }
20926
- function isSafePathUnderHome(value, home) {
20927
- const prefix = `${home}/`;
20928
- if (!value.startsWith(prefix)) {
20929
- return false;
20930
- }
20931
- const relative2 = value.slice(prefix.length);
20932
- return relative2.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
20933
- }
20934
- function isSafeRelativePath(value) {
20935
- if (!value || value.startsWith("/")) {
20936
- return false;
20937
- }
20938
- return value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
20939
- }
20940
- function isSafeBaseImageRef(value) {
20941
- return !value.startsWith("-") && /^[^\s#\\]+$/.test(value);
20942
- }
20943
- function isSetupCacheTtl(value) {
20944
- return /^[1-9][0-9]*(s|m|h|d)$/.test(value);
20945
- }
20946
- var RESOURCE_KIND_ENVIRONMENT, CURRENT_SANDBOX_USER_HOME, LEGACY_SANDBOX_USER_HOMES, STORED_SANDBOX_USER_HOMES, EnvironmentSetupCachePathSchema, StoredEnvironmentSetupCachePathSchema, EnvironmentImageSchema, StoredEnvironmentImageSchema, ENVIRONMENT_APPROVALS_MODES, EnvironmentApprovalsSchema, EnvironmentSetupSchema, EnvironmentApplySetupSchema, EnvironmentSetupCacheSchema, EnvironmentResourcesSchema, EnvironmentSpecSchema, EnvironmentApplySpecSchema, EnvironmentResourceSchema, EnvironmentApplyRequestSchema;
20947
- var init_environments = __esm({
20948
- "../../packages/schemas/src/environments.ts"() {
20949
- "use strict";
20950
- init_zod();
20951
- init_resources();
20952
- init_secrets();
20953
- RESOURCE_KIND_ENVIRONMENT = "environment";
20954
- CURRENT_SANDBOX_USER_HOME = "/home/user";
20955
- LEGACY_SANDBOX_USER_HOMES = ["/home/auto", "/home/node"];
20956
- STORED_SANDBOX_USER_HOMES = [
20957
- CURRENT_SANDBOX_USER_HOME,
20958
- ...LEGACY_SANDBOX_USER_HOMES
20959
- ];
20960
- EnvironmentSetupCachePathSchema = external_exports.string().trim().refine((value) => isSafeSandboxUserHomePath(value), {
20961
- message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
20962
- });
20963
- StoredEnvironmentSetupCachePathSchema = external_exports.string().trim().refine(
20964
- (value) => isSafeSandboxUserHomePath(value, {
20965
- allowedHomes: STORED_SANDBOX_USER_HOMES
20966
- }),
20967
- {
20968
- message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
20969
- }
20970
- );
20971
- EnvironmentImageSchema = external_exports.discriminatedUnion("kind", [
20972
- external_exports.object({
20973
- kind: external_exports.literal("preset"),
20974
- name: ResourceNameSchema
20975
- }).strict(),
20976
- external_exports.object({
20977
- kind: external_exports.literal("base"),
20978
- ref: external_exports.string().trim().min(1).max(512).refine(isSafeBaseImageRef, {
20979
- message: "Expected a single Docker/OCI image reference"
20980
- })
20981
- }).strict()
20982
- ]);
20983
- StoredEnvironmentImageSchema = external_exports.discriminatedUnion("kind", [
20984
- external_exports.object({
20985
- kind: external_exports.literal("preset"),
20986
- name: external_exports.string().trim().min(1)
20987
- }).strict(),
20988
- external_exports.object({
20989
- kind: external_exports.literal("base"),
20990
- ref: external_exports.string().trim().min(1).refine(isSafeBaseImageRef, {
20991
- message: "Expected a single Docker/OCI image reference"
20992
- })
20993
- }).strict()
20994
- ]);
20995
- ENVIRONMENT_APPROVALS_MODES = ["bypass", "prompt"];
20996
- EnvironmentApprovalsSchema = external_exports.enum(ENVIRONMENT_APPROVALS_MODES);
20997
- EnvironmentSetupSchema = environmentSetupSchema(
20998
- StoredEnvironmentSetupCachePathSchema
20999
- );
21000
- EnvironmentApplySetupSchema = environmentSetupSchema(
21001
- EnvironmentSetupCachePathSchema
21002
- );
21003
- EnvironmentSetupCacheSchema = external_exports.object({
21004
- ttl: external_exports.string().trim().refine(isSetupCacheTtl, {
21005
- message: "Expected a positive setup cache TTL such as 30m, 24h, or 7d"
21006
- })
21007
- }).strict();
21008
- EnvironmentResourcesSchema = external_exports.object({
21009
- cpuCount: external_exports.number().int().min(1).optional(),
21010
- memoryMB: external_exports.number().int().min(128).optional()
21011
- }).strict().refine(
21012
- (resources) => resources.cpuCount !== void 0 || resources.memoryMB !== void 0,
21013
- {
21014
- message: "Expected at least one runtime resource setting"
21015
- }
21016
- );
21017
- EnvironmentSpecSchema = environmentSpecSchema({
21018
- imageSchema: StoredEnvironmentImageSchema,
21019
- setupSchema: EnvironmentSetupSchema
21020
- });
21021
- EnvironmentApplySpecSchema = environmentSpecSchema({
21022
- imageSchema: EnvironmentImageSchema,
21023
- setupSchema: EnvironmentApplySetupSchema
21024
- });
21025
- EnvironmentResourceSchema = resourceEnvelopeSchema(
21026
- EnvironmentSpecSchema
21027
- );
21028
- EnvironmentApplyRequestSchema = resourceApplySchema(
21029
- EnvironmentApplySpecSchema
21030
- );
21031
- }
21032
- });
21033
-
21034
21172
  // ../../packages/schemas/src/environment-setup-failures.ts
21035
21173
  var EnvironmentSetupStepFailureDiagnosticSchema, PersistedEnvironmentSetupStepFailureDiagnosticSchema;
21036
21174
  var init_environment_setup_failures = __esm({
@@ -90213,6 +90351,7 @@ var init_src = __esm({
90213
90351
  init_github_sync();
90214
90352
  init_github_credentials();
90215
90353
  init_github_mcp_catalog();
90354
+ init_hosted_runtimes();
90216
90355
  init_identities();
90217
90356
  init_ids();
90218
90357
  init_environments();
@@ -93030,7 +93169,7 @@ var init_package = __esm({
93030
93169
  "package.json"() {
93031
93170
  package_default = {
93032
93171
  name: "@autohq/cli",
93033
- version: "0.1.609",
93172
+ version: "0.1.611",
93034
93173
  license: "SEE LICENSE IN README.md",
93035
93174
  publishConfig: {
93036
93175
  access: "public"
@@ -106463,9 +106602,170 @@ import { readUIMessageStream } from "ai";
106463
106602
 
106464
106603
  // src/commands/agent-bridge/harness/envelope-bounds.ts
106465
106604
  import { Buffer as Buffer2 } from "buffer";
106605
+
106606
+ // src/commands/agent-bridge/harness/mcp-result-canonicalization.ts
106607
+ function canonicalizeEnvelopeMcpResults(envelope) {
106608
+ switch (envelope.type) {
106609
+ case "conversation.entry": {
106610
+ const content = canonicalizeMcpResultValue(envelope.content);
106611
+ return toCanonicalizedEnvelope(
106612
+ envelope,
106613
+ { ...envelope, content: content.value },
106614
+ content.deduplicatedBranches
106615
+ );
106616
+ }
106617
+ case "conversation.delta": {
106618
+ const delta = canonicalizeMcpResultValue(envelope.delta);
106619
+ return toCanonicalizedEnvelope(
106620
+ envelope,
106621
+ { ...envelope, delta: delta.value },
106622
+ delta.deduplicatedBranches
106623
+ );
106624
+ }
106625
+ case "ui.message.chunk": {
106626
+ const chunk = canonicalizeMcpResultValue(envelope.chunk);
106627
+ return toCanonicalizedEnvelope(
106628
+ envelope,
106629
+ { ...envelope, chunk: chunk.value },
106630
+ chunk.deduplicatedBranches
106631
+ );
106632
+ }
106633
+ case "ui.message.part": {
106634
+ const part = canonicalizeMcpResultValue(envelope.part);
106635
+ const metadata = canonicalizeMcpResultValue(envelope.messageMetadata);
106636
+ const deduplicatedBranches = part.deduplicatedBranches + metadata.deduplicatedBranches;
106637
+ return toCanonicalizedEnvelope(
106638
+ envelope,
106639
+ {
106640
+ ...envelope,
106641
+ part: part.value,
106642
+ ...envelope.messageMetadata === void 0 ? {} : { messageMetadata: metadata.value }
106643
+ },
106644
+ deduplicatedBranches
106645
+ );
106646
+ }
106647
+ case "ui.message.completed": {
106648
+ const message = canonicalizeMcpResultValue(envelope.message);
106649
+ return toCanonicalizedEnvelope(
106650
+ envelope,
106651
+ { ...envelope, message: message.value },
106652
+ message.deduplicatedBranches
106653
+ );
106654
+ }
106655
+ case "runtime.liveness":
106656
+ case "runtime.usage_turn":
106657
+ return { value: envelope, deduplicatedBranches: 0 };
106658
+ }
106659
+ }
106660
+ function toCanonicalizedEnvelope(original, candidate, deduplicatedBranches) {
106661
+ return {
106662
+ value: deduplicatedBranches > 0 ? RuntimeBridgeOutputEnvelopeSchema.parse(candidate) : original,
106663
+ deduplicatedBranches
106664
+ };
106665
+ }
106666
+ function canonicalizeMcpResultValue(value) {
106667
+ if (Array.isArray(value)) {
106668
+ let deduplicatedBranches2 = 0;
106669
+ let changed2 = false;
106670
+ const items = value.map((item) => {
106671
+ const canonical2 = canonicalizeMcpResultValue(item);
106672
+ deduplicatedBranches2 += canonical2.deduplicatedBranches;
106673
+ changed2 ||= canonical2.value !== item;
106674
+ return canonical2.value;
106675
+ });
106676
+ return {
106677
+ value: changed2 ? items : value,
106678
+ deduplicatedBranches: deduplicatedBranches2
106679
+ };
106680
+ }
106681
+ if (typeof value !== "object" || value === null) {
106682
+ return { value, deduplicatedBranches: 0 };
106683
+ }
106684
+ const record2 = value;
106685
+ const duplicateContentIndexes = equivalentMcpTextContentIndexes(record2);
106686
+ let deduplicatedBranches = duplicateContentIndexes.size;
106687
+ let changed = duplicateContentIndexes.size > 0;
106688
+ const canonical = /* @__PURE__ */ Object.create(null);
106689
+ for (const [key, item] of Object.entries(record2)) {
106690
+ if (key === "content" && Array.isArray(item)) {
106691
+ const retainedContent = duplicateContentIndexes.size > 0 ? item.filter(
106692
+ (_contentItem, index) => !duplicateContentIndexes.has(index)
106693
+ ) : item;
106694
+ if (retainedContent.length === 0 && duplicateContentIndexes.size > 0) {
106695
+ continue;
106696
+ }
106697
+ const content = canonicalizeMcpResultValue(retainedContent);
106698
+ canonical[key] = content.value;
106699
+ deduplicatedBranches += content.deduplicatedBranches;
106700
+ changed ||= content.value !== item;
106701
+ continue;
106702
+ }
106703
+ const child = canonicalizeMcpResultValue(item);
106704
+ canonical[key] = child.value;
106705
+ deduplicatedBranches += child.deduplicatedBranches;
106706
+ changed ||= child.value !== item;
106707
+ }
106708
+ return {
106709
+ value: changed ? canonical : value,
106710
+ deduplicatedBranches
106711
+ };
106712
+ }
106713
+ function equivalentMcpTextContentIndexes(value) {
106714
+ if (!Array.isArray(value.content) || !Object.hasOwn(value, "structuredContent") || value.structuredContent === void 0) {
106715
+ return /* @__PURE__ */ new Set();
106716
+ }
106717
+ const indexes = /* @__PURE__ */ new Set();
106718
+ for (const [index, item] of value.content.entries()) {
106719
+ if (!isPlainMcpTextBlock(item)) {
106720
+ continue;
106721
+ }
106722
+ const parsed = parseJson(item.text);
106723
+ if (parsed.parsed && jsonValuesEqual(parsed.value, value.structuredContent)) {
106724
+ indexes.add(index);
106725
+ }
106726
+ }
106727
+ return indexes;
106728
+ }
106729
+ function isPlainMcpTextBlock(value) {
106730
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
106731
+ return false;
106732
+ }
106733
+ const record2 = value;
106734
+ const keys = Object.keys(record2);
106735
+ return keys.length === 2 && record2.type === "text" && typeof record2.text === "string";
106736
+ }
106737
+ function parseJson(value) {
106738
+ try {
106739
+ return { parsed: true, value: JSON.parse(value) };
106740
+ } catch {
106741
+ return { parsed: false, value: null };
106742
+ }
106743
+ }
106744
+ function jsonValuesEqual(left, right) {
106745
+ if (Object.is(left, right)) {
106746
+ return true;
106747
+ }
106748
+ if (Array.isArray(left) || Array.isArray(right)) {
106749
+ if (!Array.isArray(left) || !Array.isArray(right)) {
106750
+ return false;
106751
+ }
106752
+ return left.length === right.length && left.every((item, index) => jsonValuesEqual(item, right[index]));
106753
+ }
106754
+ if (typeof left !== "object" || left === null || typeof right !== "object" || right === null) {
106755
+ return false;
106756
+ }
106757
+ const leftRecord = left;
106758
+ const rightRecord = right;
106759
+ const leftKeys = Object.keys(leftRecord);
106760
+ const rightKeys = Object.keys(rightRecord);
106761
+ return leftKeys.length === rightKeys.length && leftKeys.every(
106762
+ (key) => Object.hasOwn(rightRecord, key) && jsonValuesEqual(leftRecord[key], rightRecord[key])
106763
+ );
106764
+ }
106765
+
106766
+ // src/commands/agent-bridge/harness/envelope-bounds.ts
106466
106767
  var AGENT_BRIDGE_OUTPUT_MAX_ENVELOPE_BYTES = 512 * 1024;
106467
106768
  var AGENT_BRIDGE_OUTPUT_QUARANTINE_MAX_ENVELOPE_BYTES = 8 * 1024;
106468
- var MAX_TARGETED_PAYLOAD_NOTICES = 4;
106469
106769
  var PAYLOAD_FIELD_RULES = {
106470
106770
  output: { label: "tool output", priority: 0 },
106471
106771
  errorText: { label: "tool error", priority: 0 },
@@ -106500,48 +106800,97 @@ var STRUCTURAL_STRING_FIELDS = /* @__PURE__ */ new Set([
106500
106800
  "completedAt"
106501
106801
  ]);
106502
106802
  function boundOutputEnvelope(envelope, maxBytes = AGENT_BRIDGE_OUTPUT_MAX_ENVELOPE_BYTES) {
106503
- const originalBytes = serializedByteLength(envelope);
106803
+ const original = envelopeSerializationInfo(envelope);
106804
+ const originalBytes = original.bytes;
106504
106805
  if (originalBytes <= maxBytes) {
106505
- return { envelope, originalBytes, truncated: false };
106806
+ return {
106807
+ envelope,
106808
+ originalBytes,
106809
+ boundedBytes: originalBytes,
106810
+ kind: "none",
106811
+ deduplicatedMcpResultBranches: 0,
106812
+ truncated: false
106813
+ };
106814
+ }
106815
+ const canonicalized = original.hasStructuredContent ? canonicalizeEnvelopeMcpResults(envelope) : { value: envelope, deduplicatedBranches: 0 };
106816
+ const canonicalEnvelope = canonicalized.value;
106817
+ const canonicalBytes = serializedByteLength(canonicalEnvelope);
106818
+ if (canonicalBytes <= maxBytes) {
106819
+ return {
106820
+ envelope: canonicalEnvelope,
106821
+ originalBytes,
106822
+ boundedBytes: canonicalBytes,
106823
+ kind: "mcp-result-deduplicated",
106824
+ deduplicatedMcpResultBranches: canonicalized.deduplicatedBranches,
106825
+ truncated: true
106826
+ };
106506
106827
  }
106507
- const targeted = truncatePayloads(envelope, maxBytes);
106828
+ const targeted = truncatePayloads(canonicalEnvelope, maxBytes);
106508
106829
  if (targeted) {
106830
+ const boundedEnvelope = RuntimeBridgeOutputEnvelopeSchema.parse(targeted);
106509
106831
  return {
106510
- envelope: RuntimeBridgeOutputEnvelopeSchema.parse(targeted),
106832
+ envelope: boundedEnvelope,
106511
106833
  originalBytes,
106834
+ boundedBytes: serializedByteLength(boundedEnvelope),
106835
+ kind: canonicalized.deduplicatedBranches > 0 ? "mcp-result-deduplicated+targeted-truncation" : "targeted-truncation",
106836
+ deduplicatedMcpResultBranches: canonicalized.deduplicatedBranches,
106512
106837
  truncated: true
106513
106838
  };
106514
106839
  }
106840
+ const fallbackEnvelope = RuntimeBridgeOutputEnvelopeSchema.parse(
106841
+ replacePayloadWithMarker(canonicalEnvelope)
106842
+ );
106515
106843
  return {
106516
- envelope: RuntimeBridgeOutputEnvelopeSchema.parse(
106517
- replacePayloadWithMarker(envelope)
106518
- ),
106844
+ envelope: fallbackEnvelope,
106519
106845
  originalBytes,
106846
+ boundedBytes: serializedByteLength(fallbackEnvelope),
106847
+ kind: canonicalized.deduplicatedBranches > 0 ? "mcp-result-deduplicated+payload-fallback" : "payload-fallback",
106848
+ deduplicatedMcpResultBranches: canonicalized.deduplicatedBranches,
106520
106849
  truncated: true
106521
106850
  };
106522
106851
  }
106523
106852
  function truncatePayloads(envelope, maxBytes) {
106524
106853
  const candidateEnvelope = structuredClone(envelope);
106525
106854
  const candidates = collectPayloadCandidates(envelope);
106526
- for (let noticeCount = 0; noticeCount < MAX_TARGETED_PAYLOAD_NOTICES; noticeCount += 1) {
106855
+ const truncatedCandidates = [];
106856
+ while (true) {
106527
106857
  const currentBytes = serializedByteLength(candidateEnvelope);
106528
106858
  if (currentBytes <= maxBytes) {
106529
106859
  return candidateEnvelope;
106530
106860
  }
106531
106861
  const candidate = takePayloadCandidate(candidates, currentBytes - maxBytes);
106532
106862
  if (!candidate) {
106533
- return null;
106863
+ break;
106534
106864
  }
106535
106865
  setValueAtPath(
106536
106866
  candidateEnvelope,
106537
106867
  candidate.path,
106538
106868
  truncationNotice(candidate, "")
106539
106869
  );
106540
- if (serializedByteLength(candidateEnvelope) <= maxBytes) {
106870
+ const truncatedBytes = serializedByteLength(candidateEnvelope);
106871
+ if (truncatedBytes >= currentBytes) {
106872
+ setValueAtPath(candidateEnvelope, candidate.path, candidate.value);
106873
+ continue;
106874
+ }
106875
+ truncatedCandidates.push(candidate);
106876
+ if (truncatedBytes <= maxBytes) {
106541
106877
  maximizePreview(candidateEnvelope, candidate, maxBytes);
106542
106878
  return candidateEnvelope;
106543
106879
  }
106544
106880
  }
106881
+ for (const candidate of truncatedCandidates) {
106882
+ setValueAtPath(
106883
+ candidateEnvelope,
106884
+ candidate.path,
106885
+ compactTruncationNotice(candidate)
106886
+ );
106887
+ }
106888
+ if (serializedByteLength(candidateEnvelope) <= maxBytes) {
106889
+ return candidateEnvelope;
106890
+ }
106891
+ for (const candidate of truncatedCandidates) {
106892
+ setValueAtPath(candidateEnvelope, candidate.path, "");
106893
+ }
106545
106894
  return serializedByteLength(candidateEnvelope) <= maxBytes ? candidateEnvelope : null;
106546
106895
  }
106547
106896
  function collectPayloadCandidates(envelope) {
@@ -106706,10 +107055,20 @@ function truncationNotice(candidate, preview2) {
106706
107055
  const separator = preview2.length > 0 ? "\n" : "";
106707
107056
  return `${preview2}${separator}[agent-bridge ${candidate.label} truncated: original ${candidate.originalBytes} UTF-8 bytes; kept ${keptBytes}; omitted ${omittedBytes}. Omitted content was not persisted in this transcript.]`;
106708
107057
  }
107058
+ function compactTruncationNotice(candidate) {
107059
+ return `[agent-bridge ${candidate.label} truncated: original ${candidate.originalBytes} UTF-8 bytes.]`;
107060
+ }
106709
107061
  function serializedByteLength(value) {
106710
107062
  const serialized = JSON.stringify(value);
106711
107063
  return serialized === void 0 ? 0 : Buffer2.byteLength(serialized, "utf8");
106712
107064
  }
107065
+ function envelopeSerializationInfo(envelope) {
107066
+ const serialized = JSON.stringify(envelope);
107067
+ return {
107068
+ bytes: Buffer2.byteLength(serialized, "utf8"),
107069
+ hasStructuredContent: serialized.includes('"structuredContent":')
107070
+ };
107071
+ }
106713
107072
  function replacePayloadWithMarker(envelope) {
106714
107073
  switch (envelope.type) {
106715
107074
  case "conversation.entry": {
@@ -107671,6 +108030,9 @@ var AgentBridgeOutputBuffer = class {
107671
108030
  "agent_bridge_output_envelope_truncated",
107672
108031
  this.outputLogContext(bounded.envelope, {
107673
108032
  original_bytes: bounded.originalBytes,
108033
+ bounded_bytes: bounded.boundedBytes,
108034
+ bound_kind: bounded.kind,
108035
+ deduplicated_mcp_result_branches: bounded.deduplicatedMcpResultBranches,
107674
108036
  pending_count: this.pendingOutputs.size
107675
108037
  })
107676
108038
  );
@@ -107704,6 +108066,9 @@ var AgentBridgeOutputBuffer = class {
107704
108066
  this.outputLogContext(bounded.envelope, {
107705
108067
  exhausts,
107706
108068
  original_bytes: bounded.originalBytes,
108069
+ bounded_bytes: bounded.boundedBytes,
108070
+ bound_kind: bounded.kind,
108071
+ deduplicated_mcp_result_branches: bounded.deduplicatedMcpResultBranches,
107707
108072
  truncated: bounded.truncated,
107708
108073
  pending_count: this.pendingOutputs.size
107709
108074
  })