@wave-ai-os/wave-cli 0.1.76 → 0.1.77

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.cjs CHANGED
@@ -3,13 +3,13 @@
3
3
 
4
4
  // src/index.ts
5
5
  var import_commander2 = require("commander");
6
- var import_zod20 = require("zod");
6
+ var import_zod21 = require("zod");
7
7
 
8
8
  // src/cli.ts
9
9
  var import_commander = require("commander");
10
10
 
11
11
  // src/commands/tasks.ts
12
- var import_zod2 = require("zod");
12
+ var import_zod3 = require("zod");
13
13
 
14
14
  // src/config.ts
15
15
  var import_zod = require("zod");
@@ -2144,6 +2144,17 @@ async function authGraphqlRequest(params) {
2144
2144
  }
2145
2145
  }
2146
2146
 
2147
+ // src/machineRuntimeContext.ts
2148
+ var import_node_async_hooks = require("async_hooks");
2149
+ var machineRuntimeAuthStorage = new import_node_async_hooks.AsyncLocalStorage();
2150
+ function currentMachineRuntimeAuth() {
2151
+ return machineRuntimeAuthStorage.getStore();
2152
+ }
2153
+ function withMachineRuntimeAuth(auth, callback) {
2154
+ if (!auth) return callback();
2155
+ return machineRuntimeAuthStorage.run(auth, callback);
2156
+ }
2157
+
2147
2158
  // src/commands/runtimeOptions.ts
2148
2159
  var CLI_AUTH_STATUS_QUERY = "query WaveCliAuthenticatedOrganization { cliAuthStatus { authenticated baseAuthStatus organization { id slug } } }";
2149
2160
  var stdinPromise = null;
@@ -2170,6 +2181,11 @@ function parseBool(raw) {
2170
2181
  }
2171
2182
  return void 0;
2172
2183
  }
2184
+ function omitUndefined(values) {
2185
+ return Object.fromEntries(
2186
+ Object.entries(values).filter(([, value]) => value !== void 0)
2187
+ );
2188
+ }
2173
2189
  function parseAuthJson(raw) {
2174
2190
  try {
2175
2191
  const parsed = JSON.parse(raw);
@@ -2177,7 +2193,7 @@ function parseAuthJson(raw) {
2177
2193
  throw new Error("Expected JSON object.");
2178
2194
  }
2179
2195
  const obj = parsed;
2180
- return {
2196
+ return omitUndefined({
2181
2197
  token: normalize3(obj.token),
2182
2198
  baseUrl: normalize3(obj.baseUrl ?? obj.base_url),
2183
2199
  timeoutMs: typeof obj.timeoutMs === "number" || typeof obj.timeoutMs === "string" ? obj.timeoutMs : typeof obj.timeout_ms === "number" || typeof obj.timeout_ms === "string" ? obj.timeout_ms : void 0,
@@ -2210,7 +2226,7 @@ function parseAuthJson(raw) {
2210
2226
  openapiPath: normalize3(obj.openapiPath ?? obj.openapi_path),
2211
2227
  openapiUrl: normalize3(obj.openapiUrl ?? obj.openapi_url),
2212
2228
  openapiVersion: normalize3(obj.openapiVersion ?? obj.openapi_version)
2213
- };
2229
+ });
2214
2230
  } catch (error) {
2215
2231
  throw new CliError({
2216
2232
  message: error instanceof Error ? `Invalid --auth-json-stdin payload: ${error.message}` : "Invalid --auth-json-stdin payload.",
@@ -2258,13 +2274,14 @@ function firstDefined(...values) {
2258
2274
  return values.find((value) => value !== void 0);
2259
2275
  }
2260
2276
  function resolveAuthToken(options, stdin, config, env) {
2277
+ const candidate = (source, token) => token ? { token, source } : { source };
2261
2278
  const candidates = [
2262
- { token: normalize3(options.token), source: "flag" },
2263
- { token: normalize3(stdin.token), source: "stdin" },
2264
- { token: normalize3(env.WAVE_API_TOKEN), source: "env" },
2265
- { token: normalize3(config.token), source: "config" }
2279
+ candidate("flag", normalize3(options.token)),
2280
+ candidate("stdin", normalize3(stdin.token)),
2281
+ candidate("env", normalize3(env.WAVE_API_TOKEN)),
2282
+ candidate("config", normalize3(config.token))
2266
2283
  ];
2267
- return candidates.find((candidate) => candidate.token) ?? { source: "none" };
2284
+ return candidates.find((candidate2) => candidate2.token) ?? { source: "none" };
2268
2285
  }
2269
2286
  function resolveFromSources(options, stdin, config, env) {
2270
2287
  const baseUrl = firstDefined(
@@ -2363,10 +2380,9 @@ function resolveFromSources(options, stdin, config, env) {
2363
2380
  normalize3(config.openapiVersion)
2364
2381
  );
2365
2382
  const resolvedAuth = resolveAuthToken(options, stdin, config, env);
2366
- return {
2367
- organizationId,
2383
+ const resolved = {
2368
2384
  organizationIdSource,
2369
- runtimeOptions: {
2385
+ runtimeOptions: omitUndefined({
2370
2386
  token: resolvedAuth.token,
2371
2387
  tokenSource: resolvedAuth.token ? resolvedAuth.source : "none",
2372
2388
  baseUrl,
@@ -2386,8 +2402,10 @@ function resolveFromSources(options, stdin, config, env) {
2386
2402
  openapiPath,
2387
2403
  openapiUrl,
2388
2404
  openapiVersion
2389
- }
2405
+ })
2390
2406
  };
2407
+ if (organizationId) resolved.organizationId = organizationId;
2408
+ return resolved;
2391
2409
  }
2392
2410
  async function resolveWithStoredToken(context) {
2393
2411
  if (context.runtimeOptions.token || !context.runtimeOptions.baseUrl) {
@@ -2411,11 +2429,11 @@ async function resolveWithAuthenticatedOrganization(context) {
2411
2429
  const baseUrl = normalize3(context.runtimeOptions.baseUrl);
2412
2430
  const token = normalize3(context.runtimeOptions.token);
2413
2431
  if (!baseUrl || !token) {
2432
+ const runtimeOptions2 = { ...context.runtimeOptions };
2433
+ delete runtimeOptions2.organizationId;
2414
2434
  return {
2415
- ...context,
2416
- organizationId: void 0,
2417
2435
  organizationIdSource: "none",
2418
- runtimeOptions: { ...context.runtimeOptions, organizationId: void 0 }
2436
+ runtimeOptions: runtimeOptions2
2419
2437
  };
2420
2438
  }
2421
2439
  const response = await authGraphqlRequest({
@@ -2425,12 +2443,18 @@ async function resolveWithAuthenticatedOrganization(context) {
2425
2443
  query: CLI_AUTH_STATUS_QUERY
2426
2444
  });
2427
2445
  const organizationId = response.ok ? organizationIdFromCliAuthStatus(response.result.data) : void 0;
2428
- return {
2429
- ...context,
2430
- organizationId,
2446
+ const runtimeOptions = { ...context.runtimeOptions };
2447
+ if (organizationId) {
2448
+ runtimeOptions.organizationId = organizationId;
2449
+ } else {
2450
+ delete runtimeOptions.organizationId;
2451
+ }
2452
+ const resolved = {
2431
2453
  organizationIdSource: organizationId ? "token" : "none",
2432
- runtimeOptions: { ...context.runtimeOptions, organizationId }
2454
+ runtimeOptions
2433
2455
  };
2456
+ if (organizationId) resolved.organizationId = organizationId;
2457
+ return resolved;
2434
2458
  }
2435
2459
  function defaultConfigPath(env) {
2436
2460
  const explicitEnv = normalize3(env.WAVE_CONFIG_PATH);
@@ -2497,7 +2521,22 @@ async function resolveStdinContext(options) {
2497
2521
  async function resolveUnscopedCommandContext(options) {
2498
2522
  const stdin = await resolveStdinContext(options);
2499
2523
  const config = await resolveConfigFileContext(options, process.env);
2500
- return resolveWithStoredToken(resolveFromSources(options, stdin, config, process.env));
2524
+ return resolveWithStoredToken(applyMachineRuntimeAuth(resolveFromSources(options, stdin, config, process.env)));
2525
+ }
2526
+ function applyMachineRuntimeAuth(resolved) {
2527
+ const machineAuth = currentMachineRuntimeAuth();
2528
+ if (!machineAuth) return resolved;
2529
+ return {
2530
+ organizationId: machineAuth.organizationId,
2531
+ organizationIdSource: "flag",
2532
+ runtimeOptions: {
2533
+ ...resolved.runtimeOptions,
2534
+ token: machineAuth.token,
2535
+ tokenSource: "machine",
2536
+ baseUrl: machineAuth.baseUrl,
2537
+ organizationId: machineAuth.organizationId
2538
+ }
2539
+ };
2501
2540
  }
2502
2541
  async function resolveCommandContext(options) {
2503
2542
  return resolveWithAuthenticatedOrganization(await resolveUnscopedCommandContext(options));
@@ -2651,10 +2690,29 @@ function registerGraphqlSearchCommand(command, config) {
2651
2690
  });
2652
2691
  }
2653
2692
 
2693
+ // src/commands/taskPriority.ts
2694
+ var import_zod2 = require("zod");
2695
+ var taskPrioritySchema = import_zod2.z.enum(["no_priority", "urgent", "high", "medium", "low"]);
2696
+ var taskPriorityValues = taskPrioritySchema.options.join(", ");
2697
+ var taskPriorityHelp = `Filter by priority: ${taskPriorityValues}.`;
2698
+ function parseTaskPriority(value) {
2699
+ if (value === void 0) return void 0;
2700
+ const parsed = taskPrioritySchema.safeParse(value);
2701
+ if (!parsed.success) {
2702
+ throw new CliError({
2703
+ message: `Invalid task priority. Use one of: ${taskPriorityValues}.`,
2704
+ kind: "invalid_args",
2705
+ status: 400,
2706
+ exitCode: EXIT_CODES.invalidArgs
2707
+ });
2708
+ }
2709
+ return parsed.data.toUpperCase();
2710
+ }
2711
+
2654
2712
  // src/commands/tasks.ts
2655
- var projectIdSchema = import_zod2.z.string().min(1);
2656
- var idSchema = import_zod2.z.string().min(1);
2657
- var summarySchema = import_zod2.z.string().min(1);
2713
+ var projectIdSchema = import_zod3.z.string().min(1);
2714
+ var idSchema = import_zod3.z.string().min(1);
2715
+ var summarySchema = import_zod3.z.string().min(1);
2658
2716
  function parseTaskUpdateJson(raw) {
2659
2717
  try {
2660
2718
  const parsed = JSON.parse(raw);
@@ -2681,7 +2739,7 @@ function parseLabelIds(raw) {
2681
2739
  }
2682
2740
  function registerTaskCommands(program) {
2683
2741
  const tasks = program.command("tasks").description("Task operations");
2684
- tasks.command("list").option("--project-id <projectId>").option("--page <page>").option("--per <per>").option("--team-id <teamId>").option("--team-ids <teamIds>").option("--member-id <memberId>").option("--meeting-id <meetingId>").option("--field-name <fieldName>").option("--field-value <fieldValue>").option("--field-blank <fieldBlank>").option("--open <open>").option("--rank-direction <rankDirection>").option("--include-archived <includeArchived>").action(async (opts, cmd) => {
2742
+ tasks.command("list").option("--project-id <projectId>").option("--page <page>").option("--per <per>").option("--team-id <teamId>").option("--team-ids <teamIds>").option("--member-id <memberId>").option("--meeting-id <meetingId>").option("--field-name <fieldName>").option("--field-value <fieldValue>").option("--field-blank <fieldBlank>").option("--open <open>").option("--priority <priority>", taskPriorityHelp).option("--rank-direction <rankDirection>").option("--include-archived <includeArchived>").action(async (opts, cmd) => {
2685
2743
  const context = await resolveCommandContext(cmd.optsWithGlobals());
2686
2744
  const organizationId = resolveOrganizationId(context.organizationId);
2687
2745
  const projectId = opts.projectId ? projectIdSchema.parse(opts.projectId) : void 0;
@@ -2702,9 +2760,27 @@ function registerTaskCommands(program) {
2702
2760
  field_value: opts.fieldValue,
2703
2761
  field_blank: opts.fieldBlank,
2704
2762
  open: opts.open,
2763
+ priority: parseTaskPriority(opts.priority),
2705
2764
  rank_direction: opts.rankDirection,
2706
2765
  include_archived: opts.includeArchived
2707
2766
  }),
2767
+ variableTypes: {
2768
+ organization_id: "ID!",
2769
+ page: "Int",
2770
+ per: "Int",
2771
+ project_id: "ID",
2772
+ team_id: "ID",
2773
+ team_ids: "[ID!]",
2774
+ member_id: "ID",
2775
+ meeting_id: "ID",
2776
+ field_name: "String",
2777
+ field_value: "String",
2778
+ field_blank: "Boolean",
2779
+ open: "Boolean",
2780
+ priority: "TaskPriority",
2781
+ rank_direction: "String",
2782
+ include_archived: "Boolean"
2783
+ },
2708
2784
  isList: true
2709
2785
  });
2710
2786
  });
@@ -2799,10 +2875,10 @@ function registerTaskCommands(program) {
2799
2875
  }
2800
2876
 
2801
2877
  // src/commands/projects.ts
2802
- var import_zod4 = require("zod");
2878
+ var import_zod5 = require("zod");
2803
2879
 
2804
2880
  // src/commands/entityCrud.ts
2805
- var import_zod3 = require("zod");
2881
+ var import_zod4 = require("zod");
2806
2882
 
2807
2883
  // src/commands/dtoHelpCatalog.ts
2808
2884
  var dtoHelpCatalog = {
@@ -3383,7 +3459,7 @@ function buildDataJsonHelp(rootKey, mode) {
3383
3459
  }
3384
3460
 
3385
3461
  // src/commands/entityCrud.ts
3386
- var idSchema2 = import_zod3.z.string().min(1);
3462
+ var idSchema2 = import_zod4.z.string().min(1);
3387
3463
  function toSingularResourceName(resourcePath) {
3388
3464
  if (resourcePath === "organization_meta_profiles") {
3389
3465
  return "organization_meta_profile";
@@ -3609,10 +3685,28 @@ var __testables = {
3609
3685
  };
3610
3686
 
3611
3687
  // src/commands/projects.ts
3612
- var idSchema3 = import_zod4.z.string().min(1);
3688
+ var idSchema3 = import_zod5.z.string().min(1);
3689
+ var projectStatusSchema = import_zod5.z.enum([
3690
+ "backlog",
3691
+ "planned",
3692
+ "in_progress",
3693
+ "completed",
3694
+ "cancelled"
3695
+ ]);
3696
+ var projectStatusValues = projectStatusSchema.options.join(", ");
3697
+ var projectPrioritySchema = import_zod5.z.enum([
3698
+ "no_priority",
3699
+ "urgent",
3700
+ "high",
3701
+ "medium",
3702
+ "low"
3703
+ ]);
3704
+ var projectPriorityValues = projectPrioritySchema.options.join(", ");
3613
3705
  var projectCreateDataJsonHelp = buildDataJsonHelp("project", "create") ?? 'JSON object for project or {"project": {...}}';
3614
3706
  var projectUpdateDataJsonHelp = buildDataJsonHelp("project", "update") ?? 'JSON object for project or {"project": {...}}';
3615
- var projectsIndexMinimalSelectionSet = "{ count currentPage totalPages data { id type attributes { name slug status priority } } }";
3707
+ function projectsIndexMinimalSelectionSet(includeProjectTypes = false) {
3708
+ return `{ count currentPage totalPages data { id type attributes { name slug status priority${includeProjectTypes ? " projectType" : ""} } } }`;
3709
+ }
3616
3710
  var displayPreferenceAttributesSelectionSet = "attributes { id viewType favorite groupingField groupToggleState memberId focusMemberId focusTeamId displayableId displayableType preferenceType agendaItemId }";
3617
3711
  var filterPreferenceAttributesSelectionSet = "attributes { id filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId }";
3618
3712
  var healthUpdateSummarySelectionSet = "id type value memberId status createdAt updatedAt updatableType updatableId parentUpdateId emojis { id name memberId } resources { ...ResourceSummaryFull }";
@@ -3623,6 +3717,32 @@ function asRecord3(value) {
3623
3717
  function toNonEmptyString(value) {
3624
3718
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
3625
3719
  }
3720
+ function parseProjectStatus(value) {
3721
+ if (value === void 0) return void 0;
3722
+ const parsed = projectStatusSchema.safeParse(value);
3723
+ if (!parsed.success) {
3724
+ throw new CliError({
3725
+ message: `Invalid project status. Use one of: ${projectStatusValues}.`,
3726
+ kind: "invalid_args",
3727
+ status: 400,
3728
+ exitCode: EXIT_CODES.invalidArgs
3729
+ });
3730
+ }
3731
+ return parsed.data.toUpperCase();
3732
+ }
3733
+ function parseProjectPriority(value) {
3734
+ if (value === void 0) return void 0;
3735
+ const parsed = projectPrioritySchema.safeParse(value);
3736
+ if (!parsed.success) {
3737
+ throw new CliError({
3738
+ message: `Invalid project priority. Use one of: ${projectPriorityValues}.`,
3739
+ kind: "invalid_args",
3740
+ status: 400,
3741
+ exitCode: EXIT_CODES.invalidArgs
3742
+ });
3743
+ }
3744
+ return parsed.data.toUpperCase();
3745
+ }
3626
3746
  function normalizeProjectRowForDisplay(row) {
3627
3747
  const record = asRecord3(row);
3628
3748
  if (!record) return row;
@@ -3650,7 +3770,13 @@ function normalizeProjectsListForDisplay(payload) {
3650
3770
  }
3651
3771
  function registerProjectCommands(program) {
3652
3772
  const projects = program.command("projects").description("Project operations");
3653
- projects.command("list").option("--page <page>").option("--per <per>").option("--team-ids <teamIds>").option("--member-id <memberId>").action(async (opts, cmd) => {
3773
+ projects.command("list").option("--page <page>").option("--per <per>").option("--team-ids <teamIds>").option("--member-id <memberId>").option(
3774
+ "--status <status>",
3775
+ "Filter by status: backlog, planned, in_progress, completed, cancelled."
3776
+ ).option(
3777
+ "--priority <priority>",
3778
+ "Filter by priority: no_priority, urgent, high, medium, low."
3779
+ ).option("--include-project-types", "Include projectType in the list response (opt-in).").action(async (opts, cmd) => {
3654
3780
  const context = await resolveCommandContext(cmd.optsWithGlobals());
3655
3781
  const organizationId = resolveOrganizationId(context.organizationId);
3656
3782
  await runGraphqlQueryCommand({
@@ -3663,17 +3789,21 @@ function registerProjectCommands(program) {
3663
3789
  page: opts.page,
3664
3790
  per: opts.per,
3665
3791
  team_ids: opts.teamIds,
3666
- member_id: opts.memberId
3792
+ member_id: opts.memberId,
3793
+ status: parseProjectStatus(opts.status),
3794
+ priority: parseProjectPriority(opts.priority)
3667
3795
  }),
3668
3796
  variableTypes: {
3669
3797
  organization_id: "ID!",
3670
3798
  page: "Int",
3671
3799
  per: "Int",
3672
3800
  team_ids: "[ID!]",
3673
- member_id: "ID"
3801
+ member_id: "ID",
3802
+ status: "ProjectStatus",
3803
+ priority: "ProjectPriority"
3674
3804
  },
3675
3805
  isList: true,
3676
- selectionSet: projectsIndexMinimalSelectionSet,
3806
+ selectionSet: projectsIndexMinimalSelectionSet(opts.includeProjectTypes === true),
3677
3807
  transformData: normalizeProjectsListForDisplay
3678
3808
  });
3679
3809
  });
@@ -3681,7 +3811,7 @@ function registerProjectCommands(program) {
3681
3811
  command: "projects",
3682
3812
  operationName: "ProjectsSearch",
3683
3813
  field: "projects",
3684
- selectionSet: projectsIndexMinimalSelectionSet,
3814
+ selectionSet: projectsIndexMinimalSelectionSet(),
3685
3815
  transformData: normalizeProjectsListForDisplay
3686
3816
  });
3687
3817
  projects.command("show").requiredOption("--id <id>").action(async (opts, cmd) => {
@@ -3740,10 +3870,10 @@ function registerProjectCommands(program) {
3740
3870
  }
3741
3871
 
3742
3872
  // src/commands/rocks.ts
3743
- var import_zod5 = require("zod");
3744
- var idSchema4 = import_zod5.z.string().min(1);
3745
- var rockCollectionIdSchema = import_zod5.z.string().min(1);
3746
- var statusSchema = import_zod5.z.enum(["on_track", "at_risk", "off_track"]);
3873
+ var import_zod6 = require("zod");
3874
+ var idSchema4 = import_zod6.z.string().min(1);
3875
+ var rockCollectionIdSchema = import_zod6.z.string().min(1);
3876
+ var statusSchema = import_zod6.z.enum(["on_track", "at_risk", "off_track"]);
3747
3877
  var createHelp = buildDataJsonHelp("rock", "create") ?? 'JSON object for rock or {"rock": {...}}';
3748
3878
  var updateHelp = buildDataJsonHelp("rock", "update") ?? 'JSON object for rock or {"rock": {...}}';
3749
3879
  function registerRockCommands(program) {
@@ -3841,9 +3971,9 @@ function registerRockCommands(program) {
3841
3971
  }
3842
3972
 
3843
3973
  // src/commands/meetings.ts
3844
- var import_zod6 = require("zod");
3845
- var idSchema5 = import_zod6.z.string().min(1);
3846
- var notesSchema = import_zod6.z.string().min(1);
3974
+ var import_zod7 = require("zod");
3975
+ var idSchema5 = import_zod7.z.string().min(1);
3976
+ var notesSchema = import_zod7.z.string().min(1);
3847
3977
  var MEETING_TYPES = /* @__PURE__ */ new Set(["TeamMeeting", "OneOnOneMeeting"]);
3848
3978
  var MEETING_STATUSES = /* @__PURE__ */ new Set(["upcoming", "active", "completed"]);
3849
3979
  var MEETING_REPEATS = /* @__PURE__ */ new Set(["never", "weekly", "biweekly", "monthly", "quarterly"]);
@@ -4076,8 +4206,8 @@ function registerMeetingCommands(program) {
4076
4206
  }
4077
4207
 
4078
4208
  // src/commands/members.ts
4079
- var import_zod7 = require("zod");
4080
- var idSchema6 = import_zod7.z.string().min(1);
4209
+ var import_zod8 = require("zod");
4210
+ var idSchema6 = import_zod8.z.string().min(1);
4081
4211
  var createHelp3 = buildDataJsonHelp("member", "create") ?? 'JSON object for member or {"member": {...}}';
4082
4212
  var updateHelp3 = buildDataJsonHelp("member", "update") ?? 'JSON object for member or {"member": {...}}';
4083
4213
  var MEMBER_META_PROFILE_SELECTION = "{ id type memberId summary profile attributes { id memberId summary profile } }";
@@ -4206,9 +4336,9 @@ function registerMemberCommands(program) {
4206
4336
  }
4207
4337
 
4208
4338
  // src/commands/skills.ts
4209
- var import_zod8 = require("zod");
4210
- var idSchema7 = import_zod8.z.string().min(1);
4211
- var limitSchema = import_zod8.z.coerce.number().int().positive();
4339
+ var import_zod9 = require("zod");
4340
+ var idSchema7 = import_zod9.z.string().min(1);
4341
+ var limitSchema = import_zod9.z.coerce.number().int().positive();
4212
4342
  var SKILL_SELECTION = `{
4213
4343
  id
4214
4344
  type
@@ -4284,11 +4414,11 @@ function registerSkillCommands(program) {
4284
4414
  }
4285
4415
 
4286
4416
  // src/commands/issues.ts
4287
- var import_zod9 = require("zod");
4288
- var issueGroupIdSchema = import_zod9.z.string().min(1);
4289
- var idSchema8 = import_zod9.z.string().min(1);
4290
- var nameSchema = import_zod9.z.string().min(1);
4291
- var issueTypeSchema = import_zod9.z.string().min(1).refine((value) => value === "short_term" || value === "long_term", {
4417
+ var import_zod10 = require("zod");
4418
+ var issueGroupIdSchema = import_zod10.z.string().min(1);
4419
+ var idSchema8 = import_zod10.z.string().min(1);
4420
+ var nameSchema = import_zod10.z.string().min(1);
4421
+ var issueTypeSchema = import_zod10.z.string().min(1).refine((value) => value === "short_term" || value === "long_term", {
4292
4422
  message: "Invalid issue type. Use one of: short_term, long_term."
4293
4423
  });
4294
4424
  var updateHelp4 = buildDataJsonHelp("issue", "update") ?? 'JSON object for issue or {"issue": {...}}';
@@ -5335,8 +5465,8 @@ function registerSystemToolCommands(program) {
5335
5465
  }
5336
5466
 
5337
5467
  // src/commands/teams.ts
5338
- var import_zod10 = require("zod");
5339
- var idSchema9 = import_zod10.z.string().min(1);
5468
+ var import_zod11 = require("zod");
5469
+ var idSchema9 = import_zod11.z.string().min(1);
5340
5470
  function registerTeamCommands(program) {
5341
5471
  const teams = program.command("teams").description("Team operations");
5342
5472
  teams.command("list").option("--page <page>").option("--per <per>").action(async (opts, cmd) => {
@@ -5402,8 +5532,8 @@ function registerTeamCommands(program) {
5402
5532
  }
5403
5533
 
5404
5534
  // src/commands/organizations.ts
5405
- var import_zod11 = require("zod");
5406
- var idSchema10 = import_zod11.z.string().min(1);
5535
+ var import_zod12 = require("zod");
5536
+ var idSchema10 = import_zod12.z.string().min(1);
5407
5537
  function isRecord3(value) {
5408
5538
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5409
5539
  }
@@ -5615,8 +5745,8 @@ function registerOrganizationCommands(program) {
5615
5745
  }
5616
5746
 
5617
5747
  // src/commands/foundation.ts
5618
- var import_zod12 = require("zod");
5619
- var idSchema11 = import_zod12.z.string().min(1);
5748
+ var import_zod13 = require("zod");
5749
+ var idSchema11 = import_zod13.z.string().min(1);
5620
5750
  var STRATEGIC_PLAN_ALLOWED_UPDATE_KEYS = /* @__PURE__ */ new Set([
5621
5751
  "published_at",
5622
5752
  "profile",
@@ -5817,9 +5947,9 @@ function registerFoundationCommands(program) {
5817
5947
  }
5818
5948
 
5819
5949
  // src/commands/childEntities.ts
5820
- var import_zod13 = require("zod");
5821
- var idSchema12 = import_zod13.z.string().min(1);
5822
- var jsonObjectSchema = import_zod13.z.record(import_zod13.z.string(), import_zod13.z.unknown());
5950
+ var import_zod14 = require("zod");
5951
+ var idSchema12 = import_zod14.z.string().min(1);
5952
+ var jsonObjectSchema = import_zod14.z.record(import_zod14.z.string(), import_zod14.z.unknown());
5823
5953
  var NOTE_DETAIL_FIELDS = [
5824
5954
  "notes",
5825
5955
  "hasNotes",
@@ -5967,10 +6097,17 @@ function normalizeSubtaskCreateBody(body) {
5967
6097
  }
5968
6098
  function registerChildCommands(program, config) {
5969
6099
  const command = program.command(config.command).description(config.description);
5970
- command.command("list").requiredOption(`--${config.parentFlag} <${config.parentFlag}>`).option("--page <page>").option("--per <per>").action(async (opts, cmd) => {
6100
+ const listCommand = command.command("list").requiredOption(`--${config.parentFlag} <${config.parentFlag}>`).option("--page <page>").option("--per <per>");
6101
+ if (config.priorityFilter) {
6102
+ listCommand.option("--priority <priority>", config.priorityFilter.help);
6103
+ }
6104
+ listCommand.action(async (opts, cmd) => {
5971
6105
  const context = await resolveCommandContext(cmd.optsWithGlobals());
5972
6106
  const organizationId = resolveOrganizationId(context.organizationId);
5973
6107
  const parentId = idSchema12.parse(opts[config.parentFlag.replace(/-([a-z])/g, (_, c) => c.toUpperCase())]);
6108
+ const priority = config.priorityFilter?.parse(opts.priority);
6109
+ const priorityVariables = priority === void 0 ? {} : { priority };
6110
+ const priorityVariableTypes = priority === void 0 || !config.priorityFilter ? {} : { priority: config.priorityFilter.variableType };
5974
6111
  await runGraphqlQueryCommand({
5975
6112
  command: `${config.command}.list`,
5976
6113
  operationName: config.listOperationName,
@@ -5980,13 +6117,15 @@ function registerChildCommands(program, config) {
5980
6117
  organization_id: organizationId,
5981
6118
  [config.parentFlag.replace(/-/g, "_")]: parentId,
5982
6119
  page: opts.page,
5983
- per: opts.per
6120
+ per: opts.per,
6121
+ ...priorityVariables
5984
6122
  }),
5985
6123
  variableTypes: {
5986
6124
  organization_id: "ID!",
5987
6125
  [config.parentFlag.replace(/-/g, "_")]: "ID!",
5988
6126
  page: "Int",
5989
- per: "Int"
6127
+ per: "Int",
6128
+ ...priorityVariableTypes
5990
6129
  },
5991
6130
  isList: true,
5992
6131
  selectionSet: config.listSelectionSet,
@@ -6106,6 +6245,11 @@ function registerChildEntityCommands(program) {
6106
6245
  destroyOperationName: "SubtasksDestroy",
6107
6246
  listSelectionSet: buildChildListSelectionSet("taskId"),
6108
6247
  listParentTypedField: "taskId",
6248
+ priorityFilter: {
6249
+ variableType: "TaskPriority",
6250
+ help: taskPriorityHelp,
6251
+ parse: parseTaskPriority
6252
+ },
6109
6253
  searchRequiredOptions: requiredParentSearchOption("task-id", "task"),
6110
6254
  showField: "subtask",
6111
6255
  showOperationName: "SubtasksShow",
@@ -6221,9 +6365,9 @@ function registerChildEntityCommands(program) {
6221
6365
  }
6222
6366
 
6223
6367
  // src/commands/content.ts
6224
- var import_zod14 = require("zod");
6225
- var idSchema13 = import_zod14.z.string().min(1);
6226
- var nonEmptyString = import_zod14.z.string().min(1);
6368
+ var import_zod15 = require("zod");
6369
+ var idSchema13 = import_zod15.z.string().min(1);
6370
+ var nonEmptyString = import_zod15.z.string().min(1);
6227
6371
  var contentAttributesSelection = "attributes { id type name slug content firstChildSlug rootParentSlug status contentType lastEdited organizationId memberId focusMemberId focusTeamId teamId creatorId createdAt updatedAt childCount assignmentType contentableId contentableSlug contentableType votesTotal labelIds rootContentId parentContentId }";
6228
6372
  function assertUpdateFields(params) {
6229
6373
  if (!params.name && !params.content && !params.status) {
@@ -6411,9 +6555,9 @@ function registerContentCommands(program) {
6411
6555
  }
6412
6556
 
6413
6557
  // src/commands/markdownTree.ts
6414
- var import_zod15 = require("zod");
6415
- var nonEmptyString2 = import_zod15.z.string().min(1);
6416
- var nonNegativeInt = import_zod15.z.coerce.number().int().min(0);
6558
+ var import_zod16 = require("zod");
6559
+ var nonEmptyString2 = import_zod16.z.string().min(1);
6560
+ var nonNegativeInt = import_zod16.z.coerce.number().int().min(0);
6417
6561
  function addScopeOptions(command) {
6418
6562
  return command.requiredOption("--tool-key <toolKey>").requiredOption("--node-key <nodeKey>").option("--parent-id <parentId>").option("--record-id <recordId>").option("--member-id <memberId>").option("--team-id <teamId>").option("--content-type <contentType>").option("--tree-view");
6419
6563
  }
@@ -6578,7 +6722,7 @@ function registerMarkdownTreeCommands(program) {
6578
6722
  }
6579
6723
 
6580
6724
  // src/commands/navigation.ts
6581
- var import_zod16 = require("zod");
6725
+ var import_zod17 = require("zod");
6582
6726
 
6583
6727
  // src/internalOptions.ts
6584
6728
  var INTERNAL_OPTIONS_KEY = "__waveInternalOptions";
@@ -6608,8 +6752,8 @@ function getInternalCliOptions(command) {
6608
6752
  }
6609
6753
 
6610
6754
  // src/commands/navigation.ts
6611
- var nonEmpty = import_zod16.z.string().min(1);
6612
- var nonNegativeInt2 = import_zod16.z.coerce.number().int().min(0);
6755
+ var nonEmpty = import_zod17.z.string().min(1);
6756
+ var nonNegativeInt2 = import_zod17.z.coerce.number().int().min(0);
6613
6757
  var MIGRATED_BRANCHES = ["directory", "projects", "knowledge"];
6614
6758
  function normalizeText(input) {
6615
6759
  if (typeof input !== "string") return "";
@@ -7392,11 +7536,11 @@ function registerMutationCapabilityCommands(program) {
7392
7536
  // src/commands/osmd.ts
7393
7537
  var import_promises3 = require("fs/promises");
7394
7538
  var import_node_path3 = require("path");
7395
- var import_zod17 = require("zod");
7396
- var sourceSchema = import_zod17.z.enum(["canonical_osmd", "agent_overlay", "agent_wiki"]);
7397
- var accessSchema = import_zod17.z.enum(["read_only", "read_write", "append_only"]).catch("read_write");
7398
- var ownerSchema = import_zod17.z.enum(["system", "atlas"]);
7399
- var suggestedActionSchema = import_zod17.z.enum([
7539
+ var import_zod18 = require("zod");
7540
+ var sourceSchema = import_zod18.z.enum(["canonical_osmd", "agent_overlay", "agent_wiki"]);
7541
+ var accessSchema = import_zod18.z.enum(["read_only", "read_write", "append_only"]).catch("read_write");
7542
+ var ownerSchema = import_zod18.z.enum(["system", "atlas"]);
7543
+ var suggestedActionSchema = import_zod18.z.enum([
7400
7544
  "read",
7401
7545
  "create",
7402
7546
  "init",
@@ -7405,7 +7549,7 @@ var suggestedActionSchema = import_zod17.z.enum([
7405
7549
  "forbidden",
7406
7550
  "invalid_parent"
7407
7551
  ]).catch("update");
7408
- var agentMarkdownErrorCodeSchema = import_zod17.z.enum([
7552
+ var agentMarkdownErrorCodeSchema = import_zod18.z.enum([
7409
7553
  "canonical_osmd_read_only",
7410
7554
  "agent_parent_not_found",
7411
7555
  "agent_file_not_found",
@@ -7416,9 +7560,9 @@ var agentMarkdownErrorCodeSchema = import_zod17.z.enum([
7416
7560
  "invalid_agent_wiki_path"
7417
7561
  ]);
7418
7562
  var agentMarkdownErrorCodeFieldSchema = agentMarkdownErrorCodeSchema.nullable().catch(null);
7419
- var nonEmptyString3 = import_zod17.z.string().min(1);
7420
- var nonNegativeInt3 = import_zod17.z.coerce.number().int().min(0);
7421
- var positiveInt = import_zod17.z.coerce.number().int().min(1);
7563
+ var nonEmptyString3 = import_zod18.z.string().min(1);
7564
+ var nonNegativeInt3 = import_zod18.z.coerce.number().int().min(0);
7565
+ var positiveInt = import_zod18.z.coerce.number().int().min(1);
7422
7566
  var supportedAgentOverlaySystemFiles = ["notes.md", "summary.md"];
7423
7567
  var supportedWikiIndexFile = "index.md";
7424
7568
  var supportedWikiLogFile = "log.md";
@@ -7434,20 +7578,20 @@ var supportedWikiControlledPatterns = supportedWikiControlledFolders.map(
7434
7578
  );
7435
7579
  var controlledWikiSlugPattern = /^[a-z0-9][a-z0-9-]*$/;
7436
7580
  var agentMarkdownSlugPattern = /^[a-z0-9][a-z0-9-]*$/;
7437
- var osmdSearchScopeSchema = import_zod17.z.enum([
7581
+ var osmdSearchScopeSchema = import_zod18.z.enum([
7438
7582
  "os-only",
7439
7583
  "agent-overlay-only",
7440
7584
  "agent-wiki-only",
7441
7585
  "combined"
7442
7586
  ]);
7443
- var osmdLintScopeSchema = import_zod17.z.enum([
7587
+ var osmdLintScopeSchema = import_zod18.z.enum([
7444
7588
  "combined",
7445
7589
  "agent-overlay-only",
7446
7590
  "agent-wiki-only"
7447
7591
  ]);
7448
- var osmdMemoryQualityScopeSchema = import_zod17.z.enum(["agent-overlay-only"]);
7449
- var osmdIngestKindSchema = import_zod17.z.enum(["text", "file", "url", "transcript"]);
7450
- var osmdRawSourceTypeSchema = import_zod17.z.enum([
7592
+ var osmdMemoryQualityScopeSchema = import_zod18.z.enum(["agent-overlay-only"]);
7593
+ var osmdIngestKindSchema = import_zod18.z.enum(["text", "file", "url", "transcript"]);
7594
+ var osmdRawSourceTypeSchema = import_zod18.z.enum([
7451
7595
  "pasted_text",
7452
7596
  "uploaded_markdown",
7453
7597
  "uploaded_text",
@@ -7456,31 +7600,30 @@ var osmdRawSourceTypeSchema = import_zod17.z.enum([
7456
7600
  "meeting_transcript",
7457
7601
  "url"
7458
7602
  ]);
7459
- var defaultOsmdPhantomTimeoutMs = 12e4;
7460
- var agentMarkdownFileSchema = import_zod17.z.preprocess(
7603
+ var agentMarkdownFileSchema = import_zod18.z.preprocess(
7461
7604
  normalizeAgentMarkdownJsonKeys,
7462
- import_zod17.z.object({
7463
- path: import_zod17.z.string(),
7605
+ import_zod18.z.object({
7606
+ path: import_zod18.z.string(),
7464
7607
  source: sourceSchema,
7465
7608
  access: accessSchema,
7466
7609
  owner: ownerSchema,
7467
- exists: import_zod17.z.boolean(),
7468
- canCreate: import_zod17.z.boolean(),
7469
- canUpdate: import_zod17.z.boolean(),
7470
- canAppend: import_zod17.z.boolean(),
7471
- wikiRole: import_zod17.z.string().nullable().optional(),
7472
- formatVersion: import_zod17.z.string().nullable().optional(),
7473
- createdAt: import_zod17.z.string().nullable().optional(),
7474
- updatedAt: import_zod17.z.string().nullable().optional(),
7475
- ingestedAt: import_zod17.z.string().nullable().optional(),
7476
- lastSeenAt: import_zod17.z.string().nullable().optional(),
7477
- canonicalParentUpdatedAt: import_zod17.z.string().nullable().optional(),
7478
- parentRef: import_zod17.z.string().nullable().optional(),
7479
- agentChildrenAllowed: import_zod17.z.boolean(),
7610
+ exists: import_zod18.z.boolean(),
7611
+ canCreate: import_zod18.z.boolean(),
7612
+ canUpdate: import_zod18.z.boolean(),
7613
+ canAppend: import_zod18.z.boolean(),
7614
+ wikiRole: import_zod18.z.string().nullable().optional(),
7615
+ formatVersion: import_zod18.z.string().nullable().optional(),
7616
+ createdAt: import_zod18.z.string().nullable().optional(),
7617
+ updatedAt: import_zod18.z.string().nullable().optional(),
7618
+ ingestedAt: import_zod18.z.string().nullable().optional(),
7619
+ lastSeenAt: import_zod18.z.string().nullable().optional(),
7620
+ canonicalParentUpdatedAt: import_zod18.z.string().nullable().optional(),
7621
+ parentRef: import_zod18.z.string().nullable().optional(),
7622
+ agentChildrenAllowed: import_zod18.z.boolean(),
7480
7623
  suggestedAction: suggestedActionSchema,
7481
7624
  errorCode: agentMarkdownErrorCodeFieldSchema.optional(),
7482
- content: import_zod17.z.string().nullable().optional(),
7483
- url: import_zod17.z.string().nullable().optional()
7625
+ content: import_zod18.z.string().nullable().optional(),
7626
+ url: import_zod18.z.string().nullable().optional()
7484
7627
  }).transform((value) => ({
7485
7628
  ...value,
7486
7629
  wikiRole: value.wikiRole ?? null,
@@ -7496,31 +7639,31 @@ var agentMarkdownFileSchema = import_zod17.z.preprocess(
7496
7639
  url: value.url ?? null
7497
7640
  }))
7498
7641
  );
7499
- var agentMarkdownFilesSchema = import_zod17.z.array(agentMarkdownFileSchema);
7500
- var agentMarkdownMutationDataSchema = import_zod17.z.union([
7642
+ var agentMarkdownFilesSchema = import_zod18.z.array(agentMarkdownFileSchema);
7643
+ var agentMarkdownMutationDataSchema = import_zod18.z.union([
7501
7644
  agentMarkdownFileSchema,
7502
- import_zod17.z.object({ files: agentMarkdownFilesSchema })
7645
+ import_zod18.z.object({ files: agentMarkdownFilesSchema })
7503
7646
  ]);
7504
- var osmdSearchCandidateSchema = import_zod17.z.preprocess(
7647
+ var osmdSearchCandidateSchema = import_zod18.z.preprocess(
7505
7648
  normalizeAgentMarkdownJsonKeys,
7506
- import_zod17.z.object({
7507
- path: import_zod17.z.string(),
7649
+ import_zod18.z.object({
7650
+ path: import_zod18.z.string(),
7508
7651
  source: sourceSchema,
7509
7652
  access: accessSchema,
7510
7653
  owner: ownerSchema,
7511
- wikiRole: import_zod17.z.string().nullable().optional(),
7512
- formatVersion: import_zod17.z.string().nullable().optional(),
7513
- parentRef: import_zod17.z.string().nullable().optional(),
7514
- exists: import_zod17.z.boolean(),
7515
- agentChildrenAllowed: import_zod17.z.boolean(),
7516
- title: import_zod17.z.string(),
7517
- label: import_zod17.z.string(),
7518
- snippet: import_zod17.z.string().nullable().optional(),
7519
- rank: import_zod17.z.number().int(),
7520
- matchReason: import_zod17.z.string().nullable().optional(),
7521
- toolKey: import_zod17.z.string().nullable().optional(),
7522
- nodeKey: import_zod17.z.string().nullable().optional(),
7523
- nodeKind: import_zod17.z.string().nullable().optional()
7654
+ wikiRole: import_zod18.z.string().nullable().optional(),
7655
+ formatVersion: import_zod18.z.string().nullable().optional(),
7656
+ parentRef: import_zod18.z.string().nullable().optional(),
7657
+ exists: import_zod18.z.boolean(),
7658
+ agentChildrenAllowed: import_zod18.z.boolean(),
7659
+ title: import_zod18.z.string(),
7660
+ label: import_zod18.z.string(),
7661
+ snippet: import_zod18.z.string().nullable().optional(),
7662
+ rank: import_zod18.z.number().int(),
7663
+ matchReason: import_zod18.z.string().nullable().optional(),
7664
+ toolKey: import_zod18.z.string().nullable().optional(),
7665
+ nodeKey: import_zod18.z.string().nullable().optional(),
7666
+ nodeKind: import_zod18.z.string().nullable().optional()
7524
7667
  }).transform((value) => ({
7525
7668
  ...value,
7526
7669
  wikiRole: value.wikiRole ?? null,
@@ -7533,26 +7676,26 @@ var osmdSearchCandidateSchema = import_zod17.z.preprocess(
7533
7676
  nodeKind: value.nodeKind ?? null
7534
7677
  }))
7535
7678
  );
7536
- var osmdSearchResultSchema = import_zod17.z.preprocess(
7679
+ var osmdSearchResultSchema = import_zod18.z.preprocess(
7537
7680
  normalizeAgentMarkdownJsonKeys,
7538
- import_zod17.z.object({
7539
- query: import_zod17.z.string(),
7540
- scope: import_zod17.z.string(),
7541
- count: import_zod17.z.number().int().min(0),
7542
- candidates: import_zod17.z.array(osmdSearchCandidateSchema)
7681
+ import_zod18.z.object({
7682
+ query: import_zod18.z.string(),
7683
+ scope: import_zod18.z.string(),
7684
+ count: import_zod18.z.number().int().min(0),
7685
+ candidates: import_zod18.z.array(osmdSearchCandidateSchema)
7543
7686
  })
7544
7687
  );
7545
- var osmdWikiLintIssueSchema = import_zod17.z.preprocess(
7688
+ var osmdWikiLintIssueSchema = import_zod18.z.preprocess(
7546
7689
  normalizeAgentMarkdownJsonKeys,
7547
- import_zod17.z.object({
7548
- code: import_zod17.z.string(),
7549
- severity: import_zod17.z.string(),
7550
- path: import_zod17.z.string(),
7551
- source: import_zod17.z.string().nullable().optional(),
7552
- parentRef: import_zod17.z.string().nullable().optional(),
7553
- message: import_zod17.z.string(),
7554
- suggestedAction: import_zod17.z.string().nullable().optional(),
7555
- canAutoFix: import_zod17.z.boolean()
7690
+ import_zod18.z.object({
7691
+ code: import_zod18.z.string(),
7692
+ severity: import_zod18.z.string(),
7693
+ path: import_zod18.z.string(),
7694
+ source: import_zod18.z.string().nullable().optional(),
7695
+ parentRef: import_zod18.z.string().nullable().optional(),
7696
+ message: import_zod18.z.string(),
7697
+ suggestedAction: import_zod18.z.string().nullable().optional(),
7698
+ canAutoFix: import_zod18.z.boolean()
7556
7699
  }).transform((value) => ({
7557
7700
  ...value,
7558
7701
  source: value.source ?? null,
@@ -7560,37 +7703,37 @@ var osmdWikiLintIssueSchema = import_zod17.z.preprocess(
7560
7703
  suggestedAction: value.suggestedAction ?? null
7561
7704
  }))
7562
7705
  );
7563
- var osmdWikiLintResultSchema = import_zod17.z.preprocess(
7706
+ var osmdWikiLintResultSchema = import_zod18.z.preprocess(
7564
7707
  normalizeAgentMarkdownJsonKeys,
7565
- import_zod17.z.object({
7566
- status: import_zod17.z.string(),
7567
- summary: import_zod17.z.object({
7568
- totalIssues: import_zod17.z.number().int().min(0),
7569
- errors: import_zod17.z.number().int().min(0),
7570
- warnings: import_zod17.z.number().int().min(0),
7571
- suggestions: import_zod17.z.number().int().min(0)
7708
+ import_zod18.z.object({
7709
+ status: import_zod18.z.string(),
7710
+ summary: import_zod18.z.object({
7711
+ totalIssues: import_zod18.z.number().int().min(0),
7712
+ errors: import_zod18.z.number().int().min(0),
7713
+ warnings: import_zod18.z.number().int().min(0),
7714
+ suggestions: import_zod18.z.number().int().min(0)
7572
7715
  }),
7573
- issues: import_zod17.z.array(osmdWikiLintIssueSchema)
7716
+ issues: import_zod18.z.array(osmdWikiLintIssueSchema)
7574
7717
  })
7575
7718
  );
7576
- var nullableCountSchema = import_zod17.z.preprocess(
7719
+ var nullableCountSchema = import_zod18.z.preprocess(
7577
7720
  (value) => value === void 0 || value === null || value === "" ? null : value,
7578
- import_zod17.z.coerce.number().int().min(0).nullable()
7721
+ import_zod18.z.coerce.number().int().min(0).nullable()
7579
7722
  ).catch(null);
7580
- var osmdMemoryQualityIssueSchema = import_zod17.z.preprocess(
7723
+ var osmdMemoryQualityIssueSchema = import_zod18.z.preprocess(
7581
7724
  normalizeAgentMarkdownJsonKeys,
7582
- import_zod17.z.object({
7583
- code: import_zod17.z.string().nullable().optional(),
7584
- issueCode: import_zod17.z.string().nullable().optional(),
7585
- path: import_zod17.z.string().nullable().optional(),
7586
- parentRef: import_zod17.z.string().nullable().optional(),
7587
- dimension: import_zod17.z.string().nullable().optional(),
7588
- evidence: import_zod17.z.string().nullable().optional(),
7589
- evidenceSnippet: import_zod17.z.string().nullable().optional(),
7590
- message: import_zod17.z.string().nullable().optional(),
7591
- severity: import_zod17.z.string().nullable().optional(),
7592
- suggestedAction: import_zod17.z.string().nullable().optional(),
7593
- canAutoFix: import_zod17.z.boolean().nullable().optional()
7725
+ import_zod18.z.object({
7726
+ code: import_zod18.z.string().nullable().optional(),
7727
+ issueCode: import_zod18.z.string().nullable().optional(),
7728
+ path: import_zod18.z.string().nullable().optional(),
7729
+ parentRef: import_zod18.z.string().nullable().optional(),
7730
+ dimension: import_zod18.z.string().nullable().optional(),
7731
+ evidence: import_zod18.z.string().nullable().optional(),
7732
+ evidenceSnippet: import_zod18.z.string().nullable().optional(),
7733
+ message: import_zod18.z.string().nullable().optional(),
7734
+ severity: import_zod18.z.string().nullable().optional(),
7735
+ suggestedAction: import_zod18.z.string().nullable().optional(),
7736
+ canAutoFix: import_zod18.z.boolean().nullable().optional()
7594
7737
  }).passthrough().transform((value) => ({
7595
7738
  ...value,
7596
7739
  code: value.code ?? value.issueCode ?? "unknown_issue",
@@ -7605,16 +7748,16 @@ var osmdMemoryQualityIssueSchema = import_zod17.z.preprocess(
7605
7748
  canAutoFix: value.canAutoFix === true ? true : false
7606
7749
  }))
7607
7750
  );
7608
- var osmdMemoryQualityOverlaySchema = import_zod17.z.preprocess(
7751
+ var osmdMemoryQualityOverlaySchema = import_zod18.z.preprocess(
7609
7752
  normalizeAgentMarkdownJsonKeys,
7610
- import_zod17.z.object({
7611
- path: import_zod17.z.string().nullable().optional(),
7612
- parentRef: import_zod17.z.string().nullable().optional(),
7613
- status: import_zod17.z.string().nullable().optional(),
7614
- score: import_zod17.z.union([import_zod17.z.number(), import_zod17.z.string()]).nullable().optional(),
7615
- overallScore: import_zod17.z.union([import_zod17.z.number(), import_zod17.z.string()]).nullable().optional(),
7616
- dimensions: import_zod17.z.unknown().nullable().optional(),
7617
- issues: import_zod17.z.array(osmdMemoryQualityIssueSchema).optional()
7753
+ import_zod18.z.object({
7754
+ path: import_zod18.z.string().nullable().optional(),
7755
+ parentRef: import_zod18.z.string().nullable().optional(),
7756
+ status: import_zod18.z.string().nullable().optional(),
7757
+ score: import_zod18.z.union([import_zod18.z.number(), import_zod18.z.string()]).nullable().optional(),
7758
+ overallScore: import_zod18.z.union([import_zod18.z.number(), import_zod18.z.string()]).nullable().optional(),
7759
+ dimensions: import_zod18.z.unknown().nullable().optional(),
7760
+ issues: import_zod18.z.array(osmdMemoryQualityIssueSchema).optional()
7618
7761
  }).passthrough().transform((value) => ({
7619
7762
  ...value,
7620
7763
  path: value.path ?? null,
@@ -7626,9 +7769,9 @@ var osmdMemoryQualityOverlaySchema = import_zod17.z.preprocess(
7626
7769
  issues: value.issues ?? []
7627
7770
  }))
7628
7771
  );
7629
- var osmdMemoryQualitySummarySchema = import_zod17.z.preprocess(
7772
+ var osmdMemoryQualitySummarySchema = import_zod18.z.preprocess(
7630
7773
  normalizeAgentMarkdownJsonKeys,
7631
- import_zod17.z.object({
7774
+ import_zod18.z.object({
7632
7775
  evaluatedCount: nullableCountSchema.optional(),
7633
7776
  passCount: nullableCountSchema.optional(),
7634
7777
  warnCount: nullableCountSchema.optional(),
@@ -7646,19 +7789,19 @@ var osmdMemoryQualitySummarySchema = import_zod17.z.preprocess(
7646
7789
  failCount: value.failCount ?? value.failures ?? null
7647
7790
  }))
7648
7791
  );
7649
- var osmdMemoryQualityResultSchema = import_zod17.z.preprocess(
7792
+ var osmdMemoryQualityResultSchema = import_zod18.z.preprocess(
7650
7793
  normalizeAgentMarkdownJsonKeys,
7651
- import_zod17.z.object({
7652
- status: import_zod17.z.string(),
7653
- scope: import_zod17.z.string().nullable().optional(),
7794
+ import_zod18.z.object({
7795
+ status: import_zod18.z.string(),
7796
+ scope: import_zod18.z.string().nullable().optional(),
7654
7797
  evaluatedCount: nullableCountSchema.optional(),
7655
7798
  passCount: nullableCountSchema.optional(),
7656
7799
  warnCount: nullableCountSchema.optional(),
7657
7800
  failCount: nullableCountSchema.optional(),
7658
7801
  summary: osmdMemoryQualitySummarySchema.optional(),
7659
- weakestOverlays: import_zod17.z.array(osmdMemoryQualityOverlaySchema).optional(),
7660
- issues: import_zod17.z.array(osmdMemoryQualityIssueSchema).optional(),
7661
- scores: import_zod17.z.array(osmdMemoryQualityOverlaySchema).optional()
7802
+ weakestOverlays: import_zod18.z.array(osmdMemoryQualityOverlaySchema).optional(),
7803
+ issues: import_zod18.z.array(osmdMemoryQualityIssueSchema).optional(),
7804
+ scores: import_zod18.z.array(osmdMemoryQualityOverlaySchema).optional()
7662
7805
  }).passthrough().transform((value) => {
7663
7806
  const summary = isRecord5(value.summary) ? value.summary : null;
7664
7807
  return {
@@ -7682,24 +7825,24 @@ function normalizeOsmdIngestFileRecordInput(value) {
7682
7825
  }
7683
7826
  return normalized;
7684
7827
  }
7685
- var osmdIngestFileRecordSchema = import_zod17.z.preprocess(
7828
+ var osmdIngestFileRecordSchema = import_zod18.z.preprocess(
7686
7829
  normalizeOsmdIngestFileRecordInput,
7687
- import_zod17.z.object({
7688
- path: import_zod17.z.string(),
7689
- source: import_zod17.z.string().nullable().optional(),
7690
- access: import_zod17.z.string().nullable().optional(),
7691
- owner: import_zod17.z.string().nullable().optional(),
7692
- parentRef: import_zod17.z.string().nullable().optional(),
7693
- exists: import_zod17.z.boolean().nullable().optional(),
7694
- canCreate: import_zod17.z.boolean().nullable().optional(),
7695
- canUpdate: import_zod17.z.boolean().nullable().optional(),
7696
- canAppend: import_zod17.z.boolean().nullable().optional(),
7697
- wikiRole: import_zod17.z.string().nullable().optional(),
7698
- formatVersion: import_zod17.z.string().nullable().optional(),
7699
- createdAt: import_zod17.z.string().nullable().optional(),
7700
- updatedAt: import_zod17.z.string().nullable().optional(),
7701
- suggestedAction: import_zod17.z.string().nullable().optional(),
7702
- errorCode: import_zod17.z.string().nullable().optional()
7830
+ import_zod18.z.object({
7831
+ path: import_zod18.z.string(),
7832
+ source: import_zod18.z.string().nullable().optional(),
7833
+ access: import_zod18.z.string().nullable().optional(),
7834
+ owner: import_zod18.z.string().nullable().optional(),
7835
+ parentRef: import_zod18.z.string().nullable().optional(),
7836
+ exists: import_zod18.z.boolean().nullable().optional(),
7837
+ canCreate: import_zod18.z.boolean().nullable().optional(),
7838
+ canUpdate: import_zod18.z.boolean().nullable().optional(),
7839
+ canAppend: import_zod18.z.boolean().nullable().optional(),
7840
+ wikiRole: import_zod18.z.string().nullable().optional(),
7841
+ formatVersion: import_zod18.z.string().nullable().optional(),
7842
+ createdAt: import_zod18.z.string().nullable().optional(),
7843
+ updatedAt: import_zod18.z.string().nullable().optional(),
7844
+ suggestedAction: import_zod18.z.string().nullable().optional(),
7845
+ errorCode: import_zod18.z.string().nullable().optional()
7703
7846
  }).passthrough().transform((value) => ({
7704
7847
  ...value,
7705
7848
  source: value.source ?? null,
@@ -7718,17 +7861,17 @@ var osmdIngestFileRecordSchema = import_zod17.z.preprocess(
7718
7861
  errorCode: value.errorCode ?? null
7719
7862
  }))
7720
7863
  );
7721
- var osmdIngestResultSchema = import_zod17.z.preprocess(
7864
+ var osmdIngestResultSchema = import_zod18.z.preprocess(
7722
7865
  normalizeAgentMarkdownJsonKeys,
7723
- import_zod17.z.object({
7724
- rawSourceId: import_zod17.z.union([import_zod17.z.string(), import_zod17.z.number()]).nullable().optional(),
7725
- sourceSummaryPath: import_zod17.z.string().nullable().optional(),
7866
+ import_zod18.z.object({
7867
+ rawSourceId: import_zod18.z.union([import_zod18.z.string(), import_zod18.z.number()]).nullable().optional(),
7868
+ sourceSummaryPath: import_zod18.z.string().nullable().optional(),
7726
7869
  sourceSummaryFile: osmdIngestFileRecordSchema.nullable().optional(),
7727
- slug: import_zod17.z.string().nullable().optional(),
7728
- runLint: import_zod17.z.boolean().nullable().optional(),
7729
- createdFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7730
- updatedFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7731
- skippedUpdates: import_zod17.z.array(import_zod17.z.unknown()).optional(),
7870
+ slug: import_zod18.z.string().nullable().optional(),
7871
+ runLint: import_zod18.z.boolean().nullable().optional(),
7872
+ createdFiles: import_zod18.z.array(osmdIngestFileRecordSchema).optional(),
7873
+ updatedFiles: import_zod18.z.array(osmdIngestFileRecordSchema).optional(),
7874
+ skippedUpdates: import_zod18.z.array(import_zod18.z.unknown()).optional(),
7732
7875
  lintResult: osmdWikiLintResultSchema.nullable().optional()
7733
7876
  }).passthrough().transform((value) => ({
7734
7877
  ...value,
@@ -7743,127 +7886,37 @@ var osmdIngestResultSchema = import_zod17.z.preprocess(
7743
7886
  lintResult: value.lintResult ?? null
7744
7887
  }))
7745
7888
  );
7746
- var osmdPhantomNotificationSchema = import_zod17.z.preprocess(
7747
- normalizeAgentMarkdownJsonKeys,
7748
- import_zod17.z.object({
7749
- id: import_zod17.z.union([import_zod17.z.string(), import_zod17.z.number()]).nullable().optional(),
7750
- status: import_zod17.z.string().nullable().optional()
7751
- }).passthrough().transform((value) => ({
7752
- ...value,
7753
- id: value.id === void 0 || value.id === null ? null : String(value.id),
7754
- status: value.status ?? null
7755
- }))
7756
- );
7757
- var osmdPhantomResultSchema = import_zod17.z.preprocess(
7758
- normalizeOsmdPhantomResultKeys,
7759
- import_zod17.z.object({
7760
- runId: import_zod17.z.union([import_zod17.z.string(), import_zod17.z.number()]).nullable().optional(),
7761
- organizationId: import_zod17.z.union([import_zod17.z.string(), import_zod17.z.number()]).nullable().optional(),
7762
- triggerType: import_zod17.z.string().nullable().optional(),
7763
- scope: import_zod17.z.string().nullable().optional(),
7764
- subtree: import_zod17.z.string().nullable().optional(),
7765
- status: import_zod17.z.string().nullable().optional(),
7766
- createdAt: import_zod17.z.string().nullable().optional(),
7767
- updatedAt: import_zod17.z.string().nullable().optional(),
7768
- startedAt: import_zod17.z.string().nullable().optional(),
7769
- completedAt: import_zod17.z.string().nullable().optional(),
7770
- countSemantics: import_zod17.z.unknown().nullable().optional(),
7771
- scannedFileCount: nullableCountSchema,
7772
- changedFileCount: nullableCountSchema,
7773
- unchangedFileCount: nullableCountSchema,
7774
- updatedFileCount: nullableCountSchema,
7775
- skippedFileCount: nullableCountSchema,
7776
- lintStatus: import_zod17.z.string().nullable().optional(),
7777
- errorCount: nullableCountSchema,
7778
- warningCount: nullableCountSchema,
7779
- reportPath: import_zod17.z.string().nullable().optional(),
7780
- plannedReads: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7781
- plannedReadFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7782
- plannedWrites: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7783
- plannedWriteFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7784
- changedFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7785
- unchangedFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7786
- updatedFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7787
- skippedFiles: import_zod17.z.array(osmdIngestFileRecordSchema).optional(),
7788
- lintPlan: import_zod17.z.unknown().nullable().optional(),
7789
- lintSummary: import_zod17.z.unknown().nullable().optional(),
7790
- lintResult: osmdWikiLintResultSchema.nullable().optional(),
7791
- notification: osmdPhantomNotificationSchema.nullable().optional(),
7792
- notificationId: import_zod17.z.union([import_zod17.z.string(), import_zod17.z.number()]).nullable().optional(),
7793
- notificationStatus: import_zod17.z.string().nullable().optional()
7794
- }).passthrough().transform((value) => {
7795
- const lintResultSummary = isRecord5(value.lintResult?.summary) ? value.lintResult.summary : null;
7796
- const lintSummary = isRecord5(value.lintSummary) ? value.lintSummary : null;
7797
- const notification = value.notification ?? (value.notificationId !== void 0 || value.notificationStatus !== void 0 ? {
7798
- id: value.notificationId === void 0 || value.notificationId === null ? null : String(value.notificationId),
7799
- status: value.notificationStatus ?? null
7800
- } : null);
7801
- return {
7802
- ...value,
7803
- runId: value.runId === void 0 || value.runId === null ? null : String(value.runId),
7804
- organizationId: value.organizationId === void 0 || value.organizationId === null ? null : String(value.organizationId),
7805
- triggerType: value.triggerType ?? null,
7806
- scope: value.scope ?? null,
7807
- subtree: value.subtree ?? null,
7808
- status: value.status ?? null,
7809
- createdAt: value.createdAt ?? null,
7810
- updatedAt: value.updatedAt ?? null,
7811
- startedAt: value.startedAt ?? null,
7812
- completedAt: value.completedAt ?? null,
7813
- countSemantics: value.countSemantics ?? null,
7814
- scannedFileCount: value.scannedFileCount,
7815
- changedFileCount: value.changedFileCount,
7816
- unchangedFileCount: value.unchangedFileCount,
7817
- updatedFileCount: value.updatedFileCount,
7818
- skippedFileCount: value.skippedFileCount,
7819
- lintStatus: value.lintStatus ?? (typeof value.lintResult?.status === "string" ? value.lintResult.status : null) ?? (typeof lintSummary?.status === "string" ? lintSummary.status : null),
7820
- errorCount: value.errorCount ?? countFromRecord(lintResultSummary, "errors") ?? countFromRecord(lintSummary, "errors"),
7821
- warningCount: value.warningCount ?? countFromRecord(lintResultSummary, "warnings") ?? countFromRecord(lintSummary, "warnings"),
7822
- reportPath: value.reportPath ?? null,
7823
- plannedReads: value.plannedReads ?? value.plannedReadFiles ?? [],
7824
- plannedWrites: value.plannedWrites ?? value.plannedWriteFiles ?? [],
7825
- changedFiles: value.changedFiles ?? [],
7826
- unchangedFiles: dedupeOsmdFileRecords(value.unchangedFiles ?? []),
7827
- updatedFiles: value.updatedFiles ?? [],
7828
- skippedFiles: dedupeOsmdFileRecords(value.skippedFiles ?? []),
7829
- lintPlan: value.lintPlan ?? null,
7830
- lintSummary: value.lintSummary ?? null,
7831
- lintResult: value.lintResult ?? null,
7832
- notification
7833
- };
7834
- })
7835
- );
7836
- var mutationPayloadSchema = import_zod17.z.object({
7837
- ok: import_zod17.z.boolean(),
7838
- status: import_zod17.z.number(),
7839
- errorCode: import_zod17.z.string().nullable().optional(),
7840
- data: import_zod17.z.unknown().nullable().optional(),
7841
- errors: import_zod17.z.unknown().nullable().optional()
7889
+ var mutationPayloadSchema = import_zod18.z.object({
7890
+ ok: import_zod18.z.boolean(),
7891
+ status: import_zod18.z.number(),
7892
+ errorCode: import_zod18.z.string().nullable().optional(),
7893
+ data: import_zod18.z.unknown().nullable().optional(),
7894
+ errors: import_zod18.z.unknown().nullable().optional()
7842
7895
  });
7843
- var markdownTreeNodeSchema = import_zod17.z.lazy(
7844
- () => import_zod17.z.object({
7845
- toolKey: import_zod17.z.string(),
7846
- nodeKey: import_zod17.z.string(),
7847
- nodeKind: import_zod17.z.string(),
7848
- runtimeLabel: import_zod17.z.string(),
7849
- path: import_zod17.z.string().nullable().optional().transform((value) => value ?? null),
7896
+ var markdownTreeNodeSchema = import_zod18.z.lazy(
7897
+ () => import_zod18.z.object({
7898
+ toolKey: import_zod18.z.string(),
7899
+ nodeKey: import_zod18.z.string(),
7900
+ nodeKind: import_zod18.z.string(),
7901
+ runtimeLabel: import_zod18.z.string(),
7902
+ path: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7850
7903
  source: sourceSchema,
7851
7904
  access: accessSchema,
7852
7905
  owner: ownerSchema,
7853
- parentRef: import_zod17.z.string().nullable().optional().transform((value) => value ?? null),
7854
- agentChildrenAllowed: import_zod17.z.boolean(),
7855
- exists: import_zod17.z.boolean(),
7856
- resolvedScope: import_zod17.z.object({
7857
- parentId: import_zod17.z.string().nullable().optional().transform((value) => value ?? null),
7858
- recordId: import_zod17.z.string().nullable().optional().transform((value) => value ?? null),
7859
- memberId: import_zod17.z.string().nullable().optional().transform((value) => value ?? null),
7860
- teamId: import_zod17.z.string().nullable().optional().transform((value) => value ?? null),
7861
- contentType: import_zod17.z.string().nullable().optional().transform((value) => value ?? null)
7906
+ parentRef: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7907
+ agentChildrenAllowed: import_zod18.z.boolean(),
7908
+ exists: import_zod18.z.boolean(),
7909
+ resolvedScope: import_zod18.z.object({
7910
+ parentId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7911
+ recordId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7912
+ memberId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7913
+ teamId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7914
+ contentType: import_zod18.z.string().nullable().optional().transform((value) => value ?? null)
7862
7915
  }),
7863
- isLeaf: import_zod17.z.boolean(),
7864
- treeView: import_zod17.z.boolean(),
7865
- details: import_zod17.z.unknown().nullable(),
7866
- children: import_zod17.z.array(markdownTreeNodeSchema).optional().transform((value) => value ?? [])
7916
+ isLeaf: import_zod18.z.boolean(),
7917
+ treeView: import_zod18.z.boolean(),
7918
+ details: import_zod18.z.unknown().nullable(),
7919
+ children: import_zod18.z.array(markdownTreeNodeSchema).optional().transform((value) => value ?? [])
7867
7920
  })
7868
7921
  );
7869
7922
  var AGENT_MARKDOWN_FILE_SELECTION = `{
@@ -8124,86 +8177,6 @@ function normalizeAgentMarkdownJsonKeys(value) {
8124
8177
  }
8125
8178
  return normalized;
8126
8179
  }
8127
- function firstPresent(...values) {
8128
- for (const value of values) {
8129
- if (value !== void 0 && value !== null) {
8130
- return value;
8131
- }
8132
- }
8133
- return void 0;
8134
- }
8135
- function normalizeOsmdPhantomResultKeys(value) {
8136
- const normalized = normalizeAgentMarkdownJsonKeys(value);
8137
- if (!isRecord5(normalized)) {
8138
- return normalized;
8139
- }
8140
- const run = isRecord5(normalized.run) ? normalizeAgentMarkdownJsonKeys(normalized.run) : null;
8141
- const result = run ? { ...run, ...normalized } : { ...normalized };
8142
- const runField = (key) => run ? run[key] : void 0;
8143
- const assignFirstPresent = (target, ...values) => {
8144
- const value2 = firstPresent(result[target], ...values);
8145
- if (value2 !== void 0) {
8146
- result[target] = value2;
8147
- }
8148
- };
8149
- assignFirstPresent("runId", normalized.id, runField("runId"), runField("id"));
8150
- assignFirstPresent("organizationId", runField("organizationId"));
8151
- assignFirstPresent("triggerType", runField("triggerType"));
8152
- assignFirstPresent("scope", runField("scope"));
8153
- assignFirstPresent("status", runField("status"));
8154
- assignFirstPresent("createdAt", runField("createdAt"));
8155
- assignFirstPresent("updatedAt", runField("updatedAt"));
8156
- assignFirstPresent("startedAt", runField("startedAt"));
8157
- assignFirstPresent("completedAt", runField("completedAt"));
8158
- assignFirstPresent("countSemantics", runField("countSemantics"));
8159
- assignFirstPresent(
8160
- "scannedFileCount",
8161
- normalized.scanned,
8162
- runField("scannedFileCount"),
8163
- runField("scanned")
8164
- );
8165
- assignFirstPresent(
8166
- "changedFileCount",
8167
- normalized.changed,
8168
- runField("changedFileCount"),
8169
- runField("changed")
8170
- );
8171
- assignFirstPresent(
8172
- "unchangedFileCount",
8173
- normalized.unchanged,
8174
- runField("unchangedFileCount"),
8175
- runField("unchanged")
8176
- );
8177
- assignFirstPresent(
8178
- "updatedFileCount",
8179
- normalized.updated,
8180
- runField("updatedFileCount"),
8181
- runField("updated")
8182
- );
8183
- assignFirstPresent(
8184
- "skippedFileCount",
8185
- normalized.skipped,
8186
- runField("skippedFileCount"),
8187
- runField("skipped")
8188
- );
8189
- assignFirstPresent("lintStatus", runField("lintStatus"));
8190
- assignFirstPresent("errorCount", runField("errorCount"));
8191
- assignFirstPresent("warningCount", runField("warningCount"));
8192
- assignFirstPresent("reportPath", runField("reportPath"));
8193
- assignFirstPresent("plannedReads", runField("plannedReads"), runField("plannedReadFiles"));
8194
- assignFirstPresent("plannedWrites", runField("plannedWrites"), runField("plannedWriteFiles"));
8195
- assignFirstPresent("changedFiles", runField("changedFiles"));
8196
- assignFirstPresent("unchangedFiles", runField("unchangedFiles"));
8197
- assignFirstPresent("updatedFiles", runField("updatedFiles"));
8198
- assignFirstPresent("skippedFiles", runField("skippedFiles"));
8199
- assignFirstPresent("lintPlan", runField("lintPlan"));
8200
- assignFirstPresent("lintSummary", runField("lintSummary"));
8201
- assignFirstPresent("lintResult", runField("lintResult"));
8202
- assignFirstPresent("notification", runField("notification"));
8203
- assignFirstPresent("notificationId", runField("notificationId"));
8204
- assignFirstPresent("notificationStatus", runField("notificationStatus"));
8205
- return result;
8206
- }
8207
8180
  function buildSuccessEnvelope(params) {
8208
8181
  return {
8209
8182
  ok: true,
@@ -8623,51 +8596,6 @@ async function runOsmdIngestFlow(params) {
8623
8596
  })
8624
8597
  });
8625
8598
  }
8626
- async function runOsmdPhantomPhaseOne(params) {
8627
- const runtimeOptions = {
8628
- ...params.runtimeOptions,
8629
- timeoutMs: params.runtimeOptions.timeoutMs ?? defaultOsmdPhantomTimeoutMs
8630
- };
8631
- const result = await requestOsmdMutationPayload({
8632
- command: params.command,
8633
- operationName: "RunPhantomOsmdMaintenance",
8634
- operationType: "mutation",
8635
- runtimeOptions,
8636
- field: "run_phantom_osmd_maintenance",
8637
- variables: {
8638
- organization_id: params.organizationId,
8639
- dry_run: params.dryRun
8640
- }
8641
- });
8642
- const parsedData = osmdPhantomResultSchema.safeParse(
8643
- normalizeAgentMarkdownJsonKeys(result.payload.data)
8644
- );
8645
- if (!parsedData.success) {
8646
- return printInvalidPayloadError({
8647
- command: params.command,
8648
- requestId: result.requestId,
8649
- issues: parsedData.error.issues
8650
- });
8651
- }
8652
- const data = {
8653
- ...parsedData.data,
8654
- organizationId: parsedData.data.organizationId ?? params.organizationId,
8655
- triggerType: parsedData.data.triggerType ?? "manual"
8656
- };
8657
- if (params.readable) {
8658
- return printTextAndExit({
8659
- text: formatOsmdPhantomHuman(data, params.dryRun)
8660
- });
8661
- }
8662
- return printEnvelopeAndExit({
8663
- envelope: buildSuccessEnvelope({
8664
- command: params.command,
8665
- status: result.payload.status,
8666
- data,
8667
- requestId: result.requestId
8668
- })
8669
- });
8670
- }
8671
8599
  function normalizeAgentFilePath(file) {
8672
8600
  const trimmed = nonEmptyString3.parse(file).trim().replace(/^\/+|\/+$/g, "");
8673
8601
  const fileName = trimmed.startsWith(".agent/") ? trimmed.slice(".agent/".length) : trimmed;
@@ -9078,62 +9006,6 @@ function formatIngestFileList(files) {
9078
9006
  return `- ${path}${action}`;
9079
9007
  });
9080
9008
  }
9081
- function fileRecordPath(file) {
9082
- return typeof file.path === "string" && file.path.trim() !== "" ? file.path : null;
9083
- }
9084
- function isAgentNotesWrite(file) {
9085
- const path = fileRecordPath(file);
9086
- return path !== null && /(?:^|\/)\.agent\/notes\.md$/.test(path);
9087
- }
9088
- function formatNotesWriteSummary(files) {
9089
- const notesWrites = files.filter(isAgentNotesWrite);
9090
- if (notesWrites.length === 0) {
9091
- return ["notes.md writes: none"];
9092
- }
9093
- return ["notes.md writes:", ...formatIngestFileList(notesWrites)];
9094
- }
9095
- function skippedReasonForFile(file) {
9096
- for (const key of ["reason", "skipReason", "errorCode", "suggestedAction", "status"]) {
9097
- const value = file[key];
9098
- if (typeof value === "string" && value.trim() !== "") {
9099
- return value;
9100
- }
9101
- }
9102
- return "unspecified";
9103
- }
9104
- function formatSkippedFilesByReason(files) {
9105
- if (files.length === 0) {
9106
- return ["- none"];
9107
- }
9108
- const groups = /* @__PURE__ */ new Map();
9109
- for (const file of files) {
9110
- const reason = skippedReasonForFile(file);
9111
- const existing = groups.get(reason) ?? [];
9112
- existing.push(file);
9113
- groups.set(reason, existing);
9114
- }
9115
- const lines = [];
9116
- for (const [reason, records] of groups.entries()) {
9117
- lines.push(`- ${reason}`);
9118
- for (const record of records) {
9119
- lines.push(` - ${fileRecordPath(record) ?? "-"}`);
9120
- }
9121
- }
9122
- return lines;
9123
- }
9124
- function dedupeOsmdFileRecords(files) {
9125
- const seen = /* @__PURE__ */ new Set();
9126
- const deduped = [];
9127
- for (const file of files) {
9128
- const key = file.path;
9129
- if (typeof key !== "string" || key.trim() === "" || seen.has(key)) {
9130
- continue;
9131
- }
9132
- seen.add(key);
9133
- deduped.push(file);
9134
- }
9135
- return deduped;
9136
- }
9137
9009
  function formatSkippedUpdateList(skippedUpdates) {
9138
9010
  if (skippedUpdates.length === 0) {
9139
9011
  return ["- none"];
@@ -9172,72 +9044,6 @@ function formatOsmdIngestHuman(data) {
9172
9044
  function formatNullableNumberHumanField(value) {
9173
9045
  return typeof value === "number" ? String(value) : "-";
9174
9046
  }
9175
- function formatNotificationHuman(notification) {
9176
- if (!notification) {
9177
- return "-";
9178
- }
9179
- const id = formatNullableHumanField(notification.id);
9180
- const status = formatNullableHumanField(notification.status);
9181
- return `id=${id} status=${status}`;
9182
- }
9183
- function formatPhantomTimestampLines(data) {
9184
- const lines = [];
9185
- if (data.startedAt) {
9186
- lines.push(`Started at: ${data.startedAt}`);
9187
- }
9188
- if (data.completedAt) {
9189
- lines.push(`Completed at: ${data.completedAt}`);
9190
- }
9191
- if (data.createdAt) {
9192
- lines.push(`Created at: ${data.createdAt}`);
9193
- }
9194
- if (data.updatedAt) {
9195
- lines.push(`Updated at: ${data.updatedAt}`);
9196
- }
9197
- return lines;
9198
- }
9199
- function formatOsmdPhantomHuman(data, dryRun) {
9200
- const lines = [
9201
- dryRun ? "Phantom Phase 1 plan" : "Phantom Phase 1 run",
9202
- `Run ID: ${formatNullableHumanField(data.runId)}`,
9203
- `Status: ${formatNullableHumanField(data.status)}`,
9204
- ...formatPhantomTimestampLines(data),
9205
- `Organization ID: ${formatNullableHumanField(data.organizationId)}`,
9206
- `Trigger type: ${formatNullableHumanField(data.triggerType)}`,
9207
- `Scope: ${formatNullableHumanField(data.scope ?? data.subtree)}`,
9208
- ...data.countSemantics === null || data.countSemantics === void 0 ? [] : [`Count semantics: ${formatUnknownHuman(data.countSemantics)}`],
9209
- `Reviewed OSMD/agent markdown entries: ${formatNullableNumberHumanField(data.scannedFileCount)}`,
9210
- `Changed entries: ${formatNullableNumberHumanField(data.changedFileCount)}`,
9211
- `Unchanged entries: ${formatNullableNumberHumanField(data.unchangedFileCount)}`,
9212
- `Updated files: ${formatNullableNumberHumanField(data.updatedFileCount)}`,
9213
- `Skipped entries: ${formatNullableNumberHumanField(data.skippedFileCount)}`,
9214
- `Lint status: ${formatNullableHumanField(data.lintStatus)}`,
9215
- `Errors: ${formatNullableNumberHumanField(data.errorCount)}`,
9216
- `Warnings: ${formatNullableNumberHumanField(data.warningCount)}`,
9217
- `Report path: ${formatNullableHumanField(data.reportPath)}`,
9218
- `Notification: ${formatNotificationHuman(data.notification)}`,
9219
- "",
9220
- "Planned reads:",
9221
- ...formatIngestFileList(data.plannedReads),
9222
- "",
9223
- "Planned semantic memory writes:",
9224
- ...formatIngestFileList(data.plannedWrites),
9225
- ...dryRun ? formatNotesWriteSummary(data.plannedWrites) : [],
9226
- "",
9227
- "Changed entries:",
9228
- ...formatIngestFileList(data.changedFiles),
9229
- "",
9230
- "Updated files:",
9231
- ...formatIngestFileList(data.updatedFiles),
9232
- "",
9233
- "Skipped nodes by reason:",
9234
- ...formatSkippedFilesByReason(data.skippedFiles),
9235
- "",
9236
- "Lint plan:",
9237
- formatUnknownHuman(data.lintPlan)
9238
- ];
9239
- return lines.join("\n");
9240
- }
9241
9047
  function parseSearchLimit(value) {
9242
9048
  const raw = value === void 0 || value === null || value === "" ? "10" : value;
9243
9049
  const parsed = positiveInt.safeParse(raw);
@@ -10005,18 +9811,6 @@ function registerOsmdCommands(program) {
10005
9811
  throw error;
10006
9812
  }
10007
9813
  });
10008
- const phantom = osmd.command("phantom").description("Backend-owned Phantom Phase 1 manual operations");
10009
- phantom.command("run").description("Manually run or plan Phantom Phase 1 for OSMD/agent semantic memory").option("--dry-run", "Ask backend for the Phantom Phase 1 plan without mutating").option("--readable", "Print a human-readable Phantom summary instead of JSON").action(async (opts, cmd) => {
10010
- const command = "osmd.phantom.run";
10011
- const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
10012
- return runOsmdPhantomPhaseOne({
10013
- command,
10014
- runtimeOptions,
10015
- organizationId,
10016
- dryRun: opts.dryRun === true,
10017
- readable: opts.readable === true
10018
- });
10019
- });
10020
9814
  const agent = osmd.command("agent").description(".agent markdown attached to canonical OSMD parents");
10021
9815
  agent.command("status <parent-ref> <file>").description("Show .agent file metadata without creating files").action(async (parentRef, file, _opts, cmd) => {
10022
9816
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
@@ -13012,14 +12806,14 @@ function registerMailCommands(program) {
13012
12806
  }
13013
12807
 
13014
12808
  // src/commands/phantom.ts
13015
- var import_zod18 = require("zod");
13016
- var nonNegativeInt4 = import_zod18.z.coerce.number().int().min(0);
13017
- var nullableString = import_zod18.z.string().nullable().optional().transform((value) => value ?? null);
13018
- var idString = import_zod18.z.union([import_zod18.z.string(), import_zod18.z.number()]).transform((value) => String(value));
13019
- var nullableIdString = import_zod18.z.union([import_zod18.z.string(), import_zod18.z.number()]).nullable().optional().transform(
12809
+ var import_zod19 = require("zod");
12810
+ var nonNegativeInt4 = import_zod19.z.coerce.number().int().min(0);
12811
+ var nullableString = import_zod19.z.string().nullable().optional().transform((value) => value ?? null);
12812
+ var idString = import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).transform((value) => String(value));
12813
+ var nullableIdString = import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).nullable().optional().transform(
13020
12814
  (value) => value === void 0 || value === null ? null : String(value)
13021
12815
  );
13022
- var jsonObject = import_zod18.z.record(import_zod18.z.string(), import_zod18.z.unknown());
12816
+ var jsonObject = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.unknown());
13023
12817
  var PHANTOM_LEDGER_INVENTORY_SELECTION = `{
13024
12818
  schemaVersion
13025
12819
  runsCount
@@ -13232,10 +13026,10 @@ var PHANTOM_LEDGER_KEY_ALIASES = {
13232
13026
  content_hash: "contentHash",
13233
13027
  observed_at: "observedAt"
13234
13028
  };
13235
- var phantomLedgerInventorySchema = import_zod18.z.preprocess(
13029
+ var phantomLedgerInventorySchema = import_zod19.z.preprocess(
13236
13030
  normalizePhantomLedgerKeys,
13237
- import_zod18.z.object({
13238
- schemaVersion: import_zod18.z.string(),
13031
+ import_zod19.z.object({
13032
+ schemaVersion: import_zod19.z.string(),
13239
13033
  runsCount: nonNegativeInt4,
13240
13034
  observationsCount: nonNegativeInt4,
13241
13035
  candidatesCount: nonNegativeInt4,
@@ -13245,16 +13039,16 @@ var phantomLedgerInventorySchema = import_zod18.z.preprocess(
13245
13039
  reportsCount: nonNegativeInt4
13246
13040
  })
13247
13041
  );
13248
- var phantomRunSchema = import_zod18.z.preprocess(
13042
+ var phantomRunSchema = import_zod19.z.preprocess(
13249
13043
  normalizePhantomLedgerKeys,
13250
- import_zod18.z.object({
13044
+ import_zod19.z.object({
13251
13045
  id: idString,
13252
13046
  organizationId: idString,
13253
- notificationId: import_zod18.z.union([import_zod18.z.string(), import_zod18.z.number()]).nullable().optional().transform(
13047
+ notificationId: import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).nullable().optional().transform(
13254
13048
  (value) => value === void 0 || value === null ? null : String(value)
13255
13049
  ),
13256
- status: import_zod18.z.string(),
13257
- triggerType: import_zod18.z.string(),
13050
+ status: import_zod19.z.string(),
13051
+ triggerType: import_zod19.z.string(),
13258
13052
  startedAt: nullableString,
13259
13053
  completedAt: nullableString,
13260
13054
  scannedFileCount: nonNegativeInt4,
@@ -13264,163 +13058,163 @@ var phantomRunSchema = import_zod18.z.preprocess(
13264
13058
  errorCount: nonNegativeInt4,
13265
13059
  warningCount: nonNegativeInt4,
13266
13060
  errorMessage: nullableString,
13267
- dryRun: import_zod18.z.boolean(),
13268
- schemaVersion: import_zod18.z.string(),
13061
+ dryRun: import_zod19.z.boolean(),
13062
+ schemaVersion: import_zod19.z.string(),
13269
13063
  testRunId: nullableString,
13270
13064
  idempotencyKey: nullableString,
13271
13065
  ledgerMetadata: jsonObject.catch({}),
13272
- createdAt: import_zod18.z.string(),
13273
- updatedAt: import_zod18.z.string()
13066
+ createdAt: import_zod19.z.string(),
13067
+ updatedAt: import_zod19.z.string()
13274
13068
  })
13275
13069
  );
13276
- var phantomRunListItemSchema = import_zod18.z.preprocess(
13070
+ var phantomRunListItemSchema = import_zod19.z.preprocess(
13277
13071
  normalizePhantomLedgerKeys,
13278
- import_zod18.z.object({
13072
+ import_zod19.z.object({
13279
13073
  id: idString,
13280
13074
  organizationId: idString,
13281
- status: import_zod18.z.string(),
13282
- triggerType: import_zod18.z.string(),
13283
- dryRun: import_zod18.z.boolean(),
13284
- schemaVersion: import_zod18.z.string(),
13075
+ status: import_zod19.z.string(),
13076
+ triggerType: import_zod19.z.string(),
13077
+ dryRun: import_zod19.z.boolean(),
13078
+ schemaVersion: import_zod19.z.string(),
13285
13079
  testRunId: nullableString,
13286
- createdAt: import_zod18.z.string(),
13287
- updatedAt: import_zod18.z.string()
13080
+ createdAt: import_zod19.z.string(),
13081
+ updatedAt: import_zod19.z.string()
13288
13082
  })
13289
13083
  );
13290
- var phantomReportSchema = import_zod18.z.preprocess(
13084
+ var phantomReportSchema = import_zod19.z.preprocess(
13291
13085
  normalizePhantomLedgerKeys,
13292
- import_zod18.z.object({
13086
+ import_zod19.z.object({
13293
13087
  id: idString,
13294
13088
  organizationId: idString,
13295
13089
  phantomRunId: idString,
13296
- status: import_zod18.z.string(),
13297
- reportType: import_zod18.z.string(),
13298
- schemaVersion: import_zod18.z.string(),
13090
+ status: import_zod19.z.string(),
13091
+ reportType: import_zod19.z.string(),
13092
+ schemaVersion: import_zod19.z.string(),
13299
13093
  markdownPath: nullableString,
13300
13094
  payload: jsonObject.catch({}),
13301
13095
  testRunId: nullableString,
13302
- idempotencyKey: import_zod18.z.string(),
13303
- createdAt: import_zod18.z.string(),
13304
- updatedAt: import_zod18.z.string()
13096
+ idempotencyKey: import_zod19.z.string(),
13097
+ createdAt: import_zod19.z.string(),
13098
+ updatedAt: import_zod19.z.string()
13305
13099
  })
13306
13100
  );
13307
- var phantomObservationSchema = import_zod18.z.preprocess(
13101
+ var phantomObservationSchema = import_zod19.z.preprocess(
13308
13102
  normalizePhantomLedgerKeys,
13309
- import_zod18.z.object({
13103
+ import_zod19.z.object({
13310
13104
  id: idString,
13311
13105
  organizationId: idString,
13312
13106
  phantomRunId: idString,
13313
- status: import_zod18.z.string(),
13314
- observationType: import_zod18.z.string(),
13107
+ status: import_zod19.z.string(),
13108
+ observationType: import_zod19.z.string(),
13315
13109
  targetType: nullableString,
13316
13110
  targetId: nullableString,
13317
13111
  sourceTable: nullableString,
13318
13112
  sourceRecordId: nullableString,
13319
13113
  sourceEventId: nullableString,
13320
13114
  contentHash: nullableString,
13321
- observedAt: import_zod18.z.string(),
13322
- confidence: import_zod18.z.coerce.number(),
13115
+ observedAt: import_zod19.z.string(),
13116
+ confidence: import_zod19.z.coerce.number(),
13323
13117
  payload: jsonObject.catch({}),
13324
- schemaVersion: import_zod18.z.string(),
13118
+ schemaVersion: import_zod19.z.string(),
13325
13119
  testRunId: nullableString,
13326
- idempotencyKey: import_zod18.z.string(),
13327
- createdAt: import_zod18.z.string(),
13328
- updatedAt: import_zod18.z.string()
13120
+ idempotencyKey: import_zod19.z.string(),
13121
+ createdAt: import_zod19.z.string(),
13122
+ updatedAt: import_zod19.z.string()
13329
13123
  })
13330
13124
  );
13331
- var phantomCandidateSchema = import_zod18.z.preprocess(
13125
+ var phantomCandidateSchema = import_zod19.z.preprocess(
13332
13126
  normalizePhantomLedgerKeys,
13333
- import_zod18.z.object({
13127
+ import_zod19.z.object({
13334
13128
  id: idString,
13335
13129
  organizationId: idString,
13336
13130
  phantomRunId: idString,
13337
13131
  phantomObservationId: nullableString,
13338
- status: import_zod18.z.string(),
13339
- candidateType: import_zod18.z.string(),
13132
+ status: import_zod19.z.string(),
13133
+ candidateType: import_zod19.z.string(),
13340
13134
  targetType: nullableString,
13341
13135
  targetId: nullableString,
13342
13136
  title: nullableString,
13343
- dryRun: import_zod18.z.boolean(),
13137
+ dryRun: import_zod19.z.boolean(),
13344
13138
  payload: jsonObject.catch({}),
13345
- approvalStatus: import_zod18.z.string(),
13139
+ approvalStatus: import_zod19.z.string(),
13346
13140
  approvedById: nullableIdString,
13347
13141
  approvedAt: nullableString,
13348
13142
  approvalSource: nullableString,
13349
13143
  approvalReason: nullableString,
13350
13144
  approvalMetadata: jsonObject.catch({}),
13351
- schemaVersion: import_zod18.z.string(),
13145
+ schemaVersion: import_zod19.z.string(),
13352
13146
  testRunId: nullableString,
13353
- idempotencyKey: import_zod18.z.string(),
13354
- createdAt: import_zod18.z.string(),
13355
- updatedAt: import_zod18.z.string()
13147
+ idempotencyKey: import_zod19.z.string(),
13148
+ createdAt: import_zod19.z.string(),
13149
+ updatedAt: import_zod19.z.string()
13356
13150
  })
13357
13151
  );
13358
- var phantomCandidateEvidenceSchema = import_zod18.z.preprocess(
13152
+ var phantomCandidateEvidenceSchema = import_zod19.z.preprocess(
13359
13153
  normalizePhantomLedgerKeys,
13360
- import_zod18.z.object({
13154
+ import_zod19.z.object({
13361
13155
  id: idString,
13362
13156
  organizationId: idString,
13363
13157
  phantomCandidateId: idString,
13364
13158
  phantomObservationId: nullableString,
13365
- evidenceType: import_zod18.z.string(),
13159
+ evidenceType: import_zod19.z.string(),
13366
13160
  sourceType: nullableString,
13367
13161
  sourceId: nullableString,
13368
13162
  contentHash: nullableString,
13369
13163
  payload: jsonObject.catch({}),
13370
- schemaVersion: import_zod18.z.string(),
13164
+ schemaVersion: import_zod19.z.string(),
13371
13165
  testRunId: nullableString,
13372
- idempotencyKey: import_zod18.z.string(),
13373
- createdAt: import_zod18.z.string(),
13374
- updatedAt: import_zod18.z.string()
13166
+ idempotencyKey: import_zod19.z.string(),
13167
+ createdAt: import_zod19.z.string(),
13168
+ updatedAt: import_zod19.z.string()
13375
13169
  })
13376
13170
  );
13377
- var phantomValidationSchema = import_zod18.z.preprocess(
13171
+ var phantomValidationSchema = import_zod19.z.preprocess(
13378
13172
  normalizePhantomLedgerKeys,
13379
- import_zod18.z.object({
13173
+ import_zod19.z.object({
13380
13174
  id: idString,
13381
13175
  organizationId: idString,
13382
13176
  phantomRunId: idString,
13383
13177
  phantomCandidateId: idString,
13384
- status: import_zod18.z.string(),
13385
- validationType: import_zod18.z.string(),
13386
- dryRun: import_zod18.z.boolean(),
13178
+ status: import_zod19.z.string(),
13179
+ validationType: import_zod19.z.string(),
13180
+ dryRun: import_zod19.z.boolean(),
13387
13181
  payload: jsonObject.catch({}),
13388
13182
  resultPayload: jsonObject.catch({}),
13389
- schemaVersion: import_zod18.z.string(),
13183
+ schemaVersion: import_zod19.z.string(),
13390
13184
  testRunId: nullableString,
13391
- idempotencyKey: import_zod18.z.string(),
13392
- createdAt: import_zod18.z.string(),
13393
- updatedAt: import_zod18.z.string()
13185
+ idempotencyKey: import_zod19.z.string(),
13186
+ createdAt: import_zod19.z.string(),
13187
+ updatedAt: import_zod19.z.string()
13394
13188
  })
13395
13189
  );
13396
- var phantomApplyOperationSchema = import_zod18.z.preprocess(
13190
+ var phantomApplyOperationSchema = import_zod19.z.preprocess(
13397
13191
  normalizePhantomLedgerKeys,
13398
- import_zod18.z.object({
13192
+ import_zod19.z.object({
13399
13193
  id: idString,
13400
13194
  organizationId: idString,
13401
13195
  phantomRunId: idString,
13402
13196
  phantomCandidateId: idString,
13403
- status: import_zod18.z.string(),
13404
- operationType: import_zod18.z.string(),
13405
- dryRun: import_zod18.z.boolean(),
13197
+ status: import_zod19.z.string(),
13198
+ operationType: import_zod19.z.string(),
13199
+ dryRun: import_zod19.z.boolean(),
13406
13200
  targetType: nullableString,
13407
13201
  targetId: nullableString,
13408
13202
  payload: jsonObject.catch({}),
13409
13203
  resultPayload: jsonObject.catch({}),
13410
- schemaVersion: import_zod18.z.string(),
13204
+ schemaVersion: import_zod19.z.string(),
13411
13205
  testRunId: nullableString,
13412
- idempotencyKey: import_zod18.z.string(),
13413
- createdAt: import_zod18.z.string(),
13414
- updatedAt: import_zod18.z.string()
13206
+ idempotencyKey: import_zod19.z.string(),
13207
+ createdAt: import_zod19.z.string(),
13208
+ updatedAt: import_zod19.z.string()
13415
13209
  })
13416
13210
  );
13417
- var phantomRunsSchema = import_zod18.z.array(phantomRunListItemSchema);
13418
- var phantomReportsSchema = import_zod18.z.array(phantomReportSchema);
13419
- var phantomObservationsSchema = import_zod18.z.array(phantomObservationSchema);
13420
- var phantomCandidatesSchema = import_zod18.z.array(phantomCandidateSchema);
13421
- var phantomCandidateEvidencesSchema = import_zod18.z.array(phantomCandidateEvidenceSchema);
13422
- var phantomValidationsSchema = import_zod18.z.array(phantomValidationSchema);
13423
- var phantomApplyOperationsSchema = import_zod18.z.array(phantomApplyOperationSchema);
13211
+ var phantomRunsSchema = import_zod19.z.array(phantomRunListItemSchema);
13212
+ var phantomReportsSchema = import_zod19.z.array(phantomReportSchema);
13213
+ var phantomObservationsSchema = import_zod19.z.array(phantomObservationSchema);
13214
+ var phantomCandidatesSchema = import_zod19.z.array(phantomCandidateSchema);
13215
+ var phantomCandidateEvidencesSchema = import_zod19.z.array(phantomCandidateEvidenceSchema);
13216
+ var phantomValidationsSchema = import_zod19.z.array(phantomValidationSchema);
13217
+ var phantomApplyOperationsSchema = import_zod19.z.array(phantomApplyOperationSchema);
13424
13218
  function isRecord6(value) {
13425
13219
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13426
13220
  }
@@ -14877,72 +14671,72 @@ function registerDatasheetsCommands(program) {
14877
14671
  }
14878
14672
 
14879
14673
  // src/commands/atlasAuthoring.ts
14880
- var import_zod19 = require("zod");
14881
- var idSchema14 = import_zod19.z.string().trim().min(1);
14882
- var idempotencyKeySchema = import_zod19.z.string().min(1).refine((value) => value.trim() === value, "Idempotency key must not have leading or trailing whitespace.");
14883
- var skillScopeSchema = import_zod19.z.enum(["ADMIN_GLOBAL", "MEMBER_PERSONAL"]);
14884
- var isoDateSchema = import_zod19.z.iso.date();
14885
- var nonEmptyStringSchema = import_zod19.z.string().trim().min(1);
14674
+ var import_zod20 = require("zod");
14675
+ var idSchema14 = import_zod20.z.string().trim().min(1);
14676
+ var idempotencyKeySchema = import_zod20.z.string().min(1).refine((value) => value.trim() === value, "Idempotency key must not have leading or trailing whitespace.");
14677
+ var skillScopeSchema = import_zod20.z.enum(["ADMIN_GLOBAL", "MEMBER_PERSONAL"]);
14678
+ var isoDateSchema = import_zod20.z.iso.date();
14679
+ var nonEmptyStringSchema = import_zod20.z.string().trim().min(1);
14886
14680
  var AUTOMATION_RUN_HTTP_TIMEOUT_MS = 6e4;
14887
- var agentToolAccessSchema = import_zod19.z.array(
14888
- import_zod19.z.object({
14681
+ var agentToolAccessSchema = import_zod20.z.array(
14682
+ import_zod20.z.object({
14889
14683
  tool_key: nonEmptyStringSchema,
14890
14684
  scope_value: nonEmptyStringSchema
14891
14685
  }).strict()
14892
14686
  ).min(1);
14893
14687
  var agentToolAccessUpdateSchema = agentToolAccessSchema.min(0);
14894
- var agentPluginConnectionsSchema = import_zod19.z.array(
14895
- import_zod19.z.object({
14688
+ var agentPluginConnectionsSchema = import_zod20.z.array(
14689
+ import_zod20.z.object({
14896
14690
  external_tool_connection_id: nonEmptyStringSchema,
14897
14691
  tool_key: nonEmptyStringSchema,
14898
14692
  scope_value: nonEmptyStringSchema.optional(),
14899
- allowed_tools: import_zod19.z.array(nonEmptyStringSchema).optional(),
14900
- allowed_scopes: import_zod19.z.array(nonEmptyStringSchema).optional(),
14901
- requires_confirmation: import_zod19.z.boolean().optional(),
14902
- enabled: import_zod19.z.boolean().optional()
14693
+ allowed_tools: import_zod20.z.array(nonEmptyStringSchema).optional(),
14694
+ allowed_scopes: import_zod20.z.array(nonEmptyStringSchema).optional(),
14695
+ requires_confirmation: import_zod20.z.boolean().optional(),
14696
+ enabled: import_zod20.z.boolean().optional()
14903
14697
  }).strict()
14904
14698
  ).min(1);
14905
- var agentPluginConnectionUpdateSchema = import_zod19.z.array(
14906
- import_zod19.z.union([
14907
- import_zod19.z.object({
14699
+ var agentPluginConnectionUpdateSchema = import_zod20.z.array(
14700
+ import_zod20.z.union([
14701
+ import_zod20.z.object({
14908
14702
  id: nonEmptyStringSchema,
14909
- _destroy: import_zod19.z.literal(true)
14703
+ _destroy: import_zod20.z.literal(true)
14910
14704
  }).strict(),
14911
- import_zod19.z.object({
14705
+ import_zod20.z.object({
14912
14706
  id: nonEmptyStringSchema.optional(),
14913
14707
  external_tool_connection_id: nonEmptyStringSchema.optional(),
14914
14708
  tool_key: nonEmptyStringSchema.optional(),
14915
14709
  scope_value: nonEmptyStringSchema.optional(),
14916
- allowed_tools: import_zod19.z.array(nonEmptyStringSchema).optional(),
14917
- allowed_scopes: import_zod19.z.array(nonEmptyStringSchema).optional(),
14918
- requires_confirmation: import_zod19.z.boolean().optional(),
14919
- enabled: import_zod19.z.boolean().optional()
14710
+ allowed_tools: import_zod20.z.array(nonEmptyStringSchema).optional(),
14711
+ allowed_scopes: import_zod20.z.array(nonEmptyStringSchema).optional(),
14712
+ requires_confirmation: import_zod20.z.boolean().optional(),
14713
+ enabled: import_zod20.z.boolean().optional()
14920
14714
  }).strict().superRefine((value, context) => {
14921
14715
  if (value.id || value.external_tool_connection_id && value.tool_key) return;
14922
14716
  context.addIssue({
14923
- code: import_zod19.z.ZodIssueCode.custom,
14717
+ code: import_zod20.z.ZodIssueCode.custom,
14924
14718
  message: "Plugin updates require an id, or both external_tool_connection_id and tool_key for a new grant."
14925
14719
  });
14926
14720
  })
14927
14721
  ])
14928
14722
  );
14929
- var agentTriggerSchema = import_zod19.z.object({
14930
- trigger_type: import_zod19.z.literal("cron"),
14723
+ var agentTriggerSchema = import_zod20.z.object({
14724
+ trigger_type: import_zod20.z.literal("cron"),
14931
14725
  cron_expression: nonEmptyStringSchema,
14932
14726
  timezone: nonEmptyStringSchema,
14933
- starts_at: import_zod19.z.iso.datetime({ offset: true }).nullable().optional(),
14934
- ends_at: import_zod19.z.iso.datetime({ offset: true }).nullable().optional(),
14935
- max_runs: import_zod19.z.number().int().positive().nullable().optional(),
14936
- enabled: import_zod19.z.boolean().optional()
14727
+ starts_at: import_zod20.z.iso.datetime({ offset: true }).nullable().optional(),
14728
+ ends_at: import_zod20.z.iso.datetime({ offset: true }).nullable().optional(),
14729
+ max_runs: import_zod20.z.number().int().positive().nullable().optional(),
14730
+ enabled: import_zod20.z.boolean().optional()
14937
14731
  }).strict();
14938
- var agentTriggerUpdateSchema = import_zod19.z.union([
14732
+ var agentTriggerUpdateSchema = import_zod20.z.union([
14939
14733
  agentTriggerSchema.extend({ id: nonEmptyStringSchema.optional() }).strict(),
14940
- import_zod19.z.object({
14734
+ import_zod20.z.object({
14941
14735
  id: nonEmptyStringSchema,
14942
- _destroy: import_zod19.z.literal(true)
14736
+ _destroy: import_zod20.z.literal(true)
14943
14737
  }).strict()
14944
14738
  ]);
14945
- var automationConfigSchema = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.unknown());
14739
+ var automationConfigSchema = import_zod20.z.record(import_zod20.z.string(), import_zod20.z.unknown());
14946
14740
  var AGENT_SELECTION = `{
14947
14741
  id
14948
14742
  type
@@ -15224,7 +15018,16 @@ function normalizeAutomationRunPayload(payload) {
15224
15018
  };
15225
15019
  }
15226
15020
  function parseAutomationConfig(value) {
15227
- return automationConfigSchema.parse(parseJson(String(value), "--ai-task-config"));
15021
+ const config = automationConfigSchema.parse(parseJson(String(value), "--ai-task-config"));
15022
+ if (Object.hasOwn(config, "agent_id") || Object.hasOwn(config, "agentId")) {
15023
+ throw new CliError({
15024
+ message: "Automation executor agent_id must be supplied through --agent-id, not --ai-task-config.",
15025
+ kind: "invalid_args",
15026
+ status: 400,
15027
+ exitCode: EXIT_CODES.invalidArgs
15028
+ });
15029
+ }
15030
+ return config;
15228
15031
  }
15229
15032
  function parseExpectedUpdateVersion(value) {
15230
15033
  return nonEmptyStringSchema.parse(String(value));
@@ -15433,7 +15236,7 @@ function registerAtlasAuthoringCommands(program) {
15433
15236
  "--service <service>",
15434
15237
  "Supported service: gmail, calendar, slack, or stripe"
15435
15238
  ).action(async (opts, cmd) => {
15436
- const service = import_zod19.z.enum(["gmail", "calendar", "slack", "stripe"]).parse(opts.service);
15239
+ const service = import_zod20.z.enum(["gmail", "calendar", "slack", "stripe"]).parse(opts.service);
15437
15240
  const context = await resolveCommandContext(cmd.optsWithGlobals());
15438
15241
  const organizationId = resolveOrganizationId(context.organizationId);
15439
15242
  await runGraphqlQueryCommand({
@@ -15447,7 +15250,7 @@ function registerAtlasAuthoringCommands(program) {
15447
15250
  });
15448
15251
  });
15449
15252
  const automations = program.command("automations").description("Bounded Automation authoring operations");
15450
- automations.command("create").description("Create a Backlog Automation through the API-owned createAutomation contract").requiredOption("--summary <summary>").requiredOption("--ai-task-config <json>", "Valid JSON for the API-owned ai_task_config field").requiredOption("--idempotency-key <key>", "Required create idempotency key").option("--description <description>").option("--notes <notes>").option("--member-id <memberId>").option("--agent-id <agentId>", "Optional executor Agent id for a repeat Automation").option("--priority <priority>").option("--due-date <date>", "ISO-8601 date (YYYY-MM-DD)").action(async (opts, cmd) => {
15253
+ automations.command("create").description("Create a Backlog Automation through the API-owned createAutomation contract").requiredOption("--summary <summary>").requiredOption("--ai-task-config <json>", "Valid JSON for the API-owned ai_task_config field").requiredOption("--idempotency-key <key>", "Required create idempotency key").option("--description <description>").option("--notes <notes>").option("--member-id <memberId>").requiredOption("--agent-id <agentId>", "Required executor Agent id").option("--priority <priority>").option("--due-date <date>", "ISO-8601 date (YYYY-MM-DD)").action(async (opts, cmd) => {
15451
15254
  const idempotencyKey = idempotencyKeySchema.parse(opts.idempotencyKey);
15452
15255
  const context = await resolveCommandContext(cmd.optsWithGlobals());
15453
15256
  const organizationId = resolveOrganizationId(context.organizationId);
@@ -15465,7 +15268,7 @@ function registerAtlasAuthoringCommands(program) {
15465
15268
  organization_id: organizationId,
15466
15269
  input: {
15467
15270
  summary: idSchema14.parse(opts.summary),
15468
- ai_task_config: parseJson(String(opts.aiTaskConfig), "--ai-task-config"),
15271
+ ai_task_config: parseAutomationConfig(opts.aiTaskConfig),
15469
15272
  ...opts.description !== void 0 ? { description: String(opts.description) } : {},
15470
15273
  ...opts.notes !== void 0 ? { notes: String(opts.notes) } : {},
15471
15274
  ...opts.memberId !== void 0 ? { member_id: idSchema14.parse(opts.memberId) } : {},
@@ -15536,20 +15339,17 @@ function registerAtlasAuthoringCommands(program) {
15536
15339
  "Exact opaque updateVersion value from automations show; rejects stale writes"
15537
15340
  ).option("--summary <summary>").option("--description <description>").option("--notes <notes>").option("--priority <priority>").option("--due-date <date>", "ISO-8601 date (YYYY-MM-DD)").option("--ai-task-config <json>", "Complete replacement ai_task_config JSON object").option(
15538
15341
  "--agent-id <agentId>",
15539
- "Executor Agent id; requires --ai-task-config and is stored in that config"
15342
+ "Rejected: executor ownership is immutable after Automation creation"
15540
15343
  ).action(async (opts, cmd) => {
15541
- if (opts.agentId !== void 0 && opts.aiTaskConfig === void 0) {
15344
+ if (opts.agentId !== void 0) {
15542
15345
  throw new CliError({
15543
- message: "automations update requires --ai-task-config whenever --agent-id is supplied.",
15346
+ message: "automations update cannot change executor ownership; create a new Automation instead.",
15544
15347
  kind: "invalid_args",
15545
15348
  status: 400,
15546
15349
  exitCode: EXIT_CODES.invalidArgs
15547
15350
  });
15548
15351
  }
15549
- const aiTaskConfig = opts.aiTaskConfig === void 0 ? void 0 : {
15550
- ...parseAutomationConfig(opts.aiTaskConfig),
15551
- ...opts.agentId !== void 0 ? { agent_id: idSchema14.parse(opts.agentId) } : {}
15552
- };
15352
+ const aiTaskConfig = opts.aiTaskConfig === void 0 ? void 0 : parseAutomationConfig(opts.aiTaskConfig);
15553
15353
  const patch = {
15554
15354
  ...opts.summary !== void 0 ? { summary: String(opts.summary) } : {},
15555
15355
  ...opts.description !== void 0 ? { description: String(opts.description) } : {},
@@ -15672,7 +15472,7 @@ var import_node_path4 = require("path");
15672
15472
  var import_node_crypto3 = require("crypto");
15673
15473
 
15674
15474
  // src/version.ts
15675
- var CLI_VERSION = "0.1.76";
15475
+ var CLI_VERSION = "0.1.77";
15676
15476
 
15677
15477
  // src/operationMetadata.ts
15678
15478
  var DISCOVERY_OPERATION_IDS = [
@@ -16076,7 +15876,6 @@ var WRITE_OPERATION_IDS = [
16076
15876
  "osmd.ingest.text",
16077
15877
  "osmd.ingest.transcript",
16078
15878
  "osmd.ingest.url",
16079
- "osmd.phantom.run",
16080
15879
  "osmd.wiki.append-log",
16081
15880
  "osmd.wiki.create",
16082
15881
  "osmd.wiki.index-upsert",
@@ -16395,22 +16194,21 @@ var NAMESPACE_DOCS = {
16395
16194
  osmd: {
16396
16195
  name: "osmd",
16397
16196
  tier: "primary",
16398
- description: "Canonical OSMD, .agent overlay, Agent Wiki, ingest, lint, and Phantom operations.",
16197
+ description: "Canonical OSMD, .agent overlay, Agent Wiki, ingest, and lint operations.",
16399
16198
  examples: [
16400
16199
  "wave osmd tree --depth 2",
16401
16200
  "wave osmd lint --json",
16402
16201
  'wave osmd ingest text "Notes" --slug notes --parent-ref "projects/Wave Tools" --summary "Source notes" --dry-run',
16403
- 'wave osmd agent update "projects/Wave Tools" notes.md --content "# Notes"',
16404
- "wave osmd phantom run --dry-run"
16202
+ 'wave osmd agent update "projects/Wave Tools" notes.md --content "# Notes"'
16405
16203
  ],
16406
16204
  schema: {
16407
16205
  output: "json-envelope-default",
16408
16206
  safety: [
16409
16207
  "Canonical OSMD writes are blocked before mutation.",
16410
16208
  "Agent Wiki log is append-only.",
16411
- "Ingest and Phantom support dry-run paths."
16209
+ "Ingest supports dry-run paths."
16412
16210
  ],
16413
- commands: ["tree", "status", "read", "children", "search", "lint", "memory-quality", "ingest", "phantom", "agent", "wiki"]
16211
+ commands: ["tree", "status", "read", "children", "search", "lint", "memory-quality", "ingest", "agent", "wiki"]
16414
16212
  }
16415
16213
  },
16416
16214
  phantom: {
@@ -17216,7 +17014,7 @@ function registerDiscoveryCommands(program) {
17216
17014
  const phantom = program.commands.find((command) => command.name() === "phantom");
17217
17015
  phantom?.addHelpText(
17218
17016
  "after",
17219
- "\nExamples:\n wave phantom inventory --json\n wave phantom observations --run-id 123 --json\n wave phantom candidates --candidate-type organization_meta_profile_update_candidate --json\n wave phantom apply-operations --status succeeded --operation-type organization_meta_profile_patch --json\n wave phantom report latest --json\n wave osmd phantom run --dry-run\n"
17017
+ "\nExamples:\n wave phantom inventory --json\n wave phantom observations --run-id 123 --json\n wave phantom candidates --candidate-type organization_meta_profile_update_candidate --json\n wave phantom apply-operations --status succeeded --operation-type organization_meta_profile_patch --json\n wave phantom report latest --json\n"
17220
17018
  );
17221
17019
  }
17222
17020
  function attachNamespaceDiscovery(program) {
@@ -17282,12 +17080,11 @@ function attachDiscoveryHelp(program) {
17282
17080
  " wave capabilities list",
17283
17081
  " wave capabilities tools",
17284
17082
  " wave osmd lint --json",
17285
- " wave osmd phantom run --dry-run",
17286
17083
  " wave doctor"
17287
17084
  ].join("\n")
17288
17085
  );
17289
17086
  const helpByName = /* @__PURE__ */ new Map([
17290
- ["osmd", '\nExamples:\n wave osmd tree --depth 2\n wave osmd lint --json\n wave osmd agent update "projects/Wave Tools" notes.md --content "# Notes"\n wave osmd phantom run --dry-run\n'],
17087
+ ["osmd", '\nExamples:\n wave osmd tree --depth 2\n wave osmd lint --json\n wave osmd agent update "projects/Wave Tools" notes.md --content "# Notes"\n'],
17291
17088
  ["broadcast", "\nExamples:\n wave broadcast list\n wave broadcast workspace\n wave broadcast community\n wave broadcast open\n"],
17292
17089
  ["support", "\nExamples:\n wave support counts --status open\n wave support tickets --status open --page 1 --per 20\n wave support knowledge-articles --collection-id 123 --visibility public\n wave support settings\n wave support open\n"],
17293
17090
  ["markdown-tree", "\nExamples:\n wave markdown-tree root --tree-view\n wave markdown-tree resolve --tool-key projects --node-key tasks --parent-id 123\n"],
@@ -17386,19 +17183,30 @@ function buildCli(options) {
17386
17183
 
17387
17184
  // src/machine.ts
17388
17185
  var import_node_crypto4 = require("crypto");
17186
+ var import_node_fs5 = require("fs");
17389
17187
  var MACHINE_FLAGS = /* @__PURE__ */ new Set([
17390
17188
  "--machine",
17391
17189
  "--operation",
17392
17190
  "--phase",
17393
- "--input-json"
17191
+ "--input-json",
17192
+ "--machine-auth-fd",
17193
+ "--machine-approval-fd"
17394
17194
  ]);
17195
+ var MACHINE_AUTH_FD = 3;
17196
+ var MACHINE_APPROVAL_FD = 4;
17197
+ var MAX_MACHINE_SECRET_BYTES = 64 * 1024;
17198
+ var MAX_MACHINE_INPUT_BYTES = 128 * 1024;
17395
17199
  function machineEnvelope(params) {
17396
17200
  return {
17397
17201
  ok: params.ok,
17398
17202
  command: params.command,
17399
17203
  status: params.status,
17400
17204
  data: params.data ?? null,
17401
- error: params.error ?? null,
17205
+ error: params.error ? {
17206
+ code: params.error.code,
17207
+ message: params.error.message,
17208
+ details: params.error.details ?? {}
17209
+ } : null,
17402
17210
  meta: { requestId: "machine" }
17403
17211
  };
17404
17212
  }
@@ -17420,7 +17228,7 @@ function commandId(command) {
17420
17228
  function parseMachineArgs(argv) {
17421
17229
  const values = {};
17422
17230
  for (let index = 0; index < argv.length; index += 1) {
17423
- const flag = argv[index];
17231
+ const flag = argv[index] ?? "";
17424
17232
  if (!MACHINE_FLAGS.has(flag)) {
17425
17233
  return { error: `Unsupported machine flag: ${flag}` };
17426
17234
  }
@@ -17435,19 +17243,45 @@ function parseMachineArgs(argv) {
17435
17243
  if (values["--machine"] !== "execute") {
17436
17244
  return { error: '--machine must be "execute".' };
17437
17245
  }
17246
+ const authFd = parseReservedMachineFd(values["--machine-auth-fd"], MACHINE_AUTH_FD);
17247
+ if (authFd instanceof Error) return { error: authFd.message };
17248
+ const approvalFd = parseReservedMachineFd(
17249
+ values["--machine-approval-fd"],
17250
+ MACHINE_APPROVAL_FD
17251
+ );
17252
+ if (approvalFd instanceof Error) return { error: approvalFd.message };
17438
17253
  return {
17439
- operation: values["--operation"],
17440
- phase: values["--phase"],
17441
- inputJson: values["--input-json"]
17254
+ ...values["--operation"] ? { operation: values["--operation"] } : {},
17255
+ ...values["--phase"] ? { phase: values["--phase"] } : {},
17256
+ ...values["--input-json"] ? { inputJson: values["--input-json"] } : {},
17257
+ ...authFd !== void 0 ? { authFd } : {},
17258
+ ...approvalFd !== void 0 ? { approvalFd } : {}
17442
17259
  };
17443
17260
  }
17261
+ function parseReservedMachineFd(value, expected) {
17262
+ if (value === void 0) return void 0;
17263
+ if (!/^\d+$/.test(value) || Number(value) !== expected) {
17264
+ return new Error(`The machine secret descriptor must be fd ${expected}.`);
17265
+ }
17266
+ return expected;
17267
+ }
17444
17268
  async function readMachineInput(location) {
17445
17269
  if (location !== "-") {
17446
17270
  throw new Error('Machine input must be supplied with "--input-json -".');
17447
17271
  }
17448
17272
  let raw = "";
17273
+ let bytes = 0;
17449
17274
  process.stdin.setEncoding("utf8");
17450
- for await (const chunk of process.stdin) raw += chunk;
17275
+ for await (const chunk of process.stdin) {
17276
+ const text = String(chunk);
17277
+ bytes += Buffer.byteLength(text, "utf8");
17278
+ if (bytes > MAX_MACHINE_INPUT_BYTES) {
17279
+ throw new Error(
17280
+ `Machine input exceeds the maximum size of ${MAX_MACHINE_INPUT_BYTES} bytes.`
17281
+ );
17282
+ }
17283
+ raw += text;
17284
+ }
17451
17285
  if (!raw.trim()) throw new Error("Machine input JSON is required.");
17452
17286
  const parsed = JSON.parse(raw);
17453
17287
  if (!isPlainObject(parsed)) throw new Error("Machine input must be a JSON object.");
@@ -17468,11 +17302,20 @@ function normalizeInput(input) {
17468
17302
  Object.keys(input).sort().map((key) => [key, input[key]])
17469
17303
  );
17470
17304
  }
17471
- function parseTrustedJson(name, predicate) {
17472
- const raw = process.env[name];
17473
- if (!raw) return null;
17305
+ function parseTrustedJsonFromFd(fd, predicate) {
17306
+ if (fd === void 0) return null;
17474
17307
  try {
17475
- const parsed = JSON.parse(raw);
17308
+ const chunks = [];
17309
+ const buffer = Buffer.allocUnsafe(8 * 1024);
17310
+ let bytes = 0;
17311
+ while (true) {
17312
+ const read = (0, import_node_fs5.readSync)(fd, buffer, 0, buffer.length, null);
17313
+ if (read === 0) break;
17314
+ bytes += read;
17315
+ if (bytes > MAX_MACHINE_SECRET_BYTES) return null;
17316
+ chunks.push(Buffer.from(buffer.subarray(0, read)));
17317
+ }
17318
+ const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
17476
17319
  return predicate(parsed) ? parsed : null;
17477
17320
  } catch {
17478
17321
  return null;
@@ -17547,13 +17390,9 @@ function withTrustedMachineAuth(auth, callback) {
17547
17390
  for (const key of Object.keys(process.env)) {
17548
17391
  if (key.startsWith("WAVE_")) delete process.env[key];
17549
17392
  }
17550
- if (auth) {
17551
- process.env.WAVE_API_TOKEN = auth.token;
17552
- process.env.WAVE_API_BASE_URL = auth.baseUrl;
17553
- }
17554
17393
  process.env.WAVE_CLI_AUTH_STORAGE = "disabled";
17555
17394
  process.env.WAVE_CLI_HOME = "/dev/null";
17556
- return callback().finally(() => {
17395
+ return withMachineRuntimeAuth(auth, callback).finally(() => {
17557
17396
  for (const key of Object.keys(process.env)) {
17558
17397
  if (key.startsWith("WAVE_")) delete process.env[key];
17559
17398
  }
@@ -17705,7 +17544,7 @@ async function maybeRunMachineExecute(argv, program) {
17705
17544
  })
17706
17545
  });
17707
17546
  }
17708
- const auth = parseTrustedJson("WAVE_MACHINE_AUTH_JSON", isTrustedAuth);
17547
+ const auth = parseTrustedJsonFromFd(parsed.authFd, isTrustedAuth);
17709
17548
  if (needsTrustedAuth(resolved.operation) && !auth) {
17710
17549
  return printEnvelopeAndExit({
17711
17550
  envelope: machineEnvelope({
@@ -17721,7 +17560,7 @@ async function maybeRunMachineExecute(argv, program) {
17721
17560
  });
17722
17561
  }
17723
17562
  if (resolved.operation.classification === "write") {
17724
- const approval = parseTrustedJson("WAVE_MACHINE_APPROVAL_JSON", isTrustedApproval);
17563
+ const approval = parseTrustedJsonFromFd(parsed.approvalFd, isTrustedApproval);
17725
17564
  if (!approval || approval.operation !== resolved.operation.id || approval.inputDigest !== digest || approval.cliVersion !== manifest.cli.version || approval.registryDigest !== manifest.registryDigest || approval.organizationId !== auth?.organizationId || approval.actorId !== auth?.actorId) {
17726
17565
  return printEnvelopeAndExit({
17727
17566
  envelope: machineEnvelope({
@@ -17801,13 +17640,13 @@ main().catch((error) => {
17801
17640
  });
17802
17641
  return;
17803
17642
  }
17804
- if (error instanceof import_zod20.ZodError || error instanceof import_commander2.InvalidArgumentError) {
17643
+ if (error instanceof import_zod21.ZodError || error instanceof import_commander2.InvalidArgumentError) {
17805
17644
  printCliFailure({
17806
17645
  status: 400,
17807
17646
  code: "invalid_args",
17808
17647
  message: "Invalid command arguments.",
17809
17648
  details: {
17810
- issues: error instanceof import_zod20.ZodError ? error.issues : [{ message: error.message, code: "invalid_argument" }]
17649
+ issues: error instanceof import_zod21.ZodError ? error.issues : [{ message: error.message, code: "invalid_argument" }]
17811
17650
  },
17812
17651
  exitCode: EXIT_CODES.invalidArgs
17813
17652
  });