@agentage/extension 0.23.0 → 0.24.0

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/README.md CHANGED
@@ -11,7 +11,7 @@ npm install @agentage/extension express zod
11
11
  ```
12
12
 
13
13
  A part is one folder in `src/`. This MCP part, from the extension template, serves the tool
14
- `{id}__echo` on `POST /mcp`:
14
+ `{id}_echo` on `POST /mcp`:
15
15
 
16
16
  ```ts
17
17
  import { type McpContext } from '@agentage/extension';
@@ -31,6 +31,9 @@ export function create(ctx: McpContext) {
31
31
  }
32
32
  ```
33
33
 
34
+ Since 0.24.0 the kit names each tool `{id}_{name}`, with one underscore. Its schemas still accept
35
+ the old `{id}__{name}` for now, and refuse a tool of another id.
36
+
34
37
  Start a new extension with `npx @agentage/cli extension create my-ext`: it pins this kit for you.
35
38
 
36
39
  Since 0.23.0, `check` asks an app part for `@agentage/components` ^0.21, the library that replaces
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { CommandNameSchema, CommitSchema, ExtensionIdSchema, IMAGE_PART_KINDS, PrefixedToolNameSchema, SecretNameSchema, SecretPartSchema, StoreKindSchema, VersionSchema, } from '../manifest/primitives.schema.js';
2
+ import { CommandNameSchema, CommitSchema, ExtensionIdSchema, IMAGE_PART_KINDS, ownsTool, PrefixedToolNameSchema, SecretNameSchema, SecretPartSchema, StoreKindSchema, VersionSchema, } from '../manifest/primitives.schema.js';
3
3
  import { APP_ROW_RULE, appRowFits, AppRowSchema, ServesSchema } from './served.schema.js';
4
4
  // registry host[:port]/owner/{id}-{part}@sha256: deployed by digest, a version's images never change.
5
5
  const ImageDigestRefSchema = z
@@ -92,9 +92,9 @@ const openapiNamesItsExtension = ({ id, openapi }) => !openapi || /^\/api\/v[0-9
92
92
  const OPENAPI_RULE = { message: 'openapi is /api/{id}/openapi.json', path: ['openapi'] };
93
93
  // A served document has no old /api/v{N} form: what serves it now runs this kit.
94
94
  const openapiIsOwn = ({ id, openapi }) => !openapi || openapi === `/api/${id}/openapi.json`;
95
- // A served tool is {id}__{name} of this id: the host gives every tool under its extension.
96
- export const toolsAreOwn = ({ id, tools }) => (tools ?? []).every((t) => t.name.startsWith(`${id}__`));
97
- export const TOOLS_RULE = { message: 'every tool is {id}__{name}', path: ['tools'] };
95
+ // A served tool is {id}_{name} (or the old {id}__{name}) of this id: the host names it so.
96
+ export const toolsAreOwn = ({ id, tools }) => (tools ?? []).every((t) => ownsTool(id, t.name));
97
+ export const TOOLS_RULE = { message: 'every tool is {id}_{name}', path: ['tools'] };
98
98
  // A scoped name lives only in secretParts, so an estate that does not read it mounts nothing.
99
99
  const scoped = (name) => `secret ${name}: one or more parts, none repeated, and never also in secrets`;
100
100
  // The build record: written by `build --push` into the package and the release asset; no host.
@@ -32,6 +32,7 @@ export declare const StoreKindSchema: z.ZodEnum<{
32
32
  export declare const FULL_SHA: RegExp;
33
33
  export declare const CommitSchema: z.ZodString;
34
34
  export declare const PrefixedToolNameSchema: z.ZodString;
35
+ export declare const ownsTool: (id: string, name: string) => boolean;
35
36
  export declare const IMAGE_PART_KINDS: readonly ["pages", "ui", "api", "mcp", "worker"];
36
37
  export type ImagePartKind = (typeof IMAGE_PART_KINDS)[number];
37
38
  export declare const camelName: (name: string) => string;
@@ -55,10 +55,13 @@ export const SERVED_KINDS = ['postgres', 'signoz', 'git', 'clickhouse'];
55
55
  export const StoreKindSchema = z.enum(Object.keys(STORE_KINDS));
56
56
  export const FULL_SHA = /^[0-9a-f]{40}$/;
57
57
  export const CommitSchema = z.string().regex(FULL_SHA, { message: 'full 40-hex git sha' });
58
+ // {id}_{name} or the old {id}__{name}: an id has no _ and a name starts with a letter.
59
+ const OWN_TOOL_REST = /^__?[a-z][a-z0-9_-]*$/;
58
60
  export const PrefixedToolNameSchema = z
59
61
  .string()
60
62
  .max(64)
61
- .regex(/^[a-z][a-z0-9-]*__[a-z][a-z0-9_-]*$/);
63
+ .regex(/^[a-z][a-z0-9-]*__?[a-z][a-z0-9_-]*$/);
64
+ export const ownsTool = (id, name) => name.startsWith(id) && OWN_TOOL_REST.test(name.slice(id.length));
62
65
  export const IMAGE_PART_KINDS = ['pages', 'ui', 'api', 'mcp', 'worker'];
63
66
  export const camelName = (name) => name.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
64
67
  export const SecretPartSchema = z.enum(['pages', 'api', 'mcp', 'worker']);
package/dist/mcp/tools.js CHANGED
@@ -39,6 +39,6 @@ export const createToolRegistry = () => {
39
39
  const [tool, connector] = [registrarOn(tools), registrarOn(connectors)];
40
40
  return { tool, tools, instructions, served, connector, connectors };
41
41
  };
42
- export const prefixed = (id, name) => `${id}__${name}`;
43
- // A connector tool keeps its own name (search, fetch); every other is {id}__{name}.
42
+ export const prefixed = (id, name) => `${id}_${name}`;
43
+ // A connector tool keeps its own name (search, fetch); every other is {id}_{name}.
44
44
  export const nameOf = (id, name, bare) => bare ? name : prefixed(id, name);
@@ -41,7 +41,7 @@ const mcp = async (input) => {
41
41
  const paths = input.mcpPaths;
42
42
  const options = { ...input.base, tools: registered, listing, paths, ...served };
43
43
  const mount = (app) => mountWithConnector(app, options, registry.connectors);
44
- // Connector tools stay out of the record: the record lists the {id}__{name} tools only.
44
+ // Connector tools stay out of the record: the record lists the {id}_{name} tools only.
45
45
  const tools = toolRecords(input.pkg.agentage.id, registry.tools);
46
46
  return { mount, record: tools.length ? { tools } : {} };
47
47
  };
@@ -46,7 +46,7 @@ export const startTestServer = async (options) => {
46
46
  const base = { pkg, build: TEST_BUILD, log: ctx.log, wellKnown, files };
47
47
  return startOn(createApiApp({ ...base, router: mounted.router, routes: mounted.routes, ...guard }));
48
48
  };
49
- // Runs an mcp part's create(ctx) inside the kit's real /mcp app: tools named {id}__{name}; connector tools at /connector.
49
+ // Runs an mcp part's create(ctx) inside the kit's real /mcp app: tools named {id}_{name}; connector tools at /connector.
50
50
  export const startTestMcp = async (options) => {
51
51
  const ctx = options.ctx ?? createTestContext();
52
52
  const registry = createToolRegistry();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentage/extension",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "The agentage extension kit: create(ctx) per part (pages, ui, api, mcp, worker, cli), the store, /health, discovery, the envelope, and the build tool with up and token",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -186,7 +186,7 @@
186
186
  "name": {
187
187
  "type": "string",
188
188
  "maxLength": 64,
189
- "pattern": "^[a-z][a-z0-9-]*__[a-z][a-z0-9_-]*$"
189
+ "pattern": "^[a-z][a-z0-9-]*__?[a-z][a-z0-9_-]*$"
190
190
  },
191
191
  "scope": {
192
192
  "type": "string",
@@ -141,7 +141,7 @@
141
141
  "name": {
142
142
  "type": "string",
143
143
  "maxLength": 64,
144
- "pattern": "^[a-z][a-z0-9-]*__[a-z][a-z0-9_-]*$"
144
+ "pattern": "^[a-z][a-z0-9-]*__?[a-z][a-z0-9_-]*$"
145
145
  },
146
146
  "scope": {
147
147
  "type": "string",
@@ -94,7 +94,7 @@
94
94
  "name": {
95
95
  "type": "string",
96
96
  "maxLength": 64,
97
- "pattern": "^[a-z][a-z0-9-]*__[a-z][a-z0-9_-]*$"
97
+ "pattern": "^[a-z][a-z0-9-]*__?[a-z][a-z0-9_-]*$"
98
98
  },
99
99
  "scope": {
100
100
  "type": "string",