skedyul 0.3.2 → 0.3.3

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.
@@ -1,4 +1,5 @@
1
1
  import type { WebhookRequest } from './webhook';
2
+ import type { InvocationContext } from './invocation';
2
3
  export interface InstallHandlerContext {
3
4
  env: Record<string, string>;
4
5
  workplace: {
@@ -12,6 +13,8 @@ export interface InstallHandlerContext {
12
13
  handle: string;
13
14
  versionHandle: string;
14
15
  };
16
+ /** Invocation context for log traceability */
17
+ invocation?: InvocationContext;
15
18
  }
16
19
  export interface InstallHandlerResponseOAuth {
17
20
  env?: Record<string, string>;
@@ -39,6 +42,8 @@ export interface UninstallHandlerContext {
39
42
  handle: string;
40
43
  versionHandle: string;
41
44
  };
45
+ /** Invocation context for log traceability */
46
+ invocation?: InvocationContext;
42
47
  }
43
48
  export interface UninstallHandlerResult {
44
49
  cleanedWebhookIds?: string[];
@@ -47,6 +52,8 @@ export type UninstallHandler = (ctx: UninstallHandlerContext) => Promise<Uninsta
47
52
  export interface OAuthCallbackContext {
48
53
  /** Full HTTP request from the OAuth provider */
49
54
  request: WebhookRequest;
55
+ /** Invocation context for log traceability */
56
+ invocation?: InvocationContext;
50
57
  }
51
58
  export interface OAuthCallbackResult {
52
59
  env?: Record<string, string>;
@@ -59,6 +66,8 @@ export interface ProvisionHandlerContext {
59
66
  id: string;
60
67
  versionId: string;
61
68
  };
69
+ /** Invocation context for log traceability */
70
+ invocation?: InvocationContext;
62
71
  }
63
72
  export interface ProvisionHandlerResult {
64
73
  }
@@ -5,6 +5,8 @@
5
5
  * into smaller, focused modules.
6
6
  */
7
7
  export type { AppInfo, WorkplaceInfo, RequestInfo } from './shared';
8
+ export type { InvocationType, ServerHookHandle, InvocationContext, } from './invocation';
9
+ export { createToolCallContext, createServerHookContext, createWebhookContext, createWorkflowStepContext, } from './invocation';
8
10
  export type { ToolTrigger, ProvisionToolContext, FieldChangeToolContext, PageActionToolContext, FormSubmitToolContext, AgentToolContext, WorkflowToolContext, ToolExecutionContext, } from './tool-context';
9
11
  export { isProvisionContext, isRuntimeContext } from './tool-context';
10
12
  export type { ProvisionToolInput, BillingInfo, ToolResponseMeta, ToolEffect, ToolError, ToolExecutionResult, ToolSchemaWithJson, ToolSchema, ToolHandler, ToolDefinition, ToolRegistryEntry, ToolRegistry, ToolName, ToolMetadata, ToolCallResponse, } from './tool';
@@ -6,7 +6,12 @@
6
6
  * into smaller, focused modules.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.isRuntimeWebhookContext = exports.ToolResponseMetaSchema = exports.isRuntimeContext = exports.isProvisionContext = void 0;
9
+ exports.isRuntimeWebhookContext = exports.ToolResponseMetaSchema = exports.isRuntimeContext = exports.isProvisionContext = exports.createWorkflowStepContext = exports.createWebhookContext = exports.createServerHookContext = exports.createToolCallContext = void 0;
10
+ var invocation_1 = require("./invocation");
11
+ Object.defineProperty(exports, "createToolCallContext", { enumerable: true, get: function () { return invocation_1.createToolCallContext; } });
12
+ Object.defineProperty(exports, "createServerHookContext", { enumerable: true, get: function () { return invocation_1.createServerHookContext; } });
13
+ Object.defineProperty(exports, "createWebhookContext", { enumerable: true, get: function () { return invocation_1.createWebhookContext; } });
14
+ Object.defineProperty(exports, "createWorkflowStepContext", { enumerable: true, get: function () { return invocation_1.createWorkflowStepContext; } });
10
15
  var tool_context_1 = require("./tool-context");
11
16
  Object.defineProperty(exports, "isProvisionContext", { enumerable: true, get: function () { return tool_context_1.isProvisionContext; } });
12
17
  Object.defineProperty(exports, "isRuntimeContext", { enumerable: true, get: function () { return tool_context_1.isRuntimeContext; } });
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Type of invocation that triggered the executable
3
+ */
4
+ export type InvocationType = 'tool_call' | 'server_hook' | 'workflow_step' | 'webhook';
5
+ /**
6
+ * Server hook handles for lifecycle events
7
+ */
8
+ export type ServerHookHandle = 'provision' | 'install' | 'uninstall' | 'oauth_callback';
9
+ /**
10
+ * Context for tracking how an executable was invoked.
11
+ * Used for log traceability and filtering.
12
+ */
13
+ export interface InvocationContext {
14
+ /** Unique identifier for this invocation */
15
+ invocationId: string;
16
+ /** Type of invocation */
17
+ invocationType: InvocationType;
18
+ /** Unique ID for the tool call (for tool_call invocations) */
19
+ toolCallId?: string;
20
+ /** The tool's handle for searching (e.g., "get_customers") */
21
+ toolHandle?: string;
22
+ /** Hook type: "provision", "install", "uninstall", "oauth_callback" */
23
+ serverHookHandle?: ServerHookHandle;
24
+ /** The app installation that triggered the call */
25
+ appInstallationId?: string;
26
+ /** The workflow ID (if invoked via workflow) */
27
+ workflowId?: string;
28
+ /** The workflow version ID */
29
+ workflowVersionId?: string;
30
+ /** The workflow run ID */
31
+ workflowRunId?: string;
32
+ /** The workflow step ID */
33
+ workflowStepId?: string;
34
+ }
35
+ /**
36
+ * Create an invocation context for a tool call
37
+ */
38
+ export declare function createToolCallContext(params: {
39
+ invocationId: string;
40
+ toolCallId: string;
41
+ toolHandle: string;
42
+ appInstallationId?: string;
43
+ workflowId?: string;
44
+ workflowVersionId?: string;
45
+ workflowRunId?: string;
46
+ }): InvocationContext;
47
+ /**
48
+ * Create an invocation context for a server hook
49
+ */
50
+ export declare function createServerHookContext(params: {
51
+ invocationId: string;
52
+ serverHookHandle: ServerHookHandle;
53
+ appInstallationId?: string;
54
+ }): InvocationContext;
55
+ /**
56
+ * Create an invocation context for a webhook
57
+ */
58
+ export declare function createWebhookContext(params: {
59
+ invocationId: string;
60
+ appInstallationId?: string;
61
+ }): InvocationContext;
62
+ /**
63
+ * Create an invocation context for a workflow step
64
+ */
65
+ export declare function createWorkflowStepContext(params: {
66
+ invocationId: string;
67
+ workflowId: string;
68
+ workflowVersionId: string;
69
+ workflowRunId: string;
70
+ workflowStepId?: string;
71
+ }): InvocationContext;
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ // ─────────────────────────────────────────────────────────────────────────────
3
+ // Invocation Context Types
4
+ // ─────────────────────────────────────────────────────────────────────────────
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.createToolCallContext = createToolCallContext;
7
+ exports.createServerHookContext = createServerHookContext;
8
+ exports.createWebhookContext = createWebhookContext;
9
+ exports.createWorkflowStepContext = createWorkflowStepContext;
10
+ // ─────────────────────────────────────────────────────────────────────────────
11
+ // Helper Functions for Creating Invocation Context
12
+ // ─────────────────────────────────────────────────────────────────────────────
13
+ /**
14
+ * Create an invocation context for a tool call
15
+ */
16
+ function createToolCallContext(params) {
17
+ return {
18
+ invocationId: params.invocationId,
19
+ invocationType: 'tool_call',
20
+ toolCallId: params.toolCallId,
21
+ toolHandle: params.toolHandle,
22
+ appInstallationId: params.appInstallationId,
23
+ workflowId: params.workflowId,
24
+ workflowVersionId: params.workflowVersionId,
25
+ workflowRunId: params.workflowRunId,
26
+ };
27
+ }
28
+ /**
29
+ * Create an invocation context for a server hook
30
+ */
31
+ function createServerHookContext(params) {
32
+ return {
33
+ invocationId: params.invocationId,
34
+ invocationType: 'server_hook',
35
+ serverHookHandle: params.serverHookHandle,
36
+ appInstallationId: params.appInstallationId,
37
+ };
38
+ }
39
+ /**
40
+ * Create an invocation context for a webhook
41
+ */
42
+ function createWebhookContext(params) {
43
+ return {
44
+ invocationId: params.invocationId,
45
+ invocationType: 'webhook',
46
+ appInstallationId: params.appInstallationId,
47
+ };
48
+ }
49
+ /**
50
+ * Create an invocation context for a workflow step
51
+ */
52
+ function createWorkflowStepContext(params) {
53
+ return {
54
+ invocationId: params.invocationId,
55
+ invocationType: 'workflow_step',
56
+ workflowId: params.workflowId,
57
+ workflowVersionId: params.workflowVersionId,
58
+ workflowRunId: params.workflowRunId,
59
+ workflowStepId: params.workflowStepId,
60
+ };
61
+ }
@@ -1,4 +1,5 @@
1
1
  import type { AppInfo, WorkplaceInfo, RequestInfo } from './shared';
2
+ import type { InvocationContext } from './invocation';
2
3
  /** Trigger types for tool execution */
3
4
  export type ToolTrigger = 'provision' | 'field_change' | 'page_action' | 'form_submit' | 'agent' | 'workflow' | 'page_context';
4
5
  /** Base context shared by all tool executions */
@@ -9,6 +10,8 @@ interface BaseToolContext {
9
10
  mode: 'execute' | 'estimate';
10
11
  /** App info - always present */
11
12
  app: AppInfo;
13
+ /** Invocation context for log traceability */
14
+ invocation?: InvocationContext;
12
15
  }
13
16
  /** Provision context - no installation, no workplace */
14
17
  export interface ProvisionToolContext extends BaseToolContext {
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from 'zod/v4';
2
2
  import type { ToolExecutionContext } from './tool-context';
3
3
  /**
4
4
  * Input type for Provision lifecycle tools (onProvision, onDeprovision).
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ToolResponseMetaSchema = void 0;
4
- const zod_1 = require("zod");
4
+ const v4_1 = require("zod/v4");
5
5
  // ─────────────────────────────────────────────────────────────────────────────
6
6
  // Tool Response Meta
7
7
  // ─────────────────────────────────────────────────────────────────────────────
@@ -9,11 +9,11 @@ const zod_1 = require("zod");
9
9
  * Standardized metadata for tool responses.
10
10
  * Provides consistent structure for AI evaluation, logging, and debugging.
11
11
  */
12
- exports.ToolResponseMetaSchema = zod_1.z.object({
12
+ exports.ToolResponseMetaSchema = v4_1.z.object({
13
13
  /** Whether the tool execution succeeded */
14
- success: zod_1.z.boolean(),
14
+ success: v4_1.z.boolean(),
15
15
  /** Human-readable message describing the result or error */
16
- message: zod_1.z.string(),
16
+ message: v4_1.z.string(),
17
17
  /** Name of the tool that was executed */
18
- toolName: zod_1.z.string(),
18
+ toolName: v4_1.z.string(),
19
19
  });
@@ -1,4 +1,5 @@
1
1
  import type { AppInfo, WorkplaceInfo } from './shared';
2
+ import type { InvocationContext } from './invocation';
2
3
  /**
3
4
  * Raw HTTP request shape sent over the wire in handler envelopes.
4
5
  * This is the wire format used by both webhooks and OAuth callbacks.
@@ -35,6 +36,8 @@ interface BaseWebhookContext {
35
36
  env: Record<string, string | undefined>;
36
37
  /** App info */
37
38
  app: AppInfo;
39
+ /** Invocation context for log traceability */
40
+ invocation?: InvocationContext;
38
41
  }
39
42
  /** Provision-level webhook context - no installation or workplace */
40
43
  export interface ProvisionWebhookContext extends BaseWebhookContext {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,9 +18,10 @@
18
18
  "dist"
19
19
  ],
20
20
  "scripts": {
21
- "build": "tsc --build tsconfig.json && tsc --project tsconfig.tests.json && node -e \"require('fs').mkdirSync('dist',{recursive:true}); require('fs').writeFileSync('dist/.build-stamp', String(Date.now()))\"",
21
+ "build": "tsc --build tsconfig.json && node -e \"require('fs').mkdirSync('dist',{recursive:true}); require('fs').writeFileSync('dist/.build-stamp', String(Date.now()))\"",
22
+ "db:generate": "echo 'No database generation needed for this package'",
22
23
  "dev": "npx nodemon --watch src --ext js,ts --exec \"pnpm run build\"",
23
- "test": "npm run build && node --test dist-tests/server.test.js dist-tests/cli.test.js"
24
+ "test": "tsc --project tsconfig.tests.json && node --test dist-tests/tests/server.test.js dist-tests/tests/cli.test.js"
24
25
  },
25
26
  "keywords": [
26
27
  "mcp",