skedyul 1.2.19 → 1.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/cli/index.js +512 -731
  2. package/dist/config/app-config.d.ts +26 -2
  3. package/dist/config/index.d.ts +1 -2
  4. package/dist/config/types/env.d.ts +8 -2
  5. package/dist/config/types/form.d.ts +10 -6
  6. package/dist/config/types/index.d.ts +0 -1
  7. package/dist/config/types/page.d.ts +2 -2
  8. package/dist/config/types/webhook.d.ts +2 -1
  9. package/dist/dedicated/server.js +503 -766
  10. package/dist/esm/index.mjs +503 -720
  11. package/dist/index.d.ts +2 -3
  12. package/dist/index.js +503 -722
  13. package/dist/server/config-serializer.d.ts +12 -0
  14. package/dist/server/dedicated.d.ts +3 -2
  15. package/dist/server/handlers/index.d.ts +12 -0
  16. package/dist/server/handlers/install-handler.d.ts +9 -0
  17. package/dist/server/handlers/oauth-callback-handler.d.ts +9 -0
  18. package/dist/server/handlers/provision-handler.d.ts +9 -0
  19. package/dist/server/handlers/types.d.ts +101 -0
  20. package/dist/server/handlers/uninstall-handler.d.ts +9 -0
  21. package/dist/server/handlers/webhook-handler.d.ts +28 -0
  22. package/dist/server/index.d.ts +15 -6
  23. package/dist/server/serverless.d.ts +3 -2
  24. package/dist/server/startup-logger.d.ts +3 -2
  25. package/dist/server/tool-handler.d.ts +1 -1
  26. package/dist/server/utils/http.d.ts +3 -2
  27. package/dist/server.d.ts +1 -1
  28. package/dist/server.js +503 -766
  29. package/dist/serverless/server.mjs +503 -744
  30. package/dist/types/handlers.d.ts +6 -24
  31. package/dist/types/index.d.ts +4 -4
  32. package/dist/types/server.d.ts +1 -34
  33. package/dist/types/shared.d.ts +5 -0
  34. package/dist/types/tool.d.ts +5 -7
  35. package/dist/types/webhook.d.ts +14 -6
  36. package/package.json +1 -1
  37. package/dist/config/resolve.d.ts +0 -27
  38. package/dist/config/types/compute.d.ts +0 -9
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Config serialization utilities for the /config endpoint.
3
+ */
4
+ import type { SkedyulConfig, SerializableSkedyulConfig } from '../config/app-config';
5
+ /**
6
+ * Serializes a SkedyulConfig into a SerializableSkedyulConfig.
7
+ * Used by both serverless and dedicated servers for the /config endpoint.
8
+ *
9
+ * Note: provision and agents are included if they are direct objects (not promises).
10
+ * Promise-based configs from skedyul.config.ts are resolved at build time, not runtime.
11
+ */
12
+ export declare function serializeConfig(config: SkedyulConfig): SerializableSkedyulConfig;
@@ -1,7 +1,8 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { SkedyulServerConfig, SkedyulServerInstance, ToolCallResponse, ToolMetadata, ToolRegistry, WebhookRegistry } from '../types';
2
+ import type { SkedyulServerInstance, ToolCallResponse, ToolMetadata } from '../types';
3
+ import type { RuntimeSkedyulConfig } from './index';
3
4
  import type { RequestState } from './types';
4
5
  /**
5
6
  * Creates a dedicated (long-running HTTP) server instance
6
7
  */
7
- export declare function createDedicatedServerInstance(config: SkedyulServerConfig, tools: ToolMetadata[], callTool: (nameRaw: unknown, argsRaw: unknown) => Promise<ToolCallResponse>, state: RequestState, mcpServer: McpServer, registry: ToolRegistry, webhookRegistry?: WebhookRegistry): SkedyulServerInstance;
8
+ export declare function createDedicatedServerInstance(config: RuntimeSkedyulConfig, tools: ToolMetadata[], callTool: (toolNameInput: unknown, toolArgsInput: unknown) => Promise<ToolCallResponse>, state: RequestState, mcpServer: McpServer): SkedyulServerInstance;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Shared handlers for serverless and dedicated servers.
3
+ *
4
+ * These handlers contain the core business logic that is identical
5
+ * between serverless (Lambda) and dedicated (HTTP) server modes.
6
+ */
7
+ export * from './types';
8
+ export { handleInstall } from './install-handler';
9
+ export { handleUninstall } from './uninstall-handler';
10
+ export { handleProvision } from './provision-handler';
11
+ export { handleOAuthCallback } from './oauth-callback-handler';
12
+ export { parseWebhookRequest, executeWebhookHandler, isMethodAllowed, type ParsedWebhookData, } from './webhook-handler';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Install handler - shared implementation for serverless and dedicated servers.
3
+ */
4
+ import type { ServerHooks } from '../../types';
5
+ import type { HandlerResult, InstallRequestBody } from './types';
6
+ /**
7
+ * Handle install request.
8
+ */
9
+ export declare function handleInstall(body: InstallRequestBody, hooks: ServerHooks | undefined): Promise<HandlerResult>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * OAuth callback handler - shared implementation for serverless and dedicated servers.
3
+ */
4
+ import type { ServerHooks } from '../../types';
5
+ import type { HandlerResult } from './types';
6
+ /**
7
+ * Handle OAuth callback request.
8
+ */
9
+ export declare function handleOAuthCallback(parsedBody: unknown, hooks: ServerHooks | undefined): Promise<HandlerResult>;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Provision handler - shared implementation for serverless and dedicated servers.
3
+ */
4
+ import type { ServerHooks } from '../../types';
5
+ import type { HandlerResult, ProvisionRequestBody } from './types';
6
+ /**
7
+ * Handle provision request.
8
+ */
9
+ export declare function handleProvision(body: ProvisionRequestBody, hooks: ServerHooks | undefined): Promise<HandlerResult>;
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Shared types for handler implementations.
3
+ * These types abstract over serverless vs dedicated server differences.
4
+ */
5
+ import type { InvocationContext } from '../../types';
6
+ /**
7
+ * Generic handler result that can be converted to either serverless or HTTP response.
8
+ */
9
+ export interface HandlerResult {
10
+ status: number;
11
+ body: unknown;
12
+ headers?: Record<string, string>;
13
+ }
14
+ /**
15
+ * Common envelope format from the platform.
16
+ */
17
+ export interface HandlerEnvelope {
18
+ env: Record<string, string>;
19
+ request: RawRequest;
20
+ context?: EnvelopeContext;
21
+ invocation?: InvocationContext;
22
+ }
23
+ /**
24
+ * Raw request from envelope.
25
+ */
26
+ export interface RawRequest {
27
+ method: string;
28
+ url: string;
29
+ path: string;
30
+ headers: Record<string, string>;
31
+ query: Record<string, string>;
32
+ body: string;
33
+ }
34
+ /**
35
+ * Context from envelope.
36
+ */
37
+ export interface EnvelopeContext {
38
+ app: {
39
+ id: string;
40
+ versionId: string;
41
+ };
42
+ appInstallationId?: string | null;
43
+ workplace?: {
44
+ id: string;
45
+ subdomain: string;
46
+ } | null;
47
+ registration?: Record<string, unknown> | null;
48
+ }
49
+ /**
50
+ * Install request body format.
51
+ */
52
+ export interface InstallRequestBody {
53
+ env?: Record<string, string>;
54
+ invocation?: InvocationContext;
55
+ context?: {
56
+ app: {
57
+ id: string;
58
+ versionId: string;
59
+ handle: string;
60
+ versionHandle: string;
61
+ };
62
+ appInstallationId: string;
63
+ workplace: {
64
+ id: string;
65
+ subdomain: string;
66
+ };
67
+ };
68
+ }
69
+ /**
70
+ * Uninstall request body format.
71
+ */
72
+ export interface UninstallRequestBody {
73
+ env?: Record<string, string>;
74
+ invocation?: InvocationContext;
75
+ context?: {
76
+ app: {
77
+ id: string;
78
+ versionId: string;
79
+ handle: string;
80
+ versionHandle: string;
81
+ };
82
+ appInstallationId: string;
83
+ workplace: {
84
+ id: string;
85
+ subdomain: string;
86
+ };
87
+ };
88
+ }
89
+ /**
90
+ * Provision request body format.
91
+ */
92
+ export interface ProvisionRequestBody {
93
+ env?: Record<string, string>;
94
+ invocation?: InvocationContext;
95
+ context?: {
96
+ app: {
97
+ id: string;
98
+ versionId: string;
99
+ };
100
+ };
101
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Uninstall handler - shared implementation for serverless and dedicated servers.
3
+ */
4
+ import type { ServerHooks } from '../../types';
5
+ import type { HandlerResult, UninstallRequestBody } from './types';
6
+ /**
7
+ * Handle uninstall request.
8
+ */
9
+ export declare function handleUninstall(body: UninstallRequestBody, hooks: ServerHooks | undefined): Promise<HandlerResult>;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Webhook handler - shared implementation for serverless and dedicated servers.
3
+ */
4
+ import type { WebhookContext, WebhookRequest, InvocationContext, WebhookRegistry } from '../../types';
5
+ import type { HandlerResult } from './types';
6
+ /**
7
+ * Parsed webhook request data.
8
+ */
9
+ export interface ParsedWebhookData {
10
+ webhookRequest: WebhookRequest;
11
+ webhookContext: WebhookContext;
12
+ requestEnv: Record<string, string>;
13
+ invocation?: InvocationContext;
14
+ }
15
+ /**
16
+ * Parse webhook request from envelope or direct format.
17
+ */
18
+ export declare function parseWebhookRequest(parsedBody: unknown, method: string, url: string, path: string, headers: Record<string, string | string[] | undefined>, query: Record<string, string>, rawBody: string, appIdHeader?: string, appVersionIdHeader?: string): ParsedWebhookData | {
19
+ error: string;
20
+ };
21
+ /**
22
+ * Execute webhook handler with proper context.
23
+ */
24
+ export declare function executeWebhookHandler(handle: string, webhookRegistry: WebhookRegistry, data: ParsedWebhookData): Promise<HandlerResult>;
25
+ /**
26
+ * Check if HTTP method is allowed for webhook.
27
+ */
28
+ export declare function isMethodAllowed(webhookRegistry: WebhookRegistry, handle: string, method: string): boolean;
@@ -1,4 +1,5 @@
1
- import type { DedicatedServerInstance, ServerlessServerInstance, SkedyulServerConfig, SkedyulServerInstance, ToolRegistry, WebhookRegistry } from '../types';
1
+ import type { DedicatedServerInstance, ServerlessServerInstance, SkedyulServerInstance, ToolRegistry, WebhookRegistry } from '../types';
2
+ import type { SkedyulConfig } from '../config/app-config';
2
3
  export type { RequestState, CoreMethod, ToolCallArgs } from './types';
3
4
  export { normalizeBilling, toJsonSchema, isToolSchemaWithJson, getZodSchema, getJsonSchemaFromToolSchema, parseJsonRecord, parseNumberEnv, mergeRuntimeEnv, readRawRequestBody, parseJSONBody, sendJSON, sendHTML, getDefaultHeaders, createResponse, getListeningPort, } from './utils';
4
5
  export { handleCoreMethod } from './core-api-handler';
@@ -8,13 +9,21 @@ export { printStartupLog, padEnd } from './startup-logger';
8
9
  export { createDedicatedServerInstance } from './dedicated';
9
10
  export { createServerlessInstance } from './serverless';
10
11
  export { runWithLogContext, getLogContext, installContextLogger, uninstallContextLogger } from './context-logger';
11
- export declare function createSkedyulServer(config: SkedyulServerConfig & {
12
+ /**
13
+ * Runtime config type - SkedyulConfig with resolved registries (not promises).
14
+ * This is what server.create() expects at runtime.
15
+ */
16
+ export type RuntimeSkedyulConfig = Omit<SkedyulConfig, 'tools' | 'webhooks'> & {
17
+ tools: ToolRegistry;
18
+ webhooks?: WebhookRegistry;
19
+ };
20
+ export declare function createSkedyulServer(config: RuntimeSkedyulConfig & {
12
21
  computeLayer: 'dedicated';
13
- }, registry: ToolRegistry, webhookRegistry?: WebhookRegistry): DedicatedServerInstance;
14
- export declare function createSkedyulServer(config: SkedyulServerConfig & {
22
+ }): DedicatedServerInstance;
23
+ export declare function createSkedyulServer(config: RuntimeSkedyulConfig & {
15
24
  computeLayer: 'serverless';
16
- }, registry: ToolRegistry, webhookRegistry?: WebhookRegistry): ServerlessServerInstance;
17
- export declare function createSkedyulServer(config: SkedyulServerConfig, registry: ToolRegistry, webhookRegistry?: WebhookRegistry): SkedyulServerInstance;
25
+ }): ServerlessServerInstance;
26
+ export declare function createSkedyulServer(config: RuntimeSkedyulConfig): SkedyulServerInstance;
18
27
  export declare const server: {
19
28
  create: typeof createSkedyulServer;
20
29
  };
@@ -1,7 +1,8 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import type { SkedyulServerConfig, SkedyulServerInstance, ToolCallResponse, ToolMetadata, ToolRegistry, WebhookRegistry } from '../types';
2
+ import type { SkedyulServerInstance, ToolCallResponse, ToolMetadata } from '../types';
3
+ import type { RuntimeSkedyulConfig } from './index';
3
4
  import type { RequestState } from './types';
4
5
  /**
5
6
  * Creates a serverless (Lambda-style) server instance
6
7
  */
7
- export declare function createServerlessInstance(config: SkedyulServerConfig, tools: ToolMetadata[], callTool: (nameRaw: unknown, argsRaw: unknown) => Promise<ToolCallResponse>, state: RequestState, mcpServer: McpServer, registry: ToolRegistry, webhookRegistry?: WebhookRegistry): SkedyulServerInstance;
8
+ export declare function createServerlessInstance(config: RuntimeSkedyulConfig, tools: ToolMetadata[], callTool: (toolNameInput: unknown, toolArgsInput: unknown) => Promise<ToolCallResponse>, state: RequestState, mcpServer: McpServer): SkedyulServerInstance;
@@ -1,4 +1,5 @@
1
- import type { SkedyulServerConfig, ToolMetadata, WebhookRegistry } from '../types';
1
+ import type { ToolMetadata } from '../types';
2
+ import type { SkedyulConfig } from '../config/app-config';
2
3
  /**
3
4
  * Pad a string to the right with spaces
4
5
  */
@@ -6,4 +7,4 @@ export declare function padEnd(str: string, length: number): string;
6
7
  /**
7
8
  * Prints a styled startup log showing server configuration
8
9
  */
9
- export declare function printStartupLog(config: SkedyulServerConfig, tools: ToolMetadata[], webhookRegistry?: WebhookRegistry, port?: number): void;
10
+ export declare function printStartupLog(config: SkedyulConfig, tools: ToolMetadata[], port?: number): void;
@@ -11,4 +11,4 @@ export declare function createRequestState(maxRequests: number | null, ttlExtend
11
11
  /**
12
12
  * Creates a tool call handler function for executing tools from the registry
13
13
  */
14
- export declare function createCallToolHandler<T extends ToolRegistry>(registry: T, state: RequestState, onMaxRequests?: () => void): (nameRaw: unknown, argsRaw: unknown) => Promise<ToolCallResponse>;
14
+ export declare function createCallToolHandler<T extends ToolRegistry>(registry: T, state: RequestState, onMaxRequests?: () => void): (toolNameInput: unknown, toolArgsInput: unknown) => Promise<ToolCallResponse>;
@@ -1,5 +1,6 @@
1
1
  import http, { IncomingMessage } from 'http';
2
- import type { APIGatewayProxyResult, CorsOptions, SkedyulServerConfig } from '../../types';
2
+ import type { APIGatewayProxyResult } from '../../types';
3
+ import type { CorsOptions, SkedyulConfig } from '../../config/app-config';
3
4
  /**
4
5
  * Reads the raw request body from an IncomingMessage
5
6
  */
@@ -27,4 +28,4 @@ export declare function createResponse(statusCode: number, body: unknown, header
27
28
  /**
28
29
  * Gets the port to listen on from config or environment
29
30
  */
30
- export declare function getListeningPort(config: SkedyulServerConfig): number;
31
+ export declare function getListeningPort(config: SkedyulConfig): number;
package/dist/server.d.ts CHANGED
@@ -4,4 +4,4 @@
4
4
  * This file maintains backward compatibility while the actual implementation
5
5
  * has been split into smaller, focused modules in the server/ folder.
6
6
  */
7
- export { createSkedyulServer, server, type RequestState, type CoreMethod, type ToolCallArgs, normalizeBilling, toJsonSchema, isToolSchemaWithJson, getZodSchema, getJsonSchemaFromToolSchema, parseJsonRecord, parseNumberEnv, mergeRuntimeEnv, readRawRequestBody, parseJSONBody, sendJSON, sendHTML, getDefaultHeaders, createResponse, getListeningPort, handleCoreMethod, buildToolMetadata, createRequestState, createCallToolHandler, parseHandlerEnvelope, buildRequestFromRaw, buildRequestScopedConfig, printStartupLog, padEnd, createDedicatedServerInstance, createServerlessInstance, } from './server/index';
7
+ export { createSkedyulServer, server, type RuntimeSkedyulConfig, toJsonSchema, isToolSchemaWithJson, getZodSchema, getJsonSchemaFromToolSchema, } from './server/index';