corsair 0.1.19 → 0.1.20

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAEhE,OAAO,KAAK,EACX,mBAAmB,EAEnB,mBAAmB,EACnB,MAAM,cAAc,CAAC;AAKtB,OAAO,KAAK,EACX,oBAAoB,EACpB,wBAAwB,EACxB,gBAAgB,EAChB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAExD,OAAO,KAAK,EAEX,aAAa,EAIb,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAOhF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAC9B,MAAM,SAAS,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,GAAG,SAAS,IACvE,MAAM,SAAS,mBAAmB,CAAC,MAAM,QAAQ,CAAC,GACnD;IAAE,EAAE,EAAE,mBAAmB,CAAC,QAAQ,CAAC,CAAA;CAAE,GACrC,EAAE,CAAC;AAMN;;GAEG;AACH,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,C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AS,aAAa,EAAE,EAE9C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,eAAe,EACzB,GAAG,EAAE,MAAM,GACT,uBAAuB,CAAC,OAAO,CAAC,CAyBlC"}
@@ -160,6 +160,7 @@ export function buildCorsairClient(plugins, options) {
160
160
  endpointMeta: plugin.endpointMeta,
161
161
  database,
162
162
  approvalConfig,
163
+ tenantId,
163
164
  });
164
165
  if (Object.keys(boundTree).length > 0) {
165
166
  apiUnsafe[plugin.id].api = boundTree;
@@ -19,7 +19,7 @@ export declare function isEndpoint(value: unknown): value is Function;
19
19
  * @param currentPath - The current path for tracking nested endpoint operations
20
20
  * @param keyBuilder - Optional async callback to generate a key from the plugin context
21
21
  */
22
- export declare function bindEndpointsRecursively({ endpoints, hooks, ctx, tree, pluginId, errorHandlers, currentPath, keyBuilder, permissionsConfig, endpointMeta, database, approvalConfig, }: {
22
+ export declare function bindEndpointsRecursively({ endpoints, hooks, ctx, tree, pluginId, errorHandlers, currentPath, keyBuilder, permissionsConfig, endpointMeta, database, approvalConfig, tenantId, }: {
23
23
  endpoints: Record<string, unknown>;
24
24
  hooks: Record<string, unknown> | undefined;
25
25
  ctx: Record<string, unknown>;
@@ -42,5 +42,7 @@ export declare function bindEndpointsRecursively({ endpoints, hooks, ctx, tree,
42
42
  timeout: string;
43
43
  onTimeout: 'deny' | 'approve';
44
44
  };
45
+ /** Tenant ID for multi-tenant instances. Forwarded to the permission record so executePermission can scope correctly. */
46
+ tenantId?: string;
45
47
  }): void;
46
48
  //# sourceMappingURL=bind.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bind.d.ts","sourceRoot":"","sources":["../../../core/endpoints/bind.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAGrD,OAAO,KAAK,EACX,qBAAqB,EAErB,iBAAiB,EACjB,cAAc,EACd,gB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EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC;IACpE,yHAAyH;IACzH,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,GAAG,IAAI,CA6JP"}
@@ -23,7 +23,7 @@ export function isEndpoint(value) {
23
23
  * @param currentPath - The current path for tracking nested endpoint operations
24
24
  * @param keyBuilder - Optional async callback to generate a key from the plugin context
25
25
  */
26
- export function bindEndpointsRecursively({ endpoints, hooks, ctx, tree, pluginId, errorHandlers, currentPath = [], keyBuilder, permissionsConfig, endpointMeta, database, approvalConfig, }) {
26
+ export function bindEndpointsRecursively({ endpoints, hooks, ctx, tree, pluginId, errorHandlers, currentPath = [], keyBuilder, permissionsConfig, endpointMeta, database, approvalConfig, tenantId, }) {
27
27
  for (const [key, value] of Object.entries(endpoints)) {
28
28
  // we have to retype this now because it's nested webhooks
29
29
  const nodeHooks = hooks?.[key];
@@ -49,6 +49,7 @@ export function bindEndpointsRecursively({ endpoints, hooks, ctx, tree, pluginId
49
49
  timeoutMs: approvalConfig
50
50
  ? parseDurationMs(approvalConfig.timeout)
51
51
  : undefined,
52
+ tenantId,
52
53
  });
53
54
  if (permResult === 'blocked')
54
55
  return null;
@@ -145,6 +146,7 @@ export function bindEndpointsRecursively({ endpoints, hooks, ctx, tree, pluginId
145
146
  endpointMeta,
146
147
  database,
147
148
  approvalConfig,
149
+ tenantId,
148
150
  });
149
151
  tree[key] = nestedTree;
150
152
  }
@@ -16,6 +16,8 @@ export type EnforcePermissionOptions = {
16
16
  /** Required to create an approval record. Without a DB, 'require_approval' falls back to deny. */
17
17
  db?: CorsairDatabase;
18
18
  timeoutMs?: number;
19
+ /** Tenant ID for multi-tenant instances. Stored on the record so executePermission can scope correctly. Defaults to 'default'. */
20
+ tenantId?: string;
19
21
  };
20
22
  export type EnforcePermissionResult = {
21
23
  result: 'allow' | 'blocked';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/permissions/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EACX,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,MAAM,YAAY,CAAC;AAgBpB,4HAA4H;AAC5H,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,cAAc,EACpB,QAAQ,CAAC,EAAE,gBAAgB,GACzB,gBAAgB,CAGlB;AAMD,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsBxD;AAMD,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,kGAAkG;IAClG,EAAE,CAAC,EAAE,eAAe,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,wBAAwB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CA4FlC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/permissions/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EACX,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,MAAM,YAAY,CAAC;AAgBpB,4HAA4H;AAC5H,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,iBAAiB,EAC5B,IAAI,EAAE,cAAc,EACpB,QAAQ,CAAC,EAAE,gBAAgB,GACzB,gBAAgB,CAGlB;AAMD,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAsBxD;AAMD,MAAM,MAAM,wBAAwB,GAAG;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,qFAAqF;IACrF,IAAI,EAAE,OAAO,CAAC;IACd,IAAI,EAAE,cAAc,CAAC;IACrB,QAAQ,CAAC,EAAE,gBAAgB,CAAC;IAC5B,SAAS,EAAE,iBAAiB,CAAC;IAC7B,IAAI,CAAC,EAAE,iBAAiB,CAAC;IACzB,kGAAkG;IAClG,EAAE,CAAC,EAAE,eAAe,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kIAAkI;IAClI,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAC;IAC5B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAsB,iBAAiB,CACtC,IAAI,EAAE,wBAAwB,GAC5B,OAAO,CAAC,uBAAuB,CAAC,CA+FlC"}
@@ -70,13 +70,15 @@ export async function enforcePermission(opts) {
70
70
  }
71
71
  const argsJson = JSON.stringify(opts.args);
72
72
  const now = new Date().toISOString();
73
- // Check for an existing, non-expired permission record for this plugin + endpoint + args
73
+ const tenantId = opts.tenantId ?? 'default';
74
+ // Check for an existing, non-expired permission record for this plugin + endpoint + args + tenant
74
75
  const existing = await opts.db.db
75
76
  .selectFrom('corsair_permissions')
76
77
  .selectAll()
77
78
  .where('plugin', '=', opts.pluginId)
78
79
  .where('endpoint', '=', opts.endpointPath)
79
80
  .where('args', '=', argsJson)
81
+ .where('tenant_id', '=', tenantId)
80
82
  .where('expires_at', '>', now)
81
83
  .where('status', 'in', ['pending', 'approved'])
82
84
  .orderBy('created_at', 'desc')
@@ -117,6 +119,7 @@ export async function enforcePermission(opts) {
117
119
  plugin: opts.pluginId,
118
120
  endpoint: opts.endpointPath,
119
121
  args: argsJson,
122
+ tenant_id: tenantId,
120
123
  status: 'pending',
121
124
  expires_at: expiresAt,
122
125
  })
@@ -115,12 +115,12 @@ export declare const CorsairPermissionsSchema: z.ZodObject<{
115
115
  endpoint: z.ZodString;
116
116
  /** JSON-encoded args that will be forwarded to the endpoint upon approval */
117
117
  args: z.ZodString;
118
- /** Agent session ID from the orchestrator (NanoClaw / OpenClaw) — used to resume the agent */
119
- session_id: z.ZodOptional<z.ZodString>;
120
- /** URL to POST to when the action is approved or denied, to resume the agent */
121
- callback_url: z.ZodOptional<z.ZodString>;
122
- /** Full public review page URL (ngrok URL + path + token query param) */
123
- review_url: z.ZodOptional<z.ZodString>;
118
+ /**
119
+ * Tenant ID for multi-tenant corsair instances. Stored so executePermission
120
+ * can scope the corsair instance correctly when executing the approved action.
121
+ * Defaults to 'default' for single-tenant instances.
122
+ */
123
+ tenant_id: z.ZodOptional<z.ZodString>;
124
124
  /** Current state of the approval request */
125
125
  status: z.ZodDefault<z.ZodEnum<["pending", "approved", "completed", "denied", "expired"]>>;
126
126
  /** ISO8601 timestamp — when this request becomes invalid */
@@ -135,9 +135,7 @@ export declare const CorsairPermissionsSchema: z.ZodObject<{
135
135
  endpoint: string;
136
136
  args: string;
137
137
  expires_at: string;
138
- session_id?: string | undefined;
139
- callback_url?: string | undefined;
140
- review_url?: string | undefined;
138
+ tenant_id?: string | undefined;
141
139
  }, {
142
140
  id: string;
143
141
  created_at: Date;
@@ -148,9 +146,7 @@ export declare const CorsairPermissionsSchema: z.ZodObject<{
148
146
  args: string;
149
147
  expires_at: string;
150
148
  status?: "pending" | "completed" | "approved" | "denied" | "expired" | undefined;
151
- session_id?: string | undefined;
152
- callback_url?: string | undefined;
153
- review_url?: string | undefined;
149
+ tenant_id?: string | undefined;
154
150
  }>;
155
151
  export type CorsairPermission = z.infer<typeof CorsairPermissionsSchema>;
156
152
  export type CorsairPermissionInsert = {
@@ -161,9 +157,7 @@ export type CorsairPermissionInsert = {
161
157
  plugin: string;
162
158
  endpoint: string;
163
159
  args: string;
164
- session_id?: string;
165
- callback_url?: string;
166
- review_url?: string;
160
+ tenant_id?: string;
167
161
  status?: 'pending' | 'approved' | 'completed' | 'denied' | 'expired';
168
162
  expires_at: string;
169
163
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../db/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;EAYpC,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAM3E,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAehC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMnE,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBhC,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAMlE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;EAgB9B,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAM/D,eAAO,MAAM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BAAmB,GAAG,OAAO,CACxC,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,YAAY,CAAC,CACxC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,OAAO,CACvC,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,YAAY,CAAC,CACvC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAChC,oBAAoB,EAAE,wBAAwB,CAAC;IAC/C,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,gBAAgB,EAAE,mBAAmB,CAAC;IACtC,cAAc,EAAE,kBAAkB,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,eAAe,CAAC,CAAC,SAAS,gBAAgB,IACrD,CAAC,SAAS,MAAM,kBAAkB,GAC/B,kBAAkB,CAAC,CAAC,CAAC,GACrB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
package/dist/db/index.js CHANGED
@@ -81,12 +81,12 @@ export const CorsairPermissionsSchema = z.object({
81
81
  endpoint: z.string(),
82
82
  /** JSON-encoded args that will be forwarded to the endpoint upon approval */
83
83
  args: z.string(),
84
- /** Agent session ID from the orchestrator (NanoClaw / OpenClaw) — used to resume the agent */
85
- session_id: z.string().optional(),
86
- /** URL to POST to when the action is approved or denied, to resume the agent */
87
- callback_url: z.string().optional(),
88
- /** Full public review page URL (ngrok URL + path + token query param) */
89
- review_url: z.string().optional(),
84
+ /**
85
+ * Tenant ID for multi-tenant corsair instances. Stored so executePermission
86
+ * can scope the corsair instance correctly when executing the approved action.
87
+ * Defaults to 'default' for single-tenant instances.
88
+ */
89
+ tenant_id: z.string().optional(),
90
90
  /** Current state of the approval request */
91
91
  status: z
92
92
  .enum(['pending', 'approved', 'completed', 'denied', 'expired'])
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  export { createCorsair } from './core';
2
2
  export { processWebhook } from './webhooks';
3
+ export { executePermission } from './permissions';
4
+ export type { PermissionExecuteResult } from './permissions';
3
5
  export { discord } from './plugins/discord';
4
6
  export { github } from './plugins/github';
5
7
  export { gmail } from './plugins/gmail';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAI5C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAI7D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // main function exports
2
2
  export { createCorsair } from './core';
3
3
  export { processWebhook } from './webhooks';
4
+ export { executePermission } from './permissions';
4
5
  // plugin function exports
5
6
  export { discord } from './plugins/discord';
6
7
  export { github } from './plugins/github';
@@ -0,0 +1,47 @@
1
+ import type { CorsairDatabase } from '../db/kysely/database';
2
+ /**
3
+ * A plugin namespace on the corsair instance that may have API endpoints.
4
+ */
5
+ type PluginWithApi = {
6
+ api?: Record<string, unknown>;
7
+ };
8
+ /**
9
+ * The corsair instance type for permission execution — a record of plugin namespaces.
10
+ * Mirrors the duck-typed shape used by processWebhook.
11
+ */
12
+ type CorsairInstance = Record<string, PluginWithApi | undefined> & {
13
+ withTenant?: (tenantId: string) => CorsairInstance;
14
+ };
15
+ export type PermissionExecuteResult = {
16
+ plugin: string;
17
+ endpoint: string;
18
+ result: unknown;
19
+ error?: string;
20
+ };
21
+ /**
22
+ * Deterministically executes a pending permission request by directly calling
23
+ * the bound endpoint with the frozen args stored in the approval record.
24
+ *
25
+ * This is the approval-side counterpart to processWebhook. Instead of resuming
26
+ * the LLM to re-derive the action, this function looks up the pending permission
27
+ * record, navigates corsair[plugin].api[...endpoint path] to find the bound
28
+ * function, and calls it with the exact args that were stored — no LLM
29
+ * involvement required.
30
+ *
31
+ * Lifecycle:
32
+ * 1. Fetches the permission record from corsair_permissions
33
+ * 2. Validates the record is pending and not expired
34
+ * 3. Resolves the tenant-scoped corsair instance (via withTenant if multi-tenant)
35
+ * 4. Sets status to 'approved' so the bound endpoint's permission guard allows it through
36
+ * 5. Navigates corsair[plugin].api[...endpoint path] to find the bound function
37
+ * 6. Calls the function with the stored args (JSON-parsed)
38
+ * 7. The bound function's internal onComplete callback marks the record 'completed'
39
+ * 8. Returns the result, or an error object if the endpoint throws
40
+ *
41
+ * @param corsair - The corsair instance (returned from createCorsair)
42
+ * @param db - The corsair database instance
43
+ * @param permissionId - The ID of the corsair_permissions record to execute
44
+ */
45
+ export declare function executePermission(corsair: CorsairInstance, db: CorsairDatabase, permissionId: string): Promise<PermissionExecuteResult>;
46
+ export {};
47
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../permissions/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAM7D;;GAEG;AACH,KAAK,aAAa,GAAG;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B,CAAC;AAEF;;;GAGG;AACH,KAAK,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,GAAG,SAAS,CAAC,GAAG;IAClE,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,eAAe,CAAC;CACnD,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AA4BF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,iBAAiB,CACtC,OAAO,EAAE,eAAe,EACxB,EAAE,EAAE,eAAe,EACnB,YAAY,EAAE,MAAM,GAClB,OAAO,CAAC,uBAAuB,CAAC,CAiFlC"}
@@ -0,0 +1,106 @@
1
+ // ─────────────────────────────────────────────────────────────────────────────
2
+ // Helpers
3
+ // ─────────────────────────────────────────────────────────────────────────────
4
+ /**
5
+ * Traverses a bound API tree by dot-notation path parts and returns the
6
+ * endpoint function, or null if the path does not resolve to a function.
7
+ */
8
+ function resolveEndpointFn(api, pathParts) {
9
+ let current = api;
10
+ for (const part of pathParts) {
11
+ if (!current || typeof current !== 'object')
12
+ return null;
13
+ current = current[part];
14
+ }
15
+ return typeof current === 'function'
16
+ ? current
17
+ : null;
18
+ }
19
+ // ─────────────────────────────────────────────────────────────────────────────
20
+ // Main Function
21
+ // ─────────────────────────────────────────────────────────────────────────────
22
+ /**
23
+ * Deterministically executes a pending permission request by directly calling
24
+ * the bound endpoint with the frozen args stored in the approval record.
25
+ *
26
+ * This is the approval-side counterpart to processWebhook. Instead of resuming
27
+ * the LLM to re-derive the action, this function looks up the pending permission
28
+ * record, navigates corsair[plugin].api[...endpoint path] to find the bound
29
+ * function, and calls it with the exact args that were stored — no LLM
30
+ * involvement required.
31
+ *
32
+ * Lifecycle:
33
+ * 1. Fetches the permission record from corsair_permissions
34
+ * 2. Validates the record is pending and not expired
35
+ * 3. Resolves the tenant-scoped corsair instance (via withTenant if multi-tenant)
36
+ * 4. Sets status to 'approved' so the bound endpoint's permission guard allows it through
37
+ * 5. Navigates corsair[plugin].api[...endpoint path] to find the bound function
38
+ * 6. Calls the function with the stored args (JSON-parsed)
39
+ * 7. The bound function's internal onComplete callback marks the record 'completed'
40
+ * 8. Returns the result, or an error object if the endpoint throws
41
+ *
42
+ * @param corsair - The corsair instance (returned from createCorsair)
43
+ * @param db - The corsair database instance
44
+ * @param permissionId - The ID of the corsair_permissions record to execute
45
+ */
46
+ export async function executePermission(corsair, db, permissionId) {
47
+ const now = new Date().toISOString();
48
+ const perm = await db.db
49
+ .selectFrom('corsair_permissions')
50
+ .selectAll()
51
+ .where('id', '=', permissionId)
52
+ .executeTakeFirst();
53
+ if (!perm) {
54
+ throw new Error(`executePermission: permission '${permissionId}' not found.`);
55
+ }
56
+ if (perm.status !== 'pending') {
57
+ throw new Error(`executePermission: permission '${permissionId}' is '${perm.status}', expected 'pending'.`);
58
+ }
59
+ if (perm.expires_at < now) {
60
+ await db.db
61
+ .updateTable('corsair_permissions')
62
+ .set({ status: 'expired', updated_at: new Date() })
63
+ .where('id', '=', permissionId)
64
+ .execute();
65
+ throw new Error(`executePermission: permission '${permissionId}' has expired.`);
66
+ }
67
+ // Resolve the tenant-scoped instance. The stored tenant_id ensures the correct
68
+ // plugin context is used for multi-tenant corsair instances.
69
+ const tenantId = perm.tenant_id ?? 'default';
70
+ const scopedCorsair = corsair.withTenant
71
+ ? corsair.withTenant(tenantId)
72
+ : corsair;
73
+ const pluginNamespace = scopedCorsair[perm.plugin];
74
+ if (!pluginNamespace?.api) {
75
+ throw new Error(`executePermission: plugin '${perm.plugin}' not found or has no API on this corsair instance.`);
76
+ }
77
+ const endpointFn = resolveEndpointFn(pluginNamespace.api, perm.endpoint.split('.'));
78
+ if (!endpointFn) {
79
+ throw new Error(`executePermission: endpoint '${perm.endpoint}' not found in plugin '${perm.plugin}'.`);
80
+ }
81
+ // Mark as approved — the bound function's enforcePermission will find this record,
82
+ // allow the call through, then its onComplete callback marks it 'completed'.
83
+ await db.db
84
+ .updateTable('corsair_permissions')
85
+ .set({ status: 'approved', updated_at: new Date() })
86
+ .where('id', '=', permissionId)
87
+ .execute();
88
+ try {
89
+ const result = await endpointFn(JSON.parse(perm.args));
90
+ return { plugin: perm.plugin, endpoint: perm.endpoint, result };
91
+ }
92
+ catch (error) {
93
+ // Reset to a terminal state so the approval cannot be silently retried.
94
+ await db.db
95
+ .updateTable('corsair_permissions')
96
+ .set({ status: 'denied', updated_at: new Date() })
97
+ .where('id', '=', permissionId)
98
+ .execute();
99
+ return {
100
+ plugin: perm.plugin,
101
+ endpoint: perm.endpoint,
102
+ result: null,
103
+ error: error instanceof Error ? error.message : String(error),
104
+ };
105
+ }
106
+ }
@@ -70,7 +70,7 @@ export declare const Domains: {
70
70
  data: {
71
71
  id: string;
72
72
  name: string;
73
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
73
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
74
74
  created_at?: Date | null | undefined;
75
75
  region?: string | undefined;
76
76
  }[];
@@ -162,13 +162,13 @@ declare const DomainSchema: z.ZodObject<{
162
162
  }, "strip", z.ZodTypeAny, {
163
163
  id: string;
164
164
  name: string;
165
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
165
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
166
166
  created_at?: Date | null | undefined;
167
167
  region?: string | undefined;
168
168
  }, {
169
169
  id: string;
170
170
  name: string;
171
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
171
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
172
172
  created_at?: Date | null | undefined;
173
173
  region?: string | undefined;
174
174
  }>;
@@ -284,13 +284,13 @@ export declare const ResendEndpointOutputSchemas: {
284
284
  }, "strip", z.ZodTypeAny, {
285
285
  id: string;
286
286
  name: string;
287
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
287
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
288
288
  created_at?: Date | null | undefined;
289
289
  region?: string | undefined;
290
290
  }, {
291
291
  id: string;
292
292
  name: string;
293
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
293
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
294
294
  created_at?: Date | null | undefined;
295
295
  region?: string | undefined;
296
296
  }>, "many">;
@@ -298,7 +298,7 @@ export declare const ResendEndpointOutputSchemas: {
298
298
  data: {
299
299
  id: string;
300
300
  name: string;
301
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
301
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
302
302
  created_at?: Date | null | undefined;
303
303
  region?: string | undefined;
304
304
  }[];
@@ -306,7 +306,7 @@ export declare const ResendEndpointOutputSchemas: {
306
306
  data: {
307
307
  id: string;
308
308
  name: string;
309
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
309
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
310
310
  created_at?: Date | null | undefined;
311
311
  region?: string | undefined;
312
312
  }[];
@@ -298,13 +298,13 @@ export declare const resendEndpointSchemas: {
298
298
  }, "strip", import("zod").ZodTypeAny, {
299
299
  id: string;
300
300
  name: string;
301
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
301
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
302
302
  created_at?: Date | null | undefined;
303
303
  region?: string | undefined;
304
304
  }, {
305
305
  id: string;
306
306
  name: string;
307
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
307
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
308
308
  created_at?: Date | null | undefined;
309
309
  region?: string | undefined;
310
310
  }>, "many">;
@@ -312,7 +312,7 @@ export declare const resendEndpointSchemas: {
312
312
  data: {
313
313
  id: string;
314
314
  name: string;
315
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
315
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
316
316
  created_at?: Date | null | undefined;
317
317
  region?: string | undefined;
318
318
  }[];
@@ -320,7 +320,7 @@ export declare const resendEndpointSchemas: {
320
320
  data: {
321
321
  id: string;
322
322
  name: string;
323
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
323
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
324
324
  created_at?: Date | null | undefined;
325
325
  region?: string | undefined;
326
326
  }[];
@@ -27,13 +27,13 @@ export declare const ResendDomain: z.ZodObject<{
27
27
  }, "strip", z.ZodTypeAny, {
28
28
  id: string;
29
29
  name: string;
30
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
30
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
31
31
  created_at?: Date | null | undefined;
32
32
  region?: string | undefined;
33
33
  }, {
34
34
  id: string;
35
35
  name: string;
36
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
36
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
37
37
  created_at?: Date | null | undefined;
38
38
  region?: string | undefined;
39
39
  }>;
@@ -29,13 +29,13 @@ export declare const ResendSchema: {
29
29
  }, "strip", import("zod").ZodTypeAny, {
30
30
  id: string;
31
31
  name: string;
32
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
32
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
33
33
  created_at?: Date | null | undefined;
34
34
  region?: string | undefined;
35
35
  }, {
36
36
  id: string;
37
37
  name: string;
38
- status: "validation" | "pending" | "failed" | "verified" | "error" | "not_started" | "scheduled" | "ready";
38
+ status: "validation" | "pending" | "failed" | "error" | "verified" | "not_started" | "scheduled" | "ready";
39
39
  created_at?: Date | null | undefined;
40
40
  region?: string | undefined;
41
41
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../plugins/slack/webhooks/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAGxC,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,SAAS,CAwD5C,CAAC"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../plugins/slack/webhooks/messages.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAGxC,eAAO,MAAM,OAAO,EAAE,aAAa,CAAC,SAAS,CAyE5C,CAAC"}
@@ -20,17 +20,36 @@ export const message = {
20
20
  };
21
21
  }
22
22
  let corsairEntityId = '';
23
- if (ctx.db.messages && event.ts) {
23
+ if (ctx.db.messages) {
24
24
  try {
25
- const entity = await ctx.db.messages.upsertByEntityId(event.ts, {
26
- ...event,
27
- id: event.ts,
28
- authorId: 'user' in event ? event.user : undefined,
29
- createdAt: event.ts
30
- ? new Date(parseFloat(event.ts) * 1000)
31
- : new Date(),
32
- });
33
- corsairEntityId = entity?.id || '';
25
+ if ('subtype' in event && event.subtype === 'message_changed' && 'message' in event) {
26
+ // For message_changed events, event.ts is the change-event timestamp (always new).
27
+ // The original message lives at event.message, with event.message.ts as the stable ID.
28
+ const updated = event.message;
29
+ const messageTs = 'ts' in updated ? updated.ts : undefined;
30
+ if (messageTs) {
31
+ const entity = await ctx.db.messages.upsertByEntityId(messageTs, {
32
+ ...updated,
33
+ id: messageTs,
34
+ authorId: 'user' in updated ? updated.user : undefined,
35
+ createdAt: new Date(parseFloat(messageTs) * 1000),
36
+ });
37
+ corsairEntityId = entity?.id || '';
38
+ }
39
+ }
40
+ else if (!('subtype' in event) || event.subtype !== 'message_deleted') {
41
+ // Skip message_deleted events — the message no longer exists and we don't
42
+ // want to create a spurious record keyed on the deletion-event timestamp.
43
+ if (event.ts) {
44
+ const entity = await ctx.db.messages.upsertByEntityId(event.ts, {
45
+ ...event,
46
+ id: event.ts,
47
+ authorId: 'user' in event ? event.user : undefined,
48
+ createdAt: new Date(parseFloat(event.ts) * 1000),
49
+ });
50
+ corsairEntityId = entity?.id || '';
51
+ }
52
+ }
34
53
  }
35
54
  catch (error) {
36
55
  console.warn('Failed to save message to database:', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsair",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",