@warmhub/cli 0.146.0 → 0.147.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/wh.js +141 -29
  2. package/package.json +1 -1
package/dist/wh.js CHANGED
@@ -18538,6 +18538,9 @@ function decodeDurableId(token) {
18538
18538
  thingId: bytesToUuid(payload, UUID_BYTES)
18539
18539
  };
18540
18540
  }
18541
+ function isDurableId(token) {
18542
+ return decodeDurableId(token) !== null;
18543
+ }
18541
18544
  var VERSION_SELECTOR_RE = /^(?:v0*[1-9]\d*|[Hh][Ee][Aa][Dd]|[Aa][Ll][Ll])$/;
18542
18545
  function parseDurableReferenceToken(raw) {
18543
18546
  const at = raw.lastIndexOf("@");
@@ -18577,7 +18580,7 @@ function isReservedShapeName(name) {
18577
18580
  return name === RESERVED_THING_ROOT;
18578
18581
  }
18579
18582
  function reservedThingRootMessage(name) {
18580
- return `Name "${name}" is under the reserved root "${RESERVED_THING_ROOT_PREFIX}"; only Shapes live there, as ${RESERVED_THING_ROOT_PREFIX}shapes/<Name>`;
18583
+ return `Name "${name}" is under the reserved root "${RESERVED_THING_ROOT_PREFIX}"; only platform-owned names may live there, including ${RESERVED_THING_ROOT_PREFIX}shapes/<Name> and ${RESERVED_THING_ROOT_PREFIX}redacted/<durable-id>`;
18581
18584
  }
18582
18585
 
18583
18586
  // ../../packages/rules/src/wref.ts
@@ -18754,11 +18757,13 @@ var COMMIT_OPERATIONS = [
18754
18757
  "retract",
18755
18758
  "reaffirm",
18756
18759
  "rename",
18760
+ "redact",
18757
18761
  "remove",
18758
18762
  "restore",
18759
18763
  "rewrite"
18760
18764
  ];
18761
18765
  var PRIVILEGED_COMMIT_OPERATIONS = {
18766
+ redact: "things:redact",
18762
18767
  remove: "things:delete",
18763
18768
  rewrite: "things:rewrite"
18764
18769
  };
@@ -18837,7 +18842,16 @@ var COMPONENT_TEMPLATE_VALUES = {
18837
18842
  "org-name": (ctx) => ctx.orgName,
18838
18843
  "repo-name": (ctx) => ctx.repoName
18839
18844
  };
18840
- var TEMPLATE_TOKEN_RE = /<([a-z-]+)>/g;
18845
+ function parseComponentTemplateToken(raw) {
18846
+ switch (raw) {
18847
+ case "org-name":
18848
+ case "repo-name":
18849
+ return raw;
18850
+ default:
18851
+ return;
18852
+ }
18853
+ }
18854
+ var TEMPLATE_TOKEN_RE = /<([^>]+)>/g;
18841
18855
  function listComponentTemplateTokens(value) {
18842
18856
  const tokens = new Set;
18843
18857
  for (const match of value.matchAll(TEMPLATE_TOKEN_RE)) {
@@ -18848,15 +18862,15 @@ function listComponentTemplateTokens(value) {
18848
18862
  return [...tokens];
18849
18863
  }
18850
18864
  function unsupportedComponentTemplateTokens(value) {
18851
- return listComponentTemplateTokens(value).filter((token) => !(token in COMPONENT_TEMPLATE_VALUES));
18865
+ return listComponentTemplateTokens(value).filter((token) => parseComponentTemplateToken(token) === undefined);
18852
18866
  }
18853
18867
  function resolveComponentTemplate(value, ctx) {
18854
18868
  return value.replace(TEMPLATE_TOKEN_RE, (_match, token) => {
18855
- const resolver = COMPONENT_TEMPLATE_VALUES[token];
18856
- if (!resolver) {
18869
+ const parsed = parseComponentTemplateToken(token);
18870
+ if (!parsed) {
18857
18871
  throw new Error(`Unsupported component template token <${token}>`);
18858
18872
  }
18859
- return resolver(ctx);
18873
+ return COMPONENT_TEMPLATE_VALUES[parsed](ctx);
18860
18874
  });
18861
18875
  }
18862
18876
 
@@ -25940,6 +25954,8 @@ var CORRECTED_THING_SHAPE_NAME = "CorrectedThing";
25940
25954
  var CORRECTED_THING_FIELDS = {
25941
25955
  correctionLog: { type: "array", items: { reason: "string" }, minItems: 1 }
25942
25956
  };
25957
+ var REDACTED_THING_SHAPE_NAME = "RedactedThing";
25958
+ var REDACTED_THING_FIELDS = {};
25943
25959
  var SYSTEM_SHAPES = [
25944
25960
  {
25945
25961
  name: "ComponentInstall",
@@ -25965,6 +25981,12 @@ var SYSTEM_SHAPES = [
25965
25981
  name: CORRECTED_THING_SHAPE_NAME,
25966
25982
  fields: CORRECTED_THING_FIELDS,
25967
25983
  onDemand: true
25984
+ },
25985
+ {
25986
+ name: REDACTED_THING_SHAPE_NAME,
25987
+ fields: REDACTED_THING_FIELDS,
25988
+ onDemand: true,
25989
+ systemOnlyCertification: true
25968
25990
  }
25969
25991
  ];
25970
25992
  var SYSTEM_MANIFEST = {
@@ -26006,6 +26028,7 @@ var SYSTEM_PROTECTED_SHAPES = SYSTEM_COMPONENT.shapes.filter((shape) => shape.in
26006
26028
  var SYSTEM_PROTECTED_FAMILY_SHAPES = SYSTEM_PROTECTED_SHAPES.filter((shape) => shape.onDemand !== true);
26007
26029
  var SYSTEM_INFRA_SHAPE_NAMES = new Set(SYSTEM_COMPONENTS.flatMap((entry) => entry.shapes.filter((shape) => shape.installInfra === true).map((shape) => shape.name)));
26008
26030
  var SYSTEM_SHAPE_NAMES2 = new Set(SYSTEM_MANIFEST.shapes.map((shape) => shape.name));
26031
+ var SYSTEM_ONLY_CERTIFICATE_SHAPE_NAMES = new Set(SYSTEM_COMPONENT.shapes.filter((shape) => shape.systemOnlyCertification === true).map((shape) => shape.name));
26009
26032
  function isSystemShapeName(name) {
26010
26033
  return SYSTEM_SHAPE_NAMES2.has(name);
26011
26034
  }
@@ -44826,6 +44849,7 @@ var DEFINITE_CLIENT_REJECT_CODES = new Set([
44826
44849
  "CONFLICT",
44827
44850
  "NAME_TAKEN",
44828
44851
  "TARGET_REMOVED",
44852
+ "TARGET_REDACTED",
44829
44853
  "ALREADY_RETRACTED",
44830
44854
  "ARCHIVED",
44831
44855
  "RATE_LIMITED",
@@ -46325,6 +46349,11 @@ var currentErrorDetailsSchema = exports_external.discriminatedUnion("reason", [
46325
46349
  reason: exports_external.literal("target_removed"),
46326
46350
  targetDurableId: exports_external.string().min(1),
46327
46351
  fieldPath: exports_external.string().optional()
46352
+ }).loose(),
46353
+ exports_external.object({
46354
+ reason: exports_external.literal("target_redacted"),
46355
+ targetDurableId: exports_external.string().min(1),
46356
+ fieldPath: exports_external.string().optional()
46328
46357
  }).loose()
46329
46358
  ]);
46330
46359
  var currentBaseShape = {
@@ -46831,7 +46860,7 @@ function createStreamingSubmissionHandle(input, deps) {
46831
46860
  // ../../packages/sdk-ts/package.json
46832
46861
  var package_default = {
46833
46862
  name: "@warmhub/sdk-ts",
46834
- version: "0.144.0",
46863
+ version: "0.145.0",
46835
46864
  private: false,
46836
46865
  type: "module",
46837
46866
  description: "The TypeScript SDK for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -49049,6 +49078,19 @@ class WarmHubClient {
49049
49078
  throw toWarmHubError(error51);
49050
49079
  }
49051
49080
  },
49081
+ redact: async (orgName, repoName, durableId, opts) => {
49082
+ try {
49083
+ return await this.trpc.thing.redact.mutate({
49084
+ orgName,
49085
+ repoName,
49086
+ durableId,
49087
+ expectedVersion: opts.expectedVersion,
49088
+ eventRequestId: opts.eventRequestId
49089
+ });
49090
+ } catch (error51) {
49091
+ throw toWarmHubError(error51);
49092
+ }
49093
+ },
49052
49094
  rewrite: async (orgName, repoName, wref, opts) => {
49053
49095
  try {
49054
49096
  return await this.trpc.thing.rewrite.mutate({
@@ -51867,11 +51909,13 @@ function loadProfileStore(path) {
51867
51909
  } catch (cause) {
51868
51910
  throw corruptedAuthError(p, cause);
51869
51911
  }
51870
- if (parsed === null || typeof parsed !== "object" || parsed.version !== 1 || parsed.profiles === null || typeof parsed.profiles !== "object" || Array.isArray(parsed.profiles)) {
51912
+ if (!isProfileStore(parsed))
51871
51913
  throw corruptedAuthError(p);
51872
- }
51873
51914
  return parsed;
51874
51915
  }
51916
+ function isProfileStore(value) {
51917
+ return isPlainObject(value) && value.version === 1 && isPlainObject(value.profiles) && Object.values(value.profiles).every((profile) => isPlainObject(profile) && isPlainObject(profile.tokens));
51918
+ }
51875
51919
  function corruptedAuthError(path, cause) {
51876
51920
  getLog().error("auth.profile.corrupt", { path });
51877
51921
  return new CliError(3 /* Config */, "CONFIG", `Auth file at ${path} is unreadable or in an unknown format.`, cause, `Remove the file (\`rm ${path}\`) and run \`wh auth login\` to re-authenticate.`);
@@ -54142,7 +54186,7 @@ function emitNoMatchHint(ctx, match, count) {
54142
54186
  }
54143
54187
 
54144
54188
  // ../../packages/warmhub-cli/src/domains/commit-output-contract-id.ts
54145
- var COMMIT_SUBMIT_OUTPUT_SCHEMA_ID = "wh.commit.submit.result/v0.11";
54189
+ var COMMIT_SUBMIT_OUTPUT_SCHEMA_ID = "wh.commit.submit.result/v0.12";
54146
54190
  function identifyCommitSubmitOutput(value) {
54147
54191
  if ("schema" in value) {
54148
54192
  if (value.schema === COMMIT_SUBMIT_OUTPUT_SCHEMA_ID) {
@@ -56136,6 +56180,59 @@ function renderQueryResults(out, c, result) {
56136
56180
  out(`${c.dim}${items.length} result(s)${c.reset}`);
56137
56181
  }
56138
56182
 
56183
+ // ../../packages/warmhub-cli/src/domains/thing/redact.ts
56184
+ var USAGE = "Usage: wh thing redact <durableId> [--expected-version <n>] [--yes]";
56185
+ var EXAMPLE = "wh thing redact 040T1QCTF2Y79... --expected-version 3 --yes";
56186
+ var redactFlags = {
56187
+ "expected-version": flag.number({
56188
+ description: "only redact if the Thing is still at this version (default: the version read before redacting)"
56189
+ }),
56190
+ yes: flag.boolean({ short: "y", description: "Skip confirmation prompt" }),
56191
+ "event-request-id": operationEventRequestIdFlag
56192
+ };
56193
+ var handleThingRedact = async (ctx, { flags, args }) => {
56194
+ const durableId = args[0];
56195
+ if (!durableId)
56196
+ usageError(USAGE, EXAMPLE);
56197
+ const repoRef = getRepoRef(ctx);
56198
+ if (!isDurableId(durableId)) {
56199
+ usageError(`${USAGE}
56200
+ Redaction requires the Thing's bare durable ID, never a wref.`, `wh thing resolve ${durableId}${repoRef ? ` --repo ${repoRef}` : ""}`);
56201
+ }
56202
+ const { org, repo } = parseOrgRepo(repoRef, ctx.config);
56203
+ const c = ctx.colors;
56204
+ let expectedVersion = parsePositiveIntFlag(flags["expected-version"], "--expected-version", EXAMPLE);
56205
+ let label = durableId;
56206
+ if (expectedVersion === undefined || !flags.yes) {
56207
+ const thing = await ctx.client.thing.get(org, repo, durableId, undefined, {
56208
+ includeRetracted: true
56209
+ });
56210
+ expectedVersion ??= thing.version;
56211
+ label = `${thing.wref} (${durableId})`;
56212
+ }
56213
+ if (!flags.yes) {
56214
+ const confirmed = await ctx.confirm?.(`Irreversibly redact ${label} at v${expectedVersion}? This erases its canonical content and former name, but not backups, completed exports, logs, or downstream copies.`);
56215
+ if (!confirmed) {
56216
+ ctx.status("Cancelled");
56217
+ return;
56218
+ }
56219
+ }
56220
+ const eventRequestId = flags["event-request-id"] ?? createOperationEventRequestId();
56221
+ ctx.status(`Operation event request: ${eventRequestId}`);
56222
+ const receipt = await ctx.client.thing.redact(org, repo, durableId, {
56223
+ eventRequestId,
56224
+ expectedVersion
56225
+ });
56226
+ writeOutput(ctx, receipt, () => {
56227
+ if (receipt.pruned) {
56228
+ ctx.out(`${c.dim}Replayed${c.reset} ${displayName(c, durableId)} (the receipt was pruned; the Thing was removed since)`);
56229
+ return;
56230
+ }
56231
+ const operation = receipt.operations.find((candidate) => candidate.operation === "redact");
56232
+ ctx.out(operation?.status === "noop" ? `${c.dim}Already redacted${c.reset} ${displayName(c, durableId)}` : `${c.green}Redacted${c.reset} ${displayName(c, durableId)}`);
56233
+ });
56234
+ };
56235
+
56139
56236
  // ../../packages/warmhub-cli/src/domains/thing/refs.ts
56140
56237
  var refsFlags = {
56141
56238
  inbound: flag.boolean({
@@ -56254,8 +56351,8 @@ var handleReleaseLease = async (ctx, { flags, args }) => {
56254
56351
  };
56255
56352
 
56256
56353
  // ../../packages/warmhub-cli/src/domains/thing/remove.ts
56257
- var USAGE = "Usage: wh thing remove <wref|durableId> [--expected-version <n>] [--yes]";
56258
- var EXAMPLE = "wh thing remove cave --yes";
56354
+ var USAGE2 = "Usage: wh thing remove <wref|durableId> [--expected-version <n>] [--yes]";
56355
+ var EXAMPLE2 = "wh thing remove cave --yes";
56259
56356
  var removeFlags = {
56260
56357
  "expected-version": flag.number({
56261
56358
  description: "only remove if the Thing is still at this version (default: the version read before removing)"
@@ -56266,7 +56363,7 @@ var removeFlags = {
56266
56363
  var handleThingRemove = async (ctx, { flags, args }) => {
56267
56364
  const target = args[0];
56268
56365
  if (!target)
56269
- usageError(USAGE, EXAMPLE);
56366
+ usageError(USAGE2, EXAMPLE2);
56270
56367
  const { org, repo } = parseOrgRepo(getRepoRef(ctx), ctx.config);
56271
56368
  const c = ctx.colors;
56272
56369
  let expectedVersion = parsePositiveIntFlag(flags["expected-version"], "--expected-version", "wh thing remove cave --expected-version 3");
@@ -56476,8 +56573,8 @@ var handleRevise2 = async (ctx, { flags, args }) => {
56476
56573
  };
56477
56574
 
56478
56575
  // ../../packages/warmhub-cli/src/domains/thing/rewrite.ts
56479
- var USAGE2 = "Usage: wh thing rewrite <name@vN|durableId@vN> --shape <Shape>... (--data <json-object> | --file <path>) [--yes]";
56480
- var EXAMPLE2 = "wh thing rewrite cave@v2 --shape Location --shape CorrectedThing --file corrected.json --yes";
56576
+ var USAGE3 = "Usage: wh thing rewrite <name@vN|durableId@vN> --shape <Shape>... (--data <json-object> | --file <path>) [--yes]";
56577
+ var EXAMPLE3 = "wh thing rewrite cave@v2 --shape Location --shape CorrectedThing --file corrected.json --yes";
56481
56578
  var rewriteFlags = {
56482
56579
  shape: flag.string({
56483
56580
  multiple: true,
@@ -56497,24 +56594,24 @@ function parseTarget(target) {
56497
56594
  try {
56498
56595
  parsed = parseWref(target);
56499
56596
  } catch (error51) {
56500
- usageError(`${USAGE2}
56501
- ${error51 instanceof Error ? error51.message : String(error51)}`, EXAMPLE2);
56597
+ usageError(`${USAGE3}
56598
+ ${error51 instanceof Error ? error51.message : String(error51)}`, EXAMPLE3);
56502
56599
  }
56503
56600
  if (parsed.version.type !== "pinned") {
56504
- usageError(`${USAGE2}
56505
- Name the exact version to correct, e.g. cave@v2.`, EXAMPLE2);
56601
+ usageError(`${USAGE3}
56602
+ Name the exact version to correct, e.g. cave@v2.`, EXAMPLE3);
56506
56603
  }
56507
56604
  return { wref: stripWrefVersion(target), version: parsed.version.n };
56508
56605
  }
56509
56606
  var handleThingRewrite = async (ctx, { flags, args }) => {
56510
56607
  const target = args[0];
56511
56608
  if (!target)
56512
- usageError(USAGE2, EXAMPLE2);
56609
+ usageError(USAGE3, EXAMPLE3);
56513
56610
  const { wref, version: version2 } = parseTarget(target);
56514
56611
  const shapes = flags.shape ?? [];
56515
56612
  if (shapes.length === 0) {
56516
- usageError(`${USAGE2}
56517
- State the Shapes the version declares, plus CorrectedThing.`, EXAMPLE2);
56613
+ usageError(`${USAGE3}
56614
+ State the Shapes the version declares, plus CorrectedThing.`, EXAMPLE3);
56518
56615
  }
56519
56616
  const { org, repo } = parseOrgRepo(getRepoRef(ctx), ctx.config);
56520
56617
  const c = ctx.colors;
@@ -56523,7 +56620,7 @@ State the Shapes the version declares, plus CorrectedThing.`, EXAMPLE2);
56523
56620
  file: flags.file,
56524
56621
  inlineFlag: "--data",
56525
56622
  missingMessage: "--data is required for rewrite unless --file is provided: the complete replacement body",
56526
- example: EXAMPLE2
56623
+ example: EXAMPLE3
56527
56624
  });
56528
56625
  if (ctx.dryRun) {
56529
56626
  const validation = await ctx.client.commit.validate(org, repo, [
@@ -57126,6 +57223,20 @@ var THING_DOMAIN = defineDomain({
57126
57223
  ],
57127
57224
  handler: handleThingRemove
57128
57225
  },
57226
+ redact: {
57227
+ prime: false,
57228
+ summary: "Irreversibly erase canonical content while preserving identity (needs things:redact)",
57229
+ args: "<durableId>",
57230
+ flags: redactFlags,
57231
+ examples: [
57232
+ "wh thing redact 040T1QCTF2Y79... --yes",
57233
+ "wh thing redact 040T1QCTF2Y79... --expected-version 3 --yes"
57234
+ ],
57235
+ notes: [
57236
+ "Core redaction does not erase backups, completed exports, logs, or copies already delivered downstream."
57237
+ ],
57238
+ handler: handleThingRedact
57239
+ },
57129
57240
  rewrite: {
57130
57241
  prime: false,
57131
57242
  summary: "Replace the body of one exact version in place (needs things:rewrite)",
@@ -59687,7 +59798,7 @@ var createFlags3 = {
59687
59798
  };
59688
59799
 
59689
59800
  // ../../packages/warmhub-cli/src/domains/commit-stream-output-contract-id.ts
59690
- var COMMIT_SUBMIT_STREAM_ROW_SCHEMA_ID = "wh.commit.submit.stream.row/v0.10";
59801
+ var COMMIT_SUBMIT_STREAM_ROW_SCHEMA_ID = "wh.commit.submit.stream.row/v0.11";
59691
59802
  function identify(row) {
59692
59803
  if ("schema" in row) {
59693
59804
  throw new Error("Streaming submission row already defines a schema field");
@@ -59954,6 +60065,7 @@ function retractHint(name) {
59954
60065
  return `use {"operation":"retract","name":"${name ?? "<wref>"}"} or \`wh commit submit --retract${name ? ` ${name}` : ""}\``;
59955
60066
  }
59956
60067
  var PRIVILEGED_OPERATION_HINTS = {
60068
+ redact: ({ name }) => `To irreversibly erase canonical Thing content while preserving its identity, use \`wh thing redact ${name && isDurableId(name) ? name : "<durable-id>"} --expected-version <n> --yes\`.`,
59957
60069
  remove: ({ name }) => `To delete the Thing permanently, use \`wh thing remove ${name ?? "<wref>"}\`. To withdraw it, ${retractHint(name)}.`,
59958
60070
  rewrite: ({ name, version: version2 }) => `To correct a version in place, use \`wh thing rewrite ${name ?? "<wref>"}@v${typeof version2 === "number" ? version2 : "<n>"} --shape <Shape>... --file <body.json>\`.`
59959
60071
  };
@@ -61665,7 +61777,7 @@ function bindComponentMethodArgs(invocation, method) {
61665
61777
  }
61666
61778
 
61667
61779
  // ../../packages/warmhub-cli/src/component-exec.ts
61668
- var USAGE3 = "wh component exec <component> <method> [args] --repo org/repo";
61780
+ var USAGE4 = "wh component exec <component> <method> [args] --repo org/repo";
61669
61781
  function methodHelpHint(componentName, methodName, installRepo) {
61670
61782
  return `wh component exec ${componentName} ${methodName} --help --repo ${installRepo}`;
61671
61783
  }
@@ -61719,7 +61831,7 @@ var handleComponentExec = async (ctx, _domain) => {
61719
61831
  const helpRequested = invocation.help;
61720
61832
  const dryRun = invocation.flags["dry-run"] === true;
61721
61833
  if (!invocation.component)
61722
- usageError("Component name is required", USAGE3);
61834
+ usageError("Component name is required", USAGE4);
61723
61835
  const componentName = invocation.component;
61724
61836
  const methodName = invocation.method;
61725
61837
  const { org, repo } = parseOrgRepo(getRepoRef(ctx), ctx.config);
@@ -72248,7 +72360,7 @@ function resolveLogLevel(flagLevel, env) {
72248
72360
  // package.json
72249
72361
  var package_default3 = {
72250
72362
  name: "@warmhub/cli",
72251
- version: "0.146.0",
72363
+ version: "0.147.0",
72252
72364
  private: false,
72253
72365
  type: "module",
72254
72366
  description: "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",
@@ -72873,5 +72985,5 @@ process.exitCode = interceptedExitCode === undefined ? await runPreparedCli(laun
72873
72985
  version: package_default3.version
72874
72986
  }) : interceptedExitCode;
72875
72987
 
72876
- //# debugId=C60966EBD66E31FA64756E2164756E21
72877
- //# warmhub-cli-build-info {"cliVersion":"0.146.0","sdkVersion":"0.144.0"}
72988
+ //# debugId=2ABA0653C6EADCF764756E2164756E21
72989
+ //# warmhub-cli-build-info {"cliVersion":"0.147.0","sdkVersion":"0.145.0"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warmhub/cli",
3
- "version": "0.146.0",
3
+ "version": "0.147.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "The wh CLI for WarmHub — create repos, commit and query data, and compound knowledge with your AI agents.",