@native-marketing/sdk 0.3.7 → 0.3.8

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
@@ -2570,6 +2570,7 @@ var permissionSchema = z32.enum([
2570
2570
  "feedback.manage",
2571
2571
  "recommendation.create",
2572
2572
  "package.download",
2573
+ "presentation.share",
2573
2574
  "source.read",
2574
2575
  "source.ingest",
2575
2576
  "source.content.read"
@@ -6934,7 +6935,13 @@ var surveyRejections = [
6934
6935
  "PERSONAL_SURVEY_DRAFT_TRANSITION_IMMUTABLE"
6935
6936
  ];
6936
6937
  function isKnownCapabilityRejection(code2, name) {
6937
- return capabilityRejectedErrorCodes.includes(code2) || name === "cf_repair_knowledge_reference" && [
6938
+ return name === "cf_issue_human_read_link" && [
6939
+ "HUMAN_TARGET_NOT_FOUND",
6940
+ "HUMAN_CONTENT_TOO_LARGE",
6941
+ "HUMAN_LINK_REQUEST_CONFLICT",
6942
+ "HUMAN_LINK_LIMIT",
6943
+ "HUMAN_LINK_SECRET_UNAVAILABLE"
6944
+ ].includes(code2) || name === "cf_revoke_human_read_link" && code2 === "HUMAN_LINK_REQUEST_CONFLICT" || name === "cf_cleanup_human_read_links" && code2 === "HUMAN_CLEANUP_INPUT_INVALID" || capabilityRejectedErrorCodes.includes(code2) || name === "cf_repair_knowledge_reference" && [
6938
6945
  "KNOWLEDGE_REFERENCE_REPAIR_CONFLICT",
6939
6946
  "KNOWLEDGE_REFERENCE_REPAIR_NOT_SUPPORTED",
6940
6947
  "KNOWLEDGE_REFERENCE_REPAIR_IDENTITY_MISMATCH",
@@ -7008,6 +7015,8 @@ function capabilityRecovery(code2, outcome, name) {
7008
7015
  const change2 = changeCapabilityRecovery(code2, outcome, name);
7009
7016
  if (change2) return change2;
7010
7017
  if (outcome === "UNKNOWN") {
7018
+ if (name === "cf_issue_human_read_link") return "FIND_ORIGINAL_RECEIPT";
7019
+ if (name === "cf_revoke_human_read_link") return "READ_ORIGINAL_LINK_STATE";
7011
7020
  if ([
7012
7021
  "cf_material_verification_start",
7013
7022
  "cf_material_verification_advance",
@@ -7305,6 +7314,110 @@ var knowledgeReferenceRepairCommandSchema = knowledgeReferenceRepairQuerySchema.
7305
7314
  }).strict();
7306
7315
  var knowledgeReferenceRepairReceiptQuerySchema = knowledgeAdoptionReceiptQuerySchema;
7307
7316
 
7317
+ // packages/contracts/src/agent/human-presentation.ts
7318
+ import { z as z103 } from "zod";
7319
+ var reference = z103.string().min(1).max(512);
7320
+ var digest = z103.string().regex(/^[a-f0-9]{64}$/u);
7321
+ var webUrl = z103.string().url().max(4096).refine((value) => {
7322
+ try {
7323
+ const url = new URL(value);
7324
+ return !url.username && !url.password && !url.search && (url.protocol === "https:" || url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname));
7325
+ } catch {
7326
+ return false;
7327
+ }
7328
+ });
7329
+ var packageCode = z103.string().regex(/^PKG-[0-9]{6,}$/u);
7330
+ var humanPresentationCapability = "com.native-marketing/human-presentation";
7331
+ var humanPresentationFeatures = Object.freeze({
7332
+ version: 1,
7333
+ subjects: ["CONTENT_PACKAGE"],
7334
+ interactions: ["CONTENT_PACKAGE_REVIEW"],
7335
+ links: ["AUTHENTICATED", "TEMPORARY_PUBLIC_READ"],
7336
+ publicRead: "SNAPSHOT"
7337
+ });
7338
+ var humanPresentationInputSchema = z103.object({ packageCode }).strict();
7339
+ var common3 = {
7340
+ linkRef: reference,
7341
+ kind: z103.literal("READABLE_CONTENT"),
7342
+ title: z103.string().min(1).max(500),
7343
+ subjectRef: reference,
7344
+ url: webUrl
7345
+ };
7346
+ var humanReadLinkSchema = z103.discriminatedUnion("access", [
7347
+ z103.object({
7348
+ ...common3,
7349
+ access: z103.literal("AUTHENTICATED"),
7350
+ representation: z103.literal("CURRENT_VIEW"),
7351
+ expiresAt: z103.null()
7352
+ }).strict(),
7353
+ z103.object({
7354
+ ...common3,
7355
+ access: z103.literal("TEMPORARY_PUBLIC_READ"),
7356
+ representation: z103.literal("SNAPSHOT"),
7357
+ snapshotRef: reference,
7358
+ contentSha256: digest,
7359
+ createdAt: z103.string().datetime(),
7360
+ expiresAt: z103.string().datetime()
7361
+ }).strict()
7362
+ ]);
7363
+ var humanInteractionSchema = z103.object({
7364
+ interactionRef: reference,
7365
+ kind: z103.literal("CONTENT_PACKAGE_REVIEW"),
7366
+ subjectRef: reference,
7367
+ title: z103.string().min(1).max(500),
7368
+ summary: z103.string().max(2e3),
7369
+ state: z103.enum(["PENDING", "APPROVED", "REJECTED", "RESOLVED"]),
7370
+ sourceState: z103.string().min(1).max(80),
7371
+ actionDigest: digest,
7372
+ expiresAt: z103.null(),
7373
+ reviewUrl: webUrl,
7374
+ canReview: z103.boolean()
7375
+ }).strict();
7376
+ var humanPresentationSchema = z103.object({
7377
+ schemaVersion: z103.literal(1),
7378
+ interactions: z103.array(humanInteractionSchema).max(16),
7379
+ links: z103.array(humanReadLinkSchema).max(16)
7380
+ }).strict();
7381
+ var humanReadableDocumentSchema = z103.object({
7382
+ schemaVersion: z103.literal(1),
7383
+ title: z103.string().min(1).max(500),
7384
+ subjectRef: reference,
7385
+ manifestHash: digest,
7386
+ sections: z103.array(
7387
+ z103.object({ heading: z103.string().min(1).max(500), text: z103.string().max(131072) }).strict()
7388
+ ).min(1).max(128)
7389
+ }).strict();
7390
+ var issueHumanReadLinkInputSchema = z103.object({
7391
+ requestId: z103.string().min(1).max(128),
7392
+ packageCode,
7393
+ expectedManifestHash: digest,
7394
+ access: z103.literal("TEMPORARY_PUBLIC_READ"),
7395
+ targetKeys: z103.array(z103.string().min(1).max(64)).min(1).max(32).refine((keys) => new Set(keys).size === keys.length),
7396
+ ttlSeconds: z103.number().int().min(60).max(86400).default(3600)
7397
+ }).strict();
7398
+ var humanReadLinkLookupSchema = z103.object({ linkRef: z103.string().uuid() }).strict();
7399
+ var humanReadLinkReceiptQuerySchema = z103.object({ requestId: z103.string().min(1).max(128) }).strict();
7400
+ var revokeHumanReadLinkInputSchema = humanReadLinkLookupSchema.extend({ requestId: z103.string().min(1).max(128) }).strict();
7401
+ var humanReadLinkResultSchema = z103.object({
7402
+ linkRef: z103.string().uuid(),
7403
+ issuanceRequestId: z103.string().min(1).max(128),
7404
+ state: z103.enum(["ACTIVE", "EXPIRED", "REVOKED", "UNAVAILABLE"]),
7405
+ packageCode,
7406
+ manifestHash: digest,
7407
+ expiresAt: z103.string().datetime(),
7408
+ human: humanPresentationSchema
7409
+ }).strict();
7410
+ var humanReadLinkReceiptSchema = z103.discriminatedUnion("status", [
7411
+ z103.object({ status: z103.literal("FOUND"), receipt: humanReadLinkResultSchema }).strict(),
7412
+ z103.object({ status: z103.literal("NOT_FOUND") }).strict()
7413
+ ]);
7414
+ var cleanupHumanReadLinksInputSchema = z103.object({ limit: z103.number().int().min(1).max(32).default(16) }).strict();
7415
+ var cleanupHumanReadLinksResultSchema = z103.object({
7416
+ reclaimed: z103.number().int().nonnegative().max(32),
7417
+ limit: z103.number().int().min(1).max(32)
7418
+ }).strict();
7419
+ var humanPresentationResultSchema = z103.object({ human: humanPresentationSchema }).strict();
7420
+
7308
7421
  // packages/contracts/src/agent/capability-receipts.ts
7309
7422
  var rule = (capability, schema2, operation, keys = [], field) => ({ capability, schema: schema2, operation, keys, field });
7310
7423
  var foundation = (operation, field) => rule(
@@ -7531,6 +7644,18 @@ var rules = {
7531
7644
  };
7532
7645
  var object = (value) => value && typeof value === "object" && !Array.isArray(value) ? value : {};
7533
7646
  function capabilityReceiptRead(name, input) {
7647
+ if (name === "cf_issue_human_read_link") {
7648
+ const parsed2 = humanReadLinkReceiptQuerySchema.safeParse({
7649
+ requestId: object(input).requestId
7650
+ });
7651
+ if (!parsed2.success) return void 0;
7652
+ return {
7653
+ capability: "cf_get_human_read_link_receipt",
7654
+ arguments: parsed2.data,
7655
+ requiresDescription: true,
7656
+ requiresCurrentAuthorization: true
7657
+ };
7658
+ }
7534
7659
  const r = name && Object.hasOwn(rules, name) ? rules[name] : void 0;
7535
7660
  if (!r) return void 0;
7536
7661
  const raw = object(input), source = r.field ? object(Object.hasOwn(raw, r.field) ? raw[r.field] : void 0) : raw;
@@ -7553,13 +7678,18 @@ function capabilityReceiptRead(name, input) {
7553
7678
  }
7554
7679
 
7555
7680
  // packages/contracts/src/agent/capability-status.ts
7556
- import { z as z103 } from "zod";
7681
+ import { z as z104 } from "zod";
7557
7682
  var verification = {
7558
7683
  capability: "cf_material_verification_status",
7559
7684
  schema: materialVerificationIdSchema,
7560
7685
  key: "jobId"
7561
7686
  };
7562
7687
  var rules2 = {
7688
+ cf_revoke_human_read_link: {
7689
+ capability: "cf_get_human_read_link",
7690
+ schema: humanReadLinkLookupSchema,
7691
+ key: "linkRef"
7692
+ },
7563
7693
  cf_material_verification_start: { ...verification, from: "requestId" },
7564
7694
  cf_material_verification_advance: verification,
7565
7695
  cf_material_verification_retry: verification,
@@ -7571,7 +7701,7 @@ var rules2 = {
7571
7701
  },
7572
7702
  cf_tenant_material_scan_advance: {
7573
7703
  capability: "cf_tenant_material_scan_status",
7574
- schema: z103.object({}).strict()
7704
+ schema: z104.object({}).strict()
7575
7705
  },
7576
7706
  cf_sync_materials: {
7577
7707
  capability: "cf_reconcile_materials",
@@ -7599,13 +7729,13 @@ function capabilityStatusRead(name, input) {
7599
7729
  }
7600
7730
 
7601
7731
  // packages/contracts/src/client-lifecycle.ts
7602
- import { z as z104 } from "zod";
7732
+ import { z as z105 } from "zod";
7603
7733
 
7604
7734
  // packages/contracts/src/generated/client-release.ts
7605
7735
  var nativeClientRelease = {
7606
7736
  schemaVersion: 1,
7607
7737
  product: "native-marketing",
7608
- version: "0.3.7",
7738
+ version: "0.3.8",
7609
7739
  packages: {
7610
7740
  sdk: "@native-marketing/sdk",
7611
7741
  cli: "@native-marketing/cli"
@@ -7615,41 +7745,41 @@ var nativeClientRelease = {
7615
7745
  apiMajor: 1,
7616
7746
  nodeMajor: 24,
7617
7747
  changes: [
7618
- "Unified SDK, CLI and MCP release discovery and compatibility checks.",
7619
- "Configurable CLI update notifications, pins and compatible automatic updates.",
7620
- "Upgrade verification and explicit continuation without replaying business commands."
7748
+ "Unified typed human interaction cards and authenticated reading links across SDK, CLI and MCP.",
7749
+ "Explicitly authorized expiring public read-only package text snapshots with original request recovery and revocation.",
7750
+ "Bound human presentation responses to the configured Project, original issuance request and source version."
7621
7751
  ]
7622
7752
  };
7623
7753
 
7624
7754
  // packages/contracts/src/client-lifecycle.ts
7625
7755
  var nativeReleaseCapability = "com.native-marketing/client-release";
7626
- var releaseVersionSchema = z104.string().max(128).regex(
7756
+ var releaseVersionSchema = z105.string().max(128).regex(
7627
7757
  /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/
7628
7758
  );
7629
- var clientIdentitySchema = z104.object({
7759
+ var clientIdentitySchema = z105.object({
7630
7760
  version: releaseVersionSchema,
7631
- contractVersion: z104.number().int().positive(),
7632
- apiMajor: z104.number().int().positive()
7761
+ contractVersion: z105.number().int().positive(),
7762
+ apiMajor: z105.number().int().positive()
7633
7763
  });
7634
- var clientReleaseSchema = z104.object({
7635
- schemaVersion: z104.literal(1),
7636
- product: z104.literal("native-marketing"),
7764
+ var clientReleaseSchema = z105.object({
7765
+ schemaVersion: z105.literal(1),
7766
+ product: z105.literal("native-marketing"),
7637
7767
  version: releaseVersionSchema,
7638
- packages: z104.object({
7639
- sdk: z104.literal("@native-marketing/sdk"),
7640
- cli: z104.literal("@native-marketing/cli")
7768
+ packages: z105.object({
7769
+ sdk: z105.literal("@native-marketing/sdk"),
7770
+ cli: z105.literal("@native-marketing/cli")
7641
7771
  }),
7642
- contractVersion: z104.number().int().positive(),
7772
+ contractVersion: z105.number().int().positive(),
7643
7773
  minimumClientVersion: releaseVersionSchema,
7644
- apiMajor: z104.number().int().positive(),
7645
- nodeMajor: z104.number().int().positive(),
7646
- changes: z104.array(z104.string().min(1).max(240)).max(8).default([])
7774
+ apiMajor: z105.number().int().positive(),
7775
+ nodeMajor: z105.number().int().positive(),
7776
+ changes: z105.array(z105.string().min(1).max(240)).max(8).default([])
7647
7777
  });
7648
- var updatePolicySchema = z104.object({
7649
- mode: z104.enum(["off", "notify", "auto"]).default("notify"),
7650
- channel: z104.enum(["latest", "next", "beta"]).default("latest"),
7778
+ var updatePolicySchema = z105.object({
7779
+ mode: z105.enum(["off", "notify", "auto"]).default("notify"),
7780
+ channel: z105.enum(["latest", "next", "beta"]).default("latest"),
7651
7781
  pin: releaseVersionSchema.nullable().default(null),
7652
- intervalHours: z104.number().int().min(1).max(168).default(24)
7782
+ intervalHours: z105.number().int().min(1).max(168).default(24)
7653
7783
  }).strict();
7654
7784
  var defaultUpdatePolicy = updatePolicySchema.parse({});
7655
7785
  function compareReleaseVersions(left, right) {
@@ -7687,30 +7817,30 @@ function assessNativeCompatibility(client, server) {
7687
7817
  }
7688
7818
 
7689
7819
  // packages/contracts/src/client-update-policy.ts
7690
- import { z as z105 } from "zod";
7691
- var registryReleaseSchema = z105.object({
7692
- name: z105.enum(["@native-marketing/sdk", "@native-marketing/cli"]),
7820
+ import { z as z106 } from "zod";
7821
+ var registryReleaseSchema = z106.object({
7822
+ name: z106.enum(["@native-marketing/sdk", "@native-marketing/cli"]),
7693
7823
  version: releaseVersionSchema,
7694
- deprecated: z105.string().optional(),
7695
- nativeMarketing: z105.object({
7696
- contractVersion: z105.number().int().positive(),
7697
- apiMajor: z105.number().int().positive(),
7698
- nodeMajor: z105.number().int().positive(),
7699
- changes: z105.array(z105.string().min(1).max(240)).max(8).optional()
7824
+ deprecated: z106.string().optional(),
7825
+ nativeMarketing: z106.object({
7826
+ contractVersion: z106.number().int().positive(),
7827
+ apiMajor: z106.number().int().positive(),
7828
+ nodeMajor: z106.number().int().positive(),
7829
+ changes: z106.array(z106.string().min(1).max(240)).max(8).optional()
7700
7830
  }).optional(),
7701
- dist: z105.object({
7702
- integrity: z105.string().max(512).regex(/^sha512-[A-Za-z0-9+/]{86}==$/)
7831
+ dist: z106.object({
7832
+ integrity: z106.string().max(512).regex(/^sha512-[A-Za-z0-9+/]{86}==$/)
7703
7833
  })
7704
7834
  });
7705
- var clientUpdateStateSchema = z105.object({
7706
- schemaVersion: z105.literal(1),
7835
+ var clientUpdateStateSchema = z106.object({
7836
+ schemaVersion: z106.literal(1),
7707
7837
  policy: updatePolicySchema,
7708
- lastCheck: z105.object({
7709
- at: z105.number().int().nonnegative(),
7710
- selector: z105.string().max(160),
7838
+ lastCheck: z106.object({
7839
+ at: z106.number().int().nonnegative(),
7840
+ selector: z106.string().max(160),
7711
7841
  target: registryReleaseSchema
7712
7842
  }).strict().optional(),
7713
- lastAttempt: z105.object({ at: z105.number().int().nonnegative(), selector: z105.string().max(160) }).strict().optional()
7843
+ lastAttempt: z106.object({ at: z106.number().int().nonnegative(), selector: z106.string().max(160) }).strict().optional()
7714
7844
  }).strict();
7715
7845
  function planNativeUpdate(input) {
7716
7846
  const target = registryReleaseSchema.parse(input.target);
@@ -7768,6 +7898,48 @@ function planNativeUpdate(input) {
7768
7898
  return compatibleLine && stable ? result2("UPDATE_AVAILABLE", "COMPATIBLE_UPDATE", true) : result2("UPDATE_AVAILABLE", "REVIEW_REQUIRED");
7769
7899
  }
7770
7900
 
7901
+ // packages/contracts/src/agent/human-presentation-validation.ts
7902
+ function validateHumanPresentationResource(human, resource, packageCode2) {
7903
+ try {
7904
+ const base2 = new URL(resource);
7905
+ const project = /^\/mcp\/projects\/(PRJ-[0-9]{6,})$/u.exec(base2.pathname)?.[1];
7906
+ if (!project || base2.username || base2.password || base2.search || base2.hash) return false;
7907
+ const review = (raw) => {
7908
+ const url = new URL(raw);
7909
+ return url.origin === base2.origin && !url.username && !url.password && !url.search && !url.hash && (packageCode2 ? url.pathname === `/projects/${project}/packages/${packageCode2}` : new RegExp(`^/projects/${project}/packages/PKG-[0-9]{6,}$`, "u").test(url.pathname));
7910
+ };
7911
+ return human.interactions.every((item) => review(item.reviewUrl)) && human.links.every((link) => {
7912
+ if (link.access === "AUTHENTICATED") return review(link.url);
7913
+ const url = new URL(link.url);
7914
+ return url.origin === base2.origin && !url.username && !url.password && !url.search && url.pathname === `/api/v1/human-read/${link.linkRef}` && /^#[A-Za-z0-9_-]{43}$/u.test(url.hash) && link.snapshotRef === `sha256:${link.contentSha256}` && Date.parse(link.expiresAt) > Date.parse(link.createdAt);
7915
+ });
7916
+ } catch {
7917
+ return false;
7918
+ }
7919
+ }
7920
+ function validateHumanPresentationResponse(parsed, resource, input, operation) {
7921
+ const value = parsed.status === "FOUND" ? parsed.receipt : parsed;
7922
+ if (!("human" in value)) return true;
7923
+ const human = value.human;
7924
+ if (!validateHumanPresentationResource(
7925
+ human,
7926
+ resource,
7927
+ typeof value.packageCode === "string" ? value.packageCode : input.packageCode
7928
+ ))
7929
+ return false;
7930
+ if (input.packageCode && value.packageCode && value.packageCode !== input.packageCode)
7931
+ return false;
7932
+ if (input.expectedManifestHash && value.manifestHash !== input.expectedManifestHash) return false;
7933
+ if (input.linkRef && value.linkRef !== input.linkRef) return false;
7934
+ if (input.requestId && operation !== "cf_revoke_human_read_link" && value.issuanceRequestId !== input.requestId)
7935
+ return false;
7936
+ const links = human.links;
7937
+ if (value.state === "ACTIVE" && (links.length !== 1 || links[0]?.access !== "TEMPORARY_PUBLIC_READ" || links[0].linkRef !== value.linkRef || links[0].expiresAt !== value.expiresAt))
7938
+ return false;
7939
+ if (value.state && value.state !== "ACTIVE" && links.length) return false;
7940
+ return true;
7941
+ }
7942
+
7771
7943
  // packages/cli-client/src/errors.ts
7772
7944
  var CliError = class extends Error {
7773
7945
  constructor(code2, message, outcome = "NOT_SENT", details) {
@@ -8243,6 +8415,7 @@ async function refreshNativeServerVersion(client, timeout) {
8243
8415
  }
8244
8416
 
8245
8417
  // packages/cli-client/src/transport.ts
8418
+ var resources = /* @__PURE__ */ new WeakMap();
8246
8419
  async function withClient(profile, timeout, operation, options = {}) {
8247
8420
  const resource = resourceUrl(profile.resource);
8248
8421
  const accessToken = tokenText(profile.accessToken);
@@ -8271,6 +8444,7 @@ async function withClient(profile, timeout, operation, options = {}) {
8271
8444
  reconnectionDelayGrowFactor: 1
8272
8445
  }
8273
8446
  });
8447
+ resources.set(client, resource.href);
8274
8448
  try {
8275
8449
  try {
8276
8450
  await client.connect(transport, { timeout });
@@ -8286,6 +8460,7 @@ async function withClient(profile, timeout, operation, options = {}) {
8286
8460
  options.onVersion?.(version);
8287
8461
  return await operation(client);
8288
8462
  } finally {
8463
+ resources.delete(client);
8289
8464
  await client.close().catch(() => void 0);
8290
8465
  }
8291
8466
  }
@@ -8293,13 +8468,14 @@ async function callTool(client, tool5, input, timeout, readOnly, errorToolName =
8293
8468
  if (["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(tool5.name) && errorToolName === tool5.name && typeof input.name === "string" && /^cf_[a-z0-9_]{1,100}$/.test(input.name))
8294
8469
  errorToolName = input.name;
8295
8470
  const original = ["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(tool5.name) && input.name === errorToolName ? input.arguments : input;
8296
- const unknown = (code2, message) => {
8471
+ const unknown = (code2, message, human) => {
8297
8472
  const receipt = capabilityReceiptRead(errorToolName, original);
8298
8473
  const status = capabilityStatusRead(errorToolName, original);
8299
8474
  return new CliError(code2, message, "UNKNOWN", {
8300
8475
  recovery: capabilityRecovery(code2, "UNKNOWN", errorToolName),
8301
8476
  ...receipt ? { receipt } : {},
8302
- ...status ? { status } : {}
8477
+ ...status ? { status } : {},
8478
+ ...human ? { human } : {}
8303
8479
  });
8304
8480
  };
8305
8481
  let result2;
@@ -8321,16 +8497,21 @@ async function callTool(client, tool5, input, timeout, readOnly, errorToolName =
8321
8497
  );
8322
8498
  }
8323
8499
  if ("resultType" in result2 && result2.resultType === "input_required") {
8500
+ const raw = result2._meta?.[humanPresentationCapability];
8501
+ const parsed = raw && Buffer.byteLength(JSON.stringify(raw)) <= 128 * 1024 ? humanPresentationSchema.safeParse(raw) : null;
8502
+ const resource = resources.get(client);
8503
+ const human = parsed?.success && resource && validateHumanPresentationResource(parsed.data, resource) ? parsed.data : void 0;
8324
8504
  if (!readOnly)
8325
8505
  throw unknown(
8326
8506
  "INPUT_REQUIRED",
8327
- "Resolve additional input explicitly after confirming the original outcome. No automatic fulfilment or retry was made."
8507
+ "Resolve additional input explicitly after confirming the original outcome. No automatic fulfilment or retry was made.",
8508
+ human
8328
8509
  );
8329
8510
  throw new CliError(
8330
8511
  "INPUT_REQUIRED",
8331
8512
  "Resolve additional input explicitly; no automatic fulfilment or retry was made.",
8332
8513
  "REJECTED",
8333
- { recovery: "RESOLVE_INPUT_EXPLICITLY" }
8514
+ { recovery: "RESOLVE_INPUT_EXPLICITLY", ...human ? { human } : {} }
8334
8515
  );
8335
8516
  }
8336
8517
  if (result2.isError) {
@@ -9094,6 +9275,185 @@ async function uploadNativeMaterial(connection, file, timeout = 3e4) {
9094
9275
  return materialUploadCommandResultSchema.parse(await uploadFile(connection, file, timeout));
9095
9276
  }
9096
9277
 
9278
+ // packages/cli-client/src/human-presentation.ts
9279
+ var humanCommands = {
9280
+ "human show": {
9281
+ name: "cf_get_human_presentation",
9282
+ input: humanPresentationInputSchema,
9283
+ output: humanPresentationResultSchema,
9284
+ readOnly: true
9285
+ },
9286
+ "human issue-link": {
9287
+ name: "cf_issue_human_read_link",
9288
+ input: issueHumanReadLinkInputSchema,
9289
+ output: humanReadLinkResultSchema,
9290
+ readOnly: false
9291
+ },
9292
+ "human link": {
9293
+ name: "cf_get_human_read_link",
9294
+ input: humanReadLinkLookupSchema,
9295
+ output: humanReadLinkResultSchema,
9296
+ readOnly: true
9297
+ },
9298
+ "human receipt": {
9299
+ name: "cf_get_human_read_link_receipt",
9300
+ input: humanReadLinkReceiptQuerySchema,
9301
+ output: humanReadLinkReceiptSchema,
9302
+ readOnly: true
9303
+ },
9304
+ "human revoke-link": {
9305
+ name: "cf_revoke_human_read_link",
9306
+ input: revokeHumanReadLinkInputSchema,
9307
+ output: humanReadLinkResultSchema,
9308
+ readOnly: false
9309
+ },
9310
+ "human cleanup-links": {
9311
+ name: "cf_cleanup_human_read_links",
9312
+ input: cleanupHumanReadLinksInputSchema,
9313
+ output: cleanupHumanReadLinksResultSchema,
9314
+ readOnly: false
9315
+ }
9316
+ };
9317
+ function invalid6() {
9318
+ return new CliError(
9319
+ "INVALID_HUMAN_PRESENTATION",
9320
+ "The human presentation cannot be verified against this exact product resource."
9321
+ );
9322
+ }
9323
+ async function invoke2(client, resource, raw, name, inputSchema, outputSchema, readOnly, timeout) {
9324
+ const request = inputSchema.safeParse(raw);
9325
+ if (!request.success)
9326
+ throw new CliError("INVALID_HUMAN_INPUT", "Use the exact human presentation input schema.");
9327
+ const capability = client.getServerCapabilities()?.experimental?.[humanPresentationCapability];
9328
+ if (capability?.version !== 1)
9329
+ throw new CliError(
9330
+ "HUMAN_PRESENTATION_UNSUPPORTED",
9331
+ "This service has not declared human presentation version 1."
9332
+ );
9333
+ const tool5 = {
9334
+ name,
9335
+ inputSchema: {
9336
+ type: "object",
9337
+ ...inputSchema["~standard"].jsonSchema.input({ target: "draft-2020-12" })
9338
+ },
9339
+ annotations: { readOnlyHint: readOnly }
9340
+ };
9341
+ const result2 = await callTool(client, tool5, request.data, timeout, readOnly);
9342
+ try {
9343
+ const parsed = outputSchema.parse(result2);
9344
+ if (Buffer.byteLength(JSON.stringify(parsed)) > 128 * 1024) throw invalid6();
9345
+ if (!validateHumanPresentationResponse(
9346
+ parsed,
9347
+ resource,
9348
+ request.data,
9349
+ name
9350
+ ))
9351
+ throw invalid6();
9352
+ return parsed;
9353
+ } catch {
9354
+ const outcome = readOnly ? "REJECTED" : "UNKNOWN";
9355
+ const receipt = capabilityReceiptRead(name, request.data);
9356
+ const status = capabilityStatusRead(name, request.data);
9357
+ throw new CliError(
9358
+ "INVALID_HUMAN_PRESENTATION",
9359
+ "Cannot verify this exact response. Query the original request before another write.",
9360
+ outcome,
9361
+ {
9362
+ recovery: capabilityRecovery("INVALID_HUMAN_PRESENTATION", outcome, name),
9363
+ ...!readOnly && receipt ? { receipt } : {},
9364
+ ...!readOnly && status ? { status } : {},
9365
+ ...request.data.requestId ? { requestId: request.data.requestId } : {},
9366
+ ...request.data.linkRef ? { linkRef: request.data.linkRef } : {}
9367
+ }
9368
+ );
9369
+ }
9370
+ }
9371
+ function getNativeHumanPresentation(client, resource, input, timeout = 3e4) {
9372
+ return invoke2(
9373
+ client,
9374
+ resource,
9375
+ input,
9376
+ "cf_get_human_presentation",
9377
+ humanPresentationInputSchema,
9378
+ humanPresentationResultSchema,
9379
+ true,
9380
+ timeout
9381
+ );
9382
+ }
9383
+ function issueNativeHumanReadLink(client, resource, input, timeout = 3e4) {
9384
+ return invoke2(
9385
+ client,
9386
+ resource,
9387
+ input,
9388
+ "cf_issue_human_read_link",
9389
+ issueHumanReadLinkInputSchema,
9390
+ humanReadLinkResultSchema,
9391
+ false,
9392
+ timeout
9393
+ );
9394
+ }
9395
+ function getNativeHumanReadLink(client, resource, input, timeout = 3e4) {
9396
+ return invoke2(
9397
+ client,
9398
+ resource,
9399
+ input,
9400
+ "cf_get_human_read_link",
9401
+ humanReadLinkLookupSchema,
9402
+ humanReadLinkResultSchema,
9403
+ true,
9404
+ timeout
9405
+ );
9406
+ }
9407
+ function getNativeHumanReadLinkReceipt(client, resource, input, timeout = 3e4) {
9408
+ return invoke2(
9409
+ client,
9410
+ resource,
9411
+ input,
9412
+ "cf_get_human_read_link_receipt",
9413
+ humanReadLinkReceiptQuerySchema,
9414
+ humanReadLinkReceiptSchema,
9415
+ true,
9416
+ timeout
9417
+ );
9418
+ }
9419
+ function revokeNativeHumanReadLink(client, resource, input, timeout = 3e4) {
9420
+ return invoke2(
9421
+ client,
9422
+ resource,
9423
+ input,
9424
+ "cf_revoke_human_read_link",
9425
+ revokeHumanReadLinkInputSchema,
9426
+ humanReadLinkResultSchema,
9427
+ false,
9428
+ timeout
9429
+ );
9430
+ }
9431
+ function cleanupNativeHumanReadLinks(client, resource, input = {}, timeout = 3e4) {
9432
+ return invoke2(
9433
+ client,
9434
+ resource,
9435
+ input,
9436
+ "cf_cleanup_human_read_links",
9437
+ cleanupHumanReadLinksInputSchema,
9438
+ cleanupHumanReadLinksResultSchema,
9439
+ false,
9440
+ timeout
9441
+ );
9442
+ }
9443
+ async function runHumanCommand(client, resource, name, input, timeout) {
9444
+ const spec = humanCommands[name];
9445
+ return invoke2(
9446
+ client,
9447
+ resource,
9448
+ input,
9449
+ spec.name,
9450
+ spec.input,
9451
+ spec.output,
9452
+ spec.readOnly,
9453
+ timeout
9454
+ );
9455
+ }
9456
+
9097
9457
  // packages/cli-client/src/business-search.ts
9098
9458
  var tool4 = (name, schema2) => ({
9099
9459
  name,
@@ -9108,17 +9468,17 @@ var document = tool4("cf_read_business_document", businessDocumentInputSchema);
9108
9468
  async function searchNativeBusiness(client, raw = {}, timeout = 3e4) {
9109
9469
  checkTimeout3(timeout);
9110
9470
  const input = businessSearchQuerySchema.safeParse(raw);
9111
- if (!input.success) throw invalid6("INVALID_BUSINESS_SEARCH_QUERY", "NOT_SENT");
9471
+ if (!input.success) throw invalid7("INVALID_BUSINESS_SEARCH_QUERY", "NOT_SENT");
9112
9472
  const value = await callTool(client, search, input.data, timeout, true);
9113
9473
  const parsed = businessSearchPageSchema.safeParse(value);
9114
9474
  if (!parsed.success || Buffer.byteLength(JSON.stringify(value)) > 16 * 1024)
9115
- throw invalid6("INVALID_BUSINESS_SEARCH_REPLY");
9475
+ throw invalid7("INVALID_BUSINESS_SEARCH_REPLY");
9116
9476
  return parsed.data;
9117
9477
  }
9118
9478
  async function readNativeBusinessPage(client, raw, timeout = 3e4) {
9119
9479
  checkTimeout3(timeout);
9120
9480
  const input = businessContentPageReadSchema.safeParse(raw);
9121
- if (!input.success) throw invalid6("INVALID_BUSINESS_CONTENT_QUERY", "NOT_SENT");
9481
+ if (!input.success) throw invalid7("INVALID_BUSINESS_CONTENT_QUERY", "NOT_SENT");
9122
9482
  const { offset, expectedDocumentHash, ...sourceInput } = input.data;
9123
9483
  const args = businessDocumentInputSchema.parse({
9124
9484
  sourceTool: "cf_read_business_content",
@@ -9129,18 +9489,18 @@ async function readNativeBusinessPage(client, raw, timeout = 3e4) {
9129
9489
  const value = await callTool(client, document, args, timeout, true);
9130
9490
  const parsed = businessContentPageSchema.safeParse(value);
9131
9491
  if (!parsed.success || Buffer.byteLength(JSON.stringify(value)) > 6e3)
9132
- throw invalid6("INVALID_BUSINESS_CONTENT_REPLY");
9492
+ throw invalid7("INVALID_BUSINESS_CONTENT_REPLY");
9133
9493
  const p = parsed.data;
9134
9494
  if (p.sourceInput.ref !== sourceInput.ref || p.sourceInput.expectedVersion !== sourceInput.expectedVersion || p.offset !== offset || expectedDocumentHash && p.documentHash !== expectedDocumentHash || (p.hasMore ? p.nextOffset !== offset + [...p.text].length : p.nextOffset !== null) || p.hasMore !== offset + [...p.text].length < p.totalCharacters)
9135
- throw invalid6("INVALID_BUSINESS_CONTENT_REPLY");
9495
+ throw invalid7("INVALID_BUSINESS_CONTENT_REPLY");
9136
9496
  return p;
9137
9497
  }
9138
- function invalid6(code2, outcome = "REJECTED") {
9498
+ function invalid7(code2, outcome = "REJECTED") {
9139
9499
  return new CliError(code2, "Use the exact bounded search or content-page contract.", outcome);
9140
9500
  }
9141
9501
  function checkTimeout3(value) {
9142
9502
  if (!Number.isInteger(value) || value < 100 || value > 12e4)
9143
- throw invalid6("INVALID_TIMEOUT", "NOT_SENT");
9503
+ throw invalid7("INVALID_TIMEOUT", "NOT_SENT");
9144
9504
  }
9145
9505
 
9146
9506
  // packages/cli-client/src/client.ts
@@ -9160,6 +9520,12 @@ async function withNativeAgentClient(connection, action, options = {}) {
9160
9520
  return action(
9161
9521
  new Proxy(
9162
9522
  {
9523
+ getHumanPresentation: (input) => getNativeHumanPresentation(client, connection.resource, input, timeout),
9524
+ issueHumanReadLink: (input) => issueNativeHumanReadLink(client, connection.resource, input, timeout),
9525
+ getHumanReadLink: (input) => getNativeHumanReadLink(client, connection.resource, input, timeout),
9526
+ getHumanReadLinkReceipt: (input) => getNativeHumanReadLinkReceipt(client, connection.resource, input, timeout),
9527
+ revokeHumanReadLink: (input) => revokeNativeHumanReadLink(client, connection.resource, input, timeout),
9528
+ cleanupHumanReadLinks: (input = {}) => cleanupNativeHumanReadLinks(client, connection.resource, input, timeout),
9163
9529
  getVersion: () => structuredClone(version),
9164
9530
  refreshVersion: async () => {
9165
9531
  definitions.clear();
@@ -9695,6 +10061,7 @@ var fullHelp = {
9695
10061
  "tools inspect <cf_tool>",
9696
10062
  "tools call <cf_tool> [--input-file <file>|--stdin]",
9697
10063
  ...Object.keys(commandTools).map((name) => `${name} [--input-file <file>|--stdin]`),
10064
+ ...Object.keys(humanCommands).map((name) => `${name} [--input-file <file>|--stdin]`),
9698
10065
  "task read <kind> --job JOB-000001",
9699
10066
  "result submit <kind> (--input-file <file>|--stdin)"
9700
10067
  ],
@@ -9754,6 +10121,13 @@ function groupHelp(group) {
9754
10121
  function resolveBaseCommand(parsed) {
9755
10122
  const { words, options } = parsed;
9756
10123
  const name = words.join(" ");
10124
+ if (Object.hasOwn(humanCommands, name)) {
10125
+ if (Object.keys(options).some(
10126
+ (key2) => !["input-file", "stdin", "profile", "json", "timeout-ms"].includes(key2)
10127
+ ))
10128
+ throw new CliError("INVALID_OPTION", "Unsupported human presentation option.");
10129
+ return { mode: "human" };
10130
+ }
9757
10131
  if (name === "media file" || name === "packages file") {
9758
10132
  if (Object.keys(options).some(
9759
10133
  (k) => !["output-file", "profile", "input-file", "stdin", "timeout-ms", "json"].includes(k)
@@ -9907,6 +10281,14 @@ function resolveCommand(parsed) {
9907
10281
  async function businessCommand(client, parsed, input, resource) {
9908
10282
  const resolved = resolveCommand(parsed);
9909
10283
  const { timeout, options } = parsed;
10284
+ if (resolved.mode === "human")
10285
+ return runHumanCommand(
10286
+ client,
10287
+ resource,
10288
+ parsed.words.join(" "),
10289
+ input,
10290
+ timeout
10291
+ );
9910
10292
  if (resolved.mode === "document")
9911
10293
  return readNativeDocumentPage(
9912
10294
  client,
@@ -9974,6 +10356,8 @@ async function businessCommand(client, parsed, input, resource) {
9974
10356
  // packages/cli-client/src/cli/command-input.ts
9975
10357
  function validateCommandInput(parsed, input) {
9976
10358
  const mode = resolveCommand(parsed).mode;
10359
+ if (mode === "human" && !humanCommands[parsed.words.join(" ")].input.safeParse(input).success)
10360
+ throw new CliError("INVALID_HUMAN_INPUT", "Use the exact human presentation JSON input.");
9977
10361
  if (mode === "upload" && parsed.words.join(" ") === "media upload" && !projectMediaWebUploadSchema.omit({ requestId: true }).safeParse(input).success)
9978
10362
  throw new CliError("INVALID_UPLOAD_INPUT", "Supply explicit real-media provenance JSON.");
9979
10363
  const schemas = {
@@ -10564,19 +10948,55 @@ async function runNetworkCli(args, env = process.env, io = {}, executable = "cf"
10564
10948
  function success(command5, data) {
10565
10949
  return { exitCode: 0, envelope: { ok: true, command: command5, data, error: null } };
10566
10950
  }
10951
+
10952
+ // packages/cli-client/src/cli/output.ts
10953
+ function formatNetworkCliResult(result2, json = false) {
10954
+ const { envelope } = result2;
10955
+ if (!json && envelope.ok && envelope.command.startsWith("human ")) {
10956
+ const data = envelope.data;
10957
+ const value = data.status === "FOUND" ? data.receipt : data;
10958
+ const parsed = humanPresentationSchema.safeParse(value.human);
10959
+ if (parsed.success) {
10960
+ const lines = [envelope.command, ...value.state ? [`\u72B6\u6001\uFF1A${value.state}`] : []];
10961
+ for (const card of parsed.data.interactions)
10962
+ lines.push(
10963
+ `${card.title} \xB7 ${card.state}`,
10964
+ card.summary,
10965
+ `\u6B63\u5F0F\u5BA1\u6838\u5165\u53E3\uFF08\u9700\u8981\u767B\u5F55\uFF09\uFF1A${card.reviewUrl}`
10966
+ );
10967
+ for (const link of parsed.data.links)
10968
+ lines.push(
10969
+ `${link.title} \xB7 \u9605\u8BFB`,
10970
+ link.access === "TEMPORARY_PUBLIC_READ" ? `\u4E34\u65F6\u516C\u5F00\u53EA\u8BFB\u5FEB\u7167\uFF1B\u6301\u94FE\u63A5\u8005\u65E0\u9700\u767B\u5F55\u3002\u5230\u671F\uFF1A${link.expiresAt}` : "\u5F53\u524D\u5185\u5BB9\uFF1B\u9700\u8981\u767B\u5F55\u3002",
10971
+ link.url
10972
+ );
10973
+ if (value.issuanceRequestId) lines.push(`\u539F\u7B7E\u53D1\u8BF7\u6C42\uFF1A${value.issuanceRequestId}`);
10974
+ if (!parsed.data.links.length && !parsed.data.interactions.length)
10975
+ lines.push("\u5F53\u524D\u65E0\u53EF\u7528\u9605\u8BFB\u94FE\u63A5\u6216\u4EA4\u4E92\u3002");
10976
+ return lines.join("\n") + "\n";
10977
+ }
10978
+ }
10979
+ return JSON.stringify(envelope, null, json ? void 0 : 2) + "\n";
10980
+ }
10567
10981
  export {
10568
10982
  CliError as NativeAgentClientError,
10569
10983
  assessNativeCompatibility,
10570
10984
  callNativeCapability,
10571
10985
  callNativeTool,
10572
10986
  checkNativeUpdates,
10987
+ cleanupNativeHumanReadLinks,
10573
10988
  defaultUpdatePolicy,
10574
10989
  describeNativeCapability,
10575
10990
  findAgentCapabilities,
10576
10991
  findNativeCapabilities,
10992
+ formatNetworkCliResult,
10577
10993
  getNativeBusinessSummary,
10578
10994
  getNativeClientVersion,
10995
+ getNativeHumanPresentation,
10996
+ getNativeHumanReadLink,
10997
+ getNativeHumanReadLinkReceipt,
10579
10998
  inspectNativeTool,
10999
+ issueNativeHumanReadLink,
10580
11000
  listNativeToolsPage,
10581
11001
  planNativeUpdate,
10582
11002
  projectMediaFileQuerySchema,
@@ -10587,6 +11007,7 @@ export {
10587
11007
  readNativeDocumentPage,
10588
11008
  readNativePackageFile,
10589
11009
  readNativeProjectMediaFile,
11010
+ revokeNativeHumanReadLink,
10590
11011
  runNetworkCli,
10591
11012
  searchNativeBusiness,
10592
11013
  uploadNativeMaterial,