@inf-monkeys-tech/monkeys 1.0.18 → 1.0.19

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.
@@ -7589,7 +7589,7 @@ var ApplicationRunSchema = z7.object({
7589
7589
  contract: z7.literal("ApplicationRun"),
7590
7590
  runId: ContractIdentifierSchema,
7591
7591
  definitionRef: EntityRefSchema,
7592
- runtimeLedgerRef: EntityRefSchema,
7592
+ runtimeLedgerRef: EntityRefSchema.optional(),
7593
7593
  requestId: ContractIdentifierSchema,
7594
7594
  actorRef: EntityRefSchema,
7595
7595
  status: z7.enum(["PENDING", "RUNNING", "COMPLETED", "FAILED", "CANCELLED", "EXPIRED"]),
@@ -7599,7 +7599,43 @@ var ApplicationRunSchema = z7.object({
7599
7599
  completedAt: IsoDateTimeSchema.optional(),
7600
7600
  expiresAt: IsoDateTimeSchema.optional(),
7601
7601
  metadata: JsonObjectSchema.default({})
7602
- }).strict();
7602
+ }).strict().superRefine((run, context) => {
7603
+ if (run.definitionRef.kind !== "workflow-definition") {
7604
+ context.addIssue({
7605
+ code: "custom",
7606
+ path: ["definitionRef", "kind"],
7607
+ message: "definitionRef must reference a workflow-definition."
7608
+ });
7609
+ }
7610
+ if (run.runtimeLedgerRef && run.runtimeLedgerRef.kind !== "workflow-run") {
7611
+ context.addIssue({
7612
+ code: "custom",
7613
+ path: ["runtimeLedgerRef", "kind"],
7614
+ message: "runtimeLedgerRef must reference a workflow-run."
7615
+ });
7616
+ }
7617
+ if ((run.status === "RUNNING" || run.status === "COMPLETED" || run.status === "CANCELLED") && !run.runtimeLedgerRef) {
7618
+ context.addIssue({
7619
+ code: "custom",
7620
+ path: ["runtimeLedgerRef"],
7621
+ message: `${run.status} ApplicationRun requires runtimeLedgerRef.`
7622
+ });
7623
+ }
7624
+ if (run.status === "RUNNING" && !run.startedAt) {
7625
+ context.addIssue({
7626
+ code: "custom",
7627
+ path: ["startedAt"],
7628
+ message: "RUNNING ApplicationRun requires startedAt."
7629
+ });
7630
+ }
7631
+ if (["COMPLETED", "FAILED", "CANCELLED", "EXPIRED"].includes(run.status) && !run.completedAt) {
7632
+ context.addIssue({
7633
+ code: "custom",
7634
+ path: ["completedAt"],
7635
+ message: `Terminal ApplicationRun status ${run.status} requires completedAt.`
7636
+ });
7637
+ }
7638
+ });
7603
7639
  var ExpiringAccessGrantSchema = z7.object({
7604
7640
  contract: z7.literal("ExpiringAccessGrant"),
7605
7641
  grantId: ContractIdentifierSchema,
@@ -11446,6 +11482,181 @@ var WorkflowDefinitionSchema = z14.object({
11446
11482
  });
11447
11483
  if (definition.revision.kind === "release" && definition.metadata.version !== definition.revision.recordVersion) context.addIssue({ code: "custom", path: ["revision", "recordVersion"], message: "Release recordVersion must equal metadata.version." });
11448
11484
  });
11485
+
11486
+ // src/contracts/workflow-runtime.ts
11487
+ import { z as z15 } from "zod";
11488
+ var WorkflowCatalogEntrySchema = z15.object({
11489
+ contract: z15.literal("WorkflowCatalogEntry"),
11490
+ workflowId: ContractIdentifierSchema,
11491
+ teamId: ContractIdentifierSchema,
11492
+ creatorRef: EntityRefSchema,
11493
+ currentDefinitionRef: EntityRefSchema,
11494
+ lifecycle: z15.enum(["ACTIVE", "DELETED"]),
11495
+ asset: z15.object({
11496
+ preset: z15.boolean(),
11497
+ marketplacePublished: z15.boolean(),
11498
+ publishConfig: JsonObjectSchema.optional(),
11499
+ sort: z15.number().int(),
11500
+ forkFromRef: EntityRefSchema.optional(),
11501
+ notAuthorized: z15.boolean()
11502
+ }).strict(),
11503
+ createdAt: IsoDateTimeSchema,
11504
+ updatedAt: IsoDateTimeSchema,
11505
+ deletedAt: IsoDateTimeSchema.optional()
11506
+ }).strict().superRefine((entry, context) => {
11507
+ if (entry.creatorRef.kind !== "user" && entry.creatorRef.kind !== "service") {
11508
+ context.addIssue({
11509
+ code: "custom",
11510
+ path: ["creatorRef", "kind"],
11511
+ message: "creatorRef must reference a user or service."
11512
+ });
11513
+ }
11514
+ if (entry.currentDefinitionRef.kind !== "workflow-definition") {
11515
+ context.addIssue({
11516
+ code: "custom",
11517
+ path: ["currentDefinitionRef", "kind"],
11518
+ message: "currentDefinitionRef must reference a workflow-definition."
11519
+ });
11520
+ }
11521
+ if (entry.lifecycle === "DELETED" && !entry.deletedAt) {
11522
+ context.addIssue({
11523
+ code: "custom",
11524
+ path: ["deletedAt"],
11525
+ message: "Deleted workflow catalog entries require deletedAt."
11526
+ });
11527
+ }
11528
+ if (entry.lifecycle === "ACTIVE" && entry.deletedAt) {
11529
+ context.addIssue({
11530
+ code: "custom",
11531
+ path: ["deletedAt"],
11532
+ message: "Active workflow catalog entries cannot declare deletedAt."
11533
+ });
11534
+ }
11535
+ });
11536
+ var WorkflowPublicationSchema = z15.object({
11537
+ contract: z15.literal("WorkflowPublication"),
11538
+ publicationId: ContractIdentifierSchema,
11539
+ definitionRef: EntityRefSchema,
11540
+ runtimeDefinitionRef: EntityRefSchema,
11541
+ sourceHash: Sha256Schema,
11542
+ compiledHash: Sha256Schema,
11543
+ status: z15.enum(["PENDING", "PUBLISHED", "FAILED", "RETIRED"]),
11544
+ publisherRef: EntityRefSchema,
11545
+ publishedAt: IsoDateTimeSchema.optional(),
11546
+ failureReason: z15.string().trim().min(1).optional()
11547
+ }).strict().superRefine((publication, context) => {
11548
+ if (publication.definitionRef.kind !== "workflow-definition") {
11549
+ context.addIssue({
11550
+ code: "custom",
11551
+ path: ["definitionRef", "kind"],
11552
+ message: "definitionRef must reference a workflow-definition."
11553
+ });
11554
+ }
11555
+ if (publication.runtimeDefinitionRef.kind !== "conductor-workflow-definition") {
11556
+ context.addIssue({
11557
+ code: "custom",
11558
+ path: ["runtimeDefinitionRef", "kind"],
11559
+ message: "runtimeDefinitionRef must reference a conductor-workflow-definition."
11560
+ });
11561
+ }
11562
+ if (publication.status === "PUBLISHED" && !publication.publishedAt) {
11563
+ context.addIssue({
11564
+ code: "custom",
11565
+ path: ["publishedAt"],
11566
+ message: "Published workflow publications require publishedAt."
11567
+ });
11568
+ }
11569
+ if (publication.status === "FAILED" && !publication.failureReason) {
11570
+ context.addIssue({
11571
+ code: "custom",
11572
+ path: ["failureReason"],
11573
+ message: "Failed workflow publications require failureReason."
11574
+ });
11575
+ }
11576
+ });
11577
+ var WorkflowCompletionCommitSchema = z15.object({
11578
+ contract: z15.literal("WorkflowCompletionCommit"),
11579
+ commitId: ContractIdentifierSchema,
11580
+ run: ApplicationRunSchema,
11581
+ outputs: z15.array(OutputRecordSchema),
11582
+ artifacts: z15.array(ArtifactManifestSchema),
11583
+ lineage: LineageRecordSchema,
11584
+ completedAt: IsoDateTimeSchema
11585
+ }).strict().superRefine((commit, context) => {
11586
+ const expectedRunId = commit.run.runId;
11587
+ const referencesRun = (value) => value.runRef.kind === "application-run" && value.runRef.id === expectedRunId;
11588
+ commit.outputs.forEach((output, index) => {
11589
+ if (!referencesRun(output)) {
11590
+ context.addIssue({
11591
+ code: "custom",
11592
+ path: ["outputs", index, "runRef"],
11593
+ message: "Every output must reference the committed ApplicationRun."
11594
+ });
11595
+ }
11596
+ });
11597
+ commit.artifacts.forEach((artifact, index) => {
11598
+ if (!referencesRun(artifact)) {
11599
+ context.addIssue({
11600
+ code: "custom",
11601
+ path: ["artifacts", index, "runRef"],
11602
+ message: "Every artifact must reference the committed ApplicationRun."
11603
+ });
11604
+ }
11605
+ });
11606
+ if (commit.lineage.subjectRef.kind !== "application-run" || commit.lineage.subjectRef.id !== expectedRunId) {
11607
+ context.addIssue({
11608
+ code: "custom",
11609
+ path: ["lineage", "subjectRef"],
11610
+ message: "Completion lineage must use the committed ApplicationRun as its subject."
11611
+ });
11612
+ }
11613
+ const outputIds = new Set(commit.outputs.map((output) => output.outputId));
11614
+ commit.artifacts.forEach((artifact, index) => {
11615
+ if (artifact.outputRef.kind !== "workflow-output" || !outputIds.has(artifact.outputRef.id)) {
11616
+ context.addIssue({
11617
+ code: "custom",
11618
+ path: ["artifacts", index, "outputRef"],
11619
+ message: "Artifact outputRef must reference an output in the same commit."
11620
+ });
11621
+ }
11622
+ });
11623
+ });
11624
+ var WorkflowCompletionReceiptSchema = z15.object({
11625
+ contract: z15.literal("WorkflowCompletionReceipt"),
11626
+ commitId: ContractIdentifierSchema,
11627
+ runRef: EntityRefSchema,
11628
+ outputRefs: z15.array(EntityRefSchema),
11629
+ artifactRefs: z15.array(EntityRefSchema),
11630
+ contentHash: Sha256Schema,
11631
+ committedAt: IsoDateTimeSchema,
11632
+ idempotentReplay: z15.boolean()
11633
+ }).strict().superRefine((receipt, context) => {
11634
+ if (receipt.runRef.kind !== "application-run") {
11635
+ context.addIssue({
11636
+ code: "custom",
11637
+ path: ["runRef", "kind"],
11638
+ message: "runRef must reference an application-run."
11639
+ });
11640
+ }
11641
+ receipt.outputRefs.forEach((ref, index) => {
11642
+ if (ref.kind !== "workflow-output") {
11643
+ context.addIssue({
11644
+ code: "custom",
11645
+ path: ["outputRefs", index, "kind"],
11646
+ message: "outputRefs must reference workflow-output records."
11647
+ });
11648
+ }
11649
+ });
11650
+ receipt.artifactRefs.forEach((ref, index) => {
11651
+ if (ref.kind !== "artifact") {
11652
+ context.addIssue({
11653
+ code: "custom",
11654
+ path: ["artifactRefs", index, "kind"],
11655
+ message: "artifactRefs must reference artifacts."
11656
+ });
11657
+ }
11658
+ });
11659
+ });
11449
11660
  export {
11450
11661
  AGENT_MODE_CAPABILITIES,
11451
11662
  AGENT_SESSION_CAPABILITY_EVIDENCE,
@@ -11584,12 +11795,16 @@ export {
11584
11795
  TrendSourceRecordSchema,
11585
11796
  TrendSourceSchema,
11586
11797
  ViewProviderDescriptorSchema,
11798
+ WorkflowCatalogEntrySchema,
11799
+ WorkflowCompletionCommitSchema,
11800
+ WorkflowCompletionReceiptSchema,
11587
11801
  WorkflowDefinitionSchema,
11588
11802
  WorkflowEdgeSchema,
11589
11803
  WorkflowNodeSchema,
11590
11804
  WorkflowOutputBindingSchema,
11591
11805
  WorkflowParameterSchema,
11592
11806
  WorkflowParameterTypeSchema,
11807
+ WorkflowPublicationSchema,
11593
11808
  WorkflowTriggerSchema,
11594
11809
  WorkflowValidationIssueSchema,
11595
11810
  agentModeHasCapability,