@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.
package/lib/esm/index.mjs CHANGED
@@ -7626,7 +7626,7 @@ var ApplicationRunSchema = z7.object({
7626
7626
  contract: z7.literal("ApplicationRun"),
7627
7627
  runId: ContractIdentifierSchema,
7628
7628
  definitionRef: EntityRefSchema,
7629
- runtimeLedgerRef: EntityRefSchema,
7629
+ runtimeLedgerRef: EntityRefSchema.optional(),
7630
7630
  requestId: ContractIdentifierSchema,
7631
7631
  actorRef: EntityRefSchema,
7632
7632
  status: z7.enum(["PENDING", "RUNNING", "COMPLETED", "FAILED", "CANCELLED", "EXPIRED"]),
@@ -7636,7 +7636,43 @@ var ApplicationRunSchema = z7.object({
7636
7636
  completedAt: IsoDateTimeSchema.optional(),
7637
7637
  expiresAt: IsoDateTimeSchema.optional(),
7638
7638
  metadata: JsonObjectSchema.default({})
7639
- }).strict();
7639
+ }).strict().superRefine((run, context) => {
7640
+ if (run.definitionRef.kind !== "workflow-definition") {
7641
+ context.addIssue({
7642
+ code: "custom",
7643
+ path: ["definitionRef", "kind"],
7644
+ message: "definitionRef must reference a workflow-definition."
7645
+ });
7646
+ }
7647
+ if (run.runtimeLedgerRef && run.runtimeLedgerRef.kind !== "workflow-run") {
7648
+ context.addIssue({
7649
+ code: "custom",
7650
+ path: ["runtimeLedgerRef", "kind"],
7651
+ message: "runtimeLedgerRef must reference a workflow-run."
7652
+ });
7653
+ }
7654
+ if ((run.status === "RUNNING" || run.status === "COMPLETED" || run.status === "CANCELLED") && !run.runtimeLedgerRef) {
7655
+ context.addIssue({
7656
+ code: "custom",
7657
+ path: ["runtimeLedgerRef"],
7658
+ message: `${run.status} ApplicationRun requires runtimeLedgerRef.`
7659
+ });
7660
+ }
7661
+ if (run.status === "RUNNING" && !run.startedAt) {
7662
+ context.addIssue({
7663
+ code: "custom",
7664
+ path: ["startedAt"],
7665
+ message: "RUNNING ApplicationRun requires startedAt."
7666
+ });
7667
+ }
7668
+ if (["COMPLETED", "FAILED", "CANCELLED", "EXPIRED"].includes(run.status) && !run.completedAt) {
7669
+ context.addIssue({
7670
+ code: "custom",
7671
+ path: ["completedAt"],
7672
+ message: `Terminal ApplicationRun status ${run.status} requires completedAt.`
7673
+ });
7674
+ }
7675
+ });
7640
7676
  var ExpiringAccessGrantSchema = z7.object({
7641
7677
  contract: z7.literal("ExpiringAccessGrant"),
7642
7678
  grantId: ContractIdentifierSchema,
@@ -11517,6 +11553,181 @@ var WorkflowDefinitionSchema = z14.object({
11517
11553
  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." });
11518
11554
  });
11519
11555
 
11556
+ // src/contracts/workflow-runtime.ts
11557
+ import { z as z15 } from "zod";
11558
+ var WorkflowCatalogEntrySchema = z15.object({
11559
+ contract: z15.literal("WorkflowCatalogEntry"),
11560
+ workflowId: ContractIdentifierSchema,
11561
+ teamId: ContractIdentifierSchema,
11562
+ creatorRef: EntityRefSchema,
11563
+ currentDefinitionRef: EntityRefSchema,
11564
+ lifecycle: z15.enum(["ACTIVE", "DELETED"]),
11565
+ asset: z15.object({
11566
+ preset: z15.boolean(),
11567
+ marketplacePublished: z15.boolean(),
11568
+ publishConfig: JsonObjectSchema.optional(),
11569
+ sort: z15.number().int(),
11570
+ forkFromRef: EntityRefSchema.optional(),
11571
+ notAuthorized: z15.boolean()
11572
+ }).strict(),
11573
+ createdAt: IsoDateTimeSchema,
11574
+ updatedAt: IsoDateTimeSchema,
11575
+ deletedAt: IsoDateTimeSchema.optional()
11576
+ }).strict().superRefine((entry, context) => {
11577
+ if (entry.creatorRef.kind !== "user" && entry.creatorRef.kind !== "service") {
11578
+ context.addIssue({
11579
+ code: "custom",
11580
+ path: ["creatorRef", "kind"],
11581
+ message: "creatorRef must reference a user or service."
11582
+ });
11583
+ }
11584
+ if (entry.currentDefinitionRef.kind !== "workflow-definition") {
11585
+ context.addIssue({
11586
+ code: "custom",
11587
+ path: ["currentDefinitionRef", "kind"],
11588
+ message: "currentDefinitionRef must reference a workflow-definition."
11589
+ });
11590
+ }
11591
+ if (entry.lifecycle === "DELETED" && !entry.deletedAt) {
11592
+ context.addIssue({
11593
+ code: "custom",
11594
+ path: ["deletedAt"],
11595
+ message: "Deleted workflow catalog entries require deletedAt."
11596
+ });
11597
+ }
11598
+ if (entry.lifecycle === "ACTIVE" && entry.deletedAt) {
11599
+ context.addIssue({
11600
+ code: "custom",
11601
+ path: ["deletedAt"],
11602
+ message: "Active workflow catalog entries cannot declare deletedAt."
11603
+ });
11604
+ }
11605
+ });
11606
+ var WorkflowPublicationSchema = z15.object({
11607
+ contract: z15.literal("WorkflowPublication"),
11608
+ publicationId: ContractIdentifierSchema,
11609
+ definitionRef: EntityRefSchema,
11610
+ runtimeDefinitionRef: EntityRefSchema,
11611
+ sourceHash: Sha256Schema,
11612
+ compiledHash: Sha256Schema,
11613
+ status: z15.enum(["PENDING", "PUBLISHED", "FAILED", "RETIRED"]),
11614
+ publisherRef: EntityRefSchema,
11615
+ publishedAt: IsoDateTimeSchema.optional(),
11616
+ failureReason: z15.string().trim().min(1).optional()
11617
+ }).strict().superRefine((publication, context) => {
11618
+ if (publication.definitionRef.kind !== "workflow-definition") {
11619
+ context.addIssue({
11620
+ code: "custom",
11621
+ path: ["definitionRef", "kind"],
11622
+ message: "definitionRef must reference a workflow-definition."
11623
+ });
11624
+ }
11625
+ if (publication.runtimeDefinitionRef.kind !== "conductor-workflow-definition") {
11626
+ context.addIssue({
11627
+ code: "custom",
11628
+ path: ["runtimeDefinitionRef", "kind"],
11629
+ message: "runtimeDefinitionRef must reference a conductor-workflow-definition."
11630
+ });
11631
+ }
11632
+ if (publication.status === "PUBLISHED" && !publication.publishedAt) {
11633
+ context.addIssue({
11634
+ code: "custom",
11635
+ path: ["publishedAt"],
11636
+ message: "Published workflow publications require publishedAt."
11637
+ });
11638
+ }
11639
+ if (publication.status === "FAILED" && !publication.failureReason) {
11640
+ context.addIssue({
11641
+ code: "custom",
11642
+ path: ["failureReason"],
11643
+ message: "Failed workflow publications require failureReason."
11644
+ });
11645
+ }
11646
+ });
11647
+ var WorkflowCompletionCommitSchema = z15.object({
11648
+ contract: z15.literal("WorkflowCompletionCommit"),
11649
+ commitId: ContractIdentifierSchema,
11650
+ run: ApplicationRunSchema,
11651
+ outputs: z15.array(OutputRecordSchema),
11652
+ artifacts: z15.array(ArtifactManifestSchema),
11653
+ lineage: LineageRecordSchema,
11654
+ completedAt: IsoDateTimeSchema
11655
+ }).strict().superRefine((commit, context) => {
11656
+ const expectedRunId = commit.run.runId;
11657
+ const referencesRun = (value) => value.runRef.kind === "application-run" && value.runRef.id === expectedRunId;
11658
+ commit.outputs.forEach((output, index) => {
11659
+ if (!referencesRun(output)) {
11660
+ context.addIssue({
11661
+ code: "custom",
11662
+ path: ["outputs", index, "runRef"],
11663
+ message: "Every output must reference the committed ApplicationRun."
11664
+ });
11665
+ }
11666
+ });
11667
+ commit.artifacts.forEach((artifact, index) => {
11668
+ if (!referencesRun(artifact)) {
11669
+ context.addIssue({
11670
+ code: "custom",
11671
+ path: ["artifacts", index, "runRef"],
11672
+ message: "Every artifact must reference the committed ApplicationRun."
11673
+ });
11674
+ }
11675
+ });
11676
+ if (commit.lineage.subjectRef.kind !== "application-run" || commit.lineage.subjectRef.id !== expectedRunId) {
11677
+ context.addIssue({
11678
+ code: "custom",
11679
+ path: ["lineage", "subjectRef"],
11680
+ message: "Completion lineage must use the committed ApplicationRun as its subject."
11681
+ });
11682
+ }
11683
+ const outputIds = new Set(commit.outputs.map((output) => output.outputId));
11684
+ commit.artifacts.forEach((artifact, index) => {
11685
+ if (artifact.outputRef.kind !== "workflow-output" || !outputIds.has(artifact.outputRef.id)) {
11686
+ context.addIssue({
11687
+ code: "custom",
11688
+ path: ["artifacts", index, "outputRef"],
11689
+ message: "Artifact outputRef must reference an output in the same commit."
11690
+ });
11691
+ }
11692
+ });
11693
+ });
11694
+ var WorkflowCompletionReceiptSchema = z15.object({
11695
+ contract: z15.literal("WorkflowCompletionReceipt"),
11696
+ commitId: ContractIdentifierSchema,
11697
+ runRef: EntityRefSchema,
11698
+ outputRefs: z15.array(EntityRefSchema),
11699
+ artifactRefs: z15.array(EntityRefSchema),
11700
+ contentHash: Sha256Schema,
11701
+ committedAt: IsoDateTimeSchema,
11702
+ idempotentReplay: z15.boolean()
11703
+ }).strict().superRefine((receipt, context) => {
11704
+ if (receipt.runRef.kind !== "application-run") {
11705
+ context.addIssue({
11706
+ code: "custom",
11707
+ path: ["runRef", "kind"],
11708
+ message: "runRef must reference an application-run."
11709
+ });
11710
+ }
11711
+ receipt.outputRefs.forEach((ref2, index) => {
11712
+ if (ref2.kind !== "workflow-output") {
11713
+ context.addIssue({
11714
+ code: "custom",
11715
+ path: ["outputRefs", index, "kind"],
11716
+ message: "outputRefs must reference workflow-output records."
11717
+ });
11718
+ }
11719
+ });
11720
+ receipt.artifactRefs.forEach((ref2, index) => {
11721
+ if (ref2.kind !== "artifact") {
11722
+ context.addIssue({
11723
+ code: "custom",
11724
+ path: ["artifactRefs", index, "kind"],
11725
+ message: "artifactRefs must reference artifacts."
11726
+ });
11727
+ }
11728
+ });
11729
+ });
11730
+
11520
11731
  // src/schemas/index.ts
11521
11732
  var canonicalContractSchemas = {
11522
11733
  "agent-session-command": AgentSessionCommandSchema,
@@ -11575,7 +11786,11 @@ var canonicalContractSchemas = {
11575
11786
  "trend-metric-snapshot": TrendMetricSnapshotSchema,
11576
11787
  "trend-source-record": TrendSourceRecordSchema,
11577
11788
  "view-provider-descriptor": ViewProviderDescriptorSchema,
11578
- "workflow-definition": WorkflowDefinitionSchema
11789
+ "workflow-definition": WorkflowDefinitionSchema,
11790
+ "workflow-catalog-entry": WorkflowCatalogEntrySchema,
11791
+ "workflow-publication": WorkflowPublicationSchema,
11792
+ "workflow-completion-commit": WorkflowCompletionCommitSchema,
11793
+ "workflow-completion-receipt": WorkflowCompletionReceiptSchema
11579
11794
  };
11580
11795
 
11581
11796
  // src/runtime/capability-registry.ts
@@ -12951,12 +13166,16 @@ export {
12951
13166
  ValidationIssueType,
12952
13167
  ValidationReasonType,
12953
13168
  ViewProviderDescriptorSchema,
13169
+ WorkflowCatalogEntrySchema,
13170
+ WorkflowCompletionCommitSchema,
13171
+ WorkflowCompletionReceiptSchema,
12954
13172
  WorkflowDefinitionSchema,
12955
13173
  WorkflowEdgeSchema,
12956
13174
  WorkflowNodeSchema,
12957
13175
  WorkflowOutputBindingSchema,
12958
13176
  WorkflowParameterSchema,
12959
13177
  WorkflowParameterTypeSchema,
13178
+ WorkflowPublicationSchema,
12960
13179
  WorkflowTriggerSchema,
12961
13180
  WorkflowTriggerType,
12962
13181
  WorkflowValidationIssueSchema,