skedyul 1.7.29 → 1.7.30

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.
@@ -321,9 +321,235 @@ function isRuntimeWebhookContext(ctx) {
321
321
  // src/schemas.ts
322
322
  import { z as z8 } from "zod/v4";
323
323
 
324
- // src/schemas/crm-schema.ts
324
+ // src/skills/types.ts
325
325
  import { z as z3 } from "zod/v4";
326
- var CRMFieldTypeSchema = z3.enum([
326
+ var SKILL_SCHEMA_VERSION = "https://skedyul.com/schemas/skill/v1";
327
+ var SKILL_SCHEMA_VERSION_V2 = "https://skedyul.com/schemas/skill/v2";
328
+ var SkillSourceSchema = z3.enum(["BUILTIN", "S3", "APP", "EXTERNAL"]);
329
+ var SkillToolRequirementSchema = z3.object({
330
+ requires: z3.array(z3.string()).optional(),
331
+ provides: z3.array(z3.string()).optional()
332
+ });
333
+ var SkillToolSandboxSchema = z3.object({
334
+ mock: z3.unknown().optional()
335
+ });
336
+ var ToolConstraintsSchema = z3.object({
337
+ maxCallsPerRun: z3.number().optional(),
338
+ idempotent: z3.boolean().optional(),
339
+ restricted: z3.boolean().optional(),
340
+ tags: z3.array(z3.string()).optional()
341
+ });
342
+ var SkillToolDefinitionSchema = z3.object({
343
+ tool: z3.string(),
344
+ description: z3.string().optional(),
345
+ overrides: z3.record(z3.string(), z3.unknown()).optional(),
346
+ sandbox: SkillToolSandboxSchema.optional(),
347
+ requiresApproval: z3.boolean().optional(),
348
+ constraints: ToolConstraintsSchema.optional()
349
+ });
350
+ var SkillToolsSchema = z3.union([
351
+ SkillToolRequirementSchema,
352
+ z3.array(SkillToolDefinitionSchema)
353
+ ]);
354
+ var SkillExampleSchema = z3.object({
355
+ context: z3.string().optional(),
356
+ input: z3.string(),
357
+ reasoning: z3.string().optional(),
358
+ output: z3.string(),
359
+ tool_call: z3.string().optional()
360
+ });
361
+ var CRMModelFieldRequirementsSchema = z3.object({
362
+ required: z3.array(z3.string()).optional(),
363
+ recommended: z3.array(z3.string()).optional()
364
+ });
365
+ var CRMContextSchema = z3.object({
366
+ models: z3.record(z3.string(), CRMModelFieldRequirementsSchema)
367
+ });
368
+ var EntityOperationSchema = z3.enum(["get", "list", "update", "create", "delete"]);
369
+ var EntityPoliciesSchema = z3.record(
370
+ z3.string(),
371
+ // entity handle (e.g., "member", "booking")
372
+ z3.array(EntityOperationSchema)
373
+ // allowed operations
374
+ );
375
+ var EvaluatorPreconditionsSchema = z3.object({
376
+ toolSucceeded: z3.boolean().optional(),
377
+ anyWrittenFields: z3.array(z3.string()).optional(),
378
+ noneOfWrittenFields: z3.array(z3.string()).optional(),
379
+ crm: z3.array(
380
+ z3.object({
381
+ field: z3.string(),
382
+ op: z3.enum(["eq", "in", "empty", "notEmpty"]),
383
+ value: z3.unknown().optional()
384
+ })
385
+ ).optional(),
386
+ skillsLoaded: z3.array(z3.string()).optional(),
387
+ skillsNotLoaded: z3.array(z3.string()).optional()
388
+ });
389
+ var SkillEvaluatorSchema = z3.object({
390
+ name: z3.string(),
391
+ description: z3.string().optional(),
392
+ target: z3.enum(["message", "tool", "entity"]),
393
+ selector: z3.string().optional(),
394
+ criteria: z3.string(),
395
+ passThreshold: z3.number().optional(),
396
+ checks: z3.object({
397
+ requiredArgs: z3.array(z3.string()).optional(),
398
+ forbiddenArgValues: z3.record(z3.string(), z3.array(z3.unknown())).optional()
399
+ }).optional(),
400
+ preconditions: EvaluatorPreconditionsSchema.optional()
401
+ });
402
+ var SkillYAMLSchema = z3.object({
403
+ // Schema version
404
+ $schema: z3.string().optional(),
405
+ // Identity
406
+ handle: z3.string(),
407
+ name: z3.string(),
408
+ version: z3.string().optional(),
409
+ description: z3.string().optional(),
410
+ // Instructions injected into agent system prompt
411
+ instructions: z3.string(),
412
+ // Entity policies - declares which entity operations this skill needs
413
+ // At runtime, these are resolved to CRM tools via AppCrmMap
414
+ entityPolicies: EntityPoliciesSchema.optional(),
415
+ // Tool configuration - supports both v1 and v2 formats
416
+ // Use for non-entity tools (MCP tools, system tools)
417
+ tools: SkillToolsSchema.optional(),
418
+ // CRM context - specifies which models/fields to include in schema
419
+ crmContext: CRMContextSchema.optional(),
420
+ ownedFields: z3.array(z3.string()).optional(),
421
+ // Quality evaluators owned by this skill
422
+ evaluators: z3.array(SkillEvaluatorSchema).optional(),
423
+ // Few-shot examples
424
+ examples: z3.array(SkillExampleSchema).optional()
425
+ });
426
+ var SkillYAMLV2Schema = z3.object({
427
+ $schema: z3.literal(SKILL_SCHEMA_VERSION_V2).optional(),
428
+ handle: z3.string(),
429
+ name: z3.string(),
430
+ version: z3.string().optional(),
431
+ description: z3.string().optional(),
432
+ instructions: z3.string(),
433
+ entityPolicies: EntityPoliciesSchema.optional(),
434
+ tools: z3.array(SkillToolDefinitionSchema).optional(),
435
+ crmContext: CRMContextSchema.optional(),
436
+ ownedFields: z3.array(z3.string()).optional(),
437
+ evaluators: z3.array(SkillEvaluatorSchema).optional(),
438
+ examples: z3.array(SkillExampleSchema).optional()
439
+ });
440
+ var SkillVersionWeightSchema = z3.object({
441
+ version: z3.number(),
442
+ weight: z3.number()
443
+ });
444
+ var SkillRefSchema = z3.union([
445
+ z3.string(),
446
+ // Just handle - uses latest published version
447
+ z3.object({
448
+ skill: z3.string(),
449
+ description: z3.string().optional(),
450
+ // For AI SDK Agent Skills discovery
451
+ /**
452
+ * @deprecated Ignored. The agent must call system:skill:load each turn.
453
+ * Kept so existing agent YAML still validates.
454
+ */
455
+ alwaysLoad: z3.boolean().optional(),
456
+ // Version selection (pick one):
457
+ version: z3.number().optional(),
458
+ // Pin to specific version number
459
+ versions: z3.array(SkillVersionWeightSchema).optional(),
460
+ // A/B testing weights
461
+ // Legacy support:
462
+ instructions: z3.string().optional(),
463
+ // Inline instructions (deprecated)
464
+ enabled: z3.boolean().optional()
465
+ })
466
+ ]);
467
+ var SkillMetadataSchema = z3.object({
468
+ id: z3.string(),
469
+ handle: z3.string(),
470
+ name: z3.string(),
471
+ version: z3.string().optional(),
472
+ description: z3.string().optional(),
473
+ source: SkillSourceSchema,
474
+ s3Key: z3.string().optional(),
475
+ appVersionId: z3.string().optional(),
476
+ workplaceId: z3.string().optional(),
477
+ createdAt: z3.string().datetime().optional(),
478
+ updatedAt: z3.string().datetime().optional()
479
+ });
480
+ var ResolvedSkillSchema = z3.object({
481
+ handle: z3.string(),
482
+ name: z3.string(),
483
+ instructions: z3.string().optional(),
484
+ description: z3.string().optional(),
485
+ tools: z3.array(z3.string()).optional(),
486
+ examples: z3.array(SkillExampleSchema).optional()
487
+ });
488
+ var LoadedSkillSchema = z3.object({
489
+ handle: z3.string(),
490
+ name: z3.string(),
491
+ instructions: z3.string().optional(),
492
+ description: z3.string().optional(),
493
+ entityPolicies: EntityPoliciesSchema.optional(),
494
+ tools: z3.array(SkillToolDefinitionSchema).optional(),
495
+ examples: z3.array(SkillExampleSchema).optional()
496
+ });
497
+ function isV2SkillTools(tools) {
498
+ if (!tools) return false;
499
+ return Array.isArray(tools);
500
+ }
501
+ function getSkillToolNames(tools) {
502
+ if (!tools) return [];
503
+ if (isV2SkillTools(tools)) {
504
+ return tools.map((t) => t.tool);
505
+ }
506
+ return tools.requires || [];
507
+ }
508
+ function defineSkill(skill) {
509
+ return SkillYAMLSchema.parse(skill);
510
+ }
511
+ function validateSkillYAML(skill) {
512
+ const result = SkillYAMLSchema.safeParse(skill);
513
+ if (result.success) {
514
+ return { success: true, data: result.data };
515
+ }
516
+ return { success: false, error: result.error };
517
+ }
518
+ function formatSkillInstructions(skills) {
519
+ if (skills.length === 0) return "";
520
+ const sections = skills.map((skill) => {
521
+ if (!skill.instructions) {
522
+ return `## ${skill.name}
523
+
524
+ ${skill.description || "No description available."}`;
525
+ }
526
+ let section = `## ${skill.name}
527
+
528
+ ${skill.instructions}`;
529
+ if (skill.examples && skill.examples.length > 0) {
530
+ section += "\n\n### Examples\n";
531
+ for (const example of skill.examples) {
532
+ section += `
533
+ **Input:** ${example.input}
534
+ `;
535
+ if (example.reasoning) {
536
+ section += `**Reasoning:** ${example.reasoning}
537
+ `;
538
+ }
539
+ section += `**Output:** ${example.output}
540
+ `;
541
+ }
542
+ }
543
+ return section;
544
+ });
545
+ return `# Skills
546
+
547
+ ${sections.join("\n\n---\n\n")}`;
548
+ }
549
+
550
+ // src/schemas/crm-schema.ts
551
+ import { z as z4 } from "zod/v4";
552
+ var CRMFieldTypeSchema = z4.enum([
327
553
  "string",
328
554
  "long_string",
329
555
  "number",
@@ -335,51 +561,51 @@ var CRMFieldTypeSchema = z3.enum([
335
561
  "image",
336
562
  "object"
337
563
  ]);
338
- var CRMFieldRequirementSchema = z3.enum([
564
+ var CRMFieldRequirementSchema = z4.enum([
339
565
  "optional",
340
566
  "on_create",
341
567
  "required"
342
568
  ]);
343
- var CRMFieldOptionSchema = z3.object({
344
- label: z3.string(),
345
- value: z3.string(),
346
- color: z3.string().optional()
347
- });
348
- var CRMFieldDefinitionObjectSchema = z3.object({
349
- options: z3.array(CRMFieldOptionSchema).optional(),
350
- limitChoices: z3.number().optional(),
351
- minLength: z3.number().optional(),
352
- maxLength: z3.number().optional(),
353
- min: z3.number().optional(),
354
- max: z3.number().optional(),
355
- pattern: z3.string().optional()
356
- });
357
- var CRMFieldDefinitionSchema = z3.union([
358
- z3.string(),
569
+ var CRMFieldOptionSchema = z4.object({
570
+ label: z4.string(),
571
+ value: z4.string(),
572
+ color: z4.string().optional()
573
+ });
574
+ var CRMFieldDefinitionObjectSchema = z4.object({
575
+ options: z4.array(CRMFieldOptionSchema).optional(),
576
+ limitChoices: z4.number().optional(),
577
+ minLength: z4.number().optional(),
578
+ maxLength: z4.number().optional(),
579
+ min: z4.number().optional(),
580
+ max: z4.number().optional(),
581
+ pattern: z4.string().optional()
582
+ });
583
+ var CRMFieldDefinitionSchema = z4.union([
584
+ z4.string(),
359
585
  CRMFieldDefinitionObjectSchema
360
586
  ]);
361
- var CRMFieldAppearanceSchemaZ = z3.object({
362
- leftIcon: z3.string().optional(),
363
- rightIcon: z3.string().optional(),
364
- placeholder: z3.string().optional(),
365
- helpText: z3.string().optional()
366
- });
367
- var CRMFieldAiMetaSchemaZ = z3.object({
368
- description: z3.string().optional(),
369
- mutability: z3.enum(["always", "restricted", "create_only", "immutable"]).optional()
370
- });
371
- var CRMFieldSchemaZ = z3.object({
372
- handle: z3.string().regex(/^[a-z][a-z0-9_]*$/, "Handle must be lowercase alphanumeric with underscores, starting with a letter"),
373
- label: z3.string().min(1, "Label is required"),
587
+ var CRMFieldAppearanceSchemaZ = z4.object({
588
+ leftIcon: z4.string().optional(),
589
+ rightIcon: z4.string().optional(),
590
+ placeholder: z4.string().optional(),
591
+ helpText: z4.string().optional()
592
+ });
593
+ var CRMFieldAiMetaSchemaZ = z4.object({
594
+ description: z4.string().optional(),
595
+ mutability: z4.enum(["always", "restricted", "create_only", "immutable"]).optional()
596
+ });
597
+ var CRMFieldSchemaZ = z4.object({
598
+ handle: z4.string().regex(/^[a-z][a-z0-9_]*$/, "Handle must be lowercase alphanumeric with underscores, starting with a letter"),
599
+ label: z4.string().min(1, "Label is required"),
374
600
  type: CRMFieldTypeSchema,
375
601
  /** Field description - explains what the field is for (metadata, not UI) */
376
- description: z3.string().optional(),
602
+ description: z4.string().optional(),
377
603
  /** Field appearance - UI presentation settings */
378
604
  appearance: CRMFieldAppearanceSchemaZ.optional(),
379
605
  requirement: CRMFieldRequirementSchema.optional(),
380
- unique: z3.boolean().optional(),
381
- list: z3.boolean().optional(),
382
- default: z3.unknown().optional(),
606
+ unique: z4.boolean().optional(),
607
+ list: z4.boolean().optional(),
608
+ default: z4.unknown().optional(),
383
609
  definition: CRMFieldDefinitionSchema.optional(),
384
610
  /** AI metadata - description and mutability hints for agents */
385
611
  aiMeta: CRMFieldAiMetaSchemaZ.optional(),
@@ -387,96 +613,96 @@ var CRMFieldSchemaZ = z3.object({
387
613
  * Workplace-scoped field section handle (visualization helper).
388
614
  * Find-or-create on apply; display name is derived from the handle on create.
389
615
  */
390
- section: z3.string().regex(/^[a-z][a-z0-9_-]*$/, "Section handle must be lowercase alphanumeric with underscores/hyphens, starting with a letter").optional()
391
- });
392
- var CRMModelSchemaZ = z3.object({
393
- handle: z3.string().regex(/^[a-z][a-z0-9_]*$/, "Handle must be lowercase alphanumeric with underscores, starting with a letter"),
394
- name: z3.string().min(1, "Name is required"),
395
- namePlural: z3.string().optional(),
396
- labelTemplate: z3.string().optional(),
397
- description: z3.string().optional(),
398
- icon: z3.string().optional(),
399
- fields: z3.array(CRMFieldSchemaZ)
400
- });
401
- var CRMCardinalitySchema = z3.enum([
616
+ section: z4.string().regex(/^[a-z][a-z0-9_-]*$/, "Section handle must be lowercase alphanumeric with underscores/hyphens, starting with a letter").optional()
617
+ });
618
+ var CRMModelSchemaZ = z4.object({
619
+ handle: z4.string().regex(/^[a-z][a-z0-9_]*$/, "Handle must be lowercase alphanumeric with underscores, starting with a letter"),
620
+ name: z4.string().min(1, "Name is required"),
621
+ namePlural: z4.string().optional(),
622
+ labelTemplate: z4.string().optional(),
623
+ description: z4.string().optional(),
624
+ icon: z4.string().optional(),
625
+ fields: z4.array(CRMFieldSchemaZ)
626
+ });
627
+ var CRMCardinalitySchema = z4.enum([
402
628
  "one_to_one",
403
629
  "one_to_many",
404
630
  "many_to_one",
405
631
  "many_to_many"
406
632
  ]);
407
- var CRMOnDeleteSchema = z3.enum([
633
+ var CRMOnDeleteSchema = z4.enum([
408
634
  "none",
409
635
  "cascade",
410
636
  "restrict",
411
637
  "set_null"
412
638
  ]);
413
- var CRMRelationshipLinkSchema = z3.object({
414
- model: z3.string(),
415
- field: z3.string(),
416
- label: z3.string()
639
+ var CRMRelationshipLinkSchema = z4.object({
640
+ model: z4.string(),
641
+ field: z4.string(),
642
+ label: z4.string()
417
643
  });
418
- var CRMRelationshipSchemaZ = z3.object({
644
+ var CRMRelationshipSchemaZ = z4.object({
419
645
  source: CRMRelationshipLinkSchema,
420
646
  target: CRMRelationshipLinkSchema,
421
647
  cardinality: CRMCardinalitySchema,
422
648
  onDelete: CRMOnDeleteSchema.optional()
423
649
  });
424
- var CRMBlockTypeSchema = z3.enum([
650
+ var CRMBlockTypeSchema = z4.enum([
425
651
  "spreadsheet",
426
652
  "form",
427
653
  "card",
428
654
  "metric",
429
655
  "kanban"
430
656
  ]);
431
- var CRMBlockSchemaZ = z3.object({
657
+ var CRMBlockSchemaZ = z4.object({
432
658
  type: CRMBlockTypeSchema,
433
- title: z3.string().optional(),
434
- config: z3.unknown().optional(),
435
- default: z3.boolean().optional()
659
+ title: z4.string().optional(),
660
+ config: z4.unknown().optional(),
661
+ default: z4.boolean().optional()
436
662
  });
437
- var CRMPageTypeSchema = z3.enum(["list", "instance"]);
438
- var CRMPageSchemaZ = z3.object({
439
- path: z3.string(),
663
+ var CRMPageTypeSchema = z4.enum(["list", "instance"]);
664
+ var CRMPageSchemaZ = z4.object({
665
+ path: z4.string(),
440
666
  type: CRMPageTypeSchema,
441
- title: z3.string(),
442
- icon: z3.string().optional(),
443
- modelHandle: z3.string(),
444
- parentPath: z3.string().optional(),
445
- isDefault: z3.boolean().optional(),
446
- visibility: z3.enum(["team", "private"]).optional(),
447
- baseQuery: z3.unknown().optional(),
448
- blocks: z3.array(CRMBlockSchemaZ).optional()
449
- });
450
- var CRMNavigationNodeBaseSchemaZ = z3.object({
451
- label: z3.string(),
452
- icon: z3.string().optional(),
453
- path: z3.string().optional(),
454
- kind: z3.enum(["section", "group"]).optional(),
455
- sortIndex: z3.number().optional()
456
- });
457
- var CRMNavigationItemSchemaZ = z3.lazy(
667
+ title: z4.string(),
668
+ icon: z4.string().optional(),
669
+ modelHandle: z4.string(),
670
+ parentPath: z4.string().optional(),
671
+ isDefault: z4.boolean().optional(),
672
+ visibility: z4.enum(["team", "private"]).optional(),
673
+ baseQuery: z4.unknown().optional(),
674
+ blocks: z4.array(CRMBlockSchemaZ).optional()
675
+ });
676
+ var CRMNavigationNodeBaseSchemaZ = z4.object({
677
+ label: z4.string(),
678
+ icon: z4.string().optional(),
679
+ path: z4.string().optional(),
680
+ kind: z4.enum(["section", "group"]).optional(),
681
+ sortIndex: z4.number().optional()
682
+ });
683
+ var CRMNavigationItemSchemaZ = z4.lazy(
458
684
  () => CRMNavigationNodeBaseSchemaZ.extend({
459
- children: z3.array(CRMNavigationItemSchemaZ).optional()
685
+ children: z4.array(CRMNavigationItemSchemaZ).optional()
460
686
  })
461
687
  );
462
- var CRMNavigationSchemaZ = z3.object({
463
- sidebar: z3.array(CRMNavigationItemSchemaZ).optional()
688
+ var CRMNavigationSchemaZ = z4.object({
689
+ sidebar: z4.array(CRMNavigationItemSchemaZ).optional()
464
690
  });
465
- var CRMSchemaZ = z3.object({
691
+ var CRMSchemaZ = z4.object({
466
692
  /** Schema format version for future compatibility */
467
- $schema: z3.literal("https://skedyul.com/schemas/crm/v1").optional(),
693
+ $schema: z4.literal("https://skedyul.com/schemas/crm/v1").optional(),
468
694
  /** Schema name for identification */
469
- name: z3.string().min(1, "Name is required"),
695
+ name: z4.string().min(1, "Name is required"),
470
696
  /** Optional description */
471
- description: z3.string().optional(),
697
+ description: z4.string().optional(),
472
698
  /** Schema version (semver) */
473
- version: z3.string().optional(),
699
+ version: z4.string().optional(),
474
700
  /** Model definitions */
475
- models: z3.array(CRMModelSchemaZ),
701
+ models: z4.array(CRMModelSchemaZ),
476
702
  /** Relationship definitions */
477
- relationships: z3.array(CRMRelationshipSchemaZ).optional(),
703
+ relationships: z4.array(CRMRelationshipSchemaZ).optional(),
478
704
  /** Page definitions */
479
- pages: z3.array(CRMPageSchemaZ).optional(),
705
+ pages: z4.array(CRMPageSchemaZ).optional(),
480
706
  /** Navigation definitions */
481
707
  navigation: CRMNavigationSchemaZ.optional()
482
708
  });
@@ -506,8 +732,8 @@ function safeParseCRMSchema(data) {
506
732
  import { z as z7 } from "zod/v4";
507
733
 
508
734
  // src/events/types.ts
509
- import { z as z4 } from "zod/v4";
510
- var ThreadEventTypeSchema = z4.enum([
735
+ import { z as z5 } from "zod/v4";
736
+ var ThreadEventTypeSchema = z5.enum([
511
737
  // Message events
512
738
  "thread.message.received",
513
739
  "thread.message.sent",
@@ -530,73 +756,73 @@ var ThreadEventTypeSchema = z4.enum([
530
756
  // Signal events
531
757
  "thread.signal.created"
532
758
  ]);
533
- var CustomEventTypeSchema = z4.string().regex(/^custom\.[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/, {
759
+ var CustomEventTypeSchema = z5.string().regex(/^custom\.[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/, {
534
760
  message: "Custom event type must match pattern: custom.{namespace}.{event}"
535
761
  });
536
- var EventTypeSchema = z4.union([ThreadEventTypeSchema, CustomEventTypeSchema]);
537
- var ParticipantKindSchema = z4.enum(["CONTACT", "MEMBER", "AGENT", "WORKFLOW"]);
538
- var BaseEventPayloadSchema = z4.object({
539
- threadId: z4.string(),
540
- workplaceId: z4.string(),
541
- timestamp: z4.string().datetime().optional()
762
+ var EventTypeSchema = z5.union([ThreadEventTypeSchema, CustomEventTypeSchema]);
763
+ var ParticipantKindSchema = z5.enum(["CONTACT", "MEMBER", "AGENT", "WORKFLOW"]);
764
+ var BaseEventPayloadSchema = z5.object({
765
+ threadId: z5.string(),
766
+ workplaceId: z5.string(),
767
+ timestamp: z5.string().datetime().optional()
542
768
  });
543
769
  var MessageEventPayloadSchema = BaseEventPayloadSchema.extend({
544
- message: z4.object({
545
- id: z4.string(),
546
- content: z4.string(),
547
- senderId: z4.string().optional()
770
+ message: z5.object({
771
+ id: z5.string(),
772
+ content: z5.string(),
773
+ senderId: z5.string().optional()
548
774
  }),
549
- participant: z4.object({
550
- id: z4.string(),
775
+ participant: z5.object({
776
+ id: z5.string(),
551
777
  kind: ParticipantKindSchema,
552
- displayName: z4.string().optional()
778
+ displayName: z5.string().optional()
553
779
  }).optional(),
554
- isFirstMessage: z4.boolean().optional(),
555
- messageCount: z4.number().optional()
780
+ isFirstMessage: z5.boolean().optional(),
781
+ messageCount: z5.number().optional()
556
782
  });
557
783
  var ParticipantEventPayloadSchema = BaseEventPayloadSchema.extend({
558
- participant: z4.object({
559
- id: z4.string(),
784
+ participant: z5.object({
785
+ id: z5.string(),
560
786
  kind: ParticipantKindSchema,
561
- displayName: z4.string().optional(),
562
- contactId: z4.string().optional(),
563
- memberId: z4.string().optional(),
564
- agentId: z4.string().optional(),
565
- workflowId: z4.string().optional()
787
+ displayName: z5.string().optional(),
788
+ contactId: z5.string().optional(),
789
+ memberId: z5.string().optional(),
790
+ agentId: z5.string().optional(),
791
+ workflowId: z5.string().optional()
566
792
  })
567
793
  });
568
794
  var ContextChangedPayloadSchema = BaseEventPayloadSchema.extend({
569
- context: z4.object({
570
- handle: z4.string(),
571
- model: z4.string(),
572
- instanceId: z4.string()
795
+ context: z5.object({
796
+ handle: z5.string(),
797
+ model: z5.string(),
798
+ instanceId: z5.string()
573
799
  }),
574
- change: z4.object({
575
- field: z4.string().optional(),
576
- oldValue: z4.unknown().optional(),
577
- newValue: z4.unknown().optional()
800
+ change: z5.object({
801
+ field: z5.string().optional(),
802
+ oldValue: z5.unknown().optional(),
803
+ newValue: z5.unknown().optional()
578
804
  }).optional()
579
805
  });
580
806
  var StatusChangedPayloadSchema = BaseEventPayloadSchema.extend({
581
- oldStatus: z4.string(),
582
- newStatus: z4.string()
807
+ oldStatus: z5.string(),
808
+ newStatus: z5.string()
583
809
  });
584
810
  var ScheduledEventPayloadSchema = BaseEventPayloadSchema.extend({
585
- scheduledEventId: z4.string(),
586
- reason: z4.string().optional(),
587
- context: z4.record(z4.string(), z4.unknown()).optional()
811
+ scheduledEventId: z5.string(),
812
+ reason: z5.string().optional(),
813
+ context: z5.record(z5.string(), z5.unknown()).optional()
588
814
  });
589
815
  var AgentWorkflowEventPayloadSchema = BaseEventPayloadSchema.extend({
590
- agentId: z4.string().optional(),
591
- workflowId: z4.string().optional(),
592
- workflowRunId: z4.string().optional(),
593
- outputs: z4.record(z4.string(), z4.unknown()).optional(),
594
- error: z4.string().optional()
816
+ agentId: z5.string().optional(),
817
+ workflowId: z5.string().optional(),
818
+ workflowRunId: z5.string().optional(),
819
+ outputs: z5.record(z5.string(), z5.unknown()).optional(),
820
+ error: z5.string().optional()
595
821
  });
596
822
  var CustomEventPayloadSchema = BaseEventPayloadSchema.extend({
597
- data: z4.record(z4.string(), z4.unknown()).optional()
823
+ data: z5.record(z5.string(), z5.unknown()).optional()
598
824
  });
599
- var ThreadEventPayloadSchema = z4.union([
825
+ var ThreadEventPayloadSchema = z5.union([
600
826
  MessageEventPayloadSchema,
601
827
  ParticipantEventPayloadSchema,
602
828
  ContextChangedPayloadSchema,
@@ -605,218 +831,40 @@ var ThreadEventPayloadSchema = z4.union([
605
831
  AgentWorkflowEventPayloadSchema,
606
832
  CustomEventPayloadSchema
607
833
  ]);
608
- var ThreadEventSchema = z4.object({
609
- id: z4.string(),
610
- threadId: z4.string(),
834
+ var ThreadEventSchema = z5.object({
835
+ id: z5.string(),
836
+ threadId: z5.string(),
611
837
  type: EventTypeSchema,
612
838
  payload: ThreadEventPayloadSchema,
613
- emittedBy: z4.string().optional(),
614
- createdAt: z4.string().datetime()
839
+ emittedBy: z5.string().optional(),
840
+ createdAt: z5.string().datetime()
615
841
  });
616
- var CreateThreadEventInputSchema = z4.object({
617
- threadId: z4.string(),
842
+ var CreateThreadEventInputSchema = z5.object({
843
+ threadId: z5.string(),
618
844
  type: EventTypeSchema,
619
- payload: z4.record(z4.string(), z4.unknown()),
620
- emittedBy: z4.string().optional()
845
+ payload: z5.record(z5.string(), z5.unknown()),
846
+ emittedBy: z5.string().optional()
621
847
  });
622
- var EventSubscriptionSchema = z4.object({
623
- subscribes: z4.array(EventTypeSchema),
624
- condition: z4.string().optional(),
625
- cancels: z4.array(EventTypeSchema).optional(),
626
- cancelCondition: z4.string().optional()
848
+ var EventSubscriptionSchema = z5.object({
849
+ subscribes: z5.array(EventTypeSchema),
850
+ condition: z5.string().optional(),
851
+ cancels: z5.array(EventTypeSchema).optional(),
852
+ cancelCondition: z5.string().optional()
627
853
  });
628
- var EventWaitSchema = z4.object({
854
+ var EventWaitSchema = z5.object({
629
855
  event: EventTypeSchema,
630
- timeout: z4.string().optional(),
631
- onTimeout: z4.string().optional()
856
+ timeout: z5.string().optional(),
857
+ onTimeout: z5.string().optional()
632
858
  });
633
- var EventsConfigSchema = z4.object({
634
- subscribes: z4.array(EventTypeSchema).optional(),
635
- condition: z4.string().optional(),
636
- emits: z4.array(EventTypeSchema).optional(),
637
- waits: z4.array(EventWaitSchema).optional(),
638
- cancels: z4.array(EventTypeSchema).optional(),
639
- cancelCondition: z4.string().optional()
859
+ var EventsConfigSchema = z5.object({
860
+ subscribes: z5.array(EventTypeSchema).optional(),
861
+ condition: z5.string().optional(),
862
+ emits: z5.array(EventTypeSchema).optional(),
863
+ waits: z5.array(EventWaitSchema).optional(),
864
+ cancels: z5.array(EventTypeSchema).optional(),
865
+ cancelCondition: z5.string().optional()
640
866
  });
641
867
 
642
- // src/skills/types.ts
643
- import { z as z5 } from "zod/v4";
644
- var SKILL_SCHEMA_VERSION = "https://skedyul.com/schemas/skill/v1";
645
- var SKILL_SCHEMA_VERSION_V2 = "https://skedyul.com/schemas/skill/v2";
646
- var SkillSourceSchema = z5.enum(["BUILTIN", "S3", "APP", "EXTERNAL"]);
647
- var SkillToolRequirementSchema = z5.object({
648
- requires: z5.array(z5.string()).optional(),
649
- provides: z5.array(z5.string()).optional()
650
- });
651
- var SkillToolSandboxSchema = z5.object({
652
- mock: z5.unknown().optional()
653
- });
654
- var ToolConstraintsSchema = z5.object({
655
- maxCallsPerRun: z5.number().optional(),
656
- idempotent: z5.boolean().optional(),
657
- restricted: z5.boolean().optional(),
658
- tags: z5.array(z5.string()).optional()
659
- });
660
- var SkillToolDefinitionSchema = z5.object({
661
- tool: z5.string(),
662
- description: z5.string().optional(),
663
- overrides: z5.record(z5.string(), z5.unknown()).optional(),
664
- sandbox: SkillToolSandboxSchema.optional(),
665
- requiresApproval: z5.boolean().optional(),
666
- constraints: ToolConstraintsSchema.optional()
667
- });
668
- var SkillToolsSchema = z5.union([
669
- SkillToolRequirementSchema,
670
- z5.array(SkillToolDefinitionSchema)
671
- ]);
672
- var SkillExampleSchema = z5.object({
673
- context: z5.string().optional(),
674
- input: z5.string(),
675
- reasoning: z5.string().optional(),
676
- output: z5.string(),
677
- tool_call: z5.string().optional()
678
- });
679
- var CRMModelFieldRequirementsSchema = z5.object({
680
- required: z5.array(z5.string()).optional(),
681
- recommended: z5.array(z5.string()).optional()
682
- });
683
- var CRMContextSchema = z5.object({
684
- models: z5.record(z5.string(), CRMModelFieldRequirementsSchema)
685
- });
686
- var SkillYAMLSchema = z5.object({
687
- // Schema version
688
- $schema: z5.string().optional(),
689
- // Identity
690
- handle: z5.string(),
691
- name: z5.string(),
692
- version: z5.string().optional(),
693
- description: z5.string().optional(),
694
- // Instructions injected into agent system prompt
695
- instructions: z5.string(),
696
- // Tool configuration - supports both v1 and v2 formats
697
- tools: SkillToolsSchema.optional(),
698
- // CRM context - specifies which models/fields to include in schema
699
- crmContext: CRMContextSchema.optional(),
700
- // Few-shot examples
701
- examples: z5.array(SkillExampleSchema).optional()
702
- });
703
- var SkillYAMLV2Schema = z5.object({
704
- $schema: z5.literal(SKILL_SCHEMA_VERSION_V2).optional(),
705
- handle: z5.string(),
706
- name: z5.string(),
707
- version: z5.string().optional(),
708
- description: z5.string().optional(),
709
- instructions: z5.string(),
710
- tools: z5.array(SkillToolDefinitionSchema).optional(),
711
- crmContext: CRMContextSchema.optional(),
712
- examples: z5.array(SkillExampleSchema).optional()
713
- });
714
- var SkillVersionWeightSchema = z5.object({
715
- version: z5.number(),
716
- weight: z5.number()
717
- });
718
- var SkillRefSchema = z5.union([
719
- z5.string(),
720
- // Just handle - uses latest published version
721
- z5.object({
722
- skill: z5.string(),
723
- description: z5.string().optional(),
724
- // For AI SDK Agent Skills discovery
725
- /** Auto-inject this skill's instructions and tools on every agent turn */
726
- alwaysLoad: z5.boolean().optional(),
727
- // Version selection (pick one):
728
- version: z5.number().optional(),
729
- // Pin to specific version number
730
- versions: z5.array(SkillVersionWeightSchema).optional(),
731
- // A/B testing weights
732
- // Legacy support:
733
- instructions: z5.string().optional(),
734
- // Inline instructions (deprecated)
735
- enabled: z5.boolean().optional()
736
- })
737
- ]);
738
- var SkillMetadataSchema = z5.object({
739
- id: z5.string(),
740
- handle: z5.string(),
741
- name: z5.string(),
742
- version: z5.string().optional(),
743
- description: z5.string().optional(),
744
- source: SkillSourceSchema,
745
- s3Key: z5.string().optional(),
746
- appVersionId: z5.string().optional(),
747
- workplaceId: z5.string().optional(),
748
- createdAt: z5.string().datetime().optional(),
749
- updatedAt: z5.string().datetime().optional()
750
- });
751
- var ResolvedSkillSchema = z5.object({
752
- handle: z5.string(),
753
- name: z5.string(),
754
- instructions: z5.string().optional(),
755
- description: z5.string().optional(),
756
- tools: z5.array(z5.string()).optional(),
757
- examples: z5.array(SkillExampleSchema).optional()
758
- });
759
- var LoadedSkillSchema = z5.object({
760
- handle: z5.string(),
761
- name: z5.string(),
762
- instructions: z5.string().optional(),
763
- description: z5.string().optional(),
764
- tools: z5.array(SkillToolDefinitionSchema).optional(),
765
- examples: z5.array(SkillExampleSchema).optional()
766
- });
767
- function isV2SkillTools(tools) {
768
- if (!tools) return false;
769
- return Array.isArray(tools);
770
- }
771
- function getSkillToolNames(tools) {
772
- if (!tools) return [];
773
- if (isV2SkillTools(tools)) {
774
- return tools.map((t) => t.tool);
775
- }
776
- return tools.requires || [];
777
- }
778
- function defineSkill(skill) {
779
- return SkillYAMLSchema.parse(skill);
780
- }
781
- function validateSkillYAML(skill) {
782
- const result = SkillYAMLSchema.safeParse(skill);
783
- if (result.success) {
784
- return { success: true, data: result.data };
785
- }
786
- return { success: false, error: result.error };
787
- }
788
- function formatSkillInstructions(skills) {
789
- if (skills.length === 0) return "";
790
- const sections = skills.map((skill) => {
791
- if (!skill.instructions) {
792
- return `## ${skill.name}
793
-
794
- ${skill.description || "No description available."}`;
795
- }
796
- let section = `## ${skill.name}
797
-
798
- ${skill.instructions}`;
799
- if (skill.examples && skill.examples.length > 0) {
800
- section += "\n\n### Examples\n";
801
- for (const example of skill.examples) {
802
- section += `
803
- **Input:** ${example.input}
804
- `;
805
- if (example.reasoning) {
806
- section += `**Reasoning:** ${example.reasoning}
807
- `;
808
- }
809
- section += `**Output:** ${example.output}
810
- `;
811
- }
812
- }
813
- return section;
814
- });
815
- return `# Skills
816
-
817
- ${sections.join("\n\n---\n\n")}`;
818
- }
819
-
820
868
  // src/context/types.ts
821
869
  import { z as z6 } from "zod/v4";
822
870
  var CRMContextSchema2 = z6.object({
@@ -1063,6 +1111,13 @@ var ResponsesBehaviorConfigSchema = z7.object({
1063
1111
  * @default false
1064
1112
  */
1065
1113
  allowSchedule: z7.boolean().optional(),
1114
+ /**
1115
+ * Whether the agent may skip sending when no reply is warranted.
1116
+ * Platform injects silence rules and exposes system:message:skip.
1117
+ * An explicit skip satisfies requireFinal. Off by default.
1118
+ * @default false
1119
+ */
1120
+ allowSilent: z7.boolean().optional(),
1066
1121
  /**
1067
1122
  * Message splitting configuration.
1068
1123
  * Controls whether and how the agent splits responses into multiple messages.
@@ -1369,6 +1424,22 @@ var EntityCrmMapDefaultsSchema = z8.object({
1369
1424
  var EntityRuntimeToolsSchema = z8.object({
1370
1425
  calendarWindowPull: z8.string().min(1).optional()
1371
1426
  });
1427
+ var EntitySaveInteractionSchema = z8.object({
1428
+ handle: z8.string(),
1429
+ when: z8.object({
1430
+ onCreate: z8.boolean().optional(),
1431
+ onUpdate: z8.boolean().optional(),
1432
+ fieldsChanged: z8.array(z8.string()).optional(),
1433
+ relationshipsChanged: z8.array(z8.string()).optional()
1434
+ }),
1435
+ dialog: z8.object({
1436
+ title: z8.string(),
1437
+ message: z8.string(),
1438
+ severity: z8.enum(["warning", "info"]).optional(),
1439
+ fields: z8.array(z8.string()),
1440
+ defaults: z8.record(z8.string(), z8.string()).optional()
1441
+ })
1442
+ });
1372
1443
  var EntityDefinitionSchema = z8.object({
1373
1444
  handle: z8.string(),
1374
1445
  label: z8.string(),
@@ -1378,7 +1449,8 @@ var EntityDefinitionSchema = z8.object({
1378
1449
  contextFields: z8.array(EntityFieldDefinitionSchema).optional(),
1379
1450
  relationships: z8.array(EntityRelationshipDefinitionSchema).optional(),
1380
1451
  crmMapDefaults: EntityCrmMapDefaultsSchema.optional(),
1381
- tools: EntityRuntimeToolsSchema.optional()
1452
+ tools: EntityRuntimeToolsSchema.optional(),
1453
+ saveInteractions: z8.array(EntitySaveInteractionSchema).optional()
1382
1454
  });
1383
1455
  var RelationshipCardinalitySchema = z8.enum([
1384
1456
  "ONE_TO_ONE",
@@ -1995,6 +2067,26 @@ var BatchOperationDefinitionSchema = z8.object({
1995
2067
  pageSize: z8.number().int().positive().optional(),
1996
2068
  icon: z8.string().optional()
1997
2069
  });
2070
+ var ProvisionSkillDefinitionSchema = z8.object({
2071
+ /** Unique identifier for the skill */
2072
+ handle: z8.string(),
2073
+ /** Display name */
2074
+ name: z8.string(),
2075
+ /** Short description for skill discovery */
2076
+ description: z8.string().optional(),
2077
+ /** Full instructions injected into agent context when skill is loaded */
2078
+ instructions: z8.string(),
2079
+ /** Entity policies - declares which entity operations this skill needs */
2080
+ entityPolicies: EntityPoliciesSchema.optional(),
2081
+ /** Additional tools (MCP, system) not covered by entity policies */
2082
+ tools: z8.array(SkillToolDefinitionSchema).optional(),
2083
+ /** CRM context - specifies which model fields to include in schema */
2084
+ crmContext: z8.object({
2085
+ models: z8.record(z8.string(), CRMModelFieldRequirementsSchema)
2086
+ }).optional(),
2087
+ /** Few-shot examples for the skill */
2088
+ examples: z8.array(SkillExampleSchema).optional()
2089
+ });
1998
2090
  var ProvisionConfigSchema = z8.object({
1999
2091
  env: EnvSchemaSchema.optional(),
2000
2092
  /** INTERNAL model definitions for data shared across installs */
@@ -2011,7 +2103,9 @@ var ProvisionConfigSchema = z8.object({
2011
2103
  /** Install setup checklist steps (opt-in) */
2012
2104
  setup: z8.array(SetupStepDefinitionSchema).optional(),
2013
2105
  /** Batch operations for imports, syncs, and long-running tasks */
2014
- batchOperations: z8.array(BatchOperationDefinitionSchema).optional()
2106
+ batchOperations: z8.array(BatchOperationDefinitionSchema).optional(),
2107
+ /** Skills provided by this app */
2108
+ skills: z8.array(ProvisionSkillDefinitionSchema).optional()
2015
2109
  });
2016
2110
  var SkedyulConfigSchema = z8.object({
2017
2111
  name: z8.string(),
@@ -8963,8 +9057,11 @@ export {
8963
9057
  EntityCrmMapDefaultsSchema,
8964
9058
  EntityDefinitionSchema,
8965
9059
  EntityFieldDefinitionSchema,
9060
+ EntityOperationSchema,
9061
+ EntityPoliciesSchema,
8966
9062
  EntityRelationshipDefinitionSchema,
8967
9063
  EntityRuntimeToolsSchema,
9064
+ EntitySaveInteractionSchema,
8968
9065
  EnvSchemaSchema,
8969
9066
  EnvVariableDefinitionSchema,
8970
9067
  EnvVisibilitySchema,
@@ -9063,6 +9160,7 @@ export {
9063
9160
  ParticipantEventPayloadSchema,
9064
9161
  ParticipantKindSchema,
9065
9162
  ProvisionConfigSchema,
9163
+ ProvisionSkillDefinitionSchema,
9066
9164
  QueueContextError,
9067
9165
  QueueNotFoundError,
9068
9166
  QueuedFetchExhaustedError,
@@ -9089,6 +9187,7 @@ export {
9089
9187
  SetupStepDefinitionSchema,
9090
9188
  SetupStepKindSchema,
9091
9189
  SkedyulConfigSchema,
9190
+ SkillEvaluatorSchema,
9092
9191
  SkillExampleSchema,
9093
9192
  SkillMetadataSchema,
9094
9193
  SkillRefSchema,