skedyul 0.1.45 → 0.1.47
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 +1 -1
- package/dist/core/client.d.ts +104 -0
- package/dist/core/client.js +86 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/server.js +37 -8
- package/dist/types.d.ts +45 -1
- package/package.json +1 -1
package/dist/.build-stamp
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1768787444775
|
package/dist/core/client.d.ts
CHANGED
|
@@ -102,4 +102,108 @@ export declare const communicationChannel: {
|
|
|
102
102
|
*/
|
|
103
103
|
receiveMessage(input: ReceiveMessageInput): Promise<ReceiveMessageResponse>;
|
|
104
104
|
};
|
|
105
|
+
/**
|
|
106
|
+
* Context required for instance operations.
|
|
107
|
+
* This is typically extracted from the tool handler's context.
|
|
108
|
+
*/
|
|
109
|
+
export interface InstanceContext {
|
|
110
|
+
/** The app installation ID for scoping */
|
|
111
|
+
appInstallationId: string;
|
|
112
|
+
/** Workplace info */
|
|
113
|
+
workplace: {
|
|
114
|
+
id: string;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Metadata for an instance.
|
|
119
|
+
*/
|
|
120
|
+
export interface InstanceMeta {
|
|
121
|
+
modelId: string;
|
|
122
|
+
label?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Instance data returned from the API.
|
|
126
|
+
* Contains field handles as keys with their values.
|
|
127
|
+
*/
|
|
128
|
+
export interface InstanceData {
|
|
129
|
+
id: string;
|
|
130
|
+
_meta: InstanceMeta;
|
|
131
|
+
[fieldHandle: string]: unknown;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Pagination info for list results.
|
|
135
|
+
*/
|
|
136
|
+
export interface InstancePagination {
|
|
137
|
+
page: number;
|
|
138
|
+
total: number;
|
|
139
|
+
hasMore: boolean;
|
|
140
|
+
limit: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Result from instance.list().
|
|
144
|
+
*/
|
|
145
|
+
export interface InstanceListResult {
|
|
146
|
+
data: InstanceData[];
|
|
147
|
+
pagination: InstancePagination;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Arguments for instance.list().
|
|
151
|
+
*/
|
|
152
|
+
export interface InstanceListArgs {
|
|
153
|
+
page?: number;
|
|
154
|
+
limit?: number;
|
|
155
|
+
filters?: Record<string, unknown>;
|
|
156
|
+
}
|
|
157
|
+
export declare const instance: {
|
|
158
|
+
/**
|
|
159
|
+
* List instances of an internal model scoped by appInstallationId.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* const ctx = {
|
|
164
|
+
* appInstallationId: fieldContext.appInstallationId,
|
|
165
|
+
* workplace: fieldContext.workplace,
|
|
166
|
+
* }
|
|
167
|
+
*
|
|
168
|
+
* const { data: records, pagination } = await instance.list('compliance_record', ctx, {
|
|
169
|
+
* page: 1,
|
|
170
|
+
* limit: 10,
|
|
171
|
+
* })
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
list(modelHandle: string, ctx: InstanceContext, args?: InstanceListArgs): Promise<InstanceListResult>;
|
|
175
|
+
/**
|
|
176
|
+
* Get a single instance by ID.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const record = await instance.get('instance-id-123', ctx)
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
get(id: string, ctx: InstanceContext): Promise<InstanceData | null>;
|
|
184
|
+
/**
|
|
185
|
+
* Create a new instance of an internal model.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const newRecord = await instance.create('compliance_record', {
|
|
190
|
+
* status: 'pending',
|
|
191
|
+
* document_url: 'https://...',
|
|
192
|
+
* }, ctx)
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
create(modelHandle: string, data: Record<string, unknown>, ctx: InstanceContext): Promise<InstanceData>;
|
|
196
|
+
/**
|
|
197
|
+
* Update an existing instance.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* const updated = await instance.update('instance-id-123', {
|
|
202
|
+
* status: 'approved',
|
|
203
|
+
* bundle_sid: 'BU123456',
|
|
204
|
+
* }, ctx)
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
update(id: string, data: Record<string, unknown>, ctx: InstanceContext): Promise<InstanceData>;
|
|
208
|
+
};
|
|
105
209
|
export {};
|
package/dist/core/client.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.communicationChannel = exports.workplace = void 0;
|
|
3
|
+
exports.instance = exports.communicationChannel = exports.workplace = void 0;
|
|
4
4
|
exports.configure = configure;
|
|
5
5
|
exports.getConfig = getConfig;
|
|
6
6
|
let config = {
|
|
@@ -125,3 +125,88 @@ exports.communicationChannel = {
|
|
|
125
125
|
return payload;
|
|
126
126
|
},
|
|
127
127
|
};
|
|
128
|
+
exports.instance = {
|
|
129
|
+
/**
|
|
130
|
+
* List instances of an internal model scoped by appInstallationId.
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```ts
|
|
134
|
+
* const ctx = {
|
|
135
|
+
* appInstallationId: fieldContext.appInstallationId,
|
|
136
|
+
* workplace: fieldContext.workplace,
|
|
137
|
+
* }
|
|
138
|
+
*
|
|
139
|
+
* const { data: records, pagination } = await instance.list('compliance_record', ctx, {
|
|
140
|
+
* page: 1,
|
|
141
|
+
* limit: 10,
|
|
142
|
+
* })
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
async list(modelHandle, ctx, args) {
|
|
146
|
+
const payload = (await callCore('instance.list', {
|
|
147
|
+
modelHandle,
|
|
148
|
+
appInstallationId: ctx.appInstallationId,
|
|
149
|
+
workplaceId: ctx.workplace.id,
|
|
150
|
+
...(args?.page !== undefined ? { page: args.page } : {}),
|
|
151
|
+
...(args?.limit !== undefined ? { limit: args.limit } : {}),
|
|
152
|
+
...(args?.filters ? { filters: args.filters } : {}),
|
|
153
|
+
}));
|
|
154
|
+
return payload;
|
|
155
|
+
},
|
|
156
|
+
/**
|
|
157
|
+
* Get a single instance by ID.
|
|
158
|
+
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```ts
|
|
161
|
+
* const record = await instance.get('instance-id-123', ctx)
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
async get(id, ctx) {
|
|
165
|
+
const payload = (await callCore('instance.get', {
|
|
166
|
+
id,
|
|
167
|
+
appInstallationId: ctx.appInstallationId,
|
|
168
|
+
workplaceId: ctx.workplace.id,
|
|
169
|
+
}));
|
|
170
|
+
return payload.instance;
|
|
171
|
+
},
|
|
172
|
+
/**
|
|
173
|
+
* Create a new instance of an internal model.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* ```ts
|
|
177
|
+
* const newRecord = await instance.create('compliance_record', {
|
|
178
|
+
* status: 'pending',
|
|
179
|
+
* document_url: 'https://...',
|
|
180
|
+
* }, ctx)
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
async create(modelHandle, data, ctx) {
|
|
184
|
+
const payload = (await callCore('instance.create', {
|
|
185
|
+
modelHandle,
|
|
186
|
+
appInstallationId: ctx.appInstallationId,
|
|
187
|
+
workplaceId: ctx.workplace.id,
|
|
188
|
+
data,
|
|
189
|
+
}));
|
|
190
|
+
return payload.instance;
|
|
191
|
+
},
|
|
192
|
+
/**
|
|
193
|
+
* Update an existing instance.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* const updated = await instance.update('instance-id-123', {
|
|
198
|
+
* status: 'approved',
|
|
199
|
+
* bundle_sid: 'BU123456',
|
|
200
|
+
* }, ctx)
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
async update(id, data, ctx) {
|
|
204
|
+
const payload = (await callCore('instance.update', {
|
|
205
|
+
id,
|
|
206
|
+
appInstallationId: ctx.appInstallationId,
|
|
207
|
+
workplaceId: ctx.workplace.id,
|
|
208
|
+
data,
|
|
209
|
+
}));
|
|
210
|
+
return payload.instance;
|
|
211
|
+
},
|
|
212
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@ export * from './types';
|
|
|
3
3
|
export * from './schemas';
|
|
4
4
|
export { server } from './server';
|
|
5
5
|
export { z };
|
|
6
|
-
export { workplace, communicationChannel, configure, getConfig } from './core/client';
|
|
6
|
+
export { workplace, communicationChannel, instance, configure, getConfig, } from './core/client';
|
|
7
|
+
export type { InstanceContext, InstanceData, InstanceMeta, InstancePagination, InstanceListResult, InstanceListArgs, } from './core/client';
|
|
7
8
|
declare const _default: {
|
|
8
9
|
z: typeof z;
|
|
9
10
|
};
|
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.CONFIG_FILE_NAMES = exports.getAllEnvKeys = exports.getRequiredInstallEnvKeys = exports.validateConfig = exports.loadConfig = exports.defineConfig = exports.getConfig = exports.configure = exports.communicationChannel = exports.workplace = exports.z = exports.server = void 0;
|
|
17
|
+
exports.CONFIG_FILE_NAMES = exports.getAllEnvKeys = exports.getRequiredInstallEnvKeys = exports.validateConfig = exports.loadConfig = exports.defineConfig = exports.getConfig = exports.configure = exports.instance = exports.communicationChannel = exports.workplace = exports.z = exports.server = void 0;
|
|
18
18
|
const zod_1 = require("zod");
|
|
19
19
|
Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zod_1.z; } });
|
|
20
20
|
__exportStar(require("./types"), exports);
|
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "server", { enumerable: true, get: function () {
|
|
|
24
24
|
var client_1 = require("./core/client");
|
|
25
25
|
Object.defineProperty(exports, "workplace", { enumerable: true, get: function () { return client_1.workplace; } });
|
|
26
26
|
Object.defineProperty(exports, "communicationChannel", { enumerable: true, get: function () { return client_1.communicationChannel; } });
|
|
27
|
+
Object.defineProperty(exports, "instance", { enumerable: true, get: function () { return client_1.instance; } });
|
|
27
28
|
Object.defineProperty(exports, "configure", { enumerable: true, get: function () { return client_1.configure; } });
|
|
28
29
|
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return client_1.getConfig; } });
|
|
29
30
|
// Default export for ESM compatibility when importing from CJS
|
package/dist/server.js
CHANGED
|
@@ -310,14 +310,43 @@ function createCallToolHandler(registry, state, onMaxRequests) {
|
|
|
310
310
|
const originalEnv = { ...process.env };
|
|
311
311
|
Object.assign(process.env, requestEnv);
|
|
312
312
|
try {
|
|
313
|
-
const
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
}
|
|
313
|
+
const rawInputs = (args.inputs ?? {});
|
|
314
|
+
// Extract context from inputs if present (for field_change/page_action triggers)
|
|
315
|
+
const inputContext = rawInputs.context;
|
|
316
|
+
// Create clean inputs without the nested context
|
|
317
|
+
const cleanInputs = { ...rawInputs };
|
|
318
|
+
if (inputContext) {
|
|
319
|
+
delete cleanInputs.context;
|
|
320
|
+
}
|
|
321
|
+
// Determine trigger type from input context
|
|
322
|
+
let trigger = 'agent';
|
|
323
|
+
if (inputContext?.fieldHandle) {
|
|
324
|
+
trigger = 'field_change';
|
|
325
|
+
}
|
|
326
|
+
else if (inputContext?.fieldValues) {
|
|
327
|
+
trigger = 'page_action';
|
|
328
|
+
}
|
|
329
|
+
else if (inputContext?.trigger) {
|
|
330
|
+
trigger = inputContext.trigger;
|
|
331
|
+
}
|
|
332
|
+
// Build standardized execution context
|
|
333
|
+
const executionContext = {
|
|
334
|
+
trigger,
|
|
335
|
+
appInstallationId: inputContext?.appInstallationId,
|
|
336
|
+
workplace: inputContext?.workplace,
|
|
337
|
+
field: inputContext?.fieldHandle
|
|
338
|
+
? {
|
|
339
|
+
handle: inputContext.fieldHandle,
|
|
340
|
+
type: inputContext.fieldType,
|
|
341
|
+
pageHandle: inputContext.pageHandle,
|
|
342
|
+
}
|
|
343
|
+
: undefined,
|
|
344
|
+
fieldValues: inputContext?.fieldValues,
|
|
345
|
+
env: process.env,
|
|
346
|
+
mode: estimateMode ? 'estimate' : 'execute',
|
|
347
|
+
};
|
|
348
|
+
// Call handler with two arguments: (input, context)
|
|
349
|
+
const functionResult = await fn(cleanInputs, executionContext);
|
|
321
350
|
const billing = normalizeBilling(functionResult.billing);
|
|
322
351
|
return {
|
|
323
352
|
output: functionResult.output,
|
package/dist/types.d.ts
CHANGED
|
@@ -49,10 +49,47 @@ export interface PageActionParams {
|
|
|
49
49
|
/** Handler context */
|
|
50
50
|
context: PageActionContext;
|
|
51
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* @deprecated Use ToolExecutionContext instead. This will be removed in a future version.
|
|
54
|
+
*/
|
|
52
55
|
export interface ToolParams<Input, Output> {
|
|
53
56
|
input: Input;
|
|
54
57
|
context: ToolContext;
|
|
55
58
|
}
|
|
59
|
+
/** Trigger types for tool execution */
|
|
60
|
+
export type ToolTrigger = 'field_change' | 'page_action' | 'agent' | 'workflow';
|
|
61
|
+
/** Field info when tool is triggered by a field change */
|
|
62
|
+
export interface ToolFieldContext {
|
|
63
|
+
/** Field handle from page definition */
|
|
64
|
+
handle: string;
|
|
65
|
+
/** Field datatype */
|
|
66
|
+
type: string;
|
|
67
|
+
/** Page handle where the field is defined */
|
|
68
|
+
pageHandle: string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Standardized execution context passed to all tool handlers.
|
|
72
|
+
* This is injected by the runtime and contains metadata about how the tool was invoked.
|
|
73
|
+
*/
|
|
74
|
+
export interface ToolExecutionContext {
|
|
75
|
+
/** How the tool was triggered */
|
|
76
|
+
trigger: ToolTrigger;
|
|
77
|
+
/** App installation ID for scoping instance operations */
|
|
78
|
+
appInstallationId?: string;
|
|
79
|
+
/** Workplace info */
|
|
80
|
+
workplace?: {
|
|
81
|
+
id: string;
|
|
82
|
+
subdomain?: string;
|
|
83
|
+
};
|
|
84
|
+
/** Field info (only present for field_change trigger) */
|
|
85
|
+
field?: ToolFieldContext;
|
|
86
|
+
/** All current field values on the page (only for page_action trigger) */
|
|
87
|
+
fieldValues?: Record<string, unknown>;
|
|
88
|
+
/** Environment variables */
|
|
89
|
+
env: Record<string, string | undefined>;
|
|
90
|
+
/** Execution mode - 'estimate' returns billing info without side effects */
|
|
91
|
+
mode: 'execute' | 'estimate';
|
|
92
|
+
}
|
|
56
93
|
export interface BillingInfo {
|
|
57
94
|
credits: number;
|
|
58
95
|
}
|
|
@@ -65,7 +102,14 @@ export interface ToolSchemaWithJson<Schema extends z.ZodTypeAny = z.ZodTypeAny>
|
|
|
65
102
|
jsonSchema?: Record<string, unknown>;
|
|
66
103
|
}
|
|
67
104
|
export type ToolSchema<Schema extends z.ZodTypeAny = z.ZodTypeAny> = Schema | ToolSchemaWithJson<Schema>;
|
|
68
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Tool handler function signature.
|
|
107
|
+
* Receives tool-specific input as first argument and standardized context as second.
|
|
108
|
+
*
|
|
109
|
+
* @param input - Tool-specific input data (validated against inputs schema)
|
|
110
|
+
* @param context - Standardized execution context injected by runtime
|
|
111
|
+
*/
|
|
112
|
+
export type ToolHandler<Input, Output> = (input: Input, context: ToolExecutionContext) => Promise<ToolExecutionResult<Output>> | ToolExecutionResult<Output>;
|
|
69
113
|
export interface ToolDefinition<Input = unknown, Output = unknown, InputSchema extends z.ZodTypeAny = z.ZodType<Input>, OutputSchema extends z.ZodTypeAny = z.ZodType<Output>> {
|
|
70
114
|
name: string;
|
|
71
115
|
description: string;
|