@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.js CHANGED
@@ -8,7 +8,7 @@ import { ZodError } from "zod";
8
8
  import { Command } from "commander";
9
9
 
10
10
  // src/commands/tasks.ts
11
- import { z as z2 } from "zod";
11
+ import { z as z3 } from "zod";
12
12
 
13
13
  // src/config.ts
14
14
  import { z } from "zod";
@@ -2143,6 +2143,17 @@ async function authGraphqlRequest(params) {
2143
2143
  }
2144
2144
  }
2145
2145
 
2146
+ // src/machineRuntimeContext.ts
2147
+ import { AsyncLocalStorage } from "async_hooks";
2148
+ var machineRuntimeAuthStorage = new AsyncLocalStorage();
2149
+ function currentMachineRuntimeAuth() {
2150
+ return machineRuntimeAuthStorage.getStore();
2151
+ }
2152
+ function withMachineRuntimeAuth(auth, callback) {
2153
+ if (!auth) return callback();
2154
+ return machineRuntimeAuthStorage.run(auth, callback);
2155
+ }
2156
+
2146
2157
  // src/commands/runtimeOptions.ts
2147
2158
  var CLI_AUTH_STATUS_QUERY = "query WaveCliAuthenticatedOrganization { cliAuthStatus { authenticated baseAuthStatus organization { id slug } } }";
2148
2159
  var stdinPromise = null;
@@ -2169,6 +2180,11 @@ function parseBool(raw) {
2169
2180
  }
2170
2181
  return void 0;
2171
2182
  }
2183
+ function omitUndefined(values) {
2184
+ return Object.fromEntries(
2185
+ Object.entries(values).filter(([, value]) => value !== void 0)
2186
+ );
2187
+ }
2172
2188
  function parseAuthJson(raw) {
2173
2189
  try {
2174
2190
  const parsed = JSON.parse(raw);
@@ -2176,7 +2192,7 @@ function parseAuthJson(raw) {
2176
2192
  throw new Error("Expected JSON object.");
2177
2193
  }
2178
2194
  const obj = parsed;
2179
- return {
2195
+ return omitUndefined({
2180
2196
  token: normalize3(obj.token),
2181
2197
  baseUrl: normalize3(obj.baseUrl ?? obj.base_url),
2182
2198
  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,
@@ -2209,7 +2225,7 @@ function parseAuthJson(raw) {
2209
2225
  openapiPath: normalize3(obj.openapiPath ?? obj.openapi_path),
2210
2226
  openapiUrl: normalize3(obj.openapiUrl ?? obj.openapi_url),
2211
2227
  openapiVersion: normalize3(obj.openapiVersion ?? obj.openapi_version)
2212
- };
2228
+ });
2213
2229
  } catch (error) {
2214
2230
  throw new CliError({
2215
2231
  message: error instanceof Error ? `Invalid --auth-json-stdin payload: ${error.message}` : "Invalid --auth-json-stdin payload.",
@@ -2257,13 +2273,14 @@ function firstDefined(...values) {
2257
2273
  return values.find((value) => value !== void 0);
2258
2274
  }
2259
2275
  function resolveAuthToken(options, stdin, config, env) {
2276
+ const candidate = (source, token) => token ? { token, source } : { source };
2260
2277
  const candidates = [
2261
- { token: normalize3(options.token), source: "flag" },
2262
- { token: normalize3(stdin.token), source: "stdin" },
2263
- { token: normalize3(env.WAVE_API_TOKEN), source: "env" },
2264
- { token: normalize3(config.token), source: "config" }
2278
+ candidate("flag", normalize3(options.token)),
2279
+ candidate("stdin", normalize3(stdin.token)),
2280
+ candidate("env", normalize3(env.WAVE_API_TOKEN)),
2281
+ candidate("config", normalize3(config.token))
2265
2282
  ];
2266
- return candidates.find((candidate) => candidate.token) ?? { source: "none" };
2283
+ return candidates.find((candidate2) => candidate2.token) ?? { source: "none" };
2267
2284
  }
2268
2285
  function resolveFromSources(options, stdin, config, env) {
2269
2286
  const baseUrl = firstDefined(
@@ -2362,10 +2379,9 @@ function resolveFromSources(options, stdin, config, env) {
2362
2379
  normalize3(config.openapiVersion)
2363
2380
  );
2364
2381
  const resolvedAuth = resolveAuthToken(options, stdin, config, env);
2365
- return {
2366
- organizationId,
2382
+ const resolved = {
2367
2383
  organizationIdSource,
2368
- runtimeOptions: {
2384
+ runtimeOptions: omitUndefined({
2369
2385
  token: resolvedAuth.token,
2370
2386
  tokenSource: resolvedAuth.token ? resolvedAuth.source : "none",
2371
2387
  baseUrl,
@@ -2385,8 +2401,10 @@ function resolveFromSources(options, stdin, config, env) {
2385
2401
  openapiPath,
2386
2402
  openapiUrl,
2387
2403
  openapiVersion
2388
- }
2404
+ })
2389
2405
  };
2406
+ if (organizationId) resolved.organizationId = organizationId;
2407
+ return resolved;
2390
2408
  }
2391
2409
  async function resolveWithStoredToken(context) {
2392
2410
  if (context.runtimeOptions.token || !context.runtimeOptions.baseUrl) {
@@ -2410,11 +2428,11 @@ async function resolveWithAuthenticatedOrganization(context) {
2410
2428
  const baseUrl = normalize3(context.runtimeOptions.baseUrl);
2411
2429
  const token = normalize3(context.runtimeOptions.token);
2412
2430
  if (!baseUrl || !token) {
2431
+ const runtimeOptions2 = { ...context.runtimeOptions };
2432
+ delete runtimeOptions2.organizationId;
2413
2433
  return {
2414
- ...context,
2415
- organizationId: void 0,
2416
2434
  organizationIdSource: "none",
2417
- runtimeOptions: { ...context.runtimeOptions, organizationId: void 0 }
2435
+ runtimeOptions: runtimeOptions2
2418
2436
  };
2419
2437
  }
2420
2438
  const response = await authGraphqlRequest({
@@ -2424,12 +2442,18 @@ async function resolveWithAuthenticatedOrganization(context) {
2424
2442
  query: CLI_AUTH_STATUS_QUERY
2425
2443
  });
2426
2444
  const organizationId = response.ok ? organizationIdFromCliAuthStatus(response.result.data) : void 0;
2427
- return {
2428
- ...context,
2429
- organizationId,
2445
+ const runtimeOptions = { ...context.runtimeOptions };
2446
+ if (organizationId) {
2447
+ runtimeOptions.organizationId = organizationId;
2448
+ } else {
2449
+ delete runtimeOptions.organizationId;
2450
+ }
2451
+ const resolved = {
2430
2452
  organizationIdSource: organizationId ? "token" : "none",
2431
- runtimeOptions: { ...context.runtimeOptions, organizationId }
2453
+ runtimeOptions
2432
2454
  };
2455
+ if (organizationId) resolved.organizationId = organizationId;
2456
+ return resolved;
2433
2457
  }
2434
2458
  function defaultConfigPath(env) {
2435
2459
  const explicitEnv = normalize3(env.WAVE_CONFIG_PATH);
@@ -2496,7 +2520,22 @@ async function resolveStdinContext(options) {
2496
2520
  async function resolveUnscopedCommandContext(options) {
2497
2521
  const stdin = await resolveStdinContext(options);
2498
2522
  const config = await resolveConfigFileContext(options, process.env);
2499
- return resolveWithStoredToken(resolveFromSources(options, stdin, config, process.env));
2523
+ return resolveWithStoredToken(applyMachineRuntimeAuth(resolveFromSources(options, stdin, config, process.env)));
2524
+ }
2525
+ function applyMachineRuntimeAuth(resolved) {
2526
+ const machineAuth = currentMachineRuntimeAuth();
2527
+ if (!machineAuth) return resolved;
2528
+ return {
2529
+ organizationId: machineAuth.organizationId,
2530
+ organizationIdSource: "flag",
2531
+ runtimeOptions: {
2532
+ ...resolved.runtimeOptions,
2533
+ token: machineAuth.token,
2534
+ tokenSource: "machine",
2535
+ baseUrl: machineAuth.baseUrl,
2536
+ organizationId: machineAuth.organizationId
2537
+ }
2538
+ };
2500
2539
  }
2501
2540
  async function resolveCommandContext(options) {
2502
2541
  return resolveWithAuthenticatedOrganization(await resolveUnscopedCommandContext(options));
@@ -2650,10 +2689,29 @@ function registerGraphqlSearchCommand(command, config) {
2650
2689
  });
2651
2690
  }
2652
2691
 
2692
+ // src/commands/taskPriority.ts
2693
+ import { z as z2 } from "zod";
2694
+ var taskPrioritySchema = z2.enum(["no_priority", "urgent", "high", "medium", "low"]);
2695
+ var taskPriorityValues = taskPrioritySchema.options.join(", ");
2696
+ var taskPriorityHelp = `Filter by priority: ${taskPriorityValues}.`;
2697
+ function parseTaskPriority(value) {
2698
+ if (value === void 0) return void 0;
2699
+ const parsed = taskPrioritySchema.safeParse(value);
2700
+ if (!parsed.success) {
2701
+ throw new CliError({
2702
+ message: `Invalid task priority. Use one of: ${taskPriorityValues}.`,
2703
+ kind: "invalid_args",
2704
+ status: 400,
2705
+ exitCode: EXIT_CODES.invalidArgs
2706
+ });
2707
+ }
2708
+ return parsed.data.toUpperCase();
2709
+ }
2710
+
2653
2711
  // src/commands/tasks.ts
2654
- var projectIdSchema = z2.string().min(1);
2655
- var idSchema = z2.string().min(1);
2656
- var summarySchema = z2.string().min(1);
2712
+ var projectIdSchema = z3.string().min(1);
2713
+ var idSchema = z3.string().min(1);
2714
+ var summarySchema = z3.string().min(1);
2657
2715
  function parseTaskUpdateJson(raw) {
2658
2716
  try {
2659
2717
  const parsed = JSON.parse(raw);
@@ -2680,7 +2738,7 @@ function parseLabelIds(raw) {
2680
2738
  }
2681
2739
  function registerTaskCommands(program) {
2682
2740
  const tasks = program.command("tasks").description("Task operations");
2683
- 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) => {
2741
+ 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) => {
2684
2742
  const context = await resolveCommandContext(cmd.optsWithGlobals());
2685
2743
  const organizationId = resolveOrganizationId(context.organizationId);
2686
2744
  const projectId = opts.projectId ? projectIdSchema.parse(opts.projectId) : void 0;
@@ -2701,9 +2759,27 @@ function registerTaskCommands(program) {
2701
2759
  field_value: opts.fieldValue,
2702
2760
  field_blank: opts.fieldBlank,
2703
2761
  open: opts.open,
2762
+ priority: parseTaskPriority(opts.priority),
2704
2763
  rank_direction: opts.rankDirection,
2705
2764
  include_archived: opts.includeArchived
2706
2765
  }),
2766
+ variableTypes: {
2767
+ organization_id: "ID!",
2768
+ page: "Int",
2769
+ per: "Int",
2770
+ project_id: "ID",
2771
+ team_id: "ID",
2772
+ team_ids: "[ID!]",
2773
+ member_id: "ID",
2774
+ meeting_id: "ID",
2775
+ field_name: "String",
2776
+ field_value: "String",
2777
+ field_blank: "Boolean",
2778
+ open: "Boolean",
2779
+ priority: "TaskPriority",
2780
+ rank_direction: "String",
2781
+ include_archived: "Boolean"
2782
+ },
2707
2783
  isList: true
2708
2784
  });
2709
2785
  });
@@ -2798,10 +2874,10 @@ function registerTaskCommands(program) {
2798
2874
  }
2799
2875
 
2800
2876
  // src/commands/projects.ts
2801
- import { z as z4 } from "zod";
2877
+ import { z as z5 } from "zod";
2802
2878
 
2803
2879
  // src/commands/entityCrud.ts
2804
- import { z as z3 } from "zod";
2880
+ import { z as z4 } from "zod";
2805
2881
 
2806
2882
  // src/commands/dtoHelpCatalog.ts
2807
2883
  var dtoHelpCatalog = {
@@ -3382,7 +3458,7 @@ function buildDataJsonHelp(rootKey, mode) {
3382
3458
  }
3383
3459
 
3384
3460
  // src/commands/entityCrud.ts
3385
- var idSchema2 = z3.string().min(1);
3461
+ var idSchema2 = z4.string().min(1);
3386
3462
  function toSingularResourceName(resourcePath) {
3387
3463
  if (resourcePath === "organization_meta_profiles") {
3388
3464
  return "organization_meta_profile";
@@ -3608,10 +3684,28 @@ var __testables = {
3608
3684
  };
3609
3685
 
3610
3686
  // src/commands/projects.ts
3611
- var idSchema3 = z4.string().min(1);
3687
+ var idSchema3 = z5.string().min(1);
3688
+ var projectStatusSchema = z5.enum([
3689
+ "backlog",
3690
+ "planned",
3691
+ "in_progress",
3692
+ "completed",
3693
+ "cancelled"
3694
+ ]);
3695
+ var projectStatusValues = projectStatusSchema.options.join(", ");
3696
+ var projectPrioritySchema = z5.enum([
3697
+ "no_priority",
3698
+ "urgent",
3699
+ "high",
3700
+ "medium",
3701
+ "low"
3702
+ ]);
3703
+ var projectPriorityValues = projectPrioritySchema.options.join(", ");
3612
3704
  var projectCreateDataJsonHelp = buildDataJsonHelp("project", "create") ?? 'JSON object for project or {"project": {...}}';
3613
3705
  var projectUpdateDataJsonHelp = buildDataJsonHelp("project", "update") ?? 'JSON object for project or {"project": {...}}';
3614
- var projectsIndexMinimalSelectionSet = "{ count currentPage totalPages data { id type attributes { name slug status priority } } }";
3706
+ function projectsIndexMinimalSelectionSet(includeProjectTypes = false) {
3707
+ return `{ count currentPage totalPages data { id type attributes { name slug status priority${includeProjectTypes ? " projectType" : ""} } } }`;
3708
+ }
3615
3709
  var displayPreferenceAttributesSelectionSet = "attributes { id viewType favorite groupingField groupToggleState memberId focusMemberId focusTeamId displayableId displayableType preferenceType agendaItemId }";
3616
3710
  var filterPreferenceAttributesSelectionSet = "attributes { id filterType filter memberId focusMemberId focusTeamId filterableId filterableType preferenceType agendaItemId }";
3617
3711
  var healthUpdateSummarySelectionSet = "id type value memberId status createdAt updatedAt updatableType updatableId parentUpdateId emojis { id name memberId } resources { ...ResourceSummaryFull }";
@@ -3622,6 +3716,32 @@ function asRecord3(value) {
3622
3716
  function toNonEmptyString(value) {
3623
3717
  return typeof value === "string" && value.trim() !== "" ? value : void 0;
3624
3718
  }
3719
+ function parseProjectStatus(value) {
3720
+ if (value === void 0) return void 0;
3721
+ const parsed = projectStatusSchema.safeParse(value);
3722
+ if (!parsed.success) {
3723
+ throw new CliError({
3724
+ message: `Invalid project status. Use one of: ${projectStatusValues}.`,
3725
+ kind: "invalid_args",
3726
+ status: 400,
3727
+ exitCode: EXIT_CODES.invalidArgs
3728
+ });
3729
+ }
3730
+ return parsed.data.toUpperCase();
3731
+ }
3732
+ function parseProjectPriority(value) {
3733
+ if (value === void 0) return void 0;
3734
+ const parsed = projectPrioritySchema.safeParse(value);
3735
+ if (!parsed.success) {
3736
+ throw new CliError({
3737
+ message: `Invalid project priority. Use one of: ${projectPriorityValues}.`,
3738
+ kind: "invalid_args",
3739
+ status: 400,
3740
+ exitCode: EXIT_CODES.invalidArgs
3741
+ });
3742
+ }
3743
+ return parsed.data.toUpperCase();
3744
+ }
3625
3745
  function normalizeProjectRowForDisplay(row) {
3626
3746
  const record = asRecord3(row);
3627
3747
  if (!record) return row;
@@ -3649,7 +3769,13 @@ function normalizeProjectsListForDisplay(payload) {
3649
3769
  }
3650
3770
  function registerProjectCommands(program) {
3651
3771
  const projects = program.command("projects").description("Project operations");
3652
- projects.command("list").option("--page <page>").option("--per <per>").option("--team-ids <teamIds>").option("--member-id <memberId>").action(async (opts, cmd) => {
3772
+ projects.command("list").option("--page <page>").option("--per <per>").option("--team-ids <teamIds>").option("--member-id <memberId>").option(
3773
+ "--status <status>",
3774
+ "Filter by status: backlog, planned, in_progress, completed, cancelled."
3775
+ ).option(
3776
+ "--priority <priority>",
3777
+ "Filter by priority: no_priority, urgent, high, medium, low."
3778
+ ).option("--include-project-types", "Include projectType in the list response (opt-in).").action(async (opts, cmd) => {
3653
3779
  const context = await resolveCommandContext(cmd.optsWithGlobals());
3654
3780
  const organizationId = resolveOrganizationId(context.organizationId);
3655
3781
  await runGraphqlQueryCommand({
@@ -3662,17 +3788,21 @@ function registerProjectCommands(program) {
3662
3788
  page: opts.page,
3663
3789
  per: opts.per,
3664
3790
  team_ids: opts.teamIds,
3665
- member_id: opts.memberId
3791
+ member_id: opts.memberId,
3792
+ status: parseProjectStatus(opts.status),
3793
+ priority: parseProjectPriority(opts.priority)
3666
3794
  }),
3667
3795
  variableTypes: {
3668
3796
  organization_id: "ID!",
3669
3797
  page: "Int",
3670
3798
  per: "Int",
3671
3799
  team_ids: "[ID!]",
3672
- member_id: "ID"
3800
+ member_id: "ID",
3801
+ status: "ProjectStatus",
3802
+ priority: "ProjectPriority"
3673
3803
  },
3674
3804
  isList: true,
3675
- selectionSet: projectsIndexMinimalSelectionSet,
3805
+ selectionSet: projectsIndexMinimalSelectionSet(opts.includeProjectTypes === true),
3676
3806
  transformData: normalizeProjectsListForDisplay
3677
3807
  });
3678
3808
  });
@@ -3680,7 +3810,7 @@ function registerProjectCommands(program) {
3680
3810
  command: "projects",
3681
3811
  operationName: "ProjectsSearch",
3682
3812
  field: "projects",
3683
- selectionSet: projectsIndexMinimalSelectionSet,
3813
+ selectionSet: projectsIndexMinimalSelectionSet(),
3684
3814
  transformData: normalizeProjectsListForDisplay
3685
3815
  });
3686
3816
  projects.command("show").requiredOption("--id <id>").action(async (opts, cmd) => {
@@ -3739,10 +3869,10 @@ function registerProjectCommands(program) {
3739
3869
  }
3740
3870
 
3741
3871
  // src/commands/rocks.ts
3742
- import { z as z5 } from "zod";
3743
- var idSchema4 = z5.string().min(1);
3744
- var rockCollectionIdSchema = z5.string().min(1);
3745
- var statusSchema = z5.enum(["on_track", "at_risk", "off_track"]);
3872
+ import { z as z6 } from "zod";
3873
+ var idSchema4 = z6.string().min(1);
3874
+ var rockCollectionIdSchema = z6.string().min(1);
3875
+ var statusSchema = z6.enum(["on_track", "at_risk", "off_track"]);
3746
3876
  var createHelp = buildDataJsonHelp("rock", "create") ?? 'JSON object for rock or {"rock": {...}}';
3747
3877
  var updateHelp = buildDataJsonHelp("rock", "update") ?? 'JSON object for rock or {"rock": {...}}';
3748
3878
  function registerRockCommands(program) {
@@ -3840,9 +3970,9 @@ function registerRockCommands(program) {
3840
3970
  }
3841
3971
 
3842
3972
  // src/commands/meetings.ts
3843
- import { z as z6 } from "zod";
3844
- var idSchema5 = z6.string().min(1);
3845
- var notesSchema = z6.string().min(1);
3973
+ import { z as z7 } from "zod";
3974
+ var idSchema5 = z7.string().min(1);
3975
+ var notesSchema = z7.string().min(1);
3846
3976
  var MEETING_TYPES = /* @__PURE__ */ new Set(["TeamMeeting", "OneOnOneMeeting"]);
3847
3977
  var MEETING_STATUSES = /* @__PURE__ */ new Set(["upcoming", "active", "completed"]);
3848
3978
  var MEETING_REPEATS = /* @__PURE__ */ new Set(["never", "weekly", "biweekly", "monthly", "quarterly"]);
@@ -4075,8 +4205,8 @@ function registerMeetingCommands(program) {
4075
4205
  }
4076
4206
 
4077
4207
  // src/commands/members.ts
4078
- import { z as z7 } from "zod";
4079
- var idSchema6 = z7.string().min(1);
4208
+ import { z as z8 } from "zod";
4209
+ var idSchema6 = z8.string().min(1);
4080
4210
  var createHelp3 = buildDataJsonHelp("member", "create") ?? 'JSON object for member or {"member": {...}}';
4081
4211
  var updateHelp3 = buildDataJsonHelp("member", "update") ?? 'JSON object for member or {"member": {...}}';
4082
4212
  var MEMBER_META_PROFILE_SELECTION = "{ id type memberId summary profile attributes { id memberId summary profile } }";
@@ -4205,9 +4335,9 @@ function registerMemberCommands(program) {
4205
4335
  }
4206
4336
 
4207
4337
  // src/commands/skills.ts
4208
- import { z as z8 } from "zod";
4209
- var idSchema7 = z8.string().min(1);
4210
- var limitSchema = z8.coerce.number().int().positive();
4338
+ import { z as z9 } from "zod";
4339
+ var idSchema7 = z9.string().min(1);
4340
+ var limitSchema = z9.coerce.number().int().positive();
4211
4341
  var SKILL_SELECTION = `{
4212
4342
  id
4213
4343
  type
@@ -4283,17 +4413,24 @@ function registerSkillCommands(program) {
4283
4413
  }
4284
4414
 
4285
4415
  // src/commands/issues.ts
4286
- import { z as z9 } from "zod";
4287
- var issueGroupIdSchema = z9.string().min(1);
4288
- var idSchema8 = z9.string().min(1);
4289
- var nameSchema = z9.string().min(1);
4290
- var issueTypeSchema = z9.string().min(1).refine((value) => value === "short_term" || value === "long_term", {
4416
+ import { z as z10 } from "zod";
4417
+ var issueGroupIdSchema = z10.string().min(1);
4418
+ var idSchema8 = z10.string().min(1);
4419
+ var nameSchema = z10.string().min(1);
4420
+ var issueTypeSchema = z10.string().min(1).refine((value) => value === "short_term" || value === "long_term", {
4291
4421
  message: "Invalid issue type. Use one of: short_term, long_term."
4292
4422
  });
4423
+ var issueStatusSchema = z10.string().min(1).refine((value) => value === "open" || value === "completed", {
4424
+ message: "Invalid issue status. Use one of: open, completed."
4425
+ });
4293
4426
  var updateHelp4 = buildDataJsonHelp("issue", "update") ?? 'JSON object for issue or {"issue": {...}}';
4427
+ function parseIssueIndexEnum(value, schema) {
4428
+ if (value === void 0) return void 0;
4429
+ return schema.parse(String(value)).toUpperCase();
4430
+ }
4294
4431
  function registerIssueCommands(program) {
4295
4432
  const issues = program.command("issues").description("Issue operations");
4296
- 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) => {
4433
+ 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) => {
4297
4434
  const context = await resolveCommandContext(cmd.optsWithGlobals());
4298
4435
  const organizationId = resolveOrganizationId(context.organizationId);
4299
4436
  await runGraphqlQueryCommand({
@@ -4306,11 +4443,24 @@ function registerIssueCommands(program) {
4306
4443
  per: opts.per,
4307
4444
  issue_group_id: opts.issueGroupId,
4308
4445
  start_date: opts.startDate,
4309
- issue_type: opts.issueType,
4446
+ issue_type: parseIssueIndexEnum(opts.issueType, issueTypeSchema),
4447
+ status: parseIssueIndexEnum(opts.status, issueStatusSchema),
4310
4448
  team_id: opts.teamId,
4311
4449
  member_id: opts.memberId,
4312
4450
  meeting_id: opts.meetingId
4313
4451
  }),
4452
+ variableTypes: {
4453
+ organization_id: "ID!",
4454
+ page: "Int",
4455
+ per: "Int",
4456
+ issue_group_id: "ID",
4457
+ start_date: "String",
4458
+ issue_type: "IssueType",
4459
+ status: "IssueStatus",
4460
+ team_id: "ID",
4461
+ member_id: "ID",
4462
+ meeting_id: "ID"
4463
+ },
4314
4464
  isList: true
4315
4465
  });
4316
4466
  });
@@ -5334,8 +5484,8 @@ function registerSystemToolCommands(program) {
5334
5484
  }
5335
5485
 
5336
5486
  // src/commands/teams.ts
5337
- import { z as z10 } from "zod";
5338
- var idSchema9 = z10.string().min(1);
5487
+ import { z as z11 } from "zod";
5488
+ var idSchema9 = z11.string().min(1);
5339
5489
  function registerTeamCommands(program) {
5340
5490
  const teams = program.command("teams").description("Team operations");
5341
5491
  teams.command("list").option("--page <page>").option("--per <per>").action(async (opts, cmd) => {
@@ -5401,8 +5551,8 @@ function registerTeamCommands(program) {
5401
5551
  }
5402
5552
 
5403
5553
  // src/commands/organizations.ts
5404
- import { z as z11 } from "zod";
5405
- var idSchema10 = z11.string().min(1);
5554
+ import { z as z12 } from "zod";
5555
+ var idSchema10 = z12.string().min(1);
5406
5556
  function isRecord3(value) {
5407
5557
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
5408
5558
  }
@@ -5614,8 +5764,8 @@ function registerOrganizationCommands(program) {
5614
5764
  }
5615
5765
 
5616
5766
  // src/commands/foundation.ts
5617
- import { z as z12 } from "zod";
5618
- var idSchema11 = z12.string().min(1);
5767
+ import { z as z13 } from "zod";
5768
+ var idSchema11 = z13.string().min(1);
5619
5769
  var STRATEGIC_PLAN_ALLOWED_UPDATE_KEYS = /* @__PURE__ */ new Set([
5620
5770
  "published_at",
5621
5771
  "profile",
@@ -5816,9 +5966,9 @@ function registerFoundationCommands(program) {
5816
5966
  }
5817
5967
 
5818
5968
  // src/commands/childEntities.ts
5819
- import { z as z13 } from "zod";
5820
- var idSchema12 = z13.string().min(1);
5821
- var jsonObjectSchema = z13.record(z13.string(), z13.unknown());
5969
+ import { z as z14 } from "zod";
5970
+ var idSchema12 = z14.string().min(1);
5971
+ var jsonObjectSchema = z14.record(z14.string(), z14.unknown());
5822
5972
  var NOTE_DETAIL_FIELDS = [
5823
5973
  "notes",
5824
5974
  "hasNotes",
@@ -5966,10 +6116,17 @@ function normalizeSubtaskCreateBody(body) {
5966
6116
  }
5967
6117
  function registerChildCommands(program, config) {
5968
6118
  const command = program.command(config.command).description(config.description);
5969
- command.command("list").requiredOption(`--${config.parentFlag} <${config.parentFlag}>`).option("--page <page>").option("--per <per>").action(async (opts, cmd) => {
6119
+ const listCommand = command.command("list").requiredOption(`--${config.parentFlag} <${config.parentFlag}>`).option("--page <page>").option("--per <per>");
6120
+ if (config.priorityFilter) {
6121
+ listCommand.option("--priority <priority>", config.priorityFilter.help);
6122
+ }
6123
+ listCommand.action(async (opts, cmd) => {
5970
6124
  const context = await resolveCommandContext(cmd.optsWithGlobals());
5971
6125
  const organizationId = resolveOrganizationId(context.organizationId);
5972
6126
  const parentId = idSchema12.parse(opts[config.parentFlag.replace(/-([a-z])/g, (_, c) => c.toUpperCase())]);
6127
+ const priority = config.priorityFilter?.parse(opts.priority);
6128
+ const priorityVariables = priority === void 0 ? {} : { priority };
6129
+ const priorityVariableTypes = priority === void 0 || !config.priorityFilter ? {} : { priority: config.priorityFilter.variableType };
5973
6130
  await runGraphqlQueryCommand({
5974
6131
  command: `${config.command}.list`,
5975
6132
  operationName: config.listOperationName,
@@ -5979,13 +6136,15 @@ function registerChildCommands(program, config) {
5979
6136
  organization_id: organizationId,
5980
6137
  [config.parentFlag.replace(/-/g, "_")]: parentId,
5981
6138
  page: opts.page,
5982
- per: opts.per
6139
+ per: opts.per,
6140
+ ...priorityVariables
5983
6141
  }),
5984
6142
  variableTypes: {
5985
6143
  organization_id: "ID!",
5986
6144
  [config.parentFlag.replace(/-/g, "_")]: "ID!",
5987
6145
  page: "Int",
5988
- per: "Int"
6146
+ per: "Int",
6147
+ ...priorityVariableTypes
5989
6148
  },
5990
6149
  isList: true,
5991
6150
  selectionSet: config.listSelectionSet,
@@ -6105,6 +6264,11 @@ function registerChildEntityCommands(program) {
6105
6264
  destroyOperationName: "SubtasksDestroy",
6106
6265
  listSelectionSet: buildChildListSelectionSet("taskId"),
6107
6266
  listParentTypedField: "taskId",
6267
+ priorityFilter: {
6268
+ variableType: "TaskPriority",
6269
+ help: taskPriorityHelp,
6270
+ parse: parseTaskPriority
6271
+ },
6108
6272
  searchRequiredOptions: requiredParentSearchOption("task-id", "task"),
6109
6273
  showField: "subtask",
6110
6274
  showOperationName: "SubtasksShow",
@@ -6220,9 +6384,9 @@ function registerChildEntityCommands(program) {
6220
6384
  }
6221
6385
 
6222
6386
  // src/commands/content.ts
6223
- import { z as z14 } from "zod";
6224
- var idSchema13 = z14.string().min(1);
6225
- var nonEmptyString = z14.string().min(1);
6387
+ import { z as z15 } from "zod";
6388
+ var idSchema13 = z15.string().min(1);
6389
+ var nonEmptyString = z15.string().min(1);
6226
6390
  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 }";
6227
6391
  function assertUpdateFields(params) {
6228
6392
  if (!params.name && !params.content && !params.status) {
@@ -6410,9 +6574,9 @@ function registerContentCommands(program) {
6410
6574
  }
6411
6575
 
6412
6576
  // src/commands/markdownTree.ts
6413
- import { z as z15 } from "zod";
6414
- var nonEmptyString2 = z15.string().min(1);
6415
- var nonNegativeInt = z15.coerce.number().int().min(0);
6577
+ import { z as z16 } from "zod";
6578
+ var nonEmptyString2 = z16.string().min(1);
6579
+ var nonNegativeInt = z16.coerce.number().int().min(0);
6416
6580
  function addScopeOptions(command) {
6417
6581
  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");
6418
6582
  }
@@ -6577,7 +6741,7 @@ function registerMarkdownTreeCommands(program) {
6577
6741
  }
6578
6742
 
6579
6743
  // src/commands/navigation.ts
6580
- import { z as z16 } from "zod";
6744
+ import { z as z17 } from "zod";
6581
6745
 
6582
6746
  // src/internalOptions.ts
6583
6747
  var INTERNAL_OPTIONS_KEY = "__waveInternalOptions";
@@ -6607,8 +6771,8 @@ function getInternalCliOptions(command) {
6607
6771
  }
6608
6772
 
6609
6773
  // src/commands/navigation.ts
6610
- var nonEmpty = z16.string().min(1);
6611
- var nonNegativeInt2 = z16.coerce.number().int().min(0);
6774
+ var nonEmpty = z17.string().min(1);
6775
+ var nonNegativeInt2 = z17.coerce.number().int().min(0);
6612
6776
  var MIGRATED_BRANCHES = ["directory", "projects", "knowledge"];
6613
6777
  function normalizeText(input) {
6614
6778
  if (typeof input !== "string") return "";
@@ -7391,11 +7555,11 @@ function registerMutationCapabilityCommands(program) {
7391
7555
  // src/commands/osmd.ts
7392
7556
  import { readFile as readFile3 } from "fs/promises";
7393
7557
  import { basename } from "path";
7394
- import { z as z17 } from "zod";
7395
- var sourceSchema = z17.enum(["canonical_osmd", "agent_overlay", "agent_wiki"]);
7396
- var accessSchema = z17.enum(["read_only", "read_write", "append_only"]).catch("read_write");
7397
- var ownerSchema = z17.enum(["system", "atlas"]);
7398
- var suggestedActionSchema = z17.enum([
7558
+ import { z as z18 } from "zod";
7559
+ var sourceSchema = z18.enum(["canonical_osmd", "agent_overlay", "agent_wiki"]);
7560
+ var accessSchema = z18.enum(["read_only", "read_write", "append_only"]).catch("read_write");
7561
+ var ownerSchema = z18.enum(["system", "atlas"]);
7562
+ var suggestedActionSchema = z18.enum([
7399
7563
  "read",
7400
7564
  "create",
7401
7565
  "init",
@@ -7404,7 +7568,7 @@ var suggestedActionSchema = z17.enum([
7404
7568
  "forbidden",
7405
7569
  "invalid_parent"
7406
7570
  ]).catch("update");
7407
- var agentMarkdownErrorCodeSchema = z17.enum([
7571
+ var agentMarkdownErrorCodeSchema = z18.enum([
7408
7572
  "canonical_osmd_read_only",
7409
7573
  "agent_parent_not_found",
7410
7574
  "agent_file_not_found",
@@ -7415,9 +7579,9 @@ var agentMarkdownErrorCodeSchema = z17.enum([
7415
7579
  "invalid_agent_wiki_path"
7416
7580
  ]);
7417
7581
  var agentMarkdownErrorCodeFieldSchema = agentMarkdownErrorCodeSchema.nullable().catch(null);
7418
- var nonEmptyString3 = z17.string().min(1);
7419
- var nonNegativeInt3 = z17.coerce.number().int().min(0);
7420
- var positiveInt = z17.coerce.number().int().min(1);
7582
+ var nonEmptyString3 = z18.string().min(1);
7583
+ var nonNegativeInt3 = z18.coerce.number().int().min(0);
7584
+ var positiveInt = z18.coerce.number().int().min(1);
7421
7585
  var supportedAgentOverlaySystemFiles = ["notes.md", "summary.md"];
7422
7586
  var supportedWikiIndexFile = "index.md";
7423
7587
  var supportedWikiLogFile = "log.md";
@@ -7433,20 +7597,20 @@ var supportedWikiControlledPatterns = supportedWikiControlledFolders.map(
7433
7597
  );
7434
7598
  var controlledWikiSlugPattern = /^[a-z0-9][a-z0-9-]*$/;
7435
7599
  var agentMarkdownSlugPattern = /^[a-z0-9][a-z0-9-]*$/;
7436
- var osmdSearchScopeSchema = z17.enum([
7600
+ var osmdSearchScopeSchema = z18.enum([
7437
7601
  "os-only",
7438
7602
  "agent-overlay-only",
7439
7603
  "agent-wiki-only",
7440
7604
  "combined"
7441
7605
  ]);
7442
- var osmdLintScopeSchema = z17.enum([
7606
+ var osmdLintScopeSchema = z18.enum([
7443
7607
  "combined",
7444
7608
  "agent-overlay-only",
7445
7609
  "agent-wiki-only"
7446
7610
  ]);
7447
- var osmdMemoryQualityScopeSchema = z17.enum(["agent-overlay-only"]);
7448
- var osmdIngestKindSchema = z17.enum(["text", "file", "url", "transcript"]);
7449
- var osmdRawSourceTypeSchema = z17.enum([
7611
+ var osmdMemoryQualityScopeSchema = z18.enum(["agent-overlay-only"]);
7612
+ var osmdIngestKindSchema = z18.enum(["text", "file", "url", "transcript"]);
7613
+ var osmdRawSourceTypeSchema = z18.enum([
7450
7614
  "pasted_text",
7451
7615
  "uploaded_markdown",
7452
7616
  "uploaded_text",
@@ -7455,31 +7619,30 @@ var osmdRawSourceTypeSchema = z17.enum([
7455
7619
  "meeting_transcript",
7456
7620
  "url"
7457
7621
  ]);
7458
- var defaultOsmdPhantomTimeoutMs = 12e4;
7459
- var agentMarkdownFileSchema = z17.preprocess(
7622
+ var agentMarkdownFileSchema = z18.preprocess(
7460
7623
  normalizeAgentMarkdownJsonKeys,
7461
- z17.object({
7462
- path: z17.string(),
7624
+ z18.object({
7625
+ path: z18.string(),
7463
7626
  source: sourceSchema,
7464
7627
  access: accessSchema,
7465
7628
  owner: ownerSchema,
7466
- exists: z17.boolean(),
7467
- canCreate: z17.boolean(),
7468
- canUpdate: z17.boolean(),
7469
- canAppend: z17.boolean(),
7470
- wikiRole: z17.string().nullable().optional(),
7471
- formatVersion: z17.string().nullable().optional(),
7472
- createdAt: z17.string().nullable().optional(),
7473
- updatedAt: z17.string().nullable().optional(),
7474
- ingestedAt: z17.string().nullable().optional(),
7475
- lastSeenAt: z17.string().nullable().optional(),
7476
- canonicalParentUpdatedAt: z17.string().nullable().optional(),
7477
- parentRef: z17.string().nullable().optional(),
7478
- agentChildrenAllowed: z17.boolean(),
7629
+ exists: z18.boolean(),
7630
+ canCreate: z18.boolean(),
7631
+ canUpdate: z18.boolean(),
7632
+ canAppend: z18.boolean(),
7633
+ wikiRole: z18.string().nullable().optional(),
7634
+ formatVersion: z18.string().nullable().optional(),
7635
+ createdAt: z18.string().nullable().optional(),
7636
+ updatedAt: z18.string().nullable().optional(),
7637
+ ingestedAt: z18.string().nullable().optional(),
7638
+ lastSeenAt: z18.string().nullable().optional(),
7639
+ canonicalParentUpdatedAt: z18.string().nullable().optional(),
7640
+ parentRef: z18.string().nullable().optional(),
7641
+ agentChildrenAllowed: z18.boolean(),
7479
7642
  suggestedAction: suggestedActionSchema,
7480
7643
  errorCode: agentMarkdownErrorCodeFieldSchema.optional(),
7481
- content: z17.string().nullable().optional(),
7482
- url: z17.string().nullable().optional()
7644
+ content: z18.string().nullable().optional(),
7645
+ url: z18.string().nullable().optional()
7483
7646
  }).transform((value) => ({
7484
7647
  ...value,
7485
7648
  wikiRole: value.wikiRole ?? null,
@@ -7495,31 +7658,31 @@ var agentMarkdownFileSchema = z17.preprocess(
7495
7658
  url: value.url ?? null
7496
7659
  }))
7497
7660
  );
7498
- var agentMarkdownFilesSchema = z17.array(agentMarkdownFileSchema);
7499
- var agentMarkdownMutationDataSchema = z17.union([
7661
+ var agentMarkdownFilesSchema = z18.array(agentMarkdownFileSchema);
7662
+ var agentMarkdownMutationDataSchema = z18.union([
7500
7663
  agentMarkdownFileSchema,
7501
- z17.object({ files: agentMarkdownFilesSchema })
7664
+ z18.object({ files: agentMarkdownFilesSchema })
7502
7665
  ]);
7503
- var osmdSearchCandidateSchema = z17.preprocess(
7666
+ var osmdSearchCandidateSchema = z18.preprocess(
7504
7667
  normalizeAgentMarkdownJsonKeys,
7505
- z17.object({
7506
- path: z17.string(),
7668
+ z18.object({
7669
+ path: z18.string(),
7507
7670
  source: sourceSchema,
7508
7671
  access: accessSchema,
7509
7672
  owner: ownerSchema,
7510
- wikiRole: z17.string().nullable().optional(),
7511
- formatVersion: z17.string().nullable().optional(),
7512
- parentRef: z17.string().nullable().optional(),
7513
- exists: z17.boolean(),
7514
- agentChildrenAllowed: z17.boolean(),
7515
- title: z17.string(),
7516
- label: z17.string(),
7517
- snippet: z17.string().nullable().optional(),
7518
- rank: z17.number().int(),
7519
- matchReason: z17.string().nullable().optional(),
7520
- toolKey: z17.string().nullable().optional(),
7521
- nodeKey: z17.string().nullable().optional(),
7522
- nodeKind: z17.string().nullable().optional()
7673
+ wikiRole: z18.string().nullable().optional(),
7674
+ formatVersion: z18.string().nullable().optional(),
7675
+ parentRef: z18.string().nullable().optional(),
7676
+ exists: z18.boolean(),
7677
+ agentChildrenAllowed: z18.boolean(),
7678
+ title: z18.string(),
7679
+ label: z18.string(),
7680
+ snippet: z18.string().nullable().optional(),
7681
+ rank: z18.number().int(),
7682
+ matchReason: z18.string().nullable().optional(),
7683
+ toolKey: z18.string().nullable().optional(),
7684
+ nodeKey: z18.string().nullable().optional(),
7685
+ nodeKind: z18.string().nullable().optional()
7523
7686
  }).transform((value) => ({
7524
7687
  ...value,
7525
7688
  wikiRole: value.wikiRole ?? null,
@@ -7532,26 +7695,26 @@ var osmdSearchCandidateSchema = z17.preprocess(
7532
7695
  nodeKind: value.nodeKind ?? null
7533
7696
  }))
7534
7697
  );
7535
- var osmdSearchResultSchema = z17.preprocess(
7698
+ var osmdSearchResultSchema = z18.preprocess(
7536
7699
  normalizeAgentMarkdownJsonKeys,
7537
- z17.object({
7538
- query: z17.string(),
7539
- scope: z17.string(),
7540
- count: z17.number().int().min(0),
7541
- candidates: z17.array(osmdSearchCandidateSchema)
7700
+ z18.object({
7701
+ query: z18.string(),
7702
+ scope: z18.string(),
7703
+ count: z18.number().int().min(0),
7704
+ candidates: z18.array(osmdSearchCandidateSchema)
7542
7705
  })
7543
7706
  );
7544
- var osmdWikiLintIssueSchema = z17.preprocess(
7707
+ var osmdWikiLintIssueSchema = z18.preprocess(
7545
7708
  normalizeAgentMarkdownJsonKeys,
7546
- z17.object({
7547
- code: z17.string(),
7548
- severity: z17.string(),
7549
- path: z17.string(),
7550
- source: z17.string().nullable().optional(),
7551
- parentRef: z17.string().nullable().optional(),
7552
- message: z17.string(),
7553
- suggestedAction: z17.string().nullable().optional(),
7554
- canAutoFix: z17.boolean()
7709
+ z18.object({
7710
+ code: z18.string(),
7711
+ severity: z18.string(),
7712
+ path: z18.string(),
7713
+ source: z18.string().nullable().optional(),
7714
+ parentRef: z18.string().nullable().optional(),
7715
+ message: z18.string(),
7716
+ suggestedAction: z18.string().nullable().optional(),
7717
+ canAutoFix: z18.boolean()
7555
7718
  }).transform((value) => ({
7556
7719
  ...value,
7557
7720
  source: value.source ?? null,
@@ -7559,37 +7722,37 @@ var osmdWikiLintIssueSchema = z17.preprocess(
7559
7722
  suggestedAction: value.suggestedAction ?? null
7560
7723
  }))
7561
7724
  );
7562
- var osmdWikiLintResultSchema = z17.preprocess(
7725
+ var osmdWikiLintResultSchema = z18.preprocess(
7563
7726
  normalizeAgentMarkdownJsonKeys,
7564
- z17.object({
7565
- status: z17.string(),
7566
- summary: z17.object({
7567
- totalIssues: z17.number().int().min(0),
7568
- errors: z17.number().int().min(0),
7569
- warnings: z17.number().int().min(0),
7570
- suggestions: z17.number().int().min(0)
7727
+ z18.object({
7728
+ status: z18.string(),
7729
+ summary: z18.object({
7730
+ totalIssues: z18.number().int().min(0),
7731
+ errors: z18.number().int().min(0),
7732
+ warnings: z18.number().int().min(0),
7733
+ suggestions: z18.number().int().min(0)
7571
7734
  }),
7572
- issues: z17.array(osmdWikiLintIssueSchema)
7735
+ issues: z18.array(osmdWikiLintIssueSchema)
7573
7736
  })
7574
7737
  );
7575
- var nullableCountSchema = z17.preprocess(
7738
+ var nullableCountSchema = z18.preprocess(
7576
7739
  (value) => value === void 0 || value === null || value === "" ? null : value,
7577
- z17.coerce.number().int().min(0).nullable()
7740
+ z18.coerce.number().int().min(0).nullable()
7578
7741
  ).catch(null);
7579
- var osmdMemoryQualityIssueSchema = z17.preprocess(
7742
+ var osmdMemoryQualityIssueSchema = z18.preprocess(
7580
7743
  normalizeAgentMarkdownJsonKeys,
7581
- z17.object({
7582
- code: z17.string().nullable().optional(),
7583
- issueCode: z17.string().nullable().optional(),
7584
- path: z17.string().nullable().optional(),
7585
- parentRef: z17.string().nullable().optional(),
7586
- dimension: z17.string().nullable().optional(),
7587
- evidence: z17.string().nullable().optional(),
7588
- evidenceSnippet: z17.string().nullable().optional(),
7589
- message: z17.string().nullable().optional(),
7590
- severity: z17.string().nullable().optional(),
7591
- suggestedAction: z17.string().nullable().optional(),
7592
- canAutoFix: z17.boolean().nullable().optional()
7744
+ z18.object({
7745
+ code: z18.string().nullable().optional(),
7746
+ issueCode: z18.string().nullable().optional(),
7747
+ path: z18.string().nullable().optional(),
7748
+ parentRef: z18.string().nullable().optional(),
7749
+ dimension: z18.string().nullable().optional(),
7750
+ evidence: z18.string().nullable().optional(),
7751
+ evidenceSnippet: z18.string().nullable().optional(),
7752
+ message: z18.string().nullable().optional(),
7753
+ severity: z18.string().nullable().optional(),
7754
+ suggestedAction: z18.string().nullable().optional(),
7755
+ canAutoFix: z18.boolean().nullable().optional()
7593
7756
  }).passthrough().transform((value) => ({
7594
7757
  ...value,
7595
7758
  code: value.code ?? value.issueCode ?? "unknown_issue",
@@ -7604,16 +7767,16 @@ var osmdMemoryQualityIssueSchema = z17.preprocess(
7604
7767
  canAutoFix: value.canAutoFix === true ? true : false
7605
7768
  }))
7606
7769
  );
7607
- var osmdMemoryQualityOverlaySchema = z17.preprocess(
7770
+ var osmdMemoryQualityOverlaySchema = z18.preprocess(
7608
7771
  normalizeAgentMarkdownJsonKeys,
7609
- z17.object({
7610
- path: z17.string().nullable().optional(),
7611
- parentRef: z17.string().nullable().optional(),
7612
- status: z17.string().nullable().optional(),
7613
- score: z17.union([z17.number(), z17.string()]).nullable().optional(),
7614
- overallScore: z17.union([z17.number(), z17.string()]).nullable().optional(),
7615
- dimensions: z17.unknown().nullable().optional(),
7616
- issues: z17.array(osmdMemoryQualityIssueSchema).optional()
7772
+ z18.object({
7773
+ path: z18.string().nullable().optional(),
7774
+ parentRef: z18.string().nullable().optional(),
7775
+ status: z18.string().nullable().optional(),
7776
+ score: z18.union([z18.number(), z18.string()]).nullable().optional(),
7777
+ overallScore: z18.union([z18.number(), z18.string()]).nullable().optional(),
7778
+ dimensions: z18.unknown().nullable().optional(),
7779
+ issues: z18.array(osmdMemoryQualityIssueSchema).optional()
7617
7780
  }).passthrough().transform((value) => ({
7618
7781
  ...value,
7619
7782
  path: value.path ?? null,
@@ -7625,9 +7788,9 @@ var osmdMemoryQualityOverlaySchema = z17.preprocess(
7625
7788
  issues: value.issues ?? []
7626
7789
  }))
7627
7790
  );
7628
- var osmdMemoryQualitySummarySchema = z17.preprocess(
7791
+ var osmdMemoryQualitySummarySchema = z18.preprocess(
7629
7792
  normalizeAgentMarkdownJsonKeys,
7630
- z17.object({
7793
+ z18.object({
7631
7794
  evaluatedCount: nullableCountSchema.optional(),
7632
7795
  passCount: nullableCountSchema.optional(),
7633
7796
  warnCount: nullableCountSchema.optional(),
@@ -7645,19 +7808,19 @@ var osmdMemoryQualitySummarySchema = z17.preprocess(
7645
7808
  failCount: value.failCount ?? value.failures ?? null
7646
7809
  }))
7647
7810
  );
7648
- var osmdMemoryQualityResultSchema = z17.preprocess(
7811
+ var osmdMemoryQualityResultSchema = z18.preprocess(
7649
7812
  normalizeAgentMarkdownJsonKeys,
7650
- z17.object({
7651
- status: z17.string(),
7652
- scope: z17.string().nullable().optional(),
7813
+ z18.object({
7814
+ status: z18.string(),
7815
+ scope: z18.string().nullable().optional(),
7653
7816
  evaluatedCount: nullableCountSchema.optional(),
7654
7817
  passCount: nullableCountSchema.optional(),
7655
7818
  warnCount: nullableCountSchema.optional(),
7656
7819
  failCount: nullableCountSchema.optional(),
7657
7820
  summary: osmdMemoryQualitySummarySchema.optional(),
7658
- weakestOverlays: z17.array(osmdMemoryQualityOverlaySchema).optional(),
7659
- issues: z17.array(osmdMemoryQualityIssueSchema).optional(),
7660
- scores: z17.array(osmdMemoryQualityOverlaySchema).optional()
7821
+ weakestOverlays: z18.array(osmdMemoryQualityOverlaySchema).optional(),
7822
+ issues: z18.array(osmdMemoryQualityIssueSchema).optional(),
7823
+ scores: z18.array(osmdMemoryQualityOverlaySchema).optional()
7661
7824
  }).passthrough().transform((value) => {
7662
7825
  const summary = isRecord5(value.summary) ? value.summary : null;
7663
7826
  return {
@@ -7681,24 +7844,24 @@ function normalizeOsmdIngestFileRecordInput(value) {
7681
7844
  }
7682
7845
  return normalized;
7683
7846
  }
7684
- var osmdIngestFileRecordSchema = z17.preprocess(
7847
+ var osmdIngestFileRecordSchema = z18.preprocess(
7685
7848
  normalizeOsmdIngestFileRecordInput,
7686
- z17.object({
7687
- path: z17.string(),
7688
- source: z17.string().nullable().optional(),
7689
- access: z17.string().nullable().optional(),
7690
- owner: z17.string().nullable().optional(),
7691
- parentRef: z17.string().nullable().optional(),
7692
- exists: z17.boolean().nullable().optional(),
7693
- canCreate: z17.boolean().nullable().optional(),
7694
- canUpdate: z17.boolean().nullable().optional(),
7695
- canAppend: z17.boolean().nullable().optional(),
7696
- wikiRole: z17.string().nullable().optional(),
7697
- formatVersion: z17.string().nullable().optional(),
7698
- createdAt: z17.string().nullable().optional(),
7699
- updatedAt: z17.string().nullable().optional(),
7700
- suggestedAction: z17.string().nullable().optional(),
7701
- errorCode: z17.string().nullable().optional()
7849
+ z18.object({
7850
+ path: z18.string(),
7851
+ source: z18.string().nullable().optional(),
7852
+ access: z18.string().nullable().optional(),
7853
+ owner: z18.string().nullable().optional(),
7854
+ parentRef: z18.string().nullable().optional(),
7855
+ exists: z18.boolean().nullable().optional(),
7856
+ canCreate: z18.boolean().nullable().optional(),
7857
+ canUpdate: z18.boolean().nullable().optional(),
7858
+ canAppend: z18.boolean().nullable().optional(),
7859
+ wikiRole: z18.string().nullable().optional(),
7860
+ formatVersion: z18.string().nullable().optional(),
7861
+ createdAt: z18.string().nullable().optional(),
7862
+ updatedAt: z18.string().nullable().optional(),
7863
+ suggestedAction: z18.string().nullable().optional(),
7864
+ errorCode: z18.string().nullable().optional()
7702
7865
  }).passthrough().transform((value) => ({
7703
7866
  ...value,
7704
7867
  source: value.source ?? null,
@@ -7717,17 +7880,17 @@ var osmdIngestFileRecordSchema = z17.preprocess(
7717
7880
  errorCode: value.errorCode ?? null
7718
7881
  }))
7719
7882
  );
7720
- var osmdIngestResultSchema = z17.preprocess(
7883
+ var osmdIngestResultSchema = z18.preprocess(
7721
7884
  normalizeAgentMarkdownJsonKeys,
7722
- z17.object({
7723
- rawSourceId: z17.union([z17.string(), z17.number()]).nullable().optional(),
7724
- sourceSummaryPath: z17.string().nullable().optional(),
7885
+ z18.object({
7886
+ rawSourceId: z18.union([z18.string(), z18.number()]).nullable().optional(),
7887
+ sourceSummaryPath: z18.string().nullable().optional(),
7725
7888
  sourceSummaryFile: osmdIngestFileRecordSchema.nullable().optional(),
7726
- slug: z17.string().nullable().optional(),
7727
- runLint: z17.boolean().nullable().optional(),
7728
- createdFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7729
- updatedFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7730
- skippedUpdates: z17.array(z17.unknown()).optional(),
7889
+ slug: z18.string().nullable().optional(),
7890
+ runLint: z18.boolean().nullable().optional(),
7891
+ createdFiles: z18.array(osmdIngestFileRecordSchema).optional(),
7892
+ updatedFiles: z18.array(osmdIngestFileRecordSchema).optional(),
7893
+ skippedUpdates: z18.array(z18.unknown()).optional(),
7731
7894
  lintResult: osmdWikiLintResultSchema.nullable().optional()
7732
7895
  }).passthrough().transform((value) => ({
7733
7896
  ...value,
@@ -7742,127 +7905,37 @@ var osmdIngestResultSchema = z17.preprocess(
7742
7905
  lintResult: value.lintResult ?? null
7743
7906
  }))
7744
7907
  );
7745
- var osmdPhantomNotificationSchema = z17.preprocess(
7746
- normalizeAgentMarkdownJsonKeys,
7747
- z17.object({
7748
- id: z17.union([z17.string(), z17.number()]).nullable().optional(),
7749
- status: z17.string().nullable().optional()
7750
- }).passthrough().transform((value) => ({
7751
- ...value,
7752
- id: value.id === void 0 || value.id === null ? null : String(value.id),
7753
- status: value.status ?? null
7754
- }))
7755
- );
7756
- var osmdPhantomResultSchema = z17.preprocess(
7757
- normalizeOsmdPhantomResultKeys,
7758
- z17.object({
7759
- runId: z17.union([z17.string(), z17.number()]).nullable().optional(),
7760
- organizationId: z17.union([z17.string(), z17.number()]).nullable().optional(),
7761
- triggerType: z17.string().nullable().optional(),
7762
- scope: z17.string().nullable().optional(),
7763
- subtree: z17.string().nullable().optional(),
7764
- status: z17.string().nullable().optional(),
7765
- createdAt: z17.string().nullable().optional(),
7766
- updatedAt: z17.string().nullable().optional(),
7767
- startedAt: z17.string().nullable().optional(),
7768
- completedAt: z17.string().nullable().optional(),
7769
- countSemantics: z17.unknown().nullable().optional(),
7770
- scannedFileCount: nullableCountSchema,
7771
- changedFileCount: nullableCountSchema,
7772
- unchangedFileCount: nullableCountSchema,
7773
- updatedFileCount: nullableCountSchema,
7774
- skippedFileCount: nullableCountSchema,
7775
- lintStatus: z17.string().nullable().optional(),
7776
- errorCount: nullableCountSchema,
7777
- warningCount: nullableCountSchema,
7778
- reportPath: z17.string().nullable().optional(),
7779
- plannedReads: z17.array(osmdIngestFileRecordSchema).optional(),
7780
- plannedReadFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7781
- plannedWrites: z17.array(osmdIngestFileRecordSchema).optional(),
7782
- plannedWriteFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7783
- changedFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7784
- unchangedFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7785
- updatedFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7786
- skippedFiles: z17.array(osmdIngestFileRecordSchema).optional(),
7787
- lintPlan: z17.unknown().nullable().optional(),
7788
- lintSummary: z17.unknown().nullable().optional(),
7789
- lintResult: osmdWikiLintResultSchema.nullable().optional(),
7790
- notification: osmdPhantomNotificationSchema.nullable().optional(),
7791
- notificationId: z17.union([z17.string(), z17.number()]).nullable().optional(),
7792
- notificationStatus: z17.string().nullable().optional()
7793
- }).passthrough().transform((value) => {
7794
- const lintResultSummary = isRecord5(value.lintResult?.summary) ? value.lintResult.summary : null;
7795
- const lintSummary = isRecord5(value.lintSummary) ? value.lintSummary : null;
7796
- const notification = value.notification ?? (value.notificationId !== void 0 || value.notificationStatus !== void 0 ? {
7797
- id: value.notificationId === void 0 || value.notificationId === null ? null : String(value.notificationId),
7798
- status: value.notificationStatus ?? null
7799
- } : null);
7800
- return {
7801
- ...value,
7802
- runId: value.runId === void 0 || value.runId === null ? null : String(value.runId),
7803
- organizationId: value.organizationId === void 0 || value.organizationId === null ? null : String(value.organizationId),
7804
- triggerType: value.triggerType ?? null,
7805
- scope: value.scope ?? null,
7806
- subtree: value.subtree ?? null,
7807
- status: value.status ?? null,
7808
- createdAt: value.createdAt ?? null,
7809
- updatedAt: value.updatedAt ?? null,
7810
- startedAt: value.startedAt ?? null,
7811
- completedAt: value.completedAt ?? null,
7812
- countSemantics: value.countSemantics ?? null,
7813
- scannedFileCount: value.scannedFileCount,
7814
- changedFileCount: value.changedFileCount,
7815
- unchangedFileCount: value.unchangedFileCount,
7816
- updatedFileCount: value.updatedFileCount,
7817
- skippedFileCount: value.skippedFileCount,
7818
- lintStatus: value.lintStatus ?? (typeof value.lintResult?.status === "string" ? value.lintResult.status : null) ?? (typeof lintSummary?.status === "string" ? lintSummary.status : null),
7819
- errorCount: value.errorCount ?? countFromRecord(lintResultSummary, "errors") ?? countFromRecord(lintSummary, "errors"),
7820
- warningCount: value.warningCount ?? countFromRecord(lintResultSummary, "warnings") ?? countFromRecord(lintSummary, "warnings"),
7821
- reportPath: value.reportPath ?? null,
7822
- plannedReads: value.plannedReads ?? value.plannedReadFiles ?? [],
7823
- plannedWrites: value.plannedWrites ?? value.plannedWriteFiles ?? [],
7824
- changedFiles: value.changedFiles ?? [],
7825
- unchangedFiles: dedupeOsmdFileRecords(value.unchangedFiles ?? []),
7826
- updatedFiles: value.updatedFiles ?? [],
7827
- skippedFiles: dedupeOsmdFileRecords(value.skippedFiles ?? []),
7828
- lintPlan: value.lintPlan ?? null,
7829
- lintSummary: value.lintSummary ?? null,
7830
- lintResult: value.lintResult ?? null,
7831
- notification
7832
- };
7833
- })
7834
- );
7835
- var mutationPayloadSchema = z17.object({
7836
- ok: z17.boolean(),
7837
- status: z17.number(),
7838
- errorCode: z17.string().nullable().optional(),
7839
- data: z17.unknown().nullable().optional(),
7840
- errors: z17.unknown().nullable().optional()
7908
+ var mutationPayloadSchema = z18.object({
7909
+ ok: z18.boolean(),
7910
+ status: z18.number(),
7911
+ errorCode: z18.string().nullable().optional(),
7912
+ data: z18.unknown().nullable().optional(),
7913
+ errors: z18.unknown().nullable().optional()
7841
7914
  });
7842
- var markdownTreeNodeSchema = z17.lazy(
7843
- () => z17.object({
7844
- toolKey: z17.string(),
7845
- nodeKey: z17.string(),
7846
- nodeKind: z17.string(),
7847
- runtimeLabel: z17.string(),
7848
- path: z17.string().nullable().optional().transform((value) => value ?? null),
7915
+ var markdownTreeNodeSchema = z18.lazy(
7916
+ () => z18.object({
7917
+ toolKey: z18.string(),
7918
+ nodeKey: z18.string(),
7919
+ nodeKind: z18.string(),
7920
+ runtimeLabel: z18.string(),
7921
+ path: z18.string().nullable().optional().transform((value) => value ?? null),
7849
7922
  source: sourceSchema,
7850
7923
  access: accessSchema,
7851
7924
  owner: ownerSchema,
7852
- parentRef: z17.string().nullable().optional().transform((value) => value ?? null),
7853
- agentChildrenAllowed: z17.boolean(),
7854
- exists: z17.boolean(),
7855
- resolvedScope: z17.object({
7856
- parentId: z17.string().nullable().optional().transform((value) => value ?? null),
7857
- recordId: z17.string().nullable().optional().transform((value) => value ?? null),
7858
- memberId: z17.string().nullable().optional().transform((value) => value ?? null),
7859
- teamId: z17.string().nullable().optional().transform((value) => value ?? null),
7860
- contentType: z17.string().nullable().optional().transform((value) => value ?? null)
7925
+ parentRef: z18.string().nullable().optional().transform((value) => value ?? null),
7926
+ agentChildrenAllowed: z18.boolean(),
7927
+ exists: z18.boolean(),
7928
+ resolvedScope: z18.object({
7929
+ parentId: z18.string().nullable().optional().transform((value) => value ?? null),
7930
+ recordId: z18.string().nullable().optional().transform((value) => value ?? null),
7931
+ memberId: z18.string().nullable().optional().transform((value) => value ?? null),
7932
+ teamId: z18.string().nullable().optional().transform((value) => value ?? null),
7933
+ contentType: z18.string().nullable().optional().transform((value) => value ?? null)
7861
7934
  }),
7862
- isLeaf: z17.boolean(),
7863
- treeView: z17.boolean(),
7864
- details: z17.unknown().nullable(),
7865
- children: z17.array(markdownTreeNodeSchema).optional().transform((value) => value ?? [])
7935
+ isLeaf: z18.boolean(),
7936
+ treeView: z18.boolean(),
7937
+ details: z18.unknown().nullable(),
7938
+ children: z18.array(markdownTreeNodeSchema).optional().transform((value) => value ?? [])
7866
7939
  })
7867
7940
  );
7868
7941
  var AGENT_MARKDOWN_FILE_SELECTION = `{
@@ -8123,86 +8196,6 @@ function normalizeAgentMarkdownJsonKeys(value) {
8123
8196
  }
8124
8197
  return normalized;
8125
8198
  }
8126
- function firstPresent(...values) {
8127
- for (const value of values) {
8128
- if (value !== void 0 && value !== null) {
8129
- return value;
8130
- }
8131
- }
8132
- return void 0;
8133
- }
8134
- function normalizeOsmdPhantomResultKeys(value) {
8135
- const normalized = normalizeAgentMarkdownJsonKeys(value);
8136
- if (!isRecord5(normalized)) {
8137
- return normalized;
8138
- }
8139
- const run = isRecord5(normalized.run) ? normalizeAgentMarkdownJsonKeys(normalized.run) : null;
8140
- const result = run ? { ...run, ...normalized } : { ...normalized };
8141
- const runField = (key) => run ? run[key] : void 0;
8142
- const assignFirstPresent = (target, ...values) => {
8143
- const value2 = firstPresent(result[target], ...values);
8144
- if (value2 !== void 0) {
8145
- result[target] = value2;
8146
- }
8147
- };
8148
- assignFirstPresent("runId", normalized.id, runField("runId"), runField("id"));
8149
- assignFirstPresent("organizationId", runField("organizationId"));
8150
- assignFirstPresent("triggerType", runField("triggerType"));
8151
- assignFirstPresent("scope", runField("scope"));
8152
- assignFirstPresent("status", runField("status"));
8153
- assignFirstPresent("createdAt", runField("createdAt"));
8154
- assignFirstPresent("updatedAt", runField("updatedAt"));
8155
- assignFirstPresent("startedAt", runField("startedAt"));
8156
- assignFirstPresent("completedAt", runField("completedAt"));
8157
- assignFirstPresent("countSemantics", runField("countSemantics"));
8158
- assignFirstPresent(
8159
- "scannedFileCount",
8160
- normalized.scanned,
8161
- runField("scannedFileCount"),
8162
- runField("scanned")
8163
- );
8164
- assignFirstPresent(
8165
- "changedFileCount",
8166
- normalized.changed,
8167
- runField("changedFileCount"),
8168
- runField("changed")
8169
- );
8170
- assignFirstPresent(
8171
- "unchangedFileCount",
8172
- normalized.unchanged,
8173
- runField("unchangedFileCount"),
8174
- runField("unchanged")
8175
- );
8176
- assignFirstPresent(
8177
- "updatedFileCount",
8178
- normalized.updated,
8179
- runField("updatedFileCount"),
8180
- runField("updated")
8181
- );
8182
- assignFirstPresent(
8183
- "skippedFileCount",
8184
- normalized.skipped,
8185
- runField("skippedFileCount"),
8186
- runField("skipped")
8187
- );
8188
- assignFirstPresent("lintStatus", runField("lintStatus"));
8189
- assignFirstPresent("errorCount", runField("errorCount"));
8190
- assignFirstPresent("warningCount", runField("warningCount"));
8191
- assignFirstPresent("reportPath", runField("reportPath"));
8192
- assignFirstPresent("plannedReads", runField("plannedReads"), runField("plannedReadFiles"));
8193
- assignFirstPresent("plannedWrites", runField("plannedWrites"), runField("plannedWriteFiles"));
8194
- assignFirstPresent("changedFiles", runField("changedFiles"));
8195
- assignFirstPresent("unchangedFiles", runField("unchangedFiles"));
8196
- assignFirstPresent("updatedFiles", runField("updatedFiles"));
8197
- assignFirstPresent("skippedFiles", runField("skippedFiles"));
8198
- assignFirstPresent("lintPlan", runField("lintPlan"));
8199
- assignFirstPresent("lintSummary", runField("lintSummary"));
8200
- assignFirstPresent("lintResult", runField("lintResult"));
8201
- assignFirstPresent("notification", runField("notification"));
8202
- assignFirstPresent("notificationId", runField("notificationId"));
8203
- assignFirstPresent("notificationStatus", runField("notificationStatus"));
8204
- return result;
8205
- }
8206
8199
  function buildSuccessEnvelope(params) {
8207
8200
  return {
8208
8201
  ok: true,
@@ -8622,51 +8615,6 @@ async function runOsmdIngestFlow(params) {
8622
8615
  })
8623
8616
  });
8624
8617
  }
8625
- async function runOsmdPhantomPhaseOne(params) {
8626
- const runtimeOptions = {
8627
- ...params.runtimeOptions,
8628
- timeoutMs: params.runtimeOptions.timeoutMs ?? defaultOsmdPhantomTimeoutMs
8629
- };
8630
- const result = await requestOsmdMutationPayload({
8631
- command: params.command,
8632
- operationName: "RunPhantomOsmdMaintenance",
8633
- operationType: "mutation",
8634
- runtimeOptions,
8635
- field: "run_phantom_osmd_maintenance",
8636
- variables: {
8637
- organization_id: params.organizationId,
8638
- dry_run: params.dryRun
8639
- }
8640
- });
8641
- const parsedData = osmdPhantomResultSchema.safeParse(
8642
- normalizeAgentMarkdownJsonKeys(result.payload.data)
8643
- );
8644
- if (!parsedData.success) {
8645
- return printInvalidPayloadError({
8646
- command: params.command,
8647
- requestId: result.requestId,
8648
- issues: parsedData.error.issues
8649
- });
8650
- }
8651
- const data = {
8652
- ...parsedData.data,
8653
- organizationId: parsedData.data.organizationId ?? params.organizationId,
8654
- triggerType: parsedData.data.triggerType ?? "manual"
8655
- };
8656
- if (params.readable) {
8657
- return printTextAndExit({
8658
- text: formatOsmdPhantomHuman(data, params.dryRun)
8659
- });
8660
- }
8661
- return printEnvelopeAndExit({
8662
- envelope: buildSuccessEnvelope({
8663
- command: params.command,
8664
- status: result.payload.status,
8665
- data,
8666
- requestId: result.requestId
8667
- })
8668
- });
8669
- }
8670
8618
  function normalizeAgentFilePath(file) {
8671
8619
  const trimmed = nonEmptyString3.parse(file).trim().replace(/^\/+|\/+$/g, "");
8672
8620
  const fileName = trimmed.startsWith(".agent/") ? trimmed.slice(".agent/".length) : trimmed;
@@ -9077,62 +9025,6 @@ function formatIngestFileList(files) {
9077
9025
  return `- ${path}${action}`;
9078
9026
  });
9079
9027
  }
9080
- function fileRecordPath(file) {
9081
- return typeof file.path === "string" && file.path.trim() !== "" ? file.path : null;
9082
- }
9083
- function isAgentNotesWrite(file) {
9084
- const path = fileRecordPath(file);
9085
- return path !== null && /(?:^|\/)\.agent\/notes\.md$/.test(path);
9086
- }
9087
- function formatNotesWriteSummary(files) {
9088
- const notesWrites = files.filter(isAgentNotesWrite);
9089
- if (notesWrites.length === 0) {
9090
- return ["notes.md writes: none"];
9091
- }
9092
- return ["notes.md writes:", ...formatIngestFileList(notesWrites)];
9093
- }
9094
- function skippedReasonForFile(file) {
9095
- for (const key of ["reason", "skipReason", "errorCode", "suggestedAction", "status"]) {
9096
- const value = file[key];
9097
- if (typeof value === "string" && value.trim() !== "") {
9098
- return value;
9099
- }
9100
- }
9101
- return "unspecified";
9102
- }
9103
- function formatSkippedFilesByReason(files) {
9104
- if (files.length === 0) {
9105
- return ["- none"];
9106
- }
9107
- const groups = /* @__PURE__ */ new Map();
9108
- for (const file of files) {
9109
- const reason = skippedReasonForFile(file);
9110
- const existing = groups.get(reason) ?? [];
9111
- existing.push(file);
9112
- groups.set(reason, existing);
9113
- }
9114
- const lines = [];
9115
- for (const [reason, records] of groups.entries()) {
9116
- lines.push(`- ${reason}`);
9117
- for (const record of records) {
9118
- lines.push(` - ${fileRecordPath(record) ?? "-"}`);
9119
- }
9120
- }
9121
- return lines;
9122
- }
9123
- function dedupeOsmdFileRecords(files) {
9124
- const seen = /* @__PURE__ */ new Set();
9125
- const deduped = [];
9126
- for (const file of files) {
9127
- const key = file.path;
9128
- if (typeof key !== "string" || key.trim() === "" || seen.has(key)) {
9129
- continue;
9130
- }
9131
- seen.add(key);
9132
- deduped.push(file);
9133
- }
9134
- return deduped;
9135
- }
9136
9028
  function formatSkippedUpdateList(skippedUpdates) {
9137
9029
  if (skippedUpdates.length === 0) {
9138
9030
  return ["- none"];
@@ -9171,72 +9063,6 @@ function formatOsmdIngestHuman(data) {
9171
9063
  function formatNullableNumberHumanField(value) {
9172
9064
  return typeof value === "number" ? String(value) : "-";
9173
9065
  }
9174
- function formatNotificationHuman(notification) {
9175
- if (!notification) {
9176
- return "-";
9177
- }
9178
- const id = formatNullableHumanField(notification.id);
9179
- const status = formatNullableHumanField(notification.status);
9180
- return `id=${id} status=${status}`;
9181
- }
9182
- function formatPhantomTimestampLines(data) {
9183
- const lines = [];
9184
- if (data.startedAt) {
9185
- lines.push(`Started at: ${data.startedAt}`);
9186
- }
9187
- if (data.completedAt) {
9188
- lines.push(`Completed at: ${data.completedAt}`);
9189
- }
9190
- if (data.createdAt) {
9191
- lines.push(`Created at: ${data.createdAt}`);
9192
- }
9193
- if (data.updatedAt) {
9194
- lines.push(`Updated at: ${data.updatedAt}`);
9195
- }
9196
- return lines;
9197
- }
9198
- function formatOsmdPhantomHuman(data, dryRun) {
9199
- const lines = [
9200
- dryRun ? "Phantom Phase 1 plan" : "Phantom Phase 1 run",
9201
- `Run ID: ${formatNullableHumanField(data.runId)}`,
9202
- `Status: ${formatNullableHumanField(data.status)}`,
9203
- ...formatPhantomTimestampLines(data),
9204
- `Organization ID: ${formatNullableHumanField(data.organizationId)}`,
9205
- `Trigger type: ${formatNullableHumanField(data.triggerType)}`,
9206
- `Scope: ${formatNullableHumanField(data.scope ?? data.subtree)}`,
9207
- ...data.countSemantics === null || data.countSemantics === void 0 ? [] : [`Count semantics: ${formatUnknownHuman(data.countSemantics)}`],
9208
- `Reviewed OSMD/agent markdown entries: ${formatNullableNumberHumanField(data.scannedFileCount)}`,
9209
- `Changed entries: ${formatNullableNumberHumanField(data.changedFileCount)}`,
9210
- `Unchanged entries: ${formatNullableNumberHumanField(data.unchangedFileCount)}`,
9211
- `Updated files: ${formatNullableNumberHumanField(data.updatedFileCount)}`,
9212
- `Skipped entries: ${formatNullableNumberHumanField(data.skippedFileCount)}`,
9213
- `Lint status: ${formatNullableHumanField(data.lintStatus)}`,
9214
- `Errors: ${formatNullableNumberHumanField(data.errorCount)}`,
9215
- `Warnings: ${formatNullableNumberHumanField(data.warningCount)}`,
9216
- `Report path: ${formatNullableHumanField(data.reportPath)}`,
9217
- `Notification: ${formatNotificationHuman(data.notification)}`,
9218
- "",
9219
- "Planned reads:",
9220
- ...formatIngestFileList(data.plannedReads),
9221
- "",
9222
- "Planned semantic memory writes:",
9223
- ...formatIngestFileList(data.plannedWrites),
9224
- ...dryRun ? formatNotesWriteSummary(data.plannedWrites) : [],
9225
- "",
9226
- "Changed entries:",
9227
- ...formatIngestFileList(data.changedFiles),
9228
- "",
9229
- "Updated files:",
9230
- ...formatIngestFileList(data.updatedFiles),
9231
- "",
9232
- "Skipped nodes by reason:",
9233
- ...formatSkippedFilesByReason(data.skippedFiles),
9234
- "",
9235
- "Lint plan:",
9236
- formatUnknownHuman(data.lintPlan)
9237
- ];
9238
- return lines.join("\n");
9239
- }
9240
9066
  function parseSearchLimit(value) {
9241
9067
  const raw = value === void 0 || value === null || value === "" ? "10" : value;
9242
9068
  const parsed = positiveInt.safeParse(raw);
@@ -10004,18 +9830,6 @@ function registerOsmdCommands(program) {
10004
9830
  throw error;
10005
9831
  }
10006
9832
  });
10007
- const phantom = osmd.command("phantom").description("Backend-owned Phantom Phase 1 manual operations");
10008
- 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) => {
10009
- const command = "osmd.phantom.run";
10010
- const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
10011
- return runOsmdPhantomPhaseOne({
10012
- command,
10013
- runtimeOptions,
10014
- organizationId,
10015
- dryRun: opts.dryRun === true,
10016
- readable: opts.readable === true
10017
- });
10018
- });
10019
9833
  const agent = osmd.command("agent").description(".agent markdown attached to canonical OSMD parents");
10020
9834
  agent.command("status <parent-ref> <file>").description("Show .agent file metadata without creating files").action(async (parentRef, file, _opts, cmd) => {
10021
9835
  const { organizationId, runtimeOptions } = await resolveOsmdContext(cmd);
@@ -13011,14 +12825,14 @@ function registerMailCommands(program) {
13011
12825
  }
13012
12826
 
13013
12827
  // src/commands/phantom.ts
13014
- import { z as z18 } from "zod";
13015
- var nonNegativeInt4 = z18.coerce.number().int().min(0);
13016
- var nullableString = z18.string().nullable().optional().transform((value) => value ?? null);
13017
- var idString = z18.union([z18.string(), z18.number()]).transform((value) => String(value));
13018
- var nullableIdString = z18.union([z18.string(), z18.number()]).nullable().optional().transform(
12828
+ import { z as z19 } from "zod";
12829
+ var nonNegativeInt4 = z19.coerce.number().int().min(0);
12830
+ var nullableString = z19.string().nullable().optional().transform((value) => value ?? null);
12831
+ var idString = z19.union([z19.string(), z19.number()]).transform((value) => String(value));
12832
+ var nullableIdString = z19.union([z19.string(), z19.number()]).nullable().optional().transform(
13019
12833
  (value) => value === void 0 || value === null ? null : String(value)
13020
12834
  );
13021
- var jsonObject = z18.record(z18.string(), z18.unknown());
12835
+ var jsonObject = z19.record(z19.string(), z19.unknown());
13022
12836
  var PHANTOM_LEDGER_INVENTORY_SELECTION = `{
13023
12837
  schemaVersion
13024
12838
  runsCount
@@ -13231,10 +13045,10 @@ var PHANTOM_LEDGER_KEY_ALIASES = {
13231
13045
  content_hash: "contentHash",
13232
13046
  observed_at: "observedAt"
13233
13047
  };
13234
- var phantomLedgerInventorySchema = z18.preprocess(
13048
+ var phantomLedgerInventorySchema = z19.preprocess(
13235
13049
  normalizePhantomLedgerKeys,
13236
- z18.object({
13237
- schemaVersion: z18.string(),
13050
+ z19.object({
13051
+ schemaVersion: z19.string(),
13238
13052
  runsCount: nonNegativeInt4,
13239
13053
  observationsCount: nonNegativeInt4,
13240
13054
  candidatesCount: nonNegativeInt4,
@@ -13244,16 +13058,16 @@ var phantomLedgerInventorySchema = z18.preprocess(
13244
13058
  reportsCount: nonNegativeInt4
13245
13059
  })
13246
13060
  );
13247
- var phantomRunSchema = z18.preprocess(
13061
+ var phantomRunSchema = z19.preprocess(
13248
13062
  normalizePhantomLedgerKeys,
13249
- z18.object({
13063
+ z19.object({
13250
13064
  id: idString,
13251
13065
  organizationId: idString,
13252
- notificationId: z18.union([z18.string(), z18.number()]).nullable().optional().transform(
13066
+ notificationId: z19.union([z19.string(), z19.number()]).nullable().optional().transform(
13253
13067
  (value) => value === void 0 || value === null ? null : String(value)
13254
13068
  ),
13255
- status: z18.string(),
13256
- triggerType: z18.string(),
13069
+ status: z19.string(),
13070
+ triggerType: z19.string(),
13257
13071
  startedAt: nullableString,
13258
13072
  completedAt: nullableString,
13259
13073
  scannedFileCount: nonNegativeInt4,
@@ -13263,163 +13077,163 @@ var phantomRunSchema = z18.preprocess(
13263
13077
  errorCount: nonNegativeInt4,
13264
13078
  warningCount: nonNegativeInt4,
13265
13079
  errorMessage: nullableString,
13266
- dryRun: z18.boolean(),
13267
- schemaVersion: z18.string(),
13080
+ dryRun: z19.boolean(),
13081
+ schemaVersion: z19.string(),
13268
13082
  testRunId: nullableString,
13269
13083
  idempotencyKey: nullableString,
13270
13084
  ledgerMetadata: jsonObject.catch({}),
13271
- createdAt: z18.string(),
13272
- updatedAt: z18.string()
13085
+ createdAt: z19.string(),
13086
+ updatedAt: z19.string()
13273
13087
  })
13274
13088
  );
13275
- var phantomRunListItemSchema = z18.preprocess(
13089
+ var phantomRunListItemSchema = z19.preprocess(
13276
13090
  normalizePhantomLedgerKeys,
13277
- z18.object({
13091
+ z19.object({
13278
13092
  id: idString,
13279
13093
  organizationId: idString,
13280
- status: z18.string(),
13281
- triggerType: z18.string(),
13282
- dryRun: z18.boolean(),
13283
- schemaVersion: z18.string(),
13094
+ status: z19.string(),
13095
+ triggerType: z19.string(),
13096
+ dryRun: z19.boolean(),
13097
+ schemaVersion: z19.string(),
13284
13098
  testRunId: nullableString,
13285
- createdAt: z18.string(),
13286
- updatedAt: z18.string()
13099
+ createdAt: z19.string(),
13100
+ updatedAt: z19.string()
13287
13101
  })
13288
13102
  );
13289
- var phantomReportSchema = z18.preprocess(
13103
+ var phantomReportSchema = z19.preprocess(
13290
13104
  normalizePhantomLedgerKeys,
13291
- z18.object({
13105
+ z19.object({
13292
13106
  id: idString,
13293
13107
  organizationId: idString,
13294
13108
  phantomRunId: idString,
13295
- status: z18.string(),
13296
- reportType: z18.string(),
13297
- schemaVersion: z18.string(),
13109
+ status: z19.string(),
13110
+ reportType: z19.string(),
13111
+ schemaVersion: z19.string(),
13298
13112
  markdownPath: nullableString,
13299
13113
  payload: jsonObject.catch({}),
13300
13114
  testRunId: nullableString,
13301
- idempotencyKey: z18.string(),
13302
- createdAt: z18.string(),
13303
- updatedAt: z18.string()
13115
+ idempotencyKey: z19.string(),
13116
+ createdAt: z19.string(),
13117
+ updatedAt: z19.string()
13304
13118
  })
13305
13119
  );
13306
- var phantomObservationSchema = z18.preprocess(
13120
+ var phantomObservationSchema = z19.preprocess(
13307
13121
  normalizePhantomLedgerKeys,
13308
- z18.object({
13122
+ z19.object({
13309
13123
  id: idString,
13310
13124
  organizationId: idString,
13311
13125
  phantomRunId: idString,
13312
- status: z18.string(),
13313
- observationType: z18.string(),
13126
+ status: z19.string(),
13127
+ observationType: z19.string(),
13314
13128
  targetType: nullableString,
13315
13129
  targetId: nullableString,
13316
13130
  sourceTable: nullableString,
13317
13131
  sourceRecordId: nullableString,
13318
13132
  sourceEventId: nullableString,
13319
13133
  contentHash: nullableString,
13320
- observedAt: z18.string(),
13321
- confidence: z18.coerce.number(),
13134
+ observedAt: z19.string(),
13135
+ confidence: z19.coerce.number(),
13322
13136
  payload: jsonObject.catch({}),
13323
- schemaVersion: z18.string(),
13137
+ schemaVersion: z19.string(),
13324
13138
  testRunId: nullableString,
13325
- idempotencyKey: z18.string(),
13326
- createdAt: z18.string(),
13327
- updatedAt: z18.string()
13139
+ idempotencyKey: z19.string(),
13140
+ createdAt: z19.string(),
13141
+ updatedAt: z19.string()
13328
13142
  })
13329
13143
  );
13330
- var phantomCandidateSchema = z18.preprocess(
13144
+ var phantomCandidateSchema = z19.preprocess(
13331
13145
  normalizePhantomLedgerKeys,
13332
- z18.object({
13146
+ z19.object({
13333
13147
  id: idString,
13334
13148
  organizationId: idString,
13335
13149
  phantomRunId: idString,
13336
13150
  phantomObservationId: nullableString,
13337
- status: z18.string(),
13338
- candidateType: z18.string(),
13151
+ status: z19.string(),
13152
+ candidateType: z19.string(),
13339
13153
  targetType: nullableString,
13340
13154
  targetId: nullableString,
13341
13155
  title: nullableString,
13342
- dryRun: z18.boolean(),
13156
+ dryRun: z19.boolean(),
13343
13157
  payload: jsonObject.catch({}),
13344
- approvalStatus: z18.string(),
13158
+ approvalStatus: z19.string(),
13345
13159
  approvedById: nullableIdString,
13346
13160
  approvedAt: nullableString,
13347
13161
  approvalSource: nullableString,
13348
13162
  approvalReason: nullableString,
13349
13163
  approvalMetadata: jsonObject.catch({}),
13350
- schemaVersion: z18.string(),
13164
+ schemaVersion: z19.string(),
13351
13165
  testRunId: nullableString,
13352
- idempotencyKey: z18.string(),
13353
- createdAt: z18.string(),
13354
- updatedAt: z18.string()
13166
+ idempotencyKey: z19.string(),
13167
+ createdAt: z19.string(),
13168
+ updatedAt: z19.string()
13355
13169
  })
13356
13170
  );
13357
- var phantomCandidateEvidenceSchema = z18.preprocess(
13171
+ var phantomCandidateEvidenceSchema = z19.preprocess(
13358
13172
  normalizePhantomLedgerKeys,
13359
- z18.object({
13173
+ z19.object({
13360
13174
  id: idString,
13361
13175
  organizationId: idString,
13362
13176
  phantomCandidateId: idString,
13363
13177
  phantomObservationId: nullableString,
13364
- evidenceType: z18.string(),
13178
+ evidenceType: z19.string(),
13365
13179
  sourceType: nullableString,
13366
13180
  sourceId: nullableString,
13367
13181
  contentHash: nullableString,
13368
13182
  payload: jsonObject.catch({}),
13369
- schemaVersion: z18.string(),
13183
+ schemaVersion: z19.string(),
13370
13184
  testRunId: nullableString,
13371
- idempotencyKey: z18.string(),
13372
- createdAt: z18.string(),
13373
- updatedAt: z18.string()
13185
+ idempotencyKey: z19.string(),
13186
+ createdAt: z19.string(),
13187
+ updatedAt: z19.string()
13374
13188
  })
13375
13189
  );
13376
- var phantomValidationSchema = z18.preprocess(
13190
+ var phantomValidationSchema = z19.preprocess(
13377
13191
  normalizePhantomLedgerKeys,
13378
- z18.object({
13192
+ z19.object({
13379
13193
  id: idString,
13380
13194
  organizationId: idString,
13381
13195
  phantomRunId: idString,
13382
13196
  phantomCandidateId: idString,
13383
- status: z18.string(),
13384
- validationType: z18.string(),
13385
- dryRun: z18.boolean(),
13197
+ status: z19.string(),
13198
+ validationType: z19.string(),
13199
+ dryRun: z19.boolean(),
13386
13200
  payload: jsonObject.catch({}),
13387
13201
  resultPayload: jsonObject.catch({}),
13388
- schemaVersion: z18.string(),
13202
+ schemaVersion: z19.string(),
13389
13203
  testRunId: nullableString,
13390
- idempotencyKey: z18.string(),
13391
- createdAt: z18.string(),
13392
- updatedAt: z18.string()
13204
+ idempotencyKey: z19.string(),
13205
+ createdAt: z19.string(),
13206
+ updatedAt: z19.string()
13393
13207
  })
13394
13208
  );
13395
- var phantomApplyOperationSchema = z18.preprocess(
13209
+ var phantomApplyOperationSchema = z19.preprocess(
13396
13210
  normalizePhantomLedgerKeys,
13397
- z18.object({
13211
+ z19.object({
13398
13212
  id: idString,
13399
13213
  organizationId: idString,
13400
13214
  phantomRunId: idString,
13401
13215
  phantomCandidateId: idString,
13402
- status: z18.string(),
13403
- operationType: z18.string(),
13404
- dryRun: z18.boolean(),
13216
+ status: z19.string(),
13217
+ operationType: z19.string(),
13218
+ dryRun: z19.boolean(),
13405
13219
  targetType: nullableString,
13406
13220
  targetId: nullableString,
13407
13221
  payload: jsonObject.catch({}),
13408
13222
  resultPayload: jsonObject.catch({}),
13409
- schemaVersion: z18.string(),
13223
+ schemaVersion: z19.string(),
13410
13224
  testRunId: nullableString,
13411
- idempotencyKey: z18.string(),
13412
- createdAt: z18.string(),
13413
- updatedAt: z18.string()
13225
+ idempotencyKey: z19.string(),
13226
+ createdAt: z19.string(),
13227
+ updatedAt: z19.string()
13414
13228
  })
13415
13229
  );
13416
- var phantomRunsSchema = z18.array(phantomRunListItemSchema);
13417
- var phantomReportsSchema = z18.array(phantomReportSchema);
13418
- var phantomObservationsSchema = z18.array(phantomObservationSchema);
13419
- var phantomCandidatesSchema = z18.array(phantomCandidateSchema);
13420
- var phantomCandidateEvidencesSchema = z18.array(phantomCandidateEvidenceSchema);
13421
- var phantomValidationsSchema = z18.array(phantomValidationSchema);
13422
- var phantomApplyOperationsSchema = z18.array(phantomApplyOperationSchema);
13230
+ var phantomRunsSchema = z19.array(phantomRunListItemSchema);
13231
+ var phantomReportsSchema = z19.array(phantomReportSchema);
13232
+ var phantomObservationsSchema = z19.array(phantomObservationSchema);
13233
+ var phantomCandidatesSchema = z19.array(phantomCandidateSchema);
13234
+ var phantomCandidateEvidencesSchema = z19.array(phantomCandidateEvidenceSchema);
13235
+ var phantomValidationsSchema = z19.array(phantomValidationSchema);
13236
+ var phantomApplyOperationsSchema = z19.array(phantomApplyOperationSchema);
13423
13237
  function isRecord6(value) {
13424
13238
  return Boolean(value) && typeof value === "object" && !Array.isArray(value);
13425
13239
  }
@@ -14876,72 +14690,72 @@ function registerDatasheetsCommands(program) {
14876
14690
  }
14877
14691
 
14878
14692
  // src/commands/atlasAuthoring.ts
14879
- import { z as z19 } from "zod";
14880
- var idSchema14 = z19.string().trim().min(1);
14881
- var idempotencyKeySchema = z19.string().min(1).refine((value) => value.trim() === value, "Idempotency key must not have leading or trailing whitespace.");
14882
- var skillScopeSchema = z19.enum(["ADMIN_GLOBAL", "MEMBER_PERSONAL"]);
14883
- var isoDateSchema = z19.iso.date();
14884
- var nonEmptyStringSchema = z19.string().trim().min(1);
14693
+ import { z as z20 } from "zod";
14694
+ var idSchema14 = z20.string().trim().min(1);
14695
+ var idempotencyKeySchema = z20.string().min(1).refine((value) => value.trim() === value, "Idempotency key must not have leading or trailing whitespace.");
14696
+ var skillScopeSchema = z20.enum(["ADMIN_GLOBAL", "MEMBER_PERSONAL"]);
14697
+ var isoDateSchema = z20.iso.date();
14698
+ var nonEmptyStringSchema = z20.string().trim().min(1);
14885
14699
  var AUTOMATION_RUN_HTTP_TIMEOUT_MS = 6e4;
14886
- var agentToolAccessSchema = z19.array(
14887
- z19.object({
14700
+ var agentToolAccessSchema = z20.array(
14701
+ z20.object({
14888
14702
  tool_key: nonEmptyStringSchema,
14889
14703
  scope_value: nonEmptyStringSchema
14890
14704
  }).strict()
14891
14705
  ).min(1);
14892
14706
  var agentToolAccessUpdateSchema = agentToolAccessSchema.min(0);
14893
- var agentPluginConnectionsSchema = z19.array(
14894
- z19.object({
14707
+ var agentPluginConnectionsSchema = z20.array(
14708
+ z20.object({
14895
14709
  external_tool_connection_id: nonEmptyStringSchema,
14896
14710
  tool_key: nonEmptyStringSchema,
14897
14711
  scope_value: nonEmptyStringSchema.optional(),
14898
- allowed_tools: z19.array(nonEmptyStringSchema).optional(),
14899
- allowed_scopes: z19.array(nonEmptyStringSchema).optional(),
14900
- requires_confirmation: z19.boolean().optional(),
14901
- enabled: z19.boolean().optional()
14712
+ allowed_tools: z20.array(nonEmptyStringSchema).optional(),
14713
+ allowed_scopes: z20.array(nonEmptyStringSchema).optional(),
14714
+ requires_confirmation: z20.boolean().optional(),
14715
+ enabled: z20.boolean().optional()
14902
14716
  }).strict()
14903
14717
  ).min(1);
14904
- var agentPluginConnectionUpdateSchema = z19.array(
14905
- z19.union([
14906
- z19.object({
14718
+ var agentPluginConnectionUpdateSchema = z20.array(
14719
+ z20.union([
14720
+ z20.object({
14907
14721
  id: nonEmptyStringSchema,
14908
- _destroy: z19.literal(true)
14722
+ _destroy: z20.literal(true)
14909
14723
  }).strict(),
14910
- z19.object({
14724
+ z20.object({
14911
14725
  id: nonEmptyStringSchema.optional(),
14912
14726
  external_tool_connection_id: nonEmptyStringSchema.optional(),
14913
14727
  tool_key: nonEmptyStringSchema.optional(),
14914
14728
  scope_value: nonEmptyStringSchema.optional(),
14915
- allowed_tools: z19.array(nonEmptyStringSchema).optional(),
14916
- allowed_scopes: z19.array(nonEmptyStringSchema).optional(),
14917
- requires_confirmation: z19.boolean().optional(),
14918
- enabled: z19.boolean().optional()
14729
+ allowed_tools: z20.array(nonEmptyStringSchema).optional(),
14730
+ allowed_scopes: z20.array(nonEmptyStringSchema).optional(),
14731
+ requires_confirmation: z20.boolean().optional(),
14732
+ enabled: z20.boolean().optional()
14919
14733
  }).strict().superRefine((value, context) => {
14920
14734
  if (value.id || value.external_tool_connection_id && value.tool_key) return;
14921
14735
  context.addIssue({
14922
- code: z19.ZodIssueCode.custom,
14736
+ code: z20.ZodIssueCode.custom,
14923
14737
  message: "Plugin updates require an id, or both external_tool_connection_id and tool_key for a new grant."
14924
14738
  });
14925
14739
  })
14926
14740
  ])
14927
14741
  );
14928
- var agentTriggerSchema = z19.object({
14929
- trigger_type: z19.literal("cron"),
14742
+ var agentTriggerSchema = z20.object({
14743
+ trigger_type: z20.literal("cron"),
14930
14744
  cron_expression: nonEmptyStringSchema,
14931
14745
  timezone: nonEmptyStringSchema,
14932
- starts_at: z19.iso.datetime({ offset: true }).nullable().optional(),
14933
- ends_at: z19.iso.datetime({ offset: true }).nullable().optional(),
14934
- max_runs: z19.number().int().positive().nullable().optional(),
14935
- enabled: z19.boolean().optional()
14746
+ starts_at: z20.iso.datetime({ offset: true }).nullable().optional(),
14747
+ ends_at: z20.iso.datetime({ offset: true }).nullable().optional(),
14748
+ max_runs: z20.number().int().positive().nullable().optional(),
14749
+ enabled: z20.boolean().optional()
14936
14750
  }).strict();
14937
- var agentTriggerUpdateSchema = z19.union([
14751
+ var agentTriggerUpdateSchema = z20.union([
14938
14752
  agentTriggerSchema.extend({ id: nonEmptyStringSchema.optional() }).strict(),
14939
- z19.object({
14753
+ z20.object({
14940
14754
  id: nonEmptyStringSchema,
14941
- _destroy: z19.literal(true)
14755
+ _destroy: z20.literal(true)
14942
14756
  }).strict()
14943
14757
  ]);
14944
- var automationConfigSchema = z19.record(z19.string(), z19.unknown());
14758
+ var automationConfigSchema = z20.record(z20.string(), z20.unknown());
14945
14759
  var AGENT_SELECTION = `{
14946
14760
  id
14947
14761
  type
@@ -15017,6 +14831,11 @@ var AUTOMATION_SELECTION = `{
15017
14831
  organizationId
15018
14832
  memberId
15019
14833
  agentId
14834
+ agentTriggerId
14835
+ scheduleStatus
14836
+ triggerEnabled
14837
+ cronExpression
14838
+ timezone
15020
14839
  createdAt
15021
14840
  updatedAt
15022
14841
  updateVersion
@@ -15223,7 +15042,16 @@ function normalizeAutomationRunPayload(payload) {
15223
15042
  };
15224
15043
  }
15225
15044
  function parseAutomationConfig(value) {
15226
- return automationConfigSchema.parse(parseJson(String(value), "--ai-task-config"));
15045
+ const config = automationConfigSchema.parse(parseJson(String(value), "--ai-task-config"));
15046
+ if (Object.hasOwn(config, "agent_id") || Object.hasOwn(config, "agentId")) {
15047
+ throw new CliError({
15048
+ message: "Automation executor agent_id must be supplied through --agent-id, not --ai-task-config.",
15049
+ kind: "invalid_args",
15050
+ status: 400,
15051
+ exitCode: EXIT_CODES.invalidArgs
15052
+ });
15053
+ }
15054
+ return config;
15227
15055
  }
15228
15056
  function parseExpectedUpdateVersion(value) {
15229
15057
  return nonEmptyStringSchema.parse(String(value));
@@ -15432,7 +15260,7 @@ function registerAtlasAuthoringCommands(program) {
15432
15260
  "--service <service>",
15433
15261
  "Supported service: gmail, calendar, slack, or stripe"
15434
15262
  ).action(async (opts, cmd) => {
15435
- const service = z19.enum(["gmail", "calendar", "slack", "stripe"]).parse(opts.service);
15263
+ const service = z20.enum(["gmail", "calendar", "slack", "stripe"]).parse(opts.service);
15436
15264
  const context = await resolveCommandContext(cmd.optsWithGlobals());
15437
15265
  const organizationId = resolveOrganizationId(context.organizationId);
15438
15266
  await runGraphqlQueryCommand({
@@ -15446,7 +15274,7 @@ function registerAtlasAuthoringCommands(program) {
15446
15274
  });
15447
15275
  });
15448
15276
  const automations = program.command("automations").description("Bounded Automation authoring operations");
15449
- 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) => {
15277
+ 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) => {
15450
15278
  const idempotencyKey = idempotencyKeySchema.parse(opts.idempotencyKey);
15451
15279
  const context = await resolveCommandContext(cmd.optsWithGlobals());
15452
15280
  const organizationId = resolveOrganizationId(context.organizationId);
@@ -15464,7 +15292,7 @@ function registerAtlasAuthoringCommands(program) {
15464
15292
  organization_id: organizationId,
15465
15293
  input: {
15466
15294
  summary: idSchema14.parse(opts.summary),
15467
- ai_task_config: parseJson(String(opts.aiTaskConfig), "--ai-task-config"),
15295
+ ai_task_config: parseAutomationConfig(opts.aiTaskConfig),
15468
15296
  ...opts.description !== void 0 ? { description: String(opts.description) } : {},
15469
15297
  ...opts.notes !== void 0 ? { notes: String(opts.notes) } : {},
15470
15298
  ...opts.memberId !== void 0 ? { member_id: idSchema14.parse(opts.memberId) } : {},
@@ -15535,20 +15363,17 @@ function registerAtlasAuthoringCommands(program) {
15535
15363
  "Exact opaque updateVersion value from automations show; rejects stale writes"
15536
15364
  ).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(
15537
15365
  "--agent-id <agentId>",
15538
- "Executor Agent id; requires --ai-task-config and is stored in that config"
15366
+ "Rejected: executor ownership is immutable after Automation creation"
15539
15367
  ).action(async (opts, cmd) => {
15540
- if (opts.agentId !== void 0 && opts.aiTaskConfig === void 0) {
15368
+ if (opts.agentId !== void 0) {
15541
15369
  throw new CliError({
15542
- message: "automations update requires --ai-task-config whenever --agent-id is supplied.",
15370
+ message: "automations update cannot change executor ownership; create a new Automation instead.",
15543
15371
  kind: "invalid_args",
15544
15372
  status: 400,
15545
15373
  exitCode: EXIT_CODES.invalidArgs
15546
15374
  });
15547
15375
  }
15548
- const aiTaskConfig = opts.aiTaskConfig === void 0 ? void 0 : {
15549
- ...parseAutomationConfig(opts.aiTaskConfig),
15550
- ...opts.agentId !== void 0 ? { agent_id: idSchema14.parse(opts.agentId) } : {}
15551
- };
15376
+ const aiTaskConfig = opts.aiTaskConfig === void 0 ? void 0 : parseAutomationConfig(opts.aiTaskConfig);
15552
15377
  const patch = {
15553
15378
  ...opts.summary !== void 0 ? { summary: String(opts.summary) } : {},
15554
15379
  ...opts.description !== void 0 ? { description: String(opts.description) } : {},
@@ -15671,7 +15496,7 @@ import { join as join3 } from "path";
15671
15496
  import { createHash } from "crypto";
15672
15497
 
15673
15498
  // src/version.ts
15674
- var CLI_VERSION = "0.1.76";
15499
+ var CLI_VERSION = "0.1.77";
15675
15500
 
15676
15501
  // src/operationMetadata.ts
15677
15502
  var DISCOVERY_OPERATION_IDS = [
@@ -16075,7 +15900,6 @@ var WRITE_OPERATION_IDS = [
16075
15900
  "osmd.ingest.text",
16076
15901
  "osmd.ingest.transcript",
16077
15902
  "osmd.ingest.url",
16078
- "osmd.phantom.run",
16079
15903
  "osmd.wiki.append-log",
16080
15904
  "osmd.wiki.create",
16081
15905
  "osmd.wiki.index-upsert",
@@ -16394,22 +16218,21 @@ var NAMESPACE_DOCS = {
16394
16218
  osmd: {
16395
16219
  name: "osmd",
16396
16220
  tier: "primary",
16397
- description: "Canonical OSMD, .agent overlay, Agent Wiki, ingest, lint, and Phantom operations.",
16221
+ description: "Canonical OSMD, .agent overlay, Agent Wiki, ingest, and lint operations.",
16398
16222
  examples: [
16399
16223
  "wave osmd tree --depth 2",
16400
16224
  "wave osmd lint --json",
16401
16225
  'wave osmd ingest text "Notes" --slug notes --parent-ref "projects/Wave Tools" --summary "Source notes" --dry-run',
16402
- 'wave osmd agent update "projects/Wave Tools" notes.md --content "# Notes"',
16403
- "wave osmd phantom run --dry-run"
16226
+ 'wave osmd agent update "projects/Wave Tools" notes.md --content "# Notes"'
16404
16227
  ],
16405
16228
  schema: {
16406
16229
  output: "json-envelope-default",
16407
16230
  safety: [
16408
16231
  "Canonical OSMD writes are blocked before mutation.",
16409
16232
  "Agent Wiki log is append-only.",
16410
- "Ingest and Phantom support dry-run paths."
16233
+ "Ingest supports dry-run paths."
16411
16234
  ],
16412
- commands: ["tree", "status", "read", "children", "search", "lint", "memory-quality", "ingest", "phantom", "agent", "wiki"]
16235
+ commands: ["tree", "status", "read", "children", "search", "lint", "memory-quality", "ingest", "agent", "wiki"]
16413
16236
  }
16414
16237
  },
16415
16238
  phantom: {
@@ -17215,7 +17038,7 @@ function registerDiscoveryCommands(program) {
17215
17038
  const phantom = program.commands.find((command) => command.name() === "phantom");
17216
17039
  phantom?.addHelpText(
17217
17040
  "after",
17218
- "\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"
17041
+ "\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"
17219
17042
  );
17220
17043
  }
17221
17044
  function attachNamespaceDiscovery(program) {
@@ -17281,12 +17104,11 @@ function attachDiscoveryHelp(program) {
17281
17104
  " wave capabilities list",
17282
17105
  " wave capabilities tools",
17283
17106
  " wave osmd lint --json",
17284
- " wave osmd phantom run --dry-run",
17285
17107
  " wave doctor"
17286
17108
  ].join("\n")
17287
17109
  );
17288
17110
  const helpByName = /* @__PURE__ */ new Map([
17289
- ["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'],
17111
+ ["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'],
17290
17112
  ["broadcast", "\nExamples:\n wave broadcast list\n wave broadcast workspace\n wave broadcast community\n wave broadcast open\n"],
17291
17113
  ["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"],
17292
17114
  ["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"],
@@ -17385,19 +17207,30 @@ function buildCli(options) {
17385
17207
 
17386
17208
  // src/machine.ts
17387
17209
  import { createHash as createHash2 } from "crypto";
17210
+ import { readSync } from "fs";
17388
17211
  var MACHINE_FLAGS = /* @__PURE__ */ new Set([
17389
17212
  "--machine",
17390
17213
  "--operation",
17391
17214
  "--phase",
17392
- "--input-json"
17215
+ "--input-json",
17216
+ "--machine-auth-fd",
17217
+ "--machine-approval-fd"
17393
17218
  ]);
17219
+ var MACHINE_AUTH_FD = 3;
17220
+ var MACHINE_APPROVAL_FD = 4;
17221
+ var MAX_MACHINE_SECRET_BYTES = 64 * 1024;
17222
+ var MAX_MACHINE_INPUT_BYTES = 128 * 1024;
17394
17223
  function machineEnvelope(params) {
17395
17224
  return {
17396
17225
  ok: params.ok,
17397
17226
  command: params.command,
17398
17227
  status: params.status,
17399
17228
  data: params.data ?? null,
17400
- error: params.error ?? null,
17229
+ error: params.error ? {
17230
+ code: params.error.code,
17231
+ message: params.error.message,
17232
+ details: params.error.details ?? {}
17233
+ } : null,
17401
17234
  meta: { requestId: "machine" }
17402
17235
  };
17403
17236
  }
@@ -17419,7 +17252,7 @@ function commandId(command) {
17419
17252
  function parseMachineArgs(argv) {
17420
17253
  const values = {};
17421
17254
  for (let index = 0; index < argv.length; index += 1) {
17422
- const flag = argv[index];
17255
+ const flag = argv[index] ?? "";
17423
17256
  if (!MACHINE_FLAGS.has(flag)) {
17424
17257
  return { error: `Unsupported machine flag: ${flag}` };
17425
17258
  }
@@ -17434,19 +17267,45 @@ function parseMachineArgs(argv) {
17434
17267
  if (values["--machine"] !== "execute") {
17435
17268
  return { error: '--machine must be "execute".' };
17436
17269
  }
17270
+ const authFd = parseReservedMachineFd(values["--machine-auth-fd"], MACHINE_AUTH_FD);
17271
+ if (authFd instanceof Error) return { error: authFd.message };
17272
+ const approvalFd = parseReservedMachineFd(
17273
+ values["--machine-approval-fd"],
17274
+ MACHINE_APPROVAL_FD
17275
+ );
17276
+ if (approvalFd instanceof Error) return { error: approvalFd.message };
17437
17277
  return {
17438
- operation: values["--operation"],
17439
- phase: values["--phase"],
17440
- inputJson: values["--input-json"]
17278
+ ...values["--operation"] ? { operation: values["--operation"] } : {},
17279
+ ...values["--phase"] ? { phase: values["--phase"] } : {},
17280
+ ...values["--input-json"] ? { inputJson: values["--input-json"] } : {},
17281
+ ...authFd !== void 0 ? { authFd } : {},
17282
+ ...approvalFd !== void 0 ? { approvalFd } : {}
17441
17283
  };
17442
17284
  }
17285
+ function parseReservedMachineFd(value, expected) {
17286
+ if (value === void 0) return void 0;
17287
+ if (!/^\d+$/.test(value) || Number(value) !== expected) {
17288
+ return new Error(`The machine secret descriptor must be fd ${expected}.`);
17289
+ }
17290
+ return expected;
17291
+ }
17443
17292
  async function readMachineInput(location) {
17444
17293
  if (location !== "-") {
17445
17294
  throw new Error('Machine input must be supplied with "--input-json -".');
17446
17295
  }
17447
17296
  let raw = "";
17297
+ let bytes = 0;
17448
17298
  process.stdin.setEncoding("utf8");
17449
- for await (const chunk of process.stdin) raw += chunk;
17299
+ for await (const chunk of process.stdin) {
17300
+ const text = String(chunk);
17301
+ bytes += Buffer.byteLength(text, "utf8");
17302
+ if (bytes > MAX_MACHINE_INPUT_BYTES) {
17303
+ throw new Error(
17304
+ `Machine input exceeds the maximum size of ${MAX_MACHINE_INPUT_BYTES} bytes.`
17305
+ );
17306
+ }
17307
+ raw += text;
17308
+ }
17450
17309
  if (!raw.trim()) throw new Error("Machine input JSON is required.");
17451
17310
  const parsed = JSON.parse(raw);
17452
17311
  if (!isPlainObject(parsed)) throw new Error("Machine input must be a JSON object.");
@@ -17467,11 +17326,20 @@ function normalizeInput(input) {
17467
17326
  Object.keys(input).sort().map((key) => [key, input[key]])
17468
17327
  );
17469
17328
  }
17470
- function parseTrustedJson(name, predicate) {
17471
- const raw = process.env[name];
17472
- if (!raw) return null;
17329
+ function parseTrustedJsonFromFd(fd, predicate) {
17330
+ if (fd === void 0) return null;
17473
17331
  try {
17474
- const parsed = JSON.parse(raw);
17332
+ const chunks = [];
17333
+ const buffer = Buffer.allocUnsafe(8 * 1024);
17334
+ let bytes = 0;
17335
+ while (true) {
17336
+ const read = readSync(fd, buffer, 0, buffer.length, null);
17337
+ if (read === 0) break;
17338
+ bytes += read;
17339
+ if (bytes > MAX_MACHINE_SECRET_BYTES) return null;
17340
+ chunks.push(Buffer.from(buffer.subarray(0, read)));
17341
+ }
17342
+ const parsed = JSON.parse(Buffer.concat(chunks).toString("utf8"));
17475
17343
  return predicate(parsed) ? parsed : null;
17476
17344
  } catch {
17477
17345
  return null;
@@ -17546,13 +17414,9 @@ function withTrustedMachineAuth(auth, callback) {
17546
17414
  for (const key of Object.keys(process.env)) {
17547
17415
  if (key.startsWith("WAVE_")) delete process.env[key];
17548
17416
  }
17549
- if (auth) {
17550
- process.env.WAVE_API_TOKEN = auth.token;
17551
- process.env.WAVE_API_BASE_URL = auth.baseUrl;
17552
- }
17553
17417
  process.env.WAVE_CLI_AUTH_STORAGE = "disabled";
17554
17418
  process.env.WAVE_CLI_HOME = "/dev/null";
17555
- return callback().finally(() => {
17419
+ return withMachineRuntimeAuth(auth, callback).finally(() => {
17556
17420
  for (const key of Object.keys(process.env)) {
17557
17421
  if (key.startsWith("WAVE_")) delete process.env[key];
17558
17422
  }
@@ -17704,7 +17568,7 @@ async function maybeRunMachineExecute(argv, program) {
17704
17568
  })
17705
17569
  });
17706
17570
  }
17707
- const auth = parseTrustedJson("WAVE_MACHINE_AUTH_JSON", isTrustedAuth);
17571
+ const auth = parseTrustedJsonFromFd(parsed.authFd, isTrustedAuth);
17708
17572
  if (needsTrustedAuth(resolved.operation) && !auth) {
17709
17573
  return printEnvelopeAndExit({
17710
17574
  envelope: machineEnvelope({
@@ -17720,7 +17584,7 @@ async function maybeRunMachineExecute(argv, program) {
17720
17584
  });
17721
17585
  }
17722
17586
  if (resolved.operation.classification === "write") {
17723
- const approval = parseTrustedJson("WAVE_MACHINE_APPROVAL_JSON", isTrustedApproval);
17587
+ const approval = parseTrustedJsonFromFd(parsed.approvalFd, isTrustedApproval);
17724
17588
  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) {
17725
17589
  return printEnvelopeAndExit({
17726
17590
  envelope: machineEnvelope({