skedyul 1.7.26 → 1.7.28
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/README.md +1 -0
- package/dist/.build-stamp +1 -1
- package/dist/cli/api/apps.d.ts +123 -0
- package/dist/cli/api/context.d.ts +30 -0
- package/dist/cli/api/crm.d.ts +56 -0
- package/dist/cli/api/index.d.ts +11 -0
- package/dist/cli/api/index.js +802 -0
- package/dist/cli/api/workflows.d.ts +134 -0
- package/dist/cli/index.js +1174 -1312
- package/dist/config/app-config.d.ts +3 -2
- package/dist/config/schema-loader.d.ts +10 -1
- package/dist/config/types/app-event.d.ts +13 -0
- package/dist/config/types/entity.d.ts +11 -2
- package/dist/config/types/model.d.ts +9 -9
- package/dist/core/client.d.ts +11 -10
- package/dist/esm/index.mjs +40 -17
- package/dist/index.d.ts +2 -1
- package/dist/index.js +42 -17
- package/dist/schemas/crm-schema.d.ts +49 -0
- package/dist/schemas/index.d.ts +1 -1
- package/dist/schemas.d.ts +24 -2
- package/package.json +8 -2
package/dist/cli/index.js
CHANGED
|
@@ -1855,8 +1855,9 @@ var file = {
|
|
|
1855
1855
|
/**
|
|
1856
1856
|
* Upload file content and create a File record.
|
|
1857
1857
|
*
|
|
1858
|
-
* Files are
|
|
1858
|
+
* Files are stored privately under workplaces/{subdomain}/files/{timestamp}-{name}.
|
|
1859
1859
|
* Use file.getUrl() to generate a temporary download URL when needed.
|
|
1860
|
+
* The optional `path` argument is accepted for compatibility but ignored for the S3 key.
|
|
1860
1861
|
*
|
|
1861
1862
|
* @example
|
|
1862
1863
|
* ```ts
|
|
@@ -1867,14 +1868,6 @@ var file = {
|
|
|
1867
1868
|
* name: 'document.pdf',
|
|
1868
1869
|
* mimeType: 'application/pdf',
|
|
1869
1870
|
* })
|
|
1870
|
-
*
|
|
1871
|
-
* // Upload with a path prefix for organization
|
|
1872
|
-
* const { id } = await file.upload({
|
|
1873
|
-
* content: imageBuffer,
|
|
1874
|
-
* name: 'photo.jpg',
|
|
1875
|
-
* mimeType: 'image/jpeg',
|
|
1876
|
-
* path: 'attachments',
|
|
1877
|
-
* })
|
|
1878
1871
|
* ```
|
|
1879
1872
|
*/
|
|
1880
1873
|
async upload(params) {
|
|
@@ -2290,6 +2283,586 @@ Example: skedyul dev invoke ${toolName} --workplace ${linkedWorkplaces[0]}`);
|
|
|
2290
2283
|
var fs6 = __toESM(require("fs"));
|
|
2291
2284
|
var path6 = __toESM(require("path"));
|
|
2292
2285
|
init_utils();
|
|
2286
|
+
|
|
2287
|
+
// src/cli/api/context.ts
|
|
2288
|
+
function cliApi(ctx) {
|
|
2289
|
+
return {
|
|
2290
|
+
serverUrl: ctx.serverUrl,
|
|
2291
|
+
token: ctx.token
|
|
2292
|
+
};
|
|
2293
|
+
}
|
|
2294
|
+
async function getWorkplaceToken(ctx, workplaceSubdomain) {
|
|
2295
|
+
return callCliApi(cliApi(ctx), "/workplace-token", {
|
|
2296
|
+
workplaceSubdomain
|
|
2297
|
+
});
|
|
2298
|
+
}
|
|
2299
|
+
|
|
2300
|
+
// src/cli/api/crm.ts
|
|
2301
|
+
async function listModels(ctx, workplace) {
|
|
2302
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2303
|
+
const result = await callCliApi(
|
|
2304
|
+
cliApi(ctx),
|
|
2305
|
+
"/crm-models",
|
|
2306
|
+
void 0,
|
|
2307
|
+
{ method: "GET", query: { workplaceId: workplaceToken.workplaceId } }
|
|
2308
|
+
);
|
|
2309
|
+
if (!result.success) {
|
|
2310
|
+
throw new Error(result.error || "Failed to list models");
|
|
2311
|
+
}
|
|
2312
|
+
return result.models;
|
|
2313
|
+
}
|
|
2314
|
+
async function pullSchema(ctx, workplace) {
|
|
2315
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2316
|
+
const result = await callCliApi(
|
|
2317
|
+
cliApi(ctx),
|
|
2318
|
+
"/crm-schema",
|
|
2319
|
+
void 0,
|
|
2320
|
+
{ method: "GET", query: { workplaceId: workplaceToken.workplaceId } }
|
|
2321
|
+
);
|
|
2322
|
+
if (!result.success) {
|
|
2323
|
+
throw new Error(result.error || "Failed to pull schema");
|
|
2324
|
+
}
|
|
2325
|
+
return { schema: result.schema, workplaceName: result.workplaceName };
|
|
2326
|
+
}
|
|
2327
|
+
async function postSchema(ctx, workplace, schema, options) {
|
|
2328
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2329
|
+
return callCliApi(cliApi(ctx), "/crm-schema", {
|
|
2330
|
+
workplace,
|
|
2331
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2332
|
+
schema,
|
|
2333
|
+
dryRun: options.dryRun ?? false,
|
|
2334
|
+
autoApprove: options.autoApprove ?? false,
|
|
2335
|
+
schemaName: schema.name,
|
|
2336
|
+
schemaVersion: schema.version
|
|
2337
|
+
});
|
|
2338
|
+
}
|
|
2339
|
+
async function diffSchema(ctx, workplace, schema) {
|
|
2340
|
+
return postSchema(ctx, workplace, schema, { dryRun: true });
|
|
2341
|
+
}
|
|
2342
|
+
async function approveMigration(ctx, migrationId) {
|
|
2343
|
+
await callCliApi(cliApi(ctx), "/approve-migration", { migrationId });
|
|
2344
|
+
}
|
|
2345
|
+
async function pushSchema(ctx, workplace, schema, options = {}) {
|
|
2346
|
+
const result = await postSchema(ctx, workplace, schema, {
|
|
2347
|
+
dryRun: options.dryRun ?? false,
|
|
2348
|
+
autoApprove: options.autoApprove ?? false
|
|
2349
|
+
});
|
|
2350
|
+
if (!options.dryRun && options.autoApprove && result.requiresApproval && result.migrationId) {
|
|
2351
|
+
await approveMigration(ctx, result.migrationId);
|
|
2352
|
+
return {
|
|
2353
|
+
...result,
|
|
2354
|
+
requiresApproval: false
|
|
2355
|
+
};
|
|
2356
|
+
}
|
|
2357
|
+
return result;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
// src/cli/api/workflows.ts
|
|
2361
|
+
var import_yaml = require("yaml");
|
|
2362
|
+
|
|
2363
|
+
// src/workflows/types.ts
|
|
2364
|
+
var import_v44 = require("zod/v4");
|
|
2365
|
+
|
|
2366
|
+
// src/events/types.ts
|
|
2367
|
+
var import_v42 = require("zod/v4");
|
|
2368
|
+
var ThreadEventTypeSchema = import_v42.z.enum([
|
|
2369
|
+
// Message events
|
|
2370
|
+
"thread.message.received",
|
|
2371
|
+
"thread.message.sent",
|
|
2372
|
+
"thread.attachment.received",
|
|
2373
|
+
// Participant events
|
|
2374
|
+
"thread.participant.joined",
|
|
2375
|
+
"thread.participant.left",
|
|
2376
|
+
"thread.participant.mentioned",
|
|
2377
|
+
// Context events
|
|
2378
|
+
"thread.context.changed",
|
|
2379
|
+
"thread.status.changed",
|
|
2380
|
+
// Agent/Workflow events
|
|
2381
|
+
"thread.agent.delegated",
|
|
2382
|
+
"thread.agent.completed",
|
|
2383
|
+
"thread.workflow.triggered",
|
|
2384
|
+
"thread.workflow.completed",
|
|
2385
|
+
// Scheduled events
|
|
2386
|
+
"thread.follow_up.due",
|
|
2387
|
+
"thread.reminder.due",
|
|
2388
|
+
// Signal events
|
|
2389
|
+
"thread.signal.created"
|
|
2390
|
+
]);
|
|
2391
|
+
var CustomEventTypeSchema = import_v42.z.string().regex(/^custom\.[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/, {
|
|
2392
|
+
message: "Custom event type must match pattern: custom.{namespace}.{event}"
|
|
2393
|
+
});
|
|
2394
|
+
var EventTypeSchema = import_v42.z.union([ThreadEventTypeSchema, CustomEventTypeSchema]);
|
|
2395
|
+
var ParticipantKindSchema = import_v42.z.enum(["CONTACT", "MEMBER", "AGENT", "WORKFLOW"]);
|
|
2396
|
+
var BaseEventPayloadSchema = import_v42.z.object({
|
|
2397
|
+
threadId: import_v42.z.string(),
|
|
2398
|
+
workplaceId: import_v42.z.string(),
|
|
2399
|
+
timestamp: import_v42.z.string().datetime().optional()
|
|
2400
|
+
});
|
|
2401
|
+
var MessageEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
2402
|
+
message: import_v42.z.object({
|
|
2403
|
+
id: import_v42.z.string(),
|
|
2404
|
+
content: import_v42.z.string(),
|
|
2405
|
+
senderId: import_v42.z.string().optional()
|
|
2406
|
+
}),
|
|
2407
|
+
participant: import_v42.z.object({
|
|
2408
|
+
id: import_v42.z.string(),
|
|
2409
|
+
kind: ParticipantKindSchema,
|
|
2410
|
+
displayName: import_v42.z.string().optional()
|
|
2411
|
+
}).optional(),
|
|
2412
|
+
isFirstMessage: import_v42.z.boolean().optional(),
|
|
2413
|
+
messageCount: import_v42.z.number().optional()
|
|
2414
|
+
});
|
|
2415
|
+
var ParticipantEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
2416
|
+
participant: import_v42.z.object({
|
|
2417
|
+
id: import_v42.z.string(),
|
|
2418
|
+
kind: ParticipantKindSchema,
|
|
2419
|
+
displayName: import_v42.z.string().optional(),
|
|
2420
|
+
contactId: import_v42.z.string().optional(),
|
|
2421
|
+
memberId: import_v42.z.string().optional(),
|
|
2422
|
+
agentId: import_v42.z.string().optional(),
|
|
2423
|
+
workflowId: import_v42.z.string().optional()
|
|
2424
|
+
})
|
|
2425
|
+
});
|
|
2426
|
+
var ContextChangedPayloadSchema = BaseEventPayloadSchema.extend({
|
|
2427
|
+
context: import_v42.z.object({
|
|
2428
|
+
handle: import_v42.z.string(),
|
|
2429
|
+
model: import_v42.z.string(),
|
|
2430
|
+
instanceId: import_v42.z.string()
|
|
2431
|
+
}),
|
|
2432
|
+
change: import_v42.z.object({
|
|
2433
|
+
field: import_v42.z.string().optional(),
|
|
2434
|
+
oldValue: import_v42.z.unknown().optional(),
|
|
2435
|
+
newValue: import_v42.z.unknown().optional()
|
|
2436
|
+
}).optional()
|
|
2437
|
+
});
|
|
2438
|
+
var StatusChangedPayloadSchema = BaseEventPayloadSchema.extend({
|
|
2439
|
+
oldStatus: import_v42.z.string(),
|
|
2440
|
+
newStatus: import_v42.z.string()
|
|
2441
|
+
});
|
|
2442
|
+
var ScheduledEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
2443
|
+
scheduledEventId: import_v42.z.string(),
|
|
2444
|
+
reason: import_v42.z.string().optional(),
|
|
2445
|
+
context: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional()
|
|
2446
|
+
});
|
|
2447
|
+
var AgentWorkflowEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
2448
|
+
agentId: import_v42.z.string().optional(),
|
|
2449
|
+
workflowId: import_v42.z.string().optional(),
|
|
2450
|
+
workflowRunId: import_v42.z.string().optional(),
|
|
2451
|
+
outputs: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional(),
|
|
2452
|
+
error: import_v42.z.string().optional()
|
|
2453
|
+
});
|
|
2454
|
+
var CustomEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
2455
|
+
data: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()).optional()
|
|
2456
|
+
});
|
|
2457
|
+
var ThreadEventPayloadSchema = import_v42.z.union([
|
|
2458
|
+
MessageEventPayloadSchema,
|
|
2459
|
+
ParticipantEventPayloadSchema,
|
|
2460
|
+
ContextChangedPayloadSchema,
|
|
2461
|
+
StatusChangedPayloadSchema,
|
|
2462
|
+
ScheduledEventPayloadSchema,
|
|
2463
|
+
AgentWorkflowEventPayloadSchema,
|
|
2464
|
+
CustomEventPayloadSchema
|
|
2465
|
+
]);
|
|
2466
|
+
var ThreadEventSchema = import_v42.z.object({
|
|
2467
|
+
id: import_v42.z.string(),
|
|
2468
|
+
threadId: import_v42.z.string(),
|
|
2469
|
+
type: EventTypeSchema,
|
|
2470
|
+
payload: ThreadEventPayloadSchema,
|
|
2471
|
+
emittedBy: import_v42.z.string().optional(),
|
|
2472
|
+
createdAt: import_v42.z.string().datetime()
|
|
2473
|
+
});
|
|
2474
|
+
var CreateThreadEventInputSchema = import_v42.z.object({
|
|
2475
|
+
threadId: import_v42.z.string(),
|
|
2476
|
+
type: EventTypeSchema,
|
|
2477
|
+
payload: import_v42.z.record(import_v42.z.string(), import_v42.z.unknown()),
|
|
2478
|
+
emittedBy: import_v42.z.string().optional()
|
|
2479
|
+
});
|
|
2480
|
+
var EventSubscriptionSchema = import_v42.z.object({
|
|
2481
|
+
subscribes: import_v42.z.array(EventTypeSchema),
|
|
2482
|
+
condition: import_v42.z.string().optional(),
|
|
2483
|
+
cancels: import_v42.z.array(EventTypeSchema).optional(),
|
|
2484
|
+
cancelCondition: import_v42.z.string().optional()
|
|
2485
|
+
});
|
|
2486
|
+
var EventWaitSchema = import_v42.z.object({
|
|
2487
|
+
event: EventTypeSchema,
|
|
2488
|
+
timeout: import_v42.z.string().optional(),
|
|
2489
|
+
onTimeout: import_v42.z.string().optional()
|
|
2490
|
+
});
|
|
2491
|
+
var EventsConfigSchema = import_v42.z.object({
|
|
2492
|
+
subscribes: import_v42.z.array(EventTypeSchema).optional(),
|
|
2493
|
+
condition: import_v42.z.string().optional(),
|
|
2494
|
+
emits: import_v42.z.array(EventTypeSchema).optional(),
|
|
2495
|
+
waits: import_v42.z.array(EventWaitSchema).optional(),
|
|
2496
|
+
cancels: import_v42.z.array(EventTypeSchema).optional(),
|
|
2497
|
+
cancelCondition: import_v42.z.string().optional()
|
|
2498
|
+
});
|
|
2499
|
+
|
|
2500
|
+
// src/triggers/types.ts
|
|
2501
|
+
var import_v43 = require("zod/v4");
|
|
2502
|
+
var CRMDataSchema = import_v43.z.object({
|
|
2503
|
+
model: import_v43.z.string(),
|
|
2504
|
+
instanceId: import_v43.z.string(),
|
|
2505
|
+
data: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown())
|
|
2506
|
+
});
|
|
2507
|
+
var SenderContextSchema = import_v43.z.object({
|
|
2508
|
+
kind: ParticipantKindSchema,
|
|
2509
|
+
displayName: import_v43.z.string().optional(),
|
|
2510
|
+
crm: CRMDataSchema.optional()
|
|
2511
|
+
});
|
|
2512
|
+
var ThreadContextItemSchema = import_v43.z.object({
|
|
2513
|
+
handle: import_v43.z.string(),
|
|
2514
|
+
model: import_v43.z.string(),
|
|
2515
|
+
instanceId: import_v43.z.string(),
|
|
2516
|
+
data: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional()
|
|
2517
|
+
});
|
|
2518
|
+
var ParticipantContextSchema = import_v43.z.object({
|
|
2519
|
+
id: import_v43.z.string(),
|
|
2520
|
+
kind: ParticipantKindSchema,
|
|
2521
|
+
displayName: import_v43.z.string().optional(),
|
|
2522
|
+
contactId: import_v43.z.string().optional(),
|
|
2523
|
+
memberId: import_v43.z.string().optional(),
|
|
2524
|
+
agentId: import_v43.z.string().optional(),
|
|
2525
|
+
workflowId: import_v43.z.string().optional()
|
|
2526
|
+
});
|
|
2527
|
+
var TriggerContextSchema = import_v43.z.object({
|
|
2528
|
+
// The event that triggered this
|
|
2529
|
+
event: import_v43.z.object({
|
|
2530
|
+
type: EventTypeSchema,
|
|
2531
|
+
payload: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()),
|
|
2532
|
+
participant: ParticipantContextSchema.optional()
|
|
2533
|
+
}),
|
|
2534
|
+
// Thread information
|
|
2535
|
+
thread: import_v43.z.object({
|
|
2536
|
+
id: import_v43.z.string(),
|
|
2537
|
+
title: import_v43.z.string().optional(),
|
|
2538
|
+
status: import_v43.z.string().optional(),
|
|
2539
|
+
sender: SenderContextSchema.optional(),
|
|
2540
|
+
context: import_v43.z.record(import_v43.z.string(), CRMDataSchema).optional(),
|
|
2541
|
+
participants: import_v43.z.array(ParticipantContextSchema).optional()
|
|
2542
|
+
}),
|
|
2543
|
+
// Workplace info
|
|
2544
|
+
workplace: import_v43.z.object({
|
|
2545
|
+
id: import_v43.z.string(),
|
|
2546
|
+
name: import_v43.z.string().optional(),
|
|
2547
|
+
settings: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional()
|
|
2548
|
+
})
|
|
2549
|
+
});
|
|
2550
|
+
var InputMappingSchema = import_v43.z.record(import_v43.z.string(), import_v43.z.string());
|
|
2551
|
+
var EventConditionsSchema = import_v43.z.record(import_v43.z.string(), import_v43.z.string());
|
|
2552
|
+
var TriggerConfigSchema = import_v43.z.object({
|
|
2553
|
+
id: import_v43.z.string(),
|
|
2554
|
+
workflowId: import_v43.z.string(),
|
|
2555
|
+
workflowVersionId: import_v43.z.string().optional(),
|
|
2556
|
+
workplaceId: import_v43.z.string(),
|
|
2557
|
+
handle: import_v43.z.string(),
|
|
2558
|
+
// Input mappings: how to resolve workflow inputs from thread context
|
|
2559
|
+
inputMappings: InputMappingSchema.optional(),
|
|
2560
|
+
// Event conditions: additional workplace-specific conditions
|
|
2561
|
+
eventConditions: EventConditionsSchema.optional(),
|
|
2562
|
+
// Workplace-specific config overrides
|
|
2563
|
+
config: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
|
|
2564
|
+
// Trigger type and status
|
|
2565
|
+
type: import_v43.z.string().optional(),
|
|
2566
|
+
isEnabled: import_v43.z.boolean().optional()
|
|
2567
|
+
});
|
|
2568
|
+
var ResolvedTriggerSchema = import_v43.z.object({
|
|
2569
|
+
trigger: TriggerConfigSchema,
|
|
2570
|
+
workflow: import_v43.z.object({
|
|
2571
|
+
id: import_v43.z.string(),
|
|
2572
|
+
handle: import_v43.z.string(),
|
|
2573
|
+
name: import_v43.z.string().optional(),
|
|
2574
|
+
inputs: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()).optional(),
|
|
2575
|
+
events: import_v43.z.object({
|
|
2576
|
+
subscribes: import_v43.z.array(EventTypeSchema).optional(),
|
|
2577
|
+
condition: import_v43.z.string().optional()
|
|
2578
|
+
}).optional()
|
|
2579
|
+
}),
|
|
2580
|
+
inputs: import_v43.z.record(import_v43.z.string(), import_v43.z.unknown()),
|
|
2581
|
+
context: TriggerContextSchema
|
|
2582
|
+
});
|
|
2583
|
+
var WorkflowInputDefinitionSchema = import_v43.z.object({
|
|
2584
|
+
type: import_v43.z.string(),
|
|
2585
|
+
required: import_v43.z.boolean().optional(),
|
|
2586
|
+
description: import_v43.z.string().optional(),
|
|
2587
|
+
default: import_v43.z.unknown().optional()
|
|
2588
|
+
});
|
|
2589
|
+
var WorkflowInputSchemaSchema = import_v43.z.record(import_v43.z.string(), WorkflowInputDefinitionSchema);
|
|
2590
|
+
|
|
2591
|
+
// src/workflows/types.ts
|
|
2592
|
+
var WorkflowInputSchema = import_v44.z.object({
|
|
2593
|
+
type: import_v44.z.string(),
|
|
2594
|
+
required: import_v44.z.boolean().optional().default(false),
|
|
2595
|
+
description: import_v44.z.string().optional(),
|
|
2596
|
+
default: import_v44.z.unknown().optional()
|
|
2597
|
+
});
|
|
2598
|
+
var WorkflowStepInputSchema = import_v44.z.union([import_v44.z.string(), import_v44.z.number(), import_v44.z.boolean(), import_v44.z.record(import_v44.z.string(), import_v44.z.unknown())]);
|
|
2599
|
+
var WorkflowStepSchema = import_v44.z.object({
|
|
2600
|
+
// Service and command
|
|
2601
|
+
service: import_v44.z.string(),
|
|
2602
|
+
cmd: import_v44.z.string(),
|
|
2603
|
+
// Dependencies
|
|
2604
|
+
needs: import_v44.z.array(import_v44.z.string()).optional(),
|
|
2605
|
+
// Inputs (Liquid templates supported)
|
|
2606
|
+
inputs: import_v44.z.record(import_v44.z.string(), WorkflowStepInputSchema).optional(),
|
|
2607
|
+
// Conditional execution
|
|
2608
|
+
condition: import_v44.z.string().optional(),
|
|
2609
|
+
// Retry configuration
|
|
2610
|
+
retry: import_v44.z.object({
|
|
2611
|
+
attempts: import_v44.z.number().optional(),
|
|
2612
|
+
backoff: import_v44.z.enum(["linear", "exponential"]).optional()
|
|
2613
|
+
}).optional(),
|
|
2614
|
+
// Timeout
|
|
2615
|
+
timeout: import_v44.z.string().optional()
|
|
2616
|
+
});
|
|
2617
|
+
var WorkflowRuntimeSchema = import_v44.z.object({
|
|
2618
|
+
durable: import_v44.z.boolean().optional().default(true),
|
|
2619
|
+
timeout: import_v44.z.string().optional(),
|
|
2620
|
+
retry: import_v44.z.object({
|
|
2621
|
+
attempts: import_v44.z.number().optional(),
|
|
2622
|
+
backoff: import_v44.z.enum(["linear", "exponential"]).optional()
|
|
2623
|
+
}).optional()
|
|
2624
|
+
});
|
|
2625
|
+
var WorkflowYAMLSchema = import_v44.z.object({
|
|
2626
|
+
// Schema version
|
|
2627
|
+
$schema: import_v44.z.string().optional(),
|
|
2628
|
+
// Identity
|
|
2629
|
+
handle: import_v44.z.string(),
|
|
2630
|
+
name: import_v44.z.string(),
|
|
2631
|
+
version: import_v44.z.string().optional(),
|
|
2632
|
+
description: import_v44.z.string().optional(),
|
|
2633
|
+
// Inputs this workflow needs (portable, declared in YAML)
|
|
2634
|
+
inputs: import_v44.z.record(import_v44.z.string(), WorkflowInputSchema).optional(),
|
|
2635
|
+
// Event subscriptions and conditions
|
|
2636
|
+
events: EventsConfigSchema.optional(),
|
|
2637
|
+
// Deterministic steps
|
|
2638
|
+
steps: import_v44.z.record(import_v44.z.string(), WorkflowStepSchema),
|
|
2639
|
+
// Runtime configuration
|
|
2640
|
+
runtime: WorkflowRuntimeSchema.optional()
|
|
2641
|
+
});
|
|
2642
|
+
var WorkflowMetadataSchema = import_v44.z.object({
|
|
2643
|
+
handle: import_v44.z.string(),
|
|
2644
|
+
name: import_v44.z.string(),
|
|
2645
|
+
version: import_v44.z.string().optional(),
|
|
2646
|
+
description: import_v44.z.string().optional(),
|
|
2647
|
+
inputs: import_v44.z.record(import_v44.z.string(), WorkflowInputDefinitionSchema).optional(),
|
|
2648
|
+
events: EventsConfigSchema.optional()
|
|
2649
|
+
});
|
|
2650
|
+
var WorkflowExecutionStatusSchema = import_v44.z.enum([
|
|
2651
|
+
"PENDING",
|
|
2652
|
+
"RUNNING",
|
|
2653
|
+
"COMPLETED",
|
|
2654
|
+
"FAILED",
|
|
2655
|
+
"CANCELLED",
|
|
2656
|
+
"WAITING"
|
|
2657
|
+
]);
|
|
2658
|
+
var WorkflowExecutionResultSchema = import_v44.z.object({
|
|
2659
|
+
status: WorkflowExecutionStatusSchema,
|
|
2660
|
+
outputs: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).optional(),
|
|
2661
|
+
error: import_v44.z.string().optional(),
|
|
2662
|
+
startedAt: import_v44.z.string().datetime().optional(),
|
|
2663
|
+
completedAt: import_v44.z.string().datetime().optional(),
|
|
2664
|
+
cancelledAt: import_v44.z.string().datetime().optional(),
|
|
2665
|
+
cancelReason: import_v44.z.string().optional()
|
|
2666
|
+
});
|
|
2667
|
+
function validateWorkflowYAML(workflow) {
|
|
2668
|
+
const result = WorkflowYAMLSchema.safeParse(workflow);
|
|
2669
|
+
if (result.success) {
|
|
2670
|
+
return { success: true, data: result.data };
|
|
2671
|
+
}
|
|
2672
|
+
return { success: false, error: result.error };
|
|
2673
|
+
}
|
|
2674
|
+
|
|
2675
|
+
// src/cli/api/workflows.ts
|
|
2676
|
+
function hasPlatformWorkflowSteps(rawWorkflow) {
|
|
2677
|
+
if (!rawWorkflow || typeof rawWorkflow !== "object") {
|
|
2678
|
+
return false;
|
|
2679
|
+
}
|
|
2680
|
+
const steps = rawWorkflow.steps;
|
|
2681
|
+
if (!steps || typeof steps !== "object") {
|
|
2682
|
+
return false;
|
|
2683
|
+
}
|
|
2684
|
+
return Object.values(steps).some(
|
|
2685
|
+
(step) => step && typeof step === "object" && typeof step.type === "string"
|
|
2686
|
+
);
|
|
2687
|
+
}
|
|
2688
|
+
function validateWorkflowContent(yamlContent) {
|
|
2689
|
+
let rawWorkflow;
|
|
2690
|
+
try {
|
|
2691
|
+
rawWorkflow = (0, import_yaml.parse)(yamlContent);
|
|
2692
|
+
} catch (err) {
|
|
2693
|
+
throw new Error(`Failed to parse YAML: ${err instanceof Error ? err.message : String(err)}`);
|
|
2694
|
+
}
|
|
2695
|
+
const validation = validateWorkflowYAML(rawWorkflow);
|
|
2696
|
+
if (!validation.success) {
|
|
2697
|
+
if (!hasPlatformWorkflowSteps(rawWorkflow)) {
|
|
2698
|
+
const errorMessages = validation.error.issues.map((e) => ` - ${String(e.path.join(".")) || "(root)"}: ${e.message}`).join("\n");
|
|
2699
|
+
throw new Error(`Workflow validation failed:
|
|
2700
|
+
${errorMessages}`);
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
return { content: yamlContent };
|
|
2704
|
+
}
|
|
2705
|
+
async function listWorkflows(ctx, workplace) {
|
|
2706
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2707
|
+
const result = await callCliApi(cliApi(ctx), "/workflows", void 0, {
|
|
2708
|
+
method: "GET",
|
|
2709
|
+
query: { workplaceId: workplaceToken.workplaceId }
|
|
2710
|
+
});
|
|
2711
|
+
if (!result.success) {
|
|
2712
|
+
throw new Error(result.error || "Failed to list workflows");
|
|
2713
|
+
}
|
|
2714
|
+
return result.workflows;
|
|
2715
|
+
}
|
|
2716
|
+
async function getWorkflow(ctx, workplace, handle) {
|
|
2717
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2718
|
+
const result = await callCliApi(cliApi(ctx), "/workflows", void 0, {
|
|
2719
|
+
method: "GET",
|
|
2720
|
+
query: { workplaceId: workplaceToken.workplaceId, handle }
|
|
2721
|
+
});
|
|
2722
|
+
if (!result.success) {
|
|
2723
|
+
throw new Error(result.error || "Failed to get workflow");
|
|
2724
|
+
}
|
|
2725
|
+
return result.workflow;
|
|
2726
|
+
}
|
|
2727
|
+
async function listWorkflowVersions(ctx, workplace, handle) {
|
|
2728
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2729
|
+
const result = await callCliApi(cliApi(ctx), "/workflows", void 0, {
|
|
2730
|
+
method: "GET",
|
|
2731
|
+
query: {
|
|
2732
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2733
|
+
handle,
|
|
2734
|
+
action: "versions"
|
|
2735
|
+
}
|
|
2736
|
+
});
|
|
2737
|
+
if (!result.success) {
|
|
2738
|
+
throw new Error(result.error || "Failed to list versions");
|
|
2739
|
+
}
|
|
2740
|
+
return result.workflow.versions ?? [];
|
|
2741
|
+
}
|
|
2742
|
+
async function validateWorkflow(ctx, workplace, yamlContent) {
|
|
2743
|
+
validateWorkflowContent(yamlContent);
|
|
2744
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2745
|
+
return callCliApi(cliApi(ctx), "/workflows", {
|
|
2746
|
+
action: "validate",
|
|
2747
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2748
|
+
yamlContent
|
|
2749
|
+
});
|
|
2750
|
+
}
|
|
2751
|
+
async function deployWorkflow(ctx, workplace, yamlContent, options = {}) {
|
|
2752
|
+
validateWorkflowContent(yamlContent);
|
|
2753
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2754
|
+
return callCliApi(cliApi(ctx), "/workflows", {
|
|
2755
|
+
action: "deploy",
|
|
2756
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2757
|
+
yamlContent,
|
|
2758
|
+
publish: options.publish ?? true,
|
|
2759
|
+
versionLabel: options.versionLabel
|
|
2760
|
+
});
|
|
2761
|
+
}
|
|
2762
|
+
async function publishWorkflow(ctx, workplace, handle, version) {
|
|
2763
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2764
|
+
return callCliApi(cliApi(ctx), "/workflows", {
|
|
2765
|
+
action: "publish",
|
|
2766
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2767
|
+
handle,
|
|
2768
|
+
version
|
|
2769
|
+
});
|
|
2770
|
+
}
|
|
2771
|
+
async function pullWorkflow(ctx, workplace, handle, version) {
|
|
2772
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2773
|
+
return callCliApi(cliApi(ctx), "/workflows", void 0, {
|
|
2774
|
+
method: "GET",
|
|
2775
|
+
query: {
|
|
2776
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2777
|
+
handle,
|
|
2778
|
+
action: "pull",
|
|
2779
|
+
version: version !== void 0 ? String(version) : void 0
|
|
2780
|
+
}
|
|
2781
|
+
});
|
|
2782
|
+
}
|
|
2783
|
+
async function getWorkflowSchema(ctx, workplace, handle, version) {
|
|
2784
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2785
|
+
return callCliApi(cliApi(ctx), "/workflow-schema", void 0, {
|
|
2786
|
+
method: "GET",
|
|
2787
|
+
query: {
|
|
2788
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2789
|
+
handle,
|
|
2790
|
+
version: version !== void 0 ? String(version) : void 0
|
|
2791
|
+
}
|
|
2792
|
+
});
|
|
2793
|
+
}
|
|
2794
|
+
async function runWorkflow(ctx, workplace, handle, options = {}) {
|
|
2795
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2796
|
+
return callCliApi(cliApi(ctx), "/workflows/run", {
|
|
2797
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2798
|
+
handle,
|
|
2799
|
+
version: options.version,
|
|
2800
|
+
inputs: options.inputs ?? {}
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
async function getWorkflowRun(ctx, workplace, workflowRunId) {
|
|
2804
|
+
const workplaceToken = await getWorkplaceToken(ctx, workplace);
|
|
2805
|
+
return callCliApi(cliApi(ctx), "/workflows/run", void 0, {
|
|
2806
|
+
method: "GET",
|
|
2807
|
+
query: {
|
|
2808
|
+
workplaceId: workplaceToken.workplaceId,
|
|
2809
|
+
workflowRunId
|
|
2810
|
+
}
|
|
2811
|
+
});
|
|
2812
|
+
}
|
|
2813
|
+
|
|
2814
|
+
// src/cli/api/apps.ts
|
|
2815
|
+
async function linkApp(ctx, input) {
|
|
2816
|
+
return callCliApi(cliApi(ctx), "/link", {
|
|
2817
|
+
appHandle: input.appHandle,
|
|
2818
|
+
workplaceSubdomain: input.workplaceSubdomain
|
|
2819
|
+
});
|
|
2820
|
+
}
|
|
2821
|
+
async function registerEndpoint(ctx, input) {
|
|
2822
|
+
return callCliApi(cliApi(ctx), "/register-endpoint", {
|
|
2823
|
+
appVersionId: input.appVersionId,
|
|
2824
|
+
invokeEndpoint: input.invokeEndpoint,
|
|
2825
|
+
config: input.config
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
async function unregisterEndpoint(ctx, input) {
|
|
2829
|
+
return callCliApi(cliApi(ctx), "/unregister-endpoint", {
|
|
2830
|
+
appVersionId: input.appVersionId
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
async function heartbeat(ctx, input) {
|
|
2834
|
+
return callCliApi(cliApi(ctx), "/heartbeat", {
|
|
2835
|
+
appVersionId: input.appVersionId,
|
|
2836
|
+
config: input.config
|
|
2837
|
+
});
|
|
2838
|
+
}
|
|
2839
|
+
async function installApp(ctx, input) {
|
|
2840
|
+
return callCliApi(cliApi(ctx), "/install", {
|
|
2841
|
+
appVersionId: input.appVersionId,
|
|
2842
|
+
env: input.env
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
async function uninstallApp(ctx, input) {
|
|
2846
|
+
return callCliApi(cliApi(ctx), "/uninstall", {
|
|
2847
|
+
appInstallationId: input.appInstallationId,
|
|
2848
|
+
deleteFields: input.deleteFields
|
|
2849
|
+
});
|
|
2850
|
+
}
|
|
2851
|
+
async function getInstallation(ctx, input) {
|
|
2852
|
+
return callCliApi(cliApi(ctx), "/installation", {
|
|
2853
|
+
appVersionId: input.appVersionId
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
async function invokeTool(ctx, input) {
|
|
2857
|
+
return callCliApi(cliApi(ctx), "/invoke-tool", {
|
|
2858
|
+
appInstallationId: input.appInstallationId,
|
|
2859
|
+
toolName: input.toolName,
|
|
2860
|
+
args: input.args ?? {},
|
|
2861
|
+
timeout: input.timeout
|
|
2862
|
+
});
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
// src/cli/commands/invoke-remote.ts
|
|
2293
2866
|
function getMimeType2(filePath) {
|
|
2294
2867
|
const ext = path6.extname(filePath).toLowerCase();
|
|
2295
2868
|
const mimeTypes = {
|
|
@@ -2407,42 +2980,7 @@ async function processUploadTemplates2(args2, serverUrl, token, appInstallationI
|
|
|
2407
2980
|
result[key] = value;
|
|
2408
2981
|
}
|
|
2409
2982
|
}
|
|
2410
|
-
return result;
|
|
2411
|
-
}
|
|
2412
|
-
async function callInvokeApi(serverUrl, token, body) {
|
|
2413
|
-
const url = `${serverUrl}/api/cli/invoke-tool`;
|
|
2414
|
-
const response = await fetch(url, {
|
|
2415
|
-
method: "POST",
|
|
2416
|
-
headers: {
|
|
2417
|
-
"Content-Type": "application/json",
|
|
2418
|
-
"Authorization": `Bearer ${token}`
|
|
2419
|
-
},
|
|
2420
|
-
body: JSON.stringify(body)
|
|
2421
|
-
});
|
|
2422
|
-
const text = await response.text();
|
|
2423
|
-
let json;
|
|
2424
|
-
try {
|
|
2425
|
-
json = JSON.parse(text);
|
|
2426
|
-
} catch {
|
|
2427
|
-
if (text.startsWith("<!DOCTYPE") || text.startsWith("<html")) {
|
|
2428
|
-
throw new Error(
|
|
2429
|
-
`Server returned HTML instead of JSON (status ${response.status}). This usually means the API endpoint doesn't exist or there's a server error.`
|
|
2430
|
-
);
|
|
2431
|
-
}
|
|
2432
|
-
throw new Error(`Invalid response from server: ${text.substring(0, 200)}`);
|
|
2433
|
-
}
|
|
2434
|
-
if (!response.ok) {
|
|
2435
|
-
const errorResponse = json;
|
|
2436
|
-
let errorMessage = errorResponse.error ?? `API error: ${response.status}`;
|
|
2437
|
-
if (errorResponse.availableTools && errorResponse.availableTools.length > 0) {
|
|
2438
|
-
errorMessage += `
|
|
2439
|
-
|
|
2440
|
-
Available tools:
|
|
2441
|
-
${errorResponse.availableTools.map((t) => ` - ${t}`).join("\n")}`;
|
|
2442
|
-
}
|
|
2443
|
-
throw new Error(errorMessage);
|
|
2444
|
-
}
|
|
2445
|
-
return json;
|
|
2983
|
+
return result;
|
|
2446
2984
|
}
|
|
2447
2985
|
function printHelp2() {
|
|
2448
2986
|
console.log(`
|
|
@@ -2556,9 +3094,8 @@ async function invokeRemoteCommand(args2) {
|
|
|
2556
3094
|
credentials.token,
|
|
2557
3095
|
appInstallationId
|
|
2558
3096
|
);
|
|
2559
|
-
const response = await
|
|
2560
|
-
serverUrl,
|
|
2561
|
-
credentials.token,
|
|
3097
|
+
const response = await invokeTool(
|
|
3098
|
+
{ serverUrl, token: credentials.token },
|
|
2562
3099
|
{
|
|
2563
3100
|
appInstallationId,
|
|
2564
3101
|
toolName,
|
|
@@ -2579,7 +3116,7 @@ async function invokeRemoteCommand(args2) {
|
|
|
2579
3116
|
}
|
|
2580
3117
|
|
|
2581
3118
|
// src/cli/commands/tools.ts
|
|
2582
|
-
var
|
|
3119
|
+
var z6 = __toESM(require("zod"));
|
|
2583
3120
|
init_utils();
|
|
2584
3121
|
function printHelp3() {
|
|
2585
3122
|
console.log(`
|
|
@@ -2613,7 +3150,7 @@ Examples:
|
|
|
2613
3150
|
skedyul tools sync --workplace gym-demo --model prospect
|
|
2614
3151
|
`);
|
|
2615
3152
|
}
|
|
2616
|
-
async function
|
|
3153
|
+
async function getWorkplaceToken2(workplaceSubdomain, serverUrl, cliToken) {
|
|
2617
3154
|
return callCliApi(
|
|
2618
3155
|
{ serverUrl, token: cliToken },
|
|
2619
3156
|
"/workplace-token",
|
|
@@ -2631,12 +3168,12 @@ function ensureAuth() {
|
|
|
2631
3168
|
}
|
|
2632
3169
|
function getZodSchema2(schema) {
|
|
2633
3170
|
if (!schema) return void 0;
|
|
2634
|
-
if (schema instanceof
|
|
3171
|
+
if (schema instanceof z6.ZodType) {
|
|
2635
3172
|
return schema;
|
|
2636
3173
|
}
|
|
2637
3174
|
if (typeof schema === "object" && schema !== null && "zod" in schema) {
|
|
2638
3175
|
const schemaWithZod = schema;
|
|
2639
|
-
if (schemaWithZod.zod instanceof
|
|
3176
|
+
if (schemaWithZod.zod instanceof z6.ZodType) {
|
|
2640
3177
|
return schemaWithZod.zod;
|
|
2641
3178
|
}
|
|
2642
3179
|
}
|
|
@@ -2645,7 +3182,7 @@ function getZodSchema2(schema) {
|
|
|
2645
3182
|
function toJsonSchema(schema) {
|
|
2646
3183
|
if (!schema) return void 0;
|
|
2647
3184
|
try {
|
|
2648
|
-
return
|
|
3185
|
+
return z6.toJSONSchema(schema, {
|
|
2649
3186
|
unrepresentable: "any"
|
|
2650
3187
|
});
|
|
2651
3188
|
} catch {
|
|
@@ -2715,7 +3252,7 @@ async function handleSync(args2) {
|
|
|
2715
3252
|
const { token, serverUrl } = ensureAuth();
|
|
2716
3253
|
let workplaceToken;
|
|
2717
3254
|
try {
|
|
2718
|
-
workplaceToken = await
|
|
3255
|
+
workplaceToken = await getWorkplaceToken2(workplace, serverUrl, token);
|
|
2719
3256
|
} catch (error) {
|
|
2720
3257
|
if (jsonOutput) {
|
|
2721
3258
|
console.log(JSON.stringify({ error: `Failed to get workplace token: ${error instanceof Error ? error.message : String(error)}` }));
|
|
@@ -2803,7 +3340,7 @@ init_utils();
|
|
|
2803
3340
|
|
|
2804
3341
|
// src/server/index.ts
|
|
2805
3342
|
var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
2806
|
-
var
|
|
3343
|
+
var z8 = __toESM(require("zod"));
|
|
2807
3344
|
|
|
2808
3345
|
// src/core/service.ts
|
|
2809
3346
|
var CoreApiService = class {
|
|
@@ -2870,7 +3407,7 @@ function registerSequencerConfig(config) {
|
|
|
2870
3407
|
}
|
|
2871
3408
|
|
|
2872
3409
|
// src/server/utils/schema.ts
|
|
2873
|
-
var
|
|
3410
|
+
var z7 = __toESM(require("zod"));
|
|
2874
3411
|
function normalizeBilling(billing) {
|
|
2875
3412
|
if (!billing || typeof billing !== "object") {
|
|
2876
3413
|
return { credits: 0 };
|
|
@@ -2883,7 +3420,7 @@ function normalizeBilling(billing) {
|
|
|
2883
3420
|
function toJsonSchema2(schema) {
|
|
2884
3421
|
if (!schema) return void 0;
|
|
2885
3422
|
try {
|
|
2886
|
-
return
|
|
3423
|
+
return z7.toJSONSchema(schema, {
|
|
2887
3424
|
unrepresentable: "any"
|
|
2888
3425
|
// Handle z.date(), z.bigint() etc gracefully
|
|
2889
3426
|
});
|
|
@@ -2894,12 +3431,12 @@ function toJsonSchema2(schema) {
|
|
|
2894
3431
|
}
|
|
2895
3432
|
function isToolSchemaWithJson(schema) {
|
|
2896
3433
|
return Boolean(
|
|
2897
|
-
schema && typeof schema === "object" && "zod" in schema && schema.zod instanceof
|
|
3434
|
+
schema && typeof schema === "object" && "zod" in schema && schema.zod instanceof z7.ZodType
|
|
2898
3435
|
);
|
|
2899
3436
|
}
|
|
2900
3437
|
function getZodSchema3(schema) {
|
|
2901
3438
|
if (!schema) return void 0;
|
|
2902
|
-
if (schema instanceof
|
|
3439
|
+
if (schema instanceof z7.ZodType) {
|
|
2903
3440
|
return schema;
|
|
2904
3441
|
}
|
|
2905
3442
|
if (isToolSchemaWithJson(schema)) {
|
|
@@ -5265,12 +5802,12 @@ function createSkedyulServer(config) {
|
|
|
5265
5802
|
const toolDisplayName = tool.label || toolName;
|
|
5266
5803
|
const inputZodSchema = getZodSchema3(tool.inputSchema);
|
|
5267
5804
|
const outputZodSchema = getZodSchema3(tool.outputSchema);
|
|
5268
|
-
const wrappedInputSchema =
|
|
5269
|
-
inputs: inputZodSchema ??
|
|
5270
|
-
context:
|
|
5271
|
-
env:
|
|
5272
|
-
invocation:
|
|
5273
|
-
estimate:
|
|
5805
|
+
const wrappedInputSchema = z8.object({
|
|
5806
|
+
inputs: inputZodSchema ?? z8.record(z8.string(), z8.unknown()).optional(),
|
|
5807
|
+
context: z8.record(z8.string(), z8.unknown()).optional(),
|
|
5808
|
+
env: z8.record(z8.string(), z8.string()).optional(),
|
|
5809
|
+
invocation: z8.record(z8.string(), z8.unknown()).optional(),
|
|
5810
|
+
estimate: z8.boolean().optional()
|
|
5274
5811
|
}).passthrough();
|
|
5275
5812
|
mcpServer.registerTool(
|
|
5276
5813
|
toolName,
|
|
@@ -5706,7 +6243,7 @@ async function isNgrokAvailable() {
|
|
|
5706
6243
|
|
|
5707
6244
|
// src/cli/commands/serve.ts
|
|
5708
6245
|
var readline2 = __toESM(require("readline"));
|
|
5709
|
-
var
|
|
6246
|
+
var z9 = __toESM(require("zod"));
|
|
5710
6247
|
var net = __toESM(require("net"));
|
|
5711
6248
|
var SERVE_STATE_FILE = ".skedyul/serve.json";
|
|
5712
6249
|
function writeServeState(port, workplace) {
|
|
@@ -5809,9 +6346,8 @@ async function shouldRunInstallWorkflow(linkConfig, credentials) {
|
|
|
5809
6346
|
}
|
|
5810
6347
|
}
|
|
5811
6348
|
try {
|
|
5812
|
-
const result = await
|
|
6349
|
+
const result = await getInstallation(
|
|
5813
6350
|
{ serverUrl: linkConfig.serverUrl, token: credentials.token },
|
|
5814
|
-
"/installation",
|
|
5815
6351
|
{ appVersionId: linkConfig.appVersionId }
|
|
5816
6352
|
);
|
|
5817
6353
|
return result.status !== "INSTALLED";
|
|
@@ -5923,9 +6459,9 @@ Endpoints:
|
|
|
5923
6459
|
}
|
|
5924
6460
|
function safeInputSchemaToJson(schema) {
|
|
5925
6461
|
if (!schema) return void 0;
|
|
5926
|
-
if (schema instanceof
|
|
6462
|
+
if (schema instanceof z9.ZodType) {
|
|
5927
6463
|
try {
|
|
5928
|
-
return
|
|
6464
|
+
return z9.toJSONSchema(schema, { unrepresentable: "any" });
|
|
5929
6465
|
} catch {
|
|
5930
6466
|
return void 0;
|
|
5931
6467
|
}
|
|
@@ -6025,9 +6561,8 @@ async function serveCommand(args2) {
|
|
|
6025
6561
|
console.log(` App: ${appConfig.handle}`);
|
|
6026
6562
|
const serverUrl = getServerUrl();
|
|
6027
6563
|
try {
|
|
6028
|
-
const response = await
|
|
6564
|
+
const response = await linkApp(
|
|
6029
6565
|
{ serverUrl, token: credentials.token },
|
|
6030
|
-
"/link",
|
|
6031
6566
|
{
|
|
6032
6567
|
appHandle: appConfig.handle,
|
|
6033
6568
|
workplaceSubdomain
|
|
@@ -6197,28 +6732,16 @@ Starting ngrok tunnel...`);
|
|
|
6197
6732
|
console.log(`
|
|
6198
6733
|
Registering endpoint with Skedyul...`);
|
|
6199
6734
|
try {
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
|
-
|
|
6205
|
-
|
|
6206
|
-
|
|
6207
|
-
|
|
6208
|
-
|
|
6209
|
-
|
|
6210
|
-
"Authorization": `Bearer ${credentials.token}`
|
|
6211
|
-
},
|
|
6212
|
-
body: JSON.stringify(registerBody)
|
|
6213
|
-
});
|
|
6214
|
-
if (!registerResponse.ok) {
|
|
6215
|
-
const responseText = await registerResponse.text();
|
|
6216
|
-
console.error(`Failed to register endpoint (HTTP ${registerResponse.status}):`);
|
|
6217
|
-
console.error(` Response: ${responseText.substring(0, 500)}`);
|
|
6218
|
-
} else {
|
|
6219
|
-
console.log(` \u2713 Registered as invokeEndpoint for ${linkConfig.appVersionHandle}`);
|
|
6220
|
-
console.log(` \u2713 Synced ${toolCount} tools to Skedyul`);
|
|
6221
|
-
}
|
|
6735
|
+
await registerEndpoint(
|
|
6736
|
+
{ serverUrl: linkConfig.serverUrl, token: credentials.token },
|
|
6737
|
+
{
|
|
6738
|
+
appVersionId: linkConfig.appVersionId,
|
|
6739
|
+
invokeEndpoint,
|
|
6740
|
+
config: executableConfig
|
|
6741
|
+
}
|
|
6742
|
+
);
|
|
6743
|
+
console.log(` \u2713 Registered as invokeEndpoint for ${linkConfig.appVersionHandle}`);
|
|
6744
|
+
console.log(` \u2713 Synced ${toolCount} tools to Skedyul`);
|
|
6222
6745
|
} catch (error) {
|
|
6223
6746
|
console.error(`Failed to register endpoint: ${error instanceof Error ? error.message : String(error)}`);
|
|
6224
6747
|
}
|
|
@@ -6233,9 +6756,8 @@ Running installation workflow...`);
|
|
|
6233
6756
|
"install"
|
|
6234
6757
|
);
|
|
6235
6758
|
const installEnv = filterEnvForInstallWorkflow(installEnvFromDb, installConfig);
|
|
6236
|
-
await
|
|
6759
|
+
await installApp(
|
|
6237
6760
|
{ serverUrl: linkConfig.serverUrl, token: credentials.token },
|
|
6238
|
-
"/install",
|
|
6239
6761
|
{
|
|
6240
6762
|
appVersionId: linkConfig.appVersionId,
|
|
6241
6763
|
env: installEnv
|
|
@@ -6257,9 +6779,8 @@ Running installation workflow...`);
|
|
|
6257
6779
|
void 0,
|
|
6258
6780
|
webhookRegistry
|
|
6259
6781
|
);
|
|
6260
|
-
await
|
|
6782
|
+
await heartbeat(
|
|
6261
6783
|
{ serverUrl: linkConfig.serverUrl, token: credentials.token },
|
|
6262
|
-
"/heartbeat",
|
|
6263
6784
|
{
|
|
6264
6785
|
appVersionId: linkConfig.appVersionId,
|
|
6265
6786
|
config: freshConfig
|
|
@@ -6292,9 +6813,8 @@ ${"\u2501".repeat(60)}`);
|
|
|
6292
6813
|
clearInterval(heartbeatInterval);
|
|
6293
6814
|
}
|
|
6294
6815
|
try {
|
|
6295
|
-
await
|
|
6816
|
+
await unregisterEndpoint(
|
|
6296
6817
|
{ serverUrl: linkConfig.serverUrl, token: credentials.token },
|
|
6297
|
-
"/unregister-endpoint",
|
|
6298
6818
|
{ appVersionId: linkConfig.appVersionId }
|
|
6299
6819
|
);
|
|
6300
6820
|
console.log(" \u2713 Endpoint unregistered (installation preserved)");
|
|
@@ -6318,9 +6838,8 @@ To restart: skedyul dev serve --workplace ${workplaceSubdomain}`);
|
|
|
6318
6838
|
clearInterval(heartbeatInterval);
|
|
6319
6839
|
}
|
|
6320
6840
|
try {
|
|
6321
|
-
await
|
|
6841
|
+
await unregisterEndpoint(
|
|
6322
6842
|
{ serverUrl: linkConfig.serverUrl, token: credentials.token },
|
|
6323
|
-
"/unregister-endpoint",
|
|
6324
6843
|
{ appVersionId: linkConfig.appVersionId }
|
|
6325
6844
|
);
|
|
6326
6845
|
console.log(" \u2713 Endpoint unregistered");
|
|
@@ -6328,13 +6847,11 @@ To restart: skedyul dev serve --workplace ${workplaceSubdomain}`);
|
|
|
6328
6847
|
}
|
|
6329
6848
|
try {
|
|
6330
6849
|
console.log(" Running uninstall workflow...");
|
|
6331
|
-
await
|
|
6850
|
+
await uninstallApp(
|
|
6332
6851
|
{ serverUrl: linkConfig.serverUrl, token: credentials.token },
|
|
6333
|
-
"/uninstall",
|
|
6334
6852
|
{
|
|
6335
6853
|
appInstallationId: linkConfig.appInstallationId,
|
|
6336
6854
|
deleteFields: false
|
|
6337
|
-
// Preserve custom fields for re-install
|
|
6338
6855
|
}
|
|
6339
6856
|
);
|
|
6340
6857
|
console.log(" \u2713 Uninstall workflow started");
|
|
@@ -6404,8 +6921,8 @@ var path11 = __toESM(require("path"));
|
|
|
6404
6921
|
var os2 = __toESM(require("os"));
|
|
6405
6922
|
|
|
6406
6923
|
// src/schemas/crm-schema.ts
|
|
6407
|
-
var
|
|
6408
|
-
var CRMFieldTypeSchema =
|
|
6924
|
+
var import_v45 = require("zod/v4");
|
|
6925
|
+
var CRMFieldTypeSchema = import_v45.z.enum([
|
|
6409
6926
|
"string",
|
|
6410
6927
|
"long_string",
|
|
6411
6928
|
"number",
|
|
@@ -6417,132 +6934,148 @@ var CRMFieldTypeSchema = import_v42.z.enum([
|
|
|
6417
6934
|
"image",
|
|
6418
6935
|
"object"
|
|
6419
6936
|
]);
|
|
6420
|
-
var CRMFieldRequirementSchema =
|
|
6937
|
+
var CRMFieldRequirementSchema = import_v45.z.enum([
|
|
6421
6938
|
"optional",
|
|
6422
6939
|
"on_create",
|
|
6423
6940
|
"required"
|
|
6424
6941
|
]);
|
|
6425
|
-
var CRMFieldOptionSchema =
|
|
6426
|
-
label:
|
|
6427
|
-
value:
|
|
6428
|
-
color:
|
|
6942
|
+
var CRMFieldOptionSchema = import_v45.z.object({
|
|
6943
|
+
label: import_v45.z.string(),
|
|
6944
|
+
value: import_v45.z.string(),
|
|
6945
|
+
color: import_v45.z.string().optional()
|
|
6429
6946
|
});
|
|
6430
|
-
var CRMFieldDefinitionObjectSchema =
|
|
6431
|
-
options:
|
|
6432
|
-
limitChoices:
|
|
6433
|
-
minLength:
|
|
6434
|
-
maxLength:
|
|
6435
|
-
min:
|
|
6436
|
-
max:
|
|
6437
|
-
pattern:
|
|
6947
|
+
var CRMFieldDefinitionObjectSchema = import_v45.z.object({
|
|
6948
|
+
options: import_v45.z.array(CRMFieldOptionSchema).optional(),
|
|
6949
|
+
limitChoices: import_v45.z.number().optional(),
|
|
6950
|
+
minLength: import_v45.z.number().optional(),
|
|
6951
|
+
maxLength: import_v45.z.number().optional(),
|
|
6952
|
+
min: import_v45.z.number().optional(),
|
|
6953
|
+
max: import_v45.z.number().optional(),
|
|
6954
|
+
pattern: import_v45.z.string().optional()
|
|
6438
6955
|
});
|
|
6439
|
-
var CRMFieldDefinitionSchema =
|
|
6440
|
-
|
|
6956
|
+
var CRMFieldDefinitionSchema = import_v45.z.union([
|
|
6957
|
+
import_v45.z.string(),
|
|
6441
6958
|
CRMFieldDefinitionObjectSchema
|
|
6442
6959
|
]);
|
|
6443
|
-
var CRMFieldAppearanceSchemaZ =
|
|
6444
|
-
leftIcon:
|
|
6445
|
-
rightIcon:
|
|
6446
|
-
placeholder:
|
|
6447
|
-
helpText:
|
|
6960
|
+
var CRMFieldAppearanceSchemaZ = import_v45.z.object({
|
|
6961
|
+
leftIcon: import_v45.z.string().optional(),
|
|
6962
|
+
rightIcon: import_v45.z.string().optional(),
|
|
6963
|
+
placeholder: import_v45.z.string().optional(),
|
|
6964
|
+
helpText: import_v45.z.string().optional()
|
|
6965
|
+
});
|
|
6966
|
+
var CRMFieldAiMetaSchemaZ = import_v45.z.object({
|
|
6967
|
+
description: import_v45.z.string().optional(),
|
|
6968
|
+
mutability: import_v45.z.enum(["always", "restricted", "create_only", "immutable"]).optional()
|
|
6448
6969
|
});
|
|
6449
|
-
var CRMFieldSchemaZ =
|
|
6450
|
-
handle:
|
|
6451
|
-
label:
|
|
6970
|
+
var CRMFieldSchemaZ = import_v45.z.object({
|
|
6971
|
+
handle: import_v45.z.string().regex(/^[a-z][a-z0-9_]*$/, "Handle must be lowercase alphanumeric with underscores, starting with a letter"),
|
|
6972
|
+
label: import_v45.z.string().min(1, "Label is required"),
|
|
6452
6973
|
type: CRMFieldTypeSchema,
|
|
6453
6974
|
/** Field description - explains what the field is for (metadata, not UI) */
|
|
6454
|
-
description:
|
|
6975
|
+
description: import_v45.z.string().optional(),
|
|
6455
6976
|
/** Field appearance - UI presentation settings */
|
|
6456
6977
|
appearance: CRMFieldAppearanceSchemaZ.optional(),
|
|
6457
6978
|
requirement: CRMFieldRequirementSchema.optional(),
|
|
6458
|
-
unique:
|
|
6459
|
-
list:
|
|
6460
|
-
default:
|
|
6979
|
+
unique: import_v45.z.boolean().optional(),
|
|
6980
|
+
list: import_v45.z.boolean().optional(),
|
|
6981
|
+
default: import_v45.z.unknown().optional(),
|
|
6461
6982
|
definition: CRMFieldDefinitionSchema.optional(),
|
|
6983
|
+
/** AI metadata - description and mutability hints for agents */
|
|
6984
|
+
aiMeta: CRMFieldAiMetaSchemaZ.optional(),
|
|
6462
6985
|
/**
|
|
6463
6986
|
* Workplace-scoped field section handle (visualization helper).
|
|
6464
6987
|
* Find-or-create on apply; display name is derived from the handle on create.
|
|
6465
6988
|
*/
|
|
6466
|
-
section:
|
|
6989
|
+
section: import_v45.z.string().regex(/^[a-z][a-z0-9_-]*$/, "Section handle must be lowercase alphanumeric with underscores/hyphens, starting with a letter").optional()
|
|
6467
6990
|
});
|
|
6468
|
-
var CRMModelSchemaZ =
|
|
6469
|
-
handle:
|
|
6470
|
-
name:
|
|
6471
|
-
namePlural:
|
|
6472
|
-
labelTemplate:
|
|
6473
|
-
description:
|
|
6474
|
-
icon:
|
|
6475
|
-
fields:
|
|
6991
|
+
var CRMModelSchemaZ = import_v45.z.object({
|
|
6992
|
+
handle: import_v45.z.string().regex(/^[a-z][a-z0-9_]*$/, "Handle must be lowercase alphanumeric with underscores, starting with a letter"),
|
|
6993
|
+
name: import_v45.z.string().min(1, "Name is required"),
|
|
6994
|
+
namePlural: import_v45.z.string().optional(),
|
|
6995
|
+
labelTemplate: import_v45.z.string().optional(),
|
|
6996
|
+
description: import_v45.z.string().optional(),
|
|
6997
|
+
icon: import_v45.z.string().optional(),
|
|
6998
|
+
fields: import_v45.z.array(CRMFieldSchemaZ)
|
|
6476
6999
|
});
|
|
6477
|
-
var CRMCardinalitySchema =
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
7000
|
+
var CRMCardinalitySchema = import_v45.z.enum([
|
|
7001
|
+
"one_to_one",
|
|
7002
|
+
"one_to_many",
|
|
7003
|
+
"many_to_one",
|
|
7004
|
+
"many_to_many"
|
|
7005
|
+
]);
|
|
7006
|
+
var CRMOnDeleteSchema = import_v45.z.enum([
|
|
7007
|
+
"none",
|
|
7008
|
+
"cascade",
|
|
7009
|
+
"restrict",
|
|
7010
|
+
"set_null"
|
|
7011
|
+
]);
|
|
7012
|
+
var CRMRelationshipLinkSchema = import_v45.z.object({
|
|
7013
|
+
model: import_v45.z.string(),
|
|
7014
|
+
field: import_v45.z.string(),
|
|
7015
|
+
label: import_v45.z.string()
|
|
6483
7016
|
});
|
|
6484
|
-
var CRMRelationshipSchemaZ =
|
|
7017
|
+
var CRMRelationshipSchemaZ = import_v45.z.object({
|
|
6485
7018
|
source: CRMRelationshipLinkSchema,
|
|
6486
7019
|
target: CRMRelationshipLinkSchema,
|
|
6487
7020
|
cardinality: CRMCardinalitySchema,
|
|
6488
7021
|
onDelete: CRMOnDeleteSchema.optional()
|
|
6489
7022
|
});
|
|
6490
|
-
var CRMBlockTypeSchema =
|
|
7023
|
+
var CRMBlockTypeSchema = import_v45.z.enum([
|
|
6491
7024
|
"spreadsheet",
|
|
6492
7025
|
"form",
|
|
6493
7026
|
"card",
|
|
6494
7027
|
"metric",
|
|
6495
7028
|
"kanban"
|
|
6496
7029
|
]);
|
|
6497
|
-
var CRMBlockSchemaZ =
|
|
7030
|
+
var CRMBlockSchemaZ = import_v45.z.object({
|
|
6498
7031
|
type: CRMBlockTypeSchema,
|
|
6499
|
-
title:
|
|
6500
|
-
config:
|
|
6501
|
-
default:
|
|
7032
|
+
title: import_v45.z.string().optional(),
|
|
7033
|
+
config: import_v45.z.unknown().optional(),
|
|
7034
|
+
default: import_v45.z.boolean().optional()
|
|
6502
7035
|
});
|
|
6503
|
-
var CRMPageTypeSchema =
|
|
6504
|
-
var CRMPageSchemaZ =
|
|
6505
|
-
path:
|
|
7036
|
+
var CRMPageTypeSchema = import_v45.z.enum(["list", "instance"]);
|
|
7037
|
+
var CRMPageSchemaZ = import_v45.z.object({
|
|
7038
|
+
path: import_v45.z.string(),
|
|
6506
7039
|
type: CRMPageTypeSchema,
|
|
6507
|
-
title:
|
|
6508
|
-
icon:
|
|
6509
|
-
modelHandle:
|
|
6510
|
-
parentPath:
|
|
6511
|
-
isDefault:
|
|
6512
|
-
visibility:
|
|
6513
|
-
baseQuery:
|
|
6514
|
-
blocks:
|
|
7040
|
+
title: import_v45.z.string(),
|
|
7041
|
+
icon: import_v45.z.string().optional(),
|
|
7042
|
+
modelHandle: import_v45.z.string(),
|
|
7043
|
+
parentPath: import_v45.z.string().optional(),
|
|
7044
|
+
isDefault: import_v45.z.boolean().optional(),
|
|
7045
|
+
visibility: import_v45.z.enum(["team", "private"]).optional(),
|
|
7046
|
+
baseQuery: import_v45.z.unknown().optional(),
|
|
7047
|
+
blocks: import_v45.z.array(CRMBlockSchemaZ).optional()
|
|
6515
7048
|
});
|
|
6516
|
-
var CRMNavigationNodeBaseSchemaZ =
|
|
6517
|
-
label:
|
|
6518
|
-
icon:
|
|
6519
|
-
path:
|
|
6520
|
-
kind:
|
|
6521
|
-
sortIndex:
|
|
7049
|
+
var CRMNavigationNodeBaseSchemaZ = import_v45.z.object({
|
|
7050
|
+
label: import_v45.z.string(),
|
|
7051
|
+
icon: import_v45.z.string().optional(),
|
|
7052
|
+
path: import_v45.z.string().optional(),
|
|
7053
|
+
kind: import_v45.z.enum(["section", "group"]).optional(),
|
|
7054
|
+
sortIndex: import_v45.z.number().optional()
|
|
6522
7055
|
});
|
|
6523
|
-
var CRMNavigationItemSchemaZ =
|
|
7056
|
+
var CRMNavigationItemSchemaZ = import_v45.z.lazy(
|
|
6524
7057
|
() => CRMNavigationNodeBaseSchemaZ.extend({
|
|
6525
|
-
children:
|
|
7058
|
+
children: import_v45.z.array(CRMNavigationItemSchemaZ).optional()
|
|
6526
7059
|
})
|
|
6527
7060
|
);
|
|
6528
|
-
var CRMNavigationSchemaZ =
|
|
6529
|
-
sidebar:
|
|
7061
|
+
var CRMNavigationSchemaZ = import_v45.z.object({
|
|
7062
|
+
sidebar: import_v45.z.array(CRMNavigationItemSchemaZ).optional()
|
|
6530
7063
|
});
|
|
6531
|
-
var CRMSchemaZ =
|
|
7064
|
+
var CRMSchemaZ = import_v45.z.object({
|
|
6532
7065
|
/** Schema format version for future compatibility */
|
|
6533
|
-
$schema:
|
|
7066
|
+
$schema: import_v45.z.literal("https://skedyul.com/schemas/crm/v1").optional(),
|
|
6534
7067
|
/** Schema name for identification */
|
|
6535
|
-
name:
|
|
7068
|
+
name: import_v45.z.string().min(1, "Name is required"),
|
|
6536
7069
|
/** Optional description */
|
|
6537
|
-
description:
|
|
7070
|
+
description: import_v45.z.string().optional(),
|
|
6538
7071
|
/** Schema version (semver) */
|
|
6539
|
-
version:
|
|
7072
|
+
version: import_v45.z.string().optional(),
|
|
6540
7073
|
/** Model definitions */
|
|
6541
|
-
models:
|
|
7074
|
+
models: import_v45.z.array(CRMModelSchemaZ),
|
|
6542
7075
|
/** Relationship definitions */
|
|
6543
|
-
relationships:
|
|
7076
|
+
relationships: import_v45.z.array(CRMRelationshipSchemaZ).optional(),
|
|
6544
7077
|
/** Page definitions */
|
|
6545
|
-
pages:
|
|
7078
|
+
pages: import_v45.z.array(CRMPageSchemaZ).optional(),
|
|
6546
7079
|
/** Navigation definitions */
|
|
6547
7080
|
navigation: CRMNavigationSchemaZ.optional()
|
|
6548
7081
|
});
|
|
@@ -6642,149 +7175,6 @@ async function saveSchema(schema, outputPath, options = {}) {
|
|
|
6642
7175
|
const content = isTypeScript ? serializeSchemaToTypeScript(schema) : serializeSchemaToJson(schema, options);
|
|
6643
7176
|
fs11.writeFileSync(absolutePath, content, "utf-8");
|
|
6644
7177
|
}
|
|
6645
|
-
var FIELD_TYPE_MAP = {
|
|
6646
|
-
string: "STRING",
|
|
6647
|
-
long_string: "LONG_STRING",
|
|
6648
|
-
number: "NUMBER",
|
|
6649
|
-
boolean: "BOOLEAN",
|
|
6650
|
-
date: "DATE",
|
|
6651
|
-
datetime: "DATE_TIME",
|
|
6652
|
-
time: "TIME",
|
|
6653
|
-
file: "FILE",
|
|
6654
|
-
image: "IMAGE",
|
|
6655
|
-
object: "OBJECT"
|
|
6656
|
-
};
|
|
6657
|
-
var FIELD_REQUIREMENT_MAP = {
|
|
6658
|
-
optional: "OPTIONAL",
|
|
6659
|
-
on_create: "ON_CREATE",
|
|
6660
|
-
required: "REQUIRED"
|
|
6661
|
-
};
|
|
6662
|
-
var CARDINALITY_MAP = {
|
|
6663
|
-
one_to_one: "ONE_TO_ONE",
|
|
6664
|
-
one_to_many: "ONE_TO_MANY"
|
|
6665
|
-
};
|
|
6666
|
-
var ON_DELETE_MAP = {
|
|
6667
|
-
none: "NONE",
|
|
6668
|
-
cascade: "CASCADE",
|
|
6669
|
-
restrict: "RESTRICT"
|
|
6670
|
-
};
|
|
6671
|
-
var PAGE_TYPE_MAP = {
|
|
6672
|
-
list: "LIST",
|
|
6673
|
-
instance: "INSTANCE"
|
|
6674
|
-
};
|
|
6675
|
-
var BLOCK_TYPE_MAP = {
|
|
6676
|
-
spreadsheet: "SPREADSHEET",
|
|
6677
|
-
form: "FORM",
|
|
6678
|
-
card: "CARD",
|
|
6679
|
-
metric: "METRIC",
|
|
6680
|
-
kanban: "KANBAN"
|
|
6681
|
-
};
|
|
6682
|
-
function transformToBackendSchema(schema) {
|
|
6683
|
-
const fieldDefinitions = [];
|
|
6684
|
-
const models = schema.models.map((model) => {
|
|
6685
|
-
const fields = model.fields.map((field) => {
|
|
6686
|
-
let appearance;
|
|
6687
|
-
if (field.appearance) {
|
|
6688
|
-
appearance = {};
|
|
6689
|
-
if (field.appearance.leftIcon) appearance.leftIcon = field.appearance.leftIcon;
|
|
6690
|
-
if (field.appearance.rightIcon) appearance.rightIcon = field.appearance.rightIcon;
|
|
6691
|
-
if (field.appearance.placeholder) appearance.placeholder = field.appearance.placeholder;
|
|
6692
|
-
if (field.appearance.helpText) appearance.helpText = field.appearance.helpText;
|
|
6693
|
-
if (Object.keys(appearance).length === 0) appearance = void 0;
|
|
6694
|
-
}
|
|
6695
|
-
const backendField = {
|
|
6696
|
-
handle: field.handle,
|
|
6697
|
-
label: field.label,
|
|
6698
|
-
type: FIELD_TYPE_MAP[field.type] || field.type.toUpperCase(),
|
|
6699
|
-
description: field.description || void 0,
|
|
6700
|
-
appearance,
|
|
6701
|
-
isList: field.list,
|
|
6702
|
-
isUnique: field.unique,
|
|
6703
|
-
requirement: field.requirement ? FIELD_REQUIREMENT_MAP[field.requirement] : void 0
|
|
6704
|
-
};
|
|
6705
|
-
if (field.default !== void 0) {
|
|
6706
|
-
backendField.defaultValue = {
|
|
6707
|
-
value: Array.isArray(field.default) ? field.default : [field.default]
|
|
6708
|
-
};
|
|
6709
|
-
}
|
|
6710
|
-
if (field.definition) {
|
|
6711
|
-
if (typeof field.definition === "string") {
|
|
6712
|
-
backendField.definition = field.definition;
|
|
6713
|
-
} else if (field.definition.options && field.definition.options.length > 0) {
|
|
6714
|
-
const definitionHandle = `${model.handle}_${field.handle}`;
|
|
6715
|
-
backendField.definition = {
|
|
6716
|
-
type: FIELD_TYPE_MAP[field.type] || field.type.toUpperCase(),
|
|
6717
|
-
options: field.definition.options.map((opt) => ({
|
|
6718
|
-
value: opt.value,
|
|
6719
|
-
label: opt.label,
|
|
6720
|
-
color: opt.color || null
|
|
6721
|
-
})),
|
|
6722
|
-
limitChoices: field.definition.limitChoices
|
|
6723
|
-
};
|
|
6724
|
-
fieldDefinitions.push({
|
|
6725
|
-
handle: definitionHandle,
|
|
6726
|
-
type: FIELD_TYPE_MAP[field.type] || field.type.toUpperCase(),
|
|
6727
|
-
options: field.definition.options.map((opt) => ({
|
|
6728
|
-
value: opt.value,
|
|
6729
|
-
label: opt.label,
|
|
6730
|
-
color: opt.color || null
|
|
6731
|
-
}))
|
|
6732
|
-
});
|
|
6733
|
-
}
|
|
6734
|
-
}
|
|
6735
|
-
return backendField;
|
|
6736
|
-
});
|
|
6737
|
-
return {
|
|
6738
|
-
handle: model.handle,
|
|
6739
|
-
name: model.name,
|
|
6740
|
-
namePlural: model.namePlural,
|
|
6741
|
-
labelTemplate: model.labelTemplate || `{{ ${model.fields[0]?.handle || "id"} }}`,
|
|
6742
|
-
description: model.description,
|
|
6743
|
-
icon: model.icon,
|
|
6744
|
-
fields
|
|
6745
|
-
};
|
|
6746
|
-
});
|
|
6747
|
-
const relationships = (schema.relationships || []).map(
|
|
6748
|
-
(rel) => ({
|
|
6749
|
-
source: rel.source,
|
|
6750
|
-
target: rel.target,
|
|
6751
|
-
cardinality: CARDINALITY_MAP[rel.cardinality] || rel.cardinality.toUpperCase(),
|
|
6752
|
-
onDelete: rel.onDelete ? ON_DELETE_MAP[rel.onDelete] : void 0
|
|
6753
|
-
})
|
|
6754
|
-
);
|
|
6755
|
-
const pages = (schema.pages || []).map((page) => ({
|
|
6756
|
-
path: page.path,
|
|
6757
|
-
type: PAGE_TYPE_MAP[page.type] || page.type.toUpperCase(),
|
|
6758
|
-
title: page.title,
|
|
6759
|
-
icon: page.icon,
|
|
6760
|
-
modelHandle: page.modelHandle,
|
|
6761
|
-
parentPath: page.parentPath,
|
|
6762
|
-
baseQuery: page.baseQuery,
|
|
6763
|
-
blocks: page.blocks?.map((block) => ({
|
|
6764
|
-
type: BLOCK_TYPE_MAP[block.type] || block.type.toUpperCase(),
|
|
6765
|
-
title: block.title,
|
|
6766
|
-
config: block.config,
|
|
6767
|
-
default: block.default
|
|
6768
|
-
}))
|
|
6769
|
-
}));
|
|
6770
|
-
const navigation = schema.navigation ? {
|
|
6771
|
-
sidebar: schema.navigation.sidebar?.map((item) => ({
|
|
6772
|
-
label: item.label,
|
|
6773
|
-
icon: item.icon,
|
|
6774
|
-
path: item.path,
|
|
6775
|
-
kind: item.kind,
|
|
6776
|
-
sortIndex: item.sortIndex,
|
|
6777
|
-
children: item.children
|
|
6778
|
-
}))
|
|
6779
|
-
} : void 0;
|
|
6780
|
-
return {
|
|
6781
|
-
models,
|
|
6782
|
-
relationships,
|
|
6783
|
-
fieldDefinitions,
|
|
6784
|
-
pages,
|
|
6785
|
-
navigation
|
|
6786
|
-
};
|
|
6787
|
-
}
|
|
6788
7178
|
|
|
6789
7179
|
// src/config/resolver.ts
|
|
6790
7180
|
var fs12 = __toESM(require("fs"));
|
|
@@ -8459,9 +8849,8 @@ To re-link, first run 'skedyul dev unlink --workplace ${workplaceSubdomain}'`);
|
|
|
8459
8849
|
console.log(`
|
|
8460
8850
|
Linking to ${workplaceSubdomain}...`);
|
|
8461
8851
|
try {
|
|
8462
|
-
const response = await
|
|
8852
|
+
const response = await linkApp(
|
|
8463
8853
|
{ serverUrl, token: credentials.token },
|
|
8464
|
-
"/link",
|
|
8465
8854
|
{
|
|
8466
8855
|
appHandle: config.handle,
|
|
8467
8856
|
workplaceSubdomain
|
|
@@ -8827,7 +9216,7 @@ Examples:
|
|
|
8827
9216
|
skedyul instances upsert-many panel_result --workplace crux --file ./data.json --match-field vetnostics_id
|
|
8828
9217
|
`);
|
|
8829
9218
|
}
|
|
8830
|
-
async function
|
|
9219
|
+
async function getWorkplaceToken3(workplaceSubdomain, serverUrl, cliToken) {
|
|
8831
9220
|
return callCliApi(
|
|
8832
9221
|
{ serverUrl, token: cliToken },
|
|
8833
9222
|
"/workplace-token",
|
|
@@ -8858,7 +9247,7 @@ async function instancesCommand(args2) {
|
|
|
8858
9247
|
const serverUrl = getServerUrl();
|
|
8859
9248
|
let workplaceToken;
|
|
8860
9249
|
try {
|
|
8861
|
-
workplaceToken = await
|
|
9250
|
+
workplaceToken = await getWorkplaceToken3(
|
|
8862
9251
|
workplaceSubdomain,
|
|
8863
9252
|
serverUrl,
|
|
8864
9253
|
credentials.token
|
|
@@ -9527,13 +9916,6 @@ Examples:
|
|
|
9527
9916
|
skedyul crm push --schema ./gym.schema.ts --workplace gym-demo --yes
|
|
9528
9917
|
`);
|
|
9529
9918
|
}
|
|
9530
|
-
async function getWorkplaceToken3(workplaceSubdomain, serverUrl, cliToken) {
|
|
9531
|
-
return callCliApi(
|
|
9532
|
-
{ serverUrl, token: cliToken },
|
|
9533
|
-
"/workplace-token",
|
|
9534
|
-
{ workplaceSubdomain }
|
|
9535
|
-
);
|
|
9536
|
-
}
|
|
9537
9919
|
function ensureAuth2() {
|
|
9538
9920
|
const credentials = getCredentials();
|
|
9539
9921
|
if (!credentials?.token) {
|
|
@@ -9599,46 +9981,14 @@ async function handlePush(args2) {
|
|
|
9599
9981
|
}
|
|
9600
9982
|
process.exit(1);
|
|
9601
9983
|
}
|
|
9602
|
-
const
|
|
9603
|
-
let workplaceToken;
|
|
9604
|
-
try {
|
|
9605
|
-
workplaceToken = await getWorkplaceToken3(workplace, serverUrl, token);
|
|
9606
|
-
} catch (error) {
|
|
9607
|
-
if (jsonOutput) {
|
|
9608
|
-
console.log(JSON.stringify({ error: `Failed to get workplace token: ${error instanceof Error ? error.message : String(error)}` }));
|
|
9609
|
-
} else {
|
|
9610
|
-
console.error(`Error: Failed to get workplace token: ${error instanceof Error ? error.message : String(error)}`);
|
|
9611
|
-
}
|
|
9612
|
-
process.exit(1);
|
|
9613
|
-
}
|
|
9614
|
-
const backendSchema = transformToBackendSchema(schema);
|
|
9984
|
+
const ctx = ensureAuth2();
|
|
9615
9985
|
if (!jsonOutput && !dryRun) {
|
|
9616
9986
|
console.log("");
|
|
9617
9987
|
console.log(`\u{1F4E6} Pushing schema "${schema.name}" to ${workplace}`);
|
|
9618
9988
|
console.log("");
|
|
9619
9989
|
}
|
|
9620
9990
|
try {
|
|
9621
|
-
const
|
|
9622
|
-
method: "POST",
|
|
9623
|
-
headers: {
|
|
9624
|
-
"Content-Type": "application/json",
|
|
9625
|
-
Authorization: `Bearer ${token}`
|
|
9626
|
-
},
|
|
9627
|
-
body: JSON.stringify({
|
|
9628
|
-
workplace,
|
|
9629
|
-
workplaceId: workplaceToken.workplaceId,
|
|
9630
|
-
schema: backendSchema,
|
|
9631
|
-
dryRun,
|
|
9632
|
-
autoApprove,
|
|
9633
|
-
schemaName: schema.name,
|
|
9634
|
-
schemaVersion: schema.version
|
|
9635
|
-
})
|
|
9636
|
-
});
|
|
9637
|
-
if (!response.ok) {
|
|
9638
|
-
const errorData = await response.json().catch(() => ({}));
|
|
9639
|
-
throw new Error(errorData.error || `Request failed: ${response.statusText}`);
|
|
9640
|
-
}
|
|
9641
|
-
const result = await response.json();
|
|
9991
|
+
const result = dryRun ? await diffSchema(ctx, workplace, schema) : await pushSchema(ctx, workplace, schema, { autoApprove: false });
|
|
9642
9992
|
if (jsonOutput) {
|
|
9643
9993
|
console.log(JSON.stringify(result, null, 2));
|
|
9644
9994
|
return;
|
|
@@ -9666,17 +10016,10 @@ async function handlePush(args2) {
|
|
|
9666
10016
|
console.log("\u274C Operation cancelled");
|
|
9667
10017
|
process.exit(1);
|
|
9668
10018
|
}
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
headers: {
|
|
9672
|
-
"Content-Type": "application/json",
|
|
9673
|
-
Authorization: `Bearer ${token}`
|
|
9674
|
-
},
|
|
9675
|
-
body: JSON.stringify({ migrationId: result.migrationId })
|
|
9676
|
-
});
|
|
9677
|
-
if (!approvalResponse.ok) {
|
|
9678
|
-
throw new Error("Failed to approve migration");
|
|
10019
|
+
if (!result.migrationId) {
|
|
10020
|
+
throw new Error("Migration requires approval but no migrationId was returned");
|
|
9679
10021
|
}
|
|
10022
|
+
await approveMigration(ctx, result.migrationId);
|
|
9680
10023
|
console.log("");
|
|
9681
10024
|
console.log("\u2705 Migration approved and applied");
|
|
9682
10025
|
} else {
|
|
@@ -9712,34 +10055,9 @@ async function handlePull(args2) {
|
|
|
9712
10055
|
console.error("Usage: skedyul crm pull --workplace gym-demo --output ./current.schema.json");
|
|
9713
10056
|
process.exit(1);
|
|
9714
10057
|
}
|
|
9715
|
-
const
|
|
9716
|
-
let workplaceToken;
|
|
9717
|
-
try {
|
|
9718
|
-
workplaceToken = await getWorkplaceToken3(workplace, serverUrl, token);
|
|
9719
|
-
} catch (error) {
|
|
9720
|
-
if (jsonOutput) {
|
|
9721
|
-
console.log(JSON.stringify({ error: `Failed to get workplace token: ${error instanceof Error ? error.message : String(error)}` }));
|
|
9722
|
-
} else {
|
|
9723
|
-
console.error(`Error: Failed to get workplace token: ${error instanceof Error ? error.message : String(error)}`);
|
|
9724
|
-
}
|
|
9725
|
-
process.exit(1);
|
|
9726
|
-
}
|
|
10058
|
+
const ctx = ensureAuth2();
|
|
9727
10059
|
try {
|
|
9728
|
-
const
|
|
9729
|
-
method: "GET",
|
|
9730
|
-
headers: {
|
|
9731
|
-
Authorization: `Bearer ${token}`
|
|
9732
|
-
}
|
|
9733
|
-
});
|
|
9734
|
-
if (!response.ok) {
|
|
9735
|
-
const errorData = await response.json().catch(() => ({}));
|
|
9736
|
-
throw new Error(errorData.error || `Request failed: ${response.statusText}`);
|
|
9737
|
-
}
|
|
9738
|
-
const result = await response.json();
|
|
9739
|
-
if (!result.success) {
|
|
9740
|
-
throw new Error(result.error || "Failed to pull schema");
|
|
9741
|
-
}
|
|
9742
|
-
const schema = result.schema;
|
|
10060
|
+
const { schema } = await pullSchema(ctx, workplace);
|
|
9743
10061
|
if (outputPath) {
|
|
9744
10062
|
const isTypeScript = outputPath.endsWith(".ts") || format === "ts";
|
|
9745
10063
|
await saveSchema(schema, outputPath);
|
|
@@ -9785,46 +10103,22 @@ async function handleModels(args2) {
|
|
|
9785
10103
|
console.error("Usage: skedyul crm models --workplace gym-demo");
|
|
9786
10104
|
process.exit(1);
|
|
9787
10105
|
}
|
|
9788
|
-
const
|
|
9789
|
-
let workplaceToken;
|
|
9790
|
-
try {
|
|
9791
|
-
workplaceToken = await getWorkplaceToken3(workplace, serverUrl, token);
|
|
9792
|
-
} catch (error) {
|
|
9793
|
-
if (jsonOutput) {
|
|
9794
|
-
console.log(JSON.stringify({ error: `Failed to get workplace token: ${error instanceof Error ? error.message : String(error)}` }));
|
|
9795
|
-
} else {
|
|
9796
|
-
console.error(`Error: Failed to get workplace token: ${error instanceof Error ? error.message : String(error)}`);
|
|
9797
|
-
}
|
|
9798
|
-
process.exit(1);
|
|
9799
|
-
}
|
|
10106
|
+
const ctx = ensureAuth2();
|
|
9800
10107
|
try {
|
|
9801
|
-
const
|
|
9802
|
-
method: "GET",
|
|
9803
|
-
headers: {
|
|
9804
|
-
Authorization: `Bearer ${token}`
|
|
9805
|
-
}
|
|
9806
|
-
});
|
|
9807
|
-
if (!response.ok) {
|
|
9808
|
-
const errorData = await response.json().catch(() => ({}));
|
|
9809
|
-
throw new Error(errorData.error || `Request failed: ${response.statusText}`);
|
|
9810
|
-
}
|
|
9811
|
-
const result = await response.json();
|
|
9812
|
-
if (!result.success) {
|
|
9813
|
-
throw new Error(result.error || "Failed to list models");
|
|
9814
|
-
}
|
|
10108
|
+
const models = await listModels(ctx, workplace);
|
|
9815
10109
|
if (jsonOutput) {
|
|
9816
|
-
console.log(JSON.stringify(
|
|
10110
|
+
console.log(JSON.stringify(models, null, 2));
|
|
9817
10111
|
return;
|
|
9818
10112
|
}
|
|
9819
10113
|
console.log("");
|
|
9820
10114
|
console.log(`\u{1F4E6} Models in ${workplace}`);
|
|
9821
10115
|
console.log("");
|
|
9822
|
-
if (
|
|
10116
|
+
if (models.length === 0) {
|
|
9823
10117
|
console.log(" No models found.");
|
|
9824
10118
|
} else {
|
|
9825
10119
|
console.log(" Handle Label Fields Instances");
|
|
9826
10120
|
console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
9827
|
-
for (const model of
|
|
10121
|
+
for (const model of models) {
|
|
9828
10122
|
const handle = model.handle.padEnd(20);
|
|
9829
10123
|
const label = model.name.padEnd(22);
|
|
9830
10124
|
const fields = String(model.fieldCount).padStart(6);
|
|
@@ -9872,163 +10166,163 @@ async function crmCommand(args2) {
|
|
|
9872
10166
|
// src/cli/commands/agents.ts
|
|
9873
10167
|
var fs22 = __toESM(require("fs"));
|
|
9874
10168
|
var path22 = __toESM(require("path"));
|
|
9875
|
-
var
|
|
10169
|
+
var import_yaml2 = require("yaml");
|
|
9876
10170
|
init_utils();
|
|
9877
10171
|
|
|
9878
10172
|
// src/schemas/agent-schema.ts
|
|
9879
|
-
var
|
|
9880
|
-
var ToolReferenceInputZ =
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
tool:
|
|
9884
|
-
handle:
|
|
9885
|
-
name:
|
|
9886
|
-
description:
|
|
10173
|
+
var import_v46 = require("zod/v4");
|
|
10174
|
+
var ToolReferenceInputZ = import_v46.z.union([
|
|
10175
|
+
import_v46.z.string(),
|
|
10176
|
+
import_v46.z.object({
|
|
10177
|
+
tool: import_v46.z.string(),
|
|
10178
|
+
handle: import_v46.z.string().optional(),
|
|
10179
|
+
name: import_v46.z.string().optional(),
|
|
10180
|
+
description: import_v46.z.string().optional(),
|
|
9887
10181
|
/** Execution mode: ALLOW_ALL (default) or REQUIRE_APPROVAL */
|
|
9888
|
-
executionMode:
|
|
10182
|
+
executionMode: import_v46.z.enum(["ALLOW_ALL", "REQUIRE_APPROVAL"]).optional(),
|
|
9889
10183
|
/** Approval timeout in ms (default: 86400000 = 1 day) */
|
|
9890
|
-
approvalTimeoutMs:
|
|
10184
|
+
approvalTimeoutMs: import_v46.z.number().optional()
|
|
9891
10185
|
})
|
|
9892
10186
|
]);
|
|
9893
|
-
var ToolBindingZ =
|
|
9894
|
-
|
|
9895
|
-
kind:
|
|
9896
|
-
name:
|
|
9897
|
-
handle:
|
|
9898
|
-
displayName:
|
|
9899
|
-
description:
|
|
10187
|
+
var ToolBindingZ = import_v46.z.union([
|
|
10188
|
+
import_v46.z.object({
|
|
10189
|
+
kind: import_v46.z.literal("SYSTEM"),
|
|
10190
|
+
name: import_v46.z.string(),
|
|
10191
|
+
handle: import_v46.z.string().optional(),
|
|
10192
|
+
displayName: import_v46.z.string().optional(),
|
|
10193
|
+
description: import_v46.z.string().optional(),
|
|
9900
10194
|
/** Execution mode: ALLOW_ALL (default) or REQUIRE_APPROVAL */
|
|
9901
|
-
executionMode:
|
|
10195
|
+
executionMode: import_v46.z.enum(["ALLOW_ALL", "REQUIRE_APPROVAL"]).optional(),
|
|
9902
10196
|
/** Approval timeout in ms (default: 86400000 = 1 day) */
|
|
9903
|
-
approvalTimeoutMs:
|
|
10197
|
+
approvalTimeoutMs: import_v46.z.number().optional()
|
|
9904
10198
|
}),
|
|
9905
|
-
|
|
9906
|
-
kind:
|
|
9907
|
-
name:
|
|
9908
|
-
handle:
|
|
9909
|
-
displayName:
|
|
9910
|
-
description:
|
|
10199
|
+
import_v46.z.object({
|
|
10200
|
+
kind: import_v46.z.literal("AGENT"),
|
|
10201
|
+
name: import_v46.z.string(),
|
|
10202
|
+
handle: import_v46.z.string().optional(),
|
|
10203
|
+
displayName: import_v46.z.string().optional(),
|
|
10204
|
+
description: import_v46.z.string().optional(),
|
|
9911
10205
|
/** Execution mode: ALLOW_ALL (default) or REQUIRE_APPROVAL */
|
|
9912
|
-
executionMode:
|
|
10206
|
+
executionMode: import_v46.z.enum(["ALLOW_ALL", "REQUIRE_APPROVAL"]).optional(),
|
|
9913
10207
|
/** Approval timeout in ms (default: 86400000 = 1 day) */
|
|
9914
|
-
approvalTimeoutMs:
|
|
10208
|
+
approvalTimeoutMs: import_v46.z.number().optional()
|
|
9915
10209
|
}),
|
|
9916
|
-
|
|
9917
|
-
kind:
|
|
9918
|
-
server:
|
|
9919
|
-
tool:
|
|
9920
|
-
handle:
|
|
9921
|
-
displayName:
|
|
9922
|
-
description:
|
|
10210
|
+
import_v46.z.object({
|
|
10211
|
+
kind: import_v46.z.literal("MCP"),
|
|
10212
|
+
server: import_v46.z.string(),
|
|
10213
|
+
tool: import_v46.z.string(),
|
|
10214
|
+
handle: import_v46.z.string().optional(),
|
|
10215
|
+
displayName: import_v46.z.string().optional(),
|
|
10216
|
+
description: import_v46.z.string().optional(),
|
|
9923
10217
|
/** Execution mode: ALLOW_ALL (default) or REQUIRE_APPROVAL */
|
|
9924
|
-
executionMode:
|
|
10218
|
+
executionMode: import_v46.z.enum(["ALLOW_ALL", "REQUIRE_APPROVAL"]).optional(),
|
|
9925
10219
|
/** Approval timeout in ms (default: 86400000 = 1 day) */
|
|
9926
|
-
approvalTimeoutMs:
|
|
10220
|
+
approvalTimeoutMs: import_v46.z.number().optional()
|
|
9927
10221
|
})
|
|
9928
10222
|
]);
|
|
9929
|
-
var StageBaseZ =
|
|
10223
|
+
var StageBaseZ = import_v46.z.object({
|
|
9930
10224
|
/** Unique identifier for the stage */
|
|
9931
|
-
id:
|
|
10225
|
+
id: import_v46.z.string(),
|
|
9932
10226
|
/** Stage IDs that must complete before this stage runs */
|
|
9933
|
-
needs:
|
|
10227
|
+
needs: import_v46.z.array(import_v46.z.string()).optional(),
|
|
9934
10228
|
/** Liquid condition - stage is skipped if this evaluates to false */
|
|
9935
|
-
if:
|
|
10229
|
+
if: import_v46.z.string().optional()
|
|
9936
10230
|
});
|
|
9937
10231
|
var ToolStageZ = StageBaseZ.extend({
|
|
9938
|
-
type:
|
|
10232
|
+
type: import_v46.z.literal("tool"),
|
|
9939
10233
|
/** Tool identifier (e.g., 'system:crm:prospect:get', 'app:hubspot:create_contact') */
|
|
9940
|
-
resource:
|
|
10234
|
+
resource: import_v46.z.string(),
|
|
9941
10235
|
/** Input mappings - Liquid templates */
|
|
9942
|
-
inputs:
|
|
10236
|
+
inputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional(),
|
|
9943
10237
|
/** Output mappings - Liquid templates referencing {{ result.xxx }} */
|
|
9944
|
-
outputs:
|
|
10238
|
+
outputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional()
|
|
9945
10239
|
});
|
|
9946
|
-
var StageAgentDefinitionZ =
|
|
10240
|
+
var StageAgentDefinitionZ = import_v46.z.object({
|
|
9947
10241
|
/** Unique identifier for the agent (lowercase, alphanumeric with dashes/underscores) */
|
|
9948
|
-
handle:
|
|
10242
|
+
handle: import_v46.z.string().regex(/^[a-z][a-z0-9_-]*$/, "Handle must be lowercase alphanumeric with dashes/underscores, starting with a letter"),
|
|
9949
10243
|
/** Display name for the agent */
|
|
9950
|
-
name:
|
|
10244
|
+
name: import_v46.z.string().min(1, "Name is required"),
|
|
9951
10245
|
/** Description of what the agent does */
|
|
9952
|
-
description:
|
|
10246
|
+
description: import_v46.z.string().optional(),
|
|
9953
10247
|
/** System prompt that defines the agent behavior and tool selection logic */
|
|
9954
|
-
system:
|
|
10248
|
+
system: import_v46.z.string(),
|
|
9955
10249
|
/** Optional persona name for response generation (e.g., "Brett") */
|
|
9956
|
-
personaName:
|
|
10250
|
+
personaName: import_v46.z.string().optional(),
|
|
9957
10251
|
/** Optional persona prompt for two-phase response generation (tone, style, format rules) */
|
|
9958
|
-
persona:
|
|
10252
|
+
persona: import_v46.z.string().optional(),
|
|
9959
10253
|
/** LLM model ID (e.g., "openai/gpt-4o-mini"). Defaults to gpt-4o-mini */
|
|
9960
|
-
llmModelId:
|
|
10254
|
+
llmModelId: import_v46.z.string().optional(),
|
|
9961
10255
|
/** Array of tool references to bind to this agent */
|
|
9962
|
-
tools:
|
|
10256
|
+
tools: import_v46.z.array(import_v46.z.union([ToolReferenceInputZ, ToolBindingZ])).optional(),
|
|
9963
10257
|
/** JSON Schema for structured data output */
|
|
9964
|
-
outputSchema:
|
|
10258
|
+
outputSchema: import_v46.z.record(import_v46.z.string(), import_v46.z.unknown()).optional()
|
|
9965
10259
|
});
|
|
9966
10260
|
var AgentStageBaseZ = StageBaseZ.extend({
|
|
9967
|
-
type:
|
|
10261
|
+
type: import_v46.z.literal("agent"),
|
|
9968
10262
|
/** Inline agent definition via props (preferred - contains full agent config) */
|
|
9969
10263
|
props: StageAgentDefinitionZ.optional(),
|
|
9970
10264
|
/** External agent reference by handle (for referencing DB agents) */
|
|
9971
|
-
resource:
|
|
10265
|
+
resource: import_v46.z.string().optional(),
|
|
9972
10266
|
/** Prompt template - Liquid template for the user message */
|
|
9973
|
-
prompt:
|
|
10267
|
+
prompt: import_v46.z.string().optional(),
|
|
9974
10268
|
/** Input mappings - Liquid templates injected into agent context */
|
|
9975
|
-
inputs:
|
|
10269
|
+
inputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional(),
|
|
9976
10270
|
/** Output mappings - Liquid templates referencing {{ result.xxx }} */
|
|
9977
|
-
outputs:
|
|
10271
|
+
outputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional()
|
|
9978
10272
|
});
|
|
9979
10273
|
var AgentStageZ = AgentStageBaseZ.refine(
|
|
9980
10274
|
(data) => data.props || data.resource,
|
|
9981
10275
|
{ message: "Either 'props' (inline definition) or 'resource' (external reference) must be provided" }
|
|
9982
10276
|
);
|
|
9983
10277
|
var TransformStageZ = StageBaseZ.extend({
|
|
9984
|
-
type:
|
|
10278
|
+
type: import_v46.z.literal("transform"),
|
|
9985
10279
|
/** Output mappings - Liquid templates that compute values */
|
|
9986
|
-
outputs:
|
|
10280
|
+
outputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string())
|
|
9987
10281
|
});
|
|
9988
10282
|
var OutputStageZ = StageBaseZ.extend({
|
|
9989
|
-
type:
|
|
10283
|
+
type: import_v46.z.literal("output"),
|
|
9990
10284
|
/** Output mappings - Liquid templates for the final response */
|
|
9991
|
-
outputs:
|
|
10285
|
+
outputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string())
|
|
9992
10286
|
});
|
|
9993
|
-
var StageZ =
|
|
10287
|
+
var StageZ = import_v46.z.discriminatedUnion("type", [
|
|
9994
10288
|
ToolStageZ,
|
|
9995
10289
|
AgentStageBaseZ,
|
|
9996
10290
|
TransformStageZ,
|
|
9997
10291
|
OutputStageZ
|
|
9998
10292
|
]);
|
|
9999
|
-
var LegacyActivityStageZ =
|
|
10000
|
-
id:
|
|
10001
|
-
type:
|
|
10002
|
-
activity:
|
|
10003
|
-
inputs:
|
|
10004
|
-
outputs:
|
|
10293
|
+
var LegacyActivityStageZ = import_v46.z.object({
|
|
10294
|
+
id: import_v46.z.string(),
|
|
10295
|
+
type: import_v46.z.literal("activity"),
|
|
10296
|
+
activity: import_v46.z.string(),
|
|
10297
|
+
inputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional(),
|
|
10298
|
+
outputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional()
|
|
10005
10299
|
});
|
|
10006
|
-
var LegacyAgentStageZ =
|
|
10007
|
-
id:
|
|
10008
|
-
type:
|
|
10009
|
-
agent:
|
|
10010
|
-
prompt:
|
|
10011
|
-
inputs:
|
|
10012
|
-
outputs:
|
|
10300
|
+
var LegacyAgentStageZ = import_v46.z.object({
|
|
10301
|
+
id: import_v46.z.string(),
|
|
10302
|
+
type: import_v46.z.literal("agent"),
|
|
10303
|
+
agent: import_v46.z.string(),
|
|
10304
|
+
prompt: import_v46.z.string().optional(),
|
|
10305
|
+
inputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional(),
|
|
10306
|
+
outputs: import_v46.z.record(import_v46.z.string(), import_v46.z.string()).optional()
|
|
10013
10307
|
});
|
|
10014
|
-
var LegacyConditionalStageZ =
|
|
10015
|
-
id:
|
|
10016
|
-
type:
|
|
10017
|
-
condition:
|
|
10018
|
-
then:
|
|
10019
|
-
else:
|
|
10308
|
+
var LegacyConditionalStageZ = import_v46.z.object({
|
|
10309
|
+
id: import_v46.z.string(),
|
|
10310
|
+
type: import_v46.z.literal("conditional"),
|
|
10311
|
+
condition: import_v46.z.string(),
|
|
10312
|
+
then: import_v46.z.string(),
|
|
10313
|
+
else: import_v46.z.string().optional()
|
|
10020
10314
|
});
|
|
10021
|
-
var LegacyTransformStageZ =
|
|
10022
|
-
id:
|
|
10023
|
-
type:
|
|
10024
|
-
set:
|
|
10315
|
+
var LegacyTransformStageZ = import_v46.z.object({
|
|
10316
|
+
id: import_v46.z.string(),
|
|
10317
|
+
type: import_v46.z.literal("transform"),
|
|
10318
|
+
set: import_v46.z.record(import_v46.z.string(), import_v46.z.string())
|
|
10025
10319
|
});
|
|
10026
|
-
var LegacyOutputStageZ =
|
|
10027
|
-
id:
|
|
10028
|
-
type:
|
|
10029
|
-
value:
|
|
10320
|
+
var LegacyOutputStageZ = import_v46.z.object({
|
|
10321
|
+
id: import_v46.z.string(),
|
|
10322
|
+
type: import_v46.z.literal("output"),
|
|
10323
|
+
value: import_v46.z.record(import_v46.z.string(), import_v46.z.string())
|
|
10030
10324
|
});
|
|
10031
|
-
var StageWithLegacyZ =
|
|
10325
|
+
var StageWithLegacyZ = import_v46.z.union([
|
|
10032
10326
|
StageZ,
|
|
10033
10327
|
LegacyActivityStageZ,
|
|
10034
10328
|
LegacyAgentStageZ,
|
|
@@ -10036,87 +10330,87 @@ var StageWithLegacyZ = import_v43.z.union([
|
|
|
10036
10330
|
LegacyTransformStageZ,
|
|
10037
10331
|
LegacyOutputStageZ
|
|
10038
10332
|
]);
|
|
10039
|
-
var InlineAgentDefinitionZ =
|
|
10333
|
+
var InlineAgentDefinitionZ = import_v46.z.object({
|
|
10040
10334
|
/** Unique identifier for the agent (lowercase, alphanumeric with dashes/underscores) */
|
|
10041
|
-
handle:
|
|
10335
|
+
handle: import_v46.z.string().regex(/^[a-z][a-z0-9_-]*$/, "Handle must be lowercase alphanumeric with dashes/underscores, starting with a letter"),
|
|
10042
10336
|
/** Display name for the agent */
|
|
10043
|
-
name:
|
|
10337
|
+
name: import_v46.z.string().min(1, "Name is required"),
|
|
10044
10338
|
/** Description of what the agent does */
|
|
10045
|
-
description:
|
|
10339
|
+
description: import_v46.z.string(),
|
|
10046
10340
|
/** System prompt that defines the agent behavior and tool selection logic */
|
|
10047
|
-
system:
|
|
10341
|
+
system: import_v46.z.string(),
|
|
10048
10342
|
/** Optional persona name for response generation (e.g., "Brett") */
|
|
10049
|
-
personaName:
|
|
10343
|
+
personaName: import_v46.z.string().optional(),
|
|
10050
10344
|
/** Optional persona prompt for two-phase response generation (tone, style, format rules) */
|
|
10051
|
-
persona:
|
|
10345
|
+
persona: import_v46.z.string().optional(),
|
|
10052
10346
|
/** LLM model ID (e.g., "openai/gpt-4o-mini"). Defaults to gpt-4o-mini */
|
|
10053
|
-
llmModelId:
|
|
10347
|
+
llmModelId: import_v46.z.string().optional(),
|
|
10054
10348
|
/** Array of tool references to bind to this agent */
|
|
10055
|
-
tools:
|
|
10349
|
+
tools: import_v46.z.array(import_v46.z.union([ToolReferenceInputZ, ToolBindingZ])).optional(),
|
|
10056
10350
|
/**
|
|
10057
10351
|
* JSON Schema for structured data output. When provided, the agent returns structured
|
|
10058
10352
|
* data in the `data` field matching this schema. When not provided, agent defaults to
|
|
10059
10353
|
* plain text output in the `content` field.
|
|
10060
10354
|
*/
|
|
10061
|
-
outputSchema:
|
|
10355
|
+
outputSchema: import_v46.z.record(import_v46.z.string(), import_v46.z.unknown()).optional()
|
|
10062
10356
|
});
|
|
10063
|
-
var AgentInputOptionZ =
|
|
10357
|
+
var AgentInputOptionZ = import_v46.z.object({
|
|
10064
10358
|
/** Value to store when selected */
|
|
10065
|
-
value:
|
|
10359
|
+
value: import_v46.z.string(),
|
|
10066
10360
|
/** Display label for the option */
|
|
10067
|
-
label:
|
|
10361
|
+
label: import_v46.z.string()
|
|
10068
10362
|
});
|
|
10069
|
-
var AgentInputFieldZ =
|
|
10363
|
+
var AgentInputFieldZ = import_v46.z.object({
|
|
10070
10364
|
/** Unique key for this input (used in Thread.inputs) */
|
|
10071
|
-
key:
|
|
10365
|
+
key: import_v46.z.string(),
|
|
10072
10366
|
/** Display label for the input field */
|
|
10073
|
-
label:
|
|
10367
|
+
label: import_v46.z.string().optional(),
|
|
10074
10368
|
/** Help text/description for the input */
|
|
10075
|
-
description:
|
|
10369
|
+
description: import_v46.z.string().optional(),
|
|
10076
10370
|
/** Whether this input is required */
|
|
10077
|
-
required:
|
|
10371
|
+
required: import_v46.z.boolean().optional(),
|
|
10078
10372
|
/** Input type for rendering appropriate control */
|
|
10079
|
-
type:
|
|
10373
|
+
type: import_v46.z.enum(["text", "number", "select", "textarea"]).optional(),
|
|
10080
10374
|
/** Options for select-type inputs */
|
|
10081
|
-
options:
|
|
10375
|
+
options: import_v46.z.array(AgentInputOptionZ).optional(),
|
|
10082
10376
|
/** Placeholder text for the input */
|
|
10083
|
-
placeholder:
|
|
10377
|
+
placeholder: import_v46.z.string().optional()
|
|
10084
10378
|
});
|
|
10085
|
-
var PersonaVoiceFormatZ =
|
|
10379
|
+
var PersonaVoiceFormatZ = import_v46.z.object({
|
|
10086
10380
|
/** Maximum character count for messages */
|
|
10087
|
-
maxChars:
|
|
10381
|
+
maxChars: import_v46.z.number().optional(),
|
|
10088
10382
|
/** Whether to avoid emojis */
|
|
10089
|
-
noEmojis:
|
|
10383
|
+
noEmojis: import_v46.z.boolean().optional(),
|
|
10090
10384
|
/** Whether to avoid hyphens */
|
|
10091
|
-
noHyphens:
|
|
10385
|
+
noHyphens: import_v46.z.boolean().optional(),
|
|
10092
10386
|
/** Whether to avoid bullet points */
|
|
10093
|
-
noBulletPoints:
|
|
10387
|
+
noBulletPoints: import_v46.z.boolean().optional(),
|
|
10094
10388
|
/** Maximum questions per message */
|
|
10095
|
-
maxQuestionsPerMessage:
|
|
10389
|
+
maxQuestionsPerMessage: import_v46.z.number().optional(),
|
|
10096
10390
|
/** Whether to avoid sign-offs like "Cheers" or "Thanks" */
|
|
10097
|
-
noSignOffs:
|
|
10391
|
+
noSignOffs: import_v46.z.boolean().optional()
|
|
10098
10392
|
});
|
|
10099
|
-
var PersonaVoiceZ =
|
|
10393
|
+
var PersonaVoiceZ = import_v46.z.object({
|
|
10100
10394
|
/** Style guidelines as a single string (voice, tone, personality) */
|
|
10101
|
-
style:
|
|
10395
|
+
style: import_v46.z.string(),
|
|
10102
10396
|
/** Formatting constraints */
|
|
10103
10397
|
format: PersonaVoiceFormatZ.optional()
|
|
10104
10398
|
});
|
|
10105
|
-
var PersonaZ =
|
|
10399
|
+
var PersonaZ = import_v46.z.object({
|
|
10106
10400
|
/** Display name for the persona (e.g., "Brett") */
|
|
10107
|
-
name:
|
|
10401
|
+
name: import_v46.z.string(),
|
|
10108
10402
|
/** Voice configuration with style and format rules */
|
|
10109
10403
|
voice: PersonaVoiceZ
|
|
10110
10404
|
});
|
|
10111
|
-
var RespondBlockZ =
|
|
10405
|
+
var RespondBlockZ = import_v46.z.object({
|
|
10112
10406
|
/** Optional Liquid condition - if false, no message is sent */
|
|
10113
|
-
if:
|
|
10407
|
+
if: import_v46.z.string().optional(),
|
|
10114
10408
|
/** Direct message content (no persona transformation) - mutually exclusive with instructions */
|
|
10115
|
-
content:
|
|
10409
|
+
content: import_v46.z.string().optional(),
|
|
10116
10410
|
/** Instructions for persona to write message (Liquid template) - mutually exclusive with content */
|
|
10117
|
-
instructions:
|
|
10411
|
+
instructions: import_v46.z.string().optional(),
|
|
10118
10412
|
/** If true, message requires human approval before sending */
|
|
10119
|
-
requiresApproval:
|
|
10413
|
+
requiresApproval: import_v46.z.boolean().optional()
|
|
10120
10414
|
}).refine(
|
|
10121
10415
|
(data) => {
|
|
10122
10416
|
const hasContent = !!data.content;
|
|
@@ -10125,51 +10419,51 @@ var RespondBlockZ = import_v43.z.object({
|
|
|
10125
10419
|
},
|
|
10126
10420
|
{ message: "respond must have either content or instructions, but not both" }
|
|
10127
10421
|
);
|
|
10128
|
-
var AgentBaseZ =
|
|
10422
|
+
var AgentBaseZ = import_v46.z.object({
|
|
10129
10423
|
/** Schema format version for future compatibility */
|
|
10130
|
-
$schema:
|
|
10424
|
+
$schema: import_v46.z.literal("https://skedyul.com/schemas/agent/v1").optional(),
|
|
10131
10425
|
/** Unique identifier for the agent (lowercase, alphanumeric with dashes/underscores) */
|
|
10132
|
-
handle:
|
|
10426
|
+
handle: import_v46.z.string().regex(/^[a-z][a-z0-9_-]*$/, "Handle must be lowercase alphanumeric with dashes/underscores, starting with a letter"),
|
|
10133
10427
|
/** Display name for the agent */
|
|
10134
|
-
name:
|
|
10428
|
+
name: import_v46.z.string().min(1, "Name is required"),
|
|
10135
10429
|
/** Description of what the agent does */
|
|
10136
|
-
description:
|
|
10430
|
+
description: import_v46.z.string(),
|
|
10137
10431
|
/** Whether the agent is enabled (default: true) */
|
|
10138
|
-
isEnabled:
|
|
10432
|
+
isEnabled: import_v46.z.boolean().optional()
|
|
10139
10433
|
});
|
|
10140
10434
|
var SingleStageAgentZ = AgentBaseZ.extend({
|
|
10141
10435
|
/** System prompt that defines the agent behavior and tool selection logic */
|
|
10142
|
-
system:
|
|
10436
|
+
system: import_v46.z.string(),
|
|
10143
10437
|
/** Optional persona name for response generation (e.g., "Brett") */
|
|
10144
|
-
personaName:
|
|
10438
|
+
personaName: import_v46.z.string().optional(),
|
|
10145
10439
|
/** Optional persona prompt for two-phase response generation (tone, style, format rules) */
|
|
10146
|
-
persona:
|
|
10440
|
+
persona: import_v46.z.string().optional(),
|
|
10147
10441
|
/** LLM model ID (e.g., "openai/gpt-4o-mini"). Defaults to gpt-4o-mini */
|
|
10148
|
-
llmModelId:
|
|
10442
|
+
llmModelId: import_v46.z.string().optional(),
|
|
10149
10443
|
/** Array of tool references to bind to this agent */
|
|
10150
|
-
tools:
|
|
10444
|
+
tools: import_v46.z.array(import_v46.z.union([ToolReferenceInputZ, ToolBindingZ])).optional(),
|
|
10151
10445
|
/** Input fields to collect from user before agent runs (stored in Thread.inputs) */
|
|
10152
|
-
inputs:
|
|
10446
|
+
inputs: import_v46.z.array(AgentInputFieldZ).optional()
|
|
10153
10447
|
});
|
|
10154
10448
|
var MultiStageAgentZ = AgentBaseZ.extend({
|
|
10155
10449
|
/** @deprecated Use inline agent definitions in stages instead. Kept for backward compatibility. */
|
|
10156
|
-
agents:
|
|
10450
|
+
agents: import_v46.z.array(InlineAgentDefinitionZ).optional(),
|
|
10157
10451
|
/** Stages define the execution flow - each stage runs an agent, tool, or transform */
|
|
10158
|
-
stages:
|
|
10452
|
+
stages: import_v46.z.array(StageWithLegacyZ).min(1, "Multi-stage agents must have at least one stage"),
|
|
10159
10453
|
/** Input schema for the agent (validated at runtime) */
|
|
10160
|
-
inputs:
|
|
10161
|
-
type:
|
|
10162
|
-
required:
|
|
10163
|
-
description:
|
|
10454
|
+
inputs: import_v46.z.record(import_v46.z.string(), import_v46.z.object({
|
|
10455
|
+
type: import_v46.z.enum(["string", "number", "boolean", "object", "array"]),
|
|
10456
|
+
required: import_v46.z.boolean().optional(),
|
|
10457
|
+
description: import_v46.z.string().optional()
|
|
10164
10458
|
})).optional(),
|
|
10165
10459
|
/** Error handling strategy */
|
|
10166
|
-
onError:
|
|
10460
|
+
onError: import_v46.z.enum(["fail", "skip", "retry"]).optional(),
|
|
10167
10461
|
/** Persona configuration for voice and formatting */
|
|
10168
10462
|
persona: PersonaZ.optional(),
|
|
10169
10463
|
/** Respond block for explicit message output */
|
|
10170
10464
|
respond: RespondBlockZ.optional()
|
|
10171
10465
|
});
|
|
10172
|
-
var AgentSchemaZ =
|
|
10466
|
+
var AgentSchemaZ = import_v46.z.union([SingleStageAgentZ, MultiStageAgentZ]);
|
|
10173
10467
|
function isMultiStageAgent(agent) {
|
|
10174
10468
|
return "stages" in agent && Array.isArray(agent.stages);
|
|
10175
10469
|
}
|
|
@@ -10186,265 +10480,131 @@ function validateAgentSchema(data) {
|
|
|
10186
10480
|
}
|
|
10187
10481
|
|
|
10188
10482
|
// src/schemas/agent-schema-v3.ts
|
|
10189
|
-
var
|
|
10190
|
-
|
|
10191
|
-
// src/events/types.ts
|
|
10192
|
-
var import_v44 = require("zod/v4");
|
|
10193
|
-
var ThreadEventTypeSchema = import_v44.z.enum([
|
|
10194
|
-
// Message events
|
|
10195
|
-
"thread.message.received",
|
|
10196
|
-
"thread.message.sent",
|
|
10197
|
-
"thread.attachment.received",
|
|
10198
|
-
// Participant events
|
|
10199
|
-
"thread.participant.joined",
|
|
10200
|
-
"thread.participant.left",
|
|
10201
|
-
"thread.participant.mentioned",
|
|
10202
|
-
// Context events
|
|
10203
|
-
"thread.context.changed",
|
|
10204
|
-
"thread.status.changed",
|
|
10205
|
-
// Agent/Workflow events
|
|
10206
|
-
"thread.agent.delegated",
|
|
10207
|
-
"thread.agent.completed",
|
|
10208
|
-
"thread.workflow.triggered",
|
|
10209
|
-
"thread.workflow.completed",
|
|
10210
|
-
// Scheduled events
|
|
10211
|
-
"thread.follow_up.due",
|
|
10212
|
-
"thread.reminder.due",
|
|
10213
|
-
// Signal events
|
|
10214
|
-
"thread.signal.created"
|
|
10215
|
-
]);
|
|
10216
|
-
var CustomEventTypeSchema = import_v44.z.string().regex(/^custom\.[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)*$/, {
|
|
10217
|
-
message: "Custom event type must match pattern: custom.{namespace}.{event}"
|
|
10218
|
-
});
|
|
10219
|
-
var EventTypeSchema = import_v44.z.union([ThreadEventTypeSchema, CustomEventTypeSchema]);
|
|
10220
|
-
var ParticipantKindSchema = import_v44.z.enum(["CONTACT", "MEMBER", "AGENT", "WORKFLOW"]);
|
|
10221
|
-
var BaseEventPayloadSchema = import_v44.z.object({
|
|
10222
|
-
threadId: import_v44.z.string(),
|
|
10223
|
-
workplaceId: import_v44.z.string(),
|
|
10224
|
-
timestamp: import_v44.z.string().datetime().optional()
|
|
10225
|
-
});
|
|
10226
|
-
var MessageEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
10227
|
-
message: import_v44.z.object({
|
|
10228
|
-
id: import_v44.z.string(),
|
|
10229
|
-
content: import_v44.z.string(),
|
|
10230
|
-
senderId: import_v44.z.string().optional()
|
|
10231
|
-
}),
|
|
10232
|
-
participant: import_v44.z.object({
|
|
10233
|
-
id: import_v44.z.string(),
|
|
10234
|
-
kind: ParticipantKindSchema,
|
|
10235
|
-
displayName: import_v44.z.string().optional()
|
|
10236
|
-
}).optional(),
|
|
10237
|
-
isFirstMessage: import_v44.z.boolean().optional(),
|
|
10238
|
-
messageCount: import_v44.z.number().optional()
|
|
10239
|
-
});
|
|
10240
|
-
var ParticipantEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
10241
|
-
participant: import_v44.z.object({
|
|
10242
|
-
id: import_v44.z.string(),
|
|
10243
|
-
kind: ParticipantKindSchema,
|
|
10244
|
-
displayName: import_v44.z.string().optional(),
|
|
10245
|
-
contactId: import_v44.z.string().optional(),
|
|
10246
|
-
memberId: import_v44.z.string().optional(),
|
|
10247
|
-
agentId: import_v44.z.string().optional(),
|
|
10248
|
-
workflowId: import_v44.z.string().optional()
|
|
10249
|
-
})
|
|
10250
|
-
});
|
|
10251
|
-
var ContextChangedPayloadSchema = BaseEventPayloadSchema.extend({
|
|
10252
|
-
context: import_v44.z.object({
|
|
10253
|
-
handle: import_v44.z.string(),
|
|
10254
|
-
model: import_v44.z.string(),
|
|
10255
|
-
instanceId: import_v44.z.string()
|
|
10256
|
-
}),
|
|
10257
|
-
change: import_v44.z.object({
|
|
10258
|
-
field: import_v44.z.string().optional(),
|
|
10259
|
-
oldValue: import_v44.z.unknown().optional(),
|
|
10260
|
-
newValue: import_v44.z.unknown().optional()
|
|
10261
|
-
}).optional()
|
|
10262
|
-
});
|
|
10263
|
-
var StatusChangedPayloadSchema = BaseEventPayloadSchema.extend({
|
|
10264
|
-
oldStatus: import_v44.z.string(),
|
|
10265
|
-
newStatus: import_v44.z.string()
|
|
10266
|
-
});
|
|
10267
|
-
var ScheduledEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
10268
|
-
scheduledEventId: import_v44.z.string(),
|
|
10269
|
-
reason: import_v44.z.string().optional(),
|
|
10270
|
-
context: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).optional()
|
|
10271
|
-
});
|
|
10272
|
-
var AgentWorkflowEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
10273
|
-
agentId: import_v44.z.string().optional(),
|
|
10274
|
-
workflowId: import_v44.z.string().optional(),
|
|
10275
|
-
workflowRunId: import_v44.z.string().optional(),
|
|
10276
|
-
outputs: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).optional(),
|
|
10277
|
-
error: import_v44.z.string().optional()
|
|
10278
|
-
});
|
|
10279
|
-
var CustomEventPayloadSchema = BaseEventPayloadSchema.extend({
|
|
10280
|
-
data: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()).optional()
|
|
10281
|
-
});
|
|
10282
|
-
var ThreadEventPayloadSchema = import_v44.z.union([
|
|
10283
|
-
MessageEventPayloadSchema,
|
|
10284
|
-
ParticipantEventPayloadSchema,
|
|
10285
|
-
ContextChangedPayloadSchema,
|
|
10286
|
-
StatusChangedPayloadSchema,
|
|
10287
|
-
ScheduledEventPayloadSchema,
|
|
10288
|
-
AgentWorkflowEventPayloadSchema,
|
|
10289
|
-
CustomEventPayloadSchema
|
|
10290
|
-
]);
|
|
10291
|
-
var ThreadEventSchema = import_v44.z.object({
|
|
10292
|
-
id: import_v44.z.string(),
|
|
10293
|
-
threadId: import_v44.z.string(),
|
|
10294
|
-
type: EventTypeSchema,
|
|
10295
|
-
payload: ThreadEventPayloadSchema,
|
|
10296
|
-
emittedBy: import_v44.z.string().optional(),
|
|
10297
|
-
createdAt: import_v44.z.string().datetime()
|
|
10298
|
-
});
|
|
10299
|
-
var CreateThreadEventInputSchema = import_v44.z.object({
|
|
10300
|
-
threadId: import_v44.z.string(),
|
|
10301
|
-
type: EventTypeSchema,
|
|
10302
|
-
payload: import_v44.z.record(import_v44.z.string(), import_v44.z.unknown()),
|
|
10303
|
-
emittedBy: import_v44.z.string().optional()
|
|
10304
|
-
});
|
|
10305
|
-
var EventSubscriptionSchema = import_v44.z.object({
|
|
10306
|
-
subscribes: import_v44.z.array(EventTypeSchema),
|
|
10307
|
-
condition: import_v44.z.string().optional(),
|
|
10308
|
-
cancels: import_v44.z.array(EventTypeSchema).optional(),
|
|
10309
|
-
cancelCondition: import_v44.z.string().optional()
|
|
10310
|
-
});
|
|
10311
|
-
var EventWaitSchema = import_v44.z.object({
|
|
10312
|
-
event: EventTypeSchema,
|
|
10313
|
-
timeout: import_v44.z.string().optional(),
|
|
10314
|
-
onTimeout: import_v44.z.string().optional()
|
|
10315
|
-
});
|
|
10316
|
-
var EventsConfigSchema = import_v44.z.object({
|
|
10317
|
-
subscribes: import_v44.z.array(EventTypeSchema).optional(),
|
|
10318
|
-
condition: import_v44.z.string().optional(),
|
|
10319
|
-
emits: import_v44.z.array(EventTypeSchema).optional(),
|
|
10320
|
-
waits: import_v44.z.array(EventWaitSchema).optional(),
|
|
10321
|
-
cancels: import_v44.z.array(EventTypeSchema).optional(),
|
|
10322
|
-
cancelCondition: import_v44.z.string().optional()
|
|
10323
|
-
});
|
|
10483
|
+
var import_v49 = require("zod/v4");
|
|
10324
10484
|
|
|
10325
10485
|
// src/skills/types.ts
|
|
10326
|
-
var
|
|
10486
|
+
var import_v47 = require("zod/v4");
|
|
10327
10487
|
var SKILL_SCHEMA_VERSION_V2 = "https://skedyul.com/schemas/skill/v2";
|
|
10328
|
-
var SkillSourceSchema =
|
|
10329
|
-
var SkillToolRequirementSchema =
|
|
10330
|
-
requires:
|
|
10331
|
-
provides:
|
|
10488
|
+
var SkillSourceSchema = import_v47.z.enum(["BUILTIN", "S3", "APP", "EXTERNAL"]);
|
|
10489
|
+
var SkillToolRequirementSchema = import_v47.z.object({
|
|
10490
|
+
requires: import_v47.z.array(import_v47.z.string()).optional(),
|
|
10491
|
+
provides: import_v47.z.array(import_v47.z.string()).optional()
|
|
10332
10492
|
});
|
|
10333
|
-
var SkillToolSandboxSchema =
|
|
10334
|
-
mock:
|
|
10493
|
+
var SkillToolSandboxSchema = import_v47.z.object({
|
|
10494
|
+
mock: import_v47.z.unknown().optional()
|
|
10335
10495
|
});
|
|
10336
|
-
var ToolConstraintsSchema =
|
|
10337
|
-
maxCallsPerRun:
|
|
10338
|
-
idempotent:
|
|
10339
|
-
restricted:
|
|
10340
|
-
tags:
|
|
10496
|
+
var ToolConstraintsSchema = import_v47.z.object({
|
|
10497
|
+
maxCallsPerRun: import_v47.z.number().optional(),
|
|
10498
|
+
idempotent: import_v47.z.boolean().optional(),
|
|
10499
|
+
restricted: import_v47.z.boolean().optional(),
|
|
10500
|
+
tags: import_v47.z.array(import_v47.z.string()).optional()
|
|
10341
10501
|
});
|
|
10342
|
-
var SkillToolDefinitionSchema =
|
|
10343
|
-
tool:
|
|
10344
|
-
description:
|
|
10345
|
-
overrides:
|
|
10502
|
+
var SkillToolDefinitionSchema = import_v47.z.object({
|
|
10503
|
+
tool: import_v47.z.string(),
|
|
10504
|
+
description: import_v47.z.string().optional(),
|
|
10505
|
+
overrides: import_v47.z.record(import_v47.z.string(), import_v47.z.unknown()).optional(),
|
|
10346
10506
|
sandbox: SkillToolSandboxSchema.optional(),
|
|
10347
|
-
requiresApproval:
|
|
10507
|
+
requiresApproval: import_v47.z.boolean().optional(),
|
|
10348
10508
|
constraints: ToolConstraintsSchema.optional()
|
|
10349
10509
|
});
|
|
10350
|
-
var SkillToolsSchema =
|
|
10510
|
+
var SkillToolsSchema = import_v47.z.union([
|
|
10351
10511
|
SkillToolRequirementSchema,
|
|
10352
|
-
|
|
10512
|
+
import_v47.z.array(SkillToolDefinitionSchema)
|
|
10353
10513
|
]);
|
|
10354
|
-
var SkillExampleSchema =
|
|
10355
|
-
context:
|
|
10356
|
-
input:
|
|
10357
|
-
reasoning:
|
|
10358
|
-
output:
|
|
10359
|
-
tool_call:
|
|
10514
|
+
var SkillExampleSchema = import_v47.z.object({
|
|
10515
|
+
context: import_v47.z.string().optional(),
|
|
10516
|
+
input: import_v47.z.string(),
|
|
10517
|
+
reasoning: import_v47.z.string().optional(),
|
|
10518
|
+
output: import_v47.z.string(),
|
|
10519
|
+
tool_call: import_v47.z.string().optional()
|
|
10360
10520
|
});
|
|
10361
|
-
var CRMModelFieldRequirementsSchema =
|
|
10362
|
-
required:
|
|
10363
|
-
recommended:
|
|
10521
|
+
var CRMModelFieldRequirementsSchema = import_v47.z.object({
|
|
10522
|
+
required: import_v47.z.array(import_v47.z.string()).optional(),
|
|
10523
|
+
recommended: import_v47.z.array(import_v47.z.string()).optional()
|
|
10364
10524
|
});
|
|
10365
|
-
var CRMContextSchema =
|
|
10366
|
-
models:
|
|
10525
|
+
var CRMContextSchema = import_v47.z.object({
|
|
10526
|
+
models: import_v47.z.record(import_v47.z.string(), CRMModelFieldRequirementsSchema)
|
|
10367
10527
|
});
|
|
10368
|
-
var SkillYAMLSchema =
|
|
10528
|
+
var SkillYAMLSchema = import_v47.z.object({
|
|
10369
10529
|
// Schema version
|
|
10370
|
-
$schema:
|
|
10530
|
+
$schema: import_v47.z.string().optional(),
|
|
10371
10531
|
// Identity
|
|
10372
|
-
handle:
|
|
10373
|
-
name:
|
|
10374
|
-
version:
|
|
10375
|
-
description:
|
|
10532
|
+
handle: import_v47.z.string(),
|
|
10533
|
+
name: import_v47.z.string(),
|
|
10534
|
+
version: import_v47.z.string().optional(),
|
|
10535
|
+
description: import_v47.z.string().optional(),
|
|
10376
10536
|
// Instructions injected into agent system prompt
|
|
10377
|
-
instructions:
|
|
10537
|
+
instructions: import_v47.z.string(),
|
|
10378
10538
|
// Tool configuration - supports both v1 and v2 formats
|
|
10379
10539
|
tools: SkillToolsSchema.optional(),
|
|
10380
10540
|
// CRM context - specifies which models/fields to include in schema
|
|
10381
10541
|
crmContext: CRMContextSchema.optional(),
|
|
10382
10542
|
// Few-shot examples
|
|
10383
|
-
examples:
|
|
10543
|
+
examples: import_v47.z.array(SkillExampleSchema).optional()
|
|
10384
10544
|
});
|
|
10385
|
-
var SkillYAMLV2Schema =
|
|
10386
|
-
$schema:
|
|
10387
|
-
handle:
|
|
10388
|
-
name:
|
|
10389
|
-
version:
|
|
10390
|
-
description:
|
|
10391
|
-
instructions:
|
|
10392
|
-
tools:
|
|
10545
|
+
var SkillYAMLV2Schema = import_v47.z.object({
|
|
10546
|
+
$schema: import_v47.z.literal(SKILL_SCHEMA_VERSION_V2).optional(),
|
|
10547
|
+
handle: import_v47.z.string(),
|
|
10548
|
+
name: import_v47.z.string(),
|
|
10549
|
+
version: import_v47.z.string().optional(),
|
|
10550
|
+
description: import_v47.z.string().optional(),
|
|
10551
|
+
instructions: import_v47.z.string(),
|
|
10552
|
+
tools: import_v47.z.array(SkillToolDefinitionSchema).optional(),
|
|
10393
10553
|
crmContext: CRMContextSchema.optional(),
|
|
10394
|
-
examples:
|
|
10554
|
+
examples: import_v47.z.array(SkillExampleSchema).optional()
|
|
10395
10555
|
});
|
|
10396
|
-
var SkillVersionWeightSchema =
|
|
10397
|
-
version:
|
|
10398
|
-
weight:
|
|
10556
|
+
var SkillVersionWeightSchema = import_v47.z.object({
|
|
10557
|
+
version: import_v47.z.number(),
|
|
10558
|
+
weight: import_v47.z.number()
|
|
10399
10559
|
});
|
|
10400
|
-
var SkillRefSchema =
|
|
10401
|
-
|
|
10560
|
+
var SkillRefSchema = import_v47.z.union([
|
|
10561
|
+
import_v47.z.string(),
|
|
10402
10562
|
// Just handle - uses latest published version
|
|
10403
|
-
|
|
10404
|
-
skill:
|
|
10405
|
-
description:
|
|
10563
|
+
import_v47.z.object({
|
|
10564
|
+
skill: import_v47.z.string(),
|
|
10565
|
+
description: import_v47.z.string().optional(),
|
|
10406
10566
|
// For AI SDK Agent Skills discovery
|
|
10407
10567
|
/** Auto-inject this skill's instructions and tools on every agent turn */
|
|
10408
|
-
alwaysLoad:
|
|
10568
|
+
alwaysLoad: import_v47.z.boolean().optional(),
|
|
10409
10569
|
// Version selection (pick one):
|
|
10410
|
-
version:
|
|
10570
|
+
version: import_v47.z.number().optional(),
|
|
10411
10571
|
// Pin to specific version number
|
|
10412
|
-
versions:
|
|
10572
|
+
versions: import_v47.z.array(SkillVersionWeightSchema).optional(),
|
|
10413
10573
|
// A/B testing weights
|
|
10414
10574
|
// Legacy support:
|
|
10415
|
-
instructions:
|
|
10575
|
+
instructions: import_v47.z.string().optional(),
|
|
10416
10576
|
// Inline instructions (deprecated)
|
|
10417
|
-
enabled:
|
|
10577
|
+
enabled: import_v47.z.boolean().optional()
|
|
10418
10578
|
})
|
|
10419
10579
|
]);
|
|
10420
|
-
var SkillMetadataSchema =
|
|
10421
|
-
id:
|
|
10422
|
-
handle:
|
|
10423
|
-
name:
|
|
10424
|
-
version:
|
|
10425
|
-
description:
|
|
10580
|
+
var SkillMetadataSchema = import_v47.z.object({
|
|
10581
|
+
id: import_v47.z.string(),
|
|
10582
|
+
handle: import_v47.z.string(),
|
|
10583
|
+
name: import_v47.z.string(),
|
|
10584
|
+
version: import_v47.z.string().optional(),
|
|
10585
|
+
description: import_v47.z.string().optional(),
|
|
10426
10586
|
source: SkillSourceSchema,
|
|
10427
|
-
s3Key:
|
|
10428
|
-
appVersionId:
|
|
10429
|
-
workplaceId:
|
|
10430
|
-
createdAt:
|
|
10431
|
-
updatedAt:
|
|
10587
|
+
s3Key: import_v47.z.string().optional(),
|
|
10588
|
+
appVersionId: import_v47.z.string().optional(),
|
|
10589
|
+
workplaceId: import_v47.z.string().optional(),
|
|
10590
|
+
createdAt: import_v47.z.string().datetime().optional(),
|
|
10591
|
+
updatedAt: import_v47.z.string().datetime().optional()
|
|
10432
10592
|
});
|
|
10433
|
-
var ResolvedSkillSchema =
|
|
10434
|
-
handle:
|
|
10435
|
-
name:
|
|
10436
|
-
instructions:
|
|
10437
|
-
description:
|
|
10438
|
-
tools:
|
|
10439
|
-
examples:
|
|
10593
|
+
var ResolvedSkillSchema = import_v47.z.object({
|
|
10594
|
+
handle: import_v47.z.string(),
|
|
10595
|
+
name: import_v47.z.string(),
|
|
10596
|
+
instructions: import_v47.z.string().optional(),
|
|
10597
|
+
description: import_v47.z.string().optional(),
|
|
10598
|
+
tools: import_v47.z.array(import_v47.z.string()).optional(),
|
|
10599
|
+
examples: import_v47.z.array(SkillExampleSchema).optional()
|
|
10440
10600
|
});
|
|
10441
|
-
var LoadedSkillSchema =
|
|
10442
|
-
handle:
|
|
10443
|
-
name:
|
|
10444
|
-
instructions:
|
|
10445
|
-
description:
|
|
10446
|
-
tools:
|
|
10447
|
-
examples:
|
|
10601
|
+
var LoadedSkillSchema = import_v47.z.object({
|
|
10602
|
+
handle: import_v47.z.string(),
|
|
10603
|
+
name: import_v47.z.string(),
|
|
10604
|
+
instructions: import_v47.z.string().optional(),
|
|
10605
|
+
description: import_v47.z.string().optional(),
|
|
10606
|
+
tools: import_v47.z.array(SkillToolDefinitionSchema).optional(),
|
|
10607
|
+
examples: import_v47.z.array(SkillExampleSchema).optional()
|
|
10448
10608
|
});
|
|
10449
10609
|
function validateSkillYAML(skill) {
|
|
10450
10610
|
const result = SkillYAMLSchema.safeParse(skill);
|
|
@@ -10455,179 +10615,179 @@ function validateSkillYAML(skill) {
|
|
|
10455
10615
|
}
|
|
10456
10616
|
|
|
10457
10617
|
// src/context/types.ts
|
|
10458
|
-
var
|
|
10459
|
-
var CRMContextSchema2 =
|
|
10460
|
-
model:
|
|
10461
|
-
instanceId:
|
|
10462
|
-
data:
|
|
10618
|
+
var import_v48 = require("zod/v4");
|
|
10619
|
+
var CRMContextSchema2 = import_v48.z.object({
|
|
10620
|
+
model: import_v48.z.string(),
|
|
10621
|
+
instanceId: import_v48.z.string(),
|
|
10622
|
+
data: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown())
|
|
10463
10623
|
});
|
|
10464
|
-
var
|
|
10624
|
+
var SenderContextSchema2 = import_v48.z.object({
|
|
10465
10625
|
kind: ParticipantKindSchema,
|
|
10466
|
-
displayName:
|
|
10467
|
-
email:
|
|
10468
|
-
role:
|
|
10469
|
-
permissions:
|
|
10626
|
+
displayName: import_v48.z.string().optional(),
|
|
10627
|
+
email: import_v48.z.string().optional(),
|
|
10628
|
+
role: import_v48.z.string().optional(),
|
|
10629
|
+
permissions: import_v48.z.array(import_v48.z.string()).optional(),
|
|
10470
10630
|
crm: CRMContextSchema2.optional()
|
|
10471
10631
|
});
|
|
10472
|
-
var
|
|
10473
|
-
handle:
|
|
10474
|
-
model:
|
|
10475
|
-
instanceId:
|
|
10476
|
-
data:
|
|
10632
|
+
var ThreadContextItemSchema2 = import_v48.z.object({
|
|
10633
|
+
handle: import_v48.z.string(),
|
|
10634
|
+
model: import_v48.z.string(),
|
|
10635
|
+
instanceId: import_v48.z.string(),
|
|
10636
|
+
data: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()).optional()
|
|
10477
10637
|
});
|
|
10478
|
-
var ThreadInfoSchema =
|
|
10479
|
-
id:
|
|
10480
|
-
title:
|
|
10481
|
-
status:
|
|
10482
|
-
kind:
|
|
10638
|
+
var ThreadInfoSchema = import_v48.z.object({
|
|
10639
|
+
id: import_v48.z.string(),
|
|
10640
|
+
title: import_v48.z.string().optional(),
|
|
10641
|
+
status: import_v48.z.string().optional(),
|
|
10642
|
+
kind: import_v48.z.string().optional()
|
|
10483
10643
|
});
|
|
10484
|
-
var SubscriptionSchema =
|
|
10485
|
-
identifierValue:
|
|
10486
|
-
channelHandle:
|
|
10644
|
+
var SubscriptionSchema = import_v48.z.object({
|
|
10645
|
+
identifierValue: import_v48.z.string(),
|
|
10646
|
+
channelHandle: import_v48.z.string().optional()
|
|
10487
10647
|
});
|
|
10488
|
-
var AssociationSchema =
|
|
10489
|
-
id:
|
|
10490
|
-
data:
|
|
10648
|
+
var AssociationSchema = import_v48.z.object({
|
|
10649
|
+
id: import_v48.z.string().optional(),
|
|
10650
|
+
data: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown())
|
|
10491
10651
|
});
|
|
10492
|
-
var ContactSchema =
|
|
10493
|
-
id:
|
|
10494
|
-
name:
|
|
10652
|
+
var ContactSchema = import_v48.z.object({
|
|
10653
|
+
id: import_v48.z.string().optional(),
|
|
10654
|
+
name: import_v48.z.string().optional(),
|
|
10495
10655
|
subscription: SubscriptionSchema.optional(),
|
|
10496
|
-
associations:
|
|
10656
|
+
associations: import_v48.z.record(import_v48.z.string(), AssociationSchema).optional()
|
|
10497
10657
|
});
|
|
10498
|
-
var AgentSenderContextSchema =
|
|
10499
|
-
kind:
|
|
10500
|
-
displayName:
|
|
10501
|
-
role:
|
|
10502
|
-
permissions:
|
|
10658
|
+
var AgentSenderContextSchema = import_v48.z.object({
|
|
10659
|
+
kind: import_v48.z.enum(["contact", "member"]),
|
|
10660
|
+
displayName: import_v48.z.string().optional(),
|
|
10661
|
+
role: import_v48.z.string().optional(),
|
|
10662
|
+
permissions: import_v48.z.array(import_v48.z.string()).optional(),
|
|
10503
10663
|
contact: ContactSchema.optional()
|
|
10504
10664
|
});
|
|
10505
|
-
var AgentThreadContextSchema =
|
|
10506
|
-
handle:
|
|
10507
|
-
model:
|
|
10508
|
-
data:
|
|
10665
|
+
var AgentThreadContextSchema = import_v48.z.object({
|
|
10666
|
+
handle: import_v48.z.string(),
|
|
10667
|
+
model: import_v48.z.string(),
|
|
10668
|
+
data: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown())
|
|
10509
10669
|
});
|
|
10510
|
-
var AgentContextSchema =
|
|
10670
|
+
var AgentContextSchema = import_v48.z.object({
|
|
10511
10671
|
sender: AgentSenderContextSchema,
|
|
10512
|
-
contexts:
|
|
10672
|
+
contexts: import_v48.z.array(AgentThreadContextSchema).optional()
|
|
10513
10673
|
});
|
|
10514
|
-
var ContextIssueSeveritySchema =
|
|
10515
|
-
var ContextIssueTypeSchema =
|
|
10674
|
+
var ContextIssueSeveritySchema = import_v48.z.enum(["ERROR", "WARNING"]);
|
|
10675
|
+
var ContextIssueTypeSchema = import_v48.z.enum([
|
|
10516
10676
|
"MISSING_ROUTING_PARTICIPANT",
|
|
10517
10677
|
"MISSING_ASSOCIATION",
|
|
10518
10678
|
"MISSING_REQUIRED_FIELD",
|
|
10519
10679
|
"MISSING_RECOMMENDED_FIELD"
|
|
10520
10680
|
]);
|
|
10521
|
-
var ContextIssueSchema =
|
|
10681
|
+
var ContextIssueSchema = import_v48.z.object({
|
|
10522
10682
|
type: ContextIssueTypeSchema,
|
|
10523
10683
|
severity: ContextIssueSeveritySchema,
|
|
10524
|
-
model:
|
|
10525
|
-
field:
|
|
10526
|
-
message:
|
|
10527
|
-
suggestion:
|
|
10684
|
+
model: import_v48.z.string().optional(),
|
|
10685
|
+
field: import_v48.z.string().optional(),
|
|
10686
|
+
message: import_v48.z.string(),
|
|
10687
|
+
suggestion: import_v48.z.string().optional()
|
|
10528
10688
|
});
|
|
10529
|
-
var ContextValidationResultSchema =
|
|
10530
|
-
valid:
|
|
10531
|
-
degraded:
|
|
10532
|
-
issues:
|
|
10689
|
+
var ContextValidationResultSchema = import_v48.z.object({
|
|
10690
|
+
valid: import_v48.z.boolean(),
|
|
10691
|
+
degraded: import_v48.z.boolean(),
|
|
10692
|
+
issues: import_v48.z.array(ContextIssueSchema)
|
|
10533
10693
|
});
|
|
10534
|
-
var SandboxConfigSchema =
|
|
10535
|
-
enabled:
|
|
10694
|
+
var SandboxConfigSchema = import_v48.z.object({
|
|
10695
|
+
enabled: import_v48.z.boolean().optional(),
|
|
10536
10696
|
/** @deprecated Use 'context' instead of 'mockContext' */
|
|
10537
10697
|
mockContext: AgentContextSchema.optional(),
|
|
10538
10698
|
context: AgentContextSchema.optional()
|
|
10539
10699
|
});
|
|
10540
10700
|
|
|
10541
10701
|
// src/schemas/agent-schema-v3.ts
|
|
10542
|
-
var PersonaVoiceFormatV3Schema =
|
|
10543
|
-
maxChars:
|
|
10544
|
-
noEmojis:
|
|
10545
|
-
noHyphens:
|
|
10546
|
-
noBulletPoints:
|
|
10547
|
-
maxQuestionsPerMessage:
|
|
10548
|
-
noSignOffs:
|
|
10702
|
+
var PersonaVoiceFormatV3Schema = import_v49.z.object({
|
|
10703
|
+
maxChars: import_v49.z.number().optional(),
|
|
10704
|
+
noEmojis: import_v49.z.boolean().optional(),
|
|
10705
|
+
noHyphens: import_v49.z.boolean().optional(),
|
|
10706
|
+
noBulletPoints: import_v49.z.boolean().optional(),
|
|
10707
|
+
maxQuestionsPerMessage: import_v49.z.number().optional(),
|
|
10708
|
+
noSignOffs: import_v49.z.boolean().optional()
|
|
10549
10709
|
});
|
|
10550
|
-
var PersonaVoiceV3Schema =
|
|
10551
|
-
style:
|
|
10710
|
+
var PersonaVoiceV3Schema = import_v49.z.object({
|
|
10711
|
+
style: import_v49.z.string(),
|
|
10552
10712
|
format: PersonaVoiceFormatV3Schema.optional()
|
|
10553
10713
|
});
|
|
10554
|
-
var PersonaV3Schema =
|
|
10555
|
-
name:
|
|
10714
|
+
var PersonaV3Schema = import_v49.z.object({
|
|
10715
|
+
name: import_v49.z.string(),
|
|
10556
10716
|
voice: PersonaVoiceV3Schema
|
|
10557
10717
|
});
|
|
10558
|
-
var ToolApprovalConfigSchema =
|
|
10559
|
-
required:
|
|
10560
|
-
requiredIf:
|
|
10718
|
+
var ToolApprovalConfigSchema = import_v49.z.object({
|
|
10719
|
+
required: import_v49.z.boolean().optional(),
|
|
10720
|
+
requiredIf: import_v49.z.array(import_v49.z.string()).optional()
|
|
10561
10721
|
});
|
|
10562
|
-
var ToolSandboxConfigSchema =
|
|
10563
|
-
mock:
|
|
10722
|
+
var ToolSandboxConfigSchema = import_v49.z.object({
|
|
10723
|
+
mock: import_v49.z.unknown().optional()
|
|
10564
10724
|
});
|
|
10565
|
-
var ToolRefV3Schema =
|
|
10566
|
-
|
|
10567
|
-
|
|
10568
|
-
tool:
|
|
10569
|
-
description:
|
|
10725
|
+
var ToolRefV3Schema = import_v49.z.union([
|
|
10726
|
+
import_v49.z.string(),
|
|
10727
|
+
import_v49.z.object({
|
|
10728
|
+
tool: import_v49.z.string(),
|
|
10729
|
+
description: import_v49.z.string().optional(),
|
|
10570
10730
|
approval: ToolApprovalConfigSchema.optional(),
|
|
10571
10731
|
sandbox: ToolSandboxConfigSchema.optional(),
|
|
10572
|
-
overrides:
|
|
10732
|
+
overrides: import_v49.z.record(import_v49.z.string(), import_v49.z.unknown()).optional()
|
|
10573
10733
|
})
|
|
10574
10734
|
]);
|
|
10575
|
-
var AgentToolRefSchema =
|
|
10576
|
-
|
|
10577
|
-
|
|
10578
|
-
tool:
|
|
10579
|
-
description:
|
|
10735
|
+
var AgentToolRefSchema = import_v49.z.union([
|
|
10736
|
+
import_v49.z.string(),
|
|
10737
|
+
import_v49.z.object({
|
|
10738
|
+
tool: import_v49.z.string(),
|
|
10739
|
+
description: import_v49.z.string().optional()
|
|
10580
10740
|
})
|
|
10581
10741
|
]);
|
|
10582
|
-
var WorkingMemoryConfigSchema =
|
|
10583
|
-
strategy:
|
|
10584
|
-
maxTokens:
|
|
10585
|
-
summarizeAt:
|
|
10742
|
+
var WorkingMemoryConfigSchema = import_v49.z.object({
|
|
10743
|
+
strategy: import_v49.z.enum(["full", "rolling_summary", "sliding_window"]).optional(),
|
|
10744
|
+
maxTokens: import_v49.z.number().optional(),
|
|
10745
|
+
summarizeAt: import_v49.z.number().optional()
|
|
10586
10746
|
});
|
|
10587
|
-
var ExternalMemoryConfigSchema =
|
|
10588
|
-
enabled:
|
|
10589
|
-
ttl:
|
|
10747
|
+
var ExternalMemoryConfigSchema = import_v49.z.object({
|
|
10748
|
+
enabled: import_v49.z.boolean().optional(),
|
|
10749
|
+
ttl: import_v49.z.string().optional()
|
|
10590
10750
|
});
|
|
10591
|
-
var SemanticMemoryConfigSchema =
|
|
10592
|
-
enabled:
|
|
10593
|
-
topK:
|
|
10594
|
-
scope:
|
|
10751
|
+
var SemanticMemoryConfigSchema = import_v49.z.object({
|
|
10752
|
+
enabled: import_v49.z.boolean().optional(),
|
|
10753
|
+
topK: import_v49.z.number().optional(),
|
|
10754
|
+
scope: import_v49.z.enum(["thread", "instance", "workspace"]).optional()
|
|
10595
10755
|
});
|
|
10596
|
-
var MemoryConfigV3Schema =
|
|
10756
|
+
var MemoryConfigV3Schema = import_v49.z.object({
|
|
10597
10757
|
working: WorkingMemoryConfigSchema.optional(),
|
|
10598
|
-
persistent:
|
|
10599
|
-
namespace:
|
|
10758
|
+
persistent: import_v49.z.object({
|
|
10759
|
+
namespace: import_v49.z.string().optional()
|
|
10600
10760
|
}).optional(),
|
|
10601
10761
|
external: ExternalMemoryConfigSchema.optional(),
|
|
10602
10762
|
semantic: SemanticMemoryConfigSchema.optional()
|
|
10603
10763
|
});
|
|
10604
|
-
var RequiresApprovalPolicySchema =
|
|
10605
|
-
requiresApproval:
|
|
10764
|
+
var RequiresApprovalPolicySchema = import_v49.z.object({
|
|
10765
|
+
requiresApproval: import_v49.z.boolean().optional()
|
|
10606
10766
|
});
|
|
10607
|
-
var PoliciesConfigV3Schema =
|
|
10608
|
-
messages:
|
|
10767
|
+
var PoliciesConfigV3Schema = import_v49.z.object({
|
|
10768
|
+
messages: import_v49.z.object({
|
|
10609
10769
|
send: RequiresApprovalPolicySchema.optional(),
|
|
10610
10770
|
schedule: RequiresApprovalPolicySchema.optional()
|
|
10611
10771
|
}).optional(),
|
|
10612
|
-
tools:
|
|
10613
|
-
externalRequiresApproval:
|
|
10614
|
-
systemRequiresApproval:
|
|
10772
|
+
tools: import_v49.z.object({
|
|
10773
|
+
externalRequiresApproval: import_v49.z.boolean().optional(),
|
|
10774
|
+
systemRequiresApproval: import_v49.z.boolean().optional()
|
|
10615
10775
|
}).optional()
|
|
10616
10776
|
});
|
|
10617
|
-
var RuntimeConfigV3Schema =
|
|
10777
|
+
var RuntimeConfigV3Schema = import_v49.z.object({
|
|
10618
10778
|
/** LLM model identifier for reasoning (e.g., "google/gemini-3.1-flash-lite") */
|
|
10619
|
-
model:
|
|
10779
|
+
model: import_v49.z.string().optional(),
|
|
10620
10780
|
/** LLM model for persona transformation (e.g., "openai/gpt-5-nano") */
|
|
10621
|
-
personaModel:
|
|
10781
|
+
personaModel: import_v49.z.string().optional()
|
|
10622
10782
|
});
|
|
10623
|
-
var TimeWindowTimeStampSchema =
|
|
10624
|
-
|
|
10625
|
-
|
|
10626
|
-
hour:
|
|
10627
|
-
minute:
|
|
10783
|
+
var TimeWindowTimeStampSchema = import_v49.z.union([
|
|
10784
|
+
import_v49.z.number().describe("Hour of day (0-23)"),
|
|
10785
|
+
import_v49.z.object({
|
|
10786
|
+
hour: import_v49.z.number(),
|
|
10787
|
+
minute: import_v49.z.number().optional().default(0)
|
|
10628
10788
|
})
|
|
10629
10789
|
]);
|
|
10630
|
-
var TimeWindowDayOfWeekSchema =
|
|
10790
|
+
var TimeWindowDayOfWeekSchema = import_v49.z.enum([
|
|
10631
10791
|
"monday",
|
|
10632
10792
|
"tuesday",
|
|
10633
10793
|
"wednesday",
|
|
@@ -10636,47 +10796,47 @@ var TimeWindowDayOfWeekSchema = import_v47.z.enum([
|
|
|
10636
10796
|
"saturday",
|
|
10637
10797
|
"sunday"
|
|
10638
10798
|
]);
|
|
10639
|
-
var TimeWindowSlotAgentSchema =
|
|
10799
|
+
var TimeWindowSlotAgentSchema = import_v49.z.object({
|
|
10640
10800
|
startTime: TimeWindowTimeStampSchema,
|
|
10641
10801
|
endTime: TimeWindowTimeStampSchema,
|
|
10642
|
-
days:
|
|
10802
|
+
days: import_v49.z.array(TimeWindowDayOfWeekSchema)
|
|
10643
10803
|
});
|
|
10644
|
-
var ResponseModeSchema =
|
|
10804
|
+
var ResponseModeSchema = import_v49.z.enum([
|
|
10645
10805
|
"immediate",
|
|
10646
10806
|
"ack_and_schedule",
|
|
10647
10807
|
"schedule_only"
|
|
10648
10808
|
]);
|
|
10649
|
-
var TimeWindowBehaviorSchema =
|
|
10809
|
+
var TimeWindowBehaviorSchema = import_v49.z.object({
|
|
10650
10810
|
/** How to handle responses in this window */
|
|
10651
10811
|
responseMode: ResponseModeSchema,
|
|
10652
10812
|
/** Prompt injection for this time context */
|
|
10653
|
-
prompt:
|
|
10813
|
+
prompt: import_v49.z.string().optional().describe("Prompt injection for this time context"),
|
|
10654
10814
|
/** Window to schedule responses for (when responseMode is ack_and_schedule or schedule_only) */
|
|
10655
|
-
scheduleFor:
|
|
10815
|
+
scheduleFor: import_v49.z.string().optional().describe("Window name to schedule responses for")
|
|
10656
10816
|
});
|
|
10657
|
-
var TimeWindowPolicySchema =
|
|
10817
|
+
var TimeWindowPolicySchema = import_v49.z.object({
|
|
10658
10818
|
/** IANA timezone for the window (e.g., "Australia/Sydney") */
|
|
10659
|
-
timezone:
|
|
10819
|
+
timezone: import_v49.z.string().describe('IANA timezone, e.g., "Australia/Sydney"'),
|
|
10660
10820
|
/** Time slots when this window is active */
|
|
10661
|
-
windows:
|
|
10821
|
+
windows: import_v49.z.array(TimeWindowSlotAgentSchema),
|
|
10662
10822
|
/** Behavior for this window (optional - defaults to immediate response) */
|
|
10663
10823
|
behavior: TimeWindowBehaviorSchema.optional()
|
|
10664
10824
|
});
|
|
10665
|
-
var TimeWindowPoliciesSchema =
|
|
10825
|
+
var TimeWindowPoliciesSchema = import_v49.z.record(import_v49.z.string(), TimeWindowPolicySchema);
|
|
10666
10826
|
var TimeWindowDefaultSchema = TimeWindowBehaviorSchema.describe(
|
|
10667
10827
|
"Fallback behavior when no time window matches"
|
|
10668
10828
|
);
|
|
10669
|
-
var ResponsesBehaviorConfigSchema =
|
|
10829
|
+
var ResponsesBehaviorConfigSchema = import_v49.z.object({
|
|
10670
10830
|
/**
|
|
10671
10831
|
* Maximum immediate messages per agent run (acks, progress updates).
|
|
10672
10832
|
* @default 1
|
|
10673
10833
|
*/
|
|
10674
|
-
maxImmediate:
|
|
10834
|
+
maxImmediate: import_v49.z.number().optional(),
|
|
10675
10835
|
/**
|
|
10676
10836
|
* Maximum scheduled messages per agent run (follow-ups via sendAt).
|
|
10677
10837
|
* @default 2
|
|
10678
10838
|
*/
|
|
10679
|
-
maxScheduled:
|
|
10839
|
+
maxScheduled: import_v49.z.number().optional(),
|
|
10680
10840
|
/**
|
|
10681
10841
|
* Maximum intermediate messages per agent run.
|
|
10682
10842
|
* Intermediate = progress updates, acknowledgments before task completion.
|
|
@@ -10684,74 +10844,74 @@ var ResponsesBehaviorConfigSchema = import_v47.z.object({
|
|
|
10684
10844
|
* @deprecated Use maxImmediate instead
|
|
10685
10845
|
* @default 2
|
|
10686
10846
|
*/
|
|
10687
|
-
maxIntermediate:
|
|
10847
|
+
maxIntermediate: import_v49.z.number().optional(),
|
|
10688
10848
|
/**
|
|
10689
10849
|
* Whether a final message is required before the run completes.
|
|
10690
10850
|
* If true and no final message is sent, the run fails.
|
|
10691
10851
|
* @default true
|
|
10692
10852
|
*/
|
|
10693
|
-
requireFinal:
|
|
10853
|
+
requireFinal: import_v49.z.boolean().optional(),
|
|
10694
10854
|
/**
|
|
10695
10855
|
* Whether the agent can schedule messages for future delivery.
|
|
10696
10856
|
* Scheduled messages typically require approval.
|
|
10697
10857
|
* @default false
|
|
10698
10858
|
*/
|
|
10699
|
-
allowSchedule:
|
|
10859
|
+
allowSchedule: import_v49.z.boolean().optional(),
|
|
10700
10860
|
/**
|
|
10701
10861
|
* Message splitting configuration.
|
|
10702
10862
|
* Controls whether and how the agent splits responses into multiple messages.
|
|
10703
10863
|
*/
|
|
10704
|
-
messageSplitting:
|
|
10864
|
+
messageSplitting: import_v49.z.object({
|
|
10705
10865
|
/**
|
|
10706
10866
|
* Whether to allow natural message splitting.
|
|
10707
10867
|
* When true, the agent may split responses into multiple messages
|
|
10708
10868
|
* when it improves conversational flow.
|
|
10709
10869
|
*/
|
|
10710
|
-
enabled:
|
|
10870
|
+
enabled: import_v49.z.boolean(),
|
|
10711
10871
|
/**
|
|
10712
10872
|
* Custom prompt to override the default message splitting guidance.
|
|
10713
10873
|
* If not provided, uses sensible defaults for when to split vs. keep together.
|
|
10714
10874
|
*/
|
|
10715
|
-
prompt:
|
|
10875
|
+
prompt: import_v49.z.string().optional()
|
|
10716
10876
|
}).optional()
|
|
10717
10877
|
});
|
|
10718
|
-
var SchedulingDelaySchema =
|
|
10878
|
+
var SchedulingDelaySchema = import_v49.z.object({
|
|
10719
10879
|
/** Time unit amount */
|
|
10720
|
-
amount:
|
|
10880
|
+
amount: import_v49.z.number(),
|
|
10721
10881
|
/** Time unit (e.g., "week", "weeks", "day", "days", "month", "months") */
|
|
10722
|
-
unit:
|
|
10882
|
+
unit: import_v49.z.string(),
|
|
10723
10883
|
/** Optional time window to constrain the delay */
|
|
10724
|
-
timeWindow:
|
|
10884
|
+
timeWindow: import_v49.z.string().optional()
|
|
10725
10885
|
});
|
|
10726
|
-
var SchedulingPatternSchema =
|
|
10886
|
+
var SchedulingPatternSchema = import_v49.z.object({
|
|
10727
10887
|
/** Trigger name for this pattern */
|
|
10728
|
-
trigger:
|
|
10888
|
+
trigger: import_v49.z.string(),
|
|
10729
10889
|
/** Human-readable description of when this pattern applies */
|
|
10730
|
-
description:
|
|
10890
|
+
description: import_v49.z.string().optional(),
|
|
10731
10891
|
/** Example user phrases that match this pattern */
|
|
10732
|
-
examples:
|
|
10892
|
+
examples: import_v49.z.array(import_v49.z.string()).optional(),
|
|
10733
10893
|
/** Default delay for this pattern */
|
|
10734
10894
|
defaultDelay: SchedulingDelaySchema.optional()
|
|
10735
10895
|
});
|
|
10736
|
-
var SchedulingBehaviorConfigSchema =
|
|
10896
|
+
var SchedulingBehaviorConfigSchema = import_v49.z.object({
|
|
10737
10897
|
/**
|
|
10738
10898
|
* Patterns that trigger scheduling suggestions.
|
|
10739
10899
|
* The agent uses these to know when to add sendAt to messages.
|
|
10740
10900
|
*/
|
|
10741
|
-
patterns:
|
|
10901
|
+
patterns: import_v49.z.array(SchedulingPatternSchema).optional(),
|
|
10742
10902
|
/**
|
|
10743
10903
|
* Default settings for scheduled messages.
|
|
10744
10904
|
*/
|
|
10745
|
-
defaults:
|
|
10905
|
+
defaults: import_v49.z.object({
|
|
10746
10906
|
/** Cancel scheduled message if user replies before send time (default: true) */
|
|
10747
|
-
cancelOnActivity:
|
|
10907
|
+
cancelOnActivity: import_v49.z.boolean().optional(),
|
|
10748
10908
|
/** Whether scheduled messages require approval (default: true) */
|
|
10749
|
-
requiresApproval:
|
|
10909
|
+
requiresApproval: import_v49.z.boolean().optional(),
|
|
10750
10910
|
/** Default time window policy to constrain all scheduled messages */
|
|
10751
|
-
timeWindow:
|
|
10911
|
+
timeWindow: import_v49.z.string().optional().describe("Time window policy name for scheduled messages")
|
|
10752
10912
|
}).optional()
|
|
10753
10913
|
});
|
|
10754
|
-
var BehaviorConfigV3Schema =
|
|
10914
|
+
var BehaviorConfigV3Schema = import_v49.z.object({
|
|
10755
10915
|
/**
|
|
10756
10916
|
* Response behavior - controls message sending via tool calls.
|
|
10757
10917
|
* When configured, agents must explicitly call system:message:send
|
|
@@ -10764,32 +10924,32 @@ var BehaviorConfigV3Schema = import_v47.z.object({
|
|
|
10764
10924
|
*/
|
|
10765
10925
|
scheduling: SchedulingBehaviorConfigSchema.optional()
|
|
10766
10926
|
});
|
|
10767
|
-
var PromptsConfigV3Schema =
|
|
10927
|
+
var PromptsConfigV3Schema = import_v49.z.object({
|
|
10768
10928
|
/** Main system prompt with workflow instructions */
|
|
10769
|
-
system:
|
|
10929
|
+
system: import_v49.z.string().optional(),
|
|
10770
10930
|
/** Injected during second pass when skills were loaded but tools not used */
|
|
10771
|
-
recovery:
|
|
10931
|
+
recovery: import_v49.z.string().optional(),
|
|
10772
10932
|
/** Injected during follow-up passes when context needs updating */
|
|
10773
|
-
followUp:
|
|
10933
|
+
followUp: import_v49.z.string().optional(),
|
|
10774
10934
|
/** Thread list title generation (system + user template with {{var}} placeholders) */
|
|
10775
|
-
titleEnrichment:
|
|
10776
|
-
system:
|
|
10777
|
-
user:
|
|
10935
|
+
titleEnrichment: import_v49.z.object({
|
|
10936
|
+
system: import_v49.z.string().optional(),
|
|
10937
|
+
user: import_v49.z.string().optional()
|
|
10778
10938
|
}).optional()
|
|
10779
10939
|
});
|
|
10780
|
-
var AgentYAMLV3Schema =
|
|
10781
|
-
$schema:
|
|
10782
|
-
handle:
|
|
10783
|
-
name:
|
|
10784
|
-
version:
|
|
10785
|
-
description:
|
|
10940
|
+
var AgentYAMLV3Schema = import_v49.z.object({
|
|
10941
|
+
$schema: import_v49.z.string().optional(),
|
|
10942
|
+
handle: import_v49.z.string(),
|
|
10943
|
+
name: import_v49.z.string(),
|
|
10944
|
+
version: import_v49.z.string().optional(),
|
|
10945
|
+
description: import_v49.z.string().optional(),
|
|
10786
10946
|
// Persona - Who the agent is
|
|
10787
10947
|
persona: PersonaV3Schema.optional(),
|
|
10788
10948
|
// Skills - What the agent knows how to do (skills own their tools)
|
|
10789
|
-
skills:
|
|
10949
|
+
skills: import_v49.z.array(SkillRefSchema).optional(),
|
|
10790
10950
|
// Tools - Always-available tools before any skill loads
|
|
10791
10951
|
// Examples: system:settings:business_information:get
|
|
10792
|
-
tools:
|
|
10952
|
+
tools: import_v49.z.array(AgentToolRefSchema).optional(),
|
|
10793
10953
|
/**
|
|
10794
10954
|
* Events - When the agent activates
|
|
10795
10955
|
* @deprecated Not yet implemented - this is a planned feature for event-driven agents.
|
|
@@ -10944,7 +11104,7 @@ async function loadAgentFile(filePath) {
|
|
|
10944
11104
|
if (isJson) {
|
|
10945
11105
|
rawAgent = JSON.parse(content);
|
|
10946
11106
|
} else if (isYaml) {
|
|
10947
|
-
rawAgent = (0,
|
|
11107
|
+
rawAgent = (0, import_yaml2.parse)(content);
|
|
10948
11108
|
} else {
|
|
10949
11109
|
throw new Error(
|
|
10950
11110
|
`Unsupported agent file format: ${path22.extname(absolutePath)}. Use .agent.yml or .agent.json`
|
|
@@ -12762,7 +12922,7 @@ Error: ${input.name} is required`);
|
|
|
12762
12922
|
// src/cli/commands/skills.ts
|
|
12763
12923
|
var fs24 = __toESM(require("fs"));
|
|
12764
12924
|
var path24 = __toESM(require("path"));
|
|
12765
|
-
var
|
|
12925
|
+
var import_yaml3 = require("yaml");
|
|
12766
12926
|
init_utils();
|
|
12767
12927
|
function printHelp21() {
|
|
12768
12928
|
console.log(`
|
|
@@ -12844,7 +13004,7 @@ async function loadSkillFile(filePath) {
|
|
|
12844
13004
|
}
|
|
12845
13005
|
let rawSkill;
|
|
12846
13006
|
try {
|
|
12847
|
-
rawSkill = (0,
|
|
13007
|
+
rawSkill = (0, import_yaml3.parse)(content);
|
|
12848
13008
|
} catch (err) {
|
|
12849
13009
|
throw new Error(`Failed to parse YAML: ${err instanceof Error ? err.message : String(err)}`);
|
|
12850
13010
|
}
|
|
@@ -13286,188 +13446,7 @@ async function skillsCommand(args2) {
|
|
|
13286
13446
|
var fs25 = __toESM(require("fs"));
|
|
13287
13447
|
var path25 = __toESM(require("path"));
|
|
13288
13448
|
var readline7 = __toESM(require("readline"));
|
|
13289
|
-
var import_yaml3 = require("yaml");
|
|
13290
13449
|
init_utils();
|
|
13291
|
-
|
|
13292
|
-
// src/workflows/types.ts
|
|
13293
|
-
var import_v49 = require("zod/v4");
|
|
13294
|
-
|
|
13295
|
-
// src/triggers/types.ts
|
|
13296
|
-
var import_v48 = require("zod/v4");
|
|
13297
|
-
var CRMDataSchema = import_v48.z.object({
|
|
13298
|
-
model: import_v48.z.string(),
|
|
13299
|
-
instanceId: import_v48.z.string(),
|
|
13300
|
-
data: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown())
|
|
13301
|
-
});
|
|
13302
|
-
var SenderContextSchema2 = import_v48.z.object({
|
|
13303
|
-
kind: ParticipantKindSchema,
|
|
13304
|
-
displayName: import_v48.z.string().optional(),
|
|
13305
|
-
crm: CRMDataSchema.optional()
|
|
13306
|
-
});
|
|
13307
|
-
var ThreadContextItemSchema2 = import_v48.z.object({
|
|
13308
|
-
handle: import_v48.z.string(),
|
|
13309
|
-
model: import_v48.z.string(),
|
|
13310
|
-
instanceId: import_v48.z.string(),
|
|
13311
|
-
data: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()).optional()
|
|
13312
|
-
});
|
|
13313
|
-
var ParticipantContextSchema = import_v48.z.object({
|
|
13314
|
-
id: import_v48.z.string(),
|
|
13315
|
-
kind: ParticipantKindSchema,
|
|
13316
|
-
displayName: import_v48.z.string().optional(),
|
|
13317
|
-
contactId: import_v48.z.string().optional(),
|
|
13318
|
-
memberId: import_v48.z.string().optional(),
|
|
13319
|
-
agentId: import_v48.z.string().optional(),
|
|
13320
|
-
workflowId: import_v48.z.string().optional()
|
|
13321
|
-
});
|
|
13322
|
-
var TriggerContextSchema = import_v48.z.object({
|
|
13323
|
-
// The event that triggered this
|
|
13324
|
-
event: import_v48.z.object({
|
|
13325
|
-
type: EventTypeSchema,
|
|
13326
|
-
payload: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()),
|
|
13327
|
-
participant: ParticipantContextSchema.optional()
|
|
13328
|
-
}),
|
|
13329
|
-
// Thread information
|
|
13330
|
-
thread: import_v48.z.object({
|
|
13331
|
-
id: import_v48.z.string(),
|
|
13332
|
-
title: import_v48.z.string().optional(),
|
|
13333
|
-
status: import_v48.z.string().optional(),
|
|
13334
|
-
sender: SenderContextSchema2.optional(),
|
|
13335
|
-
context: import_v48.z.record(import_v48.z.string(), CRMDataSchema).optional(),
|
|
13336
|
-
participants: import_v48.z.array(ParticipantContextSchema).optional()
|
|
13337
|
-
}),
|
|
13338
|
-
// Workplace info
|
|
13339
|
-
workplace: import_v48.z.object({
|
|
13340
|
-
id: import_v48.z.string(),
|
|
13341
|
-
name: import_v48.z.string().optional(),
|
|
13342
|
-
settings: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()).optional()
|
|
13343
|
-
})
|
|
13344
|
-
});
|
|
13345
|
-
var InputMappingSchema = import_v48.z.record(import_v48.z.string(), import_v48.z.string());
|
|
13346
|
-
var EventConditionsSchema = import_v48.z.record(import_v48.z.string(), import_v48.z.string());
|
|
13347
|
-
var TriggerConfigSchema = import_v48.z.object({
|
|
13348
|
-
id: import_v48.z.string(),
|
|
13349
|
-
workflowId: import_v48.z.string(),
|
|
13350
|
-
workflowVersionId: import_v48.z.string().optional(),
|
|
13351
|
-
workplaceId: import_v48.z.string(),
|
|
13352
|
-
handle: import_v48.z.string(),
|
|
13353
|
-
// Input mappings: how to resolve workflow inputs from thread context
|
|
13354
|
-
inputMappings: InputMappingSchema.optional(),
|
|
13355
|
-
// Event conditions: additional workplace-specific conditions
|
|
13356
|
-
eventConditions: EventConditionsSchema.optional(),
|
|
13357
|
-
// Workplace-specific config overrides
|
|
13358
|
-
config: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()).optional(),
|
|
13359
|
-
// Trigger type and status
|
|
13360
|
-
type: import_v48.z.string().optional(),
|
|
13361
|
-
isEnabled: import_v48.z.boolean().optional()
|
|
13362
|
-
});
|
|
13363
|
-
var ResolvedTriggerSchema = import_v48.z.object({
|
|
13364
|
-
trigger: TriggerConfigSchema,
|
|
13365
|
-
workflow: import_v48.z.object({
|
|
13366
|
-
id: import_v48.z.string(),
|
|
13367
|
-
handle: import_v48.z.string(),
|
|
13368
|
-
name: import_v48.z.string().optional(),
|
|
13369
|
-
inputs: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()).optional(),
|
|
13370
|
-
events: import_v48.z.object({
|
|
13371
|
-
subscribes: import_v48.z.array(EventTypeSchema).optional(),
|
|
13372
|
-
condition: import_v48.z.string().optional()
|
|
13373
|
-
}).optional()
|
|
13374
|
-
}),
|
|
13375
|
-
inputs: import_v48.z.record(import_v48.z.string(), import_v48.z.unknown()),
|
|
13376
|
-
context: TriggerContextSchema
|
|
13377
|
-
});
|
|
13378
|
-
var WorkflowInputDefinitionSchema = import_v48.z.object({
|
|
13379
|
-
type: import_v48.z.string(),
|
|
13380
|
-
required: import_v48.z.boolean().optional(),
|
|
13381
|
-
description: import_v48.z.string().optional(),
|
|
13382
|
-
default: import_v48.z.unknown().optional()
|
|
13383
|
-
});
|
|
13384
|
-
var WorkflowInputSchemaSchema = import_v48.z.record(import_v48.z.string(), WorkflowInputDefinitionSchema);
|
|
13385
|
-
|
|
13386
|
-
// src/workflows/types.ts
|
|
13387
|
-
var WorkflowInputSchema = import_v49.z.object({
|
|
13388
|
-
type: import_v49.z.string(),
|
|
13389
|
-
required: import_v49.z.boolean().optional().default(false),
|
|
13390
|
-
description: import_v49.z.string().optional(),
|
|
13391
|
-
default: import_v49.z.unknown().optional()
|
|
13392
|
-
});
|
|
13393
|
-
var WorkflowStepInputSchema = import_v49.z.union([import_v49.z.string(), import_v49.z.number(), import_v49.z.boolean(), import_v49.z.record(import_v49.z.string(), import_v49.z.unknown())]);
|
|
13394
|
-
var WorkflowStepSchema = import_v49.z.object({
|
|
13395
|
-
// Service and command
|
|
13396
|
-
service: import_v49.z.string(),
|
|
13397
|
-
cmd: import_v49.z.string(),
|
|
13398
|
-
// Dependencies
|
|
13399
|
-
needs: import_v49.z.array(import_v49.z.string()).optional(),
|
|
13400
|
-
// Inputs (Liquid templates supported)
|
|
13401
|
-
inputs: import_v49.z.record(import_v49.z.string(), WorkflowStepInputSchema).optional(),
|
|
13402
|
-
// Conditional execution
|
|
13403
|
-
condition: import_v49.z.string().optional(),
|
|
13404
|
-
// Retry configuration
|
|
13405
|
-
retry: import_v49.z.object({
|
|
13406
|
-
attempts: import_v49.z.number().optional(),
|
|
13407
|
-
backoff: import_v49.z.enum(["linear", "exponential"]).optional()
|
|
13408
|
-
}).optional(),
|
|
13409
|
-
// Timeout
|
|
13410
|
-
timeout: import_v49.z.string().optional()
|
|
13411
|
-
});
|
|
13412
|
-
var WorkflowRuntimeSchema = import_v49.z.object({
|
|
13413
|
-
durable: import_v49.z.boolean().optional().default(true),
|
|
13414
|
-
timeout: import_v49.z.string().optional(),
|
|
13415
|
-
retry: import_v49.z.object({
|
|
13416
|
-
attempts: import_v49.z.number().optional(),
|
|
13417
|
-
backoff: import_v49.z.enum(["linear", "exponential"]).optional()
|
|
13418
|
-
}).optional()
|
|
13419
|
-
});
|
|
13420
|
-
var WorkflowYAMLSchema = import_v49.z.object({
|
|
13421
|
-
// Schema version
|
|
13422
|
-
$schema: import_v49.z.string().optional(),
|
|
13423
|
-
// Identity
|
|
13424
|
-
handle: import_v49.z.string(),
|
|
13425
|
-
name: import_v49.z.string(),
|
|
13426
|
-
version: import_v49.z.string().optional(),
|
|
13427
|
-
description: import_v49.z.string().optional(),
|
|
13428
|
-
// Inputs this workflow needs (portable, declared in YAML)
|
|
13429
|
-
inputs: import_v49.z.record(import_v49.z.string(), WorkflowInputSchema).optional(),
|
|
13430
|
-
// Event subscriptions and conditions
|
|
13431
|
-
events: EventsConfigSchema.optional(),
|
|
13432
|
-
// Deterministic steps
|
|
13433
|
-
steps: import_v49.z.record(import_v49.z.string(), WorkflowStepSchema),
|
|
13434
|
-
// Runtime configuration
|
|
13435
|
-
runtime: WorkflowRuntimeSchema.optional()
|
|
13436
|
-
});
|
|
13437
|
-
var WorkflowMetadataSchema = import_v49.z.object({
|
|
13438
|
-
handle: import_v49.z.string(),
|
|
13439
|
-
name: import_v49.z.string(),
|
|
13440
|
-
version: import_v49.z.string().optional(),
|
|
13441
|
-
description: import_v49.z.string().optional(),
|
|
13442
|
-
inputs: import_v49.z.record(import_v49.z.string(), WorkflowInputDefinitionSchema).optional(),
|
|
13443
|
-
events: EventsConfigSchema.optional()
|
|
13444
|
-
});
|
|
13445
|
-
var WorkflowExecutionStatusSchema = import_v49.z.enum([
|
|
13446
|
-
"PENDING",
|
|
13447
|
-
"RUNNING",
|
|
13448
|
-
"COMPLETED",
|
|
13449
|
-
"FAILED",
|
|
13450
|
-
"CANCELLED",
|
|
13451
|
-
"WAITING"
|
|
13452
|
-
]);
|
|
13453
|
-
var WorkflowExecutionResultSchema = import_v49.z.object({
|
|
13454
|
-
status: WorkflowExecutionStatusSchema,
|
|
13455
|
-
outputs: import_v49.z.record(import_v49.z.string(), import_v49.z.unknown()).optional(),
|
|
13456
|
-
error: import_v49.z.string().optional(),
|
|
13457
|
-
startedAt: import_v49.z.string().datetime().optional(),
|
|
13458
|
-
completedAt: import_v49.z.string().datetime().optional(),
|
|
13459
|
-
cancelledAt: import_v49.z.string().datetime().optional(),
|
|
13460
|
-
cancelReason: import_v49.z.string().optional()
|
|
13461
|
-
});
|
|
13462
|
-
function validateWorkflowYAML(workflow) {
|
|
13463
|
-
const result = WorkflowYAMLSchema.safeParse(workflow);
|
|
13464
|
-
if (result.success) {
|
|
13465
|
-
return { success: true, data: result.data };
|
|
13466
|
-
}
|
|
13467
|
-
return { success: false, error: result.error };
|
|
13468
|
-
}
|
|
13469
|
-
|
|
13470
|
-
// src/cli/commands/workflows.ts
|
|
13471
13450
|
function printHelp22() {
|
|
13472
13451
|
console.log(`
|
|
13473
13452
|
skedyul workflows - Manage workplace workflows
|
|
@@ -13541,13 +13520,6 @@ function ensureAuth5() {
|
|
|
13541
13520
|
}
|
|
13542
13521
|
return { token: credentials.token, serverUrl: getServerUrl() };
|
|
13543
13522
|
}
|
|
13544
|
-
async function getWorkplaceToken7(workplaceSubdomain, serverUrl, cliToken) {
|
|
13545
|
-
return callCliApi(
|
|
13546
|
-
{ serverUrl, token: cliToken },
|
|
13547
|
-
"/workplace-token",
|
|
13548
|
-
{ workplaceSubdomain }
|
|
13549
|
-
);
|
|
13550
|
-
}
|
|
13551
13523
|
async function loadWorkflowFile(filePath) {
|
|
13552
13524
|
const absolutePath = path25.resolve(filePath);
|
|
13553
13525
|
if (!fs25.existsSync(absolutePath)) {
|
|
@@ -13558,19 +13530,7 @@ async function loadWorkflowFile(filePath) {
|
|
|
13558
13530
|
if (ext !== ".yml" && ext !== ".yaml") {
|
|
13559
13531
|
throw new Error("Workflow file must be a .yml or .yaml file");
|
|
13560
13532
|
}
|
|
13561
|
-
|
|
13562
|
-
try {
|
|
13563
|
-
rawWorkflow = (0, import_yaml3.parse)(content);
|
|
13564
|
-
} catch (err) {
|
|
13565
|
-
throw new Error(`Failed to parse YAML: ${err instanceof Error ? err.message : String(err)}`);
|
|
13566
|
-
}
|
|
13567
|
-
const validation = validateWorkflowYAML(rawWorkflow);
|
|
13568
|
-
if (!validation.success) {
|
|
13569
|
-
const errorMessages = validation.error.issues.map((e) => ` - ${String(e.path.join(".")) || "(root)"}: ${e.message}`).join("\n");
|
|
13570
|
-
throw new Error(`Workflow validation failed:
|
|
13571
|
-
${errorMessages}`);
|
|
13572
|
-
}
|
|
13573
|
-
return { content };
|
|
13533
|
+
return validateWorkflowContent(content);
|
|
13574
13534
|
}
|
|
13575
13535
|
function parseInputFlags(flags) {
|
|
13576
13536
|
const inputs = {};
|
|
@@ -13606,30 +13566,21 @@ async function handleList5(args2) {
|
|
|
13606
13566
|
console.error("Error: --workplace (-w) is required");
|
|
13607
13567
|
process.exit(1);
|
|
13608
13568
|
}
|
|
13609
|
-
const
|
|
13610
|
-
const
|
|
13611
|
-
const result = await callCliApi(
|
|
13612
|
-
{ serverUrl, token },
|
|
13613
|
-
"/workflows",
|
|
13614
|
-
void 0,
|
|
13615
|
-
{ method: "GET", query: { workplaceId: workplaceToken.workplaceId } }
|
|
13616
|
-
);
|
|
13617
|
-
if (!result.success) {
|
|
13618
|
-
throw new Error(result.error || "Failed to list workflows");
|
|
13619
|
-
}
|
|
13569
|
+
const ctx = ensureAuth5();
|
|
13570
|
+
const listed = await listWorkflows(ctx, workplace);
|
|
13620
13571
|
if (jsonOutput) {
|
|
13621
|
-
console.log(JSON.stringify(
|
|
13572
|
+
console.log(JSON.stringify(listed, null, 2));
|
|
13622
13573
|
return;
|
|
13623
13574
|
}
|
|
13624
13575
|
console.log("");
|
|
13625
13576
|
console.log(`Workflows in ${workplace}`);
|
|
13626
13577
|
console.log("");
|
|
13627
|
-
if (
|
|
13578
|
+
if (listed.length === 0) {
|
|
13628
13579
|
console.log(" No workflows found.");
|
|
13629
13580
|
} else {
|
|
13630
13581
|
console.log(" Handle Name Active");
|
|
13631
13582
|
console.log(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 \u2500\u2500\u2500\u2500\u2500\u2500\u2500");
|
|
13632
|
-
for (const workflow of
|
|
13583
|
+
for (const workflow of listed) {
|
|
13633
13584
|
const handle = workflow.handle.slice(0, 26).padEnd(26);
|
|
13634
13585
|
const name = workflow.name.slice(0, 28).padEnd(28);
|
|
13635
13586
|
const active = workflow.triggerVersion !== null ? `v${workflow.triggerVersion}` : "-";
|
|
@@ -13647,25 +13598,12 @@ async function handleGet4(args2) {
|
|
|
13647
13598
|
console.error("Error: handle and --workplace are required");
|
|
13648
13599
|
process.exit(1);
|
|
13649
13600
|
}
|
|
13650
|
-
const
|
|
13651
|
-
const
|
|
13652
|
-
const result = await callCliApi(
|
|
13653
|
-
{ serverUrl, token },
|
|
13654
|
-
"/workflows",
|
|
13655
|
-
void 0,
|
|
13656
|
-
{
|
|
13657
|
-
method: "GET",
|
|
13658
|
-
query: { workplaceId: workplaceToken.workplaceId, handle }
|
|
13659
|
-
}
|
|
13660
|
-
);
|
|
13661
|
-
if (!result.success) {
|
|
13662
|
-
throw new Error(result.error || "Failed to get workflow");
|
|
13663
|
-
}
|
|
13601
|
+
const ctx = ensureAuth5();
|
|
13602
|
+
const workflow = await getWorkflow(ctx, workplace, handle);
|
|
13664
13603
|
if (jsonOutput) {
|
|
13665
|
-
console.log(JSON.stringify(
|
|
13604
|
+
console.log(JSON.stringify(workflow, null, 2));
|
|
13666
13605
|
return;
|
|
13667
13606
|
}
|
|
13668
|
-
const workflow = result.workflow;
|
|
13669
13607
|
console.log("");
|
|
13670
13608
|
console.log(`Workflow: ${workflow.name}`);
|
|
13671
13609
|
console.log("");
|
|
@@ -13699,29 +13637,12 @@ async function handleVersions3(args2) {
|
|
|
13699
13637
|
console.error("Error: handle and --workplace are required");
|
|
13700
13638
|
process.exit(1);
|
|
13701
13639
|
}
|
|
13702
|
-
const
|
|
13703
|
-
const
|
|
13704
|
-
const result = await callCliApi(
|
|
13705
|
-
{ serverUrl, token },
|
|
13706
|
-
"/workflows",
|
|
13707
|
-
void 0,
|
|
13708
|
-
{
|
|
13709
|
-
method: "GET",
|
|
13710
|
-
query: {
|
|
13711
|
-
workplaceId: workplaceToken.workplaceId,
|
|
13712
|
-
handle,
|
|
13713
|
-
action: "versions"
|
|
13714
|
-
}
|
|
13715
|
-
}
|
|
13716
|
-
);
|
|
13717
|
-
if (!result.success) {
|
|
13718
|
-
throw new Error(result.error || "Failed to list versions");
|
|
13719
|
-
}
|
|
13640
|
+
const ctx = ensureAuth5();
|
|
13641
|
+
const versions = await listWorkflowVersions(ctx, workplace, handle);
|
|
13720
13642
|
if (jsonOutput) {
|
|
13721
|
-
console.log(JSON.stringify(
|
|
13643
|
+
console.log(JSON.stringify(versions, null, 2));
|
|
13722
13644
|
return;
|
|
13723
13645
|
}
|
|
13724
|
-
const versions = result.workflow.versions ?? [];
|
|
13725
13646
|
console.log("");
|
|
13726
13647
|
console.log(`Versions for ${handle}`);
|
|
13727
13648
|
console.log("");
|
|
@@ -13765,19 +13686,11 @@ async function handleDeploy3(args2) {
|
|
|
13765
13686
|
}
|
|
13766
13687
|
process.exit(1);
|
|
13767
13688
|
}
|
|
13768
|
-
const
|
|
13769
|
-
const
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
{
|
|
13774
|
-
action: "deploy",
|
|
13775
|
-
workplaceId: workplaceToken.workplaceId,
|
|
13776
|
-
yamlContent: content,
|
|
13777
|
-
publish: !draft,
|
|
13778
|
-
versionLabel
|
|
13779
|
-
}
|
|
13780
|
-
);
|
|
13689
|
+
const ctx = ensureAuth5();
|
|
13690
|
+
const result = await deployWorkflow(ctx, workplace, content, {
|
|
13691
|
+
publish: !draft,
|
|
13692
|
+
versionLabel
|
|
13693
|
+
});
|
|
13781
13694
|
if (!result.success) {
|
|
13782
13695
|
const message = result.error || "Deploy failed";
|
|
13783
13696
|
if (jsonOutput) {
|
|
@@ -13850,17 +13763,8 @@ async function handleValidate(args2) {
|
|
|
13850
13763
|
}
|
|
13851
13764
|
return;
|
|
13852
13765
|
}
|
|
13853
|
-
const
|
|
13854
|
-
const
|
|
13855
|
-
const result = await callCliApi(
|
|
13856
|
-
{ serverUrl, token },
|
|
13857
|
-
"/workflows",
|
|
13858
|
-
{
|
|
13859
|
-
action: "validate",
|
|
13860
|
-
workplaceId: workplaceToken.workplaceId,
|
|
13861
|
-
yamlContent: content
|
|
13862
|
-
}
|
|
13863
|
-
);
|
|
13766
|
+
const ctx = ensureAuth5();
|
|
13767
|
+
const result = await validateWorkflow(ctx, workplace, content);
|
|
13864
13768
|
if (!result.valid) {
|
|
13865
13769
|
if (jsonOutput) {
|
|
13866
13770
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -13893,21 +13797,12 @@ async function handlePull2(args2) {
|
|
|
13893
13797
|
console.error("Error: handle and --workplace are required");
|
|
13894
13798
|
process.exit(1);
|
|
13895
13799
|
}
|
|
13896
|
-
const
|
|
13897
|
-
const
|
|
13898
|
-
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
void 0
|
|
13902
|
-
{
|
|
13903
|
-
method: "GET",
|
|
13904
|
-
query: {
|
|
13905
|
-
workplaceId: workplaceToken.workplaceId,
|
|
13906
|
-
handle,
|
|
13907
|
-
action: "pull",
|
|
13908
|
-
version: version !== void 0 ? String(version) : void 0
|
|
13909
|
-
}
|
|
13910
|
-
}
|
|
13800
|
+
const ctx = ensureAuth5();
|
|
13801
|
+
const result = await pullWorkflow(
|
|
13802
|
+
ctx,
|
|
13803
|
+
workplace,
|
|
13804
|
+
handle,
|
|
13805
|
+
version !== void 0 ? Number(version) : void 0
|
|
13911
13806
|
);
|
|
13912
13807
|
if (jsonOutput) {
|
|
13913
13808
|
console.log(JSON.stringify(result, null, 2));
|
|
@@ -13932,18 +13827,8 @@ async function handlePublish3(args2) {
|
|
|
13932
13827
|
console.error("Error: --version must be a number");
|
|
13933
13828
|
process.exit(1);
|
|
13934
13829
|
}
|
|
13935
|
-
const
|
|
13936
|
-
const
|
|
13937
|
-
const result = await callCliApi(
|
|
13938
|
-
{ serverUrl, token },
|
|
13939
|
-
"/workflows",
|
|
13940
|
-
{
|
|
13941
|
-
action: "publish",
|
|
13942
|
-
workplaceId: workplaceToken.workplaceId,
|
|
13943
|
-
handle,
|
|
13944
|
-
version: versionNumber
|
|
13945
|
-
}
|
|
13946
|
-
);
|
|
13830
|
+
const ctx = ensureAuth5();
|
|
13831
|
+
const result = await publishWorkflow(ctx, workplace, handle, versionNumber);
|
|
13947
13832
|
if (jsonOutput) {
|
|
13948
13833
|
console.log(JSON.stringify(result, null, 2));
|
|
13949
13834
|
return;
|
|
@@ -13983,17 +13868,9 @@ async function promptForMissingInputs(schema, inputs) {
|
|
|
13983
13868
|
}
|
|
13984
13869
|
return resolved;
|
|
13985
13870
|
}
|
|
13986
|
-
async function waitForWorkflowRun(
|
|
13871
|
+
async function waitForWorkflowRun(ctx, workplace, workflowRunId) {
|
|
13987
13872
|
while (true) {
|
|
13988
|
-
const status = await
|
|
13989
|
-
{ serverUrl, token },
|
|
13990
|
-
"/workflows/run",
|
|
13991
|
-
void 0,
|
|
13992
|
-
{
|
|
13993
|
-
method: "GET",
|
|
13994
|
-
query: { workplaceId, workflowRunId }
|
|
13995
|
-
}
|
|
13996
|
-
);
|
|
13873
|
+
const status = await getWorkflowRun(ctx, workplace, workflowRunId);
|
|
13997
13874
|
if (!status.success) {
|
|
13998
13875
|
throw new Error(status.error || "Failed to fetch workflow run status");
|
|
13999
13876
|
}
|
|
@@ -14036,8 +13913,7 @@ async function handleRun(args2) {
|
|
|
14036
13913
|
console.error("Error: handle and --workplace are required");
|
|
14037
13914
|
process.exit(1);
|
|
14038
13915
|
}
|
|
14039
|
-
const
|
|
14040
|
-
const workplaceToken = await getWorkplaceToken7(workplace, serverUrl, token);
|
|
13916
|
+
const ctx = ensureAuth5();
|
|
14041
13917
|
let inputs;
|
|
14042
13918
|
try {
|
|
14043
13919
|
inputs = parseInputFlags(flags);
|
|
@@ -14046,18 +13922,11 @@ async function handleRun(args2) {
|
|
|
14046
13922
|
console.error(`Error: ${message}`);
|
|
14047
13923
|
process.exit(1);
|
|
14048
13924
|
}
|
|
14049
|
-
const schema = await
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
method: "GET",
|
|
14055
|
-
query: {
|
|
14056
|
-
workplaceId: workplaceToken.workplaceId,
|
|
14057
|
-
handle,
|
|
14058
|
-
version: version !== void 0 ? String(version) : void 0
|
|
14059
|
-
}
|
|
14060
|
-
}
|
|
13925
|
+
const schema = await getWorkflowSchema(
|
|
13926
|
+
ctx,
|
|
13927
|
+
workplace,
|
|
13928
|
+
handle,
|
|
13929
|
+
version !== void 0 ? Number(version) : void 0
|
|
14061
13930
|
);
|
|
14062
13931
|
if (schema.error) {
|
|
14063
13932
|
throw new Error(schema.error);
|
|
@@ -14069,16 +13938,10 @@ async function handleRun(args2) {
|
|
|
14069
13938
|
console.error(`Error: ${message}`);
|
|
14070
13939
|
process.exit(1);
|
|
14071
13940
|
}
|
|
14072
|
-
const runResult = await
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
workplaceId: workplaceToken.workplaceId,
|
|
14077
|
-
handle,
|
|
14078
|
-
version: version !== void 0 ? Number(version) : void 0,
|
|
14079
|
-
inputs
|
|
14080
|
-
}
|
|
14081
|
-
);
|
|
13941
|
+
const runResult = await runWorkflow(ctx, workplace, handle, {
|
|
13942
|
+
version: version !== void 0 ? Number(version) : void 0,
|
|
13943
|
+
inputs
|
|
13944
|
+
});
|
|
14082
13945
|
if (!runResult.success) {
|
|
14083
13946
|
throw new Error(runResult.error || "Failed to start workflow run");
|
|
14084
13947
|
}
|
|
@@ -14094,9 +13957,8 @@ async function handleRun(args2) {
|
|
|
14094
13957
|
}
|
|
14095
13958
|
if (wait) {
|
|
14096
13959
|
const finalStatus = await waitForWorkflowRun(
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
workplaceToken.workplaceId,
|
|
13960
|
+
ctx,
|
|
13961
|
+
workplace,
|
|
14100
13962
|
runResult.workflowRunId
|
|
14101
13963
|
);
|
|
14102
13964
|
if (jsonOutput) {
|
|
@@ -14197,7 +14059,7 @@ Notes:
|
|
|
14197
14059
|
- Create EventSubscription rows in the UI to test workflow dispatch
|
|
14198
14060
|
`);
|
|
14199
14061
|
}
|
|
14200
|
-
async function
|
|
14062
|
+
async function getWorkplaceToken7(workplaceSubdomain, serverUrl, cliToken) {
|
|
14201
14063
|
return callCliApi(
|
|
14202
14064
|
{ serverUrl, token: cliToken },
|
|
14203
14065
|
"/workplace-token",
|
|
@@ -14257,7 +14119,7 @@ async function eventCommand(args2) {
|
|
|
14257
14119
|
const serverUrl = getServerUrl();
|
|
14258
14120
|
let workplaceToken;
|
|
14259
14121
|
try {
|
|
14260
|
-
workplaceToken = await
|
|
14122
|
+
workplaceToken = await getWorkplaceToken7(
|
|
14261
14123
|
workplaceSubdomain,
|
|
14262
14124
|
serverUrl,
|
|
14263
14125
|
credentials.token
|