gravity-run 0.0.2 → 0.0.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.
package/dist/cli/index.js CHANGED
File without changes
package/dist/index.d.ts CHANGED
@@ -99,158 +99,8 @@ declare class Logger {
99
99
  warn(message: string, args?: unknown): void;
100
100
  addListener(listener: LogListener): void;
101
101
  }
102
- /**
103
- * The Standard Identity Structure for Basalt
104
- */
105
- interface BasaltActor {
106
- type: "user" | "agent" | "system" | "public";
107
- id?: string;
108
- name?: string;
109
- roles?: string[];
110
- metadata?: Record<string, unknown>;
111
- }
112
- type Actor = BasaltActor;
113
- type TriggerKind = "api" | "agent" | "cron" | "event" | "custom";
114
- /**
115
- * The Unified Trigger Contract
116
- */
117
- interface BasaltTrigger<
118
- TName extends string,
119
- TInput
120
- > {
121
- readonly name: TName;
122
- readonly kind: TriggerKind;
123
- readonly config: any;
124
- /** Transforms source data to Action Input */
125
- readonly map: (source: any) => TInput | Promise<TInput>;
126
- /** Defines who is performing the action for this trigger */
127
- readonly actor?: BasaltActor | ((source: any) => BasaltActor | Promise<BasaltActor>);
128
- }
129
- declare const trigger: {
130
- api: <T>(options: {
131
- method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
132
- path?: string;
133
- map: (req: Request) => T | Promise<T>;
134
- actor?: BasaltActor | ((req: Request) => BasaltActor | Promise<BasaltActor>);
135
- }) => BasaltTrigger<"api", T>;
136
- cron: <T>(options: {
137
- schedule: string;
138
- input: T;
139
- actor?: BasaltActor;
140
- }) => BasaltTrigger<"cron", T>;
141
- event: <T>(options: {
142
- name: string;
143
- map: (payload: any) => T | Promise<T>;
144
- actor?: BasaltActor | ((payload: any) => BasaltActor | Promise<BasaltActor>);
145
- }) => BasaltTrigger<"event", T>;
146
- agent: <T>(options?: {
147
- name?: string;
148
- map?: (args: any) => T | Promise<T>;
149
- actor?: BasaltActor;
150
- }) => BasaltTrigger<"agent", T>;
151
- custom: <
152
- TName extends string,
153
- T
154
- >(options: {
155
- name: TName;
156
- map: (source: any) => T | Promise<T>;
157
- actor: BasaltActor;
158
- }) => BasaltTrigger<TName, T>;
159
- };
160
- interface Organization {
161
- id: string;
162
- plan?: string;
163
- [key: string]: any;
164
- }
165
- interface JobOptions {
166
- delay?: string | number;
167
- }
168
- type BaseActionContext = {
169
- actor: BasaltActor;
170
- org?: Organization;
171
- db: any;
172
- storage: any;
173
- enqueue: (event: string, input: any) => void | Promise<void>;
174
- schedule: <
175
- TInput extends TSchema,
176
- TOutput extends TSchema
177
- >(when: number | Date | string, action: Action<TInput, TOutput>, input: Static<TInput>) => void | Promise<void>;
178
- logger: Logger;
179
- triggerName: string;
180
- triggerType: TriggerKind;
181
- requestId: string;
182
- };
183
- type ExtendActionContext = {};
184
- type ActionContext = BaseActionContext & ExtendActionContext;
185
- interface RateLimitRule {
186
- /** How many requests */
187
- limit: number;
188
- /** Time window, e.g., "1s", "1m", "1h" */
189
- window: string;
190
- /** What to group by: 'actor' (user), 'org' (tenant), or 'ip' (guest) */
191
- by: "actor" | "org" | "ip";
192
- /** Optional: custom identifier, e.g., 'ai-budget' */
193
- name?: string;
194
- }
195
- type RateLimitConfig = RateLimitRule | RateLimitRule[];
196
- type ActionRateLimit = RateLimitConfig | {
197
- common?: RateLimitConfig;
198
- api?: RateLimitConfig;
199
- agent?: RateLimitConfig;
200
- [key: string]: RateLimitConfig | undefined;
201
- };
202
- interface AccessConfig {
203
- common?: {
204
- authenticated?: boolean;
205
- };
206
- api?: {
207
- roles?: string[];
208
- };
209
- agent?: {
210
- authenticated?: boolean;
211
- };
212
- authenticated?: boolean;
213
- roles?: string[];
214
- }
215
- type GuardFunction<TInput> = (input: TInput, ctx: ActionContext) => boolean | Promise<boolean>;
216
- interface GuardConfig<TInput> {
217
- api?: GuardFunction<TInput>;
218
- event?: GuardFunction<TInput>;
219
- cron?: GuardFunction<TInput>;
220
- agent?: GuardFunction<TInput>;
221
- [key: string]: GuardFunction<TInput> | undefined;
222
- }
223
- interface ActionConfig<
224
- TInput extends TSchema = TSchema,
225
- TOutput extends TSchema = TSchema
226
- > {
227
- name: string;
228
- description?: string;
229
- input?: TInput;
230
- output?: TOutput;
231
- triggers?: BasaltTrigger<string, Static<TInput>>[];
232
- access?: AccessConfig;
233
- guard?: GuardConfig<Static<TInput>>;
234
- rateLimit?: ActionRateLimit;
235
- }
236
- type ActionHandler<
237
- TInput extends TSchema,
238
- TOutput extends TSchema
239
- > = (input: Static<TInput>, ctx: ActionContext) => Promise<Static<TOutput>>;
240
- interface Action<
241
- TInput extends TSchema = TSchema,
242
- TOutput extends TSchema = TSchema
243
- > {
244
- config: ActionConfig<TInput, TOutput>;
245
- handler: ActionHandler<TInput, TOutput>;
246
- (input: Static<TInput>, ctx: ActionContext): Promise<Static<TOutput>>;
247
- }
248
- declare function action<
249
- TInput extends TSchema2 = TSchema2,
250
- TOutput extends TSchema2 = TSchema2
251
- >(config: ActionConfig<TInput, TOutput>, handler: ActionHandler<TInput, TOutput>): Action<TInput, TOutput>;
252
- type TriggerKind2 = "api" | "cron" | "event" | "agent";
253
- interface BaseTrigger<TKind extends TriggerKind2 = TriggerKind2> {
102
+ type TriggerKind = "api" | "cron" | "event" | "agent";
103
+ interface BaseTrigger<TKind extends TriggerKind = TriggerKind> {
254
104
  kind: TKind;
255
105
  name: string;
256
106
  /**
@@ -371,6 +221,112 @@ declare function agent(tool: string, description: string, options?: {
371
221
  map?: (args: Record<string, unknown>) => unknown | Promise<unknown>;
372
222
  actor?: BasaltActor | ((context: McpContext) => BasaltActor | Promise<BasaltActor>);
373
223
  }): AgentTrigger;
224
+ /**
225
+ * The Standard Identity Structure for Basalt
226
+ */
227
+ interface BasaltActor {
228
+ type: "user" | "agent" | "system" | "public";
229
+ id?: string;
230
+ name?: string;
231
+ roles?: string[];
232
+ metadata?: Record<string, unknown>;
233
+ }
234
+ type Actor = BasaltActor;
235
+ /**
236
+ * The Unified Trigger Contract
237
+ */
238
+ interface Organization {
239
+ id: string;
240
+ plan?: string;
241
+ [key: string]: any;
242
+ }
243
+ interface JobOptions {
244
+ delay?: string | number;
245
+ }
246
+ type BaseActionContext = {
247
+ actor: BasaltActor;
248
+ org?: Organization;
249
+ db: any;
250
+ storage: any;
251
+ enqueue: (event: string, input: any) => void | Promise<void>;
252
+ schedule: <
253
+ TInput extends TSchema,
254
+ TOutput extends TSchema
255
+ >(when: number | Date | string, action: Action<TInput, TOutput>, input: Static<TInput>) => void | Promise<void>;
256
+ logger: Logger;
257
+ triggerName: string;
258
+ triggerType: TriggerKind;
259
+ requestId: string;
260
+ };
261
+ type ExtendActionContext = {};
262
+ type ActionContext = BaseActionContext & ExtendActionContext;
263
+ interface RateLimitRule {
264
+ /** How many requests */
265
+ limit: number;
266
+ /** Time window, e.g., "1s", "1m", "1h" */
267
+ window: string;
268
+ /** What to group by: 'actor' (user), 'org' (tenant), or 'ip' (guest) */
269
+ by: "actor" | "org" | "ip";
270
+ /** Optional: custom identifier, e.g., 'ai-budget' */
271
+ name?: string;
272
+ }
273
+ type RateLimitConfig = RateLimitRule | RateLimitRule[];
274
+ type ActionRateLimit = RateLimitConfig | {
275
+ common?: RateLimitConfig;
276
+ api?: RateLimitConfig;
277
+ agent?: RateLimitConfig;
278
+ [key: string]: RateLimitConfig | undefined;
279
+ };
280
+ interface AccessConfig {
281
+ common?: {
282
+ authenticated?: boolean;
283
+ };
284
+ api?: {
285
+ roles?: string[];
286
+ };
287
+ agent?: {
288
+ authenticated?: boolean;
289
+ };
290
+ authenticated?: boolean;
291
+ roles?: string[];
292
+ }
293
+ type GuardFunction<TInput> = (input: TInput, ctx: ActionContext) => boolean | Promise<boolean>;
294
+ interface GuardConfig<TInput> {
295
+ api?: GuardFunction<TInput>;
296
+ event?: GuardFunction<TInput>;
297
+ cron?: GuardFunction<TInput>;
298
+ agent?: GuardFunction<TInput>;
299
+ [key: string]: GuardFunction<TInput> | undefined;
300
+ }
301
+ interface ActionConfig<
302
+ TInput extends TSchema = TSchema,
303
+ TOutput extends TSchema = TSchema
304
+ > {
305
+ name: string;
306
+ description?: string;
307
+ input?: TInput;
308
+ output?: TOutput;
309
+ triggers?: Trigger[];
310
+ access?: AccessConfig;
311
+ guard?: GuardConfig<Static<TInput>>;
312
+ rateLimit?: ActionRateLimit;
313
+ }
314
+ type ActionHandler<
315
+ TInput extends TSchema,
316
+ TOutput extends TSchema
317
+ > = (input: Static<TInput>, ctx: ActionContext) => Promise<Static<TOutput>>;
318
+ interface Action<
319
+ TInput extends TSchema = TSchema,
320
+ TOutput extends TSchema = TSchema
321
+ > {
322
+ config: ActionConfig<TInput, TOutput>;
323
+ handler: ActionHandler<TInput, TOutput>;
324
+ (input: Static<TInput>, ctx: ActionContext): Promise<Static<TOutput>>;
325
+ }
326
+ declare function action<
327
+ TInput extends TSchema2 = TSchema2,
328
+ TOutput extends TSchema2 = TSchema2
329
+ >(config: ActionConfig<TInput, TOutput>, handler: ActionHandler<TInput, TOutput>): Action<TInput, TOutput>;
374
330
  declare class BasaltError extends Error {
375
331
  code: string;
376
332
  status: number;
@@ -395,4 +351,4 @@ declare class NonRetriableError extends BasaltError {
395
351
  constructor(message: string);
396
352
  }
397
353
  import { Type } from "typebox";
398
- export { trigger, Type as t, loadConfig, event, defineConfig, cron, api, agent, action, UnauthorizedError, Trigger, RateLimitRule, RateLimitConfig, Organization, NotFoundError, NonRetriableError, McpContext, JobOptions, InternalServerError, GuardFunction, GuardConfig, ForbiddenError, ExtendActionContext, EventTrigger, CronTrigger, BaseTrigger, BaseActionContext, BasaltTrigger, BasaltEvent, BasaltError, BasaltActor, BadRequestError, ApiTrigger, ApiRequest, AgentTrigger, Actor, ActionRateLimit, ActionHandler, ActionContext, ActionConfig, Action, AccessConfig };
354
+ export { Type as t, loadConfig, event, defineConfig, cron, api, agent, action, UnauthorizedError, TriggerKind, Trigger, RateLimitRule, RateLimitConfig, Organization, NotFoundError, NonRetriableError, McpContext, JobOptions, InternalServerError, GuardFunction, GuardConfig, ForbiddenError, ExtendActionContext, EventTrigger, CronTrigger, BaseTrigger, BaseActionContext, BasaltEvent, BasaltError, BasaltActor, BadRequestError, ApiTrigger, ApiRequest, AgentTrigger, Actor, ActionRateLimit, ActionHandler, ActionContext, ActionConfig, Action, AccessConfig };
package/dist/index.js CHANGED
@@ -112,44 +112,6 @@ function action(config, handler) {
112
112
  wrapped.handler = handler;
113
113
  return wrapped;
114
114
  }
115
- // src/core/types.ts
116
- var trigger = {
117
- api: (options) => ({
118
- name: "api",
119
- kind: "api",
120
- config: options,
121
- map: options.map,
122
- actor: options.actor
123
- }),
124
- cron: (options) => ({
125
- name: "cron",
126
- kind: "cron",
127
- config: options,
128
- map: () => options.input,
129
- actor: options.actor ?? { type: "system", name: "Basalt Scheduler" }
130
- }),
131
- event: (options) => ({
132
- name: "event",
133
- kind: "event",
134
- config: options,
135
- map: options.map,
136
- actor: options.actor
137
- }),
138
- agent: (options = {}) => ({
139
- name: "agent",
140
- kind: "agent",
141
- config: options,
142
- map: options.map || ((args) => args),
143
- actor: options.actor
144
- }),
145
- custom: (options) => ({
146
- name: options.name,
147
- kind: "custom",
148
- config: options,
149
- map: options.map,
150
- actor: options.actor
151
- })
152
- };
153
115
  // src/triggers/index.ts
154
116
  var api = (method, path, options) => {
155
117
  return {
@@ -193,7 +155,6 @@ function agent(tool, description, options) {
193
155
  // src/utils/typebox.ts
194
156
  import { Type } from "typebox";
195
157
  export {
196
- trigger,
197
158
  Type as t,
198
159
  loadConfig,
199
160
  event,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gravity-run",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "A framework for building scalable applications",
5
5
  "homepage": "https://github.com/alihussnainrb/gravity#readme",
6
6
  "bugs": {