skedyul 0.3.4 → 0.3.6

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/dist/.build-stamp CHANGED
@@ -1 +1 @@
1
- 1771566817944
1
+ 1771568589599
@@ -38,6 +38,7 @@ const z = __importStar(require("zod"));
38
38
  const fs = __importStar(require("fs"));
39
39
  const path = __importStar(require("path"));
40
40
  const utils_1 = require("../utils");
41
+ const logger_1 = require("../../server/logger");
41
42
  const auth_1 = require("../utils/auth");
42
43
  const link_1 = require("../utils/link");
43
44
  const config_1 = require("../utils/config");
@@ -278,6 +279,7 @@ async function invokeCommand(args) {
278
279
  request: { url: 'cli://invoke', params: {}, query: {} },
279
280
  env,
280
281
  mode: estimateMode ? 'estimate' : 'execute',
282
+ log: (0, logger_1.createContextLogger)(),
281
283
  };
282
284
  }
283
285
  else {
@@ -290,6 +292,7 @@ async function invokeCommand(args) {
290
292
  request: { url: 'cli://invoke', params: {}, query: {} },
291
293
  env,
292
294
  mode: estimateMode ? 'estimate' : 'execute',
295
+ log: (0, logger_1.createContextLogger)(),
293
296
  };
294
297
  }
295
298
  // Execute tool
@@ -1,3 +1,4 @@
1
+ import type { ContextLogger } from '../../server/logger';
1
2
  export type WebhookHttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
2
3
  export interface WebhookRequest {
3
4
  method: string;
@@ -15,6 +16,8 @@ export interface WebhookHandlerContext {
15
16
  subdomain: string | null;
16
17
  } | null;
17
18
  registration: Record<string, unknown>;
19
+ /** Context-aware logger that automatically includes invocation context */
20
+ log: ContextLogger;
18
21
  }
19
22
  export interface WebhookHandlerResponse {
20
23
  status: number;
package/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@ export type { InstallErrorCode } from './errors';
9
9
  export { z };
10
10
  export { workplace, communicationChannel, instance, token, file, webhook, resource, contactAssociationLink, configure, getConfig, runWithConfig, } from './core/client';
11
11
  export type { InstanceContext, InstanceData, InstanceMeta, InstancePagination, InstanceListResult, InstanceListArgs, FileUrlResponse, FileUploadParams, FileUploadResult, WebhookCreateResult, WebhookListItem, WebhookDeleteByNameOptions, WebhookListOptions, ResourceLinkParams, ResourceLinkResult, ContactAssociationLinkCreateParams, ContactAssociationLinkCreateResult, } from './core/client';
12
+ export { createContextLogger } from './server/logger';
13
+ export type { ContextLogger } from './server/logger';
12
14
  declare const _default: {
13
15
  z: typeof z;
14
16
  };
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.getRequiredInstallEnvKeys = exports.getAllEnvKeys = exports.CONFIG_FILE_NAMES = exports.validateConfig = exports.loadConfig = exports.defineConfig = exports.runWithConfig = exports.getConfig = exports.configure = exports.contactAssociationLink = exports.resource = exports.webhook = exports.file = exports.token = exports.instance = exports.communicationChannel = exports.workplace = exports.z = exports.AppAuthInvalidError = exports.ConnectionError = exports.InvalidConfigurationError = exports.AuthenticationError = exports.MissingRequiredFieldError = exports.InstallError = exports.DEFAULT_DOCKERFILE = exports.server = exports.ToolResponseMetaSchema = void 0;
17
+ exports.getRequiredInstallEnvKeys = exports.getAllEnvKeys = exports.CONFIG_FILE_NAMES = exports.validateConfig = exports.loadConfig = exports.defineConfig = exports.createContextLogger = exports.runWithConfig = exports.getConfig = exports.configure = exports.contactAssociationLink = exports.resource = exports.webhook = exports.file = exports.token = exports.instance = exports.communicationChannel = exports.workplace = exports.z = exports.AppAuthInvalidError = exports.ConnectionError = exports.InvalidConfigurationError = exports.AuthenticationError = exports.MissingRequiredFieldError = exports.InstallError = exports.DEFAULT_DOCKERFILE = exports.server = exports.ToolResponseMetaSchema = void 0;
18
18
  const v4_1 = require("zod/v4");
19
19
  Object.defineProperty(exports, "z", { enumerable: true, get: function () { return v4_1.z; } });
20
20
  __exportStar(require("./types"), exports);
@@ -45,6 +45,9 @@ Object.defineProperty(exports, "contactAssociationLink", { enumerable: true, get
45
45
  Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return client_1.configure; } });
46
46
  Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return client_1.getConfig; } });
47
47
  Object.defineProperty(exports, "runWithConfig", { enumerable: true, get: function () { return client_1.runWithConfig; } });
48
+ // Context-aware logger
49
+ var logger_1 = require("./server/logger");
50
+ Object.defineProperty(exports, "createContextLogger", { enumerable: true, get: function () { return logger_1.createContextLogger; } });
48
51
  // Default export for ESM compatibility when importing from CJS
49
52
  exports.default = { z: v4_1.z };
50
53
  var config_1 = require("./config");
@@ -13,6 +13,7 @@ const core_api_handler_1 = require("./core-api-handler");
13
13
  const handler_helpers_1 = require("./handler-helpers");
14
14
  const startup_logger_1 = require("./startup-logger");
15
15
  const context_logger_1 = require("./context-logger");
16
+ const logger_1 = require("./logger");
16
17
  const utils_1 = require("./utils");
17
18
  /**
18
19
  * Creates a dedicated (long-running HTTP) server instance
@@ -94,6 +95,7 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
94
95
  workplace: context.workplace,
95
96
  registration: context.registration ?? {},
96
97
  invocation,
98
+ log: (0, logger_1.createContextLogger)(),
97
99
  };
98
100
  }
99
101
  else {
@@ -102,6 +104,7 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
102
104
  env: envVars,
103
105
  app,
104
106
  invocation,
107
+ log: (0, logger_1.createContextLogger)(),
105
108
  };
106
109
  }
107
110
  }
@@ -125,6 +128,7 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
125
128
  webhookContext = {
126
129
  env: process.env,
127
130
  app: { id: appId, versionId: appVersionId },
131
+ log: (0, logger_1.createContextLogger)(),
128
132
  };
129
133
  }
130
134
  // Temporarily inject env into process.env for skedyul client to use
@@ -243,6 +247,7 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
243
247
  const oauthCallbackContext = {
244
248
  request: oauthRequest,
245
249
  invocation,
250
+ log: (0, logger_1.createContextLogger)(),
246
251
  };
247
252
  try {
248
253
  const oauthCallbackHook = config.hooks.oauth_callback;
@@ -298,6 +303,7 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
298
303
  appInstallationId: installBody.context.appInstallationId,
299
304
  app: installBody.context.app,
300
305
  invocation: installBody.invocation,
306
+ log: (0, logger_1.createContextLogger)(),
301
307
  };
302
308
  // Build request-scoped config for SDK access
303
309
  // Use env from request body (contains generated token from workflow)
@@ -379,6 +385,7 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
379
385
  appInstallationId: uninstallBody.context.appInstallationId,
380
386
  app: uninstallBody.context.app,
381
387
  invocation: uninstallBody.invocation,
388
+ log: (0, logger_1.createContextLogger)(),
382
389
  };
383
390
  const uninstallRequestConfig = {
384
391
  baseUrl: uninstallBody.env?.SKEDYUL_API_URL ??
@@ -447,6 +454,7 @@ function createDedicatedServerInstance(config, tools, callTool, state, mcpServer
447
454
  env: mergedEnv,
448
455
  app: provisionBody.context.app,
449
456
  invocation: provisionBody.invocation,
457
+ log: (0, logger_1.createContextLogger)(),
450
458
  };
451
459
  // Build request-scoped config for SDK access
452
460
  // Use merged env for consistency
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Context-Aware Logger
3
+ * ====================
4
+ *
5
+ * Provides a logger interface that can be attached to handler contexts.
6
+ * The logger wraps console methods, and since console.log is patched by
7
+ * context-logger.ts to inject invocation context from AsyncLocalStorage,
8
+ * all logs automatically include the context.
9
+ *
10
+ * Usage:
11
+ * context.log('Starting operation...')
12
+ * context.log.info('Info message')
13
+ * context.log.error('Error occurred', error)
14
+ */
15
+ export interface ContextLogger {
16
+ (message: string, ...args: unknown[]): void;
17
+ info: (message: string, ...args: unknown[]) => void;
18
+ warn: (message: string, ...args: unknown[]) => void;
19
+ error: (message: string, ...args: unknown[]) => void;
20
+ debug: (message: string, ...args: unknown[]) => void;
21
+ }
22
+ /**
23
+ * Creates a context logger instance.
24
+ * The logger simply wraps console methods - the AsyncLocalStorage patch
25
+ * in context-logger.ts handles injecting the invocation context automatically.
26
+ */
27
+ export declare function createContextLogger(): ContextLogger;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * Context-Aware Logger
4
+ * ====================
5
+ *
6
+ * Provides a logger interface that can be attached to handler contexts.
7
+ * The logger wraps console methods, and since console.log is patched by
8
+ * context-logger.ts to inject invocation context from AsyncLocalStorage,
9
+ * all logs automatically include the context.
10
+ *
11
+ * Usage:
12
+ * context.log('Starting operation...')
13
+ * context.log.info('Info message')
14
+ * context.log.error('Error occurred', error)
15
+ */
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createContextLogger = createContextLogger;
18
+ /**
19
+ * Creates a context logger instance.
20
+ * The logger simply wraps console methods - the AsyncLocalStorage patch
21
+ * in context-logger.ts handles injecting the invocation context automatically.
22
+ */
23
+ function createContextLogger() {
24
+ const log = ((msg, ...args) => {
25
+ console.log(msg, ...args);
26
+ });
27
+ log.info = (msg, ...args) => {
28
+ console.info(msg, ...args);
29
+ };
30
+ log.warn = (msg, ...args) => {
31
+ console.warn(msg, ...args);
32
+ };
33
+ log.error = (msg, ...args) => {
34
+ console.error(msg, ...args);
35
+ };
36
+ log.debug = (msg, ...args) => {
37
+ console.debug(msg, ...args);
38
+ };
39
+ return log;
40
+ }
@@ -8,6 +8,7 @@ const core_api_handler_1 = require("./core-api-handler");
8
8
  const handler_helpers_1 = require("./handler-helpers");
9
9
  const startup_logger_1 = require("./startup-logger");
10
10
  const context_logger_1 = require("./context-logger");
11
+ const logger_1 = require("./logger");
11
12
  const utils_1 = require("./utils");
12
13
  /**
13
14
  * Creates a serverless (Lambda-style) server instance
@@ -105,6 +106,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
105
106
  workplace: envelope.context.workplace,
106
107
  registration: envelope.context.registration ?? {},
107
108
  invocation,
109
+ log: (0, logger_1.createContextLogger)(),
108
110
  };
109
111
  }
110
112
  else {
@@ -113,6 +115,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
113
115
  env: envVars,
114
116
  app,
115
117
  invocation,
118
+ log: (0, logger_1.createContextLogger)(),
116
119
  };
117
120
  }
118
121
  }
@@ -144,6 +147,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
144
147
  webhookContext = {
145
148
  env: process.env,
146
149
  app: { id: appId, versionId: appVersionId },
150
+ log: (0, logger_1.createContextLogger)(),
147
151
  };
148
152
  }
149
153
  // Temporarily inject env into process.env for skedyul client to use
@@ -316,6 +320,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
316
320
  appInstallationId: installBody.context.appInstallationId,
317
321
  app: installBody.context.app,
318
322
  invocation: installBody.invocation,
323
+ log: (0, logger_1.createContextLogger)(),
319
324
  };
320
325
  // Build request-scoped config for SDK access
321
326
  // Use env from request body (contains generated token from workflow)
@@ -386,6 +391,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
386
391
  appInstallationId: uninstallBody.context.appInstallationId,
387
392
  app: uninstallBody.context.app,
388
393
  invocation: uninstallBody.invocation,
394
+ log: (0, logger_1.createContextLogger)(),
389
395
  };
390
396
  const uninstallRequestConfig = {
391
397
  baseUrl: uninstallBody.env?.SKEDYUL_API_URL ??
@@ -442,6 +448,7 @@ function createServerlessInstance(config, tools, callTool, state, mcpServer, reg
442
448
  const oauthCallbackContext = {
443
449
  request: oauthRequest,
444
450
  invocation,
451
+ log: (0, logger_1.createContextLogger)(),
445
452
  };
446
453
  try {
447
454
  const oauthCallbackHook = config.hooks.oauth_callback;
@@ -7,6 +7,7 @@ const utils_1 = require("./utils");
7
7
  const client_1 = require("../core/client");
8
8
  const errors_1 = require("../errors");
9
9
  const context_logger_1 = require("./context-logger");
10
+ const logger_1 = require("./logger");
10
11
  /**
11
12
  * Builds tool metadata array from a tool registry
12
13
  */
@@ -89,6 +90,8 @@ function createCallToolHandler(registry, state, onMaxRequests) {
89
90
  const trigger = rawContext.trigger || 'agent';
90
91
  // Build execution context based on trigger type
91
92
  let executionContext;
93
+ // Create context-aware logger
94
+ const log = (0, logger_1.createContextLogger)();
92
95
  if (trigger === 'provision') {
93
96
  // Provision context - no installation, no workplace
94
97
  executionContext = {
@@ -97,6 +100,7 @@ function createCallToolHandler(registry, state, onMaxRequests) {
97
100
  env: process.env,
98
101
  mode: estimateMode ? 'estimate' : 'execute',
99
102
  invocation,
103
+ log,
100
104
  };
101
105
  }
102
106
  else {
@@ -108,26 +112,26 @@ function createCallToolHandler(registry, state, onMaxRequests) {
108
112
  const modeValue = estimateMode ? 'estimate' : 'execute';
109
113
  if (trigger === 'field_change') {
110
114
  const field = rawContext.field;
111
- executionContext = { trigger: 'field_change', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, field, invocation };
115
+ executionContext = { trigger: 'field_change', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, field, invocation, log };
112
116
  }
113
117
  else if (trigger === 'page_action') {
114
118
  const page = rawContext.page;
115
- executionContext = { trigger: 'page_action', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, page, invocation };
119
+ executionContext = { trigger: 'page_action', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, page, invocation, log };
116
120
  }
117
121
  else if (trigger === 'form_submit') {
118
122
  const form = rawContext.form;
119
- executionContext = { trigger: 'form_submit', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, form, invocation };
123
+ executionContext = { trigger: 'form_submit', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, form, invocation, log };
120
124
  }
121
125
  else if (trigger === 'workflow') {
122
- executionContext = { trigger: 'workflow', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, invocation };
126
+ executionContext = { trigger: 'workflow', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, invocation, log };
123
127
  }
124
128
  else if (trigger === 'page_context') {
125
129
  // Page context trigger - similar to agent but for page context resolution
126
- executionContext = { trigger: 'agent', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, invocation };
130
+ executionContext = { trigger: 'agent', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, invocation, log };
127
131
  }
128
132
  else {
129
133
  // Default to agent
130
- executionContext = { trigger: 'agent', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, invocation };
134
+ executionContext = { trigger: 'agent', app, appInstallationId, workplace, request, env: envVars, mode: modeValue, invocation, log };
131
135
  }
132
136
  }
133
137
  // Build request-scoped config from env passed in MCP call
@@ -1,5 +1,6 @@
1
1
  import type { WebhookRequest } from './webhook';
2
2
  import type { InvocationContext } from './invocation';
3
+ import type { ContextLogger } from '../server/logger';
3
4
  export interface InstallHandlerContext {
4
5
  env: Record<string, string>;
5
6
  workplace: {
@@ -15,6 +16,8 @@ export interface InstallHandlerContext {
15
16
  };
16
17
  /** Invocation context for log traceability */
17
18
  invocation?: InvocationContext;
19
+ /** Context-aware logger that automatically includes invocation context */
20
+ log: ContextLogger;
18
21
  }
19
22
  export interface InstallHandlerResponseOAuth {
20
23
  env?: Record<string, string>;
@@ -44,6 +47,8 @@ export interface UninstallHandlerContext {
44
47
  };
45
48
  /** Invocation context for log traceability */
46
49
  invocation?: InvocationContext;
50
+ /** Context-aware logger that automatically includes invocation context */
51
+ log: ContextLogger;
47
52
  }
48
53
  export interface UninstallHandlerResult {
49
54
  cleanedWebhookIds?: string[];
@@ -54,6 +59,8 @@ export interface OAuthCallbackContext {
54
59
  request: WebhookRequest;
55
60
  /** Invocation context for log traceability */
56
61
  invocation?: InvocationContext;
62
+ /** Context-aware logger that automatically includes invocation context */
63
+ log: ContextLogger;
57
64
  }
58
65
  export interface OAuthCallbackResult {
59
66
  env?: Record<string, string>;
@@ -68,6 +75,8 @@ export interface ProvisionHandlerContext {
68
75
  };
69
76
  /** Invocation context for log traceability */
70
77
  invocation?: InvocationContext;
78
+ /** Context-aware logger that automatically includes invocation context */
79
+ log: ContextLogger;
71
80
  }
72
81
  export interface ProvisionHandlerResult {
73
82
  }
@@ -1,5 +1,6 @@
1
1
  import type { AppInfo, WorkplaceInfo, RequestInfo } from './shared';
2
2
  import type { InvocationContext } from './invocation';
3
+ import type { ContextLogger } from '../server/logger';
3
4
  /** Trigger types for tool execution */
4
5
  export type ToolTrigger = 'provision' | 'field_change' | 'page_action' | 'form_submit' | 'agent' | 'workflow' | 'page_context';
5
6
  /** Base context shared by all tool executions */
@@ -12,6 +13,8 @@ interface BaseToolContext {
12
13
  app: AppInfo;
13
14
  /** Invocation context for log traceability */
14
15
  invocation?: InvocationContext;
16
+ /** Context-aware logger that automatically includes invocation context */
17
+ log: ContextLogger;
15
18
  }
16
19
  /** Provision context - no installation, no workplace */
17
20
  export interface ProvisionToolContext extends BaseToolContext {
@@ -1,5 +1,6 @@
1
1
  import type { AppInfo, WorkplaceInfo } from './shared';
2
2
  import type { InvocationContext } from './invocation';
3
+ import type { ContextLogger } from '../server/logger';
3
4
  /**
4
5
  * Raw HTTP request shape sent over the wire in handler envelopes.
5
6
  * This is the wire format used by both webhooks and OAuth callbacks.
@@ -38,6 +39,8 @@ interface BaseWebhookContext {
38
39
  app: AppInfo;
39
40
  /** Invocation context for log traceability */
40
41
  invocation?: InvocationContext;
42
+ /** Context-aware logger that automatically includes invocation context */
43
+ log: ContextLogger;
41
44
  }
42
45
  /** Provision-level webhook context - no installation or workplace */
43
46
  export interface ProvisionWebhookContext extends BaseWebhookContext {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skedyul",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "The Skedyul SDK for Node.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",