skedyul 1.2.43 → 1.2.48

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.
Files changed (54) hide show
  1. package/dist/cli/commands/workflows.d.ts +1 -0
  2. package/dist/cli/index.js +3682 -9076
  3. package/dist/cli/utils/auth.d.ts +4 -1
  4. package/dist/cli/utils/auth.js +32 -8
  5. package/dist/cli/utils/config.d.ts +23 -0
  6. package/dist/cli/utils/env-sync.d.ts +46 -0
  7. package/dist/cli/utils/mcp-http-client.d.ts +74 -0
  8. package/dist/cli/utils/migration-approval.d.ts +39 -0
  9. package/dist/cli/utils/mock-context.d.ts +19 -9
  10. package/dist/cli/utils/sse.d.ts +33 -0
  11. package/dist/cli/utils.d.ts +5 -1
  12. package/dist/compiler/types.d.ts +11 -9
  13. package/dist/config/schema-loader.d.ts +15 -2
  14. package/dist/config/types/model.d.ts +2 -0
  15. package/dist/config/types/page.d.ts +9 -0
  16. package/dist/context/index.d.ts +2 -2
  17. package/dist/context/resolver.d.ts +29 -28
  18. package/dist/context/types.d.ts +195 -37
  19. package/dist/core/client.d.ts +189 -233
  20. package/dist/dedicated/server.js +264 -166
  21. package/dist/esm/index.mjs +1161 -7674
  22. package/dist/index.d.ts +11 -6
  23. package/dist/index.js +1206 -7672
  24. package/dist/scheduling/calculateWaitTime.d.ts +16 -0
  25. package/dist/scheduling/index.d.ts +11 -0
  26. package/dist/scheduling/index.js +334 -0
  27. package/dist/scheduling/index.mjs +305 -0
  28. package/dist/scheduling/isTimeInWindow.d.ts +15 -0
  29. package/dist/scheduling/types-workflow.d.ts +54 -0
  30. package/dist/scheduling/types.d.ts +166 -0
  31. package/dist/schemas/agent-schema-v3.d.ts +406 -60
  32. package/dist/schemas/agent-schema-v3.js +248 -75
  33. package/dist/schemas/agent-schema-v3.mjs +234 -73
  34. package/dist/schemas/agent-schema.js +3 -7295
  35. package/dist/schemas/agent-schema.mjs +3 -7323
  36. package/dist/schemas/crm-schema.d.ts +53 -19
  37. package/dist/schemas/index.d.ts +1 -1
  38. package/dist/schemas.d.ts +128 -40
  39. package/dist/server/route-handlers/handlers.d.ts +7 -0
  40. package/dist/server/utils/env.d.ts +9 -0
  41. package/dist/server/utils/index.d.ts +1 -0
  42. package/dist/server/utils/mcp-response.d.ts +11 -0
  43. package/dist/server.js +264 -166
  44. package/dist/serverless/server.mjs +264 -166
  45. package/dist/skills/index.d.ts +1 -1
  46. package/dist/skills/types.d.ts +34 -23
  47. package/dist/skills/types.js +8 -17
  48. package/dist/skills/types.mjs +7 -16
  49. package/dist/types/index.d.ts +3 -3
  50. package/dist/types/server.d.ts +1 -0
  51. package/dist/types/tool-context.d.ts +31 -4
  52. package/dist/types/tool-response.d.ts +2 -0
  53. package/dist/types/tool.d.ts +35 -1
  54. package/package.json +8 -1
@@ -170,14 +170,12 @@ var SkillExampleSchema = z2.object({
170
170
  output: z2.string(),
171
171
  tool_call: z2.string().optional()
172
172
  });
173
- var SkillEvaluationMetricSchema = z2.object({
174
- metric: z2.string(),
175
- description: z2.string().optional(),
176
- threshold: z2.number().optional()
173
+ var CRMModelFieldRequirementsSchema = z2.object({
174
+ required: z2.array(z2.string()).optional(),
175
+ recommended: z2.array(z2.string()).optional()
177
176
  });
178
177
  var CRMContextSchema = z2.object({
179
- models: z2.record(z2.string(), z2.array(z2.string()))
180
- // { modelHandle: [fieldHandles] }
178
+ models: z2.record(z2.string(), CRMModelFieldRequirementsSchema)
181
179
  });
182
180
  var SkillYAMLSchema = z2.object({
183
181
  // Schema version
@@ -194,11 +192,7 @@ var SkillYAMLSchema = z2.object({
194
192
  // CRM context - specifies which models/fields to include in schema
195
193
  crmContext: CRMContextSchema.optional(),
196
194
  // Few-shot examples
197
- examples: z2.array(SkillExampleSchema).optional(),
198
- // Evaluation criteria
199
- evaluation: z2.array(SkillEvaluationMetricSchema).optional(),
200
- // Tags for discovery
201
- tags: z2.array(z2.string()).optional()
195
+ examples: z2.array(SkillExampleSchema).optional()
202
196
  });
203
197
  var SkillYAMLV2Schema = z2.object({
204
198
  $schema: z2.literal(SKILL_SCHEMA_VERSION_V2).optional(),
@@ -209,9 +203,7 @@ var SkillYAMLV2Schema = z2.object({
209
203
  instructions: z2.string(),
210
204
  tools: z2.array(SkillToolDefinitionSchema).optional(),
211
205
  crmContext: CRMContextSchema.optional(),
212
- examples: z2.array(SkillExampleSchema).optional(),
213
- evaluation: z2.array(SkillEvaluationMetricSchema).optional(),
214
- tags: z2.array(z2.string()).optional()
206
+ examples: z2.array(SkillExampleSchema).optional()
215
207
  });
216
208
  var SkillVersionWeightSchema = z2.object({
217
209
  version: z2.number(),
@@ -245,7 +237,6 @@ var SkillMetadataSchema = z2.object({
245
237
  s3Key: z2.string().optional(),
246
238
  appVersionId: z2.string().optional(),
247
239
  workplaceId: z2.string().optional(),
248
- tags: z2.array(z2.string()).optional(),
249
240
  createdAt: z2.string().datetime().optional(),
250
241
  updatedAt: z2.string().datetime().optional()
251
242
  });
@@ -293,52 +284,61 @@ var ThreadInfoSchema = z3.object({
293
284
  status: z3.string().optional(),
294
285
  kind: z3.string().optional()
295
286
  });
296
- var AgentContextSchema = z3.object({
297
- // Who sent the message
298
- sender: SenderContextSchema,
299
- // Thread contexts (linked CRM instances)
300
- contexts: z3.array(ThreadContextItemSchema).optional(),
301
- // Thread info
302
- thread: ThreadInfoSchema,
303
- // Workplace info
304
- workplace: z3.object({
305
- id: z3.string(),
306
- name: z3.string().optional()
307
- }).optional()
308
- });
309
- var MockSubscriptionSchema = z3.object({
287
+ var SubscriptionSchema = z3.object({
310
288
  identifierValue: z3.string(),
311
289
  channelHandle: z3.string().optional()
312
290
  });
313
- var MockAssociationSchema = z3.object({
291
+ var AssociationSchema = z3.object({
314
292
  id: z3.string().optional(),
315
293
  data: z3.record(z3.string(), z3.unknown())
316
294
  });
317
- var MockContactSchema = z3.object({
295
+ var ContactSchema = z3.object({
318
296
  id: z3.string().optional(),
319
297
  name: z3.string().optional(),
320
- subscription: MockSubscriptionSchema.optional(),
321
- associations: z3.record(z3.string(), MockAssociationSchema).optional()
298
+ subscription: SubscriptionSchema.optional(),
299
+ associations: z3.record(z3.string(), AssociationSchema).optional()
322
300
  });
323
- var MockSenderContextSchema = z3.object({
301
+ var AgentSenderContextSchema = z3.object({
324
302
  kind: z3.enum(["contact", "member"]),
325
303
  displayName: z3.string().optional(),
326
304
  role: z3.string().optional(),
327
305
  permissions: z3.array(z3.string()).optional(),
328
- contact: MockContactSchema.optional()
306
+ contact: ContactSchema.optional()
329
307
  });
330
- var MockThreadContextSchema = z3.object({
308
+ var AgentThreadContextSchema = z3.object({
331
309
  handle: z3.string(),
332
310
  model: z3.string(),
333
311
  data: z3.record(z3.string(), z3.unknown())
334
312
  });
335
- var MockContextSchema = z3.object({
336
- sender: MockSenderContextSchema,
337
- contexts: z3.array(MockThreadContextSchema).optional()
313
+ var AgentContextSchema = z3.object({
314
+ sender: AgentSenderContextSchema,
315
+ contexts: z3.array(AgentThreadContextSchema).optional()
316
+ });
317
+ var ContextIssueSeveritySchema = z3.enum(["ERROR", "WARNING"]);
318
+ var ContextIssueTypeSchema = z3.enum([
319
+ "MISSING_ROUTING_PARTICIPANT",
320
+ "MISSING_ASSOCIATION",
321
+ "MISSING_REQUIRED_FIELD",
322
+ "MISSING_RECOMMENDED_FIELD"
323
+ ]);
324
+ var ContextIssueSchema = z3.object({
325
+ type: ContextIssueTypeSchema,
326
+ severity: ContextIssueSeveritySchema,
327
+ model: z3.string().optional(),
328
+ field: z3.string().optional(),
329
+ message: z3.string(),
330
+ suggestion: z3.string().optional()
331
+ });
332
+ var ContextValidationResultSchema = z3.object({
333
+ valid: z3.boolean(),
334
+ degraded: z3.boolean(),
335
+ issues: z3.array(ContextIssueSchema)
338
336
  });
339
337
  var SandboxConfigSchema = z3.object({
340
338
  enabled: z3.boolean().optional(),
341
- mockContext: MockContextSchema.optional()
339
+ /** @deprecated Use 'context' instead of 'mockContext' */
340
+ mockContext: AgentContextSchema.optional(),
341
+ context: AgentContextSchema.optional()
342
342
  });
343
343
 
344
344
  // src/schemas/agent-schema-v3.ts
@@ -376,13 +376,14 @@ var ToolRefV3Schema = z4.union([
376
376
  overrides: z4.record(z4.string(), z4.unknown()).optional()
377
377
  })
378
378
  ]);
379
- var BootstrapToolRefSchema = z4.union([
379
+ var AgentToolRefSchema = z4.union([
380
380
  z4.string(),
381
381
  z4.object({
382
382
  tool: z4.string(),
383
383
  description: z4.string().optional()
384
384
  })
385
385
  ]);
386
+ var BootstrapToolRefSchema = AgentToolRefSchema;
386
387
  var WorkingMemoryConfigSchema = z4.object({
387
388
  strategy: z4.enum(["full", "rolling_summary", "sliding_window"]).optional(),
388
389
  maxTokens: z4.number().optional(),
@@ -405,29 +406,169 @@ var MemoryConfigV3Schema = z4.object({
405
406
  external: ExternalMemoryConfigSchema.optional(),
406
407
  semantic: SemanticMemoryConfigSchema.optional()
407
408
  });
408
- var ResponsePolicySchema = z4.object({
409
- requiresApproval: z4.boolean().optional(),
410
- requiresApprovalIf: z4.array(z4.string()).optional()
409
+ var RequiresApprovalPolicySchema = z4.object({
410
+ requiresApproval: z4.boolean().optional()
411
411
  });
412
412
  var PoliciesConfigV3Schema = z4.object({
413
- response: ResponsePolicySchema.optional(),
414
- rules: z4.array(z4.string()).optional()
413
+ messages: z4.object({
414
+ send: RequiresApprovalPolicySchema.optional(),
415
+ schedule: RequiresApprovalPolicySchema.optional()
416
+ }).optional(),
417
+ tools: z4.object({
418
+ externalRequiresApproval: z4.boolean().optional(),
419
+ systemRequiresApproval: z4.boolean().optional()
420
+ }).optional()
415
421
  });
416
422
  var RuntimeConfigV3Schema = z4.object({
417
- model: z4.string().optional(),
418
- timeout: z4.string().optional(),
419
- timezone: z4.string().optional(),
420
- retry: z4.object({
421
- attempts: z4.number().optional(),
422
- backoff: z4.enum(["linear", "exponential"]).optional()
423
+ /** LLM model identifier (e.g., "google/gemini-3.1-flash-lite") */
424
+ model: z4.string().optional()
425
+ });
426
+ var TimeWindowTimeStampSchema = z4.union([
427
+ z4.number().describe("Hour of day (0-23)"),
428
+ z4.object({
429
+ hour: z4.number(),
430
+ minute: z4.number().optional().default(0)
431
+ })
432
+ ]);
433
+ var TimeWindowDayOfWeekSchema = z4.enum([
434
+ "monday",
435
+ "tuesday",
436
+ "wednesday",
437
+ "thursday",
438
+ "friday",
439
+ "saturday",
440
+ "sunday"
441
+ ]);
442
+ var TimeWindowSlotAgentSchema = z4.object({
443
+ startTime: TimeWindowTimeStampSchema,
444
+ endTime: TimeWindowTimeStampSchema,
445
+ days: z4.array(TimeWindowDayOfWeekSchema)
446
+ });
447
+ var ResponseModeSchema = z4.enum([
448
+ "immediate",
449
+ "ack_and_schedule",
450
+ "schedule_only"
451
+ ]);
452
+ var TimeWindowBehaviorSchema = z4.object({
453
+ /** How to handle responses in this window */
454
+ responseMode: ResponseModeSchema,
455
+ /** Prompt injection for this time context */
456
+ prompt: z4.string().optional().describe("Prompt injection for this time context"),
457
+ /** Window to schedule responses for (when responseMode is ack_and_schedule or schedule_only) */
458
+ scheduleFor: z4.string().optional().describe("Window name to schedule responses for")
459
+ });
460
+ var TimeWindowPolicySchema = z4.object({
461
+ /** IANA timezone for the window (e.g., "Australia/Sydney") */
462
+ timezone: z4.string().describe('IANA timezone, e.g., "Australia/Sydney"'),
463
+ /** Time slots when this window is active */
464
+ windows: z4.array(TimeWindowSlotAgentSchema),
465
+ /** Behavior for this window (optional - defaults to immediate response) */
466
+ behavior: TimeWindowBehaviorSchema.optional()
467
+ });
468
+ var TimeWindowPoliciesSchema = z4.record(z4.string(), TimeWindowPolicySchema);
469
+ var TimeWindowDefaultSchema = TimeWindowBehaviorSchema.describe(
470
+ "Fallback behavior when no time window matches"
471
+ );
472
+ var ResponsesBehaviorConfigSchema = z4.object({
473
+ /**
474
+ * Maximum intermediate messages per agent run.
475
+ * Intermediate = progress updates, acknowledgments before task completion.
476
+ * The final message slot is always reserved separately.
477
+ * @default 2
478
+ */
479
+ maxIntermediate: z4.number().optional(),
480
+ /**
481
+ * Whether a final message is required before the run completes.
482
+ * If true and no final message is sent, the run fails.
483
+ * @default true
484
+ */
485
+ requireFinal: z4.boolean().optional(),
486
+ /**
487
+ * Whether the agent can schedule messages for future delivery.
488
+ * Scheduled messages typically require approval.
489
+ * @default false
490
+ */
491
+ allowSchedule: z4.boolean().optional(),
492
+ /**
493
+ * Message splitting configuration.
494
+ * Controls whether and how the agent splits responses into multiple messages.
495
+ */
496
+ messageSplitting: z4.object({
497
+ /**
498
+ * Whether to allow natural message splitting.
499
+ * When true, the agent may split responses into multiple messages
500
+ * when it improves conversational flow.
501
+ */
502
+ enabled: z4.boolean(),
503
+ /**
504
+ * Custom prompt to override the default message splitting guidance.
505
+ * If not provided, uses sensible defaults for when to split vs. keep together.
506
+ */
507
+ prompt: z4.string().optional()
423
508
  }).optional()
424
509
  });
510
+ var SchedulingDelaySchema = z4.object({
511
+ /** Time unit amount */
512
+ amount: z4.number(),
513
+ /** Time unit (e.g., "week", "weeks", "day", "days", "month", "months") */
514
+ unit: z4.string(),
515
+ /** Optional time window to constrain the delay */
516
+ timeWindow: z4.string().optional()
517
+ });
518
+ var SchedulingPatternSchema = z4.object({
519
+ /** Trigger name for this pattern */
520
+ trigger: z4.string(),
521
+ /** Human-readable description of when this pattern applies */
522
+ description: z4.string().optional(),
523
+ /** Example user phrases that match this pattern */
524
+ examples: z4.array(z4.string()).optional(),
525
+ /** Default delay for this pattern */
526
+ defaultDelay: SchedulingDelaySchema.optional()
527
+ });
528
+ var SchedulingBehaviorConfigSchema = z4.object({
529
+ /**
530
+ * Patterns that trigger scheduling suggestions.
531
+ * The agent uses these to know when to add sendAt to messages.
532
+ */
533
+ patterns: z4.array(SchedulingPatternSchema).optional(),
534
+ /**
535
+ * Default settings for scheduled messages.
536
+ */
537
+ defaults: z4.object({
538
+ /** Cancel scheduled message if user replies before send time (default: true) */
539
+ cancelOnActivity: z4.boolean().optional(),
540
+ /** Whether scheduled messages require approval (default: true) */
541
+ requiresApproval: z4.boolean().optional(),
542
+ /** Default time window policy to constrain all scheduled messages */
543
+ timeWindow: z4.string().optional().describe("Time window policy name for scheduled messages")
544
+ }).optional()
545
+ });
546
+ var BehaviorConfigV3Schema = z4.object({
547
+ /**
548
+ * Response behavior - controls message sending via tool calls.
549
+ * When configured, agents must explicitly call system:message:send
550
+ * instead of producing implicit final output.
551
+ */
552
+ responses: ResponsesBehaviorConfigSchema.optional(),
553
+ /**
554
+ * Scheduling behavior - controls when the agent schedules follow-up messages.
555
+ * Patterns define triggers like "user indicates they'll return later".
556
+ */
557
+ scheduling: SchedulingBehaviorConfigSchema.optional()
558
+ });
425
559
  var PromptsConfigV3Schema = z4.object({
560
+ /** Main system prompt with workflow instructions */
561
+ system: z4.string().optional(),
562
+ /** Injected during second pass when skills were loaded but tools not used */
426
563
  recovery: z4.string().optional(),
564
+ /** Injected during follow-up passes when context needs updating */
427
565
  followUp: z4.string().optional(),
428
- skillDiscoveryWorkflow: z4.string().optional()
566
+ /** Thread list title generation (system + user template with {{var}} placeholders) */
567
+ titleEnrichment: z4.object({
568
+ system: z4.string().optional(),
569
+ user: z4.string().optional()
570
+ }).optional()
429
571
  });
430
- var AgentConfigV3Schema = z4.record(z4.string(), z4.unknown());
431
572
  var AgentYAMLV3Schema = z4.object({
432
573
  $schema: z4.string().optional(),
433
574
  handle: z4.string(),
@@ -438,28 +579,36 @@ var AgentYAMLV3Schema = z4.object({
438
579
  persona: PersonaV3Schema.optional(),
439
580
  // Skills - What the agent knows how to do (skills own their tools)
440
581
  skills: z4.array(SkillRefSchema).optional(),
441
- // Bootstrap tools - Always-available system tools before any skill loads
442
- // Examples: system:skill:load, system:message:send
443
- bootstrapTools: z4.array(BootstrapToolRefSchema).optional(),
444
- // Tools - DEPRECATED: Use skills to own tools instead
445
- // Kept for backward compatibility during migration
446
- // @deprecated Will be removed in a future version
447
- tools: z4.array(ToolRefV3Schema).optional(),
448
- // Events - When the agent activates
582
+ // Tools - Always-available tools before any skill loads
583
+ // Examples: system:settings:business_information:get
584
+ tools: z4.array(AgentToolRefSchema).optional(),
585
+ /**
586
+ * Events - When the agent activates
587
+ * @deprecated Not yet implemented - this is a planned feature for event-driven agents.
588
+ * Fields are accepted but not used at runtime.
589
+ */
449
590
  events: EventsConfigSchema.optional(),
450
- // Memory - How the agent remembers
591
+ /**
592
+ * Memory - How the agent remembers
593
+ * @deprecated Not yet implemented - this is a planned feature.
594
+ * Fields are accepted but not used at runtime.
595
+ */
451
596
  memory: MemoryConfigV3Schema.optional(),
452
- // Policies - Constraints and approvals
597
+ // Policies - Business rules for the agent
453
598
  policies: PoliciesConfigV3Schema.optional(),
454
- // Runtime - Execution configuration
599
+ // Runtime - Execution configuration (only model is used)
455
600
  runtime: RuntimeConfigV3Schema.optional(),
456
- // Prompts - Agent-specific prompt injections for runtime phases
457
- // recovery: Injected during second pass when skills were loaded but tools not used
458
- // followUp: Injected during follow-up passes when context needs updating
459
- // skillDiscoveryWorkflow: Custom workflow instructions for skill discovery
601
+ // Prompts - Agent-specific prompt injections
460
602
  prompts: PromptsConfigV3Schema.optional(),
461
- // Config - Business-specific settings
462
- config: AgentConfigV3Schema.optional(),
603
+ // Behavior - Agent runtime behavior configuration
604
+ // responses: Controls message sending via explicit tool calls
605
+ behavior: BehaviorConfigV3Schema.optional(),
606
+ // Time Windows - Named time window policies for scheduling constraints
607
+ // Windows must be mutually exclusive (non-overlapping)
608
+ // Each window can define its own behavior (response mode, prompt, etc.)
609
+ timeWindows: TimeWindowPoliciesSchema.optional(),
610
+ // Time Window Default - Fallback behavior when no window matches
611
+ timeWindowDefault: TimeWindowDefaultSchema.optional(),
463
612
  // Sandbox - Testing configuration
464
613
  sandbox: SandboxConfigSchema.optional()
465
614
  });
@@ -475,8 +624,9 @@ function validateAgentYAMLV3(agent) {
475
624
  }
476
625
  export {
477
626
  AGENT_SCHEMA_VERSION_V3,
478
- AgentConfigV3Schema,
627
+ AgentToolRefSchema,
479
628
  AgentYAMLV3Schema,
629
+ BehaviorConfigV3Schema,
480
630
  BootstrapToolRefSchema,
481
631
  ExternalMemoryConfigSchema,
482
632
  MemoryConfigV3Schema,
@@ -485,9 +635,20 @@ export {
485
635
  PersonaVoiceV3Schema,
486
636
  PoliciesConfigV3Schema,
487
637
  PromptsConfigV3Schema,
488
- ResponsePolicySchema,
638
+ ResponseModeSchema,
639
+ ResponsesBehaviorConfigSchema,
489
640
  RuntimeConfigV3Schema,
641
+ SchedulingBehaviorConfigSchema,
642
+ SchedulingDelaySchema,
643
+ SchedulingPatternSchema,
490
644
  SemanticMemoryConfigSchema,
645
+ TimeWindowBehaviorSchema,
646
+ TimeWindowDayOfWeekSchema,
647
+ TimeWindowDefaultSchema,
648
+ TimeWindowPoliciesSchema,
649
+ TimeWindowPolicySchema,
650
+ TimeWindowSlotAgentSchema,
651
+ TimeWindowTimeStampSchema,
491
652
  ToolApprovalConfigSchema,
492
653
  ToolRefV3Schema,
493
654
  ToolSandboxConfigSchema,