corsair 0.1.16 → 0.1.17

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.
@@ -19,33 +19,37 @@ export type EndpointSchemaResult = {
19
19
  export type CorsairInspectMethods = {
20
20
  /**
21
21
  * Returns all available endpoint paths for every registered plugin.
22
- * Keys are plugin IDs, values are arrays of full-form paths (plugin.group.method).
22
+ * Keys are plugin IDs, values are arrays of full-form paths (plugin.api.group.method), all lowercase.
23
23
  *
24
24
  * @example
25
25
  * corsair.get_methods()
26
- * // { slack: ['slack.channels.list', 'slack.messages.post', ...], github: ['github.issues.list', ...] }
26
+ * // { slack: ['slack.api.channels.list', 'slack.api.messages.post', ...], github: ['github.api.issues.list', ...] }
27
27
  */
28
28
  get_methods(): Record<string, string[]>;
29
29
  /**
30
30
  * Returns all available endpoint paths for a specific plugin.
31
- * Paths are full-form (plugin.group.method) so they can be passed directly to get_schema().
31
+ * Paths are full-form (plugin.api.group.method), all lowercase, and can be passed directly to get_schema().
32
32
  *
33
33
  * @example
34
34
  * corsair.get_methods('slack')
35
- * // ['slack.channels.list', 'slack.channels.get', 'slack.messages.post', ...]
35
+ * // ['slack.api.channels.list', 'slack.api.channels.get', 'slack.api.messages.post', ...]
36
36
  */
37
37
  get_methods(plugin: string): string[];
38
38
  /**
39
39
  * Returns schema and metadata for a specific endpoint.
40
- * Pass the full dot-path including the plugin ID: 'slack.channels.list'.
40
+ * Pass the full dot-path including the plugin ID and 'api' segment: 'slack.api.channels.list'.
41
+ * Casing is ignored — the method string is lowercased before lookup.
41
42
  * If the method is not found, returns an empty result with `availableMethods` listing all valid paths.
42
43
  *
43
44
  * @example
44
- * corsair.get_schema('slack.channels.list')
45
+ * corsair.get_schema('slack.api.channels.list')
45
46
  * // { description: '...', riskLevel: 'read', input: { type: 'object', ... }, output: { ... } }
46
47
  *
47
- * corsair.get_schema('slack.invalid')
48
- * // { availableMethods: { slack: ['slack.channels.list', ...], ... } }
48
+ * corsair.get_schema('slack.api.channels.getHistory') // casing normalised automatically
49
+ * // { description: '...', riskLevel: 'read', input: { type: 'object', ... }, output: { ... } }
50
+ *
51
+ * corsair.get_schema('slack.api.invalid')
52
+ * // { availableMethods: { slack: ['slack.api.channels.list', ...], ... } }
49
53
  */
50
54
  get_schema(method: string): EndpointSchemaResult;
51
55
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/inspect/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAqFnE,MAAM,MAAM,oBAAoB,GAAG;IAClC,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC;IAC7C,4CAA4C;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACnC;;;;;;;OAOG;IACH,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtC;;;;;;;;;;;OAWG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACjD,CAAC;AAmFF;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,SAAS,aAAa,EAAE,GAC/B,qBAAqB,CASvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../core/inspect/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAqB,MAAM,YAAY,CAAC;AAqFnE,MAAM,MAAM,oBAAoB,GAAG;IAClC,6DAA6D;IAC7D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,aAAa,CAAC;IAC7C,4CAA4C;IAC5C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gEAAgE;IAChE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,yDAAyD;IACzD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAC5C,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IACnC;;;;;;;OAOG;IACH,WAAW,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACxC;;;;;;;OAOG;IACH,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACtC;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAAC;CACjD,CAAC;AA+GF;;;GAGG;AACH,wBAAgB,mBAAmB,CAClC,OAAO,EAAE,SAAS,aAAa,EAAE,GAC/B,qBAAqB,CASvB"}
@@ -95,7 +95,7 @@ function getMethods(plugins, plugin) {
95
95
  return [];
96
96
  const paths = [];
97
97
  walkEndpointTree(found.endpoints, [], paths);
98
- return paths.map((path) => `${found.id}.${path}`);
98
+ return paths.map((path) => `${found.id}.api.${path.toLowerCase()}`);
99
99
  }
100
100
  const result = {};
101
101
  for (const p of plugins) {
@@ -103,19 +103,39 @@ function getMethods(plugins, plugin) {
103
103
  continue;
104
104
  const paths = [];
105
105
  walkEndpointTree(p.endpoints, [], paths);
106
- result[p.id] = paths.map((path) => `${p.id}.${path}`);
106
+ result[p.id] = paths.map((path) => `${p.id}.api.${path.toLowerCase()}`);
107
107
  }
108
108
  return result;
109
109
  }
110
+ /**
111
+ * Case-insensitive lookup in an endpoint record (endpointMeta or endpointSchemas).
112
+ * Keys in those records use camelCase (e.g. 'channels.getHistory') while the
113
+ * normalised path coming from the agent is fully lowercased.
114
+ */
115
+ function findEndpointCaseInsensitive(record, lowercasedPath) {
116
+ if (!record)
117
+ return undefined;
118
+ for (const [key, value] of Object.entries(record)) {
119
+ if (key.toLowerCase() === lowercasedPath)
120
+ return value;
121
+ }
122
+ return undefined;
123
+ }
110
124
  function getSchema(plugins, method) {
111
- const dotIndex = method.indexOf('.');
125
+ // Normalise casing so the agent can call with any capitalisation
126
+ const normalised = method.toLowerCase();
127
+ const dotIndex = normalised.indexOf('.');
112
128
  if (dotIndex !== -1) {
113
- const pluginId = method.slice(0, dotIndex);
114
- const endpointPath = method.slice(dotIndex + 1);
129
+ const pluginId = normalised.slice(0, dotIndex);
130
+ let remainder = normalised.slice(dotIndex + 1);
131
+ // Strip the optional 'api.' segment (present in the new full-form paths)
132
+ if (remainder.startsWith('api.')) {
133
+ remainder = remainder.slice(4);
134
+ }
115
135
  const plugin = plugins.find((p) => p.id === pluginId);
116
136
  if (plugin) {
117
- const meta = plugin.endpointMeta?.[endpointPath];
118
- const schemas = plugin.endpointSchemas?.[endpointPath];
137
+ const meta = findEndpointCaseInsensitive(plugin.endpointMeta, remainder);
138
+ const schemas = findEndpointCaseInsensitive(plugin.endpointSchemas, remainder);
119
139
  // Valid entry — meta or schemas found
120
140
  if (meta || schemas) {
121
141
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "corsair",
3
- "version": "0.1.16",
3
+ "version": "0.1.17",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",