@native-marketing/sdk 0.1.1 → 0.3.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.
package/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
+ // packages/cli-client/src/capability-definition.ts
2
+ import { createHash } from "node:crypto";
3
+
1
4
  // packages/contracts/src/project.ts
2
5
  import { z as z3 } from "zod";
3
6
 
@@ -5116,7 +5119,8 @@ var capabilityQuerySchema = z69.object({
5116
5119
  query: z69.string().trim().max(240).default(""),
5117
5120
  group: capabilityGroupSchema.optional(),
5118
5121
  limit: z69.number().int().min(1).max(20).default(8),
5119
- cursor: z69.string().min(1).max(128).optional()
5122
+ cursor: z69.string().min(1).max(128).optional(),
5123
+ profile: z69.literal("AGENT_V3").optional()
5120
5124
  }).strict();
5121
5125
  var capabilityDescribeSchema = z69.object({
5122
5126
  name: z69.string().regex(/^cf_[a-z0-9_]{1,100}$/u)
@@ -5152,9 +5156,49 @@ var capabilityDefinitionSchema = z69.object({
5152
5156
  }).strict(),
5153
5157
  authority: capabilityPageSchema.shape.authority
5154
5158
  }).strict();
5159
+ var agentCapabilityPageSchema = capabilityPageSchema.extend({
5160
+ schemaVersion: z69.literal(3),
5161
+ matching: z69.literal("ACTION_OBJECT_BILINGUAL"),
5162
+ result: z69.enum(["MATCH", "NO_MATCH", "BROWSE"]),
5163
+ scope: z69.literal("CURRENT_AUTHORIZED_CATALOGUE"),
5164
+ items: z69.array(
5165
+ capabilitySummarySchema.extend({
5166
+ schemaSha256: z69.string().regex(/^[a-f0-9]{64}$/u).optional(),
5167
+ definition: capabilityDefinitionSchema.optional(),
5168
+ supportsValidateOnly: z69.boolean().optional()
5169
+ }).strict()
5170
+ ).max(20)
5171
+ }).strict();
5172
+
5173
+ // packages/contracts/src/agent/input-repair.ts
5174
+ import { z as z70 } from "zod";
5175
+ var scalar = z70.union([z70.string().max(160), z70.number().finite(), z70.boolean(), z70.null()]);
5176
+ var capabilityInputRepairSchema = z70.object({
5177
+ phase: z70.literal("INPUT"),
5178
+ handlerEntered: z70.literal(false),
5179
+ issues: z70.array(
5180
+ z70.object({
5181
+ field: z70.string().max(240),
5182
+ message: z70.literal("Value does not match the declared schema."),
5183
+ expectedType: z70.enum(["string", "number", "integer", "boolean", "object", "array", "null"]).optional(),
5184
+ allowedRange: z70.object({ min: z70.number().finite().optional(), max: z70.number().finite().optional() }).strict().optional(),
5185
+ minLength: z70.number().int().nonnegative().optional(),
5186
+ maxLength: z70.number().int().nonnegative().optional(),
5187
+ enum: z70.array(scalar).max(16).optional()
5188
+ }).strict()
5189
+ ).max(6),
5190
+ argumentPatch: z70.record(z70.string().regex(/^[A-Za-z_][A-Za-z0-9_]{0,79}$/), scalar).refine((patch) => Object.keys(patch).length <= 6),
5191
+ schema: z70.object({
5192
+ tool: z70.literal("cf_describe_capability"),
5193
+ arguments: z70.object({ name: z70.string().regex(/^cf_[a-z0-9_]{1,100}$/) }).strict()
5194
+ }).strict()
5195
+ }).strict();
5155
5196
 
5156
5197
  // packages/contracts/src/agent/capability-outcome.ts
5157
5198
  var capabilityRejectedErrorCodes = [
5199
+ "MCP_TEST_RECORD_CONFLICT",
5200
+ "MCP_TEST_RECORD_NOT_FOUND",
5201
+ "MCP_TEST_RECORD_CLEANED",
5158
5202
  "BUSINESS_CHECKPOINT_CONFLICT",
5159
5203
  "FOUNDATION_CHECKPOINT_CONFLICT",
5160
5204
  "ADMINISTRATION_VERSION_CONFLICT",
@@ -5247,8 +5291,8 @@ function changeCapabilityRecovery(code2, outcome, name) {
5247
5291
  }
5248
5292
 
5249
5293
  // packages/contracts/src/agent/business-search.ts
5250
- import { z as z70 } from "zod";
5251
- var businessSearchKindSchema = z70.enum([
5294
+ import { z as z71 } from "zod";
5295
+ var businessSearchKindSchema = z71.enum([
5252
5296
  "positioning",
5253
5297
  "research",
5254
5298
  "introduction",
@@ -5262,59 +5306,59 @@ var businessSearchKindSchema = z70.enum([
5262
5306
  "review",
5263
5307
  "source"
5264
5308
  ]);
5265
- var businessSearchQuerySchema = z70.object({
5266
- query: z70.string().trim().max(240).default(""),
5267
- kinds: z70.array(businessSearchKindSchema).min(1).max(12).optional(),
5268
- includeHistory: z70.boolean().default(false),
5269
- limit: z70.number().int().min(1).max(20).default(8),
5270
- cursor: z70.string().min(1).max(512).optional()
5271
- }).strict();
5272
- var businessContentRefSchema = z70.string().regex(
5309
+ var businessSearchQuerySchema = z71.object({
5310
+ query: z71.string().trim().max(240).default(""),
5311
+ kinds: z71.array(businessSearchKindSchema).min(1).max(12).optional(),
5312
+ includeHistory: z71.boolean().default(false),
5313
+ limit: z71.number().int().min(1).max(20).default(8),
5314
+ cursor: z71.string().min(1).max(512).optional()
5315
+ }).strict();
5316
+ var businessContentRefSchema = z71.string().regex(
5273
5317
  /^cf:\/\/business\/(positioning|research|introduction|personal-input|strategy|opportunity|action|package|feedback|improvement|review|source)\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/u
5274
5318
  );
5275
- var businessContentReadSchema = z70.object({
5319
+ var businessContentReadSchema = z71.object({
5276
5320
  ref: businessContentRefSchema,
5277
- expectedVersion: z70.string().regex(/^[a-f0-9]{64}$/u)
5321
+ expectedVersion: z71.string().regex(/^[a-f0-9]{64}$/u)
5278
5322
  }).strict();
5279
- var businessSearchHitSchema = z70.object({
5323
+ var businessSearchHitSchema = z71.object({
5280
5324
  ref: businessContentRefSchema,
5281
5325
  kind: businessSearchKindSchema,
5282
- title: z70.string().max(180),
5283
- status: z70.string().max(80),
5284
- excerpt: z70.string().max(300),
5285
- version: z70.string().regex(/^[a-f0-9]{64}$/u),
5286
- navigation: z70.object({
5287
- href: z70.string().max(500).regex(/^\/(?!\/)[a-zA-Z0-9_/?=&%.:-]+$/u),
5288
- relation: z70.enum(["EXACT", "CONTEXT"])
5326
+ title: z71.string().max(180),
5327
+ status: z71.string().max(80),
5328
+ excerpt: z71.string().max(300),
5329
+ version: z71.string().regex(/^[a-f0-9]{64}$/u),
5330
+ navigation: z71.object({
5331
+ href: z71.string().max(500).regex(/^\/(?!\/)[a-zA-Z0-9_/?=&%.:-]+$/u),
5332
+ relation: z71.enum(["EXACT", "CONTEXT"])
5289
5333
  }).strict().optional(),
5290
- read: z70.object({
5291
- tool: z70.literal("cf_read_business_document"),
5292
- input: z70.object({
5293
- sourceTool: z70.literal("cf_read_business_content"),
5334
+ read: z71.object({
5335
+ tool: z71.literal("cf_read_business_document"),
5336
+ input: z71.object({
5337
+ sourceTool: z71.literal("cf_read_business_content"),
5294
5338
  sourceInput: businessContentReadSchema
5295
5339
  }).strict()
5296
5340
  }).strict()
5297
5341
  }).strict();
5298
- var businessSearchPageSchema = z70.object({
5299
- schemaVersion: z70.literal(1),
5300
- matching: z70.literal("SAVED_TEXT_LEXICAL"),
5301
- consistency: z70.literal("LIVE"),
5302
- context: z70.object({
5303
- kind: z70.enum(["PERSONAL", "ORGANIZATION", "PROJECT"]),
5304
- businessCode: z70.string().max(100)
5342
+ var businessSearchPageSchema = z71.object({
5343
+ schemaVersion: z71.literal(1),
5344
+ matching: z71.literal("SAVED_TEXT_LEXICAL"),
5345
+ consistency: z71.literal("LIVE"),
5346
+ context: z71.object({
5347
+ kind: z71.enum(["PERSONAL", "ORGANIZATION", "PROJECT"]),
5348
+ businessCode: z71.string().max(100)
5305
5349
  }).strict(),
5306
- coverage: z70.array(
5307
- z70.object({
5350
+ coverage: z71.array(
5351
+ z71.object({
5308
5352
  kind: businessSearchKindSchema,
5309
- state: z70.enum(["SEARCHED", "METADATA_ONLY", "UNAVAILABLE", "NOT_APPLICABLE"])
5353
+ state: z71.enum(["SEARCHED", "METADATA_ONLY", "UNAVAILABLE", "NOT_APPLICABLE"])
5310
5354
  }).strict()
5311
5355
  ).max(12),
5312
- items: z70.array(businessSearchHitSchema).max(20),
5313
- page: z70.object({ hasMore: z70.boolean(), nextCursor: z70.string().nullable() }).strict()
5356
+ items: z71.array(businessSearchHitSchema).max(20),
5357
+ page: z71.object({ hasMore: z71.boolean(), nextCursor: z71.string().nullable() }).strict()
5314
5358
  }).strict();
5315
5359
  var businessContentPageReadSchema = businessContentReadSchema.extend({
5316
- offset: z70.number().int().nonnegative().default(0),
5317
- expectedDocumentHash: z70.string().regex(/^[a-f0-9]{64}$/u).optional()
5360
+ offset: z71.number().int().nonnegative().default(0),
5361
+ expectedDocumentHash: z71.string().regex(/^[a-f0-9]{64}$/u).optional()
5318
5362
  }).superRefine((v, ctx) => {
5319
5363
  if (v.offset > 0 && !v.expectedDocumentHash)
5320
5364
  ctx.addIssue({
@@ -5323,26 +5367,26 @@ var businessContentPageReadSchema = businessContentReadSchema.extend({
5323
5367
  message: "Continuation requires the original document hash."
5324
5368
  });
5325
5369
  });
5326
- var businessContentPageSchema = z70.object({
5327
- schemaVersion: z70.literal(1),
5328
- documentKind: z70.literal("BUSINESS_READ"),
5329
- sourceTool: z70.literal("cf_read_business_content"),
5370
+ var businessContentPageSchema = z71.object({
5371
+ schemaVersion: z71.literal(1),
5372
+ documentKind: z71.literal("BUSINESS_READ"),
5373
+ sourceTool: z71.literal("cf_read_business_content"),
5330
5374
  sourceInput: businessContentReadSchema,
5331
- mode: z70.literal("JSON_TEXT_PAGE"),
5332
- documentHash: z70.string().regex(/^[a-f0-9]{64}$/u),
5333
- contentSha256: z70.string().regex(/^[a-f0-9]{64}$/u),
5334
- path: z70.literal(""),
5335
- offset: z70.number().int().nonnegative(),
5336
- totalCharacters: z70.number().int().positive(),
5337
- text: z70.string(),
5338
- hasMore: z70.boolean(),
5339
- nextOffset: z70.number().int().positive().nullable(),
5340
- complete: z70.boolean()
5375
+ mode: z71.literal("JSON_TEXT_PAGE"),
5376
+ documentHash: z71.string().regex(/^[a-f0-9]{64}$/u),
5377
+ contentSha256: z71.string().regex(/^[a-f0-9]{64}$/u),
5378
+ path: z71.literal(""),
5379
+ offset: z71.number().int().nonnegative(),
5380
+ totalCharacters: z71.number().int().positive(),
5381
+ text: z71.string(),
5382
+ hasMore: z71.boolean(),
5383
+ nextOffset: z71.number().int().positive().nullable(),
5384
+ complete: z71.boolean()
5341
5385
  }).passthrough();
5342
5386
 
5343
5387
  // packages/contracts/src/agent/business-document.ts
5344
- import { z as z71 } from "zod";
5345
- var businessDocumentToolSchema = z71.enum([
5388
+ import { z as z72 } from "zod";
5389
+ var businessDocumentToolSchema = z72.enum([
5346
5390
  "cf_list_team_members",
5347
5391
  "cf_get_team_member",
5348
5392
  "cf_get_project_access",
@@ -5424,15 +5468,15 @@ var businessDocumentToolSchema = z71.enum([
5424
5468
  "cf_read_source",
5425
5469
  "cf_read_knowledge"
5426
5470
  ]);
5427
- var businessDocumentInputSchema = z71.object({
5471
+ var businessDocumentInputSchema = z72.object({
5428
5472
  sourceTool: businessDocumentToolSchema,
5429
- sourceInput: z71.record(z71.string(), z71.unknown()).default({}).refine((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 4096),
5473
+ sourceInput: z72.record(z72.string(), z72.unknown()).default({}).refine((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 4096),
5430
5474
  // RAW保持原CLI整包合同;SOURCE_JSON显式解析已验证来源的JSON语义。
5431
- view: z71.enum(["RAW", "SOURCE_JSON"]).default("RAW"),
5432
- path: z71.string().max(2048).default(""),
5433
- format: z71.enum(["JSON_TEXT", "INDEX"]).default("JSON_TEXT"),
5434
- offset: z71.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).default(0),
5435
- expectedDocumentHash: z71.string().regex(/^[a-f0-9]{64}$/u).optional()
5475
+ view: z72.enum(["RAW", "SOURCE_JSON"]).default("RAW"),
5476
+ path: z72.string().max(2048).default(""),
5477
+ format: z72.enum(["JSON_TEXT", "INDEX"]).default("JSON_TEXT"),
5478
+ offset: z72.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).default(0),
5479
+ expectedDocumentHash: z72.string().regex(/^[a-f0-9]{64}$/u).optional()
5436
5480
  }).strict().superRefine((input, ctx) => {
5437
5481
  if ((input.offset > 0 || input.path !== "") && !input.expectedDocumentHash)
5438
5482
  ctx.addIssue({
@@ -5443,44 +5487,44 @@ var businessDocumentInputSchema = z71.object({
5443
5487
  });
5444
5488
 
5445
5489
  // packages/contracts/src/agent/compact-surface.ts
5446
- import { z as z72 } from "zod";
5490
+ import { z as z73 } from "zod";
5447
5491
  var nativeAgentSurfaceCapability = "io.native-marketing/agent-native";
5448
- var hash = z72.string().regex(/^[a-f0-9]{64}$/u);
5492
+ var hash = z73.string().regex(/^[a-f0-9]{64}$/u);
5449
5493
  var capabilitySchemaReadSchema = capabilityDescribeSchema.extend({
5450
5494
  expectedSchemaSha256: hash,
5451
- offset: z72.number().int().nonnegative().default(0)
5495
+ offset: z73.number().int().nonnegative().default(0)
5452
5496
  }).strict();
5453
- var capabilitySchemaPageSchema = z72.object({
5454
- schemaVersion: z72.literal(1),
5497
+ var capabilitySchemaPageSchema = z73.object({
5498
+ schemaVersion: z73.literal(1),
5455
5499
  name: capabilityDescribeSchema.shape.name,
5456
5500
  schemaSha256: hash,
5457
5501
  contentSha256: hash,
5458
- mode: z72.literal("JSON_TEXT_PAGE"),
5459
- offset: z72.number().int().nonnegative(),
5460
- totalCharacters: z72.number().int().positive(),
5461
- text: z72.string(),
5462
- hasMore: z72.boolean(),
5463
- nextOffset: z72.number().int().positive().nullable()
5464
- }).strict();
5465
- var capabilityDescriptorSchema = z72.union([
5502
+ mode: z73.literal("JSON_TEXT_PAGE"),
5503
+ offset: z73.number().int().nonnegative(),
5504
+ totalCharacters: z73.number().int().positive(),
5505
+ text: z73.string(),
5506
+ hasMore: z73.boolean(),
5507
+ nextOffset: z73.number().int().positive().nullable()
5508
+ }).strict();
5509
+ var capabilityDescriptorSchema = z73.union([
5466
5510
  capabilityDefinitionSchema,
5467
- z72.object({
5468
- schemaVersion: z72.literal(2),
5511
+ z73.object({
5512
+ schemaVersion: z73.literal(2),
5469
5513
  name: capabilityDescribeSchema.shape.name,
5470
5514
  schemaSha256: hash,
5471
- delivery: z72.literal("PAGED_SCHEMA"),
5472
- byteLength: z72.number().int().positive(),
5473
- read: z72.object({ tool: z72.literal("cf_read_capability_schema"), input: capabilitySchemaReadSchema }).strict(),
5515
+ delivery: z73.literal("PAGED_SCHEMA"),
5516
+ byteLength: z73.number().int().positive(),
5517
+ read: z73.object({ tool: z73.literal("cf_read_capability_schema"), input: capabilitySchemaReadSchema }).strict(),
5474
5518
  authority: capabilityDefinitionSchema.shape.authority
5475
5519
  }).strict()
5476
5520
  ]);
5477
- var capabilityCallSchema = z72.object({
5521
+ var capabilityCallSchema = z73.object({
5478
5522
  name: capabilityDescribeSchema.shape.name,
5479
5523
  expectedSchemaSha256: hash,
5480
- arguments: z72.record(z72.string(), z72.unknown()).refine((v) => new TextEncoder().encode(JSON.stringify(v)).byteLength <= 1024 * 1024),
5481
- delivery: z72.literal("ORIGINAL")
5524
+ arguments: z73.record(z73.string(), z73.unknown()).refine((v) => new TextEncoder().encode(JSON.stringify(v)).byteLength <= 1024 * 1024),
5525
+ delivery: z73.literal("ORIGINAL")
5482
5526
  }).strict();
5483
- var agentSummarySourceSchema = z72.enum([
5527
+ var agentSummarySourceSchema = z73.enum([
5484
5528
  "cf_get_channel_feedback",
5485
5529
  "cf_get_channel_feedback_fact",
5486
5530
  "cf_get_team_member",
@@ -5514,10 +5558,10 @@ var agentSummarySourceSchema = z72.enum([
5514
5558
  "cf_get_review_context",
5515
5559
  "cf_get_improvement_proposal"
5516
5560
  ]);
5517
- var agentSummaryInputSchema = z72.object({
5561
+ var agentSummaryInputSchema = z73.object({
5518
5562
  sourceTool: agentSummarySourceSchema,
5519
- sourceInput: z72.record(z72.string(), z72.unknown()).default({}).refine((v) => new TextEncoder().encode(JSON.stringify(v)).byteLength <= 4096),
5520
- actionOffset: z72.number().int().nonnegative().max(1e3).default(0),
5563
+ sourceInput: z73.record(z73.string(), z73.unknown()).default({}).refine((v) => new TextEncoder().encode(JSON.stringify(v)).byteLength <= 4096),
5564
+ actionOffset: z73.number().int().nonnegative().max(1e3).default(0),
5521
5565
  expectedDocumentHash: hash.optional(),
5522
5566
  expectedActionsHash: hash.optional()
5523
5567
  }).strict().superRefine((v, ctx) => {
@@ -5528,110 +5572,191 @@ var agentSummaryInputSchema = z72.object({
5528
5572
  message: "Continuation requires the original document hash."
5529
5573
  });
5530
5574
  });
5531
- var agentNextActionSchema = z72.object({
5532
- actionId: z72.string().min(1).max(160),
5533
- title: z72.string().max(120),
5575
+ var agentNextActionSchema = z73.object({
5576
+ actionId: z73.string().min(1).max(160),
5577
+ title: z73.string().max(120),
5534
5578
  capability: capabilityDescribeSchema.shape.name.nullable(),
5535
- mode: z72.enum(["READ", "WRITE", "HUMAN"]),
5536
- state: z72.enum(["AVAILABLE", "READ_REQUIRED", "HUMAN_DECISION", "BLOCKED"]),
5537
- requiresHumanDecision: z72.boolean(),
5538
- input: z72.record(z72.string(), z72.unknown()),
5539
- requiredInputs: z72.array(z72.string().max(120)).max(8),
5540
- conditions: z72.array(z72.string().max(120)).max(12),
5541
- baseline: z72.record(z72.string(), z72.unknown()),
5542
- href: z72.string().max(1200).nullable()
5543
- }).strict();
5544
- var agentSummarySchema = z72.object({
5545
- schemaVersion: z72.literal(1),
5546
- view: z72.literal("SUMMARY"),
5547
- contentComplete: z72.literal(false),
5579
+ mode: z73.enum(["READ", "WRITE", "HUMAN"]),
5580
+ state: z73.enum(["AVAILABLE", "READ_REQUIRED", "HUMAN_DECISION", "BLOCKED"]),
5581
+ requiresHumanDecision: z73.boolean(),
5582
+ input: z73.record(z73.string(), z73.unknown()),
5583
+ requiredInputs: z73.array(z73.string().max(120)).max(8),
5584
+ conditions: z73.array(z73.string().max(120)).max(12),
5585
+ baseline: z73.record(z73.string(), z73.unknown()),
5586
+ href: z73.string().max(1200).nullable()
5587
+ }).strict();
5588
+ var agentSummarySchema = z73.object({
5589
+ schemaVersion: z73.literal(1),
5590
+ view: z73.literal("SUMMARY"),
5591
+ contentComplete: z73.literal(false),
5548
5592
  sourceTool: agentSummarySourceSchema,
5549
5593
  documentHash: hash,
5550
5594
  actionsHash: hash,
5551
- summary: z72.record(z72.string(), z72.unknown()),
5552
- read: z72.object({
5553
- tool: z72.literal("cf_read_business_document"),
5595
+ summary: z73.record(z73.string(), z73.unknown()),
5596
+ read: z73.object({
5597
+ tool: z73.literal("cf_read_business_document"),
5554
5598
  input: businessDocumentInputSchema
5555
5599
  }).strict(),
5556
- nextActions: z72.array(agentNextActionSchema).max(6),
5557
- actionPage: z72.object({
5558
- offset: z72.number().int().nonnegative(),
5559
- hasMore: z72.boolean(),
5560
- nextOffset: z72.number().int().nonnegative().nullable()
5600
+ nextActions: z73.array(agentNextActionSchema).max(6),
5601
+ actionPage: z73.object({
5602
+ offset: z73.number().int().nonnegative(),
5603
+ hasMore: z73.boolean(),
5604
+ nextOffset: z73.number().int().nonnegative().nullable()
5561
5605
  }).strict(),
5562
- authority: z72.object({
5563
- actionsAreAuthority: z72.literal(false),
5564
- callsReauthorize: z72.literal(true),
5565
- runtimeChoosesContinuation: z72.literal(true)
5606
+ authority: z73.object({
5607
+ actionsAreAuthority: z73.literal(false),
5608
+ callsReauthorize: z73.literal(true),
5609
+ runtimeChoosesContinuation: z73.literal(true)
5566
5610
  }).strict()
5567
5611
  }).strict();
5568
5612
 
5569
5613
  // packages/contracts/src/agent/document-page.ts
5570
- import { z as z73 } from "zod";
5571
- var hash2 = z73.string().regex(/^[a-f0-9]{64}$/u);
5614
+ import { z as z74 } from "zod";
5615
+ var hash2 = z74.string().regex(/^[a-f0-9]{64}$/u);
5572
5616
  var base = {
5573
- schemaVersion: z73.literal(1),
5574
- documentKind: z73.literal("BUSINESS_READ"),
5617
+ schemaVersion: z74.literal(1),
5618
+ documentKind: z74.literal("BUSINESS_READ"),
5575
5619
  sourceTool: businessDocumentInputSchema.shape.sourceTool,
5576
- sourceInput: z73.record(z73.string(), z73.unknown()),
5620
+ sourceInput: z74.record(z74.string(), z74.unknown()),
5577
5621
  documentHash: hash2,
5578
5622
  contentSha256: hash2,
5579
5623
  nodeHash: hash2,
5580
- path: z73.string().max(2048),
5581
- view: z73.object({ version: z73.literal(1), kind: z73.enum(["RAW", "SOURCE_JSON"]) }).strict()
5624
+ path: z74.string().max(2048),
5625
+ view: z74.object({ version: z74.literal(1), kind: z74.enum(["RAW", "SOURCE_JSON"]) }).strict()
5582
5626
  };
5583
- var businessDocumentPageSchema = z73.discriminatedUnion("mode", [
5584
- z73.object({
5627
+ var businessDocumentPageSchema = z74.discriminatedUnion("mode", [
5628
+ z74.object({
5585
5629
  ...base,
5586
- mode: z73.literal("JSON_TEXT_PAGE"),
5587
- complete: z73.boolean(),
5588
- text: z73.string(),
5589
- offset: z73.number().int().nonnegative(),
5590
- totalCharacters: z73.number().int().positive(),
5591
- hasMore: z73.boolean(),
5592
- nextOffset: z73.number().int().positive().nullable()
5630
+ mode: z74.literal("JSON_TEXT_PAGE"),
5631
+ complete: z74.boolean(),
5632
+ text: z74.string(),
5633
+ offset: z74.number().int().nonnegative(),
5634
+ totalCharacters: z74.number().int().positive(),
5635
+ hasMore: z74.boolean(),
5636
+ nextOffset: z74.number().int().positive().nullable()
5593
5637
  }).passthrough(),
5594
- z73.object({
5638
+ z74.object({
5595
5639
  ...base,
5596
- mode: z73.literal("INDEX"),
5597
- complete: z73.literal(false),
5598
- offset: z73.number().int().nonnegative(),
5599
- totalItems: z73.number().int().positive(),
5600
- items: z73.array(z73.object({ path: z73.string(), nodeHash: hash2, complete: z73.boolean() }).passthrough()).max(20),
5601
- hasMore: z73.boolean(),
5602
- nextOffset: z73.number().int().positive().nullable()
5640
+ mode: z74.literal("INDEX"),
5641
+ complete: z74.literal(false),
5642
+ offset: z74.number().int().nonnegative(),
5643
+ totalItems: z74.number().int().positive(),
5644
+ items: z74.array(z74.object({ path: z74.string(), nodeHash: hash2, complete: z74.boolean() }).passthrough()).max(20),
5645
+ hasMore: z74.boolean(),
5646
+ nextOffset: z74.number().int().positive().nullable()
5603
5647
  }).passthrough(),
5604
- z73.object({ ...base, mode: z73.literal("FULL"), complete: z73.literal(true), data: z73.unknown() }).passthrough()
5648
+ z74.object({ ...base, mode: z74.literal("FULL"), complete: z74.literal(true), data: z74.unknown() }).passthrough()
5605
5649
  ]);
5606
5650
 
5651
+ // packages/contracts/src/agent/test-records.ts
5652
+ import { z as z75 } from "zod";
5653
+ var testRecordSaveSchema = z75.object({
5654
+ recordId: uuidSchema,
5655
+ expectedVersion: z75.number().int().nonnegative(),
5656
+ label: z75.string().trim().min(1).max(120),
5657
+ payload: z75.string().max(2e3),
5658
+ requestId: uuidSchema,
5659
+ validateOnly: z75.boolean().default(false)
5660
+ }).strict();
5661
+ var testRecordReadSchema = z75.object({ recordId: uuidSchema }).strict();
5662
+ var testRecordCleanupSchema = z75.object({
5663
+ records: z75.array(
5664
+ z75.object({ recordId: uuidSchema, expectedVersion: z75.number().int().positive() }).strict()
5665
+ ).min(1).max(20),
5666
+ requestId: uuidSchema,
5667
+ validateOnly: z75.boolean().default(false)
5668
+ }).strict().refine((q) => new Set(q.records.map((item) => item.recordId)).size === q.records.length);
5669
+ var testRecordReceiptSchema = z75.object({ operation: z75.enum(["SAVE", "CLEANUP"]), requestId: uuidSchema }).strict();
5670
+
5671
+ // packages/contracts/src/publication/collaboration.ts
5672
+ import { z as z76 } from "zod";
5673
+ var hash3 = z76.string().regex(/^[a-f0-9]{64}$/);
5674
+ var deliveryPackageReadSchema = z76.object({ packageCode: businessCodeSchema }).strict();
5675
+ var deliveryPackageQuerySchema = z76.object({
5676
+ limit: z76.coerce.number().int().min(1).max(50).default(12),
5677
+ cursor: z76.string().max(2048).optional(),
5678
+ q: z76.string().max(160).optional(),
5679
+ status: contentPackageStatusSchema.optional()
5680
+ }).strict();
5681
+ var deliveryTargetReadSchema = deliveryPackageReadSchema.extend({ targetKey: packageTargetKeySchema }).strict();
5682
+ var deliveryPublicationReadSchema = z76.object({ publicationCode: businessCodeSchema }).strict();
5683
+ var deliveryPackageDecisionSchema = deliveryPackageReadSchema.extend({
5684
+ requestId: z76.uuid(),
5685
+ expectedReviewSha256: hash3,
5686
+ decision: packageReviewDecisionSchema,
5687
+ note: z76.string().max(4096).nullable().default(null),
5688
+ humanDecision: humanDecisionDeclarationSchema.optional()
5689
+ }).strict();
5690
+ var deliveryPublicationRecordSchema = deliveryTargetReadSchema.extend({
5691
+ requestId: z76.uuid(),
5692
+ expectedContextSha256: hash3,
5693
+ destinationCode: businessCodeSchema,
5694
+ externalRef: externalHttpUrlSchema,
5695
+ publishedAt: z76.string().datetime({ offset: true }).nullable().default(null),
5696
+ humanDecision: humanDecisionDeclarationSchema.optional()
5697
+ }).strict();
5698
+ var deliveryAdmissionSchema = deliveryTargetReadSchema.extend({ destinationCode: businessCodeSchema, programCode: businessCodeSchema }).strict();
5699
+ var deliveryReceiptSchema = z76.object({ operation: z76.enum(["REVIEW", "RECORD"]), requestId: z76.uuid() }).strict();
5700
+ var deliveryCommandSchema = z76.discriminatedUnion("operation", [
5701
+ deliveryPackageDecisionSchema.extend({ operation: z76.literal("REVIEW") }),
5702
+ deliveryPublicationRecordSchema.extend({ operation: z76.literal("RECORD") })
5703
+ ]);
5704
+ var packageFileKeySchema = z76.string().regex(/^(archive|manifest|(?:asset|media|render):[a-z0-9][a-z0-9._-]{0,63}:(?:0|[1-9][0-9]?))$/).max(100);
5705
+ var packageDownloadSchema = deliveryPackageReadSchema.extend({ fileKey: packageFileKeySchema.default("archive"), expectedManifestHash: hash3 }).strict();
5706
+ var packageFilesQuerySchema = deliveryPackageReadSchema.extend({
5707
+ targetKey: packageTargetKeySchema.optional(),
5708
+ limit: z76.coerce.number().int().min(1).max(50).default(12),
5709
+ cursor: z76.string().max(2048).optional()
5710
+ }).strict();
5711
+ var packageFileDescriptorSchema = z76.object({
5712
+ packageCode: businessCodeSchema,
5713
+ manifestHash: hash3,
5714
+ fileKey: packageFileKeySchema,
5715
+ filename: z76.string().max(512),
5716
+ mimeType: z76.string().max(160),
5717
+ byteSize: z76.number().int().nonnegative().nullable(),
5718
+ sha256: hash3.nullable(),
5719
+ integrity: z76.enum(["SHA256", "FROZEN_PACKAGE_ARCHIVE"]),
5720
+ downloadPath: z76.string().max(2048),
5721
+ authentication: z76.literal("CF_OAUTH"),
5722
+ method: z76.literal("GET"),
5723
+ head: z76.literal(true),
5724
+ range: z76.boolean()
5725
+ }).strict();
5726
+ var packageFileReadOptionsSchema = packageDownloadSchema.extend({
5727
+ head: z76.boolean().default(false),
5728
+ range: z76.string().regex(/^bytes=\d*-\d*$/).max(160).optional(),
5729
+ maxBytes: z76.number().int().positive().max(16 * 1024 * 1024 * 1024).default(2 * 1024 * 1024 * 1024)
5730
+ }).strict();
5731
+
5607
5732
  // packages/contracts/src/foundation/collaboration.ts
5608
- import { z as z74 } from "zod";
5609
- var ref = z74.string().trim().min(1).max(1e3);
5610
- var question = z74.object({ id: ref.optional(), question: ref, impact: ref }).strict();
5611
- var foundationResearchAnswerSchema = z74.object({
5733
+ import { z as z77 } from "zod";
5734
+ var ref = z77.string().trim().min(1).max(1e3);
5735
+ var question = z77.object({ id: ref.optional(), question: ref, impact: ref }).strict();
5736
+ var foundationResearchAnswerSchema = z77.object({
5612
5737
  questionId: ref,
5613
5738
  question: ref,
5614
5739
  impact: ref,
5615
- text: z74.string().trim().min(1).max(4e3),
5616
- actorUserId: z74.string().min(1),
5617
- requestId: z74.string().min(1).max(160)
5618
- }).strict();
5619
- var foundationResearchContentSchema = z74.object({
5620
- goalFingerprint: z74.string().regex(/^[a-f0-9]{64}$/).optional(),
5621
- basisFingerprint: z74.string().regex(/^[a-f0-9]{64}$/).optional(),
5622
- title: z74.string().trim().min(1).max(200),
5623
- summary: z74.string().trim().max(4e3),
5624
- body: z74.string().trim().max(64e3),
5625
- status: z74.enum(["REQUESTED", "IN_PROGRESS", "WAITING_INPUT", "READY"]),
5626
- sourceRefs: z74.array(ref).max(100),
5627
- questions: z74.array(question).max(30),
5628
- answers: z74.array(foundationResearchAnswerSchema).max(100).optional()
5629
- }).strict();
5630
- var foundationMaterialReadingSchema = z74.object({
5740
+ text: z77.string().trim().min(1).max(4e3),
5741
+ actorUserId: z77.string().min(1),
5742
+ requestId: z77.string().min(1).max(160)
5743
+ }).strict();
5744
+ var foundationResearchContentSchema = z77.object({
5745
+ goalFingerprint: z77.string().regex(/^[a-f0-9]{64}$/).optional(),
5746
+ basisFingerprint: z77.string().regex(/^[a-f0-9]{64}$/).optional(),
5747
+ title: z77.string().trim().min(1).max(200),
5748
+ summary: z77.string().trim().max(4e3),
5749
+ body: z77.string().trim().max(64e3),
5750
+ status: z77.enum(["REQUESTED", "IN_PROGRESS", "WAITING_INPUT", "READY"]),
5751
+ sourceRefs: z77.array(ref).max(100),
5752
+ questions: z77.array(question).max(30),
5753
+ answers: z77.array(foundationResearchAnswerSchema).max(100).optional()
5754
+ }).strict();
5755
+ var foundationMaterialReadingSchema = z77.object({
5631
5756
  sourceRef: ref,
5632
- state: z74.enum(["CONSUMED", "UNAVAILABLE"]),
5633
- contentHash: z74.string().regex(/^(sha256:)?[a-f0-9]{64}$/).nullable(),
5634
- note: z74.string().trim().max(2e3)
5757
+ state: z77.enum(["CONSUMED", "UNAVAILABLE"]),
5758
+ contentHash: z77.string().regex(/^(sha256:)?[a-f0-9]{64}$/).nullable(),
5759
+ note: z77.string().trim().max(2e3)
5635
5760
  }).strict().superRefine((value, context) => {
5636
5761
  if (value.state === "CONSUMED" && !value.contentHash)
5637
5762
  context.addIssue({
@@ -5641,177 +5766,177 @@ var foundationMaterialReadingSchema = z74.object({
5641
5766
  });
5642
5767
  });
5643
5768
  var foundationHumanDecisionSchema = humanDecisionDeclarationSchema;
5644
- var foundationRecordSchema = z74.object({
5645
- id: z74.string().uuid(),
5646
- kind: z74.enum(["RESEARCH", "MATERIAL_READING", "DECISION"]),
5769
+ var foundationRecordSchema = z77.object({
5770
+ id: z77.string().uuid(),
5771
+ kind: z77.enum(["RESEARCH", "MATERIAL_READING", "DECISION"]),
5647
5772
  scope: foundationScopeSchema,
5648
- revision: z74.number().int().positive(),
5649
- content: z74.record(z74.string(), z74.unknown()),
5650
- contentHash: z74.string(),
5651
- actorUserId: z74.string(),
5652
- createdAt: z74.string().datetime()
5653
- }).strict();
5654
- var foundationResearchSaveSchema = z74.object({
5655
- id: z74.string().uuid(),
5656
- expectedRevision: z74.number().int().nonnegative(),
5657
- requestId: z74.string().min(1).max(160),
5658
- expectedGoalFingerprint: z74.string().regex(/^[a-f0-9]{64}$/),
5659
- expectedBasisFingerprint: z74.string().regex(/^[a-f0-9]{64}$/),
5773
+ revision: z77.number().int().positive(),
5774
+ content: z77.record(z77.string(), z77.unknown()),
5775
+ contentHash: z77.string(),
5776
+ actorUserId: z77.string(),
5777
+ createdAt: z77.string().datetime()
5778
+ }).strict();
5779
+ var foundationResearchSaveSchema = z77.object({
5780
+ id: z77.string().uuid(),
5781
+ expectedRevision: z77.number().int().nonnegative(),
5782
+ requestId: z77.string().min(1).max(160),
5783
+ expectedGoalFingerprint: z77.string().regex(/^[a-f0-9]{64}$/),
5784
+ expectedBasisFingerprint: z77.string().regex(/^[a-f0-9]{64}$/),
5660
5785
  content: foundationResearchContentSchema.omit({ answers: true })
5661
5786
  }).strict();
5662
5787
  var foundationMaterialReadingSaveSchema = foundationResearchSaveSchema.omit({ content: true, expectedBasisFingerprint: true, expectedGoalFingerprint: true }).extend({ content: foundationMaterialReadingSchema }).strict();
5663
- var foundationChangeSchema = z74.object({
5664
- cursor: z74.string(),
5665
- kind: z74.string(),
5788
+ var foundationChangeSchema = z77.object({
5789
+ cursor: z77.string(),
5790
+ kind: z77.string(),
5666
5791
  resourceRef: ref,
5667
- revision: z74.number().int().nonnegative(),
5668
- occurredAt: z74.string().datetime()
5669
- }).strict();
5670
- var foundationChangesQuerySchema = z74.object({
5671
- after: z74.string().max(1e3).optional(),
5672
- limit: z74.number().int().min(1).max(50).default(20)
5673
- }).strict();
5674
- var foundationChangesPageSchema = z74.object({
5675
- items: z74.array(foundationChangeSchema),
5676
- checkpoint: z74.string(),
5677
- initialReadRequired: z74.boolean(),
5678
- nextCursor: z74.string(),
5679
- hasMore: z74.boolean()
5680
- }).strict();
5681
- var foundationChangesAckSchema = z74.object({
5682
- expectedCheckpoint: z74.string().max(1e3),
5683
- through: z74.string().max(1e3)
5684
- }).strict();
5685
- var foundationResearchReplySchema = z74.object({
5686
- id: z74.string().uuid(),
5687
- expectedRevision: z74.number().int().positive(),
5792
+ revision: z77.number().int().nonnegative(),
5793
+ occurredAt: z77.string().datetime()
5794
+ }).strict();
5795
+ var foundationChangesQuerySchema = z77.object({
5796
+ after: z77.string().max(1e3).optional(),
5797
+ limit: z77.number().int().min(1).max(50).default(20)
5798
+ }).strict();
5799
+ var foundationChangesPageSchema = z77.object({
5800
+ items: z77.array(foundationChangeSchema),
5801
+ checkpoint: z77.string(),
5802
+ initialReadRequired: z77.boolean(),
5803
+ nextCursor: z77.string(),
5804
+ hasMore: z77.boolean()
5805
+ }).strict();
5806
+ var foundationChangesAckSchema = z77.object({
5807
+ expectedCheckpoint: z77.string().max(1e3),
5808
+ through: z77.string().max(1e3)
5809
+ }).strict();
5810
+ var foundationResearchReplySchema = z77.object({
5811
+ id: z77.string().uuid(),
5812
+ expectedRevision: z77.number().int().positive(),
5688
5813
  questionId: ref,
5689
- text: z74.string().trim().min(1).max(4e3),
5690
- requestId: z74.string().min(1).max(160)
5814
+ text: z77.string().trim().min(1).max(4e3),
5815
+ requestId: z77.string().min(1).max(160)
5691
5816
  }).strict();
5692
- var foundationDecisionReceiptSchema = z74.discriminatedUnion("state", [
5693
- z74.object({ state: z74.literal("FOUND"), decision: foundationRecordSchema }).strict(),
5694
- z74.object({ state: z74.literal("NOT_FOUND"), decision: z74.null() }).strict()
5817
+ var foundationDecisionReceiptSchema = z77.discriminatedUnion("state", [
5818
+ z77.object({ state: z77.literal("FOUND"), decision: foundationRecordSchema }).strict(),
5819
+ z77.object({ state: z77.literal("NOT_FOUND"), decision: z77.null() }).strict()
5695
5820
  ]);
5696
5821
 
5697
5822
  // packages/contracts/src/material-verification.ts
5698
- import { z as z75 } from "zod";
5699
- var hash3 = z75.string().regex(/^sha256:[a-f0-9]{64}$/);
5700
- var materialVerificationStartSchema = z75.object({
5701
- requestId: z75.uuid(),
5702
- fullReadLimitBytes: z75.number().int().min(1).max(256 * 1024 * 1024).default(32 * 1024 * 1024)
5703
- }).strict();
5704
- var materialVerificationIdSchema = z75.object({ jobId: z75.uuid() }).strict();
5705
- var materialVerificationReceiptSchema = z75.object({
5706
- original: z75.object({
5707
- state: z75.enum(["NOT_CHECKED", "VERIFIED_FULL", "UPSTREAM_VERIFIED", "FAILED"]),
5708
- transportHash: hash3.nullable(),
5709
- byteLength: z75.number().int().nonnegative().nullable(),
5710
- reasonCode: z75.string().nullable()
5823
+ import { z as z78 } from "zod";
5824
+ var hash4 = z78.string().regex(/^sha256:[a-f0-9]{64}$/);
5825
+ var materialVerificationStartSchema = z78.object({
5826
+ requestId: z78.uuid(),
5827
+ fullReadLimitBytes: z78.number().int().min(1).max(256 * 1024 * 1024).default(32 * 1024 * 1024)
5828
+ }).strict();
5829
+ var materialVerificationIdSchema = z78.object({ jobId: z78.uuid() }).strict();
5830
+ var materialVerificationReceiptSchema = z78.object({
5831
+ original: z78.object({
5832
+ state: z78.enum(["NOT_CHECKED", "VERIFIED_FULL", "UPSTREAM_VERIFIED", "FAILED"]),
5833
+ transportHash: hash4.nullable(),
5834
+ byteLength: z78.number().int().nonnegative().nullable(),
5835
+ reasonCode: z78.string().nullable()
5711
5836
  }),
5712
- projection: z75.object({
5713
- state: z75.enum(["NOT_CHECKED", "VERIFIED", "NOT_APPLICABLE", "UNAVAILABLE"]),
5714
- documentRef: z75.string().nullable(),
5715
- documentHash: hash3.nullable(),
5716
- reasonCode: z75.string().nullable()
5837
+ projection: z78.object({
5838
+ state: z78.enum(["NOT_CHECKED", "VERIFIED", "NOT_APPLICABLE", "UNAVAILABLE"]),
5839
+ documentRef: z78.string().nullable(),
5840
+ documentHash: hash4.nullable(),
5841
+ reasonCode: z78.string().nullable()
5717
5842
  }),
5718
- media: z75.object({
5719
- state: z75.enum(["NOT_CHECKED", "PARTIAL", "COMPLETE", "NOT_APPLICABLE", "UNAVAILABLE"]),
5720
- documentRef: z75.string().nullable(),
5721
- documentHash: hash3.nullable(),
5722
- afterOrdinal: z75.number().int().nonnegative().nullable(),
5723
- mirroredVerified: z75.number().int().nonnegative(),
5724
- remoteOnly: z75.number().int().nonnegative(),
5725
- unavailable: z75.number().int().nonnegative(),
5726
- reasonCode: z75.string().nullable()
5843
+ media: z78.object({
5844
+ state: z78.enum(["NOT_CHECKED", "PARTIAL", "COMPLETE", "NOT_APPLICABLE", "UNAVAILABLE"]),
5845
+ documentRef: z78.string().nullable(),
5846
+ documentHash: hash4.nullable(),
5847
+ afterOrdinal: z78.number().int().nonnegative().nullable(),
5848
+ mirroredVerified: z78.number().int().nonnegative(),
5849
+ remoteOnly: z78.number().int().nonnegative(),
5850
+ unavailable: z78.number().int().nonnegative(),
5851
+ reasonCode: z78.string().nullable()
5727
5852
  }),
5728
- checkedAt: z75.string().datetime(),
5729
- errorCode: z75.string().nullable(),
5730
- humanReading: z75.literal("NOT_PROVEN"),
5731
- agentReading: z75.literal("NOT_PROVEN")
5732
- }).strict();
5733
- var materialVerificationJobSchema = z75.object({
5734
- id: z75.uuid(),
5735
- tenantId: z75.uuid(),
5736
- kvTenantId: z75.string(),
5737
- projectKey: z75.string(),
5738
- connectorRevision: z75.string().nullable(),
5739
- generation: z75.number().int().positive(),
5740
- inventoryStatus: z75.enum(["IDLE", "RUNNING", "FAILED", "COMPLETE"]),
5741
- acknowledgedSeq: z75.number().int().nonnegative(),
5742
- pendingSeq: z75.number().int().nonnegative().nullable(),
5743
- fullReadLimitBytes: z75.number().int().positive(),
5744
- state: z75.enum(["READY", "RUNNING", "COMPLETE", "CANCELLED", "STALE"]),
5745
- total: z75.number().int().nonnegative(),
5746
- completed: z75.number().int().nonnegative(),
5747
- failed: z75.number().int().nonnegative(),
5748
- pending: z75.number().int().nonnegative(),
5749
- createdAt: z75.string().datetime(),
5750
- updatedAt: z75.string().datetime()
5751
- }).strict();
5752
- var materialVerificationItemSchema = z75.object({
5753
- sourceId: z75.uuid(),
5754
- artifactRef: z75.string(),
5755
- identityHash: hash3,
5756
- resourceType: z75.string(),
5757
- state: z75.enum(["PENDING", "COMPLETE", "FAILED"]),
5853
+ checkedAt: z78.string().datetime(),
5854
+ errorCode: z78.string().nullable(),
5855
+ humanReading: z78.literal("NOT_PROVEN"),
5856
+ agentReading: z78.literal("NOT_PROVEN")
5857
+ }).strict();
5858
+ var materialVerificationJobSchema = z78.object({
5859
+ id: z78.uuid(),
5860
+ tenantId: z78.uuid(),
5861
+ kvTenantId: z78.string(),
5862
+ projectKey: z78.string(),
5863
+ connectorRevision: z78.string().nullable(),
5864
+ generation: z78.number().int().positive(),
5865
+ inventoryStatus: z78.enum(["IDLE", "RUNNING", "FAILED", "COMPLETE"]),
5866
+ acknowledgedSeq: z78.number().int().nonnegative(),
5867
+ pendingSeq: z78.number().int().nonnegative().nullable(),
5868
+ fullReadLimitBytes: z78.number().int().positive(),
5869
+ state: z78.enum(["READY", "RUNNING", "COMPLETE", "CANCELLED", "STALE"]),
5870
+ total: z78.number().int().nonnegative(),
5871
+ completed: z78.number().int().nonnegative(),
5872
+ failed: z78.number().int().nonnegative(),
5873
+ pending: z78.number().int().nonnegative(),
5874
+ createdAt: z78.string().datetime(),
5875
+ updatedAt: z78.string().datetime()
5876
+ }).strict();
5877
+ var materialVerificationItemSchema = z78.object({
5878
+ sourceId: z78.uuid(),
5879
+ artifactRef: z78.string(),
5880
+ identityHash: hash4,
5881
+ resourceType: z78.string(),
5882
+ state: z78.enum(["PENDING", "COMPLETE", "FAILED"]),
5758
5883
  receipt: materialVerificationReceiptSchema.nullable()
5759
5884
  }).strict();
5760
- var materialVerificationPageSchema = z75.object({
5885
+ var materialVerificationPageSchema = z78.object({
5761
5886
  job: materialVerificationJobSchema,
5762
- items: z75.array(materialVerificationItemSchema).max(100),
5763
- nextAfter: z75.string().nullable()
5887
+ items: z78.array(materialVerificationItemSchema).max(100),
5888
+ nextAfter: z78.string().nullable()
5764
5889
  }).strict();
5765
5890
 
5766
5891
  // packages/contracts/src/editorial-workspace.ts
5767
- import { z as z76 } from "zod";
5768
- var sha = z76.string().regex(/^[a-f0-9]{64}$/u);
5892
+ import { z as z79 } from "zod";
5893
+ var sha = z79.string().regex(/^[a-f0-9]{64}$/u);
5769
5894
  var publicEditorialCandidateSchema = editorialCandidateSchema.omit({ projectId: true });
5770
5895
  var publicEditorialKernelSchema = contentKernelSchema.omit({ projectId: true });
5771
- var editorialKindSchema = z76.enum(["CANDIDATE", "KERNEL"]);
5772
- var command2 = z76.object({
5773
- version: z76.literal(1),
5896
+ var editorialKindSchema = z79.enum(["CANDIDATE", "KERNEL"]);
5897
+ var command2 = z79.object({
5898
+ version: z79.literal(1),
5774
5899
  requestId: uuidSchema,
5775
5900
  expectedReviewSha256: sha,
5776
- note: z76.string().trim().max(4096).nullable()
5901
+ note: z79.string().trim().max(4096).nullable()
5777
5902
  }).strict();
5778
5903
  var humanCandidateDecisionSchema = command2.extend({ decision: editorialDecisionSchema }).strict();
5779
5904
  var humanKernelReviewSchema = command2.extend({ decision: kernelReviewDecisionSchema }).strict();
5780
- var editorialCandidateQuerySchema = z76.object({
5781
- limit: z76.coerce.number().int().min(1).max(100).default(20),
5782
- cursor: z76.string().min(1).max(1024).optional(),
5905
+ var editorialCandidateQuerySchema = z79.object({
5906
+ limit: z79.coerce.number().int().min(1).max(100).default(20),
5907
+ cursor: z79.string().min(1).max(1024).optional(),
5783
5908
  status: editorialCandidateStatusSchema.optional()
5784
5909
  }).strict();
5785
5910
  var editorialKernelQuerySchema = editorialCandidateQuerySchema.extend({ status: contentKernelStatusSchema.optional() }).strict();
5786
- var pageInfo = z76.object({ hasMore: z76.boolean(), nextCursor: z76.string().nullable() });
5787
- var scope = z76.object({
5788
- projectCode: z76.string(),
5789
- projectName: z76.string(),
5790
- canReview: z76.boolean(),
5791
- canPrepare: z76.boolean()
5911
+ var pageInfo = z79.object({ hasMore: z79.boolean(), nextCursor: z79.string().nullable() });
5912
+ var scope = z79.object({
5913
+ projectCode: z79.string(),
5914
+ projectName: z79.string(),
5915
+ canReview: z79.boolean(),
5916
+ canPrepare: z79.boolean()
5792
5917
  });
5793
5918
  var editorialCandidatePageSchema = scope.extend({
5794
- items: z76.array(publicEditorialCandidateSchema),
5919
+ items: z79.array(publicEditorialCandidateSchema),
5795
5920
  pageInfo
5796
5921
  });
5797
5922
  var editorialKernelPageSchema = scope.extend({
5798
- items: z76.array(publicEditorialKernelSchema),
5923
+ items: z79.array(publicEditorialKernelSchema),
5799
5924
  pageInfo
5800
5925
  });
5801
- var editorialSourceStateSchema = z76.object({
5926
+ var editorialSourceStateSchema = z79.object({
5802
5927
  ref: stableRefSchema,
5803
5928
  id: uuidSchema.nullable(),
5804
5929
  sourceType: sourceTypeSchema.nullable(),
5805
- authority: z76.string().nullable(),
5806
- observedAt: z76.string().datetime().nullable(),
5807
- validUntil: z76.string().datetime().nullable(),
5808
- available: z76.boolean(),
5809
- reason: z76.enum(["CURRENT", "UNAVAILABLE", "EXPIRED", "CHANGED", "NO_CONTENT"]),
5810
- contentHash: z76.string().nullable()
5811
- });
5812
- var origin = z76.object({
5813
- workRequestCode: z76.string(),
5814
- acceptedAt: z76.string().datetime(),
5930
+ authority: z79.string().nullable(),
5931
+ observedAt: z79.string().datetime().nullable(),
5932
+ validUntil: z79.string().datetime().nullable(),
5933
+ available: z79.boolean(),
5934
+ reason: z79.enum(["CURRENT", "UNAVAILABLE", "EXPIRED", "CHANGED", "NO_CONTENT"]),
5935
+ contentHash: z79.string().nullable()
5936
+ });
5937
+ var origin = z79.object({
5938
+ workRequestCode: z79.string(),
5939
+ acceptedAt: z79.string().datetime(),
5815
5940
  contract: agentOutputContractReferenceSchema,
5816
5941
  basisSha256: sha,
5817
5942
  contentSha256: sha,
@@ -5820,13 +5945,13 @@ var origin = z76.object({
5820
5945
  var detail = scope.extend({
5821
5946
  reviewSha256: sha,
5822
5947
  recordSha256: sha,
5823
- basisCurrent: z76.boolean(),
5824
- sources: z76.array(editorialSourceStateSchema),
5948
+ basisCurrent: z79.boolean(),
5949
+ sources: z79.array(editorialSourceStateSchema),
5825
5950
  origin,
5826
- canApprove: z76.boolean(),
5827
- canReject: z76.boolean(),
5828
- canStartKernel: z76.boolean(),
5829
- blockedReason: z76.enum([
5951
+ canApprove: z79.boolean(),
5952
+ canReject: z79.boolean(),
5953
+ canStartKernel: z79.boolean(),
5954
+ blockedReason: z79.enum([
5830
5955
  "SOURCE_UNAVAILABLE",
5831
5956
  "TASK_BASIS_CHANGED",
5832
5957
  "KERNEL_EXPIRED",
@@ -5835,198 +5960,198 @@ var detail = scope.extend({
5835
5960
  ]).nullable()
5836
5961
  });
5837
5962
  var editorialCandidateDetailSchema = detail.extend({
5838
- kind: z76.literal("CANDIDATE"),
5963
+ kind: z79.literal("CANDIDATE"),
5839
5964
  candidate: publicEditorialCandidateSchema
5840
5965
  });
5841
5966
  var editorialKernelDetailSchema = detail.extend({
5842
- kind: z76.literal("KERNEL"),
5967
+ kind: z79.literal("KERNEL"),
5843
5968
  kernel: publicEditorialKernelSchema
5844
5969
  });
5845
- var editorialReviewReceiptSchema = z76.object({
5846
- version: z76.literal(1),
5970
+ var editorialReviewReceiptSchema = z79.object({
5971
+ version: z79.literal(1),
5847
5972
  requestId: uuidSchema,
5848
5973
  resourceRef: stableRefSchema,
5849
- actorCode: z76.string(),
5850
- decidedAt: z76.string().datetime(),
5851
- decision: z76.enum(["SELECTED", "APPROVED", "REJECTED"]),
5852
- note: z76.string().nullable(),
5853
- replayed: z76.boolean(),
5854
- result: z76.discriminatedUnion("kind", [
5855
- z76.object({ kind: z76.literal("CANDIDATE"), candidate: publicEditorialCandidateSchema }),
5856
- z76.object({ kind: z76.literal("KERNEL"), kernel: publicEditorialKernelSchema })
5974
+ actorCode: z79.string(),
5975
+ decidedAt: z79.string().datetime(),
5976
+ decision: z79.enum(["SELECTED", "APPROVED", "REJECTED"]),
5977
+ note: z79.string().nullable(),
5978
+ replayed: z79.boolean(),
5979
+ result: z79.discriminatedUnion("kind", [
5980
+ z79.object({ kind: z79.literal("CANDIDATE"), candidate: publicEditorialCandidateSchema }),
5981
+ z79.object({ kind: z79.literal("KERNEL"), kernel: publicEditorialKernelSchema })
5857
5982
  ])
5858
5983
  });
5859
5984
 
5860
5985
  // packages/contracts/src/foundation/agent-workspace.ts
5861
- import { z as z77 } from "zod";
5862
- var kind = z77.enum(["ORGANIZATION", "PROJECT", "PERSONAL_CONTEXT"]);
5863
- var foundationAgentOverviewInputSchema = z77.object({ workspaceCode: z77.string().regex(/^WSP-[0-9]{6,}$/) }).strict();
5864
- var foundationAgentWorkspaceInputSchema = z77.object({ kind }).strict();
5865
- var foundationAgentProfileSaveSchema = z77.object({ kind, draft: saveFoundationDraftInputSchema }).strict();
5866
- var contextSurvey = saveOrganizationProjectSurveyInputSchema.extend({ expectedEditVersion: z77.number().int().positive().nullable() }).strict();
5867
- var foundationAgentSurveySaveSchema = z77.discriminatedUnion("kind", [
5868
- z77.object({ kind: z77.literal("ORGANIZATION"), requestId: z77.uuid(), survey: contextSurvey }).strict(),
5869
- z77.object({ kind: z77.literal("PROJECT"), requestId: z77.uuid(), survey: contextSurvey }).strict(),
5870
- z77.object({
5871
- kind: z77.literal("PERSONAL_CONTEXT"),
5872
- requestId: z77.uuid(),
5986
+ import { z as z80 } from "zod";
5987
+ var kind = z80.enum(["ORGANIZATION", "PROJECT", "PERSONAL_CONTEXT"]);
5988
+ var foundationAgentOverviewInputSchema = z80.object({ workspaceCode: z80.string().regex(/^WSP-[0-9]{6,}$/) }).strict();
5989
+ var foundationAgentWorkspaceInputSchema = z80.object({ kind }).strict();
5990
+ var foundationAgentProfileSaveSchema = z80.object({ kind, draft: saveFoundationDraftInputSchema }).strict();
5991
+ var contextSurvey = saveOrganizationProjectSurveyInputSchema.extend({ expectedEditVersion: z80.number().int().positive().nullable() }).strict();
5992
+ var foundationAgentSurveySaveSchema = z80.discriminatedUnion("kind", [
5993
+ z80.object({ kind: z80.literal("ORGANIZATION"), requestId: z80.uuid(), survey: contextSurvey }).strict(),
5994
+ z80.object({ kind: z80.literal("PROJECT"), requestId: z80.uuid(), survey: contextSurvey }).strict(),
5995
+ z80.object({
5996
+ kind: z80.literal("PERSONAL_CONTEXT"),
5997
+ requestId: z80.uuid(),
5873
5998
  survey: personalSurveyResponsesSchema.strict(),
5874
- expectedEditVersion: z77.number().int().positive().nullable()
5999
+ expectedEditVersion: z80.number().int().positive().nullable()
5875
6000
  }).strict()
5876
6001
  ]);
5877
- var foundationAgentAcceptSchema = z77.object({ kind, adoption: acceptFoundationInputSchema, decision: foundationHumanDecisionSchema }).strict();
5878
- var foundationAgentResearchSchema = z77.object({ kind, research: foundationResearchSaveSchema }).strict();
5879
- var foundationAgentReadingSchema = z77.object({ kind, reading: foundationMaterialReadingSaveSchema }).strict();
5880
- var foundationAgentResearchReplySchema = z77.object({ kind, answer: foundationResearchReplySchema }).strict();
5881
- var foundationAgentChangesSchema = z77.object({ kind, query: foundationChangesQuerySchema }).strict();
5882
- var foundationAgentAckSchema = z77.object({ kind, acknowledgement: foundationChangesAckSchema }).strict();
5883
- var foundationAgentRecordQuerySchema = z77.object({ kind, id: z77.string().uuid(), revision: z77.number().int().positive().optional() }).strict();
5884
- var foundationAgentDecisionReceiptQuerySchema = z77.object({
6002
+ var foundationAgentAcceptSchema = z80.object({ kind, adoption: acceptFoundationInputSchema, decision: foundationHumanDecisionSchema }).strict();
6003
+ var foundationAgentResearchSchema = z80.object({ kind, research: foundationResearchSaveSchema }).strict();
6004
+ var foundationAgentReadingSchema = z80.object({ kind, reading: foundationMaterialReadingSaveSchema }).strict();
6005
+ var foundationAgentResearchReplySchema = z80.object({ kind, answer: foundationResearchReplySchema }).strict();
6006
+ var foundationAgentChangesSchema = z80.object({ kind, query: foundationChangesQuerySchema }).strict();
6007
+ var foundationAgentAckSchema = z80.object({ kind, acknowledgement: foundationChangesAckSchema }).strict();
6008
+ var foundationAgentRecordQuerySchema = z80.object({ kind, id: z80.string().uuid(), revision: z80.number().int().positive().optional() }).strict();
6009
+ var foundationAgentDecisionReceiptQuerySchema = z80.object({
5885
6010
  kind,
5886
- requestId: z77.string().min(1).max(160)
6011
+ requestId: z80.string().min(1).max(160)
5887
6012
  }).strict();
5888
- var foundationSaveOperationSchema = z77.enum([
6013
+ var foundationSaveOperationSchema = z80.enum([
5889
6014
  "PROFILE",
5890
6015
  "SURVEY",
5891
6016
  "RESEARCH",
5892
6017
  "READING",
5893
6018
  "ANSWER"
5894
6019
  ]);
5895
- var foundationAgentSaveReceiptSchema = z77.object({ kind, operation: foundationSaveOperationSchema, requestId: z77.string().min(1).max(160) }).strict();
5896
- var foundationAgentRevokeSchema = z77.object({
6020
+ var foundationAgentSaveReceiptSchema = z80.object({ kind, operation: foundationSaveOperationSchema, requestId: z80.string().min(1).max(160) }).strict();
6021
+ var foundationAgentRevokeSchema = z80.object({
5897
6022
  kind,
5898
6023
  revocation: revokeFoundationInputSchema,
5899
6024
  decision: foundationHumanDecisionSchema
5900
6025
  }).strict();
5901
6026
 
5902
6027
  // packages/contracts/src/source-material.ts
5903
- import { z as z78 } from "zod";
6028
+ import { z as z81 } from "zod";
5904
6029
  var SOURCE_MATERIAL_MAX_BYTES = 20 * 1024 * 1024;
5905
- var sourceMaterialOriginalSchema = z78.object({
5906
- sha256: z78.string().regex(/^[a-f0-9]{64}$/),
5907
- byteSize: z78.number().int().positive().max(SOURCE_MATERIAL_MAX_BYTES),
5908
- mediaType: z78.string().regex(/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/).max(256),
5909
- filename: z78.string().min(1).max(240)
6030
+ var sourceMaterialOriginalSchema = z81.object({
6031
+ sha256: z81.string().regex(/^[a-f0-9]{64}$/),
6032
+ byteSize: z81.number().int().positive().max(SOURCE_MATERIAL_MAX_BYTES),
6033
+ mediaType: z81.string().regex(/^[a-z0-9.+-]+\/[a-z0-9.+-]+$/).max(256),
6034
+ filename: z81.string().min(1).max(240)
5910
6035
  });
5911
6036
 
5912
6037
  // packages/contracts/src/personal-material.ts
5913
- import { z as z79 } from "zod";
5914
- var personalMaterialRefSchema = z79.string().regex(/^cf:\/\/personal-material\/[0-9a-f-]{36}$/i);
5915
- var personalMaterialSchema = z79.object({
6038
+ import { z as z82 } from "zod";
6039
+ var personalMaterialRefSchema = z82.string().regex(/^cf:\/\/personal-material\/[0-9a-f-]{36}$/i);
6040
+ var personalMaterialSchema = z82.object({
5916
6041
  id: uuidSchema,
5917
6042
  ref: personalMaterialRefSchema,
5918
6043
  ownerUserId: uuidSchema,
5919
6044
  original: sourceMaterialOriginalSchema,
5920
- createdAt: z79.string().datetime()
6045
+ createdAt: z82.string().datetime()
5921
6046
  });
5922
- var personalMaterialTargetSchema = z79.discriminatedUnion("kind", [
5923
- z79.object({ kind: z79.literal("ORGANIZATION"), tenantId: uuidSchema }),
5924
- z79.object({ kind: z79.literal("PROJECT"), tenantId: uuidSchema, projectId: uuidSchema })
6047
+ var personalMaterialTargetSchema = z82.discriminatedUnion("kind", [
6048
+ z82.object({ kind: z82.literal("ORGANIZATION"), tenantId: uuidSchema }),
6049
+ z82.object({ kind: z82.literal("PROJECT"), tenantId: uuidSchema, projectId: uuidSchema })
5925
6050
  ]);
5926
- var personalMaterialUseSchema = z79.object({
6051
+ var personalMaterialUseSchema = z82.object({
5927
6052
  id: uuidSchema,
5928
6053
  materialId: uuidSchema,
5929
6054
  target: personalMaterialTargetSchema,
5930
- destinationCode: z79.string().min(1).max(64),
5931
- destinationName: z79.string().min(1).max(240),
5932
- active: z79.boolean(),
5933
- editVersion: z79.number().int().positive(),
5934
- createdAt: z79.string().datetime(),
5935
- updatedAt: z79.string().datetime()
5936
- });
5937
- var personalMaterialUseInputSchema = z79.object({
5938
- active: z79.boolean(),
5939
- expectedEditVersion: z79.number().int().nonnegative(),
6055
+ destinationCode: z82.string().min(1).max(64),
6056
+ destinationName: z82.string().min(1).max(240),
6057
+ active: z82.boolean(),
6058
+ editVersion: z82.number().int().positive(),
6059
+ createdAt: z82.string().datetime(),
6060
+ updatedAt: z82.string().datetime()
6061
+ });
6062
+ var personalMaterialUseInputSchema = z82.object({
6063
+ active: z82.boolean(),
6064
+ expectedEditVersion: z82.number().int().nonnegative(),
5940
6065
  requestId: uuidSchema
5941
6066
  }).strict();
5942
- var personalMaterialPageSchema = z79.object({
5943
- items: z79.array(personalMaterialSchema).max(50),
5944
- nextCursor: z79.string().nullable()
6067
+ var personalMaterialPageSchema = z82.object({
6068
+ items: z82.array(personalMaterialSchema).max(50),
6069
+ nextCursor: z82.string().nullable()
5945
6070
  });
5946
- var personalMaterialListQuerySchema = z79.object({
5947
- limit: z79.number().int().min(1).max(50).default(20),
5948
- q: z79.string().trim().max(160).optional(),
5949
- cursor: z79.string().max(1024).optional()
6071
+ var personalMaterialListQuerySchema = z82.object({
6072
+ limit: z82.number().int().min(1).max(50).default(20),
6073
+ q: z82.string().trim().max(160).optional(),
6074
+ cursor: z82.string().max(1024).optional()
5950
6075
  }).strict();
5951
6076
 
5952
6077
  // packages/contracts/src/operating/program-agent-draft.ts
5953
- import { z as z80 } from "zod";
5954
- var programAgentDraftSaveSchema = z80.object({
5955
- programCode: z80.string().regex(/^CPG-[0-9]{6,}$/u),
5956
- expectedUpdatedAt: z80.string().datetime(),
6078
+ import { z as z83 } from "zod";
6079
+ var programAgentDraftSaveSchema = z83.object({
6080
+ programCode: z83.string().regex(/^CPG-[0-9]{6,}$/u),
6081
+ expectedUpdatedAt: z83.string().datetime(),
5957
6082
  content: contentProgramContentSchema,
5958
- strategies: z80.array(contentProgramChannelStrategyInputSchema).max(64)
6083
+ strategies: z83.array(contentProgramChannelStrategyInputSchema).max(64)
5959
6084
  }).strict();
5960
6085
 
5961
6086
  // packages/contracts/src/publication/package-delivery.ts
5962
- import { z as z81 } from "zod";
5963
- var packageDeliveryInputSchema = z81.object({
5964
- packageCode: z81.string().regex(/^PKG-[0-9]{6,}$/)
6087
+ import { z as z84 } from "zod";
6088
+ var packageDeliveryInputSchema = z84.object({
6089
+ packageCode: z84.string().regex(/^PKG-[0-9]{6,}$/)
5965
6090
  }).strict();
5966
- var packageExportRequestSchema = z81.object({
5967
- retryOf: z81.string().regex(/^JOB-[0-9]{6,}$/).optional()
6091
+ var packageExportRequestSchema = z84.object({
6092
+ retryOf: z84.string().regex(/^JOB-[0-9]{6,}$/).optional()
5968
6093
  }).strict().optional();
5969
6094
  var packageExportInputSchema = packageDeliveryInputSchema.extend({
5970
- retryOf: z81.string().regex(/^JOB-[0-9]{6,}$/).optional()
6095
+ retryOf: z84.string().regex(/^JOB-[0-9]{6,}$/).optional()
5971
6096
  }).strict();
5972
6097
  var packageContentReadInputSchema = packageDeliveryInputSchema.extend({
5973
- targetKey: z81.string().min(1).max(64).optional()
6098
+ targetKey: z84.string().min(1).max(64).optional()
5974
6099
  }).strict();
5975
- var packageDeliveryViewSchema = z81.object({
5976
- packageCode: z81.string(),
5977
- manifestHash: z81.string(),
5978
- reviewSha256: z81.string().regex(/^[a-f0-9]{64}$/),
6100
+ var packageDeliveryViewSchema = z84.object({
6101
+ packageCode: z84.string(),
6102
+ manifestHash: z84.string(),
6103
+ reviewSha256: z84.string().regex(/^[a-f0-9]{64}$/),
5979
6104
  status: contentPackageStatusSchema,
5980
- capabilities: z81.object({
5981
- review: z81.boolean(),
5982
- download: z81.boolean(),
5983
- recordPublication: z81.boolean()
6105
+ capabilities: z84.object({
6106
+ review: z84.boolean(),
6107
+ download: z84.boolean(),
6108
+ recordPublication: z84.boolean()
5984
6109
  }),
5985
- export: z81.object({
5986
- readable: z81.boolean(),
5987
- unavailable: z81.boolean(),
5988
- ready: z81.boolean(),
5989
- work: z81.object({
5990
- businessCode: z81.string(),
6110
+ export: z84.object({
6111
+ readable: z84.boolean(),
6112
+ unavailable: z84.boolean(),
6113
+ ready: z84.boolean(),
6114
+ work: z84.object({
6115
+ businessCode: z84.string(),
5991
6116
  state: workRequestStateSchema,
5992
- updatedAt: z81.string().datetime(),
5993
- errorCode: z81.string().nullable()
6117
+ updatedAt: z84.string().datetime(),
6118
+ errorCode: z84.string().nullable()
5994
6119
  }).nullable()
5995
6120
  })
5996
6121
  });
5997
6122
 
5998
6123
  // packages/contracts/src/feedback-facts.ts
5999
- import { z as z83 } from "zod";
6124
+ import { z as z86 } from "zod";
6000
6125
 
6001
6126
  // packages/contracts/src/foundation/command-outcome.ts
6002
- import { z as z82 } from "zod";
6003
- var commandRejectedReceiptSchema = z82.object({
6004
- state: z82.literal("REJECTED"),
6005
- result: z82.null(),
6006
- error: z82.object({
6007
- code: z82.string().regex(/^[A-Z0-9_]{1,100}$/),
6008
- outcome: z82.literal("REJECTED"),
6009
- recovery: z82.string().min(1).max(100)
6127
+ import { z as z85 } from "zod";
6128
+ var commandRejectedReceiptSchema = z85.object({
6129
+ state: z85.literal("REJECTED"),
6130
+ result: z85.null(),
6131
+ error: z85.object({
6132
+ code: z85.string().regex(/^[A-Z0-9_]{1,100}$/),
6133
+ outcome: z85.literal("REJECTED"),
6134
+ recovery: z85.string().min(1).max(100)
6010
6135
  }).strict()
6011
6136
  }).strict();
6012
6137
 
6013
6138
  // packages/contracts/src/feedback-facts.ts
6014
- var feedbackFactIdentitySchema = z83.object({
6015
- sourceKey: z83.string().trim().min(1).max(128),
6016
- factKey: z83.string().trim().min(1).max(512).refine((v) => !/[\u0000-\u001f\u007f]/.test(v))
6139
+ var feedbackFactIdentitySchema = z86.object({
6140
+ sourceKey: z86.string().trim().min(1).max(128),
6141
+ factKey: z86.string().trim().min(1).max(512).refine((v) => !/[\u0000-\u001f\u007f]/.test(v))
6017
6142
  }).strict();
6018
6143
  var feedbackSourceFactSchema = feedbackFactIdentitySchema.extend({
6019
- sourceKey: z83.string().regex(/^[a-z][a-z0-9._/-]{0,127}$/).refine((v) => v !== "native"),
6020
- sourceRevision: z83.number().int().positive().max(2147483647).optional()
6144
+ sourceKey: z86.string().regex(/^[a-z][a-z0-9._/-]{0,127}$/).refine((v) => v !== "native"),
6145
+ sourceRevision: z86.number().int().positive().max(2147483647).optional()
6021
6146
  }).strict();
6022
- var feedbackFactCorrectionSchema = z83.object({
6023
- observedAt: z83.string().datetime(),
6147
+ var feedbackFactCorrectionSchema = z86.object({
6148
+ observedAt: z86.string().datetime(),
6024
6149
  metricWindow: feedbackMetricWindowSchema,
6025
- periodStart: z83.string().datetime().nullable(),
6026
- periodEnd: z83.string().datetime().nullable(),
6150
+ periodStart: z86.string().datetime().nullable(),
6151
+ periodEnd: z86.string().datetime().nullable(),
6027
6152
  metrics: feedbackMetricsSchema,
6028
- note: z83.string().trim().max(8192).nullable(),
6029
- sourceReference: z83.string().trim().min(1).max(2048).nullable()
6153
+ note: z86.string().trim().max(8192).nullable(),
6154
+ sourceReference: z86.string().trim().min(1).max(2048).nullable()
6030
6155
  }).strict().superRefine((v, ctx) => {
6031
6156
  refineFeedbackMeasurementWindow(v, ctx);
6032
6157
  if (!Object.keys(v.metrics).some((k) => k !== "currency") && !v.note?.trim())
@@ -6034,13 +6159,13 @@ var feedbackFactCorrectionSchema = z83.object({
6034
6159
  if (Object.keys(v.metrics).some((k) => k !== "currency") && !v.sourceReference)
6035
6160
  ctx.addIssue({ code: "custom", message: "Actual metrics need a source reference." });
6036
6161
  });
6037
- var observationCode = z83.string().regex(/^OBS-[0-9]{6,}$/);
6038
- var feedbackFactHttpQuerySchema = z83.object({
6162
+ var observationCode = z86.string().regex(/^OBS-[0-9]{6,}$/);
6163
+ var feedbackFactHttpQuerySchema = z86.object({
6039
6164
  observationCode: observationCode.optional(),
6040
6165
  sourceKey: feedbackFactIdentitySchema.shape.sourceKey.optional(),
6041
6166
  factKey: feedbackFactIdentitySchema.shape.factKey.optional(),
6042
- beforeRevision: z83.coerce.number().int().positive().max(2147483647).optional(),
6043
- limit: z83.coerce.number().int().min(1).max(30).default(10)
6167
+ beforeRevision: z86.coerce.number().int().positive().max(2147483647).optional(),
6168
+ limit: z86.coerce.number().int().min(1).max(30).default(10)
6044
6169
  }).strict().superRefine((v, ctx) => {
6045
6170
  if (v.observationCode ? v.sourceKey !== void 0 || v.factKey !== void 0 : !v.sourceKey || !v.factKey)
6046
6171
  ctx.addIssue({
@@ -6048,109 +6173,109 @@ var feedbackFactHttpQuerySchema = z83.object({
6048
6173
  message: "Use an observation code or an exact source/fact key pair."
6049
6174
  });
6050
6175
  });
6051
- var feedbackFactReadSchema = z83.union([
6052
- z83.object({
6176
+ var feedbackFactReadSchema = z86.union([
6177
+ z86.object({
6053
6178
  observationCode,
6054
- beforeRevision: z83.coerce.number().int().positive().max(2147483647).optional(),
6055
- limit: z83.coerce.number().int().min(1).max(30).default(10)
6179
+ beforeRevision: z86.coerce.number().int().positive().max(2147483647).optional(),
6180
+ limit: z86.coerce.number().int().min(1).max(30).default(10)
6056
6181
  }).strict(),
6057
- z83.object({
6182
+ z86.object({
6058
6183
  identity: feedbackFactIdentitySchema,
6059
- beforeRevision: z83.coerce.number().int().positive().max(2147483647).optional(),
6060
- limit: z83.coerce.number().int().min(1).max(30).default(10)
6184
+ beforeRevision: z86.coerce.number().int().positive().max(2147483647).optional(),
6185
+ limit: z86.coerce.number().int().min(1).max(30).default(10)
6061
6186
  }).strict()
6062
6187
  ]);
6063
6188
  var change = {
6064
- requestId: z83.uuid(),
6189
+ requestId: z86.uuid(),
6065
6190
  observationCode,
6066
- expectedRevision: z83.number().int().positive().max(2147483647),
6067
- expectedAccountUpdatedAt: z83.string().datetime(),
6068
- reason: z83.string().trim().min(1).max(2048),
6069
- sourceRevision: z83.number().int().positive().max(2147483647).optional()
6191
+ expectedRevision: z86.number().int().positive().max(2147483647),
6192
+ expectedAccountUpdatedAt: z86.string().datetime(),
6193
+ reason: z86.string().trim().min(1).max(2048),
6194
+ sourceRevision: z86.number().int().positive().max(2147483647).optional()
6070
6195
  };
6071
- var feedbackFactChangeSchema = z83.discriminatedUnion("operation", [
6072
- z83.object({
6196
+ var feedbackFactChangeSchema = z86.discriminatedUnion("operation", [
6197
+ z86.object({
6073
6198
  ...change,
6074
- operation: z83.literal("CORRECT"),
6199
+ operation: z86.literal("CORRECT"),
6075
6200
  correction: feedbackFactCorrectionSchema
6076
6201
  }).strict(),
6077
- z83.object({ ...change, operation: z83.literal("WITHDRAW") }).strict()
6202
+ z86.object({ ...change, operation: z86.literal("WITHDRAW") }).strict()
6078
6203
  ]);
6079
- var feedbackFactSchema = z83.object({
6204
+ var feedbackFactSchema = z86.object({
6080
6205
  identity: feedbackFactIdentitySchema,
6081
- revision: z83.number().int().positive(),
6082
- sourceRevision: z83.number().int().positive().nullable(),
6083
- state: z83.enum(["CURRENT", "WITHDRAWN"]),
6206
+ revision: z86.number().int().positive(),
6207
+ sourceRevision: z86.number().int().positive().nullable(),
6208
+ state: z86.enum(["CURRENT", "WITHDRAWN"]),
6084
6209
  current: feedbackObservationSchema.nullable(),
6085
- updatedAt: z83.string().datetime()
6210
+ updatedAt: z86.string().datetime()
6086
6211
  });
6087
- var feedbackFactChangeReceiptSchema = z83.object({
6212
+ var feedbackFactChangeReceiptSchema = z86.object({
6088
6213
  observationCode,
6089
- revision: z83.number().int().positive(),
6090
- state: z83.enum(["CURRENT", "WITHDRAWN"]),
6091
- destinationCode: z83.string(),
6092
- replayed: z83.boolean()
6093
- });
6094
- var feedbackFactOriginalReceiptSchema = z83.discriminatedUnion("state", [
6095
- z83.object({ state: z83.literal("FOUND"), result: feedbackFactChangeReceiptSchema }),
6096
- z83.object({ state: z83.literal("NOT_FOUND"), result: z83.null() }),
6214
+ revision: z86.number().int().positive(),
6215
+ state: z86.enum(["CURRENT", "WITHDRAWN"]),
6216
+ destinationCode: z86.string(),
6217
+ replayed: z86.boolean()
6218
+ });
6219
+ var feedbackFactOriginalReceiptSchema = z86.discriminatedUnion("state", [
6220
+ z86.object({ state: z86.literal("FOUND"), result: feedbackFactChangeReceiptSchema }),
6221
+ z86.object({ state: z86.literal("NOT_FOUND"), result: z86.null() }),
6097
6222
  commandRejectedReceiptSchema
6098
6223
  ]);
6099
6224
  var feedbackFactDocumentSchema = feedbackFactSchema.extend({
6100
6225
  lastObservation: feedbackObservationSchema.nullable().default(null),
6101
- canChange: z83.boolean(),
6102
- destinationCode: z83.string(),
6103
- accountUpdatedAt: z83.string().datetime(),
6104
- history: z83.array(
6105
- z83.object({
6106
- revision: z83.number().int().positive(),
6107
- sourceRevision: z83.number().int().positive().nullable(),
6108
- operation: z83.enum(["OBSERVE", "CORRECT", "WITHDRAW"]),
6226
+ canChange: z86.boolean(),
6227
+ destinationCode: z86.string(),
6228
+ accountUpdatedAt: z86.string().datetime(),
6229
+ history: z86.array(
6230
+ z86.object({
6231
+ revision: z86.number().int().positive(),
6232
+ sourceRevision: z86.number().int().positive().nullable(),
6233
+ operation: z86.enum(["OBSERVE", "CORRECT", "WITHDRAW"]),
6109
6234
  observation: feedbackObservationSchema.nullable(),
6110
- reason: z83.string().nullable(),
6111
- createdAt: z83.string().datetime()
6235
+ reason: z86.string().nullable(),
6236
+ createdAt: z86.string().datetime()
6112
6237
  })
6113
6238
  ),
6114
- hasMore: z83.boolean(),
6115
- nextBeforeRevision: z83.number().int().positive().nullable().default(null)
6239
+ hasMore: z86.boolean(),
6240
+ nextBeforeRevision: z86.number().int().positive().nullable().default(null)
6116
6241
  });
6117
- var feedbackFactAgentReadSchema = z83.union([
6242
+ var feedbackFactAgentReadSchema = z86.union([
6118
6243
  feedbackFactReadSchema.options[0].extend({
6119
- destinationCode: z83.string().regex(/^DST-[0-9]{6,}$/)
6244
+ destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
6120
6245
  }),
6121
6246
  feedbackFactReadSchema.options[1].extend({
6122
- destinationCode: z83.string().regex(/^DST-[0-9]{6,}$/)
6247
+ destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
6123
6248
  })
6124
6249
  ]);
6125
- var feedbackFactAgentChangeSchema = z83.discriminatedUnion("operation", [
6250
+ var feedbackFactAgentChangeSchema = z86.discriminatedUnion("operation", [
6126
6251
  feedbackFactChangeSchema.options[0].extend({
6127
- destinationCode: z83.string().regex(/^DST-[0-9]{6,}$/)
6252
+ destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
6128
6253
  }),
6129
6254
  feedbackFactChangeSchema.options[1].extend({
6130
- destinationCode: z83.string().regex(/^DST-[0-9]{6,}$/)
6255
+ destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
6131
6256
  })
6132
6257
  ]);
6133
- var feedbackFactAgentReceiptSchema = z83.object({ requestId: z83.uuid(), destinationCode: z83.string().regex(/^DST-[0-9]{6,}$/) }).strict();
6258
+ var feedbackFactAgentReceiptSchema = z86.object({ requestId: z86.uuid(), destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/) }).strict();
6134
6259
 
6135
6260
  // packages/contracts/src/channel-feedback.ts
6136
- import { z as z84 } from "zod";
6137
- var channelFeedbackCommandSchema = z84.object({
6261
+ import { z as z87 } from "zod";
6262
+ var channelFeedbackCommandSchema = z87.object({
6138
6263
  fact: feedbackSourceFactSchema.optional(),
6139
- requestId: z84.uuid(),
6140
- expectedAccountUpdatedAt: z84.string().datetime(),
6141
- sourceName: z84.string().trim().min(1).max(128),
6142
- sourceReference: z84.string().trim().min(1).max(2048).nullable(),
6143
- observedAt: z84.string().datetime(),
6264
+ requestId: z87.uuid(),
6265
+ expectedAccountUpdatedAt: z87.string().datetime(),
6266
+ sourceName: z87.string().trim().min(1).max(128),
6267
+ sourceReference: z87.string().trim().min(1).max(2048).nullable(),
6268
+ observedAt: z87.string().datetime(),
6144
6269
  metricWindow: feedbackMetricWindowSchema,
6145
- periodStart: z84.string().datetime().nullable(),
6146
- periodEnd: z84.string().datetime().nullable(),
6270
+ periodStart: z87.string().datetime().nullable(),
6271
+ periodEnd: z87.string().datetime().nullable(),
6147
6272
  metrics: feedbackMetricsSchema,
6148
- note: z84.string().trim().max(8192).nullable(),
6149
- publicationCode: z84.string().regex(/^PUB-[0-9]{6,}$/).nullable(),
6150
- goal: z84.object({
6151
- programCode: z84.string().regex(/^CPG-[0-9]{6,}$/),
6152
- revision: z84.number().int().positive(),
6153
- goalId: z84.string().min(1).max(64)
6273
+ note: z87.string().trim().max(8192).nullable(),
6274
+ publicationCode: z87.string().regex(/^PUB-[0-9]{6,}$/).nullable(),
6275
+ goal: z87.object({
6276
+ programCode: z87.string().regex(/^CPG-[0-9]{6,}$/),
6277
+ revision: z87.number().int().positive(),
6278
+ goalId: z87.string().min(1).max(64)
6154
6279
  }).strict().nullable()
6155
6280
  }).strict().superRefine((v, ctx) => {
6156
6281
  if (!Object.keys(v.metrics).some((k) => k !== "currency") && !v.note?.trim())
@@ -6164,177 +6289,177 @@ var channelFeedbackCommandSchema = z84.object({
6164
6289
  if ((v.metrics.attributedRevenueAmount !== void 0 || v.metrics.adSpendAmount !== void 0) && !v.metrics.currency)
6165
6290
  ctx.addIssue({ code: "custom", message: "Currency required." });
6166
6291
  });
6167
- var channelFeedbackQuerySchema = z84.object({
6168
- view: z84.enum(["CURRENT", "HISTORY"]).default("CURRENT"),
6169
- limit: z84.coerce.number().int().min(1).max(50).default(10),
6170
- afterBusinessCode: z84.string().regex(/^OBS-[0-9]{6,}$/).optional()
6292
+ var channelFeedbackQuerySchema = z87.object({
6293
+ view: z87.enum(["CURRENT", "HISTORY"]).default("CURRENT"),
6294
+ limit: z87.coerce.number().int().min(1).max(50).default(10),
6295
+ afterBusinessCode: z87.string().regex(/^OBS-[0-9]{6,}$/).optional()
6171
6296
  }).strict();
6172
- var channelFeedbackPageSchema = z84.object({
6173
- canRecord: z84.boolean(),
6174
- items: z84.array(feedbackObservationSchema),
6175
- hasMore: z84.boolean(),
6176
- nextAfterBusinessCode: z84.string().nullable()
6297
+ var channelFeedbackPageSchema = z87.object({
6298
+ canRecord: z87.boolean(),
6299
+ items: z87.array(feedbackObservationSchema),
6300
+ hasMore: z87.boolean(),
6301
+ nextAfterBusinessCode: z87.string().nullable()
6177
6302
  }).strict();
6178
- var channelFeedbackReceiptSchema = z84.object({ observationCode: z84.string(), observedAt: z84.string().datetime(), replayed: z84.boolean() }).strict();
6303
+ var channelFeedbackReceiptSchema = z87.object({ observationCode: z87.string(), observedAt: z87.string().datetime(), replayed: z87.boolean() }).strict();
6179
6304
  var channelFeedbackReadSchema = channelFeedbackQuerySchema.extend({
6180
- destinationCode: z84.string().regex(/^DST-[0-9]{6,}$/)
6305
+ destinationCode: z87.string().regex(/^DST-[0-9]{6,}$/)
6181
6306
  });
6182
6307
  var channelFeedbackWriteSchema = channelFeedbackCommandSchema.safeExtend({
6183
- destinationCode: z84.string().regex(/^DST-[0-9]{6,}$/)
6308
+ destinationCode: z87.string().regex(/^DST-[0-9]{6,}$/)
6184
6309
  });
6185
- var channelFeedbackReceiptQuerySchema = z84.object({ requestId: z84.uuid() }).strict();
6186
- var channelFeedbackOriginalReceiptSchema = z84.discriminatedUnion("state", [
6187
- z84.object({ state: z84.literal("FOUND"), result: channelFeedbackReceiptSchema }).strict(),
6188
- z84.object({ state: z84.literal("NOT_FOUND"), result: z84.null() }).strict(),
6310
+ var channelFeedbackReceiptQuerySchema = z87.object({ requestId: z87.uuid() }).strict();
6311
+ var channelFeedbackOriginalReceiptSchema = z87.discriminatedUnion("state", [
6312
+ z87.object({ state: z87.literal("FOUND"), result: channelFeedbackReceiptSchema }).strict(),
6313
+ z87.object({ state: z87.literal("NOT_FOUND"), result: z87.null() }).strict(),
6189
6314
  commandRejectedReceiptSchema
6190
6315
  ]);
6191
6316
  var channelFeedbackAgentReceiptSchema = channelFeedbackReceiptQuerySchema.extend({
6192
- destinationCode: z84.string().regex(/^DST-[0-9]{6,}$/)
6317
+ destinationCode: z87.string().regex(/^DST-[0-9]{6,}$/)
6193
6318
  });
6194
6319
 
6195
6320
  // packages/contracts/src/business-objects.ts
6196
- import { z as z85 } from "zod";
6197
- var workspaceCode = z85.string().regex(/^WSP-[0-9]{6,}$/);
6198
- var page = z85.object({
6199
- limit: z85.number().int().min(1).max(20).default(8),
6200
- cursor: z85.string().max(2e3).optional()
6201
- }).strict();
6202
- var businessObjectsQuerySchema = z85.discriminatedUnion("kind", [
6203
- page.extend({ kind: z85.literal("ORGANIZATIONS") }).strict(),
6204
- page.extend({ kind: z85.literal("WORKSPACES") }).strict(),
6321
+ import { z as z88 } from "zod";
6322
+ var workspaceCode = z88.string().regex(/^WSP-[0-9]{6,}$/);
6323
+ var page = z88.object({
6324
+ limit: z88.number().int().min(1).max(20).default(8),
6325
+ cursor: z88.string().max(2e3).optional()
6326
+ }).strict();
6327
+ var businessObjectsQuerySchema = z88.discriminatedUnion("kind", [
6328
+ page.extend({ kind: z88.literal("ORGANIZATIONS") }).strict(),
6329
+ page.extend({ kind: z88.literal("WORKSPACES") }).strict(),
6205
6330
  page.extend({
6206
- kind: z85.literal("PROJECTS"),
6331
+ kind: z88.literal("PROJECTS"),
6207
6332
  workspaceCode,
6208
- search: z85.string().trim().min(1).max(160).optional(),
6333
+ search: z88.string().trim().min(1).max(160).optional(),
6209
6334
  status: projectStatusSchema.optional()
6210
6335
  }).strict()
6211
6336
  ]);
6212
- var projectCreationCommandSchema = z85.object({
6337
+ var projectCreationCommandSchema = z88.object({
6213
6338
  key: projectKeySchema,
6214
- name: z85.string().trim().min(1).max(160),
6215
- requestId: z85.string().min(1).max(128)
6339
+ name: z88.string().trim().min(1).max(160),
6340
+ requestId: z88.string().min(1).max(128)
6216
6341
  }).strict();
6217
6342
  var agentProjectCreationSchema = projectCreationCommandSchema.extend({ workspaceCode }).strict();
6218
- var projectCreationReceiptQuerySchema = z85.object({ workspaceCode, requestId: z85.string().min(1).max(128) }).strict();
6219
- var result = z85.object({
6220
- project: z85.object({
6221
- businessCode: z85.string().regex(/^PRJ-[0-9]{6,}$/),
6343
+ var projectCreationReceiptQuerySchema = z88.object({ workspaceCode, requestId: z88.string().min(1).max(128) }).strict();
6344
+ var result = z88.object({
6345
+ project: z88.object({
6346
+ businessCode: z88.string().regex(/^PRJ-[0-9]{6,}$/),
6222
6347
  key: projectKeySchema,
6223
- name: z85.string(),
6348
+ name: z88.string(),
6224
6349
  status: projectStatusSchema,
6225
6350
  workspaceCode,
6226
- tenantCode: z85.string().regex(/^TEN-[0-9]{6,}$/)
6351
+ tenantCode: z88.string().regex(/^TEN-[0-9]{6,}$/)
6227
6352
  }).strict(),
6228
- connection: z85.object({ resource: z85.string().url(), authorizationRequired: z85.literal(true) }).strict()
6353
+ connection: z88.object({ resource: z88.string().url(), authorizationRequired: z88.literal(true) }).strict()
6229
6354
  }).strict();
6230
- var projectCreationResultSchema = result.extend({ replayed: z85.boolean() }).strict();
6231
- var projectCreationReceiptSchema = z85.discriminatedUnion("state", [
6232
- z85.object({ state: z85.literal("FOUND"), result }).strict(),
6233
- z85.object({ state: z85.literal("NOT_FOUND"), result: z85.null() }).strict()
6355
+ var projectCreationResultSchema = result.extend({ replayed: z88.boolean() }).strict();
6356
+ var projectCreationReceiptSchema = z88.discriminatedUnion("state", [
6357
+ z88.object({ state: z88.literal("FOUND"), result }).strict(),
6358
+ z88.object({ state: z88.literal("NOT_FOUND"), result: z88.null() }).strict()
6234
6359
  ]);
6235
6360
 
6236
6361
  // packages/contracts/src/foundation/survey-operations.ts
6237
- import { z as z86 } from "zod";
6238
- var kind2 = z86.enum(["ORGANIZATION", "PROJECT", "PERSONAL_CONTEXT"]);
6239
- var foundationSurveyOperationSchema = z86.enum(["SUBMIT", "UPDATE_INSTRUMENT"]);
6240
- var foundationSurveyCommandSchema = z86.object({
6362
+ import { z as z89 } from "zod";
6363
+ var kind2 = z89.enum(["ORGANIZATION", "PROJECT", "PERSONAL_CONTEXT"]);
6364
+ var foundationSurveyOperationSchema = z89.enum(["SUBMIT", "UPDATE_INSTRUMENT"]);
6365
+ var foundationSurveyCommandSchema = z89.object({
6241
6366
  kind: kind2,
6242
- surveyCode: z86.string().regex(/^SRV-[0-9]{6,}$/),
6243
- expectedEditVersion: z86.number().int().positive(),
6244
- requestId: z86.string().min(1).max(128)
6367
+ surveyCode: z89.string().regex(/^SRV-[0-9]{6,}$/),
6368
+ expectedEditVersion: z89.number().int().positive(),
6369
+ requestId: z89.string().min(1).max(128)
6245
6370
  }).strict();
6246
- var foundationSurveyReceiptQuerySchema = z86.object({
6371
+ var foundationSurveyReceiptQuerySchema = z89.object({
6247
6372
  kind: kind2,
6248
6373
  operation: foundationSurveyOperationSchema,
6249
- requestId: z86.string().min(1).max(128)
6374
+ requestId: z89.string().min(1).max(128)
6250
6375
  }).strict();
6251
6376
 
6252
6377
  // packages/contracts/src/source-registration.ts
6253
- import { z as z87 } from "zod";
6254
- var requestId2 = z87.string().min(1).max(128);
6378
+ import { z as z90 } from "zod";
6379
+ var requestId2 = z90.string().min(1).max(128);
6255
6380
  var sourceRegistrationCommandSchema = sourceObservationInputSchema.safeExtend({ requestId: requestId2 }).strict();
6256
- var sourceLinksCommandSchema = z87.object({
6381
+ var sourceLinksCommandSchema = z90.object({
6257
6382
  requestId: requestId2,
6258
- urls: z87.array(z87.string().max(2048)).min(1).max(20)
6383
+ urls: z90.array(z90.string().max(2048)).min(1).max(20)
6259
6384
  }).strict();
6260
- var sourceRegistrationReceiptQuerySchema = z87.object({
6261
- operation: z87.enum(["REGISTER", "LINKS"]),
6385
+ var sourceRegistrationReceiptQuerySchema = z90.object({
6386
+ operation: z90.enum(["REGISTER", "LINKS"]),
6262
6387
  requestId: requestId2
6263
6388
  }).strict();
6264
- var sourceRegistrationTargetSchema = z87.discriminatedUnion("kind", [
6265
- z87.object({ kind: z87.literal("ORGANIZATION"), tenantCode: z87.string().regex(/^TEN-[0-9]{6,}$/) }).strict(),
6266
- z87.object({ kind: z87.literal("PROJECT"), projectCode: z87.string().regex(/^PRJ-[0-9]{6,}$/) }).strict()
6389
+ var sourceRegistrationTargetSchema = z90.discriminatedUnion("kind", [
6390
+ z90.object({ kind: z90.literal("ORGANIZATION"), tenantCode: z90.string().regex(/^TEN-[0-9]{6,}$/) }).strict(),
6391
+ z90.object({ kind: z90.literal("PROJECT"), projectCode: z90.string().regex(/^PRJ-[0-9]{6,}$/) }).strict()
6267
6392
  ]);
6268
- var sourceLinksResultSchema = z87.object({
6269
- entries: z87.array(
6270
- z87.object({
6271
- index: z87.number().int(),
6272
- input: z87.string(),
6273
- state: z87.enum(["ADDED", "DUPLICATE", "INVALID"]),
6393
+ var sourceLinksResultSchema = z90.object({
6394
+ entries: z90.array(
6395
+ z90.object({
6396
+ index: z90.number().int(),
6397
+ input: z90.string(),
6398
+ state: z90.enum(["ADDED", "DUPLICATE", "INVALID"]),
6274
6399
  source: sourceRefSchema.nullable(),
6275
- message: z87.string().nullable()
6400
+ message: z90.string().nullable()
6276
6401
  }).strict()
6277
6402
  ),
6278
- registeredOnly: z87.literal(true)
6403
+ registeredOnly: z90.literal(true)
6279
6404
  }).strict();
6280
- var sourceRegistrationReceiptSchema = z87.discriminatedUnion("state", [
6281
- z87.object({
6282
- state: z87.literal("FOUND"),
6283
- result: z87.union([sourceRefSchema, sourceLinksResultSchema])
6405
+ var sourceRegistrationReceiptSchema = z90.discriminatedUnion("state", [
6406
+ z90.object({
6407
+ state: z90.literal("FOUND"),
6408
+ result: z90.union([sourceRefSchema, sourceLinksResultSchema])
6284
6409
  }).strict(),
6285
- z87.object({ state: z87.literal("NOT_FOUND"), result: z87.null() }).strict(),
6410
+ z90.object({ state: z90.literal("NOT_FOUND"), result: z90.null() }).strict(),
6286
6411
  commandRejectedReceiptSchema
6287
6412
  ]);
6288
- var sourceLinksCommandResultSchema = z87.object({ result: sourceLinksResultSchema, replayed: z87.boolean() }).strict();
6413
+ var sourceLinksCommandResultSchema = z90.object({ result: sourceLinksResultSchema, replayed: z90.boolean() }).strict();
6289
6414
 
6290
6415
  // packages/contracts/src/material-upload.ts
6291
- import { z as z88 } from "zod";
6292
- var materialUploadTargetSchema = z88.discriminatedUnion("kind", [
6293
- z88.object({ kind: z88.literal("PERSONAL") }).strict(),
6294
- z88.object({ kind: z88.literal("ORGANIZATION"), tenantCode: businessCodeSchema }).strict(),
6295
- z88.object({ kind: z88.literal("PROJECT"), projectCode: businessCodeSchema }).strict()
6416
+ import { z as z91 } from "zod";
6417
+ var materialUploadTargetSchema = z91.discriminatedUnion("kind", [
6418
+ z91.object({ kind: z91.literal("PERSONAL") }).strict(),
6419
+ z91.object({ kind: z91.literal("ORGANIZATION"), tenantCode: businessCodeSchema }).strict(),
6420
+ z91.object({ kind: z91.literal("PROJECT"), projectCode: businessCodeSchema }).strict()
6296
6421
  ]);
6297
- var materialUploadQuerySchema = z88.object({ requestId: uuidSchema }).strict();
6422
+ var materialUploadQuerySchema = z91.object({ requestId: uuidSchema }).strict();
6298
6423
  var materialUploadCommandSchema = materialUploadQuerySchema.extend({
6299
- filename: z88.string().trim().min(1).max(240).refine(
6424
+ filename: z91.string().trim().min(1).max(240).refine(
6300
6425
  (value) => !/[\\/\u0000-\u001f\u007f]/.test(value),
6301
6426
  "Use an original basename without control characters."
6302
6427
  ),
6303
- byteSize: z88.number().int().min(1).max(SOURCE_MATERIAL_MAX_BYTES),
6304
- sha256: z88.string().regex(/^[a-f0-9]{64}$/)
6428
+ byteSize: z91.number().int().min(1).max(SOURCE_MATERIAL_MAX_BYTES),
6429
+ sha256: z91.string().regex(/^[a-f0-9]{64}$/)
6305
6430
  }).strict();
6306
- var materialUploadResultSchema = z88.discriminatedUnion("kind", [
6307
- z88.object({ kind: z88.literal("PERSONAL"), material: personalMaterialSchema }),
6308
- z88.object({ kind: z88.enum(["ORGANIZATION", "PROJECT"]), source: sourceRefSchema })
6431
+ var materialUploadResultSchema = z91.discriminatedUnion("kind", [
6432
+ z91.object({ kind: z91.literal("PERSONAL"), material: personalMaterialSchema }),
6433
+ z91.object({ kind: z91.enum(["ORGANIZATION", "PROJECT"]), source: sourceRefSchema })
6309
6434
  ]);
6310
- var materialUploadReceiptSchema = z88.object({
6311
- state: z88.enum(["FOUND", "NOT_FOUND"]),
6435
+ var materialUploadReceiptSchema = z91.object({
6436
+ state: z91.enum(["FOUND", "NOT_FOUND"]),
6312
6437
  result: materialUploadResultSchema.nullable()
6313
6438
  });
6314
6439
  var materialUploadPreparedSchema = materialUploadCommandSchema.extend({
6315
- maxBytes: z88.number().int().positive(),
6316
- uploadPath: z88.string().min(1).max(1024),
6317
- method: z88.literal("POST"),
6318
- contentType: z88.literal("multipart/form-data"),
6319
- fileField: z88.literal("file"),
6320
- authentication: z88.literal("CF_OAUTH"),
6321
- preparedOnly: z88.literal(true)
6322
- });
6323
- var materialUploadCommandResultSchema = z88.object({
6440
+ maxBytes: z91.number().int().positive(),
6441
+ uploadPath: z91.string().min(1).max(1024),
6442
+ method: z91.literal("POST"),
6443
+ contentType: z91.literal("multipart/form-data"),
6444
+ fileField: z91.literal("file"),
6445
+ authentication: z91.literal("CF_OAUTH"),
6446
+ preparedOnly: z91.literal(true)
6447
+ });
6448
+ var materialUploadCommandResultSchema = z91.object({
6324
6449
  result: materialUploadResultSchema,
6325
- replayed: z88.boolean()
6450
+ replayed: z91.boolean()
6326
6451
  });
6327
6452
 
6328
6453
  // packages/contracts/src/material-reuse.ts
6329
- import { z as z89 } from "zod";
6330
- var personalMaterialDetailQuerySchema = z89.object({ materialId: uuidSchema }).strict();
6454
+ import { z as z92 } from "zod";
6455
+ var personalMaterialDetailQuerySchema = z92.object({ materialId: uuidSchema }).strict();
6331
6456
  var personalMaterialUsesQuerySchema = personalMaterialDetailQuerySchema.extend({
6332
- limit: z89.number().int().min(1).max(20).default(8),
6333
- cursor: z89.string().max(2048).optional()
6457
+ limit: z92.number().int().min(1).max(20).default(8),
6458
+ cursor: z92.string().max(2048).optional()
6334
6459
  }).strict();
6335
6460
  var command3 = personalMaterialDetailQuerySchema.extend({
6336
6461
  requestId: uuidSchema,
6337
- expectedEditVersion: z89.number().int().nonnegative()
6462
+ expectedEditVersion: z92.number().int().nonnegative()
6338
6463
  });
6339
6464
  var personalMaterialGrantCommandSchema = command3.extend({
6340
6465
  target: sourceRegistrationTargetSchema,
@@ -6346,258 +6471,197 @@ var personalMaterialStopCommandSchema = command3.extend({
6346
6471
  }).strict();
6347
6472
  var personalMaterialUseReceiptQuerySchema = personalMaterialDetailQuerySchema.extend({
6348
6473
  requestId: uuidSchema,
6349
- operation: z89.enum(["GRANT", "STOP"])
6474
+ operation: z92.enum(["GRANT", "STOP"])
6350
6475
  }).strict();
6351
- var personalMaterialUseResultSchema = z89.object({
6476
+ var personalMaterialUseResultSchema = z92.object({
6352
6477
  use: personalMaterialUseSchema,
6353
6478
  origin: businessWriteOriginSchema
6354
6479
  }).strict();
6355
- var personalMaterialUseReceiptSchema = z89.discriminatedUnion("state", [
6356
- z89.object({ state: z89.literal("FOUND"), result: personalMaterialUseResultSchema }).strict(),
6357
- z89.object({ state: z89.literal("NOT_FOUND"), result: z89.null() }).strict(),
6480
+ var personalMaterialUseReceiptSchema = z92.discriminatedUnion("state", [
6481
+ z92.object({ state: z92.literal("FOUND"), result: personalMaterialUseResultSchema }).strict(),
6482
+ z92.object({ state: z92.literal("NOT_FOUND"), result: z92.null() }).strict(),
6358
6483
  commandRejectedReceiptSchema
6359
6484
  ]);
6360
6485
 
6361
6486
  // packages/contracts/src/source-binding.ts
6362
- import { z as z90 } from "zod";
6363
- var sourceCandidatesQuerySchema = z90.object({
6364
- q: z90.string().trim().max(160).optional(),
6487
+ import { z as z93 } from "zod";
6488
+ var sourceCandidatesQuerySchema = z93.object({
6489
+ q: z93.string().trim().max(160).optional(),
6365
6490
  sourceType: sourceTypeSchema.optional(),
6366
- limit: z90.number().int().min(1).max(20).default(8),
6367
- cursor: z90.string().max(2048).optional()
6491
+ limit: z93.number().int().min(1).max(20).default(8),
6492
+ cursor: z93.string().max(2048).optional()
6368
6493
  }).strict();
6369
- var sourceBindingCommandSchema = z90.object({
6494
+ var sourceBindingCommandSchema = z93.object({
6370
6495
  sourceId: uuidSchema,
6371
- expectedBound: z90.boolean(),
6496
+ expectedBound: z93.boolean(),
6372
6497
  requestId: uuidSchema
6373
6498
  }).strict();
6374
- var sourceBindingResultSchema = z90.object({ sourceRef: z90.string(), binding: projectSourceBindingSchema }).strict();
6375
- var sourceBindingReceiptQuerySchema = z90.object({ requestId: uuidSchema }).strict();
6376
- var sourceBindingReceiptSchema = z90.discriminatedUnion("state", [
6377
- z90.object({ state: z90.literal("FOUND"), result: sourceBindingResultSchema }).strict(),
6378
- z90.object({ state: z90.literal("NOT_FOUND"), result: z90.null() }).strict(),
6499
+ var sourceBindingResultSchema = z93.object({ sourceRef: z93.string(), binding: projectSourceBindingSchema }).strict();
6500
+ var sourceBindingReceiptQuerySchema = z93.object({ requestId: uuidSchema }).strict();
6501
+ var sourceBindingReceiptSchema = z93.discriminatedUnion("state", [
6502
+ z93.object({ state: z93.literal("FOUND"), result: sourceBindingResultSchema }).strict(),
6503
+ z93.object({ state: z93.literal("NOT_FOUND"), result: z93.null() }).strict(),
6379
6504
  commandRejectedReceiptSchema
6380
6505
  ]);
6381
6506
 
6382
6507
  // packages/contracts/src/operating/strategy-commands.ts
6383
- import { z as z91 } from "zod";
6384
- var programCommandReceiptSchema = z91.discriminatedUnion("state", [
6385
- z91.object({ state: z91.literal("FOUND"), result: z91.unknown() }),
6386
- z91.object({ state: z91.literal("NOT_FOUND"), result: z91.null() }),
6508
+ import { z as z94 } from "zod";
6509
+ var programCommandReceiptSchema = z94.discriminatedUnion("state", [
6510
+ z94.object({ state: z94.literal("FOUND"), result: z94.unknown() }),
6511
+ z94.object({ state: z94.literal("NOT_FOUND"), result: z94.null() }),
6387
6512
  commandRejectedReceiptSchema
6388
6513
  ]);
6389
- var requestId3 = z91.string().uuid();
6390
- var fingerprint = z91.string().regex(/^[a-f0-9]{64}$/);
6391
- var programDraftOpenCommandSchema = z91.object({
6514
+ var requestId3 = z94.string().uuid();
6515
+ var fingerprint = z94.string().regex(/^[a-f0-9]{64}$/);
6516
+ var programDraftOpenCommandSchema = z94.object({
6392
6517
  requestId: requestId3,
6393
6518
  expectedPreparationFingerprint: fingerprint,
6394
- expectedDraft: z91.object({ programCode: businessCodeSchema, updatedAt: z91.string().datetime() }).strict().nullable()
6519
+ expectedDraft: z94.object({ programCode: businessCodeSchema, updatedAt: z94.string().datetime() }).strict().nullable()
6395
6520
  }).strict();
6396
6521
  var programDraftSaveCommandSchema = programAgentDraftSaveSchema.extend({ requestId: requestId3 }).strict();
6397
- var programActivationCommandSchema = z91.object({
6522
+ var programActivationCommandSchema = z94.object({
6398
6523
  requestId: requestId3,
6399
6524
  programCode: businessCodeSchema,
6400
- expectedUpdatedAt: z91.string().datetime(),
6525
+ expectedUpdatedAt: z94.string().datetime(),
6401
6526
  foundationBasis: foundationProgramBasisSchema,
6402
6527
  decision: humanDecisionDeclarationSchema.optional()
6403
6528
  }).strict();
6404
- var programCommandReceiptQuerySchema = z91.object({ operation: z91.enum(["OPEN", "SAVE", "REBASE", "ACTIVATE", "APPLY"]), requestId: requestId3 }).strict();
6405
- var goalObservationCommandSchema = z91.object({
6529
+ var programCommandReceiptQuerySchema = z94.object({ operation: z94.enum(["OPEN", "SAVE", "REBASE", "ACTIVATE", "APPLY"]), requestId: requestId3 }).strict();
6530
+ var goalObservationCommandSchema = z94.object({
6406
6531
  requestId: requestId3,
6407
6532
  programCode: businessCodeSchema,
6408
- expectedProgramUpdatedAt: z91.string().datetime(),
6409
- goalId: z91.string().min(1).max(64),
6410
- startsAt: z91.string().datetime(),
6411
- endsAt: z91.string().datetime(),
6412
- value: z91.number().finite().nonnegative(),
6413
- sourceName: z91.string().trim().min(1).max(128),
6414
- sourceReference: z91.string().trim().min(1).max(2048),
6415
- sourceMode: z91.enum(["HUMAN", "API_ADAPTER"]),
6416
- observedAt: z91.string().datetime(),
6417
- note: z91.string().max(8192).nullable()
6418
- }).strict();
6419
- var goalObservationReceiptQuerySchema = z91.object({ requestId: requestId3 }).strict();
6420
- var programBasisCommandSchema = z91.object({
6533
+ expectedProgramUpdatedAt: z94.string().datetime(),
6534
+ goalId: z94.string().min(1).max(64),
6535
+ startsAt: z94.string().datetime(),
6536
+ endsAt: z94.string().datetime(),
6537
+ value: z94.number().finite().nonnegative(),
6538
+ sourceName: z94.string().trim().min(1).max(128),
6539
+ sourceReference: z94.string().trim().min(1).max(2048),
6540
+ sourceMode: z94.enum(["HUMAN", "API_ADAPTER"]),
6541
+ observedAt: z94.string().datetime(),
6542
+ note: z94.string().max(8192).nullable()
6543
+ }).strict();
6544
+ var goalObservationReceiptQuerySchema = z94.object({ requestId: requestId3 }).strict();
6545
+ var programBasisCommandSchema = z94.object({
6421
6546
  requestId: requestId3,
6422
6547
  programCode: businessCodeSchema,
6423
- expectedUpdatedAt: z91.string().datetime(),
6548
+ expectedUpdatedAt: z94.string().datetime(),
6424
6549
  foundationBasis: foundationProgramBasisSchema
6425
6550
  }).strict();
6426
- var programSuggestionReadSchema = z91.object({ candidateCode: businessCodeSchema.optional(), workCode: businessCodeSchema.optional() }).strict().refine((v) => Boolean(v.candidateCode) !== Boolean(v.workCode));
6427
- var programSuggestionApplySchema = z91.object({
6551
+ var programSuggestionReadSchema = z94.object({ candidateCode: businessCodeSchema.optional(), workCode: businessCodeSchema.optional() }).strict().refine((v) => Boolean(v.candidateCode) !== Boolean(v.workCode));
6552
+ var programSuggestionApplySchema = z94.object({
6428
6553
  candidateCode: businessCodeSchema,
6429
- expectedUpdatedAt: z91.string().datetime().nullable(),
6554
+ expectedUpdatedAt: z94.string().datetime().nullable(),
6430
6555
  requestId: requestId3
6431
6556
  }).strict();
6432
- var programPreparationViewSchema = z91.object({
6433
- basis: z91.object({
6434
- version: z91.literal(1),
6557
+ var programPreparationViewSchema = z94.object({
6558
+ basis: z94.object({
6559
+ version: z94.literal(1),
6435
6560
  fingerprint,
6436
- sourceRefs: z91.array(z91.string()).max(24),
6561
+ sourceRefs: z94.array(z94.string()).max(24),
6437
6562
  goalFingerprint: fingerprint
6438
6563
  }).strict(),
6439
6564
  adoptionBasis: foundationProgramBasisSchema.nullable(),
6440
- goals: z91.array(z91.object({ id: z91.string(), outcome: z91.string() })).max(12),
6441
- alignment: z91.object({ basisFingerprint: fingerprint, goalFingerprint: fingerprint }),
6442
- currentDraft: z91.object({ programCode: businessCodeSchema, updatedAt: z91.string().datetime() }).nullable(),
6443
- referenceOnly: z91.boolean(),
6444
- inputRead: z91.object({
6445
- capability: z91.string(),
6446
- input: z91.object({ kind: z91.literal("PROJECT") })
6565
+ goals: z94.array(z94.object({ id: z94.string(), outcome: z94.string() })).max(12),
6566
+ alignment: z94.object({ basisFingerprint: fingerprint, goalFingerprint: fingerprint }),
6567
+ currentDraft: z94.object({ programCode: businessCodeSchema, updatedAt: z94.string().datetime() }).nullable(),
6568
+ referenceOnly: z94.boolean(),
6569
+ inputRead: z94.object({
6570
+ capability: z94.string(),
6571
+ input: z94.object({ kind: z94.literal("PROJECT") })
6447
6572
  }),
6448
- alignmentSave: z91.object({
6449
- capability: z91.string(),
6450
- kind: z91.literal("PROJECT"),
6573
+ alignmentSave: z94.object({
6574
+ capability: z94.string(),
6575
+ kind: z94.literal("PROJECT"),
6451
6576
  expectedBasisFingerprint: fingerprint,
6452
6577
  expectedGoalFingerprint: fingerprint
6453
6578
  }),
6454
- authority: z91.object({ preparationIsAdoption: z91.literal(false) })
6579
+ authority: z94.object({ preparationIsAdoption: z94.literal(false) })
6455
6580
  }).strict();
6456
- var programCommandResultSchema = z91.object({
6581
+ var programCommandResultSchema = z94.object({
6457
6582
  programCode: businessCodeSchema,
6458
- updatedAt: z91.string().datetime(),
6459
- status: z91.enum(["DRAFT", "ACTIVE", "SUPERSEDED"]),
6460
- activated: z91.boolean(),
6461
- referenceOnly: z91.boolean(),
6583
+ updatedAt: z94.string().datetime(),
6584
+ status: z94.enum(["DRAFT", "ACTIVE", "SUPERSEDED"]),
6585
+ activated: z94.boolean(),
6586
+ referenceOnly: z94.boolean(),
6462
6587
  origin: businessWriteOriginSchema
6463
6588
  }).strict();
6464
- var programCommandEnvelopeSchema = z91.object({ result: programCommandResultSchema, replayed: z91.boolean() }).strict();
6465
- var programGoalOptionsQuerySchema = z91.object({ programCode: businessCodeSchema, goalId: z91.string().min(1).max(64).optional() }).strict();
6589
+ var programCommandEnvelopeSchema = z94.object({ result: programCommandResultSchema, replayed: z94.boolean() }).strict();
6590
+ var programGoalOptionsQuerySchema = z94.object({ programCode: businessCodeSchema, goalId: z94.string().min(1).max(64).optional() }).strict();
6466
6591
 
6467
6592
  // packages/contracts/src/editorial-collaboration.ts
6468
- import { z as z92 } from "zod";
6469
- var editorialProposalCommandSchema = z92.discriminatedUnion("kind", [
6470
- z92.object({
6471
- kind: z92.literal("CANDIDATE"),
6472
- requestId: z92.uuid(),
6593
+ import { z as z95 } from "zod";
6594
+ var editorialProposalCommandSchema = z95.discriminatedUnion("kind", [
6595
+ z95.object({
6596
+ kind: z95.literal("CANDIDATE"),
6597
+ requestId: z95.uuid(),
6473
6598
  content: createEditorialCandidateInputSchema.omit({ projectId: true, requestId: true }).strict()
6474
6599
  }).strict(),
6475
- z92.object({
6476
- kind: z92.literal("KERNEL"),
6477
- requestId: z92.uuid(),
6600
+ z95.object({
6601
+ kind: z95.literal("KERNEL"),
6602
+ requestId: z95.uuid(),
6478
6603
  candidateRef: cfRefSchema,
6479
- expectedReviewSha256: z92.string().regex(/^[a-f0-9]{64}$/),
6604
+ expectedReviewSha256: z95.string().regex(/^[a-f0-9]{64}$/),
6480
6605
  content: createContentKernelInputSchema.omit({ candidateId: true, requestId: true }).strict()
6481
6606
  }).strict()
6482
6607
  ]);
6483
- var editorialReadQuerySchema = z92.object({
6608
+ var editorialReadQuerySchema = z95.object({
6484
6609
  kind: editorialKindSchema,
6485
- limit: z92.coerce.number().int().min(1).max(100).default(12),
6486
- cursor: z92.string().max(2048).optional(),
6487
- status: z92.string().max(40).optional()
6488
- }).strict();
6489
- var editorialReadSchema = z92.object({ kind: editorialKindSchema, ref: cfRefSchema }).strict();
6490
- var editorialDecisionCommandSchema = z92.discriminatedUnion("kind", [
6491
- z92.object({
6492
- kind: z92.literal("CANDIDATE"),
6610
+ limit: z95.coerce.number().int().min(1).max(100).default(12),
6611
+ cursor: z95.string().max(2048).optional(),
6612
+ status: z95.string().max(40).optional()
6613
+ }).strict();
6614
+ var editorialReadSchema = z95.object({ kind: editorialKindSchema, ref: cfRefSchema }).strict();
6615
+ var editorialDecisionCommandSchema = z95.discriminatedUnion("kind", [
6616
+ z95.object({
6617
+ kind: z95.literal("CANDIDATE"),
6493
6618
  ref: cfRefSchema,
6494
6619
  command: humanCandidateDecisionSchema,
6495
6620
  humanDecision: humanDecisionDeclarationSchema.optional()
6496
6621
  }).strict(),
6497
- z92.object({
6498
- kind: z92.literal("KERNEL"),
6622
+ z95.object({
6623
+ kind: z95.literal("KERNEL"),
6499
6624
  ref: cfRefSchema,
6500
6625
  command: humanKernelReviewSchema,
6501
6626
  humanDecision: humanDecisionDeclarationSchema.optional()
6502
6627
  }).strict()
6503
6628
  ]);
6504
- var editorialCommandReceiptQuerySchema = z92.object({ operation: z92.enum(["PROPOSE", "DECIDE"]), requestId: z92.uuid() }).strict();
6505
-
6506
- // packages/contracts/src/publication/collaboration.ts
6507
- import { z as z93 } from "zod";
6508
- var hash4 = z93.string().regex(/^[a-f0-9]{64}$/);
6509
- var deliveryPackageReadSchema = z93.object({ packageCode: businessCodeSchema }).strict();
6510
- var deliveryPackageQuerySchema = z93.object({
6511
- limit: z93.coerce.number().int().min(1).max(50).default(12),
6512
- cursor: z93.string().max(2048).optional(),
6513
- q: z93.string().max(160).optional(),
6514
- status: contentPackageStatusSchema.optional()
6515
- }).strict();
6516
- var deliveryTargetReadSchema = deliveryPackageReadSchema.extend({ targetKey: packageTargetKeySchema }).strict();
6517
- var deliveryPublicationReadSchema = z93.object({ publicationCode: businessCodeSchema }).strict();
6518
- var deliveryPackageDecisionSchema = deliveryPackageReadSchema.extend({
6519
- requestId: z93.uuid(),
6520
- expectedReviewSha256: hash4,
6521
- decision: packageReviewDecisionSchema,
6522
- note: z93.string().max(4096).nullable().default(null),
6523
- humanDecision: humanDecisionDeclarationSchema.optional()
6524
- }).strict();
6525
- var deliveryPublicationRecordSchema = deliveryTargetReadSchema.extend({
6526
- requestId: z93.uuid(),
6527
- expectedContextSha256: hash4,
6528
- destinationCode: businessCodeSchema,
6529
- externalRef: externalHttpUrlSchema,
6530
- publishedAt: z93.string().datetime({ offset: true }).nullable().default(null),
6531
- humanDecision: humanDecisionDeclarationSchema.optional()
6532
- }).strict();
6533
- var deliveryAdmissionSchema = deliveryTargetReadSchema.extend({ destinationCode: businessCodeSchema, programCode: businessCodeSchema }).strict();
6534
- var deliveryReceiptSchema = z93.object({ operation: z93.enum(["REVIEW", "RECORD"]), requestId: z93.uuid() }).strict();
6535
- var deliveryCommandSchema = z93.discriminatedUnion("operation", [
6536
- deliveryPackageDecisionSchema.extend({ operation: z93.literal("REVIEW") }),
6537
- deliveryPublicationRecordSchema.extend({ operation: z93.literal("RECORD") })
6538
- ]);
6539
- var packageFileKeySchema = z93.string().regex(/^(archive|manifest|(?:asset|media|render):[a-z0-9][a-z0-9._-]{0,63}:(?:0|[1-9][0-9]?))$/).max(100);
6540
- var packageDownloadSchema = deliveryPackageReadSchema.extend({ fileKey: packageFileKeySchema.default("archive"), expectedManifestHash: hash4 }).strict();
6541
- var packageFilesQuerySchema = deliveryPackageReadSchema.extend({
6542
- targetKey: packageTargetKeySchema.optional(),
6543
- limit: z93.coerce.number().int().min(1).max(50).default(12),
6544
- cursor: z93.string().max(2048).optional()
6545
- }).strict();
6546
- var packageFileDescriptorSchema = z93.object({
6547
- packageCode: businessCodeSchema,
6548
- manifestHash: hash4,
6549
- fileKey: packageFileKeySchema,
6550
- filename: z93.string().max(512),
6551
- mimeType: z93.string().max(160),
6552
- byteSize: z93.number().int().nonnegative().nullable(),
6553
- sha256: hash4.nullable(),
6554
- integrity: z93.enum(["SHA256", "FROZEN_PACKAGE_ARCHIVE"]),
6555
- downloadPath: z93.string().max(2048),
6556
- authentication: z93.literal("CF_OAUTH"),
6557
- method: z93.literal("GET"),
6558
- head: z93.literal(true),
6559
- range: z93.boolean()
6560
- }).strict();
6561
- var packageFileReadOptionsSchema = packageDownloadSchema.extend({
6562
- head: z93.boolean().default(false),
6563
- range: z93.string().regex(/^bytes=\d*-\d*$/).max(160).optional(),
6564
- maxBytes: z93.number().int().positive().max(16 * 1024 * 1024 * 1024).default(2 * 1024 * 1024 * 1024)
6565
- }).strict();
6629
+ var editorialCommandReceiptQuerySchema = z95.object({ operation: z95.enum(["PROPOSE", "DECIDE"]), requestId: z95.uuid() }).strict();
6566
6630
 
6567
6631
  // packages/contracts/src/operating/learning-collaboration.ts
6568
- import { z as z94 } from "zod";
6569
- var humanImprovementProposalSchema = z94.object({
6570
- requestId: z94.uuid(),
6571
- observationCodes: z94.array(businessCodeSchema).min(1).max(20),
6632
+ import { z as z96 } from "zod";
6633
+ var humanImprovementProposalSchema = z96.object({
6634
+ requestId: z96.uuid(),
6635
+ observationCodes: z96.array(businessCodeSchema).min(1).max(20),
6572
6636
  window: feedbackAnalysisRequestInputSchema,
6573
- expectedBasisFingerprint: z94.string().regex(/^[a-f0-9]{64}$/),
6574
- kindKey: z94.string().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
6575
- title: z94.string().trim().min(1).max(300),
6576
- summary: z94.string().trim().min(1).max(4e3),
6577
- rationale: z94.string().trim().min(1).max(8e3),
6578
- proposedChange: z94.string().trim().min(1).max(8e3)
6579
- }).strict();
6580
- var improvementListSchema = z94.object({
6581
- limit: z94.coerce.number().int().min(1).max(50).default(12),
6582
- cursor: z94.string().max(2048).optional(),
6583
- q: z94.string().max(160).optional(),
6637
+ expectedBasisFingerprint: z96.string().regex(/^[a-f0-9]{64}$/),
6638
+ kindKey: z96.string().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
6639
+ title: z96.string().trim().min(1).max(300),
6640
+ summary: z96.string().trim().min(1).max(4e3),
6641
+ rationale: z96.string().trim().min(1).max(8e3),
6642
+ proposedChange: z96.string().trim().min(1).max(8e3)
6643
+ }).strict();
6644
+ var improvementListSchema = z96.object({
6645
+ limit: z96.coerce.number().int().min(1).max(50).default(12),
6646
+ cursor: z96.string().max(2048).optional(),
6647
+ q: z96.string().max(160).optional(),
6584
6648
  status: operatingRecommendationStatusSchema.optional(),
6585
- queue: z94.enum(["PENDING", "DECIDED"]).optional()
6649
+ queue: z96.enum(["PENDING", "DECIDED"]).optional()
6586
6650
  }).strict().refine((q) => !(q.status && q.queue), "Select an exact status or a queue.");
6587
6651
  var improvementDecisionSchema = operatingRecommendationHumanDecisionSchema.safeExtend({
6588
6652
  recommendationCode: businessCodeSchema,
6589
6653
  humanDecision: humanDecisionDeclarationSchema.optional()
6590
6654
  });
6591
6655
  var packageReviewFeedbackSchema = packageReviewObservationCommandSchema.extend({ packageCode: businessCodeSchema }).strict();
6592
- var publicationObservationBodySchema = z94.object({
6593
- requestId: z94.uuid(),
6594
- observedAt: z94.string().datetime({ offset: true }).transform((v) => new Date(v).toISOString()),
6656
+ var publicationObservationBodySchema = z96.object({
6657
+ requestId: z96.uuid(),
6658
+ observedAt: z96.string().datetime({ offset: true }).transform((v) => new Date(v).toISOString()),
6595
6659
  metricWindow: feedbackMetricWindowSchema.default("SNAPSHOT"),
6596
- periodStart: z94.string().datetime({ offset: true }).transform((v) => new Date(v).toISOString()).nullable().default(null),
6597
- periodEnd: z94.string().datetime({ offset: true }).transform((v) => new Date(v).toISOString()).nullable().default(null),
6660
+ periodStart: z96.string().datetime({ offset: true }).transform((v) => new Date(v).toISOString()).nullable().default(null),
6661
+ periodEnd: z96.string().datetime({ offset: true }).transform((v) => new Date(v).toISOString()).nullable().default(null),
6598
6662
  metrics: feedbackMetricsSchema.default({}),
6599
6663
  facts: feedbackFactsSchema.default({}),
6600
- note: z94.string().trim().max(8192).nullable().default(null)
6664
+ note: z96.string().trim().max(8192).nullable().default(null)
6601
6665
  }).strict().superRefine((q, ctx) => {
6602
6666
  refineFeedbackMeasurementWindow(q, ctx);
6603
6667
  if (!Object.keys(q.metrics).length && !Object.keys(q.facts).length && !q.note)
@@ -6614,8 +6678,8 @@ var publicationObservationBodySchema = z94.object({
6614
6678
  var publicationObservationCommandSchema = publicationObservationBodySchema.safeExtend({
6615
6679
  publicationCode: businessCodeSchema
6616
6680
  });
6617
- var learningReceiptSchema = z94.object({
6618
- operation: z94.enum([
6681
+ var learningReceiptSchema = z96.object({
6682
+ operation: z96.enum([
6619
6683
  "DECISION",
6620
6684
  "PACKAGE_OBSERVATION",
6621
6685
  "PUBLICATION_OBSERVATION",
@@ -6623,101 +6687,101 @@ var learningReceiptSchema = z94.object({
6623
6687
  "REVIEW_PROPOSAL",
6624
6688
  "HUMAN_PROPOSAL"
6625
6689
  ]),
6626
- requestId: z94.string().min(1).max(160)
6690
+ requestId: z96.string().min(1).max(160)
6627
6691
  }).strict();
6628
- var strategyLearningReadSchema = z94.object({ recommendationCodes: z94.array(businessCodeSchema).min(1).max(20) }).strict();
6629
- var learningFeedbackCommandSchema = z94.discriminatedUnion("operation", [
6630
- packageReviewFeedbackSchema.extend({ operation: z94.literal("PACKAGE_OBSERVATION") }),
6692
+ var strategyLearningReadSchema = z96.object({ recommendationCodes: z96.array(businessCodeSchema).min(1).max(20) }).strict();
6693
+ var learningFeedbackCommandSchema = z96.discriminatedUnion("operation", [
6694
+ packageReviewFeedbackSchema.extend({ operation: z96.literal("PACKAGE_OBSERVATION") }),
6631
6695
  publicationObservationCommandSchema.safeExtend({
6632
- operation: z94.literal("PUBLICATION_OBSERVATION")
6696
+ operation: z96.literal("PUBLICATION_OBSERVATION")
6633
6697
  })
6634
6698
  ]);
6635
- var publicationObservationReceiptSchema = z94.object({
6699
+ var publicationObservationReceiptSchema = z96.object({
6636
6700
  observationCode: businessCodeSchema,
6637
- observedAt: z94.string().datetime(),
6638
- sourceMode: z94.literal("HUMAN"),
6701
+ observedAt: z96.string().datetime(),
6702
+ sourceMode: z96.literal("HUMAN"),
6639
6703
  publicationCode: businessCodeSchema
6640
6704
  }).strict();
6641
6705
 
6642
6706
  // packages/contracts/src/access/administration.ts
6643
- import { z as z95 } from "zod";
6644
- var command4 = { requestId: z95.uuid(), humanDecision: humanDecisionDeclarationSchema.optional() };
6645
- var tenantRoleSchema = z95.enum(["TENANT_OWNER", "TENANT_ADMIN"]).nullable();
6646
- var teamListSchema = z95.object({
6647
- limit: z95.coerce.number().int().min(1).max(50).default(12),
6648
- cursor: z95.string().max(2048).optional(),
6649
- q: z95.string().max(160).optional(),
6650
- status: z95.enum(["ACTIVE", "INACTIVE"]).optional()
6651
- }).strict();
6652
- var teamMemberReadSchema = z95.object({
6707
+ import { z as z97 } from "zod";
6708
+ var command4 = { requestId: z97.uuid(), humanDecision: humanDecisionDeclarationSchema.optional() };
6709
+ var tenantRoleSchema = z97.enum(["TENANT_OWNER", "TENANT_ADMIN"]).nullable();
6710
+ var teamListSchema = z97.object({
6711
+ limit: z97.coerce.number().int().min(1).max(50).default(12),
6712
+ cursor: z97.string().max(2048).optional(),
6713
+ q: z97.string().max(160).optional(),
6714
+ status: z97.enum(["ACTIVE", "INACTIVE"]).optional()
6715
+ }).strict();
6716
+ var teamMemberReadSchema = z97.object({
6653
6717
  userCode: businessCodeSchema,
6654
- includeBusiness: z95.boolean().default(false),
6718
+ includeBusiness: z97.boolean().default(false),
6655
6719
  businessKind: memberBusinessKindSchema.optional(),
6656
- businessCursor: z95.string().min(1).max(2048).optional()
6720
+ businessCursor: z97.string().min(1).max(2048).optional()
6657
6721
  }).strict().refine(
6658
6722
  (v) => (!v.businessKind || v.includeBusiness) && (!v.businessCursor || Boolean(v.businessKind)),
6659
6723
  { message: "Business pagination requires includeBusiness and an exact businessKind." }
6660
6724
  );
6661
- var teamRegisterSchema = z95.object({
6725
+ var teamRegisterSchema = z97.object({
6662
6726
  ...command4,
6663
- email: z95.string().trim().email().max(320),
6664
- displayName: z95.string().trim().min(1).max(160),
6727
+ email: z97.string().trim().email().max(320),
6728
+ displayName: z97.string().trim().min(1).max(160),
6665
6729
  roleTemplate: tenantRoleSchema.default(null)
6666
6730
  }).strict();
6667
- var teamUpdateSchema = z95.object({
6731
+ var teamUpdateSchema = z97.object({
6668
6732
  ...command4,
6669
6733
  userCode: businessCodeSchema,
6670
- expectedSha256: z95.string().regex(/^[a-f0-9]{64}$/),
6671
- displayName: z95.string().trim().min(1).max(160).optional(),
6734
+ expectedSha256: z97.string().regex(/^[a-f0-9]{64}$/),
6735
+ displayName: z97.string().trim().min(1).max(160).optional(),
6672
6736
  roleTemplate: tenantRoleSchema.optional()
6673
6737
  }).strict().refine((v) => v.displayName !== void 0 || v.roleTemplate !== void 0, {
6674
6738
  message: "Choose a name or company role to update."
6675
6739
  });
6676
- var teamDeactivateSchema = z95.object({
6740
+ var teamDeactivateSchema = z97.object({
6677
6741
  ...command4,
6678
6742
  userCode: businessCodeSchema,
6679
- expectedSha256: z95.string().regex(/^[a-f0-9]{64}$/)
6743
+ expectedSha256: z97.string().regex(/^[a-f0-9]{64}$/)
6680
6744
  }).strict();
6681
- var projectAccessReadSchema = z95.object({ projectCode: businessCodeSchema, userCode: businessCodeSchema }).strict();
6745
+ var projectAccessReadSchema = z97.object({ projectCode: businessCodeSchema, userCode: businessCodeSchema }).strict();
6682
6746
  var projectAccessCommandSchema = projectAccessChangeSchema.extend({ ...command4, ...projectAccessReadSchema.shape }).strict();
6683
- var administrationReceiptSchema = z95.object({
6684
- operation: z95.enum(["REGISTER", "UPDATE", "DEACTIVATE", "PROJECT_ACCESS"]),
6685
- requestId: z95.uuid()
6747
+ var administrationReceiptSchema = z97.object({
6748
+ operation: z97.enum(["REGISTER", "UPDATE", "DEACTIVATE", "PROJECT_ACCESS"]),
6749
+ requestId: z97.uuid()
6686
6750
  }).strict();
6687
- var administrationMemberSchema = z95.object({
6688
- user: z95.object({
6751
+ var administrationMemberSchema = z97.object({
6752
+ user: z97.object({
6689
6753
  businessCode: businessCodeSchema,
6690
- email: z95.string(),
6691
- displayName: z95.string(),
6692
- status: z95.enum(["ACTIVE", "DISABLED"])
6754
+ email: z97.string(),
6755
+ displayName: z97.string(),
6756
+ status: z97.enum(["ACTIVE", "DISABLED"])
6693
6757
  }),
6694
- status: z95.enum(["ACTIVE", "INACTIVE"]),
6695
- roleTemplate: z95.string().nullable(),
6696
- deactivatedAt: z95.string().datetime().nullable(),
6697
- canManage: z95.boolean(),
6698
- canEditDisplayName: z95.boolean(),
6699
- canChangeRole: z95.boolean().optional(),
6700
- canViewBusiness: z95.boolean().optional(),
6701
- business: z95.null().optional(),
6702
- baselineSha256: z95.string(),
6703
- credentialSetupRequired: z95.boolean(),
6704
- credentialSetupHref: z95.string().nullable()
6758
+ status: z97.enum(["ACTIVE", "INACTIVE"]),
6759
+ roleTemplate: z97.string().nullable(),
6760
+ deactivatedAt: z97.string().datetime().nullable(),
6761
+ canManage: z97.boolean(),
6762
+ canEditDisplayName: z97.boolean(),
6763
+ canChangeRole: z97.boolean().optional(),
6764
+ canViewBusiness: z97.boolean().optional(),
6765
+ business: z97.null().optional(),
6766
+ baselineSha256: z97.string(),
6767
+ credentialSetupRequired: z97.boolean(),
6768
+ credentialSetupHref: z97.string().nullable()
6705
6769
  }).strict();
6706
6770
  var administrationMemberReadSchema = administrationMemberSchema.extend({
6707
6771
  business: memberBusinessViewSchema.nullable().optional()
6708
6772
  });
6709
- var administrationConfigurationSchema = z95.object({
6710
- limit: z95.coerce.number().int().min(1).max(20).default(8),
6711
- cursor: z95.string().max(2048).optional()
6773
+ var administrationConfigurationSchema = z97.object({
6774
+ limit: z97.coerce.number().int().min(1).max(20).default(8),
6775
+ cursor: z97.string().max(2048).optional()
6712
6776
  }).strict();
6713
- var administrationBrowserCommandSchema = z95.discriminatedUnion("operation", [
6714
- teamRegisterSchema.extend({ operation: z95.literal("REGISTER") }),
6715
- teamUpdateSchema.safeExtend({ operation: z95.literal("UPDATE") }),
6716
- teamDeactivateSchema.extend({ operation: z95.literal("DEACTIVATE") }),
6717
- projectAccessCommandSchema.extend({ operation: z95.literal("PROJECT_ACCESS") })
6777
+ var administrationBrowserCommandSchema = z97.discriminatedUnion("operation", [
6778
+ teamRegisterSchema.extend({ operation: z97.literal("REGISTER") }),
6779
+ teamUpdateSchema.safeExtend({ operation: z97.literal("UPDATE") }),
6780
+ teamDeactivateSchema.extend({ operation: z97.literal("DEACTIVATE") }),
6781
+ projectAccessCommandSchema.extend({ operation: z97.literal("PROJECT_ACCESS") })
6718
6782
  ]);
6719
6783
  var administrationProjectReceiptSchema = administrationReceiptSchema.extend({
6720
- operation: z95.literal("PROJECT_ACCESS")
6784
+ operation: z97.literal("PROJECT_ACCESS")
6721
6785
  });
6722
6786
 
6723
6787
  // packages/contracts/src/agent/capability-recovery.ts
@@ -6754,7 +6818,18 @@ var surveyRejections = [
6754
6818
  "PERSONAL_SURVEY_DRAFT_TRANSITION_IMMUTABLE"
6755
6819
  ];
6756
6820
  function isKnownCapabilityRejection(code2, name) {
6757
- return capabilityRejectedErrorCodes.includes(code2) || code2 === "INVALID_CURSOR" && isChangeAcknowledgement(name) || surveyWrites.includes(name ?? "") && surveyRejections.includes(code2) || researchWrites.includes(name ?? "") && ["FOUNDATION_RECORD_CONFLICT", "FOUNDATION_INPUT_REQUIRED"].includes(code2);
6821
+ return capabilityRejectedErrorCodes.includes(code2) || name === "cf_adopt_discovered_knowledge" && [
6822
+ "KNOWLEDGE_DISCOVERY_IDENTITY_CHANGED",
6823
+ "KNOWLEDGE_DISCOVERY_FORBIDDEN",
6824
+ "KNOWLEDGE_DISCOVERY_TEXT_TOO_LARGE",
6825
+ "KNOWLEDGE_DISCOVERY_TEXT_UNSUPPORTED",
6826
+ "KNOWLEDGE_DISCOVERY_UNAVAILABLE",
6827
+ "KNOWLEDGE_CATALOG_UNAVAILABLE",
6828
+ "KNOWLEDGE_CATALOG_INVALID",
6829
+ "KNOWLEDGE_CATALOG_SCOPE_NOT_CONFIGURED",
6830
+ "KNOWLEDGE_PROVIDER_AUTH_REQUIRED",
6831
+ "KNOWLEDGE_TENANT_IDENTITY_CHANGED"
6832
+ ].includes(code2) || code2 === "INVALID_CURSOR" && isChangeAcknowledgement(name) || surveyWrites.includes(name ?? "") && surveyRejections.includes(code2) || researchWrites.includes(name ?? "") && ["FOUNDATION_RECORD_CONFLICT", "FOUNDATION_INPUT_REQUIRED"].includes(code2);
6758
6833
  }
6759
6834
  var recoveries = {
6760
6835
  CAPABILITY_SCHEMA_CHANGED: "READ_EXACT_SCHEMA",
@@ -6826,6 +6901,167 @@ function capabilityRecovery(code2, outcome, name) {
6826
6901
  return "CHECK_ACCESS_OR_REFRESH_EXACT_INPUT";
6827
6902
  }
6828
6903
 
6904
+ // packages/contracts/src/event-exchange.ts
6905
+ import { z as z99 } from "zod";
6906
+
6907
+ // packages/contracts/src/event-exchange-browser.ts
6908
+ import { z as z98 } from "zod";
6909
+ var ref2 = z98.string().min(1).max(2048);
6910
+ var eventExchangeSourceSchema = z98.object({ source: ref2, serviceRef: ref2, tenantRef: ref2, issuer: ref2, subject: ref2 }).strict();
6911
+ var eventExchangeTargetSchema = z98.object({ serviceRef: ref2, tenantRef: ref2 }).strict();
6912
+ var eventExchangeBrowserCommandSchema = z98.object({
6913
+ schemaVersion: z98.literal(1),
6914
+ requestId: z98.string().min(1).max(256),
6915
+ expectedRevision: z98.number().int().positive().nullable(),
6916
+ source: eventExchangeSourceSchema,
6917
+ target: eventExchangeTargetSchema,
6918
+ grant: z98.object({
6919
+ grantRef: z98.string().min(1).max(256),
6920
+ version: z98.number().int().positive(),
6921
+ eventType: z98.string().min(1).max(256),
6922
+ consumerRef: ref2
6923
+ }).strict(),
6924
+ status: z98.enum(["ACTIVE", "REVOKED"])
6925
+ }).strict();
6926
+
6927
+ // packages/contracts/src/event-exchange.ts
6928
+ var eventExchangePageQuerySchema = z99.object({
6929
+ after: z99.string().max(256).default(""),
6930
+ limit: z99.number().int().min(1).max(100).default(50)
6931
+ }).strict();
6932
+ var eventExchangeReceiptQuerySchema = z99.object({ requestId: z99.string().min(1).max(256) }).strict();
6933
+ var knowledgeRefreshRevisionSchema = z99.object({
6934
+ schemaVersion: z99.literal(1),
6935
+ revision: z99.string().regex(/^\d+$/),
6936
+ recordedAt: z99.string().datetime().nullable(),
6937
+ baselines: z99.array(
6938
+ z99.object({
6939
+ connectionRef: z99.string(),
6940
+ source: z99.string(),
6941
+ baselineRef: z99.string(),
6942
+ watermark: z99.string().regex(/^\d+$/),
6943
+ sourceRevision: z99.string()
6944
+ }).strict()
6945
+ ).max(100).default([]),
6946
+ baselinesTruncated: z99.boolean().default(false)
6947
+ }).strict();
6948
+ var exchangeStatus = z99.enum(["ACTIVE", "REVOKED"]);
6949
+ var direction = z99.enum(["OUTBOUND", "RECEIVE"]);
6950
+ var eventExchangeResultSchema = z99.object({
6951
+ schemaVersion: z99.literal(1),
6952
+ connectionRef: z99.string().regex(/^urn:eventsdk:connection:[a-f0-9]{64}$/),
6953
+ revision: z99.number().int().positive(),
6954
+ direction,
6955
+ status: exchangeStatus,
6956
+ grantRef: z99.string().min(1).max(256),
6957
+ grantVersion: z99.number().int().positive(),
6958
+ eventType: z99.string().optional()
6959
+ }).strict();
6960
+ var eventExchangeReceiptSchema = z99.object({
6961
+ schemaVersion: z99.literal(1),
6962
+ requestId: z99.string().min(1).max(256),
6963
+ result: eventExchangeResultSchema.nullable()
6964
+ }).strict();
6965
+ var eventExchangePageSchema = z99.object({
6966
+ schemaVersion: z99.literal(1),
6967
+ localTenant: eventExchangeTargetSchema.optional(),
6968
+ items: z99.array(
6969
+ eventExchangeResultSchema.pick({
6970
+ connectionRef: true,
6971
+ revision: true,
6972
+ direction: true,
6973
+ status: true
6974
+ }).extend({
6975
+ source: eventExchangeSourceSchema.optional(),
6976
+ target: eventExchangeTargetSchema.optional(),
6977
+ grantsTruncated: z99.boolean().optional(),
6978
+ grants: z99.array(
6979
+ z99.object({
6980
+ eventType: z99.string(),
6981
+ grantRef: z99.string(),
6982
+ grantVersion: z99.number().int().positive(),
6983
+ consumerRef: z99.string().optional(),
6984
+ source: eventExchangeSourceSchema.optional(),
6985
+ target: eventExchangeTargetSchema.optional(),
6986
+ status: exchangeStatus
6987
+ }).strict()
6988
+ ).max(100).optional()
6989
+ })
6990
+ ).max(100),
6991
+ nextAfter: z99.string().max(256).nullable()
6992
+ }).strict();
6993
+
6994
+ // packages/contracts/src/knowledge-discovery.ts
6995
+ import { z as z100 } from "zod";
6996
+ var knowledgeRemoteRefSchema = z100.string().min(1).max(4096).refine((value) => {
6997
+ try {
6998
+ const url = new URL(value);
6999
+ return !url.username && !url.password && /^[a-z][a-z0-9+.-]*:$/.test(url.protocol);
7000
+ } catch {
7001
+ return false;
7002
+ }
7003
+ });
7004
+ var knowledgeDiscoveryQuerySchema = z100.object({
7005
+ q: z100.string().trim().min(2).max(160).optional(),
7006
+ cursor: z100.string().min(1).max(8192).optional(),
7007
+ resourceType: z100.string().regex(/^[a-z][a-z0-9._-]{0,63}$/).optional(),
7008
+ limit: z100.number().int().min(1).max(50).default(20)
7009
+ }).strict();
7010
+ var knowledgeDiscoveryReadQuerySchema = z100.object({
7011
+ ref: knowledgeRemoteRefSchema,
7012
+ expectedContentHash: z100.string().regex(/^sha256:[a-f0-9]{64}$/).optional()
7013
+ }).strict();
7014
+ var knowledgeDiscoveryItemSchema = z100.object({
7015
+ ref: knowledgeRemoteRefSchema,
7016
+ ownerTenantId: z100.string().min(1).max(256),
7017
+ resourceType: z100.string().min(1).max(128),
7018
+ originType: z100.enum(["LEGACY_PROJECT", "TENANT_AUTHOR", "TENANT_SOURCE"]),
7019
+ identityHash: z100.string().regex(/^sha256:[a-f0-9]{64}$/),
7020
+ identityKind: z100.enum(["CAS_BYTES", "REFERENCE_RECORD_DIGEST"]),
7021
+ kind: z100.string().min(1).max(128),
7022
+ classification: z100.string().max(128),
7023
+ mediaType: z100.string().min(1).max(256),
7024
+ title: z100.string().max(512),
7025
+ summary: z100.string().max(1024),
7026
+ readable: z100.boolean(),
7027
+ reasonCodes: z100.array(z100.string().max(128)).max(32)
7028
+ });
7029
+ var knowledgeDiscoveryPageSchema = z100.object({
7030
+ schemaVersion: z100.literal(1),
7031
+ sourceTenantId: z100.string().min(1).max(256),
7032
+ items: z100.array(knowledgeDiscoveryItemSchema).max(50),
7033
+ pageInfo: z100.object({ nextCursor: z100.string().max(8192).nullable() }).strict(),
7034
+ coverage: z100.enum(["CURRENT_AUTHORIZED_DIRECTORY", "INDEXED_DESCRIPTIONS_ONLY"]),
7035
+ checkedAt: z100.string().datetime()
7036
+ }).strict();
7037
+ var knowledgeDiscoveryReadSchema = z100.object({
7038
+ schemaVersion: z100.literal(1),
7039
+ sourceTenantId: z100.string().min(1).max(256),
7040
+ item: knowledgeDiscoveryItemSchema,
7041
+ contentHash: z100.string().regex(/^sha256:[a-f0-9]{64}$/),
7042
+ mediaType: z100.string().min(1).max(256),
7043
+ byteLength: z100.number().int().min(0).max(524288),
7044
+ content: z100.string().max(524288),
7045
+ verified: z100.literal(true),
7046
+ checkedAt: z100.string().datetime()
7047
+ }).strict();
7048
+ var knowledgeAdoptionCommandSchema = knowledgeDiscoveryReadQuerySchema.required().extend({
7049
+ requestId: z100.string().min(1).max(128)
7050
+ }).strict();
7051
+ var knowledgeAdoptionResultSchema = z100.object({ result: sourceRefSchema, replayed: z100.boolean() }).strict();
7052
+ var knowledgeAdoptionReceiptQuerySchema = z100.object({ requestId: z100.string().min(1).max(128) }).strict();
7053
+ var knowledgeAdoptionReceiptSchema = z100.discriminatedUnion("state", [
7054
+ z100.object({ state: z100.literal("FOUND"), result: sourceRefSchema }).strict(),
7055
+ z100.object({ state: z100.literal("NOT_FOUND"), result: z100.null() }).strict(),
7056
+ commandRejectedReceiptSchema
7057
+ ]);
7058
+ var adoptedKnowledgeResourceSchema = z100.object({
7059
+ schemaVersion: z100.literal(1),
7060
+ sourceTenantId: z100.string().min(1).max(256),
7061
+ ref: knowledgeRemoteRefSchema,
7062
+ identityHash: z100.string().regex(/^sha256:[a-f0-9]{64}$/)
7063
+ }).strict();
7064
+
6829
7065
  // packages/contracts/src/agent/capability-receipts.ts
6830
7066
  var rule = (capability, schema2, operation, keys = [], field) => ({ capability, schema: schema2, operation, keys, field });
6831
7067
  var foundation = (operation, field) => rule(
@@ -6847,6 +7083,20 @@ var execution = (family, operation) => ({
6847
7083
  });
6848
7084
  var learning = (op) => rule("cf_get_learning_command_receipt", learningReceiptSchema, op);
6849
7085
  var rules = {
7086
+ cf_configure_event_exchange: rule(
7087
+ "cf_get_event_exchange_receipt",
7088
+ eventExchangeReceiptQuerySchema
7089
+ ),
7090
+ cf_recover_event_outbox: rule(
7091
+ "cf_get_event_outbox_recovery_receipt",
7092
+ eventExchangeReceiptQuerySchema
7093
+ ),
7094
+ cf_adopt_discovered_knowledge: rule(
7095
+ "cf_get_knowledge_adoption_receipt",
7096
+ knowledgeAdoptionReceiptQuerySchema
7097
+ ),
7098
+ cf_save_test_record: rule("cf_get_test_record_receipt", testRecordReceiptSchema, "SAVE"),
7099
+ cf_cleanup_test_records: rule("cf_get_test_record_receipt", testRecordReceiptSchema, "CLEANUP"),
6850
7100
  cf_register_source: rule(
6851
7101
  "cf_get_source_registration_receipt",
6852
7102
  sourceRegistrationReceiptQuerySchema,
@@ -7056,7 +7306,7 @@ function capabilityReceiptRead(name, input) {
7056
7306
  }
7057
7307
 
7058
7308
  // packages/contracts/src/agent/capability-status.ts
7059
- import { z as z96 } from "zod";
7309
+ import { z as z101 } from "zod";
7060
7310
  var verification = {
7061
7311
  capability: "cf_material_verification_status",
7062
7312
  schema: materialVerificationIdSchema,
@@ -7074,7 +7324,7 @@ var rules2 = {
7074
7324
  },
7075
7325
  cf_tenant_material_scan_advance: {
7076
7326
  capability: "cf_tenant_material_scan_status",
7077
- schema: z96.object({}).strict()
7327
+ schema: z101.object({}).strict()
7078
7328
  },
7079
7329
  cf_sync_materials: {
7080
7330
  capability: "cf_reconcile_materials",
@@ -7101,12 +7351,6 @@ function capabilityStatusRead(name, input) {
7101
7351
  };
7102
7352
  }
7103
7353
 
7104
- // packages/cli-client/src/profile.ts
7105
- import { mkdir, lstat, open as open2, rename, unlink } from "node:fs/promises";
7106
- import { randomUUID } from "node:crypto";
7107
- import { homedir } from "node:os";
7108
- import { join } from "node:path";
7109
-
7110
7354
  // packages/cli-client/src/errors.ts
7111
7355
  var CliError = class extends Error {
7112
7356
  constructor(code2, message, outcome = "NOT_SENT", details) {
@@ -7132,6 +7376,154 @@ function safeError(error) {
7132
7376
  };
7133
7377
  }
7134
7378
 
7379
+ // packages/cli-client/src/capability-definition.ts
7380
+ function verifyCapabilityDefinition(raw, name, expectedHash) {
7381
+ const fail = () => new CliError(
7382
+ "INVALID_CAPABILITY_REPLY",
7383
+ "The exact capability definition or fingerprint is invalid.",
7384
+ "REJECTED"
7385
+ );
7386
+ if (Buffer.byteLength(JSON.stringify(raw) ?? "") > 68 * 1024) throw fail();
7387
+ const parsed = capabilityDefinitionSchema.safeParse(raw);
7388
+ if (!parsed.success || parsed.data.definition.name !== name || parsed.data.definition.inputSchema.type !== "object" || expectedHash && parsed.data.schemaSha256 !== expectedHash)
7389
+ throw fail();
7390
+ try {
7391
+ const hash5 = createHash("sha256").update(
7392
+ executionCanonicalJson(parsed.data.definition, {
7393
+ maxDepth: 32,
7394
+ maxNodes: 20100,
7395
+ maxLength: 11e4
7396
+ })
7397
+ ).digest("hex");
7398
+ if (hash5 !== parsed.data.schemaSha256) throw fail();
7399
+ } catch {
7400
+ throw fail();
7401
+ }
7402
+ return parsed.data;
7403
+ }
7404
+ var CapabilityDefinitionCache = class {
7405
+ values = /* @__PURE__ */ new Map();
7406
+ remember(value) {
7407
+ const verified = verifyCapabilityDefinition(value, value.definition.name);
7408
+ const key2 = `${verified.definition.name}:AGENT_V3:${verified.schemaSha256}`;
7409
+ if (this.values.size >= 64) this.values.delete(this.values.keys().next().value);
7410
+ this.values.set(key2, structuredClone(verified));
7411
+ }
7412
+ get(name, hash5) {
7413
+ const value = this.values.get(`${name}:AGENT_V3:${hash5}`);
7414
+ return value ? structuredClone(value) : void 0;
7415
+ }
7416
+ };
7417
+
7418
+ // packages/cli-client/src/capability-errors.ts
7419
+ function capabilityError(tool5, data, readOnly = true, input) {
7420
+ if (!/^cf_[a-z0-9_]{1,100}$/.test(tool5) || !data || typeof data !== "object" || !("error" in data))
7421
+ return null;
7422
+ const error = data.error;
7423
+ if (!error || typeof error !== "object" || !("code" in error) || typeof error.code !== "string" || !/^[A-Z0-9_]{1,100}$/u.test(error.code))
7424
+ return null;
7425
+ const code2 = error.code;
7426
+ const outcome = "outcome" in error && error.outcome === "UNKNOWN" ? "UNKNOWN" : "outcome" in error && error.outcome === "REJECTED" || readOnly || isKnownCapabilityRejection(code2, tool5) ? "REJECTED" : "UNKNOWN";
7427
+ const recovery = capabilityRecovery(code2, outcome, tool5);
7428
+ const receipt = outcome === "UNKNOWN" || recovery === "FIND_ORIGINAL_RECEIPT" ? capabilityReceiptRead(tool5, input) : void 0;
7429
+ const status = outcome === "UNKNOWN" ? capabilityStatusRead(tool5, input) : void 0;
7430
+ const validation = code2 === "CAPABILITY_INPUT_INVALID" && outcome === "REJECTED" && "validation" in error && Buffer.byteLength(JSON.stringify(error.validation) ?? "") <= 4096 ? capabilityInputRepairSchema.safeParse(error.validation) : null;
7431
+ const delegatedTarget = tool5 === "cf_validate_capability" && input && typeof input === "object" && Object.hasOwn(input, "name") ? input.name : void 0;
7432
+ const validationMatches = validation?.success && (validation.data.schema.arguments.name === tool5 || typeof delegatedTarget === "string" && validation.data.schema.arguments.name === delegatedTarget);
7433
+ return new CliError(
7434
+ code2,
7435
+ "The capability operation was not completed. Follow the indicated recovery before another operation.",
7436
+ outcome,
7437
+ {
7438
+ recovery,
7439
+ ...receipt ? { receipt } : {},
7440
+ ...status ? { status } : {},
7441
+ ...validation?.success && validationMatches ? { validation: validation.data } : {}
7442
+ }
7443
+ );
7444
+ }
7445
+
7446
+ // packages/cli-client/src/transport.ts
7447
+ import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
7448
+
7449
+ // packages/cli-client/src/http.ts
7450
+ function boundedFetch(origin2, timeout) {
7451
+ return async (input, init) => {
7452
+ const requestUrl = new URL(input instanceof Request ? input.url : String(input));
7453
+ if (requestUrl.origin !== origin2 || requestUrl.username || requestUrl.password)
7454
+ throw new CliError("UNTRUSTED_ENDPOINT", "Cross-origin credential requests are forbidden.");
7455
+ const signal = AbortSignal.any([
7456
+ AbortSignal.timeout(timeout),
7457
+ ...init?.signal ? [init.signal] : []
7458
+ ]);
7459
+ const response = await fetch(input, { ...init, signal, redirect: "error" });
7460
+ if (!response.body) return response;
7461
+ const reader = response.body.getReader();
7462
+ const chunks = [];
7463
+ let length = 0;
7464
+ try {
7465
+ for (; ; ) {
7466
+ const { done, value } = await reader.read();
7467
+ if (done) break;
7468
+ length += value.length;
7469
+ if (length > 8 * 1024 * 1024)
7470
+ throw new CliError("RESPONSE_TOO_LARGE", "Response exceeds 8 MiB. Read a smaller page.");
7471
+ chunks.push(value);
7472
+ }
7473
+ } catch (error) {
7474
+ await reader.cancel().catch(() => void 0);
7475
+ throw error;
7476
+ } finally {
7477
+ reader.releaseLock();
7478
+ }
7479
+ return new Response([204, 205, 304].includes(response.status) ? null : Buffer.concat(chunks), {
7480
+ status: response.status,
7481
+ statusText: response.statusText,
7482
+ headers: response.headers
7483
+ });
7484
+ };
7485
+ }
7486
+ async function oauthPost(resource, path, body, timeout) {
7487
+ const origin2 = new URL(resource).origin;
7488
+ let response;
7489
+ try {
7490
+ response = await boundedFetch(origin2, timeout)(`${origin2}${path}`, {
7491
+ method: "POST",
7492
+ headers: {
7493
+ "content-type": body instanceof URLSearchParams ? "application/x-www-form-urlencoded" : "application/json"
7494
+ },
7495
+ body: body instanceof URLSearchParams ? body.toString() : JSON.stringify(body)
7496
+ });
7497
+ } catch {
7498
+ throw new CliError(
7499
+ "OAUTH_NETWORK_FAILURE",
7500
+ "OAuth request failed; no automatic retry was made.",
7501
+ "UNKNOWN"
7502
+ );
7503
+ }
7504
+ if (!response.ok)
7505
+ throw new CliError(
7506
+ "OAUTH_REJECTED",
7507
+ "CF rejected the OAuth request. Reauthorize if the grant expired or was revoked.",
7508
+ "REJECTED"
7509
+ );
7510
+ try {
7511
+ return await response.json();
7512
+ } catch {
7513
+ throw new CliError(
7514
+ "INVALID_OAUTH_RESPONSE",
7515
+ "CF returned an invalid OAuth response.",
7516
+ "UNKNOWN"
7517
+ );
7518
+ }
7519
+ }
7520
+
7521
+ // packages/cli-client/src/profile.ts
7522
+ import { mkdir, lstat, open as open2, rename, unlink } from "node:fs/promises";
7523
+ import { randomUUID } from "node:crypto";
7524
+ import { homedir } from "node:os";
7525
+ import { join } from "node:path";
7526
+
7135
7527
  // packages/cli-client/src/input.ts
7136
7528
  import { open } from "node:fs/promises";
7137
7529
  import { constants } from "node:fs";
@@ -7278,101 +7670,6 @@ var ProfileStore = class {
7278
7670
  }
7279
7671
  };
7280
7672
 
7281
- // packages/cli-client/src/capability-errors.ts
7282
- function capabilityError(tool4, data, readOnly = true, input) {
7283
- if (!/^cf_[a-z0-9_]{1,100}$/.test(tool4) || !data || typeof data !== "object" || !("error" in data))
7284
- return null;
7285
- const error = data.error;
7286
- if (!error || typeof error !== "object" || !("code" in error) || typeof error.code !== "string" || !/^[A-Z0-9_]{1,100}$/u.test(error.code))
7287
- return null;
7288
- const code2 = error.code;
7289
- const outcome = "outcome" in error && error.outcome === "UNKNOWN" ? "UNKNOWN" : "outcome" in error && error.outcome === "REJECTED" || readOnly || isKnownCapabilityRejection(code2, tool4) ? "REJECTED" : "UNKNOWN";
7290
- const recovery = capabilityRecovery(code2, outcome, tool4);
7291
- const receipt = outcome === "UNKNOWN" || recovery === "FIND_ORIGINAL_RECEIPT" ? capabilityReceiptRead(tool4, input) : void 0;
7292
- const status = outcome === "UNKNOWN" ? capabilityStatusRead(tool4, input) : void 0;
7293
- return new CliError(
7294
- code2,
7295
- "The capability operation was not completed. Follow the indicated recovery before another operation.",
7296
- outcome,
7297
- { recovery, ...receipt ? { receipt } : {}, ...status ? { status } : {} }
7298
- );
7299
- }
7300
-
7301
- // packages/cli-client/src/transport.ts
7302
- import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
7303
-
7304
- // packages/cli-client/src/http.ts
7305
- function boundedFetch(origin2, timeout) {
7306
- return async (input, init) => {
7307
- const requestUrl = new URL(input instanceof Request ? input.url : String(input));
7308
- if (requestUrl.origin !== origin2 || requestUrl.username || requestUrl.password)
7309
- throw new CliError("UNTRUSTED_ENDPOINT", "Cross-origin credential requests are forbidden.");
7310
- const signal = AbortSignal.any([
7311
- AbortSignal.timeout(timeout),
7312
- ...init?.signal ? [init.signal] : []
7313
- ]);
7314
- const response = await fetch(input, { ...init, signal, redirect: "error" });
7315
- if (!response.body) return response;
7316
- const reader = response.body.getReader();
7317
- const chunks = [];
7318
- let length = 0;
7319
- try {
7320
- for (; ; ) {
7321
- const { done, value } = await reader.read();
7322
- if (done) break;
7323
- length += value.length;
7324
- if (length > 8 * 1024 * 1024)
7325
- throw new CliError("RESPONSE_TOO_LARGE", "Response exceeds 8 MiB. Read a smaller page.");
7326
- chunks.push(value);
7327
- }
7328
- } catch (error) {
7329
- await reader.cancel().catch(() => void 0);
7330
- throw error;
7331
- } finally {
7332
- reader.releaseLock();
7333
- }
7334
- return new Response([204, 205, 304].includes(response.status) ? null : Buffer.concat(chunks), {
7335
- status: response.status,
7336
- statusText: response.statusText,
7337
- headers: response.headers
7338
- });
7339
- };
7340
- }
7341
- async function oauthPost(resource, path, body, timeout) {
7342
- const origin2 = new URL(resource).origin;
7343
- let response;
7344
- try {
7345
- response = await boundedFetch(origin2, timeout)(`${origin2}${path}`, {
7346
- method: "POST",
7347
- headers: {
7348
- "content-type": body instanceof URLSearchParams ? "application/x-www-form-urlencoded" : "application/json"
7349
- },
7350
- body: body instanceof URLSearchParams ? body.toString() : JSON.stringify(body)
7351
- });
7352
- } catch {
7353
- throw new CliError(
7354
- "OAUTH_NETWORK_FAILURE",
7355
- "OAuth request failed; no automatic retry was made.",
7356
- "UNKNOWN"
7357
- );
7358
- }
7359
- if (!response.ok)
7360
- throw new CliError(
7361
- "OAUTH_REJECTED",
7362
- "CF rejected the OAuth request. Reauthorize if the grant expired or was revoked.",
7363
- "REJECTED"
7364
- );
7365
- try {
7366
- return await response.json();
7367
- } catch {
7368
- throw new CliError(
7369
- "INVALID_OAUTH_RESPONSE",
7370
- "CF returned an invalid OAuth response.",
7371
- "UNKNOWN"
7372
- );
7373
- }
7374
- }
7375
-
7376
7673
  // packages/cli-client/src/knowledge-errors.ts
7377
7674
  var codes = /* @__PURE__ */ new Set([
7378
7675
  "FORBIDDEN",
@@ -7402,13 +7699,13 @@ var codes = /* @__PURE__ */ new Set([
7402
7699
  "MCP_KNOWLEDGE_ENCODING_INVALID",
7403
7700
  "MCP_KNOWLEDGE_UNAVAILABLE"
7404
7701
  ]);
7405
- function knowledgeError(tool4, raw) {
7702
+ function knowledgeError(tool5, raw) {
7406
7703
  if (![
7407
7704
  "cf_list_knowledge",
7408
7705
  "cf_read_knowledge",
7409
7706
  "cf_read_source",
7410
7707
  "cf_material_verification_status"
7411
- ].includes(tool4))
7708
+ ].includes(tool5))
7412
7709
  return null;
7413
7710
  const value = object2(raw), error = object2(value?.error);
7414
7711
  if (!error || typeof error.code !== "string" || !codes.has(error.code)) return null;
@@ -7417,7 +7714,9 @@ function knowledgeError(tool4, raw) {
7417
7714
  if (typeof error.checkedAt === "string" && /^\d{4}-\d{2}-\d{2}T[\d:.]+Z$/.test(error.checkedAt))
7418
7715
  details.checkedAt = error.checkedAt;
7419
7716
  const descriptor = object2(error.descriptor);
7420
- if (descriptor && typeof descriptor.readingPath === "string" && /^\/projects\/PRJ-\d{6,}\/knowledge\/library\/[0-9a-f-]{36}$/i.test(descriptor.readingPath))
7717
+ if (descriptor && typeof descriptor.readingPath === "string" && /^\/(?:projects\/PRJ|tenants\/TEN)-\d{6,}\/knowledge\/library\/[0-9a-f-]{36}$/i.test(
7718
+ descriptor.readingPath
7719
+ ))
7421
7720
  details.readingPath = descriptor.readingPath;
7422
7721
  return new CliError(
7423
7722
  error.code,
@@ -7462,8 +7761,8 @@ async function withClient(profile, timeout, operation) {
7462
7761
  await client.close().catch(() => void 0);
7463
7762
  }
7464
7763
  }
7465
- async function callTool(client, tool4, input, timeout, readOnly, errorToolName = tool4.name) {
7466
- const original = ["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(tool4.name) && input.name === errorToolName ? input.arguments : input;
7764
+ async function callTool(client, tool5, input, timeout, readOnly, errorToolName = tool5.name) {
7765
+ const original = ["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(tool5.name) && input.name === errorToolName ? input.arguments : input;
7467
7766
  const unknown = (code2, message) => {
7468
7767
  const receipt = capabilityReceiptRead(errorToolName, original);
7469
7768
  const status = capabilityStatusRead(errorToolName, original);
@@ -7476,8 +7775,8 @@ async function callTool(client, tool4, input, timeout, readOnly, errorToolName =
7476
7775
  let result2;
7477
7776
  try {
7478
7777
  result2 = await client.callTool(
7479
- { name: tool4.name, arguments: input },
7480
- { timeout, toolDefinition: tool4, allowInputRequired: true }
7778
+ { name: tool5.name, arguments: input },
7779
+ { timeout, toolDefinition: tool5, allowInputRequired: true }
7481
7780
  );
7482
7781
  } catch {
7483
7782
  if (!readOnly)
@@ -7554,9 +7853,47 @@ function decodedText(content) {
7554
7853
  }
7555
7854
  }
7556
7855
 
7856
+ // packages/cli-client/src/agent-capabilities.ts
7857
+ var tool = {
7858
+ name: "cf_discover_capabilities",
7859
+ inputSchema: {
7860
+ type: "object",
7861
+ ...capabilityQuerySchema["~standard"].jsonSchema.input({ target: "draft-2020-12" })
7862
+ },
7863
+ annotations: { readOnlyHint: true, openWorldHint: false }
7864
+ };
7865
+ async function findAgentCapabilities(client, input = {}, timeout = 3e4) {
7866
+ if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4)
7867
+ throw new CliError("INVALID_TIMEOUT", "Timeout must be 100\u2013120000 milliseconds.");
7868
+ const query = capabilityQuerySchema.safeParse({ ...input, profile: "AGENT_V3" });
7869
+ if (!query.success)
7870
+ throw new CliError(
7871
+ "INVALID_CAPABILITY_QUERY",
7872
+ "Use a bounded query and optional group/limit/cursor."
7873
+ );
7874
+ const raw = await callTool(client, tool, query.data, timeout, true);
7875
+ if (Buffer.byteLength(JSON.stringify(raw) ?? "") > 8192) throw invalid();
7876
+ const parsed = agentCapabilityPageSchema.safeParse(raw);
7877
+ if (!parsed.success) throw invalid();
7878
+ for (const item of parsed.data.items) {
7879
+ if (item.definition) {
7880
+ if (!item.schemaSha256) throw invalid();
7881
+ verifyCapabilityDefinition(item.definition, item.name, item.schemaSha256);
7882
+ }
7883
+ }
7884
+ return parsed.data;
7885
+ }
7886
+ function invalid() {
7887
+ return new CliError(
7888
+ "INVALID_CAPABILITY_REPLY",
7889
+ "The discovery response does not match AGENT_V3 or its byte limit.",
7890
+ "REJECTED"
7891
+ );
7892
+ }
7893
+
7557
7894
  // packages/cli-client/src/schema-pages.ts
7558
- import { createHash } from "node:crypto";
7559
- var tool = (name, schema2) => ({
7895
+ import { createHash as createHash2 } from "node:crypto";
7896
+ var tool2 = (name, schema2) => ({
7560
7897
  name,
7561
7898
  inputSchema: {
7562
7899
  type: "object",
@@ -7564,28 +7901,28 @@ var tool = (name, schema2) => ({
7564
7901
  },
7565
7902
  annotations: { readOnlyHint: true }
7566
7903
  });
7567
- var describe = tool("cf_describe_capability", capabilityDescribeSchema);
7568
- var read = tool("cf_read_capability_schema", capabilitySchemaReadSchema);
7904
+ var describe = tool2("cf_describe_capability", capabilityDescribeSchema);
7905
+ var read = tool2("cf_read_capability_schema", capabilitySchemaReadSchema);
7569
7906
  async function readNativeCapabilityDescriptor(client, name, timeout = 3e4) {
7570
- if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid("NOT_SENT");
7907
+ if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid2("NOT_SENT");
7571
7908
  const input = capabilityDescribeSchema.safeParse({ name });
7572
- if (!input.success) throw invalid("NOT_SENT");
7909
+ if (!input.success) throw invalid2("NOT_SENT");
7573
7910
  const raw = await callTool(client, describe, input.data, timeout, true), result2 = capabilityDescriptorSchema.safeParse(raw);
7574
- if (!result2.success || Buffer.byteLength(JSON.stringify(raw)) > 8 * 1024) throw invalid();
7911
+ if (!result2.success || Buffer.byteLength(JSON.stringify(raw)) > 8 * 1024) throw invalid2();
7575
7912
  if ((result2.data.schemaVersion === 1 ? result2.data.definition.name : result2.data.name) !== name)
7576
- throw invalid();
7913
+ throw invalid2();
7577
7914
  return result2.data;
7578
7915
  }
7579
7916
  async function readNativeCapabilitySchemaPage(client, input, timeout = 3e4) {
7580
- if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid("NOT_SENT");
7917
+ if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid2("NOT_SENT");
7581
7918
  const query = capabilitySchemaReadSchema.safeParse(input);
7582
- if (!query.success) throw invalid("NOT_SENT");
7919
+ if (!query.success) throw invalid2("NOT_SENT");
7583
7920
  const raw = await callTool(client, read, query.data, timeout, true);
7584
7921
  const parsed = capabilitySchemaPageSchema.safeParse(raw);
7585
- if (!parsed.success || Buffer.byteLength(JSON.stringify(raw)) > 6e3) throw invalid();
7922
+ if (!parsed.success || Buffer.byteLength(JSON.stringify(raw)) > 6e3) throw invalid2();
7586
7923
  const p = parsed.data, end = p.offset + [...p.text].length;
7587
7924
  if (p.name !== query.data.name || p.schemaSha256 !== query.data.expectedSchemaSha256 || p.offset !== query.data.offset || !p.text || p.totalCharacters > 7e4 || (p.hasMore ? p.nextOffset !== end || end >= p.totalCharacters : p.nextOffset !== null || end !== p.totalCharacters))
7588
- throw invalid();
7925
+ throw invalid2();
7589
7926
  return p;
7590
7927
  }
7591
7928
  async function loadCapabilitySchemaPages(client, descriptor, timeout) {
@@ -7593,7 +7930,7 @@ async function loadCapabilitySchemaPages(client, descriptor, timeout) {
7593
7930
  let offset = 0, contentHash, total;
7594
7931
  for (let i = 0; i < 128; i++) {
7595
7932
  const remaining = deadline - Date.now();
7596
- if (remaining < 100) throw invalid();
7933
+ if (remaining < 100) throw invalid2();
7597
7934
  const p = await readNativeCapabilitySchemaPage(
7598
7935
  client,
7599
7936
  { name: descriptor.name, expectedSchemaSha256: descriptor.schemaSha256, offset },
@@ -7601,25 +7938,25 @@ async function loadCapabilitySchemaPages(client, descriptor, timeout) {
7601
7938
  );
7602
7939
  const end = offset + [...p.text].length;
7603
7940
  if (p.name !== descriptor.name || p.schemaSha256 !== descriptor.schemaSha256 || p.offset !== offset || !p.text || contentHash && p.contentSha256 !== contentHash || total && total !== p.totalCharacters || p.totalCharacters > 7e4 || (p.hasMore ? p.nextOffset !== end || end >= p.totalCharacters : p.nextOffset !== null || end !== p.totalCharacters))
7604
- throw invalid();
7941
+ throw invalid2();
7605
7942
  contentHash = p.contentSha256;
7606
7943
  total = p.totalCharacters;
7607
7944
  parts.push(p.text);
7608
7945
  if (!p.hasMore) {
7609
7946
  const text3 = parts.join("");
7610
- if (Buffer.byteLength(text3) !== descriptor.byteLength || createHash("sha256").update(text3).digest("hex") !== contentHash)
7611
- throw invalid();
7947
+ if (Buffer.byteLength(text3) !== descriptor.byteLength || createHash2("sha256").update(text3).digest("hex") !== contentHash)
7948
+ throw invalid2();
7612
7949
  try {
7613
7950
  return JSON.parse(text3);
7614
7951
  } catch {
7615
- throw invalid();
7952
+ throw invalid2();
7616
7953
  }
7617
7954
  }
7618
7955
  offset = end;
7619
7956
  }
7620
- throw invalid();
7957
+ throw invalid2();
7621
7958
  }
7622
- function invalid(outcome = "REJECTED") {
7959
+ function invalid2(outcome = "REJECTED") {
7623
7960
  return new CliError(
7624
7961
  "INVALID_CAPABILITY_REPLY",
7625
7962
  "Capability descriptor/schema pages did not match their bounded identity and hashes.",
@@ -7628,9 +7965,7 @@ function invalid(outcome = "REJECTED") {
7628
7965
  }
7629
7966
 
7630
7967
  // packages/cli-client/src/capabilities.ts
7631
- import { createHash as createHash2 } from "node:crypto";
7632
7968
  var maxPage = 8 * 1024;
7633
- var maxDefinition = 68 * 1024;
7634
7969
  function bootstrap(name, inputSchema) {
7635
7970
  return { name, inputSchema, annotations: { readOnlyHint: true, openWorldHint: false } };
7636
7971
  }
@@ -7640,6 +7975,11 @@ var queryTool = bootstrap("cf_discover_capabilities", {
7640
7975
  });
7641
7976
  async function findNativeCapabilities(client, input = {}, timeout = 3e4) {
7642
7977
  checkTimeout(timeout);
7978
+ if (input.profile)
7979
+ throw new CliError(
7980
+ "INVALID_CAPABILITY_QUERY",
7981
+ "Use findAgentCapabilities for the AGENT_V3 profile."
7982
+ );
7643
7983
  const query = capabilityQuerySchema.safeParse(input);
7644
7984
  if (!query.success)
7645
7985
  throw new CliError(
@@ -7648,9 +7988,9 @@ async function findNativeCapabilities(client, input = {}, timeout = 3e4) {
7648
7988
  );
7649
7989
  const raw = await callTool(client, queryTool, query.data, timeout, true);
7650
7990
  if (typeof JSON.stringify(raw) !== "string" || Buffer.byteLength(JSON.stringify(raw)) > maxPage)
7651
- throw invalid2();
7991
+ throw invalid3();
7652
7992
  const result2 = capabilityPageSchema.safeParse(raw);
7653
- if (!result2.success) throw invalid2();
7993
+ if (!result2.success) throw invalid3();
7654
7994
  return result2.data;
7655
7995
  }
7656
7996
  async function describeNativeCapability(client, name, timeout = 3e4) {
@@ -7660,26 +8000,9 @@ async function describeNativeCapability(client, name, timeout = 3e4) {
7660
8000
  throw new CliError("INVALID_CAPABILITY_NAME", "Use an exact cf_ capability name.");
7661
8001
  const descriptor = await readNativeCapabilityDescriptor(client, input.data.name, timeout);
7662
8002
  const raw = descriptor.schemaVersion === 1 ? descriptor : await loadCapabilitySchemaPages(client, descriptor, timeout);
7663
- if (typeof JSON.stringify(raw) !== "string" || Buffer.byteLength(JSON.stringify(raw)) > maxDefinition)
7664
- throw invalid2();
7665
- const result2 = capabilityDefinitionSchema.safeParse(raw);
7666
- if (!result2.success || result2.data.schemaSha256 !== descriptor.schemaSha256 || result2.data.definition.name !== name || result2.data.definition.inputSchema.type !== "object")
7667
- throw invalid2();
7668
- try {
7669
- const hash5 = createHash2("sha256").update(
7670
- executionCanonicalJson(result2.data.definition, {
7671
- maxDepth: 32,
7672
- maxNodes: 20100,
7673
- maxLength: 11e4
7674
- })
7675
- ).digest("hex");
7676
- if (hash5 !== result2.data.schemaSha256) throw invalid2();
7677
- } catch {
7678
- throw invalid2();
7679
- }
7680
- return result2.data;
8003
+ return verifyCapabilityDefinition(raw, name, descriptor.schemaSha256);
7681
8004
  }
7682
- function invalid2() {
8005
+ function invalid3() {
7683
8006
  return new CliError(
7684
8007
  "INVALID_CAPABILITY_REPLY",
7685
8008
  "The capability reply exceeded its limit or did not match its exact contract.",
@@ -7715,8 +8038,8 @@ async function nativeToolDefinition(client, name, timeout) {
7715
8038
  "TOOL_UNAVAILABLE",
7716
8039
  "A typed catalogue page is required; no business call was sent."
7717
8040
  );
7718
- const tool4 = page2.tools.find((t) => t.name === name);
7719
- if (tool4) return { tool: tool4, schemaSha256: null };
8041
+ const tool5 = page2.tools.find((t) => t.name === name);
8042
+ if (tool5) return { tool: tool5, schemaSha256: null };
7720
8043
  if (!page2.nextCursor || seen.has(page2.nextCursor)) break;
7721
8044
  seen.add(page2.nextCursor);
7722
8045
  cursor = page2.nextCursor;
@@ -7761,10 +8084,10 @@ var writeInvoke = {
7761
8084
  async function getNativeBusinessSummary(client, input, timeout = 3e4) {
7762
8085
  checkTimeout2(timeout);
7763
8086
  const query = agentSummaryInputSchema.safeParse(input);
7764
- if (!query.success) throw invalid3("NOT_SENT");
8087
+ if (!query.success) throw invalid4("NOT_SENT");
7765
8088
  const raw = await callTool(client, summary, query.data, timeout, true), parsed = agentSummarySchema.safeParse(raw);
7766
8089
  if (!parsed.success || Buffer.byteLength(JSON.stringify(raw)) > 16 * 1024 || parsed.data.sourceTool !== query.data.sourceTool || query.data.expectedDocumentHash && parsed.data.documentHash !== query.data.expectedDocumentHash || query.data.expectedActionsHash && parsed.data.actionsHash !== query.data.expectedActionsHash || parsed.data.actionPage.offset !== query.data.actionOffset || parsed.data.read.input.sourceTool !== query.data.sourceTool || executionCanonicalJson(parsed.data.read.input.sourceInput) !== executionCanonicalJson(query.data.sourceInput) || parsed.data.read.input.expectedDocumentHash !== parsed.data.documentHash || (parsed.data.actionPage.hasMore ? parsed.data.actionPage.nextOffset !== query.data.actionOffset + parsed.data.nextActions.length : parsed.data.actionPage.nextOffset !== null))
7767
- throw invalid3();
8090
+ throw invalid4();
7768
8091
  return parsed.data;
7769
8092
  }
7770
8093
  async function callNativeCapability(client, input, timeout = 3e4) {
@@ -7776,13 +8099,13 @@ async function readNativeCapability(client, input, timeout = 3e4) {
7776
8099
  async function writeNativeCapability(client, input, timeout = 3e4) {
7777
8100
  return invokeCapability(client, input, writeInvoke, false, timeout);
7778
8101
  }
7779
- async function invokeCapability(client, input, tool4, readOnly, timeout) {
8102
+ async function invokeCapability(client, input, tool5, readOnly, timeout) {
7780
8103
  checkTimeout2(timeout);
7781
8104
  const args = capabilityCallSchema.safeParse(input);
7782
- if (!args.success) throw invalid3("NOT_SENT");
7783
- return callTool(client, tool4, args.data, timeout, readOnly, args.data.name);
8105
+ if (!args.success) throw invalid4("NOT_SENT");
8106
+ return callTool(client, tool5, args.data, timeout, readOnly, args.data.name);
7784
8107
  }
7785
- function invalid3(outcome = "REJECTED") {
8108
+ function invalid4(outcome = "REJECTED") {
7786
8109
  return new CliError(
7787
8110
  "INVALID_COMPACT_INPUT_OR_REPLY",
7788
8111
  "Use exact schema identity, summary source and hash-bound continuation.",
@@ -7790,12 +8113,12 @@ function invalid3(outcome = "REJECTED") {
7790
8113
  );
7791
8114
  }
7792
8115
  function checkTimeout2(v) {
7793
- if (!Number.isInteger(v) || v < 100 || v > 12e4) throw invalid3("NOT_SENT");
8116
+ if (!Number.isInteger(v) || v < 100 || v > 12e4) throw invalid4("NOT_SENT");
7794
8117
  }
7795
8118
 
7796
8119
  // packages/cli-client/src/document-page.ts
7797
8120
  import { createHash as createHash3 } from "node:crypto";
7798
- var tool2 = {
8121
+ var tool3 = {
7799
8122
  name: "cf_read_business_document",
7800
8123
  annotations: { readOnlyHint: true },
7801
8124
  inputSchema: {
@@ -7804,36 +8127,36 @@ var tool2 = {
7804
8127
  }
7805
8128
  };
7806
8129
  async function readNativeDocumentPage(client, raw, timeout = 3e4) {
7807
- if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid4("NOT_SENT");
8130
+ if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid5("NOT_SENT");
7808
8131
  const input = businessDocumentInputSchema.safeParse(raw);
7809
- if (!input.success) throw invalid4("NOT_SENT");
7810
- const value = await callTool(client, tool2, input.data, timeout, true, input.data.sourceTool);
7811
- if (Buffer.byteLength(JSON.stringify(value)) > 6e3) throw invalid4();
8132
+ if (!input.success) throw invalid5("NOT_SENT");
8133
+ const value = await callTool(client, tool3, input.data, timeout, true, input.data.sourceTool);
8134
+ if (Buffer.byteLength(JSON.stringify(value)) > 6e3) throw invalid5();
7812
8135
  const result2 = businessDocumentPageSchema.safeParse(value);
7813
- if (!result2.success) throw invalid4();
8136
+ if (!result2.success) throw invalid5();
7814
8137
  const p = result2.data, q = input.data;
7815
8138
  if (p.sourceTool !== q.sourceTool || executionCanonicalJson(p.sourceInput) !== executionCanonicalJson(q.sourceInput) || p.path !== q.path || p.view.kind !== q.view || q.expectedDocumentHash && p.documentHash !== q.expectedDocumentHash)
7816
- throw invalid4();
8139
+ throw invalid5();
7817
8140
  if (p.mode === "JSON_TEXT_PAGE") {
7818
8141
  const end = p.offset + [...p.text].length;
7819
8142
  if (p.offset !== q.offset || !p.text || p.complete !== (p.offset === 0 && !p.hasMore) || (p.hasMore ? p.nextOffset !== end || end >= p.totalCharacters : p.nextOffset !== null || end !== p.totalCharacters))
7820
- throw invalid4();
8143
+ throw invalid5();
7821
8144
  } else if (p.mode === "INDEX") {
7822
8145
  const end = p.offset + p.items.length;
7823
8146
  if (q.format !== "INDEX" || p.offset !== q.offset || !p.items.length || (p.hasMore ? p.nextOffset !== end || end >= p.totalItems : p.nextOffset !== null || end !== p.totalItems))
7824
- throw invalid4();
8147
+ throw invalid5();
7825
8148
  } else {
7826
- if (q.format !== "INDEX" || q.offset !== 0) throw invalid4();
8149
+ if (q.format !== "INDEX" || q.offset !== 0) throw invalid5();
7827
8150
  try {
7828
8151
  if (createHash3("sha256").update(JSON.stringify(p.data)).digest("hex") !== p.contentSha256)
7829
- throw invalid4();
8152
+ throw invalid5();
7830
8153
  } catch {
7831
- throw invalid4();
8154
+ throw invalid5();
7832
8155
  }
7833
8156
  }
7834
8157
  return p;
7835
8158
  }
7836
- function invalid4(outcome = "REJECTED") {
8159
+ function invalid5(outcome = "REJECTED") {
7837
8160
  return new CliError(
7838
8161
  "INVALID_DOCUMENT_PAGE",
7839
8162
  "Read one exact source/path page with its original document hash; do not mix versions or treat an index as complete content.",
@@ -7842,11 +8165,11 @@ function invalid4(outcome = "REJECTED") {
7842
8165
  }
7843
8166
 
7844
8167
  // packages/cli-client/src/review-links.ts
7845
- function reviewLinks(resource, tool4, result2, input = {}) {
8168
+ function reviewLinks(resource, tool5, result2, input = {}) {
7846
8169
  const url = new URL(resource);
7847
- if (tool4.startsWith("cf_material_verification_") && /^\/mcp\/tenants\/TEN-\d{6,}$/.test(url.pathname))
8170
+ if (tool5.startsWith("cf_material_verification_") && /^\/mcp\/tenants\/TEN-\d{6,}$/.test(url.pathname))
7848
8171
  return { materialsUrl: `${url.origin}${url.pathname.replace("/mcp", "")}/knowledge/materials` };
7849
- if (["cf_start_task", "cf_get_task_status", "cf_find_task_receipt"].includes(tool4) && /^\/mcp\/projects\/PRJ-\d{6,}$/.test(url.pathname)) {
8172
+ if (["cf_start_task", "cf_get_task_status", "cf_find_task_receipt"].includes(tool5) && /^\/mcp\/projects\/PRJ-\d{6,}$/.test(url.pathname)) {
7850
8173
  const value = result2 && typeof result2 === "object" && "receipt" in result2 ? result2.receipt : result2;
7851
8174
  if (value && typeof value === "object" && "workRequestCode" in value && typeof value.workRequestCode === "string" && /^JOB-\d{6,}$/.test(value.workRequestCode)) {
7852
8175
  return {
@@ -7855,34 +8178,41 @@ function reviewLinks(resource, tool4, result2, input = {}) {
7855
8178
  }
7856
8179
  return {};
7857
8180
  }
7858
- if (tool4 === "cf_read_knowledge" && result2 && typeof result2 === "object" && "readingPath" in result2 && typeof result2.readingPath === "string" && /^\/projects\/PRJ-\d{6,}\/knowledge\/library\/[0-9a-f-]{36}$/i.test(result2.readingPath)) {
8181
+ if (tool5 === "cf_read_knowledge" && result2 && typeof result2 === "object" && "readingPath" in result2 && typeof result2.readingPath === "string" && knowledgePathMatchesResource(result2.readingPath, url.pathname)) {
7859
8182
  return { readingUrl: new URL(result2.readingPath, url.origin).href };
7860
8183
  }
7861
- if (tool4 === "cf_submit_intelligence_candidate" && url.pathname === "/mcp/me" && result2 && typeof result2 === "object" && "businessCode" in result2 && typeof result2.businessCode === "string" && /^INT-[0-9]{6,}$/.test(result2.businessCode)) {
8184
+ if (tool5 === "cf_submit_intelligence_candidate" && url.pathname === "/mcp/me" && result2 && typeof result2 === "object" && "businessCode" in result2 && typeof result2.businessCode === "string" && /^INT-[0-9]{6,}$/.test(result2.businessCode)) {
7862
8185
  return { reviewUrl: `${url.origin}/me/survey/intelligence/${result2.businessCode}` };
7863
8186
  }
7864
8187
  const project = /^\/mcp\/projects\/(PRJ-\d{6,})$/.exec(url.pathname)?.[1];
7865
8188
  const tenant = /^\/mcp\/tenants\/(TEN-\d{6,})$/.exec(url.pathname)?.[1];
7866
- if (tool4.includes("foundation")) {
8189
+ if (tool5.includes("foundation")) {
7867
8190
  const kind3 = input.kind ?? input.target;
7868
8191
  const path = kind3 === "PERSONAL_CONTEXT" ? project ? `/foundation/personal/projects/${project}` : tenant ? `/foundation/personal/organizations/${tenant}` : "/me/identity" : kind3 === "PROJECT" && project ? `/me/identity/projects/${project}` : tenant ? `/me/identity/organizations/${tenant}` : "/foundation";
7869
8192
  return { workspaceUrl: url.origin + path };
7870
8193
  }
7871
8194
  if (project) {
7872
8195
  let area = "";
7873
- if (tool4.includes("program")) area = "/program";
7874
- else if (tool4.includes("review") || tool4.includes("feedback") || tool4.includes("improvement"))
8196
+ if (tool5.includes("program")) area = "/program";
8197
+ else if (tool5.includes("review") || tool5.includes("feedback") || tool5.includes("improvement"))
7875
8198
  area = "/insights/performance";
7876
- else if (tool4.includes("channel_account")) area = "/destinations";
7877
- else if (tool4.includes("package") || tool4.includes("publication")) area = "/packages";
7878
- else if (tool4.includes("action") || tool4.includes("asset")) area = "/actions";
7879
- else if (tool4.includes("opportunit")) area = "/opportunities";
7880
- else if (tool4.includes("knowledge") || tool4.includes("material") || tool4.includes("source"))
8199
+ else if (tool5.includes("channel_account")) area = "/destinations";
8200
+ else if (tool5.includes("package") || tool5.includes("publication")) area = "/packages";
8201
+ else if (tool5.includes("action") || tool5.includes("asset")) area = "/actions";
8202
+ else if (tool5.includes("opportunit")) area = "/opportunities";
8203
+ else if (tool5.includes("knowledge") || tool5.includes("material") || tool5.includes("source"))
7881
8204
  area = "/sources";
7882
8205
  return { workspaceUrl: `${url.origin}/projects/${project}${area}` };
7883
8206
  }
7884
8207
  return { workspaceUrl: url.origin + (tenant ? "/foundation" : "/me/identity") };
7885
8208
  }
8209
+ function knowledgePathMatchesResource(readingPath, resourcePath) {
8210
+ const resource = /^\/mcp\/((?:projects\/PRJ|tenants\/TEN)-\d{6,})$/.exec(resourcePath);
8211
+ const path = /^\/((?:projects\/PRJ|tenants\/TEN)-\d{6,})\/knowledge\/library\/[0-9a-f-]{36}$/i.exec(
8212
+ readingPath
8213
+ );
8214
+ return Boolean(resource && path && resource[1] === path[1]);
8215
+ }
7886
8216
 
7887
8217
  // packages/cli-client/src/operations.ts
7888
8218
  async function inspectNativeTool(client, name, timeout = 3e4) {
@@ -7907,7 +8237,7 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
7907
8237
  throw new CliError("INVALID_VIEW", "Use SUMMARY, INDEX, PAGE or ORIGINAL.");
7908
8238
  if (options.expectedSchemaSha256 !== void 0 && !/^[a-f0-9]{64}$/.test(options.expectedSchemaSha256))
7909
8239
  throw new CliError("INVALID_SCHEMA_HASH", "Supply the observed schema SHA-256.");
7910
- const { tool: tool4, schemaSha256 } = await nativeToolDefinition(client, name, timeout);
8240
+ const { tool: tool5, schemaSha256 } = await nativeToolDefinition(client, name, timeout);
7911
8241
  if (options.expectedSchemaSha256 !== void 0 && schemaSha256 !== options.expectedSchemaSha256)
7912
8242
  throw new CliError(
7913
8243
  "CAPABILITY_SCHEMA_CHANGED",
@@ -7916,7 +8246,7 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
7916
8246
  { recovery: "READ_EXACT_SCHEMA" }
7917
8247
  );
7918
8248
  const summary2 = agentSummarySourceSchema.safeParse(name), document2 = businessDocumentToolSchema.safeParse(name);
7919
- const read2 = tool4.annotations?.readOnlyHint === true;
8249
+ const read2 = tool5.annotations?.readOnlyHint === true;
7920
8250
  const view = options.view ?? (schemaSha256 && read2 ? summary2.success ? "SUMMARY" : document2.success ? "INDEX" : "ORIGINAL" : "ORIGINAL");
7921
8251
  if (view !== "ORIGINAL" && (!schemaSha256 || !read2 || (view === "SUMMARY" ? !summary2.success : !document2.success)))
7922
8252
  throw new CliError(
@@ -7946,7 +8276,7 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
7946
8276
  { name, expectedSchemaSha256: schemaSha256, arguments: input, delivery: "ORIGINAL" },
7947
8277
  timeout
7948
8278
  );
7949
- else result2 = await callTool(client, tool4, input, timeout, read2);
8279
+ else result2 = await callTool(client, tool5, input, timeout, read2);
7950
8280
  return { tool: name, view, result: result2, links: reviewLinks(resource, name, result2, input) };
7951
8281
  }
7952
8282
  function check(name, input, timeout) {
@@ -8210,7 +8540,7 @@ async function uploadNativeMaterial(connection, file, timeout = 3e4) {
8210
8540
  }
8211
8541
 
8212
8542
  // packages/cli-client/src/business-search.ts
8213
- var tool3 = (name, schema2) => ({
8543
+ var tool4 = (name, schema2) => ({
8214
8544
  name,
8215
8545
  inputSchema: {
8216
8546
  type: "object",
@@ -8218,22 +8548,22 @@ var tool3 = (name, schema2) => ({
8218
8548
  },
8219
8549
  annotations: { readOnlyHint: true, openWorldHint: false }
8220
8550
  });
8221
- var search = tool3("cf_search_business", businessSearchQuerySchema);
8222
- var document = tool3("cf_read_business_document", businessDocumentInputSchema);
8551
+ var search = tool4("cf_search_business", businessSearchQuerySchema);
8552
+ var document = tool4("cf_read_business_document", businessDocumentInputSchema);
8223
8553
  async function searchNativeBusiness(client, raw = {}, timeout = 3e4) {
8224
8554
  checkTimeout3(timeout);
8225
8555
  const input = businessSearchQuerySchema.safeParse(raw);
8226
- if (!input.success) throw invalid5("INVALID_BUSINESS_SEARCH_QUERY", "NOT_SENT");
8556
+ if (!input.success) throw invalid6("INVALID_BUSINESS_SEARCH_QUERY", "NOT_SENT");
8227
8557
  const value = await callTool(client, search, input.data, timeout, true);
8228
8558
  const parsed = businessSearchPageSchema.safeParse(value);
8229
8559
  if (!parsed.success || Buffer.byteLength(JSON.stringify(value)) > 16 * 1024)
8230
- throw invalid5("INVALID_BUSINESS_SEARCH_REPLY");
8560
+ throw invalid6("INVALID_BUSINESS_SEARCH_REPLY");
8231
8561
  return parsed.data;
8232
8562
  }
8233
8563
  async function readNativeBusinessPage(client, raw, timeout = 3e4) {
8234
8564
  checkTimeout3(timeout);
8235
8565
  const input = businessContentPageReadSchema.safeParse(raw);
8236
- if (!input.success) throw invalid5("INVALID_BUSINESS_CONTENT_QUERY", "NOT_SENT");
8566
+ if (!input.success) throw invalid6("INVALID_BUSINESS_CONTENT_QUERY", "NOT_SENT");
8237
8567
  const { offset, expectedDocumentHash, ...sourceInput } = input.data;
8238
8568
  const args = businessDocumentInputSchema.parse({
8239
8569
  sourceTool: "cf_read_business_content",
@@ -8244,24 +8574,25 @@ async function readNativeBusinessPage(client, raw, timeout = 3e4) {
8244
8574
  const value = await callTool(client, document, args, timeout, true);
8245
8575
  const parsed = businessContentPageSchema.safeParse(value);
8246
8576
  if (!parsed.success || Buffer.byteLength(JSON.stringify(value)) > 6e3)
8247
- throw invalid5("INVALID_BUSINESS_CONTENT_REPLY");
8577
+ throw invalid6("INVALID_BUSINESS_CONTENT_REPLY");
8248
8578
  const p = parsed.data;
8249
8579
  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)
8250
- throw invalid5("INVALID_BUSINESS_CONTENT_REPLY");
8580
+ throw invalid6("INVALID_BUSINESS_CONTENT_REPLY");
8251
8581
  return p;
8252
8582
  }
8253
- function invalid5(code2, outcome = "REJECTED") {
8583
+ function invalid6(code2, outcome = "REJECTED") {
8254
8584
  return new CliError(code2, "Use the exact bounded search or content-page contract.", outcome);
8255
8585
  }
8256
8586
  function checkTimeout3(value) {
8257
8587
  if (!Number.isInteger(value) || value < 100 || value > 12e4)
8258
- throw invalid5("INVALID_TIMEOUT", "NOT_SENT");
8588
+ throw invalid6("INVALID_TIMEOUT", "NOT_SENT");
8259
8589
  }
8260
8590
 
8261
8591
  // packages/cli-client/src/client.ts
8262
8592
  async function withNativeAgentClient(connection, action, options = {}) {
8263
8593
  const timeout = options.timeoutMs ?? 3e4;
8264
8594
  checkTimeout4(timeout);
8595
+ const definitions = new CapabilityDefinitionCache();
8265
8596
  return withClient(
8266
8597
  connection,
8267
8598
  timeout,
@@ -8283,7 +8614,24 @@ async function withNativeAgentClient(connection, action, options = {}) {
8283
8614
  searchBusiness: (input) => searchNativeBusiness(client, input, timeout),
8284
8615
  readBusinessPage: (input) => readNativeBusinessPage(client, input, timeout),
8285
8616
  findCapabilities: (input) => findNativeCapabilities(client, input, timeout),
8286
- describeCapability: (name) => describeNativeCapability(client, name, timeout)
8617
+ discoverCapabilities: async (input) => {
8618
+ const page2 = await findAgentCapabilities(client, input, timeout);
8619
+ for (const item of page2.items) if (item.definition) definitions.remember(item.definition);
8620
+ return page2;
8621
+ },
8622
+ describeCapability: async (name, expectedHash) => {
8623
+ const cached = expectedHash ? definitions.get(name, expectedHash) : void 0;
8624
+ if (cached) return cached;
8625
+ const definition = await describeNativeCapability(client, name, timeout);
8626
+ if (expectedHash && definition.schemaSha256 !== expectedHash)
8627
+ throw new CliError(
8628
+ "CAPABILITY_SCHEMA_CHANGED",
8629
+ "Discover the current definition again.",
8630
+ "REJECTED"
8631
+ );
8632
+ definitions.remember(definition);
8633
+ return definition;
8634
+ }
8287
8635
  })
8288
8636
  );
8289
8637
  }
@@ -8664,13 +9012,24 @@ var commandTools = {
8664
9012
  "source read": "cf_get_opportunity_source",
8665
9013
  // 目录/正文与任务冻结 source read 分离,避免把当前知识替换为任务证据。
8666
9014
  "knowledge list": "cf_list_knowledge",
9015
+ "knowledge discover": "cf_discover_knowledge",
9016
+ "knowledge adopt": "cf_adopt_discovered_knowledge",
9017
+ "knowledge adoption-receipt": "cf_get_knowledge_adoption_receipt",
9018
+ "knowledge read-discovered": "cf_read_discovered_knowledge",
8667
9019
  "knowledge materials": "cf_list_materials",
9020
+ "knowledge topics": "cf_list_material_topics",
8668
9021
  "knowledge read": "cf_read_knowledge",
9022
+ "knowledge read-source": "cf_read_source",
8669
9023
  "knowledge select": "cf_select_knowledge",
8670
9024
  "knowledge collect": "cf_collect_materials",
8671
- "knowledge sync": "cf_sync_materials",
8672
9025
  "knowledge tenant-status": "cf_tenant_material_scan_status",
8673
- "knowledge tenant-advance": "cf_tenant_material_scan_advance",
9026
+ "knowledge reconcile": "cf_reconcile_materials",
9027
+ "event-exchanges list": "cf_list_event_exchanges",
9028
+ "event-exchanges configure": "cf_configure_event_exchange",
9029
+ "event-exchanges receipt": "cf_get_event_exchange_receipt",
9030
+ "event-exchanges outbox-list": "cf_list_event_outbox",
9031
+ "event-exchanges outbox-recover": "cf_recover_event_outbox",
9032
+ "event-exchanges outbox-receipt": "cf_get_event_outbox_recovery_receipt",
8674
9033
  "knowledge verify-start": "cf_material_verification_start",
8675
9034
  "knowledge verify-status": "cf_material_verification_status",
8676
9035
  "knowledge verify-advance": "cf_material_verification_advance",
@@ -8870,7 +9229,9 @@ function resolveBaseCommand(parsed) {
8870
9229
  function resolveCommand(parsed) {
8871
9230
  const removed = {
8872
9231
  doctor: "context",
8873
- "knowledge sync-all": "knowledge sync"
9232
+ "knowledge sync-all": "knowledge discover",
9233
+ "knowledge sync": "knowledge discover",
9234
+ "knowledge tenant-advance": "knowledge discover"
8874
9235
  };
8875
9236
  const replacement = removed[parsed.words.join(" ")];
8876
9237
  if (replacement)
@@ -8940,7 +9301,7 @@ async function businessCommand(client, parsed, input, resource) {
8940
9301
  );
8941
9302
  if (resolved.mode === "discover") {
8942
9303
  const query = parsed.words.slice(2).join(" ");
8943
- return findNativeCapabilities(client, query ? { query } : input, timeout);
9304
+ return findAgentCapabilities(client, query ? { query } : input, timeout);
8944
9305
  }
8945
9306
  if (resolved.mode === "describe")
8946
9307
  return describeNativeCapability(client, parsed.words[2], timeout);
@@ -9119,6 +9480,7 @@ export {
9119
9480
  callNativeCapability,
9120
9481
  callNativeTool,
9121
9482
  describeNativeCapability,
9483
+ findAgentCapabilities,
9122
9484
  findNativeCapabilities,
9123
9485
  getNativeBusinessSummary,
9124
9486
  inspectNativeTool,