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

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,17 +4414,24 @@ 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
  });
4424
+ var issueStatusSchema = import_zod10.z.string().min(1).refine((value) => value === "open" || value === "completed", {
4425
+ message: "Invalid issue status. Use one of: open, completed."
4426
+ });
4294
4427
  var updateHelp4 = buildDataJsonHelp("issue", "update") ?? 'JSON object for issue or {"issue": {...}}';
4428
+ function parseIssueIndexEnum(value, schema) {
4429
+ if (value === void 0) return void 0;
4430
+ return schema.parse(String(value)).toUpperCase();
4431
+ }
4295
4432
  function registerIssueCommands(program) {
4296
4433
  const issues = program.command("issues").description("Issue operations");
4297
- issues.command("list").option("--page <page>").option("--per <per>").option("--issue-group-id <issueGroupId>").option("--start-date <startDate>").option("--issue-type <issueType>").option("--team-id <teamId>").option("--member-id <memberId>").option("--meeting-id <meetingId>").action(async (opts, cmd) => {
4434
+ issues.command("list").option("--page <page>").option("--per <per>").option("--issue-group-id <issueGroupId>").option("--start-date <startDate>").option("--issue-type <issueType>").option("--status <status>", "Issue status: open | completed").option("--team-id <teamId>").option("--member-id <memberId>").option("--meeting-id <meetingId>").action(async (opts, cmd) => {
4298
4435
  const context = await resolveCommandContext(cmd.optsWithGlobals());
4299
4436
  const organizationId = resolveOrganizationId(context.organizationId);
4300
4437
  await runGraphqlQueryCommand({
@@ -4307,11 +4444,24 @@ function registerIssueCommands(program) {
4307
4444
  per: opts.per,
4308
4445
  issue_group_id: opts.issueGroupId,
4309
4446
  start_date: opts.startDate,
4310
- issue_type: opts.issueType,
4447
+ issue_type: parseIssueIndexEnum(opts.issueType, issueTypeSchema),
4448
+ status: parseIssueIndexEnum(opts.status, issueStatusSchema),
4311
4449
  team_id: opts.teamId,
4312
4450
  member_id: opts.memberId,
4313
4451
  meeting_id: opts.meetingId
4314
4452
  }),
4453
+ variableTypes: {
4454
+ organization_id: "ID!",
4455
+ page: "Int",
4456
+ per: "Int",
4457
+ issue_group_id: "ID",
4458
+ start_date: "String",
4459
+ issue_type: "IssueType",
4460
+ status: "IssueStatus",
4461
+ team_id: "ID",
4462
+ member_id: "ID",
4463
+ meeting_id: "ID"
4464
+ },
4315
4465
  isList: true
4316
4466
  });
4317
4467
  });
@@ -5335,8 +5485,8 @@ function registerSystemToolCommands(program) {
5335
5485
  }
5336
5486
 
5337
5487
  // src/commands/teams.ts
5338
- var import_zod10 = require("zod");
5339
- var idSchema9 = import_zod10.z.string().min(1);
5488
+ var import_zod11 = require("zod");
5489
+ var idSchema9 = import_zod11.z.string().min(1);
5340
5490
  function registerTeamCommands(program) {
5341
5491
  const teams = program.command("teams").description("Team operations");
5342
5492
  teams.command("list").option("--page <page>").option("--per <per>").action(async (opts, cmd) => {
@@ -5402,8 +5552,8 @@ function registerTeamCommands(program) {
5402
5552
  }
5403
5553
 
5404
5554
  // src/commands/organizations.ts
5405
- var import_zod11 = require("zod");
5406
- var idSchema10 = import_zod11.z.string().min(1);
5555
+ var import_zod12 = require("zod");
5556
+ var idSchema10 = import_zod12.z.string().min(1);
5407
5557
  function isRecord3(value) {
5408
5558
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5409
5559
  }
@@ -5615,8 +5765,8 @@ function registerOrganizationCommands(program) {
5615
5765
  }
5616
5766
 
5617
5767
  // src/commands/foundation.ts
5618
- var import_zod12 = require("zod");
5619
- var idSchema11 = import_zod12.z.string().min(1);
5768
+ var import_zod13 = require("zod");
5769
+ var idSchema11 = import_zod13.z.string().min(1);
5620
5770
  var STRATEGIC_PLAN_ALLOWED_UPDATE_KEYS = /* @__PURE__ */ new Set([
5621
5771
  "published_at",
5622
5772
  "profile",
@@ -5817,9 +5967,9 @@ function registerFoundationCommands(program) {
5817
5967
  }
5818
5968
 
5819
5969
  // 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());
5970
+ var import_zod14 = require("zod");
5971
+ var idSchema12 = import_zod14.z.string().min(1);
5972
+ var jsonObjectSchema = import_zod14.z.record(import_zod14.z.string(), import_zod14.z.unknown());
5823
5973
  var NOTE_DETAIL_FIELDS = [
5824
5974
  "notes",
5825
5975
  "hasNotes",
@@ -5967,10 +6117,17 @@ function normalizeSubtaskCreateBody(body) {
5967
6117
  }
5968
6118
  function registerChildCommands(program, config) {
5969
6119
  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) => {
6120
+ const listCommand = command.command("list").requiredOption(`--${config.parentFlag} <${config.parentFlag}>`).option("--page <page>").option("--per <per>");
6121
+ if (config.priorityFilter) {
6122
+ listCommand.option("--priority <priority>", config.priorityFilter.help);
6123
+ }
6124
+ listCommand.action(async (opts, cmd) => {
5971
6125
  const context = await resolveCommandContext(cmd.optsWithGlobals());
5972
6126
  const organizationId = resolveOrganizationId(context.organizationId);
5973
6127
  const parentId = idSchema12.parse(opts[config.parentFlag.replace(/-([a-z])/g, (_, c) => c.toUpperCase())]);
6128
+ const priority = config.priorityFilter?.parse(opts.priority);
6129
+ const priorityVariables = priority === void 0 ? {} : { priority };
6130
+ const priorityVariableTypes = priority === void 0 || !config.priorityFilter ? {} : { priority: config.priorityFilter.variableType };
5974
6131
  await runGraphqlQueryCommand({
5975
6132
  command: `${config.command}.list`,
5976
6133
  operationName: config.listOperationName,
@@ -5980,13 +6137,15 @@ function registerChildCommands(program, config) {
5980
6137
  organization_id: organizationId,
5981
6138
  [config.parentFlag.replace(/-/g, "_")]: parentId,
5982
6139
  page: opts.page,
5983
- per: opts.per
6140
+ per: opts.per,
6141
+ ...priorityVariables
5984
6142
  }),
5985
6143
  variableTypes: {
5986
6144
  organization_id: "ID!",
5987
6145
  [config.parentFlag.replace(/-/g, "_")]: "ID!",
5988
6146
  page: "Int",
5989
- per: "Int"
6147
+ per: "Int",
6148
+ ...priorityVariableTypes
5990
6149
  },
5991
6150
  isList: true,
5992
6151
  selectionSet: config.listSelectionSet,
@@ -6106,6 +6265,11 @@ function registerChildEntityCommands(program) {
6106
6265
  destroyOperationName: "SubtasksDestroy",
6107
6266
  listSelectionSet: buildChildListSelectionSet("taskId"),
6108
6267
  listParentTypedField: "taskId",
6268
+ priorityFilter: {
6269
+ variableType: "TaskPriority",
6270
+ help: taskPriorityHelp,
6271
+ parse: parseTaskPriority
6272
+ },
6109
6273
  searchRequiredOptions: requiredParentSearchOption("task-id", "task"),
6110
6274
  showField: "subtask",
6111
6275
  showOperationName: "SubtasksShow",
@@ -6221,9 +6385,9 @@ function registerChildEntityCommands(program) {
6221
6385
  }
6222
6386
 
6223
6387
  // 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);
6388
+ var import_zod15 = require("zod");
6389
+ var idSchema13 = import_zod15.z.string().min(1);
6390
+ var nonEmptyString = import_zod15.z.string().min(1);
6227
6391
  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
6392
  function assertUpdateFields(params) {
6229
6393
  if (!params.name && !params.content && !params.status) {
@@ -6411,9 +6575,9 @@ function registerContentCommands(program) {
6411
6575
  }
6412
6576
 
6413
6577
  // 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);
6578
+ var import_zod16 = require("zod");
6579
+ var nonEmptyString2 = import_zod16.z.string().min(1);
6580
+ var nonNegativeInt = import_zod16.z.coerce.number().int().min(0);
6417
6581
  function addScopeOptions(command) {
6418
6582
  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
6583
  }
@@ -6578,7 +6742,7 @@ function registerMarkdownTreeCommands(program) {
6578
6742
  }
6579
6743
 
6580
6744
  // src/commands/navigation.ts
6581
- var import_zod16 = require("zod");
6745
+ var import_zod17 = require("zod");
6582
6746
 
6583
6747
  // src/internalOptions.ts
6584
6748
  var INTERNAL_OPTIONS_KEY = "__waveInternalOptions";
@@ -6608,8 +6772,8 @@ function getInternalCliOptions(command) {
6608
6772
  }
6609
6773
 
6610
6774
  // src/commands/navigation.ts
6611
- var nonEmpty = import_zod16.z.string().min(1);
6612
- var nonNegativeInt2 = import_zod16.z.coerce.number().int().min(0);
6775
+ var nonEmpty = import_zod17.z.string().min(1);
6776
+ var nonNegativeInt2 = import_zod17.z.coerce.number().int().min(0);
6613
6777
  var MIGRATED_BRANCHES = ["directory", "projects", "knowledge"];
6614
6778
  function normalizeText(input) {
6615
6779
  if (typeof input !== "string") return "";
@@ -7392,11 +7556,11 @@ function registerMutationCapabilityCommands(program) {
7392
7556
  // src/commands/osmd.ts
7393
7557
  var import_promises3 = require("fs/promises");
7394
7558
  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([
7559
+ var import_zod18 = require("zod");
7560
+ var sourceSchema = import_zod18.z.enum(["canonical_osmd", "agent_overlay", "agent_wiki"]);
7561
+ var accessSchema = import_zod18.z.enum(["read_only", "read_write", "append_only"]).catch("read_write");
7562
+ var ownerSchema = import_zod18.z.enum(["system", "atlas"]);
7563
+ var suggestedActionSchema = import_zod18.z.enum([
7400
7564
  "read",
7401
7565
  "create",
7402
7566
  "init",
@@ -7405,7 +7569,7 @@ var suggestedActionSchema = import_zod17.z.enum([
7405
7569
  "forbidden",
7406
7570
  "invalid_parent"
7407
7571
  ]).catch("update");
7408
- var agentMarkdownErrorCodeSchema = import_zod17.z.enum([
7572
+ var agentMarkdownErrorCodeSchema = import_zod18.z.enum([
7409
7573
  "canonical_osmd_read_only",
7410
7574
  "agent_parent_not_found",
7411
7575
  "agent_file_not_found",
@@ -7416,9 +7580,9 @@ var agentMarkdownErrorCodeSchema = import_zod17.z.enum([
7416
7580
  "invalid_agent_wiki_path"
7417
7581
  ]);
7418
7582
  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);
7583
+ var nonEmptyString3 = import_zod18.z.string().min(1);
7584
+ var nonNegativeInt3 = import_zod18.z.coerce.number().int().min(0);
7585
+ var positiveInt = import_zod18.z.coerce.number().int().min(1);
7422
7586
  var supportedAgentOverlaySystemFiles = ["notes.md", "summary.md"];
7423
7587
  var supportedWikiIndexFile = "index.md";
7424
7588
  var supportedWikiLogFile = "log.md";
@@ -7434,20 +7598,20 @@ var supportedWikiControlledPatterns = supportedWikiControlledFolders.map(
7434
7598
  );
7435
7599
  var controlledWikiSlugPattern = /^[a-z0-9][a-z0-9-]*$/;
7436
7600
  var agentMarkdownSlugPattern = /^[a-z0-9][a-z0-9-]*$/;
7437
- var osmdSearchScopeSchema = import_zod17.z.enum([
7601
+ var osmdSearchScopeSchema = import_zod18.z.enum([
7438
7602
  "os-only",
7439
7603
  "agent-overlay-only",
7440
7604
  "agent-wiki-only",
7441
7605
  "combined"
7442
7606
  ]);
7443
- var osmdLintScopeSchema = import_zod17.z.enum([
7607
+ var osmdLintScopeSchema = import_zod18.z.enum([
7444
7608
  "combined",
7445
7609
  "agent-overlay-only",
7446
7610
  "agent-wiki-only"
7447
7611
  ]);
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([
7612
+ var osmdMemoryQualityScopeSchema = import_zod18.z.enum(["agent-overlay-only"]);
7613
+ var osmdIngestKindSchema = import_zod18.z.enum(["text", "file", "url", "transcript"]);
7614
+ var osmdRawSourceTypeSchema = import_zod18.z.enum([
7451
7615
  "pasted_text",
7452
7616
  "uploaded_markdown",
7453
7617
  "uploaded_text",
@@ -7456,31 +7620,30 @@ var osmdRawSourceTypeSchema = import_zod17.z.enum([
7456
7620
  "meeting_transcript",
7457
7621
  "url"
7458
7622
  ]);
7459
- var defaultOsmdPhantomTimeoutMs = 12e4;
7460
- var agentMarkdownFileSchema = import_zod17.z.preprocess(
7623
+ var agentMarkdownFileSchema = import_zod18.z.preprocess(
7461
7624
  normalizeAgentMarkdownJsonKeys,
7462
- import_zod17.z.object({
7463
- path: import_zod17.z.string(),
7625
+ import_zod18.z.object({
7626
+ path: import_zod18.z.string(),
7464
7627
  source: sourceSchema,
7465
7628
  access: accessSchema,
7466
7629
  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(),
7630
+ exists: import_zod18.z.boolean(),
7631
+ canCreate: import_zod18.z.boolean(),
7632
+ canUpdate: import_zod18.z.boolean(),
7633
+ canAppend: import_zod18.z.boolean(),
7634
+ wikiRole: import_zod18.z.string().nullable().optional(),
7635
+ formatVersion: import_zod18.z.string().nullable().optional(),
7636
+ createdAt: import_zod18.z.string().nullable().optional(),
7637
+ updatedAt: import_zod18.z.string().nullable().optional(),
7638
+ ingestedAt: import_zod18.z.string().nullable().optional(),
7639
+ lastSeenAt: import_zod18.z.string().nullable().optional(),
7640
+ canonicalParentUpdatedAt: import_zod18.z.string().nullable().optional(),
7641
+ parentRef: import_zod18.z.string().nullable().optional(),
7642
+ agentChildrenAllowed: import_zod18.z.boolean(),
7480
7643
  suggestedAction: suggestedActionSchema,
7481
7644
  errorCode: agentMarkdownErrorCodeFieldSchema.optional(),
7482
- content: import_zod17.z.string().nullable().optional(),
7483
- url: import_zod17.z.string().nullable().optional()
7645
+ content: import_zod18.z.string().nullable().optional(),
7646
+ url: import_zod18.z.string().nullable().optional()
7484
7647
  }).transform((value) => ({
7485
7648
  ...value,
7486
7649
  wikiRole: value.wikiRole ?? null,
@@ -7496,31 +7659,31 @@ var agentMarkdownFileSchema = import_zod17.z.preprocess(
7496
7659
  url: value.url ?? null
7497
7660
  }))
7498
7661
  );
7499
- var agentMarkdownFilesSchema = import_zod17.z.array(agentMarkdownFileSchema);
7500
- var agentMarkdownMutationDataSchema = import_zod17.z.union([
7662
+ var agentMarkdownFilesSchema = import_zod18.z.array(agentMarkdownFileSchema);
7663
+ var agentMarkdownMutationDataSchema = import_zod18.z.union([
7501
7664
  agentMarkdownFileSchema,
7502
- import_zod17.z.object({ files: agentMarkdownFilesSchema })
7665
+ import_zod18.z.object({ files: agentMarkdownFilesSchema })
7503
7666
  ]);
7504
- var osmdSearchCandidateSchema = import_zod17.z.preprocess(
7667
+ var osmdSearchCandidateSchema = import_zod18.z.preprocess(
7505
7668
  normalizeAgentMarkdownJsonKeys,
7506
- import_zod17.z.object({
7507
- path: import_zod17.z.string(),
7669
+ import_zod18.z.object({
7670
+ path: import_zod18.z.string(),
7508
7671
  source: sourceSchema,
7509
7672
  access: accessSchema,
7510
7673
  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()
7674
+ wikiRole: import_zod18.z.string().nullable().optional(),
7675
+ formatVersion: import_zod18.z.string().nullable().optional(),
7676
+ parentRef: import_zod18.z.string().nullable().optional(),
7677
+ exists: import_zod18.z.boolean(),
7678
+ agentChildrenAllowed: import_zod18.z.boolean(),
7679
+ title: import_zod18.z.string(),
7680
+ label: import_zod18.z.string(),
7681
+ snippet: import_zod18.z.string().nullable().optional(),
7682
+ rank: import_zod18.z.number().int(),
7683
+ matchReason: import_zod18.z.string().nullable().optional(),
7684
+ toolKey: import_zod18.z.string().nullable().optional(),
7685
+ nodeKey: import_zod18.z.string().nullable().optional(),
7686
+ nodeKind: import_zod18.z.string().nullable().optional()
7524
7687
  }).transform((value) => ({
7525
7688
  ...value,
7526
7689
  wikiRole: value.wikiRole ?? null,
@@ -7533,26 +7696,26 @@ var osmdSearchCandidateSchema = import_zod17.z.preprocess(
7533
7696
  nodeKind: value.nodeKind ?? null
7534
7697
  }))
7535
7698
  );
7536
- var osmdSearchResultSchema = import_zod17.z.preprocess(
7699
+ var osmdSearchResultSchema = import_zod18.z.preprocess(
7537
7700
  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)
7701
+ import_zod18.z.object({
7702
+ query: import_zod18.z.string(),
7703
+ scope: import_zod18.z.string(),
7704
+ count: import_zod18.z.number().int().min(0),
7705
+ candidates: import_zod18.z.array(osmdSearchCandidateSchema)
7543
7706
  })
7544
7707
  );
7545
- var osmdWikiLintIssueSchema = import_zod17.z.preprocess(
7708
+ var osmdWikiLintIssueSchema = import_zod18.z.preprocess(
7546
7709
  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()
7710
+ import_zod18.z.object({
7711
+ code: import_zod18.z.string(),
7712
+ severity: import_zod18.z.string(),
7713
+ path: import_zod18.z.string(),
7714
+ source: import_zod18.z.string().nullable().optional(),
7715
+ parentRef: import_zod18.z.string().nullable().optional(),
7716
+ message: import_zod18.z.string(),
7717
+ suggestedAction: import_zod18.z.string().nullable().optional(),
7718
+ canAutoFix: import_zod18.z.boolean()
7556
7719
  }).transform((value) => ({
7557
7720
  ...value,
7558
7721
  source: value.source ?? null,
@@ -7560,37 +7723,37 @@ var osmdWikiLintIssueSchema = import_zod17.z.preprocess(
7560
7723
  suggestedAction: value.suggestedAction ?? null
7561
7724
  }))
7562
7725
  );
7563
- var osmdWikiLintResultSchema = import_zod17.z.preprocess(
7726
+ var osmdWikiLintResultSchema = import_zod18.z.preprocess(
7564
7727
  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)
7728
+ import_zod18.z.object({
7729
+ status: import_zod18.z.string(),
7730
+ summary: import_zod18.z.object({
7731
+ totalIssues: import_zod18.z.number().int().min(0),
7732
+ errors: import_zod18.z.number().int().min(0),
7733
+ warnings: import_zod18.z.number().int().min(0),
7734
+ suggestions: import_zod18.z.number().int().min(0)
7572
7735
  }),
7573
- issues: import_zod17.z.array(osmdWikiLintIssueSchema)
7736
+ issues: import_zod18.z.array(osmdWikiLintIssueSchema)
7574
7737
  })
7575
7738
  );
7576
- var nullableCountSchema = import_zod17.z.preprocess(
7739
+ var nullableCountSchema = import_zod18.z.preprocess(
7577
7740
  (value) => value === void 0 || value === null || value === "" ? null : value,
7578
- import_zod17.z.coerce.number().int().min(0).nullable()
7741
+ import_zod18.z.coerce.number().int().min(0).nullable()
7579
7742
  ).catch(null);
7580
- var osmdMemoryQualityIssueSchema = import_zod17.z.preprocess(
7743
+ var osmdMemoryQualityIssueSchema = import_zod18.z.preprocess(
7581
7744
  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()
7745
+ import_zod18.z.object({
7746
+ code: import_zod18.z.string().nullable().optional(),
7747
+ issueCode: import_zod18.z.string().nullable().optional(),
7748
+ path: import_zod18.z.string().nullable().optional(),
7749
+ parentRef: import_zod18.z.string().nullable().optional(),
7750
+ dimension: import_zod18.z.string().nullable().optional(),
7751
+ evidence: import_zod18.z.string().nullable().optional(),
7752
+ evidenceSnippet: import_zod18.z.string().nullable().optional(),
7753
+ message: import_zod18.z.string().nullable().optional(),
7754
+ severity: import_zod18.z.string().nullable().optional(),
7755
+ suggestedAction: import_zod18.z.string().nullable().optional(),
7756
+ canAutoFix: import_zod18.z.boolean().nullable().optional()
7594
7757
  }).passthrough().transform((value) => ({
7595
7758
  ...value,
7596
7759
  code: value.code ?? value.issueCode ?? "unknown_issue",
@@ -7605,16 +7768,16 @@ var osmdMemoryQualityIssueSchema = import_zod17.z.preprocess(
7605
7768
  canAutoFix: value.canAutoFix === true ? true : false
7606
7769
  }))
7607
7770
  );
7608
- var osmdMemoryQualityOverlaySchema = import_zod17.z.preprocess(
7771
+ var osmdMemoryQualityOverlaySchema = import_zod18.z.preprocess(
7609
7772
  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()
7773
+ import_zod18.z.object({
7774
+ path: import_zod18.z.string().nullable().optional(),
7775
+ parentRef: import_zod18.z.string().nullable().optional(),
7776
+ status: import_zod18.z.string().nullable().optional(),
7777
+ score: import_zod18.z.union([import_zod18.z.number(), import_zod18.z.string()]).nullable().optional(),
7778
+ overallScore: import_zod18.z.union([import_zod18.z.number(), import_zod18.z.string()]).nullable().optional(),
7779
+ dimensions: import_zod18.z.unknown().nullable().optional(),
7780
+ issues: import_zod18.z.array(osmdMemoryQualityIssueSchema).optional()
7618
7781
  }).passthrough().transform((value) => ({
7619
7782
  ...value,
7620
7783
  path: value.path ?? null,
@@ -7626,9 +7789,9 @@ var osmdMemoryQualityOverlaySchema = import_zod17.z.preprocess(
7626
7789
  issues: value.issues ?? []
7627
7790
  }))
7628
7791
  );
7629
- var osmdMemoryQualitySummarySchema = import_zod17.z.preprocess(
7792
+ var osmdMemoryQualitySummarySchema = import_zod18.z.preprocess(
7630
7793
  normalizeAgentMarkdownJsonKeys,
7631
- import_zod17.z.object({
7794
+ import_zod18.z.object({
7632
7795
  evaluatedCount: nullableCountSchema.optional(),
7633
7796
  passCount: nullableCountSchema.optional(),
7634
7797
  warnCount: nullableCountSchema.optional(),
@@ -7646,19 +7809,19 @@ var osmdMemoryQualitySummarySchema = import_zod17.z.preprocess(
7646
7809
  failCount: value.failCount ?? value.failures ?? null
7647
7810
  }))
7648
7811
  );
7649
- var osmdMemoryQualityResultSchema = import_zod17.z.preprocess(
7812
+ var osmdMemoryQualityResultSchema = import_zod18.z.preprocess(
7650
7813
  normalizeAgentMarkdownJsonKeys,
7651
- import_zod17.z.object({
7652
- status: import_zod17.z.string(),
7653
- scope: import_zod17.z.string().nullable().optional(),
7814
+ import_zod18.z.object({
7815
+ status: import_zod18.z.string(),
7816
+ scope: import_zod18.z.string().nullable().optional(),
7654
7817
  evaluatedCount: nullableCountSchema.optional(),
7655
7818
  passCount: nullableCountSchema.optional(),
7656
7819
  warnCount: nullableCountSchema.optional(),
7657
7820
  failCount: nullableCountSchema.optional(),
7658
7821
  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()
7822
+ weakestOverlays: import_zod18.z.array(osmdMemoryQualityOverlaySchema).optional(),
7823
+ issues: import_zod18.z.array(osmdMemoryQualityIssueSchema).optional(),
7824
+ scores: import_zod18.z.array(osmdMemoryQualityOverlaySchema).optional()
7662
7825
  }).passthrough().transform((value) => {
7663
7826
  const summary = isRecord5(value.summary) ? value.summary : null;
7664
7827
  return {
@@ -7682,24 +7845,24 @@ function normalizeOsmdIngestFileRecordInput(value) {
7682
7845
  }
7683
7846
  return normalized;
7684
7847
  }
7685
- var osmdIngestFileRecordSchema = import_zod17.z.preprocess(
7848
+ var osmdIngestFileRecordSchema = import_zod18.z.preprocess(
7686
7849
  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()
7850
+ import_zod18.z.object({
7851
+ path: import_zod18.z.string(),
7852
+ source: import_zod18.z.string().nullable().optional(),
7853
+ access: import_zod18.z.string().nullable().optional(),
7854
+ owner: import_zod18.z.string().nullable().optional(),
7855
+ parentRef: import_zod18.z.string().nullable().optional(),
7856
+ exists: import_zod18.z.boolean().nullable().optional(),
7857
+ canCreate: import_zod18.z.boolean().nullable().optional(),
7858
+ canUpdate: import_zod18.z.boolean().nullable().optional(),
7859
+ canAppend: import_zod18.z.boolean().nullable().optional(),
7860
+ wikiRole: import_zod18.z.string().nullable().optional(),
7861
+ formatVersion: import_zod18.z.string().nullable().optional(),
7862
+ createdAt: import_zod18.z.string().nullable().optional(),
7863
+ updatedAt: import_zod18.z.string().nullable().optional(),
7864
+ suggestedAction: import_zod18.z.string().nullable().optional(),
7865
+ errorCode: import_zod18.z.string().nullable().optional()
7703
7866
  }).passthrough().transform((value) => ({
7704
7867
  ...value,
7705
7868
  source: value.source ?? null,
@@ -7718,17 +7881,17 @@ var osmdIngestFileRecordSchema = import_zod17.z.preprocess(
7718
7881
  errorCode: value.errorCode ?? null
7719
7882
  }))
7720
7883
  );
7721
- var osmdIngestResultSchema = import_zod17.z.preprocess(
7884
+ var osmdIngestResultSchema = import_zod18.z.preprocess(
7722
7885
  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(),
7886
+ import_zod18.z.object({
7887
+ rawSourceId: import_zod18.z.union([import_zod18.z.string(), import_zod18.z.number()]).nullable().optional(),
7888
+ sourceSummaryPath: import_zod18.z.string().nullable().optional(),
7726
7889
  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(),
7890
+ slug: import_zod18.z.string().nullable().optional(),
7891
+ runLint: import_zod18.z.boolean().nullable().optional(),
7892
+ createdFiles: import_zod18.z.array(osmdIngestFileRecordSchema).optional(),
7893
+ updatedFiles: import_zod18.z.array(osmdIngestFileRecordSchema).optional(),
7894
+ skippedUpdates: import_zod18.z.array(import_zod18.z.unknown()).optional(),
7732
7895
  lintResult: osmdWikiLintResultSchema.nullable().optional()
7733
7896
  }).passthrough().transform((value) => ({
7734
7897
  ...value,
@@ -7743,127 +7906,37 @@ var osmdIngestResultSchema = import_zod17.z.preprocess(
7743
7906
  lintResult: value.lintResult ?? null
7744
7907
  }))
7745
7908
  );
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()
7909
+ var mutationPayloadSchema = import_zod18.z.object({
7910
+ ok: import_zod18.z.boolean(),
7911
+ status: import_zod18.z.number(),
7912
+ errorCode: import_zod18.z.string().nullable().optional(),
7913
+ data: import_zod18.z.unknown().nullable().optional(),
7914
+ errors: import_zod18.z.unknown().nullable().optional()
7842
7915
  });
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),
7916
+ var markdownTreeNodeSchema = import_zod18.z.lazy(
7917
+ () => import_zod18.z.object({
7918
+ toolKey: import_zod18.z.string(),
7919
+ nodeKey: import_zod18.z.string(),
7920
+ nodeKind: import_zod18.z.string(),
7921
+ runtimeLabel: import_zod18.z.string(),
7922
+ path: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7850
7923
  source: sourceSchema,
7851
7924
  access: accessSchema,
7852
7925
  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)
7926
+ parentRef: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7927
+ agentChildrenAllowed: import_zod18.z.boolean(),
7928
+ exists: import_zod18.z.boolean(),
7929
+ resolvedScope: import_zod18.z.object({
7930
+ parentId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7931
+ recordId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7932
+ memberId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7933
+ teamId: import_zod18.z.string().nullable().optional().transform((value) => value ?? null),
7934
+ contentType: import_zod18.z.string().nullable().optional().transform((value) => value ?? null)
7862
7935
  }),
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 ?? [])
7936
+ isLeaf: import_zod18.z.boolean(),
7937
+ treeView: import_zod18.z.boolean(),
7938
+ details: import_zod18.z.unknown().nullable(),
7939
+ children: import_zod18.z.array(markdownTreeNodeSchema).optional().transform((value) => value ?? [])
7867
7940
  })
7868
7941
  );
7869
7942
  var AGENT_MARKDOWN_FILE_SELECTION = `{
@@ -8124,86 +8197,6 @@ function normalizeAgentMarkdownJsonKeys(value) {
8124
8197
  }
8125
8198
  return normalized;
8126
8199
  }
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
8200
  function buildSuccessEnvelope(params) {
8208
8201
  return {
8209
8202
  ok: true,
@@ -8623,51 +8616,6 @@ async function runOsmdIngestFlow(params) {
8623
8616
  })
8624
8617
  });
8625
8618
  }
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
8619
  function normalizeAgentFilePath(file) {
8672
8620
  const trimmed = nonEmptyString3.parse(file).trim().replace(/^\/+|\/+$/g, "");
8673
8621
  const fileName = trimmed.startsWith(".agent/") ? trimmed.slice(".agent/".length) : trimmed;
@@ -9078,62 +9026,6 @@ function formatIngestFileList(files) {
9078
9026
  return `- ${path}${action}`;
9079
9027
  });
9080
9028
  }
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
9029
  function formatSkippedUpdateList(skippedUpdates) {
9138
9030
  if (skippedUpdates.length === 0) {
9139
9031
  return ["- none"];
@@ -9172,72 +9064,6 @@ function formatOsmdIngestHuman(data) {
9172
9064
  function formatNullableNumberHumanField(value) {
9173
9065
  return typeof value === "number" ? String(value) : "-";
9174
9066
  }
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
9067
  function parseSearchLimit(value) {
9242
9068
  const raw = value === void 0 || value === null || value === "" ? "10" : value;
9243
9069
  const parsed = positiveInt.safeParse(raw);
@@ -10005,18 +9831,6 @@ function registerOsmdCommands(program) {
10005
9831
  throw error;
10006
9832
  }
10007
9833
  });
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
9834
  const agent = osmd.command("agent").description(".agent markdown attached to canonical OSMD parents");
10021
9835
  agent.command("status <parent-ref> <file>").description("Show .agent file metadata without creating files").action(async (parentRef, file, _opts, cmd) => {
10022
9836
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
@@ -13012,14 +12826,14 @@ function registerMailCommands(program) {
13012
12826
  }
13013
12827
 
13014
12828
  // 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(
12829
+ var import_zod19 = require("zod");
12830
+ var nonNegativeInt4 = import_zod19.z.coerce.number().int().min(0);
12831
+ var nullableString = import_zod19.z.string().nullable().optional().transform((value) => value ?? null);
12832
+ var idString = import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).transform((value) => String(value));
12833
+ var nullableIdString = import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).nullable().optional().transform(
13020
12834
  (value) => value === void 0 || value === null ? null : String(value)
13021
12835
  );
13022
- var jsonObject = import_zod18.z.record(import_zod18.z.string(), import_zod18.z.unknown());
12836
+ var jsonObject = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.unknown());
13023
12837
  var PHANTOM_LEDGER_INVENTORY_SELECTION = `{
13024
12838
  schemaVersion
13025
12839
  runsCount
@@ -13232,10 +13046,10 @@ var PHANTOM_LEDGER_KEY_ALIASES = {
13232
13046
  content_hash: "contentHash",
13233
13047
  observed_at: "observedAt"
13234
13048
  };
13235
- var phantomLedgerInventorySchema = import_zod18.z.preprocess(
13049
+ var phantomLedgerInventorySchema = import_zod19.z.preprocess(
13236
13050
  normalizePhantomLedgerKeys,
13237
- import_zod18.z.object({
13238
- schemaVersion: import_zod18.z.string(),
13051
+ import_zod19.z.object({
13052
+ schemaVersion: import_zod19.z.string(),
13239
13053
  runsCount: nonNegativeInt4,
13240
13054
  observationsCount: nonNegativeInt4,
13241
13055
  candidatesCount: nonNegativeInt4,
@@ -13245,16 +13059,16 @@ var phantomLedgerInventorySchema = import_zod18.z.preprocess(
13245
13059
  reportsCount: nonNegativeInt4
13246
13060
  })
13247
13061
  );
13248
- var phantomRunSchema = import_zod18.z.preprocess(
13062
+ var phantomRunSchema = import_zod19.z.preprocess(
13249
13063
  normalizePhantomLedgerKeys,
13250
- import_zod18.z.object({
13064
+ import_zod19.z.object({
13251
13065
  id: idString,
13252
13066
  organizationId: idString,
13253
- notificationId: import_zod18.z.union([import_zod18.z.string(), import_zod18.z.number()]).nullable().optional().transform(
13067
+ notificationId: import_zod19.z.union([import_zod19.z.string(), import_zod19.z.number()]).nullable().optional().transform(
13254
13068
  (value) => value === void 0 || value === null ? null : String(value)
13255
13069
  ),
13256
- status: import_zod18.z.string(),
13257
- triggerType: import_zod18.z.string(),
13070
+ status: import_zod19.z.string(),
13071
+ triggerType: import_zod19.z.string(),
13258
13072
  startedAt: nullableString,
13259
13073
  completedAt: nullableString,
13260
13074
  scannedFileCount: nonNegativeInt4,
@@ -13264,163 +13078,163 @@ var phantomRunSchema = import_zod18.z.preprocess(
13264
13078
  errorCount: nonNegativeInt4,
13265
13079
  warningCount: nonNegativeInt4,
13266
13080
  errorMessage: nullableString,
13267
- dryRun: import_zod18.z.boolean(),
13268
- schemaVersion: import_zod18.z.string(),
13081
+ dryRun: import_zod19.z.boolean(),
13082
+ schemaVersion: import_zod19.z.string(),
13269
13083
  testRunId: nullableString,
13270
13084
  idempotencyKey: nullableString,
13271
13085
  ledgerMetadata: jsonObject.catch({}),
13272
- createdAt: import_zod18.z.string(),
13273
- updatedAt: import_zod18.z.string()
13086
+ createdAt: import_zod19.z.string(),
13087
+ updatedAt: import_zod19.z.string()
13274
13088
  })
13275
13089
  );
13276
- var phantomRunListItemSchema = import_zod18.z.preprocess(
13090
+ var phantomRunListItemSchema = import_zod19.z.preprocess(
13277
13091
  normalizePhantomLedgerKeys,
13278
- import_zod18.z.object({
13092
+ import_zod19.z.object({
13279
13093
  id: idString,
13280
13094
  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(),
13095
+ status: import_zod19.z.string(),
13096
+ triggerType: import_zod19.z.string(),
13097
+ dryRun: import_zod19.z.boolean(),
13098
+ schemaVersion: import_zod19.z.string(),
13285
13099
  testRunId: nullableString,
13286
- createdAt: import_zod18.z.string(),
13287
- updatedAt: import_zod18.z.string()
13100
+ createdAt: import_zod19.z.string(),
13101
+ updatedAt: import_zod19.z.string()
13288
13102
  })
13289
13103
  );
13290
- var phantomReportSchema = import_zod18.z.preprocess(
13104
+ var phantomReportSchema = import_zod19.z.preprocess(
13291
13105
  normalizePhantomLedgerKeys,
13292
- import_zod18.z.object({
13106
+ import_zod19.z.object({
13293
13107
  id: idString,
13294
13108
  organizationId: idString,
13295
13109
  phantomRunId: idString,
13296
- status: import_zod18.z.string(),
13297
- reportType: import_zod18.z.string(),
13298
- schemaVersion: import_zod18.z.string(),
13110
+ status: import_zod19.z.string(),
13111
+ reportType: import_zod19.z.string(),
13112
+ schemaVersion: import_zod19.z.string(),
13299
13113
  markdownPath: nullableString,
13300
13114
  payload: jsonObject.catch({}),
13301
13115
  testRunId: nullableString,
13302
- idempotencyKey: import_zod18.z.string(),
13303
- createdAt: import_zod18.z.string(),
13304
- updatedAt: import_zod18.z.string()
13116
+ idempotencyKey: import_zod19.z.string(),
13117
+ createdAt: import_zod19.z.string(),
13118
+ updatedAt: import_zod19.z.string()
13305
13119
  })
13306
13120
  );
13307
- var phantomObservationSchema = import_zod18.z.preprocess(
13121
+ var phantomObservationSchema = import_zod19.z.preprocess(
13308
13122
  normalizePhantomLedgerKeys,
13309
- import_zod18.z.object({
13123
+ import_zod19.z.object({
13310
13124
  id: idString,
13311
13125
  organizationId: idString,
13312
13126
  phantomRunId: idString,
13313
- status: import_zod18.z.string(),
13314
- observationType: import_zod18.z.string(),
13127
+ status: import_zod19.z.string(),
13128
+ observationType: import_zod19.z.string(),
13315
13129
  targetType: nullableString,
13316
13130
  targetId: nullableString,
13317
13131
  sourceTable: nullableString,
13318
13132
  sourceRecordId: nullableString,
13319
13133
  sourceEventId: nullableString,
13320
13134
  contentHash: nullableString,
13321
- observedAt: import_zod18.z.string(),
13322
- confidence: import_zod18.z.coerce.number(),
13135
+ observedAt: import_zod19.z.string(),
13136
+ confidence: import_zod19.z.coerce.number(),
13323
13137
  payload: jsonObject.catch({}),
13324
- schemaVersion: import_zod18.z.string(),
13138
+ schemaVersion: import_zod19.z.string(),
13325
13139
  testRunId: nullableString,
13326
- idempotencyKey: import_zod18.z.string(),
13327
- createdAt: import_zod18.z.string(),
13328
- updatedAt: import_zod18.z.string()
13140
+ idempotencyKey: import_zod19.z.string(),
13141
+ createdAt: import_zod19.z.string(),
13142
+ updatedAt: import_zod19.z.string()
13329
13143
  })
13330
13144
  );
13331
- var phantomCandidateSchema = import_zod18.z.preprocess(
13145
+ var phantomCandidateSchema = import_zod19.z.preprocess(
13332
13146
  normalizePhantomLedgerKeys,
13333
- import_zod18.z.object({
13147
+ import_zod19.z.object({
13334
13148
  id: idString,
13335
13149
  organizationId: idString,
13336
13150
  phantomRunId: idString,
13337
13151
  phantomObservationId: nullableString,
13338
- status: import_zod18.z.string(),
13339
- candidateType: import_zod18.z.string(),
13152
+ status: import_zod19.z.string(),
13153
+ candidateType: import_zod19.z.string(),
13340
13154
  targetType: nullableString,
13341
13155
  targetId: nullableString,
13342
13156
  title: nullableString,
13343
- dryRun: import_zod18.z.boolean(),
13157
+ dryRun: import_zod19.z.boolean(),
13344
13158
  payload: jsonObject.catch({}),
13345
- approvalStatus: import_zod18.z.string(),
13159
+ approvalStatus: import_zod19.z.string(),
13346
13160
  approvedById: nullableIdString,
13347
13161
  approvedAt: nullableString,
13348
13162
  approvalSource: nullableString,
13349
13163
  approvalReason: nullableString,
13350
13164
  approvalMetadata: jsonObject.catch({}),
13351
- schemaVersion: import_zod18.z.string(),
13165
+ schemaVersion: import_zod19.z.string(),
13352
13166
  testRunId: nullableString,
13353
- idempotencyKey: import_zod18.z.string(),
13354
- createdAt: import_zod18.z.string(),
13355
- updatedAt: import_zod18.z.string()
13167
+ idempotencyKey: import_zod19.z.string(),
13168
+ createdAt: import_zod19.z.string(),
13169
+ updatedAt: import_zod19.z.string()
13356
13170
  })
13357
13171
  );
13358
- var phantomCandidateEvidenceSchema = import_zod18.z.preprocess(
13172
+ var phantomCandidateEvidenceSchema = import_zod19.z.preprocess(
13359
13173
  normalizePhantomLedgerKeys,
13360
- import_zod18.z.object({
13174
+ import_zod19.z.object({
13361
13175
  id: idString,
13362
13176
  organizationId: idString,
13363
13177
  phantomCandidateId: idString,
13364
13178
  phantomObservationId: nullableString,
13365
- evidenceType: import_zod18.z.string(),
13179
+ evidenceType: import_zod19.z.string(),
13366
13180
  sourceType: nullableString,
13367
13181
  sourceId: nullableString,
13368
13182
  contentHash: nullableString,
13369
13183
  payload: jsonObject.catch({}),
13370
- schemaVersion: import_zod18.z.string(),
13184
+ schemaVersion: import_zod19.z.string(),
13371
13185
  testRunId: nullableString,
13372
- idempotencyKey: import_zod18.z.string(),
13373
- createdAt: import_zod18.z.string(),
13374
- updatedAt: import_zod18.z.string()
13186
+ idempotencyKey: import_zod19.z.string(),
13187
+ createdAt: import_zod19.z.string(),
13188
+ updatedAt: import_zod19.z.string()
13375
13189
  })
13376
13190
  );
13377
- var phantomValidationSchema = import_zod18.z.preprocess(
13191
+ var phantomValidationSchema = import_zod19.z.preprocess(
13378
13192
  normalizePhantomLedgerKeys,
13379
- import_zod18.z.object({
13193
+ import_zod19.z.object({
13380
13194
  id: idString,
13381
13195
  organizationId: idString,
13382
13196
  phantomRunId: idString,
13383
13197
  phantomCandidateId: idString,
13384
- status: import_zod18.z.string(),
13385
- validationType: import_zod18.z.string(),
13386
- dryRun: import_zod18.z.boolean(),
13198
+ status: import_zod19.z.string(),
13199
+ validationType: import_zod19.z.string(),
13200
+ dryRun: import_zod19.z.boolean(),
13387
13201
  payload: jsonObject.catch({}),
13388
13202
  resultPayload: jsonObject.catch({}),
13389
- schemaVersion: import_zod18.z.string(),
13203
+ schemaVersion: import_zod19.z.string(),
13390
13204
  testRunId: nullableString,
13391
- idempotencyKey: import_zod18.z.string(),
13392
- createdAt: import_zod18.z.string(),
13393
- updatedAt: import_zod18.z.string()
13205
+ idempotencyKey: import_zod19.z.string(),
13206
+ createdAt: import_zod19.z.string(),
13207
+ updatedAt: import_zod19.z.string()
13394
13208
  })
13395
13209
  );
13396
- var phantomApplyOperationSchema = import_zod18.z.preprocess(
13210
+ var phantomApplyOperationSchema = import_zod19.z.preprocess(
13397
13211
  normalizePhantomLedgerKeys,
13398
- import_zod18.z.object({
13212
+ import_zod19.z.object({
13399
13213
  id: idString,
13400
13214
  organizationId: idString,
13401
13215
  phantomRunId: idString,
13402
13216
  phantomCandidateId: idString,
13403
- status: import_zod18.z.string(),
13404
- operationType: import_zod18.z.string(),
13405
- dryRun: import_zod18.z.boolean(),
13217
+ status: import_zod19.z.string(),
13218
+ operationType: import_zod19.z.string(),
13219
+ dryRun: import_zod19.z.boolean(),
13406
13220
  targetType: nullableString,
13407
13221
  targetId: nullableString,
13408
13222
  payload: jsonObject.catch({}),
13409
13223
  resultPayload: jsonObject.catch({}),
13410
- schemaVersion: import_zod18.z.string(),
13224
+ schemaVersion: import_zod19.z.string(),
13411
13225
  testRunId: nullableString,
13412
- idempotencyKey: import_zod18.z.string(),
13413
- createdAt: import_zod18.z.string(),
13414
- updatedAt: import_zod18.z.string()
13226
+ idempotencyKey: import_zod19.z.string(),
13227
+ createdAt: import_zod19.z.string(),
13228
+ updatedAt: import_zod19.z.string()
13415
13229
  })
13416
13230
  );
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);
13231
+ var phantomRunsSchema = import_zod19.z.array(phantomRunListItemSchema);
13232
+ var phantomReportsSchema = import_zod19.z.array(phantomReportSchema);
13233
+ var phantomObservationsSchema = import_zod19.z.array(phantomObservationSchema);
13234
+ var phantomCandidatesSchema = import_zod19.z.array(phantomCandidateSchema);
13235
+ var phantomCandidateEvidencesSchema = import_zod19.z.array(phantomCandidateEvidenceSchema);
13236
+ var phantomValidationsSchema = import_zod19.z.array(phantomValidationSchema);
13237
+ var phantomApplyOperationsSchema = import_zod19.z.array(phantomApplyOperationSchema);
13424
13238
  function isRecord6(value) {
13425
13239
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13426
13240
  }
@@ -14877,72 +14691,72 @@ function registerDatasheetsCommands(program) {
14877
14691
  }
14878
14692
 
14879
14693
  // 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);
14694
+ var import_zod20 = require("zod");
14695
+ var idSchema14 = import_zod20.z.string().trim().min(1);
14696
+ var idempotencyKeySchema = import_zod20.z.string().min(1).refine((value) => value.trim() === value, "Idempotency key must not have leading or trailing whitespace.");
14697
+ var skillScopeSchema = import_zod20.z.enum(["ADMIN_GLOBAL", "MEMBER_PERSONAL"]);
14698
+ var isoDateSchema = import_zod20.z.iso.date();
14699
+ var nonEmptyStringSchema = import_zod20.z.string().trim().min(1);
14886
14700
  var AUTOMATION_RUN_HTTP_TIMEOUT_MS = 6e4;
14887
- var agentToolAccessSchema = import_zod19.z.array(
14888
- import_zod19.z.object({
14701
+ var agentToolAccessSchema = import_zod20.z.array(
14702
+ import_zod20.z.object({
14889
14703
  tool_key: nonEmptyStringSchema,
14890
14704
  scope_value: nonEmptyStringSchema
14891
14705
  }).strict()
14892
14706
  ).min(1);
14893
14707
  var agentToolAccessUpdateSchema = agentToolAccessSchema.min(0);
14894
- var agentPluginConnectionsSchema = import_zod19.z.array(
14895
- import_zod19.z.object({
14708
+ var agentPluginConnectionsSchema = import_zod20.z.array(
14709
+ import_zod20.z.object({
14896
14710
  external_tool_connection_id: nonEmptyStringSchema,
14897
14711
  tool_key: nonEmptyStringSchema,
14898
14712
  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()
14713
+ allowed_tools: import_zod20.z.array(nonEmptyStringSchema).optional(),
14714
+ allowed_scopes: import_zod20.z.array(nonEmptyStringSchema).optional(),
14715
+ requires_confirmation: import_zod20.z.boolean().optional(),
14716
+ enabled: import_zod20.z.boolean().optional()
14903
14717
  }).strict()
14904
14718
  ).min(1);
14905
- var agentPluginConnectionUpdateSchema = import_zod19.z.array(
14906
- import_zod19.z.union([
14907
- import_zod19.z.object({
14719
+ var agentPluginConnectionUpdateSchema = import_zod20.z.array(
14720
+ import_zod20.z.union([
14721
+ import_zod20.z.object({
14908
14722
  id: nonEmptyStringSchema,
14909
- _destroy: import_zod19.z.literal(true)
14723
+ _destroy: import_zod20.z.literal(true)
14910
14724
  }).strict(),
14911
- import_zod19.z.object({
14725
+ import_zod20.z.object({
14912
14726
  id: nonEmptyStringSchema.optional(),
14913
14727
  external_tool_connection_id: nonEmptyStringSchema.optional(),
14914
14728
  tool_key: nonEmptyStringSchema.optional(),
14915
14729
  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()
14730
+ allowed_tools: import_zod20.z.array(nonEmptyStringSchema).optional(),
14731
+ allowed_scopes: import_zod20.z.array(nonEmptyStringSchema).optional(),
14732
+ requires_confirmation: import_zod20.z.boolean().optional(),
14733
+ enabled: import_zod20.z.boolean().optional()
14920
14734
  }).strict().superRefine((value, context) => {
14921
14735
  if (value.id || value.external_tool_connection_id && value.tool_key) return;
14922
14736
  context.addIssue({
14923
- code: import_zod19.z.ZodIssueCode.custom,
14737
+ code: import_zod20.z.ZodIssueCode.custom,
14924
14738
  message: "Plugin updates require an id, or both external_tool_connection_id and tool_key for a new grant."
14925
14739
  });
14926
14740
  })
14927
14741
  ])
14928
14742
  );
14929
- var agentTriggerSchema = import_zod19.z.object({
14930
- trigger_type: import_zod19.z.literal("cron"),
14743
+ var agentTriggerSchema = import_zod20.z.object({
14744
+ trigger_type: import_zod20.z.literal("cron"),
14931
14745
  cron_expression: nonEmptyStringSchema,
14932
14746
  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()
14747
+ starts_at: import_zod20.z.iso.datetime({ offset: true }).nullable().optional(),
14748
+ ends_at: import_zod20.z.iso.datetime({ offset: true }).nullable().optional(),
14749
+ max_runs: import_zod20.z.number().int().positive().nullable().optional(),
14750
+ enabled: import_zod20.z.boolean().optional()
14937
14751
  }).strict();
14938
- var agentTriggerUpdateSchema = import_zod19.z.union([
14752
+ var agentTriggerUpdateSchema = import_zod20.z.union([
14939
14753
  agentTriggerSchema.extend({ id: nonEmptyStringSchema.optional() }).strict(),
14940
- import_zod19.z.object({
14754
+ import_zod20.z.object({
14941
14755
  id: nonEmptyStringSchema,
14942
- _destroy: import_zod19.z.literal(true)
14756
+ _destroy: import_zod20.z.literal(true)
14943
14757
  }).strict()
14944
14758
  ]);
14945
- var automationConfigSchema = import_zod19.z.record(import_zod19.z.string(), import_zod19.z.unknown());
14759
+ var automationConfigSchema = import_zod20.z.record(import_zod20.z.string(), import_zod20.z.unknown());
14946
14760
  var AGENT_SELECTION = `{
14947
14761
  id
14948
14762
  type
@@ -15018,6 +14832,11 @@ var AUTOMATION_SELECTION = `{
15018
14832
  organizationId
15019
14833
  memberId
15020
14834
  agentId
14835
+ agentTriggerId
14836
+ scheduleStatus
14837
+ triggerEnabled
14838
+ cronExpression
14839
+ timezone
15021
14840
  createdAt
15022
14841
  updatedAt
15023
14842
  updateVersion
@@ -15224,7 +15043,16 @@ function normalizeAutomationRunPayload(payload) {
15224
15043
  };
15225
15044
  }
15226
15045
  function parseAutomationConfig(value) {
15227
- return automationConfigSchema.parse(parseJson(String(value), "--ai-task-config"));
15046
+ const config = automationConfigSchema.parse(parseJson(String(value), "--ai-task-config"));
15047
+ if (Object.hasOwn(config, "agent_id") || Object.hasOwn(config, "agentId")) {
15048
+ throw new CliError({
15049
+ message: "Automation executor agent_id must be supplied through --agent-id, not --ai-task-config.",
15050
+ kind: "invalid_args",
15051
+ status: 400,
15052
+ exitCode: EXIT_CODES.invalidArgs
15053
+ });
15054
+ }
15055
+ return config;
15228
15056
  }
15229
15057
  function parseExpectedUpdateVersion(value) {
15230
15058
  return nonEmptyStringSchema.parse(String(value));
@@ -15433,7 +15261,7 @@ function registerAtlasAuthoringCommands(program) {
15433
15261
  "--service <service>",
15434
15262
  "Supported service: gmail, calendar, slack, or stripe"
15435
15263
  ).action(async (opts, cmd) => {
15436
- const service = import_zod19.z.enum(["gmail", "calendar", "slack", "stripe"]).parse(opts.service);
15264
+ const service = import_zod20.z.enum(["gmail", "calendar", "slack", "stripe"]).parse(opts.service);
15437
15265
  const context = await resolveCommandContext(cmd.optsWithGlobals());
15438
15266
  const organizationId = resolveOrganizationId(context.organizationId);
15439
15267
  await runGraphqlQueryCommand({
@@ -15447,7 +15275,7 @@ function registerAtlasAuthoringCommands(program) {
15447
15275
  });
15448
15276
  });
15449
15277
  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) => {
15278
+ 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
15279
  const idempotencyKey = idempotencyKeySchema.parse(opts.idempotencyKey);
15452
15280
  const context = await resolveCommandContext(cmd.optsWithGlobals());
15453
15281
  const organizationId = resolveOrganizationId(context.organizationId);
@@ -15465,7 +15293,7 @@ function registerAtlasAuthoringCommands(program) {
15465
15293
  organization_id: organizationId,
15466
15294
  input: {
15467
15295
  summary: idSchema14.parse(opts.summary),
15468
- ai_task_config: parseJson(String(opts.aiTaskConfig), "--ai-task-config"),
15296
+ ai_task_config: parseAutomationConfig(opts.aiTaskConfig),
15469
15297
  ...opts.description !== void 0 ? { description: String(opts.description) } : {},
15470
15298
  ...opts.notes !== void 0 ? { notes: String(opts.notes) } : {},
15471
15299
  ...opts.memberId !== void 0 ? { member_id: idSchema14.parse(opts.memberId) } : {},
@@ -15536,20 +15364,17 @@ function registerAtlasAuthoringCommands(program) {
15536
15364
  "Exact opaque updateVersion value from automations show; rejects stale writes"
15537
15365
  ).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
15366
  "--agent-id <agentId>",
15539
- "Executor Agent id; requires --ai-task-config and is stored in that config"
15367
+ "Rejected: executor ownership is immutable after Automation creation"
15540
15368
  ).action(async (opts, cmd) => {
15541
- if (opts.agentId !== void 0 && opts.aiTaskConfig === void 0) {
15369
+ if (opts.agentId !== void 0) {
15542
15370
  throw new CliError({
15543
- message: "automations update requires --ai-task-config whenever --agent-id is supplied.",
15371
+ message: "automations update cannot change executor ownership; create a new Automation instead.",
15544
15372
  kind: "invalid_args",
15545
15373
  status: 400,
15546
15374
  exitCode: EXIT_CODES.invalidArgs
15547
15375
  });
15548
15376
  }
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
- };
15377
+ const aiTaskConfig = opts.aiTaskConfig === void 0 ? void 0 : parseAutomationConfig(opts.aiTaskConfig);
15553
15378
  const patch = {
15554
15379
  ...opts.summary !== void 0 ? { summary: String(opts.summary) } : {},
15555
15380
  ...opts.description !== void 0 ? { description: String(opts.description) } : {},
@@ -15672,7 +15497,7 @@ var import_node_path4 = require("path");
15672
15497
  var import_node_crypto3 = require("crypto");
15673
15498
 
15674
15499
  // src/version.ts
15675
- var CLI_VERSION = "0.1.76";
15500
+ var CLI_VERSION = "0.1.77";
15676
15501
 
15677
15502
  // src/operationMetadata.ts
15678
15503
  var DISCOVERY_OPERATION_IDS = [
@@ -16076,7 +15901,6 @@ var WRITE_OPERATION_IDS = [
16076
15901
  "osmd.ingest.text",
16077
15902
  "osmd.ingest.transcript",
16078
15903
  "osmd.ingest.url",
16079
- "osmd.phantom.run",
16080
15904
  "osmd.wiki.append-log",
16081
15905
  "osmd.wiki.create",
16082
15906
  "osmd.wiki.index-upsert",
@@ -16395,22 +16219,21 @@ var NAMESPACE_DOCS = {
16395
16219
  osmd: {
16396
16220
  name: "osmd",
16397
16221
  tier: "primary",
16398
- description: "Canonical OSMD, .agent overlay, Agent Wiki, ingest, lint, and Phantom operations.",
16222
+ description: "Canonical OSMD, .agent overlay, Agent Wiki, ingest, and lint operations.",
16399
16223
  examples: [
16400
16224
  "wave osmd tree --depth 2",
16401
16225
  "wave osmd lint --json",
16402
16226
  '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"
16227
+ 'wave osmd agent update "projects/Wave Tools" notes.md --content "# Notes"'
16405
16228
  ],
16406
16229
  schema: {
16407
16230
  output: "json-envelope-default",
16408
16231
  safety: [
16409
16232
  "Canonical OSMD writes are blocked before mutation.",
16410
16233
  "Agent Wiki log is append-only.",
16411
- "Ingest and Phantom support dry-run paths."
16234
+ "Ingest supports dry-run paths."
16412
16235
  ],
16413
- commands: ["tree", "status", "read", "children", "search", "lint", "memory-quality", "ingest", "phantom", "agent", "wiki"]
16236
+ commands: ["tree", "status", "read", "children", "search", "lint", "memory-quality", "ingest", "agent", "wiki"]
16414
16237
  }
16415
16238
  },
16416
16239
  phantom: {
@@ -17216,7 +17039,7 @@ function registerDiscoveryCommands(program) {
17216
17039
  const phantom = program.commands.find((command) => command.name() === "phantom");
17217
17040
  phantom?.addHelpText(
17218
17041
  "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"
17042
+ "\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
17043
  );
17221
17044
  }
17222
17045
  function attachNamespaceDiscovery(program) {
@@ -17282,12 +17105,11 @@ function attachDiscoveryHelp(program) {
17282
17105
  " wave capabilities list",
17283
17106
  " wave capabilities tools",
17284
17107
  " wave osmd lint --json",
17285
- " wave osmd phantom run --dry-run",
17286
17108
  " wave doctor"
17287
17109
  ].join("\n")
17288
17110
  );
17289
17111
  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'],
17112
+ ["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
17113
  ["broadcast", "\nExamples:\n wave broadcast list\n wave broadcast workspace\n wave broadcast community\n wave broadcast open\n"],
17292
17114
  ["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
17115
  ["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 +17208,30 @@ function buildCli(options) {
17386
17208
 
17387
17209
  // src/machine.ts
17388
17210
  var import_node_crypto4 = require("crypto");
17211
+ var import_node_fs5 = require("fs");
17389
17212
  var MACHINE_FLAGS = /* @__PURE__ */ new Set([
17390
17213
  "--machine",
17391
17214
  "--operation",
17392
17215
  "--phase",
17393
- "--input-json"
17216
+ "--input-json",
17217
+ "--machine-auth-fd",
17218
+ "--machine-approval-fd"
17394
17219
  ]);
17220
+ var MACHINE_AUTH_FD = 3;
17221
+ var MACHINE_APPROVAL_FD = 4;
17222
+ var MAX_MACHINE_SECRET_BYTES = 64 * 1024;
17223
+ var MAX_MACHINE_INPUT_BYTES = 128 * 1024;
17395
17224
  function machineEnvelope(params) {
17396
17225
  return {
17397
17226
  ok: params.ok,
17398
17227
  command: params.command,
17399
17228
  status: params.status,
17400
17229
  data: params.data ?? null,
17401
- error: params.error ?? null,
17230
+ error: params.error ? {
17231
+ code: params.error.code,
17232
+ message: params.error.message,
17233
+ details: params.error.details ?? {}
17234
+ } : null,
17402
17235
  meta: { requestId: "machine" }
17403
17236
  };
17404
17237
  }
@@ -17420,7 +17253,7 @@ function commandId(command) {
17420
17253
  function parseMachineArgs(argv) {
17421
17254
  const values = {};
17422
17255
  for (let index = 0; index < argv.length; index += 1) {
17423
- const flag = argv[index];
17256
+ const flag = argv[index] ?? "";
17424
17257
  if (!MACHINE_FLAGS.has(flag)) {
17425
17258
  return { error: `Unsupported machine flag: ${flag}` };
17426
17259
  }
@@ -17435,19 +17268,45 @@ function parseMachineArgs(argv) {
17435
17268
  if (values["--machine"] !== "execute") {
17436
17269
  return { error: '--machine must be "execute".' };
17437
17270
  }
17271
+ const authFd = parseReservedMachineFd(values["--machine-auth-fd"], MACHINE_AUTH_FD);
17272
+ if (authFd instanceof Error) return { error: authFd.message };
17273
+ const approvalFd = parseReservedMachineFd(
17274
+ values["--machine-approval-fd"],
17275
+ MACHINE_APPROVAL_FD
17276
+ );
17277
+ if (approvalFd instanceof Error) return { error: approvalFd.message };
17438
17278
  return {
17439
- operation: values["--operation"],
17440
- phase: values["--phase"],
17441
- inputJson: values["--input-json"]
17279
+ ...values["--operation"] ? { operation: values["--operation"] } : {},
17280
+ ...values["--phase"] ? { phase: values["--phase"] } : {},
17281
+ ...values["--input-json"] ? { inputJson: values["--input-json"] } : {},
17282
+ ...authFd !== void 0 ? { authFd } : {},
17283
+ ...approvalFd !== void 0 ? { approvalFd } : {}
17442
17284
  };
17443
17285
  }
17286
+ function parseReservedMachineFd(value, expected) {
17287
+ if (value === void 0) return void 0;
17288
+ if (!/^\d+$/.test(value) || Number(value) !== expected) {
17289
+ return new Error(`The machine secret descriptor must be fd ${expected}.`);
17290
+ }
17291
+ return expected;
17292
+ }
17444
17293
  async function readMachineInput(location) {
17445
17294
  if (location !== "-") {
17446
17295
  throw new Error('Machine input must be supplied with "--input-json -".');
17447
17296
  }
17448
17297
  let raw = "";
17298
+ let bytes = 0;
17449
17299
  process.stdin.setEncoding("utf8");
17450
- for await (const chunk of process.stdin) raw += chunk;
17300
+ for await (const chunk of process.stdin) {
17301
+ const text = String(chunk);
17302
+ bytes += Buffer.byteLength(text, "utf8");
17303
+ if (bytes > MAX_MACHINE_INPUT_BYTES) {
17304
+ throw new Error(
17305
+ `Machine input exceeds the maximum size of ${MAX_MACHINE_INPUT_BYTES} bytes.`
17306
+ );
17307
+ }
17308
+ raw += text;
17309
+ }
17451
17310
  if (!raw.trim()) throw new Error("Machine input JSON is required.");
17452
17311
  const parsed = JSON.parse(raw);
17453
17312
  if (!isPlainObject(parsed)) throw new Error("Machine input must be a JSON object.");
@@ -17468,11 +17327,20 @@ function normalizeInput(input) {
17468
17327
  Object.keys(input).sort().map((key) => [key, input[key]])
17469
17328
  );
17470
17329
  }
17471
- function parseTrustedJson(name, predicate) {
17472
- const raw = process.env[name];
17473
- if (!raw) return null;
17330
+ function parseTrustedJsonFromFd(fd, predicate) {
17331
+ if (fd === void 0) return null;
17474
17332
  try {
17475
- const parsed = JSON.parse(raw);
17333
+ const chunks = [];
17334
+ const buffer = Buffer.allocUnsafe(8 * 1024);
17335
+ let bytes = 0;
17336
+ while (true) {
17337
+ const read = (0, import_node_fs5.readSync)(fd, buffer, 0, buffer.length, null);
17338
+ if (read === 0) break;
17339
+ bytes += read;
17340
+ if (bytes > MAX_MACHINE_SECRET_BYTES) return null;
17341
+ chunks.push(Buffer.from(buffer.subarray(0, read)));
17342
+ }
17343
+ const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
17476
17344
  return predicate(parsed) ? parsed : null;
17477
17345
  } catch {
17478
17346
  return null;
@@ -17547,13 +17415,9 @@ function withTrustedMachineAuth(auth, callback) {
17547
17415
  for (const key of Object.keys(process.env)) {
17548
17416
  if (key.startsWith("WAVE_")) delete process.env[key];
17549
17417
  }
17550
- if (auth) {
17551
- process.env.WAVE_API_TOKEN = auth.token;
17552
- process.env.WAVE_API_BASE_URL = auth.baseUrl;
17553
- }
17554
17418
  process.env.WAVE_CLI_AUTH_STORAGE = "disabled";
17555
17419
  process.env.WAVE_CLI_HOME = "/dev/null";
17556
- return callback().finally(() => {
17420
+ return withMachineRuntimeAuth(auth, callback).finally(() => {
17557
17421
  for (const key of Object.keys(process.env)) {
17558
17422
  if (key.startsWith("WAVE_")) delete process.env[key];
17559
17423
  }
@@ -17705,7 +17569,7 @@ async function maybeRunMachineExecute(argv, program) {
17705
17569
  })
17706
17570
  });
17707
17571
  }
17708
- const auth = parseTrustedJson("WAVE_MACHINE_AUTH_JSON", isTrustedAuth);
17572
+ const auth = parseTrustedJsonFromFd(parsed.authFd, isTrustedAuth);
17709
17573
  if (needsTrustedAuth(resolved.operation) && !auth) {
17710
17574
  return printEnvelopeAndExit({
17711
17575
  envelope: machineEnvelope({
@@ -17721,7 +17585,7 @@ async function maybeRunMachineExecute(argv, program) {
17721
17585
  });
17722
17586
  }
17723
17587
  if (resolved.operation.classification === "write") {
17724
- const approval = parseTrustedJson("WAVE_MACHINE_APPROVAL_JSON", isTrustedApproval);
17588
+ const approval = parseTrustedJsonFromFd(parsed.approvalFd, isTrustedApproval);
17725
17589
  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
17590
  return printEnvelopeAndExit({
17727
17591
  envelope: machineEnvelope({
@@ -17801,13 +17665,13 @@ main().catch((error) => {
17801
17665
  });
17802
17666
  return;
17803
17667
  }
17804
- if (error instanceof import_zod20.ZodError || error instanceof import_commander2.InvalidArgumentError) {
17668
+ if (error instanceof import_zod21.ZodError || error instanceof import_commander2.InvalidArgumentError) {
17805
17669
  printCliFailure({
17806
17670
  status: 400,
17807
17671
  code: "invalid_args",
17808
17672
  message: "Invalid command arguments.",
17809
17673
  details: {
17810
- issues: error instanceof import_zod20.ZodError ? error.issues : [{ message: error.message, code: "invalid_argument" }]
17674
+ issues: error instanceof import_zod21.ZodError ? error.issues : [{ message: error.message, code: "invalid_argument" }]
17811
17675
  },
17812
17676
  exitCode: EXIT_CODES.invalidArgs
17813
17677
  });