@native-marketing/sdk 0.1.1 → 0.2.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/README.md +12 -3
- package/dist/index.js +1176 -1020
- package/package.json +1 -1
- package/release.json +2 -2
- package/types/contracts/agent/capabilities.d.ts +59 -0
- package/types/contracts/agent/index.d.ts +4 -0
- package/types/contracts/agent/input-repair.d.ts +32 -0
- package/types/contracts/agent/publication-preflight.d.ts +6 -0
- package/types/contracts/agent/test-records.d.ts +28 -0
- package/types/contracts/agent/validation.d.ts +7 -0
- package/types/sdk/agent-capabilities.d.ts +3 -0
- package/types/sdk/capability-definition.d.ts +24 -0
- package/types/sdk/client.d.ts +3 -2
- package/types/sdk/index.d.ts +2 -1
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
|
|
5251
|
-
var businessSearchKindSchema =
|
|
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 =
|
|
5266
|
-
query:
|
|
5267
|
-
kinds:
|
|
5268
|
-
includeHistory:
|
|
5269
|
-
limit:
|
|
5270
|
-
cursor:
|
|
5271
|
-
}).strict();
|
|
5272
|
-
var businessContentRefSchema =
|
|
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 =
|
|
5319
|
+
var businessContentReadSchema = z71.object({
|
|
5276
5320
|
ref: businessContentRefSchema,
|
|
5277
|
-
expectedVersion:
|
|
5321
|
+
expectedVersion: z71.string().regex(/^[a-f0-9]{64}$/u)
|
|
5278
5322
|
}).strict();
|
|
5279
|
-
var businessSearchHitSchema =
|
|
5323
|
+
var businessSearchHitSchema = z71.object({
|
|
5280
5324
|
ref: businessContentRefSchema,
|
|
5281
5325
|
kind: businessSearchKindSchema,
|
|
5282
|
-
title:
|
|
5283
|
-
status:
|
|
5284
|
-
excerpt:
|
|
5285
|
-
version:
|
|
5286
|
-
navigation:
|
|
5287
|
-
href:
|
|
5288
|
-
relation:
|
|
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:
|
|
5291
|
-
tool:
|
|
5292
|
-
input:
|
|
5293
|
-
sourceTool:
|
|
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 =
|
|
5299
|
-
schemaVersion:
|
|
5300
|
-
matching:
|
|
5301
|
-
consistency:
|
|
5302
|
-
context:
|
|
5303
|
-
kind:
|
|
5304
|
-
businessCode:
|
|
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:
|
|
5307
|
-
|
|
5350
|
+
coverage: z71.array(
|
|
5351
|
+
z71.object({
|
|
5308
5352
|
kind: businessSearchKindSchema,
|
|
5309
|
-
state:
|
|
5353
|
+
state: z71.enum(["SEARCHED", "METADATA_ONLY", "UNAVAILABLE", "NOT_APPLICABLE"])
|
|
5310
5354
|
}).strict()
|
|
5311
5355
|
).max(12),
|
|
5312
|
-
items:
|
|
5313
|
-
page:
|
|
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:
|
|
5317
|
-
expectedDocumentHash:
|
|
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 =
|
|
5327
|
-
schemaVersion:
|
|
5328
|
-
documentKind:
|
|
5329
|
-
sourceTool:
|
|
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:
|
|
5332
|
-
documentHash:
|
|
5333
|
-
contentSha256:
|
|
5334
|
-
path:
|
|
5335
|
-
offset:
|
|
5336
|
-
totalCharacters:
|
|
5337
|
-
text:
|
|
5338
|
-
hasMore:
|
|
5339
|
-
nextOffset:
|
|
5340
|
-
complete:
|
|
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
|
|
5345
|
-
var businessDocumentToolSchema =
|
|
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 =
|
|
5471
|
+
var businessDocumentInputSchema = z72.object({
|
|
5428
5472
|
sourceTool: businessDocumentToolSchema,
|
|
5429
|
-
sourceInput:
|
|
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:
|
|
5432
|
-
path:
|
|
5433
|
-
format:
|
|
5434
|
-
offset:
|
|
5435
|
-
expectedDocumentHash:
|
|
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
|
|
5490
|
+
import { z as z73 } from "zod";
|
|
5447
5491
|
var nativeAgentSurfaceCapability = "io.native-marketing/agent-native";
|
|
5448
|
-
var hash =
|
|
5492
|
+
var hash = z73.string().regex(/^[a-f0-9]{64}$/u);
|
|
5449
5493
|
var capabilitySchemaReadSchema = capabilityDescribeSchema.extend({
|
|
5450
5494
|
expectedSchemaSha256: hash,
|
|
5451
|
-
offset:
|
|
5495
|
+
offset: z73.number().int().nonnegative().default(0)
|
|
5452
5496
|
}).strict();
|
|
5453
|
-
var capabilitySchemaPageSchema =
|
|
5454
|
-
schemaVersion:
|
|
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:
|
|
5459
|
-
offset:
|
|
5460
|
-
totalCharacters:
|
|
5461
|
-
text:
|
|
5462
|
-
hasMore:
|
|
5463
|
-
nextOffset:
|
|
5464
|
-
}).strict();
|
|
5465
|
-
var capabilityDescriptorSchema =
|
|
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
|
-
|
|
5468
|
-
schemaVersion:
|
|
5511
|
+
z73.object({
|
|
5512
|
+
schemaVersion: z73.literal(2),
|
|
5469
5513
|
name: capabilityDescribeSchema.shape.name,
|
|
5470
5514
|
schemaSha256: hash,
|
|
5471
|
-
delivery:
|
|
5472
|
-
byteLength:
|
|
5473
|
-
read:
|
|
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 =
|
|
5521
|
+
var capabilityCallSchema = z73.object({
|
|
5478
5522
|
name: capabilityDescribeSchema.shape.name,
|
|
5479
5523
|
expectedSchemaSha256: hash,
|
|
5480
|
-
arguments:
|
|
5481
|
-
delivery:
|
|
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 =
|
|
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 =
|
|
5561
|
+
var agentSummaryInputSchema = z73.object({
|
|
5518
5562
|
sourceTool: agentSummarySourceSchema,
|
|
5519
|
-
sourceInput:
|
|
5520
|
-
actionOffset:
|
|
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 =
|
|
5532
|
-
actionId:
|
|
5533
|
-
title:
|
|
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:
|
|
5536
|
-
state:
|
|
5537
|
-
requiresHumanDecision:
|
|
5538
|
-
input:
|
|
5539
|
-
requiredInputs:
|
|
5540
|
-
conditions:
|
|
5541
|
-
baseline:
|
|
5542
|
-
href:
|
|
5543
|
-
}).strict();
|
|
5544
|
-
var agentSummarySchema =
|
|
5545
|
-
schemaVersion:
|
|
5546
|
-
view:
|
|
5547
|
-
contentComplete:
|
|
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:
|
|
5552
|
-
read:
|
|
5553
|
-
tool:
|
|
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:
|
|
5557
|
-
actionPage:
|
|
5558
|
-
offset:
|
|
5559
|
-
hasMore:
|
|
5560
|
-
nextOffset:
|
|
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:
|
|
5563
|
-
actionsAreAuthority:
|
|
5564
|
-
callsReauthorize:
|
|
5565
|
-
runtimeChoosesContinuation:
|
|
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
|
|
5571
|
-
var hash2 =
|
|
5614
|
+
import { z as z74 } from "zod";
|
|
5615
|
+
var hash2 = z74.string().regex(/^[a-f0-9]{64}$/u);
|
|
5572
5616
|
var base = {
|
|
5573
|
-
schemaVersion:
|
|
5574
|
-
documentKind:
|
|
5617
|
+
schemaVersion: z74.literal(1),
|
|
5618
|
+
documentKind: z74.literal("BUSINESS_READ"),
|
|
5575
5619
|
sourceTool: businessDocumentInputSchema.shape.sourceTool,
|
|
5576
|
-
sourceInput:
|
|
5620
|
+
sourceInput: z74.record(z74.string(), z74.unknown()),
|
|
5577
5621
|
documentHash: hash2,
|
|
5578
5622
|
contentSha256: hash2,
|
|
5579
5623
|
nodeHash: hash2,
|
|
5580
|
-
path:
|
|
5581
|
-
view:
|
|
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 =
|
|
5584
|
-
|
|
5627
|
+
var businessDocumentPageSchema = z74.discriminatedUnion("mode", [
|
|
5628
|
+
z74.object({
|
|
5585
5629
|
...base,
|
|
5586
|
-
mode:
|
|
5587
|
-
complete:
|
|
5588
|
-
text:
|
|
5589
|
-
offset:
|
|
5590
|
-
totalCharacters:
|
|
5591
|
-
hasMore:
|
|
5592
|
-
nextOffset:
|
|
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
|
-
|
|
5638
|
+
z74.object({
|
|
5595
5639
|
...base,
|
|
5596
|
-
mode:
|
|
5597
|
-
complete:
|
|
5598
|
-
offset:
|
|
5599
|
-
totalItems:
|
|
5600
|
-
items:
|
|
5601
|
-
hasMore:
|
|
5602
|
-
nextOffset:
|
|
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
|
-
|
|
5648
|
+
z74.object({ ...base, mode: z74.literal("FULL"), complete: z74.literal(true), data: z74.unknown() }).passthrough()
|
|
5649
|
+
]);
|
|
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") })
|
|
5605
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();
|
|
5606
5731
|
|
|
5607
5732
|
// packages/contracts/src/foundation/collaboration.ts
|
|
5608
|
-
import { z as
|
|
5609
|
-
var ref =
|
|
5610
|
-
var question =
|
|
5611
|
-
var foundationResearchAnswerSchema =
|
|
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:
|
|
5616
|
-
actorUserId:
|
|
5617
|
-
requestId:
|
|
5618
|
-
}).strict();
|
|
5619
|
-
var foundationResearchContentSchema =
|
|
5620
|
-
goalFingerprint:
|
|
5621
|
-
basisFingerprint:
|
|
5622
|
-
title:
|
|
5623
|
-
summary:
|
|
5624
|
-
body:
|
|
5625
|
-
status:
|
|
5626
|
-
sourceRefs:
|
|
5627
|
-
questions:
|
|
5628
|
-
answers:
|
|
5629
|
-
}).strict();
|
|
5630
|
-
var foundationMaterialReadingSchema =
|
|
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:
|
|
5633
|
-
contentHash:
|
|
5634
|
-
note:
|
|
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 =
|
|
5645
|
-
id:
|
|
5646
|
-
kind:
|
|
5769
|
+
var foundationRecordSchema = z77.object({
|
|
5770
|
+
id: z77.string().uuid(),
|
|
5771
|
+
kind: z77.enum(["RESEARCH", "MATERIAL_READING", "DECISION"]),
|
|
5647
5772
|
scope: foundationScopeSchema,
|
|
5648
|
-
revision:
|
|
5649
|
-
content:
|
|
5650
|
-
contentHash:
|
|
5651
|
-
actorUserId:
|
|
5652
|
-
createdAt:
|
|
5653
|
-
}).strict();
|
|
5654
|
-
var foundationResearchSaveSchema =
|
|
5655
|
-
id:
|
|
5656
|
-
expectedRevision:
|
|
5657
|
-
requestId:
|
|
5658
|
-
expectedGoalFingerprint:
|
|
5659
|
-
expectedBasisFingerprint:
|
|
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 =
|
|
5664
|
-
cursor:
|
|
5665
|
-
kind:
|
|
5788
|
+
var foundationChangeSchema = z77.object({
|
|
5789
|
+
cursor: z77.string(),
|
|
5790
|
+
kind: z77.string(),
|
|
5666
5791
|
resourceRef: ref,
|
|
5667
|
-
revision:
|
|
5668
|
-
occurredAt:
|
|
5669
|
-
}).strict();
|
|
5670
|
-
var foundationChangesQuerySchema =
|
|
5671
|
-
after:
|
|
5672
|
-
limit:
|
|
5673
|
-
}).strict();
|
|
5674
|
-
var foundationChangesPageSchema =
|
|
5675
|
-
items:
|
|
5676
|
-
checkpoint:
|
|
5677
|
-
initialReadRequired:
|
|
5678
|
-
nextCursor:
|
|
5679
|
-
hasMore:
|
|
5680
|
-
}).strict();
|
|
5681
|
-
var foundationChangesAckSchema =
|
|
5682
|
-
expectedCheckpoint:
|
|
5683
|
-
through:
|
|
5684
|
-
}).strict();
|
|
5685
|
-
var foundationResearchReplySchema =
|
|
5686
|
-
id:
|
|
5687
|
-
expectedRevision:
|
|
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:
|
|
5690
|
-
requestId:
|
|
5814
|
+
text: z77.string().trim().min(1).max(4e3),
|
|
5815
|
+
requestId: z77.string().min(1).max(160)
|
|
5691
5816
|
}).strict();
|
|
5692
|
-
var foundationDecisionReceiptSchema =
|
|
5693
|
-
|
|
5694
|
-
|
|
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
|
|
5699
|
-
var
|
|
5700
|
-
var materialVerificationStartSchema =
|
|
5701
|
-
requestId:
|
|
5702
|
-
fullReadLimitBytes:
|
|
5703
|
-
}).strict();
|
|
5704
|
-
var materialVerificationIdSchema =
|
|
5705
|
-
var materialVerificationReceiptSchema =
|
|
5706
|
-
original:
|
|
5707
|
-
state:
|
|
5708
|
-
transportHash:
|
|
5709
|
-
byteLength:
|
|
5710
|
-
reasonCode:
|
|
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:
|
|
5713
|
-
state:
|
|
5714
|
-
documentRef:
|
|
5715
|
-
documentHash:
|
|
5716
|
-
reasonCode:
|
|
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:
|
|
5719
|
-
state:
|
|
5720
|
-
documentRef:
|
|
5721
|
-
documentHash:
|
|
5722
|
-
afterOrdinal:
|
|
5723
|
-
mirroredVerified:
|
|
5724
|
-
remoteOnly:
|
|
5725
|
-
unavailable:
|
|
5726
|
-
reasonCode:
|
|
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:
|
|
5729
|
-
errorCode:
|
|
5730
|
-
humanReading:
|
|
5731
|
-
agentReading:
|
|
5732
|
-
}).strict();
|
|
5733
|
-
var materialVerificationJobSchema =
|
|
5734
|
-
id:
|
|
5735
|
-
tenantId:
|
|
5736
|
-
kvTenantId:
|
|
5737
|
-
projectKey:
|
|
5738
|
-
connectorRevision:
|
|
5739
|
-
generation:
|
|
5740
|
-
inventoryStatus:
|
|
5741
|
-
acknowledgedSeq:
|
|
5742
|
-
pendingSeq:
|
|
5743
|
-
fullReadLimitBytes:
|
|
5744
|
-
state:
|
|
5745
|
-
total:
|
|
5746
|
-
completed:
|
|
5747
|
-
failed:
|
|
5748
|
-
pending:
|
|
5749
|
-
createdAt:
|
|
5750
|
-
updatedAt:
|
|
5751
|
-
}).strict();
|
|
5752
|
-
var materialVerificationItemSchema =
|
|
5753
|
-
sourceId:
|
|
5754
|
-
artifactRef:
|
|
5755
|
-
identityHash:
|
|
5756
|
-
resourceType:
|
|
5757
|
-
state:
|
|
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 =
|
|
5885
|
+
var materialVerificationPageSchema = z78.object({
|
|
5761
5886
|
job: materialVerificationJobSchema,
|
|
5762
|
-
items:
|
|
5763
|
-
nextAfter:
|
|
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
|
|
5768
|
-
var sha =
|
|
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 =
|
|
5772
|
-
var command2 =
|
|
5773
|
-
version:
|
|
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:
|
|
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 =
|
|
5781
|
-
limit:
|
|
5782
|
-
cursor:
|
|
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 =
|
|
5787
|
-
var scope =
|
|
5788
|
-
projectCode:
|
|
5789
|
-
projectName:
|
|
5790
|
-
canReview:
|
|
5791
|
-
canPrepare:
|
|
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:
|
|
5919
|
+
items: z79.array(publicEditorialCandidateSchema),
|
|
5795
5920
|
pageInfo
|
|
5796
5921
|
});
|
|
5797
5922
|
var editorialKernelPageSchema = scope.extend({
|
|
5798
|
-
items:
|
|
5923
|
+
items: z79.array(publicEditorialKernelSchema),
|
|
5799
5924
|
pageInfo
|
|
5800
5925
|
});
|
|
5801
|
-
var editorialSourceStateSchema =
|
|
5926
|
+
var editorialSourceStateSchema = z79.object({
|
|
5802
5927
|
ref: stableRefSchema,
|
|
5803
5928
|
id: uuidSchema.nullable(),
|
|
5804
5929
|
sourceType: sourceTypeSchema.nullable(),
|
|
5805
|
-
authority:
|
|
5806
|
-
observedAt:
|
|
5807
|
-
validUntil:
|
|
5808
|
-
available:
|
|
5809
|
-
reason:
|
|
5810
|
-
contentHash:
|
|
5811
|
-
});
|
|
5812
|
-
var origin =
|
|
5813
|
-
workRequestCode:
|
|
5814
|
-
acceptedAt:
|
|
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:
|
|
5824
|
-
sources:
|
|
5948
|
+
basisCurrent: z79.boolean(),
|
|
5949
|
+
sources: z79.array(editorialSourceStateSchema),
|
|
5825
5950
|
origin,
|
|
5826
|
-
canApprove:
|
|
5827
|
-
canReject:
|
|
5828
|
-
canStartKernel:
|
|
5829
|
-
blockedReason:
|
|
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:
|
|
5963
|
+
kind: z79.literal("CANDIDATE"),
|
|
5839
5964
|
candidate: publicEditorialCandidateSchema
|
|
5840
5965
|
});
|
|
5841
5966
|
var editorialKernelDetailSchema = detail.extend({
|
|
5842
|
-
kind:
|
|
5967
|
+
kind: z79.literal("KERNEL"),
|
|
5843
5968
|
kernel: publicEditorialKernelSchema
|
|
5844
5969
|
});
|
|
5845
|
-
var editorialReviewReceiptSchema =
|
|
5846
|
-
version:
|
|
5970
|
+
var editorialReviewReceiptSchema = z79.object({
|
|
5971
|
+
version: z79.literal(1),
|
|
5847
5972
|
requestId: uuidSchema,
|
|
5848
5973
|
resourceRef: stableRefSchema,
|
|
5849
|
-
actorCode:
|
|
5850
|
-
decidedAt:
|
|
5851
|
-
decision:
|
|
5852
|
-
note:
|
|
5853
|
-
replayed:
|
|
5854
|
-
result:
|
|
5855
|
-
|
|
5856
|
-
|
|
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
|
|
5862
|
-
var kind =
|
|
5863
|
-
var foundationAgentOverviewInputSchema =
|
|
5864
|
-
var foundationAgentWorkspaceInputSchema =
|
|
5865
|
-
var foundationAgentProfileSaveSchema =
|
|
5866
|
-
var contextSurvey = saveOrganizationProjectSurveyInputSchema.extend({ expectedEditVersion:
|
|
5867
|
-
var foundationAgentSurveySaveSchema =
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
kind:
|
|
5872
|
-
requestId:
|
|
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:
|
|
5999
|
+
expectedEditVersion: z80.number().int().positive().nullable()
|
|
5875
6000
|
}).strict()
|
|
5876
6001
|
]);
|
|
5877
|
-
var foundationAgentAcceptSchema =
|
|
5878
|
-
var foundationAgentResearchSchema =
|
|
5879
|
-
var foundationAgentReadingSchema =
|
|
5880
|
-
var foundationAgentResearchReplySchema =
|
|
5881
|
-
var foundationAgentChangesSchema =
|
|
5882
|
-
var foundationAgentAckSchema =
|
|
5883
|
-
var foundationAgentRecordQuerySchema =
|
|
5884
|
-
var foundationAgentDecisionReceiptQuerySchema =
|
|
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:
|
|
6011
|
+
requestId: z80.string().min(1).max(160)
|
|
5887
6012
|
}).strict();
|
|
5888
|
-
var foundationSaveOperationSchema =
|
|
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 =
|
|
5896
|
-
var foundationAgentRevokeSchema =
|
|
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
|
|
6028
|
+
import { z as z81 } from "zod";
|
|
5904
6029
|
var SOURCE_MATERIAL_MAX_BYTES = 20 * 1024 * 1024;
|
|
5905
|
-
var sourceMaterialOriginalSchema =
|
|
5906
|
-
sha256:
|
|
5907
|
-
byteSize:
|
|
5908
|
-
mediaType:
|
|
5909
|
-
filename:
|
|
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
|
|
5914
|
-
var personalMaterialRefSchema =
|
|
5915
|
-
var personalMaterialSchema =
|
|
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:
|
|
6045
|
+
createdAt: z82.string().datetime()
|
|
5921
6046
|
});
|
|
5922
|
-
var personalMaterialTargetSchema =
|
|
5923
|
-
|
|
5924
|
-
|
|
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 =
|
|
6051
|
+
var personalMaterialUseSchema = z82.object({
|
|
5927
6052
|
id: uuidSchema,
|
|
5928
6053
|
materialId: uuidSchema,
|
|
5929
6054
|
target: personalMaterialTargetSchema,
|
|
5930
|
-
destinationCode:
|
|
5931
|
-
destinationName:
|
|
5932
|
-
active:
|
|
5933
|
-
editVersion:
|
|
5934
|
-
createdAt:
|
|
5935
|
-
updatedAt:
|
|
5936
|
-
});
|
|
5937
|
-
var personalMaterialUseInputSchema =
|
|
5938
|
-
active:
|
|
5939
|
-
expectedEditVersion:
|
|
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 =
|
|
5943
|
-
items:
|
|
5944
|
-
nextCursor:
|
|
6067
|
+
var personalMaterialPageSchema = z82.object({
|
|
6068
|
+
items: z82.array(personalMaterialSchema).max(50),
|
|
6069
|
+
nextCursor: z82.string().nullable()
|
|
5945
6070
|
});
|
|
5946
|
-
var personalMaterialListQuerySchema =
|
|
5947
|
-
limit:
|
|
5948
|
-
q:
|
|
5949
|
-
cursor:
|
|
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
|
|
5954
|
-
var programAgentDraftSaveSchema =
|
|
5955
|
-
programCode:
|
|
5956
|
-
expectedUpdatedAt:
|
|
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:
|
|
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
|
|
5963
|
-
var packageDeliveryInputSchema =
|
|
5964
|
-
packageCode:
|
|
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 =
|
|
5967
|
-
retryOf:
|
|
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:
|
|
6095
|
+
retryOf: z84.string().regex(/^JOB-[0-9]{6,}$/).optional()
|
|
5971
6096
|
}).strict();
|
|
5972
6097
|
var packageContentReadInputSchema = packageDeliveryInputSchema.extend({
|
|
5973
|
-
targetKey:
|
|
6098
|
+
targetKey: z84.string().min(1).max(64).optional()
|
|
5974
6099
|
}).strict();
|
|
5975
|
-
var packageDeliveryViewSchema =
|
|
5976
|
-
packageCode:
|
|
5977
|
-
manifestHash:
|
|
5978
|
-
reviewSha256:
|
|
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:
|
|
5981
|
-
review:
|
|
5982
|
-
download:
|
|
5983
|
-
recordPublication:
|
|
6105
|
+
capabilities: z84.object({
|
|
6106
|
+
review: z84.boolean(),
|
|
6107
|
+
download: z84.boolean(),
|
|
6108
|
+
recordPublication: z84.boolean()
|
|
5984
6109
|
}),
|
|
5985
|
-
export:
|
|
5986
|
-
readable:
|
|
5987
|
-
unavailable:
|
|
5988
|
-
ready:
|
|
5989
|
-
work:
|
|
5990
|
-
businessCode:
|
|
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:
|
|
5993
|
-
errorCode:
|
|
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
|
|
6124
|
+
import { z as z86 } from "zod";
|
|
6000
6125
|
|
|
6001
6126
|
// packages/contracts/src/foundation/command-outcome.ts
|
|
6002
|
-
import { z as
|
|
6003
|
-
var commandRejectedReceiptSchema =
|
|
6004
|
-
state:
|
|
6005
|
-
result:
|
|
6006
|
-
error:
|
|
6007
|
-
code:
|
|
6008
|
-
outcome:
|
|
6009
|
-
recovery:
|
|
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 =
|
|
6015
|
-
sourceKey:
|
|
6016
|
-
factKey:
|
|
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:
|
|
6020
|
-
sourceRevision:
|
|
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 =
|
|
6023
|
-
observedAt:
|
|
6147
|
+
var feedbackFactCorrectionSchema = z86.object({
|
|
6148
|
+
observedAt: z86.string().datetime(),
|
|
6024
6149
|
metricWindow: feedbackMetricWindowSchema,
|
|
6025
|
-
periodStart:
|
|
6026
|
-
periodEnd:
|
|
6150
|
+
periodStart: z86.string().datetime().nullable(),
|
|
6151
|
+
periodEnd: z86.string().datetime().nullable(),
|
|
6027
6152
|
metrics: feedbackMetricsSchema,
|
|
6028
|
-
note:
|
|
6029
|
-
sourceReference:
|
|
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 =
|
|
6038
|
-
var feedbackFactHttpQuerySchema =
|
|
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:
|
|
6043
|
-
limit:
|
|
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 =
|
|
6052
|
-
|
|
6176
|
+
var feedbackFactReadSchema = z86.union([
|
|
6177
|
+
z86.object({
|
|
6053
6178
|
observationCode,
|
|
6054
|
-
beforeRevision:
|
|
6055
|
-
limit:
|
|
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
|
-
|
|
6182
|
+
z86.object({
|
|
6058
6183
|
identity: feedbackFactIdentitySchema,
|
|
6059
|
-
beforeRevision:
|
|
6060
|
-
limit:
|
|
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:
|
|
6189
|
+
requestId: z86.uuid(),
|
|
6065
6190
|
observationCode,
|
|
6066
|
-
expectedRevision:
|
|
6067
|
-
expectedAccountUpdatedAt:
|
|
6068
|
-
reason:
|
|
6069
|
-
sourceRevision:
|
|
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 =
|
|
6072
|
-
|
|
6196
|
+
var feedbackFactChangeSchema = z86.discriminatedUnion("operation", [
|
|
6197
|
+
z86.object({
|
|
6073
6198
|
...change,
|
|
6074
|
-
operation:
|
|
6199
|
+
operation: z86.literal("CORRECT"),
|
|
6075
6200
|
correction: feedbackFactCorrectionSchema
|
|
6076
6201
|
}).strict(),
|
|
6077
|
-
|
|
6202
|
+
z86.object({ ...change, operation: z86.literal("WITHDRAW") }).strict()
|
|
6078
6203
|
]);
|
|
6079
|
-
var feedbackFactSchema =
|
|
6204
|
+
var feedbackFactSchema = z86.object({
|
|
6080
6205
|
identity: feedbackFactIdentitySchema,
|
|
6081
|
-
revision:
|
|
6082
|
-
sourceRevision:
|
|
6083
|
-
state:
|
|
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:
|
|
6210
|
+
updatedAt: z86.string().datetime()
|
|
6086
6211
|
});
|
|
6087
|
-
var feedbackFactChangeReceiptSchema =
|
|
6212
|
+
var feedbackFactChangeReceiptSchema = z86.object({
|
|
6088
6213
|
observationCode,
|
|
6089
|
-
revision:
|
|
6090
|
-
state:
|
|
6091
|
-
destinationCode:
|
|
6092
|
-
replayed:
|
|
6093
|
-
});
|
|
6094
|
-
var feedbackFactOriginalReceiptSchema =
|
|
6095
|
-
|
|
6096
|
-
|
|
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:
|
|
6102
|
-
destinationCode:
|
|
6103
|
-
accountUpdatedAt:
|
|
6104
|
-
history:
|
|
6105
|
-
|
|
6106
|
-
revision:
|
|
6107
|
-
sourceRevision:
|
|
6108
|
-
operation:
|
|
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:
|
|
6111
|
-
createdAt:
|
|
6235
|
+
reason: z86.string().nullable(),
|
|
6236
|
+
createdAt: z86.string().datetime()
|
|
6112
6237
|
})
|
|
6113
6238
|
),
|
|
6114
|
-
hasMore:
|
|
6115
|
-
nextBeforeRevision:
|
|
6239
|
+
hasMore: z86.boolean(),
|
|
6240
|
+
nextBeforeRevision: z86.number().int().positive().nullable().default(null)
|
|
6116
6241
|
});
|
|
6117
|
-
var feedbackFactAgentReadSchema =
|
|
6242
|
+
var feedbackFactAgentReadSchema = z86.union([
|
|
6118
6243
|
feedbackFactReadSchema.options[0].extend({
|
|
6119
|
-
destinationCode:
|
|
6244
|
+
destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
|
|
6120
6245
|
}),
|
|
6121
6246
|
feedbackFactReadSchema.options[1].extend({
|
|
6122
|
-
destinationCode:
|
|
6247
|
+
destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
|
|
6123
6248
|
})
|
|
6124
6249
|
]);
|
|
6125
|
-
var feedbackFactAgentChangeSchema =
|
|
6250
|
+
var feedbackFactAgentChangeSchema = z86.discriminatedUnion("operation", [
|
|
6126
6251
|
feedbackFactChangeSchema.options[0].extend({
|
|
6127
|
-
destinationCode:
|
|
6252
|
+
destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
|
|
6128
6253
|
}),
|
|
6129
6254
|
feedbackFactChangeSchema.options[1].extend({
|
|
6130
|
-
destinationCode:
|
|
6255
|
+
destinationCode: z86.string().regex(/^DST-[0-9]{6,}$/)
|
|
6131
6256
|
})
|
|
6132
6257
|
]);
|
|
6133
|
-
var feedbackFactAgentReceiptSchema =
|
|
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
|
|
6137
|
-
var channelFeedbackCommandSchema =
|
|
6261
|
+
import { z as z87 } from "zod";
|
|
6262
|
+
var channelFeedbackCommandSchema = z87.object({
|
|
6138
6263
|
fact: feedbackSourceFactSchema.optional(),
|
|
6139
|
-
requestId:
|
|
6140
|
-
expectedAccountUpdatedAt:
|
|
6141
|
-
sourceName:
|
|
6142
|
-
sourceReference:
|
|
6143
|
-
observedAt:
|
|
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:
|
|
6146
|
-
periodEnd:
|
|
6270
|
+
periodStart: z87.string().datetime().nullable(),
|
|
6271
|
+
periodEnd: z87.string().datetime().nullable(),
|
|
6147
6272
|
metrics: feedbackMetricsSchema,
|
|
6148
|
-
note:
|
|
6149
|
-
publicationCode:
|
|
6150
|
-
goal:
|
|
6151
|
-
programCode:
|
|
6152
|
-
revision:
|
|
6153
|
-
goalId:
|
|
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 =
|
|
6168
|
-
view:
|
|
6169
|
-
limit:
|
|
6170
|
-
afterBusinessCode:
|
|
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 =
|
|
6173
|
-
canRecord:
|
|
6174
|
-
items:
|
|
6175
|
-
hasMore:
|
|
6176
|
-
nextAfterBusinessCode:
|
|
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 =
|
|
6303
|
+
var channelFeedbackReceiptSchema = z87.object({ observationCode: z87.string(), observedAt: z87.string().datetime(), replayed: z87.boolean() }).strict();
|
|
6179
6304
|
var channelFeedbackReadSchema = channelFeedbackQuerySchema.extend({
|
|
6180
|
-
destinationCode:
|
|
6305
|
+
destinationCode: z87.string().regex(/^DST-[0-9]{6,}$/)
|
|
6181
6306
|
});
|
|
6182
6307
|
var channelFeedbackWriteSchema = channelFeedbackCommandSchema.safeExtend({
|
|
6183
|
-
destinationCode:
|
|
6308
|
+
destinationCode: z87.string().regex(/^DST-[0-9]{6,}$/)
|
|
6184
6309
|
});
|
|
6185
|
-
var channelFeedbackReceiptQuerySchema =
|
|
6186
|
-
var channelFeedbackOriginalReceiptSchema =
|
|
6187
|
-
|
|
6188
|
-
|
|
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:
|
|
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
|
|
6197
|
-
var workspaceCode =
|
|
6198
|
-
var page =
|
|
6199
|
-
limit:
|
|
6200
|
-
cursor:
|
|
6201
|
-
}).strict();
|
|
6202
|
-
var businessObjectsQuerySchema =
|
|
6203
|
-
page.extend({ kind:
|
|
6204
|
-
page.extend({ kind:
|
|
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:
|
|
6331
|
+
kind: z88.literal("PROJECTS"),
|
|
6207
6332
|
workspaceCode,
|
|
6208
|
-
search:
|
|
6333
|
+
search: z88.string().trim().min(1).max(160).optional(),
|
|
6209
6334
|
status: projectStatusSchema.optional()
|
|
6210
6335
|
}).strict()
|
|
6211
6336
|
]);
|
|
6212
|
-
var projectCreationCommandSchema =
|
|
6337
|
+
var projectCreationCommandSchema = z88.object({
|
|
6213
6338
|
key: projectKeySchema,
|
|
6214
|
-
name:
|
|
6215
|
-
requestId:
|
|
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 =
|
|
6219
|
-
var result =
|
|
6220
|
-
project:
|
|
6221
|
-
businessCode:
|
|
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:
|
|
6348
|
+
name: z88.string(),
|
|
6224
6349
|
status: projectStatusSchema,
|
|
6225
6350
|
workspaceCode,
|
|
6226
|
-
tenantCode:
|
|
6351
|
+
tenantCode: z88.string().regex(/^TEN-[0-9]{6,}$/)
|
|
6227
6352
|
}).strict(),
|
|
6228
|
-
connection:
|
|
6353
|
+
connection: z88.object({ resource: z88.string().url(), authorizationRequired: z88.literal(true) }).strict()
|
|
6229
6354
|
}).strict();
|
|
6230
|
-
var projectCreationResultSchema = result.extend({ replayed:
|
|
6231
|
-
var projectCreationReceiptSchema =
|
|
6232
|
-
|
|
6233
|
-
|
|
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
|
|
6238
|
-
var kind2 =
|
|
6239
|
-
var foundationSurveyOperationSchema =
|
|
6240
|
-
var foundationSurveyCommandSchema =
|
|
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:
|
|
6243
|
-
expectedEditVersion:
|
|
6244
|
-
requestId:
|
|
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 =
|
|
6371
|
+
var foundationSurveyReceiptQuerySchema = z89.object({
|
|
6247
6372
|
kind: kind2,
|
|
6248
6373
|
operation: foundationSurveyOperationSchema,
|
|
6249
|
-
requestId:
|
|
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
|
|
6254
|
-
var requestId2 =
|
|
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 =
|
|
6381
|
+
var sourceLinksCommandSchema = z90.object({
|
|
6257
6382
|
requestId: requestId2,
|
|
6258
|
-
urls:
|
|
6383
|
+
urls: z90.array(z90.string().max(2048)).min(1).max(20)
|
|
6259
6384
|
}).strict();
|
|
6260
|
-
var sourceRegistrationReceiptQuerySchema =
|
|
6261
|
-
operation:
|
|
6385
|
+
var sourceRegistrationReceiptQuerySchema = z90.object({
|
|
6386
|
+
operation: z90.enum(["REGISTER", "LINKS"]),
|
|
6262
6387
|
requestId: requestId2
|
|
6263
6388
|
}).strict();
|
|
6264
|
-
var sourceRegistrationTargetSchema =
|
|
6265
|
-
|
|
6266
|
-
|
|
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 =
|
|
6269
|
-
entries:
|
|
6270
|
-
|
|
6271
|
-
index:
|
|
6272
|
-
input:
|
|
6273
|
-
state:
|
|
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:
|
|
6400
|
+
message: z90.string().nullable()
|
|
6276
6401
|
}).strict()
|
|
6277
6402
|
),
|
|
6278
|
-
registeredOnly:
|
|
6403
|
+
registeredOnly: z90.literal(true)
|
|
6279
6404
|
}).strict();
|
|
6280
|
-
var sourceRegistrationReceiptSchema =
|
|
6281
|
-
|
|
6282
|
-
state:
|
|
6283
|
-
result:
|
|
6405
|
+
var sourceRegistrationReceiptSchema = z90.discriminatedUnion("state", [
|
|
6406
|
+
z90.object({
|
|
6407
|
+
state: z90.literal("FOUND"),
|
|
6408
|
+
result: z90.union([sourceRefSchema, sourceLinksResultSchema])
|
|
6284
6409
|
}).strict(),
|
|
6285
|
-
|
|
6410
|
+
z90.object({ state: z90.literal("NOT_FOUND"), result: z90.null() }).strict(),
|
|
6286
6411
|
commandRejectedReceiptSchema
|
|
6287
6412
|
]);
|
|
6288
|
-
var sourceLinksCommandResultSchema =
|
|
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
|
|
6292
|
-
var materialUploadTargetSchema =
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
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 =
|
|
6422
|
+
var materialUploadQuerySchema = z91.object({ requestId: uuidSchema }).strict();
|
|
6298
6423
|
var materialUploadCommandSchema = materialUploadQuerySchema.extend({
|
|
6299
|
-
filename:
|
|
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:
|
|
6304
|
-
sha256:
|
|
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 =
|
|
6307
|
-
|
|
6308
|
-
|
|
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 =
|
|
6311
|
-
state:
|
|
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:
|
|
6316
|
-
uploadPath:
|
|
6317
|
-
method:
|
|
6318
|
-
contentType:
|
|
6319
|
-
fileField:
|
|
6320
|
-
authentication:
|
|
6321
|
-
preparedOnly:
|
|
6322
|
-
});
|
|
6323
|
-
var materialUploadCommandResultSchema =
|
|
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:
|
|
6450
|
+
replayed: z91.boolean()
|
|
6326
6451
|
});
|
|
6327
6452
|
|
|
6328
6453
|
// packages/contracts/src/material-reuse.ts
|
|
6329
|
-
import { z as
|
|
6330
|
-
var personalMaterialDetailQuerySchema =
|
|
6454
|
+
import { z as z92 } from "zod";
|
|
6455
|
+
var personalMaterialDetailQuerySchema = z92.object({ materialId: uuidSchema }).strict();
|
|
6331
6456
|
var personalMaterialUsesQuerySchema = personalMaterialDetailQuerySchema.extend({
|
|
6332
|
-
limit:
|
|
6333
|
-
cursor:
|
|
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:
|
|
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:
|
|
6474
|
+
operation: z92.enum(["GRANT", "STOP"])
|
|
6350
6475
|
}).strict();
|
|
6351
|
-
var personalMaterialUseResultSchema =
|
|
6476
|
+
var personalMaterialUseResultSchema = z92.object({
|
|
6352
6477
|
use: personalMaterialUseSchema,
|
|
6353
6478
|
origin: businessWriteOriginSchema
|
|
6354
6479
|
}).strict();
|
|
6355
|
-
var personalMaterialUseReceiptSchema =
|
|
6356
|
-
|
|
6357
|
-
|
|
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
|
|
6363
|
-
var sourceCandidatesQuerySchema =
|
|
6364
|
-
q:
|
|
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:
|
|
6367
|
-
cursor:
|
|
6491
|
+
limit: z93.number().int().min(1).max(20).default(8),
|
|
6492
|
+
cursor: z93.string().max(2048).optional()
|
|
6368
6493
|
}).strict();
|
|
6369
|
-
var sourceBindingCommandSchema =
|
|
6494
|
+
var sourceBindingCommandSchema = z93.object({
|
|
6370
6495
|
sourceId: uuidSchema,
|
|
6371
|
-
expectedBound:
|
|
6496
|
+
expectedBound: z93.boolean(),
|
|
6372
6497
|
requestId: uuidSchema
|
|
6373
6498
|
}).strict();
|
|
6374
|
-
var sourceBindingResultSchema =
|
|
6375
|
-
var sourceBindingReceiptQuerySchema =
|
|
6376
|
-
var sourceBindingReceiptSchema =
|
|
6377
|
-
|
|
6378
|
-
|
|
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
|
|
6384
|
-
var programCommandReceiptSchema =
|
|
6385
|
-
|
|
6386
|
-
|
|
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 =
|
|
6390
|
-
var fingerprint =
|
|
6391
|
-
var programDraftOpenCommandSchema =
|
|
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:
|
|
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 =
|
|
6522
|
+
var programActivationCommandSchema = z94.object({
|
|
6398
6523
|
requestId: requestId3,
|
|
6399
6524
|
programCode: businessCodeSchema,
|
|
6400
|
-
expectedUpdatedAt:
|
|
6525
|
+
expectedUpdatedAt: z94.string().datetime(),
|
|
6401
6526
|
foundationBasis: foundationProgramBasisSchema,
|
|
6402
6527
|
decision: humanDecisionDeclarationSchema.optional()
|
|
6403
6528
|
}).strict();
|
|
6404
|
-
var programCommandReceiptQuerySchema =
|
|
6405
|
-
var goalObservationCommandSchema =
|
|
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:
|
|
6409
|
-
goalId:
|
|
6410
|
-
startsAt:
|
|
6411
|
-
endsAt:
|
|
6412
|
-
value:
|
|
6413
|
-
sourceName:
|
|
6414
|
-
sourceReference:
|
|
6415
|
-
sourceMode:
|
|
6416
|
-
observedAt:
|
|
6417
|
-
note:
|
|
6418
|
-
}).strict();
|
|
6419
|
-
var goalObservationReceiptQuerySchema =
|
|
6420
|
-
var programBasisCommandSchema =
|
|
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:
|
|
6548
|
+
expectedUpdatedAt: z94.string().datetime(),
|
|
6424
6549
|
foundationBasis: foundationProgramBasisSchema
|
|
6425
6550
|
}).strict();
|
|
6426
|
-
var programSuggestionReadSchema =
|
|
6427
|
-
var programSuggestionApplySchema =
|
|
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:
|
|
6554
|
+
expectedUpdatedAt: z94.string().datetime().nullable(),
|
|
6430
6555
|
requestId: requestId3
|
|
6431
6556
|
}).strict();
|
|
6432
|
-
var programPreparationViewSchema =
|
|
6433
|
-
basis:
|
|
6434
|
-
version:
|
|
6557
|
+
var programPreparationViewSchema = z94.object({
|
|
6558
|
+
basis: z94.object({
|
|
6559
|
+
version: z94.literal(1),
|
|
6435
6560
|
fingerprint,
|
|
6436
|
-
sourceRefs:
|
|
6561
|
+
sourceRefs: z94.array(z94.string()).max(24),
|
|
6437
6562
|
goalFingerprint: fingerprint
|
|
6438
6563
|
}).strict(),
|
|
6439
6564
|
adoptionBasis: foundationProgramBasisSchema.nullable(),
|
|
6440
|
-
goals:
|
|
6441
|
-
alignment:
|
|
6442
|
-
currentDraft:
|
|
6443
|
-
referenceOnly:
|
|
6444
|
-
inputRead:
|
|
6445
|
-
capability:
|
|
6446
|
-
input:
|
|
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:
|
|
6449
|
-
capability:
|
|
6450
|
-
kind:
|
|
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:
|
|
6579
|
+
authority: z94.object({ preparationIsAdoption: z94.literal(false) })
|
|
6455
6580
|
}).strict();
|
|
6456
|
-
var programCommandResultSchema =
|
|
6581
|
+
var programCommandResultSchema = z94.object({
|
|
6457
6582
|
programCode: businessCodeSchema,
|
|
6458
|
-
updatedAt:
|
|
6459
|
-
status:
|
|
6460
|
-
activated:
|
|
6461
|
-
referenceOnly:
|
|
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 =
|
|
6465
|
-
var programGoalOptionsQuerySchema =
|
|
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
|
|
6469
|
-
var editorialProposalCommandSchema =
|
|
6470
|
-
|
|
6471
|
-
kind:
|
|
6472
|
-
requestId:
|
|
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
|
-
|
|
6476
|
-
kind:
|
|
6477
|
-
requestId:
|
|
6600
|
+
z95.object({
|
|
6601
|
+
kind: z95.literal("KERNEL"),
|
|
6602
|
+
requestId: z95.uuid(),
|
|
6478
6603
|
candidateRef: cfRefSchema,
|
|
6479
|
-
expectedReviewSha256:
|
|
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 =
|
|
6608
|
+
var editorialReadQuerySchema = z95.object({
|
|
6484
6609
|
kind: editorialKindSchema,
|
|
6485
|
-
limit:
|
|
6486
|
-
cursor:
|
|
6487
|
-
status:
|
|
6488
|
-
}).strict();
|
|
6489
|
-
var editorialReadSchema =
|
|
6490
|
-
var editorialDecisionCommandSchema =
|
|
6491
|
-
|
|
6492
|
-
kind:
|
|
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
|
-
|
|
6498
|
-
kind:
|
|
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 =
|
|
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
|
|
6569
|
-
var humanImprovementProposalSchema =
|
|
6570
|
-
requestId:
|
|
6571
|
-
observationCodes:
|
|
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:
|
|
6574
|
-
kindKey:
|
|
6575
|
-
title:
|
|
6576
|
-
summary:
|
|
6577
|
-
rationale:
|
|
6578
|
-
proposedChange:
|
|
6579
|
-
}).strict();
|
|
6580
|
-
var improvementListSchema =
|
|
6581
|
-
limit:
|
|
6582
|
-
cursor:
|
|
6583
|
-
q:
|
|
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:
|
|
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 =
|
|
6593
|
-
requestId:
|
|
6594
|
-
observedAt:
|
|
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:
|
|
6597
|
-
periodEnd:
|
|
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:
|
|
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 =
|
|
6618
|
-
operation:
|
|
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:
|
|
6690
|
+
requestId: z96.string().min(1).max(160)
|
|
6627
6691
|
}).strict();
|
|
6628
|
-
var strategyLearningReadSchema =
|
|
6629
|
-
var learningFeedbackCommandSchema =
|
|
6630
|
-
packageReviewFeedbackSchema.extend({ operation:
|
|
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:
|
|
6696
|
+
operation: z96.literal("PUBLICATION_OBSERVATION")
|
|
6633
6697
|
})
|
|
6634
6698
|
]);
|
|
6635
|
-
var publicationObservationReceiptSchema =
|
|
6699
|
+
var publicationObservationReceiptSchema = z96.object({
|
|
6636
6700
|
observationCode: businessCodeSchema,
|
|
6637
|
-
observedAt:
|
|
6638
|
-
sourceMode:
|
|
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
|
|
6644
|
-
var command4 = { requestId:
|
|
6645
|
-
var tenantRoleSchema =
|
|
6646
|
-
var teamListSchema =
|
|
6647
|
-
limit:
|
|
6648
|
-
cursor:
|
|
6649
|
-
q:
|
|
6650
|
-
status:
|
|
6651
|
-
}).strict();
|
|
6652
|
-
var teamMemberReadSchema =
|
|
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:
|
|
6718
|
+
includeBusiness: z97.boolean().default(false),
|
|
6655
6719
|
businessKind: memberBusinessKindSchema.optional(),
|
|
6656
|
-
businessCursor:
|
|
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 =
|
|
6725
|
+
var teamRegisterSchema = z97.object({
|
|
6662
6726
|
...command4,
|
|
6663
|
-
email:
|
|
6664
|
-
displayName:
|
|
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 =
|
|
6731
|
+
var teamUpdateSchema = z97.object({
|
|
6668
6732
|
...command4,
|
|
6669
6733
|
userCode: businessCodeSchema,
|
|
6670
|
-
expectedSha256:
|
|
6671
|
-
displayName:
|
|
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 =
|
|
6740
|
+
var teamDeactivateSchema = z97.object({
|
|
6677
6741
|
...command4,
|
|
6678
6742
|
userCode: businessCodeSchema,
|
|
6679
|
-
expectedSha256:
|
|
6743
|
+
expectedSha256: z97.string().regex(/^[a-f0-9]{64}$/)
|
|
6680
6744
|
}).strict();
|
|
6681
|
-
var projectAccessReadSchema =
|
|
6745
|
+
var projectAccessReadSchema = z97.object({ projectCode: businessCodeSchema, userCode: businessCodeSchema }).strict();
|
|
6682
6746
|
var projectAccessCommandSchema = projectAccessChangeSchema.extend({ ...command4, ...projectAccessReadSchema.shape }).strict();
|
|
6683
|
-
var administrationReceiptSchema =
|
|
6684
|
-
operation:
|
|
6685
|
-
requestId:
|
|
6747
|
+
var administrationReceiptSchema = z97.object({
|
|
6748
|
+
operation: z97.enum(["REGISTER", "UPDATE", "DEACTIVATE", "PROJECT_ACCESS"]),
|
|
6749
|
+
requestId: z97.uuid()
|
|
6686
6750
|
}).strict();
|
|
6687
|
-
var administrationMemberSchema =
|
|
6688
|
-
user:
|
|
6751
|
+
var administrationMemberSchema = z97.object({
|
|
6752
|
+
user: z97.object({
|
|
6689
6753
|
businessCode: businessCodeSchema,
|
|
6690
|
-
email:
|
|
6691
|
-
displayName:
|
|
6692
|
-
status:
|
|
6754
|
+
email: z97.string(),
|
|
6755
|
+
displayName: z97.string(),
|
|
6756
|
+
status: z97.enum(["ACTIVE", "DISABLED"])
|
|
6693
6757
|
}),
|
|
6694
|
-
status:
|
|
6695
|
-
roleTemplate:
|
|
6696
|
-
deactivatedAt:
|
|
6697
|
-
canManage:
|
|
6698
|
-
canEditDisplayName:
|
|
6699
|
-
canChangeRole:
|
|
6700
|
-
canViewBusiness:
|
|
6701
|
-
business:
|
|
6702
|
-
baselineSha256:
|
|
6703
|
-
credentialSetupRequired:
|
|
6704
|
-
credentialSetupHref:
|
|
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 =
|
|
6710
|
-
limit:
|
|
6711
|
-
cursor:
|
|
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 =
|
|
6714
|
-
teamRegisterSchema.extend({ operation:
|
|
6715
|
-
teamUpdateSchema.safeExtend({ operation:
|
|
6716
|
-
teamDeactivateSchema.extend({ operation:
|
|
6717
|
-
projectAccessCommandSchema.extend({ operation:
|
|
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:
|
|
6784
|
+
operation: z97.literal("PROJECT_ACCESS")
|
|
6721
6785
|
});
|
|
6722
6786
|
|
|
6723
6787
|
// packages/contracts/src/agent/capability-recovery.ts
|
|
@@ -6847,6 +6911,8 @@ var execution = (family, operation) => ({
|
|
|
6847
6911
|
});
|
|
6848
6912
|
var learning = (op) => rule("cf_get_learning_command_receipt", learningReceiptSchema, op);
|
|
6849
6913
|
var rules = {
|
|
6914
|
+
cf_save_test_record: rule("cf_get_test_record_receipt", testRecordReceiptSchema, "SAVE"),
|
|
6915
|
+
cf_cleanup_test_records: rule("cf_get_test_record_receipt", testRecordReceiptSchema, "CLEANUP"),
|
|
6850
6916
|
cf_register_source: rule(
|
|
6851
6917
|
"cf_get_source_registration_receipt",
|
|
6852
6918
|
sourceRegistrationReceiptQuerySchema,
|
|
@@ -7056,7 +7122,7 @@ function capabilityReceiptRead(name, input) {
|
|
|
7056
7122
|
}
|
|
7057
7123
|
|
|
7058
7124
|
// packages/contracts/src/agent/capability-status.ts
|
|
7059
|
-
import { z as
|
|
7125
|
+
import { z as z98 } from "zod";
|
|
7060
7126
|
var verification = {
|
|
7061
7127
|
capability: "cf_material_verification_status",
|
|
7062
7128
|
schema: materialVerificationIdSchema,
|
|
@@ -7074,7 +7140,7 @@ var rules2 = {
|
|
|
7074
7140
|
},
|
|
7075
7141
|
cf_tenant_material_scan_advance: {
|
|
7076
7142
|
capability: "cf_tenant_material_scan_status",
|
|
7077
|
-
schema:
|
|
7143
|
+
schema: z98.object({}).strict()
|
|
7078
7144
|
},
|
|
7079
7145
|
cf_sync_materials: {
|
|
7080
7146
|
capability: "cf_reconcile_materials",
|
|
@@ -7101,12 +7167,6 @@ function capabilityStatusRead(name, input) {
|
|
|
7101
7167
|
};
|
|
7102
7168
|
}
|
|
7103
7169
|
|
|
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
7170
|
// packages/cli-client/src/errors.ts
|
|
7111
7171
|
var CliError = class extends Error {
|
|
7112
7172
|
constructor(code2, message, outcome = "NOT_SENT", details) {
|
|
@@ -7132,6 +7192,154 @@ function safeError(error) {
|
|
|
7132
7192
|
};
|
|
7133
7193
|
}
|
|
7134
7194
|
|
|
7195
|
+
// packages/cli-client/src/capability-definition.ts
|
|
7196
|
+
function verifyCapabilityDefinition(raw, name, expectedHash) {
|
|
7197
|
+
const fail = () => new CliError(
|
|
7198
|
+
"INVALID_CAPABILITY_REPLY",
|
|
7199
|
+
"The exact capability definition or fingerprint is invalid.",
|
|
7200
|
+
"REJECTED"
|
|
7201
|
+
);
|
|
7202
|
+
if (Buffer.byteLength(JSON.stringify(raw) ?? "") > 68 * 1024) throw fail();
|
|
7203
|
+
const parsed = capabilityDefinitionSchema.safeParse(raw);
|
|
7204
|
+
if (!parsed.success || parsed.data.definition.name !== name || parsed.data.definition.inputSchema.type !== "object" || expectedHash && parsed.data.schemaSha256 !== expectedHash)
|
|
7205
|
+
throw fail();
|
|
7206
|
+
try {
|
|
7207
|
+
const hash5 = createHash("sha256").update(
|
|
7208
|
+
executionCanonicalJson(parsed.data.definition, {
|
|
7209
|
+
maxDepth: 32,
|
|
7210
|
+
maxNodes: 20100,
|
|
7211
|
+
maxLength: 11e4
|
|
7212
|
+
})
|
|
7213
|
+
).digest("hex");
|
|
7214
|
+
if (hash5 !== parsed.data.schemaSha256) throw fail();
|
|
7215
|
+
} catch {
|
|
7216
|
+
throw fail();
|
|
7217
|
+
}
|
|
7218
|
+
return parsed.data;
|
|
7219
|
+
}
|
|
7220
|
+
var CapabilityDefinitionCache = class {
|
|
7221
|
+
values = /* @__PURE__ */ new Map();
|
|
7222
|
+
remember(value) {
|
|
7223
|
+
const verified = verifyCapabilityDefinition(value, value.definition.name);
|
|
7224
|
+
const key2 = `${verified.definition.name}:AGENT_V3:${verified.schemaSha256}`;
|
|
7225
|
+
if (this.values.size >= 64) this.values.delete(this.values.keys().next().value);
|
|
7226
|
+
this.values.set(key2, structuredClone(verified));
|
|
7227
|
+
}
|
|
7228
|
+
get(name, hash5) {
|
|
7229
|
+
const value = this.values.get(`${name}:AGENT_V3:${hash5}`);
|
|
7230
|
+
return value ? structuredClone(value) : void 0;
|
|
7231
|
+
}
|
|
7232
|
+
};
|
|
7233
|
+
|
|
7234
|
+
// packages/cli-client/src/capability-errors.ts
|
|
7235
|
+
function capabilityError(tool5, data, readOnly = true, input) {
|
|
7236
|
+
if (!/^cf_[a-z0-9_]{1,100}$/.test(tool5) || !data || typeof data !== "object" || !("error" in data))
|
|
7237
|
+
return null;
|
|
7238
|
+
const error = data.error;
|
|
7239
|
+
if (!error || typeof error !== "object" || !("code" in error) || typeof error.code !== "string" || !/^[A-Z0-9_]{1,100}$/u.test(error.code))
|
|
7240
|
+
return null;
|
|
7241
|
+
const code2 = error.code;
|
|
7242
|
+
const outcome = "outcome" in error && error.outcome === "UNKNOWN" ? "UNKNOWN" : "outcome" in error && error.outcome === "REJECTED" || readOnly || isKnownCapabilityRejection(code2, tool5) ? "REJECTED" : "UNKNOWN";
|
|
7243
|
+
const recovery = capabilityRecovery(code2, outcome, tool5);
|
|
7244
|
+
const receipt = outcome === "UNKNOWN" || recovery === "FIND_ORIGINAL_RECEIPT" ? capabilityReceiptRead(tool5, input) : void 0;
|
|
7245
|
+
const status = outcome === "UNKNOWN" ? capabilityStatusRead(tool5, input) : void 0;
|
|
7246
|
+
const validation = code2 === "CAPABILITY_INPUT_INVALID" && outcome === "REJECTED" && "validation" in error && Buffer.byteLength(JSON.stringify(error.validation) ?? "") <= 4096 ? capabilityInputRepairSchema.safeParse(error.validation) : null;
|
|
7247
|
+
const delegatedTarget = tool5 === "cf_validate_capability" && input && typeof input === "object" && Object.hasOwn(input, "name") ? input.name : void 0;
|
|
7248
|
+
const validationMatches = validation?.success && (validation.data.schema.arguments.name === tool5 || typeof delegatedTarget === "string" && validation.data.schema.arguments.name === delegatedTarget);
|
|
7249
|
+
return new CliError(
|
|
7250
|
+
code2,
|
|
7251
|
+
"The capability operation was not completed. Follow the indicated recovery before another operation.",
|
|
7252
|
+
outcome,
|
|
7253
|
+
{
|
|
7254
|
+
recovery,
|
|
7255
|
+
...receipt ? { receipt } : {},
|
|
7256
|
+
...status ? { status } : {},
|
|
7257
|
+
...validation?.success && validationMatches ? { validation: validation.data } : {}
|
|
7258
|
+
}
|
|
7259
|
+
);
|
|
7260
|
+
}
|
|
7261
|
+
|
|
7262
|
+
// packages/cli-client/src/transport.ts
|
|
7263
|
+
import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
7264
|
+
|
|
7265
|
+
// packages/cli-client/src/http.ts
|
|
7266
|
+
function boundedFetch(origin2, timeout) {
|
|
7267
|
+
return async (input, init) => {
|
|
7268
|
+
const requestUrl = new URL(input instanceof Request ? input.url : String(input));
|
|
7269
|
+
if (requestUrl.origin !== origin2 || requestUrl.username || requestUrl.password)
|
|
7270
|
+
throw new CliError("UNTRUSTED_ENDPOINT", "Cross-origin credential requests are forbidden.");
|
|
7271
|
+
const signal = AbortSignal.any([
|
|
7272
|
+
AbortSignal.timeout(timeout),
|
|
7273
|
+
...init?.signal ? [init.signal] : []
|
|
7274
|
+
]);
|
|
7275
|
+
const response = await fetch(input, { ...init, signal, redirect: "error" });
|
|
7276
|
+
if (!response.body) return response;
|
|
7277
|
+
const reader = response.body.getReader();
|
|
7278
|
+
const chunks = [];
|
|
7279
|
+
let length = 0;
|
|
7280
|
+
try {
|
|
7281
|
+
for (; ; ) {
|
|
7282
|
+
const { done, value } = await reader.read();
|
|
7283
|
+
if (done) break;
|
|
7284
|
+
length += value.length;
|
|
7285
|
+
if (length > 8 * 1024 * 1024)
|
|
7286
|
+
throw new CliError("RESPONSE_TOO_LARGE", "Response exceeds 8 MiB. Read a smaller page.");
|
|
7287
|
+
chunks.push(value);
|
|
7288
|
+
}
|
|
7289
|
+
} catch (error) {
|
|
7290
|
+
await reader.cancel().catch(() => void 0);
|
|
7291
|
+
throw error;
|
|
7292
|
+
} finally {
|
|
7293
|
+
reader.releaseLock();
|
|
7294
|
+
}
|
|
7295
|
+
return new Response([204, 205, 304].includes(response.status) ? null : Buffer.concat(chunks), {
|
|
7296
|
+
status: response.status,
|
|
7297
|
+
statusText: response.statusText,
|
|
7298
|
+
headers: response.headers
|
|
7299
|
+
});
|
|
7300
|
+
};
|
|
7301
|
+
}
|
|
7302
|
+
async function oauthPost(resource, path, body, timeout) {
|
|
7303
|
+
const origin2 = new URL(resource).origin;
|
|
7304
|
+
let response;
|
|
7305
|
+
try {
|
|
7306
|
+
response = await boundedFetch(origin2, timeout)(`${origin2}${path}`, {
|
|
7307
|
+
method: "POST",
|
|
7308
|
+
headers: {
|
|
7309
|
+
"content-type": body instanceof URLSearchParams ? "application/x-www-form-urlencoded" : "application/json"
|
|
7310
|
+
},
|
|
7311
|
+
body: body instanceof URLSearchParams ? body.toString() : JSON.stringify(body)
|
|
7312
|
+
});
|
|
7313
|
+
} catch {
|
|
7314
|
+
throw new CliError(
|
|
7315
|
+
"OAUTH_NETWORK_FAILURE",
|
|
7316
|
+
"OAuth request failed; no automatic retry was made.",
|
|
7317
|
+
"UNKNOWN"
|
|
7318
|
+
);
|
|
7319
|
+
}
|
|
7320
|
+
if (!response.ok)
|
|
7321
|
+
throw new CliError(
|
|
7322
|
+
"OAUTH_REJECTED",
|
|
7323
|
+
"CF rejected the OAuth request. Reauthorize if the grant expired or was revoked.",
|
|
7324
|
+
"REJECTED"
|
|
7325
|
+
);
|
|
7326
|
+
try {
|
|
7327
|
+
return await response.json();
|
|
7328
|
+
} catch {
|
|
7329
|
+
throw new CliError(
|
|
7330
|
+
"INVALID_OAUTH_RESPONSE",
|
|
7331
|
+
"CF returned an invalid OAuth response.",
|
|
7332
|
+
"UNKNOWN"
|
|
7333
|
+
);
|
|
7334
|
+
}
|
|
7335
|
+
}
|
|
7336
|
+
|
|
7337
|
+
// packages/cli-client/src/profile.ts
|
|
7338
|
+
import { mkdir, lstat, open as open2, rename, unlink } from "node:fs/promises";
|
|
7339
|
+
import { randomUUID } from "node:crypto";
|
|
7340
|
+
import { homedir } from "node:os";
|
|
7341
|
+
import { join } from "node:path";
|
|
7342
|
+
|
|
7135
7343
|
// packages/cli-client/src/input.ts
|
|
7136
7344
|
import { open } from "node:fs/promises";
|
|
7137
7345
|
import { constants } from "node:fs";
|
|
@@ -7278,101 +7486,6 @@ var ProfileStore = class {
|
|
|
7278
7486
|
}
|
|
7279
7487
|
};
|
|
7280
7488
|
|
|
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
7489
|
// packages/cli-client/src/knowledge-errors.ts
|
|
7377
7490
|
var codes = /* @__PURE__ */ new Set([
|
|
7378
7491
|
"FORBIDDEN",
|
|
@@ -7402,13 +7515,13 @@ var codes = /* @__PURE__ */ new Set([
|
|
|
7402
7515
|
"MCP_KNOWLEDGE_ENCODING_INVALID",
|
|
7403
7516
|
"MCP_KNOWLEDGE_UNAVAILABLE"
|
|
7404
7517
|
]);
|
|
7405
|
-
function knowledgeError(
|
|
7518
|
+
function knowledgeError(tool5, raw) {
|
|
7406
7519
|
if (![
|
|
7407
7520
|
"cf_list_knowledge",
|
|
7408
7521
|
"cf_read_knowledge",
|
|
7409
7522
|
"cf_read_source",
|
|
7410
7523
|
"cf_material_verification_status"
|
|
7411
|
-
].includes(
|
|
7524
|
+
].includes(tool5))
|
|
7412
7525
|
return null;
|
|
7413
7526
|
const value = object2(raw), error = object2(value?.error);
|
|
7414
7527
|
if (!error || typeof error.code !== "string" || !codes.has(error.code)) return null;
|
|
@@ -7462,8 +7575,8 @@ async function withClient(profile, timeout, operation) {
|
|
|
7462
7575
|
await client.close().catch(() => void 0);
|
|
7463
7576
|
}
|
|
7464
7577
|
}
|
|
7465
|
-
async function callTool(client,
|
|
7466
|
-
const original = ["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(
|
|
7578
|
+
async function callTool(client, tool5, input, timeout, readOnly, errorToolName = tool5.name) {
|
|
7579
|
+
const original = ["cf_call_capability", "cf_read_capability", "cf_write_capability"].includes(tool5.name) && input.name === errorToolName ? input.arguments : input;
|
|
7467
7580
|
const unknown = (code2, message) => {
|
|
7468
7581
|
const receipt = capabilityReceiptRead(errorToolName, original);
|
|
7469
7582
|
const status = capabilityStatusRead(errorToolName, original);
|
|
@@ -7476,8 +7589,8 @@ async function callTool(client, tool4, input, timeout, readOnly, errorToolName =
|
|
|
7476
7589
|
let result2;
|
|
7477
7590
|
try {
|
|
7478
7591
|
result2 = await client.callTool(
|
|
7479
|
-
{ name:
|
|
7480
|
-
{ timeout, toolDefinition:
|
|
7592
|
+
{ name: tool5.name, arguments: input },
|
|
7593
|
+
{ timeout, toolDefinition: tool5, allowInputRequired: true }
|
|
7481
7594
|
);
|
|
7482
7595
|
} catch {
|
|
7483
7596
|
if (!readOnly)
|
|
@@ -7554,9 +7667,47 @@ function decodedText(content) {
|
|
|
7554
7667
|
}
|
|
7555
7668
|
}
|
|
7556
7669
|
|
|
7670
|
+
// packages/cli-client/src/agent-capabilities.ts
|
|
7671
|
+
var tool = {
|
|
7672
|
+
name: "cf_discover_capabilities",
|
|
7673
|
+
inputSchema: {
|
|
7674
|
+
type: "object",
|
|
7675
|
+
...capabilityQuerySchema["~standard"].jsonSchema.input({ target: "draft-2020-12" })
|
|
7676
|
+
},
|
|
7677
|
+
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
7678
|
+
};
|
|
7679
|
+
async function findAgentCapabilities(client, input = {}, timeout = 3e4) {
|
|
7680
|
+
if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4)
|
|
7681
|
+
throw new CliError("INVALID_TIMEOUT", "Timeout must be 100\u2013120000 milliseconds.");
|
|
7682
|
+
const query = capabilityQuerySchema.safeParse({ ...input, profile: "AGENT_V3" });
|
|
7683
|
+
if (!query.success)
|
|
7684
|
+
throw new CliError(
|
|
7685
|
+
"INVALID_CAPABILITY_QUERY",
|
|
7686
|
+
"Use a bounded query and optional group/limit/cursor."
|
|
7687
|
+
);
|
|
7688
|
+
const raw = await callTool(client, tool, query.data, timeout, true);
|
|
7689
|
+
if (Buffer.byteLength(JSON.stringify(raw) ?? "") > 8192) throw invalid();
|
|
7690
|
+
const parsed = agentCapabilityPageSchema.safeParse(raw);
|
|
7691
|
+
if (!parsed.success) throw invalid();
|
|
7692
|
+
for (const item of parsed.data.items) {
|
|
7693
|
+
if (item.definition) {
|
|
7694
|
+
if (!item.schemaSha256) throw invalid();
|
|
7695
|
+
verifyCapabilityDefinition(item.definition, item.name, item.schemaSha256);
|
|
7696
|
+
}
|
|
7697
|
+
}
|
|
7698
|
+
return parsed.data;
|
|
7699
|
+
}
|
|
7700
|
+
function invalid() {
|
|
7701
|
+
return new CliError(
|
|
7702
|
+
"INVALID_CAPABILITY_REPLY",
|
|
7703
|
+
"The discovery response does not match AGENT_V3 or its byte limit.",
|
|
7704
|
+
"REJECTED"
|
|
7705
|
+
);
|
|
7706
|
+
}
|
|
7707
|
+
|
|
7557
7708
|
// packages/cli-client/src/schema-pages.ts
|
|
7558
|
-
import { createHash } from "node:crypto";
|
|
7559
|
-
var
|
|
7709
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
7710
|
+
var tool2 = (name, schema2) => ({
|
|
7560
7711
|
name,
|
|
7561
7712
|
inputSchema: {
|
|
7562
7713
|
type: "object",
|
|
@@ -7564,28 +7715,28 @@ var tool = (name, schema2) => ({
|
|
|
7564
7715
|
},
|
|
7565
7716
|
annotations: { readOnlyHint: true }
|
|
7566
7717
|
});
|
|
7567
|
-
var describe =
|
|
7568
|
-
var read =
|
|
7718
|
+
var describe = tool2("cf_describe_capability", capabilityDescribeSchema);
|
|
7719
|
+
var read = tool2("cf_read_capability_schema", capabilitySchemaReadSchema);
|
|
7569
7720
|
async function readNativeCapabilityDescriptor(client, name, timeout = 3e4) {
|
|
7570
|
-
if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw
|
|
7721
|
+
if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid2("NOT_SENT");
|
|
7571
7722
|
const input = capabilityDescribeSchema.safeParse({ name });
|
|
7572
|
-
if (!input.success) throw
|
|
7723
|
+
if (!input.success) throw invalid2("NOT_SENT");
|
|
7573
7724
|
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
|
|
7725
|
+
if (!result2.success || Buffer.byteLength(JSON.stringify(raw)) > 8 * 1024) throw invalid2();
|
|
7575
7726
|
if ((result2.data.schemaVersion === 1 ? result2.data.definition.name : result2.data.name) !== name)
|
|
7576
|
-
throw
|
|
7727
|
+
throw invalid2();
|
|
7577
7728
|
return result2.data;
|
|
7578
7729
|
}
|
|
7579
7730
|
async function readNativeCapabilitySchemaPage(client, input, timeout = 3e4) {
|
|
7580
|
-
if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw
|
|
7731
|
+
if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid2("NOT_SENT");
|
|
7581
7732
|
const query = capabilitySchemaReadSchema.safeParse(input);
|
|
7582
|
-
if (!query.success) throw
|
|
7733
|
+
if (!query.success) throw invalid2("NOT_SENT");
|
|
7583
7734
|
const raw = await callTool(client, read, query.data, timeout, true);
|
|
7584
7735
|
const parsed = capabilitySchemaPageSchema.safeParse(raw);
|
|
7585
|
-
if (!parsed.success || Buffer.byteLength(JSON.stringify(raw)) > 6e3) throw
|
|
7736
|
+
if (!parsed.success || Buffer.byteLength(JSON.stringify(raw)) > 6e3) throw invalid2();
|
|
7586
7737
|
const p = parsed.data, end = p.offset + [...p.text].length;
|
|
7587
7738
|
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
|
|
7739
|
+
throw invalid2();
|
|
7589
7740
|
return p;
|
|
7590
7741
|
}
|
|
7591
7742
|
async function loadCapabilitySchemaPages(client, descriptor, timeout) {
|
|
@@ -7593,7 +7744,7 @@ async function loadCapabilitySchemaPages(client, descriptor, timeout) {
|
|
|
7593
7744
|
let offset = 0, contentHash, total;
|
|
7594
7745
|
for (let i = 0; i < 128; i++) {
|
|
7595
7746
|
const remaining = deadline - Date.now();
|
|
7596
|
-
if (remaining < 100) throw
|
|
7747
|
+
if (remaining < 100) throw invalid2();
|
|
7597
7748
|
const p = await readNativeCapabilitySchemaPage(
|
|
7598
7749
|
client,
|
|
7599
7750
|
{ name: descriptor.name, expectedSchemaSha256: descriptor.schemaSha256, offset },
|
|
@@ -7601,25 +7752,25 @@ async function loadCapabilitySchemaPages(client, descriptor, timeout) {
|
|
|
7601
7752
|
);
|
|
7602
7753
|
const end = offset + [...p.text].length;
|
|
7603
7754
|
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
|
|
7755
|
+
throw invalid2();
|
|
7605
7756
|
contentHash = p.contentSha256;
|
|
7606
7757
|
total = p.totalCharacters;
|
|
7607
7758
|
parts.push(p.text);
|
|
7608
7759
|
if (!p.hasMore) {
|
|
7609
7760
|
const text3 = parts.join("");
|
|
7610
|
-
if (Buffer.byteLength(text3) !== descriptor.byteLength ||
|
|
7611
|
-
throw
|
|
7761
|
+
if (Buffer.byteLength(text3) !== descriptor.byteLength || createHash2("sha256").update(text3).digest("hex") !== contentHash)
|
|
7762
|
+
throw invalid2();
|
|
7612
7763
|
try {
|
|
7613
7764
|
return JSON.parse(text3);
|
|
7614
7765
|
} catch {
|
|
7615
|
-
throw
|
|
7766
|
+
throw invalid2();
|
|
7616
7767
|
}
|
|
7617
7768
|
}
|
|
7618
7769
|
offset = end;
|
|
7619
7770
|
}
|
|
7620
|
-
throw
|
|
7771
|
+
throw invalid2();
|
|
7621
7772
|
}
|
|
7622
|
-
function
|
|
7773
|
+
function invalid2(outcome = "REJECTED") {
|
|
7623
7774
|
return new CliError(
|
|
7624
7775
|
"INVALID_CAPABILITY_REPLY",
|
|
7625
7776
|
"Capability descriptor/schema pages did not match their bounded identity and hashes.",
|
|
@@ -7628,9 +7779,7 @@ function invalid(outcome = "REJECTED") {
|
|
|
7628
7779
|
}
|
|
7629
7780
|
|
|
7630
7781
|
// packages/cli-client/src/capabilities.ts
|
|
7631
|
-
import { createHash as createHash2 } from "node:crypto";
|
|
7632
7782
|
var maxPage = 8 * 1024;
|
|
7633
|
-
var maxDefinition = 68 * 1024;
|
|
7634
7783
|
function bootstrap(name, inputSchema) {
|
|
7635
7784
|
return { name, inputSchema, annotations: { readOnlyHint: true, openWorldHint: false } };
|
|
7636
7785
|
}
|
|
@@ -7640,6 +7789,11 @@ var queryTool = bootstrap("cf_discover_capabilities", {
|
|
|
7640
7789
|
});
|
|
7641
7790
|
async function findNativeCapabilities(client, input = {}, timeout = 3e4) {
|
|
7642
7791
|
checkTimeout(timeout);
|
|
7792
|
+
if (input.profile)
|
|
7793
|
+
throw new CliError(
|
|
7794
|
+
"INVALID_CAPABILITY_QUERY",
|
|
7795
|
+
"Use findAgentCapabilities for the AGENT_V3 profile."
|
|
7796
|
+
);
|
|
7643
7797
|
const query = capabilityQuerySchema.safeParse(input);
|
|
7644
7798
|
if (!query.success)
|
|
7645
7799
|
throw new CliError(
|
|
@@ -7648,9 +7802,9 @@ async function findNativeCapabilities(client, input = {}, timeout = 3e4) {
|
|
|
7648
7802
|
);
|
|
7649
7803
|
const raw = await callTool(client, queryTool, query.data, timeout, true);
|
|
7650
7804
|
if (typeof JSON.stringify(raw) !== "string" || Buffer.byteLength(JSON.stringify(raw)) > maxPage)
|
|
7651
|
-
throw
|
|
7805
|
+
throw invalid3();
|
|
7652
7806
|
const result2 = capabilityPageSchema.safeParse(raw);
|
|
7653
|
-
if (!result2.success) throw
|
|
7807
|
+
if (!result2.success) throw invalid3();
|
|
7654
7808
|
return result2.data;
|
|
7655
7809
|
}
|
|
7656
7810
|
async function describeNativeCapability(client, name, timeout = 3e4) {
|
|
@@ -7660,26 +7814,9 @@ async function describeNativeCapability(client, name, timeout = 3e4) {
|
|
|
7660
7814
|
throw new CliError("INVALID_CAPABILITY_NAME", "Use an exact cf_ capability name.");
|
|
7661
7815
|
const descriptor = await readNativeCapabilityDescriptor(client, input.data.name, timeout);
|
|
7662
7816
|
const raw = descriptor.schemaVersion === 1 ? descriptor : await loadCapabilitySchemaPages(client, descriptor, timeout);
|
|
7663
|
-
|
|
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;
|
|
7817
|
+
return verifyCapabilityDefinition(raw, name, descriptor.schemaSha256);
|
|
7681
7818
|
}
|
|
7682
|
-
function
|
|
7819
|
+
function invalid3() {
|
|
7683
7820
|
return new CliError(
|
|
7684
7821
|
"INVALID_CAPABILITY_REPLY",
|
|
7685
7822
|
"The capability reply exceeded its limit or did not match its exact contract.",
|
|
@@ -7715,8 +7852,8 @@ async function nativeToolDefinition(client, name, timeout) {
|
|
|
7715
7852
|
"TOOL_UNAVAILABLE",
|
|
7716
7853
|
"A typed catalogue page is required; no business call was sent."
|
|
7717
7854
|
);
|
|
7718
|
-
const
|
|
7719
|
-
if (
|
|
7855
|
+
const tool5 = page2.tools.find((t) => t.name === name);
|
|
7856
|
+
if (tool5) return { tool: tool5, schemaSha256: null };
|
|
7720
7857
|
if (!page2.nextCursor || seen.has(page2.nextCursor)) break;
|
|
7721
7858
|
seen.add(page2.nextCursor);
|
|
7722
7859
|
cursor = page2.nextCursor;
|
|
@@ -7761,10 +7898,10 @@ var writeInvoke = {
|
|
|
7761
7898
|
async function getNativeBusinessSummary(client, input, timeout = 3e4) {
|
|
7762
7899
|
checkTimeout2(timeout);
|
|
7763
7900
|
const query = agentSummaryInputSchema.safeParse(input);
|
|
7764
|
-
if (!query.success) throw
|
|
7901
|
+
if (!query.success) throw invalid4("NOT_SENT");
|
|
7765
7902
|
const raw = await callTool(client, summary, query.data, timeout, true), parsed = agentSummarySchema.safeParse(raw);
|
|
7766
7903
|
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
|
|
7904
|
+
throw invalid4();
|
|
7768
7905
|
return parsed.data;
|
|
7769
7906
|
}
|
|
7770
7907
|
async function callNativeCapability(client, input, timeout = 3e4) {
|
|
@@ -7776,13 +7913,13 @@ async function readNativeCapability(client, input, timeout = 3e4) {
|
|
|
7776
7913
|
async function writeNativeCapability(client, input, timeout = 3e4) {
|
|
7777
7914
|
return invokeCapability(client, input, writeInvoke, false, timeout);
|
|
7778
7915
|
}
|
|
7779
|
-
async function invokeCapability(client, input,
|
|
7916
|
+
async function invokeCapability(client, input, tool5, readOnly, timeout) {
|
|
7780
7917
|
checkTimeout2(timeout);
|
|
7781
7918
|
const args = capabilityCallSchema.safeParse(input);
|
|
7782
|
-
if (!args.success) throw
|
|
7783
|
-
return callTool(client,
|
|
7919
|
+
if (!args.success) throw invalid4("NOT_SENT");
|
|
7920
|
+
return callTool(client, tool5, args.data, timeout, readOnly, args.data.name);
|
|
7784
7921
|
}
|
|
7785
|
-
function
|
|
7922
|
+
function invalid4(outcome = "REJECTED") {
|
|
7786
7923
|
return new CliError(
|
|
7787
7924
|
"INVALID_COMPACT_INPUT_OR_REPLY",
|
|
7788
7925
|
"Use exact schema identity, summary source and hash-bound continuation.",
|
|
@@ -7790,12 +7927,12 @@ function invalid3(outcome = "REJECTED") {
|
|
|
7790
7927
|
);
|
|
7791
7928
|
}
|
|
7792
7929
|
function checkTimeout2(v) {
|
|
7793
|
-
if (!Number.isInteger(v) || v < 100 || v > 12e4) throw
|
|
7930
|
+
if (!Number.isInteger(v) || v < 100 || v > 12e4) throw invalid4("NOT_SENT");
|
|
7794
7931
|
}
|
|
7795
7932
|
|
|
7796
7933
|
// packages/cli-client/src/document-page.ts
|
|
7797
7934
|
import { createHash as createHash3 } from "node:crypto";
|
|
7798
|
-
var
|
|
7935
|
+
var tool3 = {
|
|
7799
7936
|
name: "cf_read_business_document",
|
|
7800
7937
|
annotations: { readOnlyHint: true },
|
|
7801
7938
|
inputSchema: {
|
|
@@ -7804,36 +7941,36 @@ var tool2 = {
|
|
|
7804
7941
|
}
|
|
7805
7942
|
};
|
|
7806
7943
|
async function readNativeDocumentPage(client, raw, timeout = 3e4) {
|
|
7807
|
-
if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw
|
|
7944
|
+
if (!Number.isInteger(timeout) || timeout < 100 || timeout > 12e4) throw invalid5("NOT_SENT");
|
|
7808
7945
|
const input = businessDocumentInputSchema.safeParse(raw);
|
|
7809
|
-
if (!input.success) throw
|
|
7810
|
-
const value = await callTool(client,
|
|
7811
|
-
if (Buffer.byteLength(JSON.stringify(value)) > 6e3) throw
|
|
7946
|
+
if (!input.success) throw invalid5("NOT_SENT");
|
|
7947
|
+
const value = await callTool(client, tool3, input.data, timeout, true, input.data.sourceTool);
|
|
7948
|
+
if (Buffer.byteLength(JSON.stringify(value)) > 6e3) throw invalid5();
|
|
7812
7949
|
const result2 = businessDocumentPageSchema.safeParse(value);
|
|
7813
|
-
if (!result2.success) throw
|
|
7950
|
+
if (!result2.success) throw invalid5();
|
|
7814
7951
|
const p = result2.data, q = input.data;
|
|
7815
7952
|
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
|
|
7953
|
+
throw invalid5();
|
|
7817
7954
|
if (p.mode === "JSON_TEXT_PAGE") {
|
|
7818
7955
|
const end = p.offset + [...p.text].length;
|
|
7819
7956
|
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
|
|
7957
|
+
throw invalid5();
|
|
7821
7958
|
} else if (p.mode === "INDEX") {
|
|
7822
7959
|
const end = p.offset + p.items.length;
|
|
7823
7960
|
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
|
|
7961
|
+
throw invalid5();
|
|
7825
7962
|
} else {
|
|
7826
|
-
if (q.format !== "INDEX" || q.offset !== 0) throw
|
|
7963
|
+
if (q.format !== "INDEX" || q.offset !== 0) throw invalid5();
|
|
7827
7964
|
try {
|
|
7828
7965
|
if (createHash3("sha256").update(JSON.stringify(p.data)).digest("hex") !== p.contentSha256)
|
|
7829
|
-
throw
|
|
7966
|
+
throw invalid5();
|
|
7830
7967
|
} catch {
|
|
7831
|
-
throw
|
|
7968
|
+
throw invalid5();
|
|
7832
7969
|
}
|
|
7833
7970
|
}
|
|
7834
7971
|
return p;
|
|
7835
7972
|
}
|
|
7836
|
-
function
|
|
7973
|
+
function invalid5(outcome = "REJECTED") {
|
|
7837
7974
|
return new CliError(
|
|
7838
7975
|
"INVALID_DOCUMENT_PAGE",
|
|
7839
7976
|
"Read one exact source/path page with its original document hash; do not mix versions or treat an index as complete content.",
|
|
@@ -7842,11 +7979,11 @@ function invalid4(outcome = "REJECTED") {
|
|
|
7842
7979
|
}
|
|
7843
7980
|
|
|
7844
7981
|
// packages/cli-client/src/review-links.ts
|
|
7845
|
-
function reviewLinks(resource,
|
|
7982
|
+
function reviewLinks(resource, tool5, result2, input = {}) {
|
|
7846
7983
|
const url = new URL(resource);
|
|
7847
|
-
if (
|
|
7984
|
+
if (tool5.startsWith("cf_material_verification_") && /^\/mcp\/tenants\/TEN-\d{6,}$/.test(url.pathname))
|
|
7848
7985
|
return { materialsUrl: `${url.origin}${url.pathname.replace("/mcp", "")}/knowledge/materials` };
|
|
7849
|
-
if (["cf_start_task", "cf_get_task_status", "cf_find_task_receipt"].includes(
|
|
7986
|
+
if (["cf_start_task", "cf_get_task_status", "cf_find_task_receipt"].includes(tool5) && /^\/mcp\/projects\/PRJ-\d{6,}$/.test(url.pathname)) {
|
|
7850
7987
|
const value = result2 && typeof result2 === "object" && "receipt" in result2 ? result2.receipt : result2;
|
|
7851
7988
|
if (value && typeof value === "object" && "workRequestCode" in value && typeof value.workRequestCode === "string" && /^JOB-\d{6,}$/.test(value.workRequestCode)) {
|
|
7852
7989
|
return {
|
|
@@ -7855,29 +7992,29 @@ function reviewLinks(resource, tool4, result2, input = {}) {
|
|
|
7855
7992
|
}
|
|
7856
7993
|
return {};
|
|
7857
7994
|
}
|
|
7858
|
-
if (
|
|
7995
|
+
if (tool5 === "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)) {
|
|
7859
7996
|
return { readingUrl: new URL(result2.readingPath, url.origin).href };
|
|
7860
7997
|
}
|
|
7861
|
-
if (
|
|
7998
|
+
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
7999
|
return { reviewUrl: `${url.origin}/me/survey/intelligence/${result2.businessCode}` };
|
|
7863
8000
|
}
|
|
7864
8001
|
const project = /^\/mcp\/projects\/(PRJ-\d{6,})$/.exec(url.pathname)?.[1];
|
|
7865
8002
|
const tenant = /^\/mcp\/tenants\/(TEN-\d{6,})$/.exec(url.pathname)?.[1];
|
|
7866
|
-
if (
|
|
8003
|
+
if (tool5.includes("foundation")) {
|
|
7867
8004
|
const kind3 = input.kind ?? input.target;
|
|
7868
8005
|
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
8006
|
return { workspaceUrl: url.origin + path };
|
|
7870
8007
|
}
|
|
7871
8008
|
if (project) {
|
|
7872
8009
|
let area = "";
|
|
7873
|
-
if (
|
|
7874
|
-
else if (
|
|
8010
|
+
if (tool5.includes("program")) area = "/program";
|
|
8011
|
+
else if (tool5.includes("review") || tool5.includes("feedback") || tool5.includes("improvement"))
|
|
7875
8012
|
area = "/insights/performance";
|
|
7876
|
-
else if (
|
|
7877
|
-
else if (
|
|
7878
|
-
else if (
|
|
7879
|
-
else if (
|
|
7880
|
-
else if (
|
|
8013
|
+
else if (tool5.includes("channel_account")) area = "/destinations";
|
|
8014
|
+
else if (tool5.includes("package") || tool5.includes("publication")) area = "/packages";
|
|
8015
|
+
else if (tool5.includes("action") || tool5.includes("asset")) area = "/actions";
|
|
8016
|
+
else if (tool5.includes("opportunit")) area = "/opportunities";
|
|
8017
|
+
else if (tool5.includes("knowledge") || tool5.includes("material") || tool5.includes("source"))
|
|
7881
8018
|
area = "/sources";
|
|
7882
8019
|
return { workspaceUrl: `${url.origin}/projects/${project}${area}` };
|
|
7883
8020
|
}
|
|
@@ -7907,7 +8044,7 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
|
|
|
7907
8044
|
throw new CliError("INVALID_VIEW", "Use SUMMARY, INDEX, PAGE or ORIGINAL.");
|
|
7908
8045
|
if (options.expectedSchemaSha256 !== void 0 && !/^[a-f0-9]{64}$/.test(options.expectedSchemaSha256))
|
|
7909
8046
|
throw new CliError("INVALID_SCHEMA_HASH", "Supply the observed schema SHA-256.");
|
|
7910
|
-
const { tool:
|
|
8047
|
+
const { tool: tool5, schemaSha256 } = await nativeToolDefinition(client, name, timeout);
|
|
7911
8048
|
if (options.expectedSchemaSha256 !== void 0 && schemaSha256 !== options.expectedSchemaSha256)
|
|
7912
8049
|
throw new CliError(
|
|
7913
8050
|
"CAPABILITY_SCHEMA_CHANGED",
|
|
@@ -7916,7 +8053,7 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
|
|
|
7916
8053
|
{ recovery: "READ_EXACT_SCHEMA" }
|
|
7917
8054
|
);
|
|
7918
8055
|
const summary2 = agentSummarySourceSchema.safeParse(name), document2 = businessDocumentToolSchema.safeParse(name);
|
|
7919
|
-
const read2 =
|
|
8056
|
+
const read2 = tool5.annotations?.readOnlyHint === true;
|
|
7920
8057
|
const view = options.view ?? (schemaSha256 && read2 ? summary2.success ? "SUMMARY" : document2.success ? "INDEX" : "ORIGINAL" : "ORIGINAL");
|
|
7921
8058
|
if (view !== "ORIGINAL" && (!schemaSha256 || !read2 || (view === "SUMMARY" ? !summary2.success : !document2.success)))
|
|
7922
8059
|
throw new CliError(
|
|
@@ -7946,7 +8083,7 @@ async function callNativeTool(client, name, input, resource, options = {}, timeo
|
|
|
7946
8083
|
{ name, expectedSchemaSha256: schemaSha256, arguments: input, delivery: "ORIGINAL" },
|
|
7947
8084
|
timeout
|
|
7948
8085
|
);
|
|
7949
|
-
else result2 = await callTool(client,
|
|
8086
|
+
else result2 = await callTool(client, tool5, input, timeout, read2);
|
|
7950
8087
|
return { tool: name, view, result: result2, links: reviewLinks(resource, name, result2, input) };
|
|
7951
8088
|
}
|
|
7952
8089
|
function check(name, input, timeout) {
|
|
@@ -8210,7 +8347,7 @@ async function uploadNativeMaterial(connection, file, timeout = 3e4) {
|
|
|
8210
8347
|
}
|
|
8211
8348
|
|
|
8212
8349
|
// packages/cli-client/src/business-search.ts
|
|
8213
|
-
var
|
|
8350
|
+
var tool4 = (name, schema2) => ({
|
|
8214
8351
|
name,
|
|
8215
8352
|
inputSchema: {
|
|
8216
8353
|
type: "object",
|
|
@@ -8218,22 +8355,22 @@ var tool3 = (name, schema2) => ({
|
|
|
8218
8355
|
},
|
|
8219
8356
|
annotations: { readOnlyHint: true, openWorldHint: false }
|
|
8220
8357
|
});
|
|
8221
|
-
var search =
|
|
8222
|
-
var document =
|
|
8358
|
+
var search = tool4("cf_search_business", businessSearchQuerySchema);
|
|
8359
|
+
var document = tool4("cf_read_business_document", businessDocumentInputSchema);
|
|
8223
8360
|
async function searchNativeBusiness(client, raw = {}, timeout = 3e4) {
|
|
8224
8361
|
checkTimeout3(timeout);
|
|
8225
8362
|
const input = businessSearchQuerySchema.safeParse(raw);
|
|
8226
|
-
if (!input.success) throw
|
|
8363
|
+
if (!input.success) throw invalid6("INVALID_BUSINESS_SEARCH_QUERY", "NOT_SENT");
|
|
8227
8364
|
const value = await callTool(client, search, input.data, timeout, true);
|
|
8228
8365
|
const parsed = businessSearchPageSchema.safeParse(value);
|
|
8229
8366
|
if (!parsed.success || Buffer.byteLength(JSON.stringify(value)) > 16 * 1024)
|
|
8230
|
-
throw
|
|
8367
|
+
throw invalid6("INVALID_BUSINESS_SEARCH_REPLY");
|
|
8231
8368
|
return parsed.data;
|
|
8232
8369
|
}
|
|
8233
8370
|
async function readNativeBusinessPage(client, raw, timeout = 3e4) {
|
|
8234
8371
|
checkTimeout3(timeout);
|
|
8235
8372
|
const input = businessContentPageReadSchema.safeParse(raw);
|
|
8236
|
-
if (!input.success) throw
|
|
8373
|
+
if (!input.success) throw invalid6("INVALID_BUSINESS_CONTENT_QUERY", "NOT_SENT");
|
|
8237
8374
|
const { offset, expectedDocumentHash, ...sourceInput } = input.data;
|
|
8238
8375
|
const args = businessDocumentInputSchema.parse({
|
|
8239
8376
|
sourceTool: "cf_read_business_content",
|
|
@@ -8244,24 +8381,25 @@ async function readNativeBusinessPage(client, raw, timeout = 3e4) {
|
|
|
8244
8381
|
const value = await callTool(client, document, args, timeout, true);
|
|
8245
8382
|
const parsed = businessContentPageSchema.safeParse(value);
|
|
8246
8383
|
if (!parsed.success || Buffer.byteLength(JSON.stringify(value)) > 6e3)
|
|
8247
|
-
throw
|
|
8384
|
+
throw invalid6("INVALID_BUSINESS_CONTENT_REPLY");
|
|
8248
8385
|
const p = parsed.data;
|
|
8249
8386
|
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
|
|
8387
|
+
throw invalid6("INVALID_BUSINESS_CONTENT_REPLY");
|
|
8251
8388
|
return p;
|
|
8252
8389
|
}
|
|
8253
|
-
function
|
|
8390
|
+
function invalid6(code2, outcome = "REJECTED") {
|
|
8254
8391
|
return new CliError(code2, "Use the exact bounded search or content-page contract.", outcome);
|
|
8255
8392
|
}
|
|
8256
8393
|
function checkTimeout3(value) {
|
|
8257
8394
|
if (!Number.isInteger(value) || value < 100 || value > 12e4)
|
|
8258
|
-
throw
|
|
8395
|
+
throw invalid6("INVALID_TIMEOUT", "NOT_SENT");
|
|
8259
8396
|
}
|
|
8260
8397
|
|
|
8261
8398
|
// packages/cli-client/src/client.ts
|
|
8262
8399
|
async function withNativeAgentClient(connection, action, options = {}) {
|
|
8263
8400
|
const timeout = options.timeoutMs ?? 3e4;
|
|
8264
8401
|
checkTimeout4(timeout);
|
|
8402
|
+
const definitions = new CapabilityDefinitionCache();
|
|
8265
8403
|
return withClient(
|
|
8266
8404
|
connection,
|
|
8267
8405
|
timeout,
|
|
@@ -8283,7 +8421,24 @@ async function withNativeAgentClient(connection, action, options = {}) {
|
|
|
8283
8421
|
searchBusiness: (input) => searchNativeBusiness(client, input, timeout),
|
|
8284
8422
|
readBusinessPage: (input) => readNativeBusinessPage(client, input, timeout),
|
|
8285
8423
|
findCapabilities: (input) => findNativeCapabilities(client, input, timeout),
|
|
8286
|
-
|
|
8424
|
+
discoverCapabilities: async (input) => {
|
|
8425
|
+
const page2 = await findAgentCapabilities(client, input, timeout);
|
|
8426
|
+
for (const item of page2.items) if (item.definition) definitions.remember(item.definition);
|
|
8427
|
+
return page2;
|
|
8428
|
+
},
|
|
8429
|
+
describeCapability: async (name, expectedHash) => {
|
|
8430
|
+
const cached = expectedHash ? definitions.get(name, expectedHash) : void 0;
|
|
8431
|
+
if (cached) return cached;
|
|
8432
|
+
const definition = await describeNativeCapability(client, name, timeout);
|
|
8433
|
+
if (expectedHash && definition.schemaSha256 !== expectedHash)
|
|
8434
|
+
throw new CliError(
|
|
8435
|
+
"CAPABILITY_SCHEMA_CHANGED",
|
|
8436
|
+
"Discover the current definition again.",
|
|
8437
|
+
"REJECTED"
|
|
8438
|
+
);
|
|
8439
|
+
definitions.remember(definition);
|
|
8440
|
+
return definition;
|
|
8441
|
+
}
|
|
8287
8442
|
})
|
|
8288
8443
|
);
|
|
8289
8444
|
}
|
|
@@ -8940,7 +9095,7 @@ async function businessCommand(client, parsed, input, resource) {
|
|
|
8940
9095
|
);
|
|
8941
9096
|
if (resolved.mode === "discover") {
|
|
8942
9097
|
const query = parsed.words.slice(2).join(" ");
|
|
8943
|
-
return
|
|
9098
|
+
return findAgentCapabilities(client, query ? { query } : input, timeout);
|
|
8944
9099
|
}
|
|
8945
9100
|
if (resolved.mode === "describe")
|
|
8946
9101
|
return describeNativeCapability(client, parsed.words[2], timeout);
|
|
@@ -9119,6 +9274,7 @@ export {
|
|
|
9119
9274
|
callNativeCapability,
|
|
9120
9275
|
callNativeTool,
|
|
9121
9276
|
describeNativeCapability,
|
|
9277
|
+
findAgentCapabilities,
|
|
9122
9278
|
findNativeCapabilities,
|
|
9123
9279
|
getNativeBusinessSummary,
|
|
9124
9280
|
inspectNativeTool,
|