@peasant-labs/schema 0.32.0 → 0.33.1

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.
@@ -1440,6 +1440,7 @@ export const zSchemaVersionResponse = z.object({
1440
1440
  contentCapabilities: z.array(z.string()).optional(),
1441
1441
  minPullContractVersion: z.string().optional(),
1442
1442
  minPushContractVersion: z.string(),
1443
+ pullContractMaxVersion: z.string().optional(),
1443
1444
  pullContractVersion: z.string().optional(),
1444
1445
  pushContractVersion: z.string(),
1445
1446
  supportedTargetKinds: z.array(z.string()).nullable(),
@@ -2223,7 +2224,7 @@ export const zAnnotationsPayload = z.object({
2223
2224
  axis: zAnnotationAxis,
2224
2225
  id: z.string()
2225
2226
  });
2226
- export const zPullAnnotation = z.object({
2227
+ export const zLegacyPullAnnotation = z.object({
2227
2228
  annotatorKind: zAnnotatorKind.optional(),
2228
2229
  annotatorName: z.string().optional(),
2229
2230
  authorUserId: z.string(),
@@ -2248,6 +2249,12 @@ export const zPullAnnotation = z.object({
2248
2249
  typeId: z.string().optional(),
2249
2250
  typeName: z.string().optional(),
2250
2251
  value: z.string().optional()
2252
+ }).superRefine((value, context) => {
2253
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zLegacyPullAnnotation: " + reason });
2254
+ if (value.authorUserId === "" && value.authorUsername !== "anon")
2255
+ fail("an empty id carries a username; a hidden person would be named; send anon beside an empty id");
2256
+ if (value.authorUserId !== "" && value.authorUsername === "")
2257
+ fail("an id carries no username; send the profile's username, or an empty id with anon");
2251
2258
  });
2252
2259
  export const zQualitySession = z.object({
2253
2260
  date: z.string(),
@@ -3022,6 +3029,10 @@ export const zVillageListTranscriptAttestation = z.object({
3022
3029
  org_login: z.string(),
3023
3030
  transcript_id: zTranscriptID
3024
3031
  });
3032
+ export const zVillageListUserOrganization = z.object({
3033
+ avatar_url: z.string().nullable(),
3034
+ org_login: z.string()
3035
+ });
3025
3036
  export const zVillageMetadataUserOrganization = z.object({
3026
3037
  avatar_url: z.string().nullable(),
3027
3038
  fetched_at: z.iso.datetime(),
@@ -3047,6 +3058,95 @@ export const zVillageProjectNameSource = z.enum([
3047
3058
  * Check-run conclusion policy for a collective's linked repositories when no prompts are attached
3048
3059
  */
3049
3060
  export const zVillagePromptsCheckMode = z.enum(['informational', 'required']);
3061
+ /**
3062
+ * Village Public Owner
3063
+ *
3064
+ * A person as another viewer sees them. The server resolves anonymity per viewer; consumers render what they receive and never re-derive the rule. profile carries id, username, display_name, and avatar_url; anonymous carries only its kind, with no id. Readers treat an unknown kind as anonymous.
3065
+ */
3066
+ export const zVillagePublicOwner = z.union([
3067
+ z.object({
3068
+ avatar_url: z.string().nullable(),
3069
+ display_name: z.string().nullable(),
3070
+ id: z.uuid().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/),
3071
+ kind: z.literal('profile'),
3072
+ username: z.string().min(1)
3073
+ }),
3074
+ z.object({
3075
+ kind: z.literal('anonymous')
3076
+ }),
3077
+ z.object({
3078
+ kind: z.string().min(1).refine((kind) => !["profile", "anonymous"].includes(kind))
3079
+ }).transform(() => ({ kind: 'anonymous' }))
3080
+ ]);
3081
+ export const zPullAnnotation = z.object({
3082
+ annotatorKind: zAnnotatorKind.optional(),
3083
+ annotatorName: z.string().optional(),
3084
+ author: zVillagePublicOwner,
3085
+ confidence: z.number().nullish(),
3086
+ contentHash: z.string().nullish(),
3087
+ createdAt: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }).optional(),
3088
+ id: z.string().optional(),
3089
+ isPrimary: z.boolean().optional(),
3090
+ provenance: zProvenance.optional(),
3091
+ reason: z.string().nullish(),
3092
+ supersededBy: z.string().nullish(),
3093
+ targetAnnotationId: z.string().nullish(),
3094
+ targetAssociationId: zAssociationID.optional(),
3095
+ targetContentHash: z.string().nullish(),
3096
+ targetEntryEndIndex: z.int().nullish(),
3097
+ targetEntryIndex: z.int().nullish(),
3098
+ targetFilePath: z.string().nullish(),
3099
+ targetKind: zTargetKind.optional(),
3100
+ targetProjectHash: zProjectHash.optional(),
3101
+ targetSessionId: z.string().nullish(),
3102
+ typeId: z.string().optional(),
3103
+ typeName: z.string().optional(),
3104
+ value: z.string().optional()
3105
+ });
3106
+ export const zVillageCollectiveContributor = z.object({
3107
+ contributor: zVillagePublicOwner,
3108
+ transcript_count: z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
3109
+ });
3110
+ export const zVillageCollectiveMember = z.object({
3111
+ github_orgs: z.array(z.string()),
3112
+ joined_at: z.iso.datetime(),
3113
+ member: zVillagePublicOwner,
3114
+ role: zVillageCollectiveRole
3115
+ }).superRefine((value, context) => {
3116
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageCollectiveMember: " + reason });
3117
+ if (value.member.kind !== "profile" && value.github_orgs.length > 0)
3118
+ fail("github_orgs lists organizations beside an anonymous member; emit none for an anonymous member");
3119
+ });
3120
+ export const zVillagePendingShare = z.object({
3121
+ branch: z.string().nullable(),
3122
+ input_submission_count: z.int().gte(0).lte(9007199254740991).optional(),
3123
+ local_id: zSessionID,
3124
+ model_provider: z.string(),
3125
+ owner: zVillagePublicOwner,
3126
+ parent_session_id: zSessionID.nullable(),
3127
+ parent_transcript_id: zTranscriptID.nullable(),
3128
+ project_hash: zProjectHash.nullable(),
3129
+ project_name: z.string().nullable(),
3130
+ purpose: zSessionPurpose.optional(),
3131
+ relationships: z.array(zSessionRelationship).optional(),
3132
+ root_session_id: zSessionID.nullish(),
3133
+ shared_at: z.iso.datetime(),
3134
+ title: z.string().nullable(),
3135
+ transcript_id: zTranscriptID
3136
+ }).superRefine((value, context) => {
3137
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillagePendingShare: " + reason });
3138
+ if (value.owner.kind !== "profile") {
3139
+ const present = ["project_hash", "project_name", "branch"].filter((field) => { const v = value[field]; return v !== null && v !== undefined; });
3140
+ if (present.length > 0)
3141
+ fail(present.join(", ") + " identify the repository of an anonymous owner; withhold every repository field (null, or omitted on the pull envelope) when the owner is anonymous");
3142
+ }
3143
+ });
3144
+ /**
3145
+ * Village Public Owner Kind
3146
+ *
3147
+ * How a person is shown to the viewer: their public profile, or anonymous. Readers treat a kind they do not know as anonymous.
3148
+ */
3149
+ export const zVillagePublicOwnerKind = z.enum(['profile', 'anonymous']);
3050
3150
  /**
3051
3151
  * Village Pull Request Attachment State
3052
3152
  *
@@ -3191,6 +3291,86 @@ export const zVillageTranscriptVisibility = z.enum([
3191
3291
  'shared',
3192
3292
  'public'
3193
3293
  ]);
3294
+ export const zVillageCollectiveTranscript = z.object({
3295
+ blob_size_bytes: z.int().nullable(),
3296
+ compute_version: z.int().nullable(),
3297
+ computed_at: z.iso.datetime().nullable(),
3298
+ content_hash: zTranscriptContentHash.nullable(),
3299
+ description: z.string().nullable(),
3300
+ diagnostics_partial: z.boolean().nullable(),
3301
+ diagnostics_warnings: z.array(zDiagnosticEntry).nullable(),
3302
+ discovery_turns: z.int().nullable(),
3303
+ duration_ms: z.int().nullable(),
3304
+ exploration_ratio: z.number().nullable(),
3305
+ files_touched: z.int().nullable(),
3306
+ git_branch: z.string().nullable(),
3307
+ git_remote: z.string().nullable(),
3308
+ harness_version: z.string().nullable(),
3309
+ id: zTranscriptID,
3310
+ ingested_at: z.iso.datetime().nullable(),
3311
+ input_submission_count: z.int().gte(0).lte(9007199254740991).optional(),
3312
+ license_id: zLicense.nullable(),
3313
+ lines_changed: z.int().nullable(),
3314
+ local_id: zSessionID,
3315
+ m2_token_outcome_ratio: z.number().nullable(),
3316
+ m3_unique_tool_count: z.int().nullable(),
3317
+ m4_consecutive_error_max: z.int().nullable(),
3318
+ m4_error_recovery_count: z.int().nullable(),
3319
+ m5_avg_message_tokens: z.int().nullable(),
3320
+ m5_context_utilization_pct: z.number().nullable(),
3321
+ m5_peak_context_tokens: z.int().nullable(),
3322
+ m6_lines_survived: z.int().nullable(),
3323
+ m6_lines_total: z.int().nullable(),
3324
+ m6_output_survival_pct: z.number().nullable(),
3325
+ m7_spec_has_constraints: z.boolean().nullable(),
3326
+ m7_spec_has_examples: z.boolean().nullable(),
3327
+ m7_spec_word_count: z.int().nullable(),
3328
+ model_name: z.string().nullable(),
3329
+ model_provider: z.string(),
3330
+ outcome: zSessionOutcome.nullable(),
3331
+ owner: zVillagePublicOwner,
3332
+ parent_session_id: zSessionID.nullable(),
3333
+ parent_transcript_id: zTranscriptID.nullable(),
3334
+ project_display_name: z.string().nullable(),
3335
+ project_hash: zProjectHash.nullable(),
3336
+ project_name: z.string().nullable(),
3337
+ project_name_source: zVillageProjectNameSource.nullable(),
3338
+ project_remote_label: z.string().nullable(),
3339
+ published_at: z.iso.datetime(),
3340
+ pull_requests: zVillagePullRequestsSummary,
3341
+ purpose: zSessionPurpose.optional(),
3342
+ relationships: z.array(zSessionRelationship).optional(),
3343
+ retry_loops: z.int().nullable(),
3344
+ retry_tokens_wasted: z.int().nullable(),
3345
+ root_session_id: zSessionID.nullish(),
3346
+ schema_version: z.string(),
3347
+ scope_breadth: z.int().nullable(),
3348
+ session_end: z.iso.datetime().nullable(),
3349
+ session_origin: zSessionOrigin,
3350
+ session_start: z.iso.datetime().nullable(),
3351
+ signal_density: z.number().nullable(),
3352
+ source_format: zSourceFormat.nullable(),
3353
+ spec_quality_score: z.number().nullable(),
3354
+ subagent_count: z.int().nullable(),
3355
+ subagents: z.array(z.record(z.string(), z.unknown())).nullable(),
3356
+ title: z.string().nullable(),
3357
+ title_generated: z.string().nullable(),
3358
+ token_count: z.int().nullable(),
3359
+ tokens_in: z.int().nullable(),
3360
+ tokens_out: z.int().nullable(),
3361
+ tool_call_count: z.int().nullable(),
3362
+ turn_count: z.int().nullable(),
3363
+ updated_at: z.iso.datetime(),
3364
+ visibility: zVillageTranscriptVisibility,
3365
+ within_session_reverts: z.int().nullable()
3366
+ }).superRefine((value, context) => {
3367
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageCollectiveTranscript: " + reason });
3368
+ if (value.owner.kind !== "profile") {
3369
+ const present = ["git_branch", "git_remote", "project_hash", "project_name", "project_display_name", "project_name_source", "project_remote_label"].filter((field) => { const v = value[field]; return v !== null && v !== undefined; });
3370
+ if (present.length > 0)
3371
+ fail(present.join(", ") + " identify the repository of an anonymous owner; withhold every repository field (null, or omitted on the pull envelope) when the owner is anonymous");
3372
+ }
3373
+ });
3194
3374
  export const zVillageContributableTranscript = z.object({
3195
3375
  already_shared: z.boolean(),
3196
3376
  git_branch: z.string().nullable(),
@@ -3217,6 +3397,77 @@ export const zVillagePullRequestAttachedTranscript = z.object({
3217
3397
  title: z.string().nullable(),
3218
3398
  transcript_id: zTranscriptID
3219
3399
  });
3400
+ export const zVillageTranscript = z.object({
3401
+ blob_size_bytes: z.int().nullable(),
3402
+ compute_version: z.int().nullable(),
3403
+ computed_at: z.iso.datetime().nullable(),
3404
+ content_hash: zTranscriptContentHash.nullable(),
3405
+ description: z.string().nullable(),
3406
+ diagnostics_partial: z.boolean().nullable(),
3407
+ diagnostics_warnings: z.array(zDiagnosticEntry).nullable(),
3408
+ discovery_turns: z.int().nullable(),
3409
+ duration_ms: z.int().nullable(),
3410
+ exploration_ratio: z.number().nullable(),
3411
+ files_touched: z.int().nullable(),
3412
+ git_branch: z.string().nullable(),
3413
+ git_remote: z.string().nullable(),
3414
+ harness_version: z.string().nullable(),
3415
+ id: zTranscriptID,
3416
+ ingested_at: z.iso.datetime().nullable(),
3417
+ input_submission_count: z.int().gte(0).lte(9007199254740991).optional(),
3418
+ license_id: zLicense.nullable(),
3419
+ lines_changed: z.int().nullable(),
3420
+ local_id: zSessionID,
3421
+ m2_token_outcome_ratio: z.number().nullable(),
3422
+ m3_unique_tool_count: z.int().nullable(),
3423
+ m4_consecutive_error_max: z.int().nullable(),
3424
+ m4_error_recovery_count: z.int().nullable(),
3425
+ m5_avg_message_tokens: z.int().nullable(),
3426
+ m5_context_utilization_pct: z.number().nullable(),
3427
+ m5_peak_context_tokens: z.int().nullable(),
3428
+ m6_lines_survived: z.int().nullable(),
3429
+ m6_lines_total: z.int().nullable(),
3430
+ m6_output_survival_pct: z.number().nullable(),
3431
+ m7_spec_has_constraints: z.boolean().nullable(),
3432
+ m7_spec_has_examples: z.boolean().nullable(),
3433
+ m7_spec_word_count: z.int().nullable(),
3434
+ model_name: z.string().nullable(),
3435
+ model_provider: z.string(),
3436
+ outcome: zSessionOutcome.nullable(),
3437
+ parent_session_id: zSessionID.nullable(),
3438
+ parent_transcript_id: zTranscriptID.nullable(),
3439
+ project_display_name: z.string().nullable(),
3440
+ project_hash: zProjectHash.nullable(),
3441
+ project_name: z.string().nullable(),
3442
+ project_name_source: zVillageProjectNameSource.nullable(),
3443
+ project_remote_label: z.string().nullable(),
3444
+ published_at: z.iso.datetime(),
3445
+ purpose: zSessionPurpose.optional(),
3446
+ relationships: z.array(zSessionRelationship).optional(),
3447
+ retry_loops: z.int().nullable(),
3448
+ retry_tokens_wasted: z.int().nullable(),
3449
+ root_session_id: zSessionID.nullish(),
3450
+ schema_version: z.string(),
3451
+ scope_breadth: z.int().nullable(),
3452
+ session_end: z.iso.datetime().nullable(),
3453
+ session_origin: zSessionOrigin,
3454
+ session_start: z.iso.datetime().nullable(),
3455
+ signal_density: z.number().nullable(),
3456
+ source_format: zSourceFormat.nullable(),
3457
+ spec_quality_score: z.number().nullable(),
3458
+ subagent_count: z.int().nullable(),
3459
+ subagents: z.array(z.record(z.string(), z.unknown())).nullable(),
3460
+ title: z.string().nullable(),
3461
+ title_generated: z.string().nullable(),
3462
+ token_count: z.int().nullable(),
3463
+ tokens_in: z.int().nullable(),
3464
+ tokens_out: z.int().nullable(),
3465
+ tool_call_count: z.int().nullable(),
3466
+ turn_count: z.int().nullable(),
3467
+ updated_at: z.iso.datetime(),
3468
+ visibility: zVillageTranscriptVisibility,
3469
+ within_session_reverts: z.int().nullable()
3470
+ });
3220
3471
  /**
3221
3472
  * Village UUID
3222
3473
  *
@@ -3421,7 +3672,7 @@ export const zSyncPushResponse = z.object({
3421
3672
  export const zVillageCollective = z.object({
3422
3673
  acceptance_mode: zVillageCollectiveAcceptanceMode,
3423
3674
  created_at: z.iso.datetime(),
3424
- created_by: zVillageUUID,
3675
+ creator: zVillagePublicOwner,
3425
3676
  data_access: zVillageCollectiveDataAccess,
3426
3677
  description: z.string().nullable(),
3427
3678
  display_members: z.boolean(),
@@ -3433,16 +3684,10 @@ export const zVillageCollective = z.object({
3433
3684
  transcript_deletion_policy: zVillageTranscriptDeletionPolicy,
3434
3685
  updated_at: z.iso.datetime()
3435
3686
  });
3436
- export const zVillageCollectiveContributor = z.object({
3437
- avatar_url: z.string().nullable(),
3438
- github_username: z.string(),
3439
- id: zVillageUUID,
3440
- transcript_count: z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
3441
- });
3442
3687
  export const zVillageCollectiveDetailRecord = z.object({
3443
3688
  acceptance_mode: zVillageCollectiveAcceptanceMode,
3444
3689
  created_at: z.iso.datetime(),
3445
- created_by: zVillageUUID,
3690
+ creator: zVillagePublicOwner,
3446
3691
  data_access: zVillageCollectiveDataAccess,
3447
3692
  description: z.string().nullable(),
3448
3693
  display_members: z.boolean(),
@@ -3454,14 +3699,16 @@ export const zVillageCollectiveDetailRecord = z.object({
3454
3699
  transcript_deletion_policy: zVillageTranscriptDeletionPolicy,
3455
3700
  updated_at: z.iso.datetime()
3456
3701
  });
3457
- export const zVillageCollectiveMember = z.object({
3458
- avatar_url: z.string().nullable(),
3459
- display_name: z.string().nullable(),
3460
- github_orgs: z.array(z.string()),
3461
- github_username: z.string(),
3462
- id: zVillageUUID,
3463
- joined_at: z.iso.datetime(),
3464
- role: zVillageCollectiveRole
3702
+ export const zVillageCollectiveDetailResponse = z.object({
3703
+ can_read: z.boolean(),
3704
+ contributors: z.array(zVillageCollectiveContributor),
3705
+ group: zVillageCollectiveDetailRecord,
3706
+ members: z.array(zVillageCollectiveMember),
3707
+ models: z.array(zVillageCollectiveModelBreakdown),
3708
+ pending_members: z.array(zVillageCollectiveMember).optional(),
3709
+ stats: zVillageCollectiveTranscriptStats,
3710
+ transcripts: z.array(zVillageCollectiveTranscript),
3711
+ your_role: zVillageCollectiveViewerRole
3465
3712
  });
3466
3713
  export const zVillageCollectiveSearchResult = z.object({
3467
3714
  description: z.string().nullable(),
@@ -3482,92 +3729,6 @@ export const zVillageCollectiveSubmission = z.object({
3482
3729
  title: z.string().nullable(),
3483
3730
  transcript_id: zTranscriptID
3484
3731
  });
3485
- export const zVillageCollectiveTranscript = z.object({
3486
- blob_size_bytes: z.int().nullable(),
3487
- compute_version: z.int().nullable(),
3488
- computed_at: z.iso.datetime().nullable(),
3489
- content_hash: zTranscriptContentHash.nullable(),
3490
- description: z.string().nullable(),
3491
- diagnostics_partial: z.boolean().nullable(),
3492
- diagnostics_warnings: z.array(zDiagnosticEntry).nullable(),
3493
- discovery_turns: z.int().nullable(),
3494
- duration_ms: z.int().nullable(),
3495
- exploration_ratio: z.number().nullable(),
3496
- files_touched: z.int().nullable(),
3497
- git_branch: z.string().nullable(),
3498
- git_remote: z.string().nullable(),
3499
- harness_version: z.string().nullable(),
3500
- id: zTranscriptID,
3501
- ingested_at: z.iso.datetime().nullable(),
3502
- input_submission_count: z.int().gte(0).lte(9007199254740991).optional(),
3503
- license_id: zLicense.nullable(),
3504
- lines_changed: z.int().nullable(),
3505
- local_id: zSessionID,
3506
- m2_token_outcome_ratio: z.number().nullable(),
3507
- m3_unique_tool_count: z.int().nullable(),
3508
- m4_consecutive_error_max: z.int().nullable(),
3509
- m4_error_recovery_count: z.int().nullable(),
3510
- m5_avg_message_tokens: z.int().nullable(),
3511
- m5_context_utilization_pct: z.number().nullable(),
3512
- m5_peak_context_tokens: z.int().nullable(),
3513
- m6_lines_survived: z.int().nullable(),
3514
- m6_lines_total: z.int().nullable(),
3515
- m6_output_survival_pct: z.number().nullable(),
3516
- m7_spec_has_constraints: z.boolean().nullable(),
3517
- m7_spec_has_examples: z.boolean().nullable(),
3518
- m7_spec_word_count: z.int().nullable(),
3519
- model_name: z.string().nullable(),
3520
- model_provider: z.string(),
3521
- outcome: zSessionOutcome.nullable(),
3522
- owner_avatar_url: z.string().nullable(),
3523
- owner_id: zVillageUUID,
3524
- owner_is_discoverable: z.boolean(),
3525
- owner_username: z.string(),
3526
- parent_session_id: zSessionID.nullable(),
3527
- project_display_name: z.string(),
3528
- project_hash: zProjectHash,
3529
- project_name: z.string().nullable(),
3530
- project_name_source: zVillageProjectNameSource,
3531
- project_remote_label: z.string(),
3532
- published_at: z.iso.datetime(),
3533
- pull_requests: zVillagePullRequestsSummary,
3534
- purpose: zSessionPurpose.optional(),
3535
- relationships: z.array(zSessionRelationship).optional(),
3536
- retry_loops: z.int().nullable(),
3537
- retry_tokens_wasted: z.int().nullable(),
3538
- root_session_id: zSessionID.nullish(),
3539
- schema_version: z.string(),
3540
- scope_breadth: z.int().nullable(),
3541
- session_end: z.iso.datetime().nullable(),
3542
- session_origin: zSessionOrigin,
3543
- session_start: z.iso.datetime().nullable(),
3544
- signal_density: z.number().nullable(),
3545
- source_format: zSourceFormat.nullable(),
3546
- spec_quality_score: z.number().nullable(),
3547
- subagent_count: z.int().nullable(),
3548
- subagents: z.array(z.record(z.string(), z.unknown())).nullable(),
3549
- title: z.string().nullable(),
3550
- title_generated: z.string().nullable(),
3551
- token_count: z.int().nullable(),
3552
- tokens_in: z.int().nullable(),
3553
- tokens_out: z.int().nullable(),
3554
- tool_call_count: z.int().nullable(),
3555
- turn_count: z.int().nullable(),
3556
- updated_at: z.iso.datetime(),
3557
- visibility: zVillageTranscriptVisibility,
3558
- within_session_reverts: z.int().nullable()
3559
- });
3560
- export const zVillageCollectiveDetailResponse = z.object({
3561
- can_read: z.boolean(),
3562
- contributors: z.array(zVillageCollectiveContributor),
3563
- group: zVillageCollectiveDetailRecord,
3564
- members: z.array(zVillageCollectiveMember),
3565
- models: z.array(zVillageCollectiveModelBreakdown),
3566
- pending_members: z.array(zVillageCollectiveMember).optional(),
3567
- stats: zVillageCollectiveTranscriptStats,
3568
- transcripts: z.array(zVillageCollectiveTranscript),
3569
- your_role: zVillageCollectiveViewerRole
3570
- });
3571
3732
  export const zVillageContributableResponse = z.object({
3572
3733
  group_id: zVillageUUID,
3573
3734
  transcripts: z.array(zVillageContributableTranscript)
@@ -3601,18 +3762,13 @@ export const zVillageLinkedRepository = z.object({
3601
3762
  installation_id: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
3602
3763
  is_private: z.boolean(),
3603
3764
  last_synced_at: z.iso.datetime().nullable(),
3604
- linked_by: zVillageUUID,
3765
+ linked_by: zVillagePublicOwner,
3605
3766
  name: z.string(),
3606
3767
  owner: z.string()
3607
3768
  });
3608
3769
  export const zVillageLinkedRepositoriesResponse = z.object({
3609
3770
  repositories: z.array(zVillageLinkedRepository)
3610
3771
  });
3611
- export const zVillageListUserOrganization = z.object({
3612
- avatar_url: z.string().nullable(),
3613
- org_login: z.string(),
3614
- user_id: zVillageUUID
3615
- });
3616
3772
  export const zVillageOrganizationCollective = z.object({
3617
3773
  description: z.string().nullable(),
3618
3774
  id: zVillageUUID,
@@ -3624,24 +3780,6 @@ export const zVillageOrganizationCollectivesResponse = z.object({
3624
3780
  collectives: z.array(zVillageOrganizationCollective)
3625
3781
  }).superRefine((value, ctx) => { const issue = collectiveContractIssue("VillageOrganizationCollectivesResponse", value); if (issue !== undefined)
3626
3782
  ctx.addIssue({ code: "custom", message: "Collective contract validation: " + issue + "; retain prior evidence and fetch validated metadata before retrying" }); });
3627
- export const zVillagePendingShare = z.object({
3628
- branch: z.string().nullable(),
3629
- input_submission_count: z.int().gte(0).lte(9007199254740991).optional(),
3630
- local_id: zSessionID,
3631
- model_provider: z.string(),
3632
- owner_id: zVillageUUID,
3633
- owner_is_discoverable: z.boolean(),
3634
- owner_username: z.string(),
3635
- parent_session_id: zSessionID.nullable(),
3636
- project_hash: zProjectHash,
3637
- project_name: z.string().nullable(),
3638
- purpose: zSessionPurpose.optional(),
3639
- relationships: z.array(zSessionRelationship).optional(),
3640
- root_session_id: zSessionID.nullish(),
3641
- shared_at: z.iso.datetime(),
3642
- title: z.string().nullable(),
3643
- transcript_id: zTranscriptID
3644
- });
3645
3783
  export const zVillagePublicCollective = z.object({
3646
3784
  acceptance_mode: zVillageCollectiveAcceptanceMode,
3647
3785
  created_at: z.iso.datetime(),
@@ -3654,7 +3792,7 @@ export const zVillagePublicCollective = z.object({
3654
3792
  transcript_count: z.int().min(-2147483648, { error: 'Invalid value: Expected int32 to be >= -2147483648' }).max(2147483647, { error: 'Invalid value: Expected int32 to be <= 2147483647' })
3655
3793
  });
3656
3794
  export const zVillagePullRequestAttachment = z.object({
3657
- author_user_id: zVillageUUID.nullable(),
3795
+ author: zVillagePublicOwner,
3658
3796
  check_run_id: z.int().nullable(),
3659
3797
  comment_id: z.int().nullable(),
3660
3798
  confirmed_at: z.iso.datetime().nullable(),
@@ -3667,7 +3805,7 @@ export const zVillagePullRequestAttachment = z.object({
3667
3805
  name: z.string(),
3668
3806
  number: z.int(),
3669
3807
  owner: z.string(),
3670
- requested_by_github_id: z.int().nullable(),
3808
+ requested_by: zVillagePublicOwner.nullable(),
3671
3809
  state: zVillagePullRequestAttachmentState,
3672
3810
  title: z.string().nullable(),
3673
3811
  updated_at: z.iso.datetime()
@@ -3685,81 +3823,9 @@ export const zVillageTag = z.object({
3685
3823
  id: zVillageUUID,
3686
3824
  name: z.string()
3687
3825
  });
3688
- export const zVillageTranscript = z.object({
3689
- blob_size_bytes: z.int().nullable(),
3690
- compute_version: z.int().nullable(),
3691
- computed_at: z.iso.datetime().nullable(),
3692
- content_hash: zTranscriptContentHash.nullable(),
3693
- description: z.string().nullable(),
3694
- diagnostics_partial: z.boolean().nullable(),
3695
- diagnostics_warnings: z.array(zDiagnosticEntry).nullable(),
3696
- discovery_turns: z.int().nullable(),
3697
- duration_ms: z.int().nullable(),
3698
- exploration_ratio: z.number().nullable(),
3699
- files_touched: z.int().nullable(),
3700
- git_branch: z.string().nullable(),
3701
- git_remote: z.string().nullable(),
3702
- harness_version: z.string().nullable(),
3703
- id: zTranscriptID,
3704
- ingested_at: z.iso.datetime().nullable(),
3705
- input_submission_count: z.int().gte(0).lte(9007199254740991).optional(),
3706
- license_id: zLicense.nullable(),
3707
- lines_changed: z.int().nullable(),
3708
- local_id: zSessionID,
3709
- m2_token_outcome_ratio: z.number().nullable(),
3710
- m3_unique_tool_count: z.int().nullable(),
3711
- m4_consecutive_error_max: z.int().nullable(),
3712
- m4_error_recovery_count: z.int().nullable(),
3713
- m5_avg_message_tokens: z.int().nullable(),
3714
- m5_context_utilization_pct: z.number().nullable(),
3715
- m5_peak_context_tokens: z.int().nullable(),
3716
- m6_lines_survived: z.int().nullable(),
3717
- m6_lines_total: z.int().nullable(),
3718
- m6_output_survival_pct: z.number().nullable(),
3719
- m7_spec_has_constraints: z.boolean().nullable(),
3720
- m7_spec_has_examples: z.boolean().nullable(),
3721
- m7_spec_word_count: z.int().nullable(),
3722
- model_name: z.string().nullable(),
3723
- model_provider: z.string(),
3724
- outcome: zSessionOutcome.nullable(),
3725
- owner_id: zVillageUUID,
3726
- parent_session_id: zSessionID.nullable(),
3727
- project_display_name: z.string(),
3728
- project_hash: zProjectHash,
3729
- project_name: z.string().nullable(),
3730
- project_name_source: zVillageProjectNameSource,
3731
- project_remote_label: z.string(),
3732
- published_at: z.iso.datetime(),
3733
- purpose: zSessionPurpose.optional(),
3734
- relationships: z.array(zSessionRelationship).optional(),
3735
- retry_loops: z.int().nullable(),
3736
- retry_tokens_wasted: z.int().nullable(),
3737
- root_session_id: zSessionID.nullish(),
3738
- schema_version: z.string(),
3739
- scope_breadth: z.int().nullable(),
3740
- session_end: z.iso.datetime().nullable(),
3741
- session_origin: zSessionOrigin,
3742
- session_start: z.iso.datetime().nullable(),
3743
- signal_density: z.number().nullable(),
3744
- source_format: zSourceFormat.nullable(),
3745
- spec_quality_score: z.number().nullable(),
3746
- subagent_count: z.int().nullable(),
3747
- subagents: z.array(z.record(z.string(), z.unknown())).nullable(),
3748
- title: z.string().nullable(),
3749
- title_generated: z.string().nullable(),
3750
- token_count: z.int().nullable(),
3751
- tokens_in: z.int().nullable(),
3752
- tokens_out: z.int().nullable(),
3753
- tool_call_count: z.int().nullable(),
3754
- turn_count: z.int().nullable(),
3755
- updated_at: z.iso.datetime(),
3756
- visibility: zVillageTranscriptVisibility,
3757
- within_session_reverts: z.int().nullable()
3758
- });
3759
3826
  export const zVillageTranscriptAttestation = z.object({
3760
3827
  attestation_type: z.string(),
3761
- attester_avatar: z.string().nullable(),
3762
- attester_username: z.string(),
3828
+ attester: zVillagePublicOwner,
3763
3829
  created_at: z.iso.datetime(),
3764
3830
  id: zVillageUUID,
3765
3831
  note: z.string().nullable(),
@@ -3776,11 +3842,59 @@ export const zVillageTranscriptCollective = z.object({
3776
3842
  export const zVillageTranscriptCollectivesResponse = z.object({
3777
3843
  collectives: z.array(zVillageTranscriptCollective)
3778
3844
  });
3845
+ export const zVillageTranscriptListRow = z.object({
3846
+ attestations: z.array(zVillageListTranscriptAttestation).nullable(),
3847
+ owner: zVillagePublicOwner,
3848
+ owner_orgs: z.array(zVillageListUserOrganization).nullable(),
3849
+ pull_requests: zVillagePullRequestsSummary,
3850
+ shares: z.array(zVillageEnrichedTranscriptShare).nullable(),
3851
+ tags: z.array(zVillageTag),
3852
+ transcript: zVillageTranscript
3853
+ }).superRefine((value, context) => {
3854
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageTranscriptListRow: " + reason });
3855
+ if (value.owner.kind !== "profile" && (value.owner_orgs?.length ?? 0) > 0)
3856
+ fail("owner_orgs lists organizations beside an anonymous owner; emit none for an anonymous owner");
3857
+ }).superRefine((value, context) => {
3858
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageTranscriptListRow: " + reason });
3859
+ if (value.owner.kind !== "profile") {
3860
+ const present = ["git_branch", "git_remote", "project_hash", "project_name", "project_display_name", "project_name_source", "project_remote_label"].filter((field) => { const v = value.transcript[field]; return v !== null && v !== undefined; });
3861
+ if (present.length > 0)
3862
+ fail(present.join(", ") + " identify the repository of an anonymous owner; withhold every repository field (null, or omitted on the pull envelope) when the owner is anonymous");
3863
+ }
3864
+ });
3865
+ export const zVillageTranscriptListResponse = z.object({
3866
+ agent_total: z.int(),
3867
+ limit: z.int(),
3868
+ page: z.int(),
3869
+ total: z.int(),
3870
+ transcripts: z.array(zVillageTranscriptListRow)
3871
+ });
3779
3872
  export const zVillageTranscriptShare = z.object({
3780
3873
  group_id: zVillageUUID,
3781
3874
  group_name: z.string(),
3782
3875
  shared_at: z.iso.datetime()
3783
3876
  });
3877
+ export const zVillageTranscriptMetadataResponse = z.object({
3878
+ attestations: z.array(zVillageTranscriptAttestation),
3879
+ enriched_shares: z.array(zVillageEnrichedTranscriptShare),
3880
+ owner: zVillagePublicOwner,
3881
+ owner_orgs: z.array(zVillageMetadataUserOrganization),
3882
+ relationshipNavigation: z.array(zSessionRelationshipNavigation).optional(),
3883
+ shares: z.array(zVillageTranscriptShare),
3884
+ tags: z.array(zVillageTag),
3885
+ transcript: zVillageTranscript
3886
+ }).superRefine((value, context) => {
3887
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageTranscriptMetadataResponse: " + reason });
3888
+ if (value.owner.kind !== "profile" && value.owner_orgs.length > 0)
3889
+ fail("owner_orgs lists organizations beside an anonymous owner; emit none for an anonymous owner");
3890
+ }).superRefine((value, context) => {
3891
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageTranscriptMetadataResponse: " + reason });
3892
+ if (value.owner.kind !== "profile") {
3893
+ const present = ["git_branch", "git_remote", "project_hash", "project_name", "project_display_name", "project_name_source", "project_remote_label"].filter((field) => { const v = value.transcript[field]; return v !== null && v !== undefined; });
3894
+ if (present.length > 0)
3895
+ fail(present.join(", ") + " identify the repository of an anonymous owner; withhold every repository field (null, or omitted on the pull envelope) when the owner is anonymous");
3896
+ }
3897
+ });
3784
3898
  export const zVillageUpdateCollectiveRequest = z.object({
3785
3899
  acceptance_mode: zVillageCollectiveAcceptanceMode.optional(),
3786
3900
  data_access: zVillageCollectiveDataAccess.optional(),
@@ -3810,36 +3924,10 @@ export const zVillageUser = z.object({
3810
3924
  updated_at: z.iso.datetime(),
3811
3925
  username_chosen: z.boolean()
3812
3926
  });
3813
- export const zVillageTranscriptListRow = z.object({
3814
- attestations: z.array(zVillageListTranscriptAttestation).nullable(),
3815
- owner: zVillageUser,
3816
- owner_orgs: z.array(zVillageListUserOrganization).nullable(),
3817
- pull_requests: zVillagePullRequestsSummary,
3818
- shares: z.array(zVillageEnrichedTranscriptShare).nullable(),
3819
- tags: z.array(zVillageTag),
3820
- transcript: zVillageTranscript
3821
- });
3822
- export const zVillageTranscriptListResponse = z.object({
3823
- agent_total: z.int(),
3824
- limit: z.int(),
3825
- page: z.int(),
3826
- total: z.int(),
3827
- transcripts: z.array(zVillageTranscriptListRow)
3828
- });
3829
- export const zVillageTranscriptMetadataResponse = z.object({
3830
- attestations: z.array(zVillageTranscriptAttestation),
3831
- enriched_shares: z.array(zVillageEnrichedTranscriptShare),
3832
- owner: zVillageUser,
3833
- owner_orgs: z.array(zVillageMetadataUserOrganization),
3834
- relationshipNavigation: z.array(zSessionRelationshipNavigation).optional(),
3835
- shares: z.array(zVillageTranscriptShare),
3836
- tags: z.array(zVillageTag),
3837
- transcript: zVillageTranscript
3838
- });
3839
3927
  export const zVillageUserCollective = z.object({
3840
3928
  acceptance_mode: zVillageCollectiveAcceptanceMode,
3841
3929
  created_at: z.iso.datetime(),
3842
- created_by: zVillageUUID,
3930
+ creator: zVillagePublicOwner,
3843
3931
  data_access: zVillageCollectiveDataAccess,
3844
3932
  description: z.string().nullable(),
3845
3933
  display_members: z.boolean(),
@@ -3866,8 +3954,9 @@ export const zVillageUserCollectiveShare = z.object({
3866
3954
  local_id: zSessionID,
3867
3955
  model_name: z.string().nullable(),
3868
3956
  model_provider: z.string(),
3869
- owner_id: zVillageUUID,
3957
+ owner: zVillagePublicOwner,
3870
3958
  parent_session_id: zSessionID.nullable(),
3959
+ parent_transcript_id: zTranscriptID.nullable(),
3871
3960
  published_at: z.iso.datetime(),
3872
3961
  purpose: zSessionPurpose.optional(),
3873
3962
  relationships: z.array(zSessionRelationship).optional(),
@@ -3884,11 +3973,14 @@ export const zVillageSessionRow = z.object({
3884
3973
  collective: zVillageCollectiveTranscript.nullish(),
3885
3974
  contributable: zVillageContributableTranscript.nullish(),
3886
3975
  myShare: zVillageUserCollectiveShare.nullish(),
3976
+ owner: zVillagePublicOwner,
3887
3977
  pending: zVillagePendingShare.nullish(),
3888
3978
  session: zVillageTranscript
3889
3979
  }).superRefine((value, context) => {
3890
3980
  const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageSessionRow during grouped read validation: " + reason });
3891
3981
  const s = value.session;
3982
+ if (s.parent_transcript_id != null && (s.parent_session_id == null || s.parent_transcript_id === s.id))
3983
+ fail("parent_transcript_id is set without a parent_session_id or names the row itself; resolve the parent within the same owner, or emit null");
3892
3984
  const arms = [value.collective, value.pending, value.myShare, value.contributable].filter(v => v != null);
3893
3985
  if (arms.length > 1)
3894
3986
  fail("multiple route arms supplied; retain the originating route only");
@@ -3908,11 +4000,21 @@ export const zVillageSessionRow = z.object({
3908
4000
  if (!equal(row[key], session[aliases[key] ?? key]))
3909
4001
  fail("route identity or metric mirrors disagree; derive both from the same row");
3910
4002
  };
4003
+ for (const arm of [value.collective, value.pending, value.myShare])
4004
+ if (arm != null && !equal(arm.owner, value.owner))
4005
+ fail("route owner differs from the row owner; resolve the owner once for this viewer and project it into both");
3911
4006
  const graph = ["parent_session_id", "root_session_id", "purpose", "relationships", "input_submission_count"];
3912
- check(value.collective, [...graph, "id", "owner_id", "local_id", "title", "description", "visibility", "model_provider", "model_name", "harness_version", "turn_count", "token_count", "tokens_in", "tokens_out", "duration_ms", "project_hash", "project_name", "project_display_name", "project_name_source", "project_remote_label", "git_branch", "session_origin"]);
3913
- check(value.pending, [...graph, "transcript_id", "owner_id", "local_id", "title", "model_provider", "project_hash", "project_name", "branch"], { transcript_id: "id", branch: "git_branch" });
3914
- check(value.myShare, [...graph, "id", "owner_id", "local_id", "title", "visibility", "published_at", "model_provider", "model_name", "turn_count", "tokens_in", "tokens_out"]);
4007
+ check(value.collective, [...graph, "parent_transcript_id", "id", "local_id", "title", "description", "visibility", "model_provider", "model_name", "harness_version", "turn_count", "token_count", "tokens_in", "tokens_out", "duration_ms", "project_hash", "project_name", "project_display_name", "project_name_source", "project_remote_label", "git_branch", "session_origin"]);
4008
+ check(value.pending, [...graph, "parent_transcript_id", "transcript_id", "local_id", "title", "model_provider", "project_hash", "project_name", "branch"], { transcript_id: "id", branch: "git_branch" });
4009
+ check(value.myShare, [...graph, "parent_transcript_id", "id", "local_id", "title", "visibility", "published_at", "model_provider", "model_name", "turn_count", "tokens_in", "tokens_out"]);
3915
4010
  check(value.contributable, [...graph, "id", "local_id", "title", "visibility", "model_provider", "project_hash", "project_display_name", "project_name_source", "git_branch", "published_at", "session_origin"]);
4011
+ }).superRefine((value, context) => {
4012
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zVillageSessionRow: " + reason });
4013
+ if (value.owner.kind !== "profile") {
4014
+ const present = ["git_branch", "git_remote", "project_hash", "project_name", "project_display_name", "project_name_source", "project_remote_label"].filter((field) => { const v = value.session[field]; return v !== null && v !== undefined; });
4015
+ if (present.length > 0)
4016
+ fail(present.join(", ") + " identify the repository of an anonymous owner; withhold every repository field (null, or omitted on the pull envelope) when the owner is anonymous");
4017
+ }
3916
4018
  });
3917
4019
  export const zVillageSessionListItem = z.object({
3918
4020
  context: zHelperContextSummary.nullish(),
@@ -4007,7 +4109,7 @@ export const zVillageUserStats = z.object({
4007
4109
  export const zVillageVisibleCollective = z.object({
4008
4110
  acceptance_mode: zVillageCollectiveAcceptanceMode,
4009
4111
  created_at: z.iso.datetime(),
4010
- created_by: zVillageUUID,
4112
+ creator: zVillagePublicOwner,
4011
4113
  data_access: zVillageCollectiveDataAccess,
4012
4114
  description: z.string().nullable(),
4013
4115
  display_members: z.boolean(),
@@ -4031,6 +4133,36 @@ export const zVisibility = z.enum([
4031
4133
  'group',
4032
4134
  'public'
4033
4135
  ]);
4136
+ export const zLegacyPullTranscriptInfo = z.object({
4137
+ annotationCount: z.int(),
4138
+ contentHash: z.string().optional(),
4139
+ contractVersion: z.string().optional(),
4140
+ harness: zHarness.optional(),
4141
+ license: zLicense.optional(),
4142
+ localId: z.string().optional(),
4143
+ ownerUserId: z.string(),
4144
+ ownerUsername: z.string(),
4145
+ projectName: z.string().optional(),
4146
+ publishedAt: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
4147
+ title: z.string().optional(),
4148
+ transcriptId: zTranscriptID,
4149
+ updatedAt: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
4150
+ visibility: zVisibility
4151
+ }).superRefine((value, context) => {
4152
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zLegacyPullTranscriptInfo: " + reason });
4153
+ if (value.ownerUserId === "" && value.ownerUsername !== "anon")
4154
+ fail("an empty id carries a username; a hidden person would be named; send anon beside an empty id");
4155
+ if (value.ownerUserId !== "" && value.ownerUsername === "")
4156
+ fail("an id carries no username; send the profile's username, or an empty id with anon");
4157
+ if (value.ownerUserId === "" && (value.projectName ?? "") !== "")
4158
+ fail("projectName sits beside an anonymous owner; omit it for an anonymous owner");
4159
+ });
4160
+ export const zLegacyPullListResponse = z.object({
4161
+ limit: z.int(),
4162
+ page: z.int(),
4163
+ total: z.int(),
4164
+ transcripts: z.array(zLegacyPullTranscriptInfo).nullable()
4165
+ });
4034
4166
  export const zPublishNormalizedValues = z.object({
4035
4167
  derivedTitle: z.string().nullable(),
4036
4168
  entryHarnesses: z.array(zHarness),
@@ -4081,14 +4213,20 @@ export const zPullTranscriptInfo = z.object({
4081
4213
  harness: zHarness.optional(),
4082
4214
  license: zLicense.optional(),
4083
4215
  localId: z.string().optional(),
4084
- ownerUserId: z.string(),
4085
- ownerUsername: z.string(),
4086
- projectName: z.string().optional(),
4216
+ owner: zVillagePublicOwner,
4217
+ projectName: z.string().nullish(),
4087
4218
  publishedAt: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
4088
4219
  title: z.string().optional(),
4089
4220
  transcriptId: zTranscriptID,
4090
4221
  updatedAt: z.coerce.bigint().min(BigInt('-9223372036854775808'), { error: 'Invalid value: Expected int64 to be >= -9223372036854775808' }).max(BigInt('9223372036854775807'), { error: 'Invalid value: Expected int64 to be <= 9223372036854775807' }),
4091
4222
  visibility: zVisibility
4223
+ }).superRefine((value, context) => {
4224
+ const fail = (reason) => context.addIssue({ code: "custom", message: "schema.zPullTranscriptInfo: " + reason });
4225
+ if (value.owner.kind !== "profile") {
4226
+ const present = ["projectName"].filter((field) => { const v = value[field]; return v !== null && v !== undefined; });
4227
+ if (present.length > 0)
4228
+ fail(present.join(", ") + " identify the repository of an anonymous owner; withhold every repository field (null, or omitted on the pull envelope) when the owner is anonymous");
4229
+ }
4092
4230
  });
4093
4231
  export const zPullListResponse = z.object({
4094
4232
  limit: z.int(),