@agentage/extension 0.18.8 → 0.19.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.
Files changed (35) hide show
  1. package/dist/contracts/index.d.ts +2 -0
  2. package/dist/contracts/index.js +2 -0
  3. package/dist/discovery/combine.d.ts +57 -0
  4. package/dist/discovery/combine.js +86 -0
  5. package/dist/discovery/discovery.d.ts +15 -1
  6. package/dist/discovery/discovery.js +6 -2
  7. package/dist/discovery/discovery.schema.d.ts +35 -1
  8. package/dist/discovery/discovery.schema.js +14 -7
  9. package/dist/discovery/host-document.schema.d.ts +74 -0
  10. package/dist/discovery/host-document.schema.js +54 -0
  11. package/dist/discovery/route-table.d.ts +23 -0
  12. package/dist/discovery/route-table.js +24 -0
  13. package/dist/discovery/served.schema.d.ts +30 -0
  14. package/dist/discovery/served.schema.js +26 -0
  15. package/dist/host/daemon/shell-routes.d.ts +4 -3
  16. package/dist/host/daemon/shell-routes.js +8 -6
  17. package/dist/host/daemon/sign-in-page.d.ts +3 -0
  18. package/dist/host/daemon/sign-in-page.js +30 -0
  19. package/dist/host/host-parts.js +8 -1
  20. package/dist/host/index.d.ts +1 -0
  21. package/dist/host/index.js +1 -0
  22. package/dist/manifest/manifest.schema.d.ts +5 -0
  23. package/dist/manifest/manifest.schema.js +1 -1
  24. package/dist/schemas/json-schemas.js +5 -0
  25. package/dist/server/app.d.ts +2 -0
  26. package/dist/server/app.js +3 -9
  27. package/dist/server/discovery-handler.d.ts +6 -0
  28. package/dist/server/discovery-handler.js +14 -0
  29. package/dist/shell/dist/index.html +1 -1
  30. package/dist/tool/up/local-record.d.ts +2 -1
  31. package/dist/tool/up/local-record.js +3 -2
  32. package/dist/tool/up/up.js +1 -1
  33. package/package.json +1 -1
  34. package/schemas/extension-discovery.schema.json +51 -1
  35. package/schemas/host-document.schema.json +187 -0
@@ -1,5 +1,7 @@
1
1
  export { AGCID_HEADER, isAgcid } from '../agcid/header.js';
2
2
  export { CloudDiscoveryDocumentSchema, DiscoveryDocumentSchema, ExtensionRecordSchema, type DiscoveryDocument, type ExtensionRecord, } from '../discovery/discovery.schema.js';
3
+ export { entryOfDocument } from '../discovery/combine.js';
4
+ export { HostDocumentSchema, type HostDocument, type HostEntry, } from '../discovery/host-document.schema.js';
3
5
  export { ERROR_CODES, type ErrorCode } from '../envelope/codes.js';
4
6
  export { ErrorEnvelopeSchema, OkEnvelopeSchema } from '../envelope/envelope.schema.js';
5
7
  export { type ErrorEnvelope, type OkEnvelope } from '../envelope/envelope.js';
@@ -1,5 +1,7 @@
1
1
  export { AGCID_HEADER, isAgcid } from '../agcid/header.js';
2
2
  export { CloudDiscoveryDocumentSchema, DiscoveryDocumentSchema, ExtensionRecordSchema, } from '../discovery/discovery.schema.js';
3
+ export { entryOfDocument } from '../discovery/combine.js';
4
+ export { HostDocumentSchema, } from '../discovery/host-document.schema.js';
3
5
  export { ERROR_CODES } from '../envelope/codes.js';
4
6
  export { ErrorEnvelopeSchema, OkEnvelopeSchema } from '../envelope/envelope.schema.js';
5
7
  export {} from '../envelope/envelope.js';
@@ -0,0 +1,57 @@
1
+ import { type DiscoveryDocument } from './discovery.schema.js';
2
+ import { type Expose, type HostDocument, type HostKind } from './host-document.schema.js';
3
+ import { type Route } from './route-table.js';
4
+ export { type Route } from './route-table.js';
5
+ export interface HostInstallation {
6
+ host: string;
7
+ shell?: {
8
+ package: string;
9
+ version: string;
10
+ };
11
+ extensions: {
12
+ id: string;
13
+ version: string;
14
+ enabled?: boolean;
15
+ expose?: Expose;
16
+ }[];
17
+ }
18
+ export interface Answer {
19
+ upstream: string;
20
+ document: unknown;
21
+ }
22
+ export interface Refusal {
23
+ upstream: string;
24
+ id?: string;
25
+ reason: string;
26
+ }
27
+ export interface Combined {
28
+ document: HostDocument;
29
+ routes: Route[];
30
+ refused: Refusal[];
31
+ }
32
+ export declare const entryOfDocument: (doc: DiscoveryDocument) => {
33
+ app?: {
34
+ title: string;
35
+ entry: string;
36
+ css: string;
37
+ icon?: string | undefined;
38
+ order?: number | undefined;
39
+ } | undefined;
40
+ openapi?: string | undefined;
41
+ tools?: {
42
+ name: string;
43
+ scope: string;
44
+ }[] | undefined;
45
+ id: string;
46
+ version: string;
47
+ commit: string;
48
+ parts: ("pages" | "ui" | "api" | "mcp" | "worker" | "app")[];
49
+ };
50
+ export type CallerState = 'starting' | 'failed';
51
+ export interface CombineInput {
52
+ kind: HostKind;
53
+ installation: HostInstallation;
54
+ answers: Answer[];
55
+ states?: Record<string, CallerState>;
56
+ }
57
+ export declare const combineHost: ({ kind, installation, answers, states }: CombineInput) => Combined;
@@ -0,0 +1,86 @@
1
+ import { DiscoveryDocumentSchema } from './discovery.schema.js';
2
+ import { HostDocumentSchema, } from './host-document.schema.js';
3
+ import { routeTable } from './route-table.js';
4
+ import { SERVES_KINDS } from './served.schema.js';
5
+ export {} from './route-table.js';
6
+ // The fields of one extension document that the host document repeats as they are.
7
+ export const entryOfDocument = (doc) => ({
8
+ id: doc.id,
9
+ version: doc.version,
10
+ commit: doc.commit,
11
+ parts: SERVES_KINDS.filter((kind) => doc.serves.includes(kind)),
12
+ ...(doc.tools && { tools: doc.tools }),
13
+ ...(doc.openapi && { openapi: doc.openapi }),
14
+ ...(doc.app && { app: doc.app }),
15
+ });
16
+ const issuesOf = (error) => error.issues.map((i) => `${i.path.map(String).join('.')}: ${i.message}`).join('; ');
17
+ // Why an answer is not used for its row, or null when it is.
18
+ const refusalOf = (doc, row, first) => {
19
+ if (!row)
20
+ return 'unknown id';
21
+ if (row.enabled === false)
22
+ return 'disabled';
23
+ if (doc.version !== row.version)
24
+ return `version ${doc.version}, not ${row.version}`;
25
+ return first && first.commit !== doc.commit ? `another build than ${first.commit}` : null;
26
+ };
27
+ // Each valid answer under its id, in answer order; every other answer is refused with its reason.
28
+ const sortAnswers = (rows, answers) => {
29
+ const byId = new Map();
30
+ const refused = [];
31
+ for (const { upstream, document } of answers) {
32
+ if (document === null || document === undefined)
33
+ continue;
34
+ const parsed = DiscoveryDocumentSchema.safeParse(document);
35
+ if (!parsed.success) {
36
+ refused.push({ upstream, reason: `invalid: ${issuesOf(parsed.error)}` });
37
+ continue;
38
+ }
39
+ const doc = parsed.data;
40
+ const reason = refusalOf(doc, rows.find((r) => r.id === doc.id), byId.get(doc.id)?.[0]?.doc);
41
+ if (reason)
42
+ refused.push({ upstream, id: doc.id, reason });
43
+ else
44
+ byId.set(doc.id, [...(byId.get(doc.id) ?? []), { upstream, doc }]);
45
+ }
46
+ return { byId, refused };
47
+ };
48
+ const stateOf = (row, served, told) => {
49
+ if (row.enabled === false)
50
+ return 'disabled';
51
+ return told ?? (served.length ? 'running' : 'down');
52
+ };
53
+ // Parts and fields of every container of one id; the first document wins a field two give.
54
+ // An entry that is not running keeps the fields of the last good document the caller passes.
55
+ const entryOf = (row, served, told) => {
56
+ const expose = row.expose ?? {};
57
+ const state = stateOf(row, served, told);
58
+ const docs = served.map((s) => entryOfDocument(s.doc));
59
+ if (!docs.length)
60
+ return { id: row.id, version: row.version, parts: [], expose, state };
61
+ const parts = SERVES_KINDS.filter((kind) => docs.some((d) => d.parts.includes(kind)));
62
+ return { ...docs.reduceRight((later, doc) => ({ ...later, ...doc })), parts, expose, state };
63
+ };
64
+ const documentOf = (installation, kind, entries) => {
65
+ const { shell } = installation;
66
+ const named = shell && { shell: { package: shell.package, version: shell.version } };
67
+ return HostDocumentSchema.parse({ host: installation.host, kind, ...named, extensions: entries });
68
+ };
69
+ const pagesRefusal = (route, site) => ({
70
+ upstream: route.upstream,
71
+ id: route.id,
72
+ reason: `a second pages route: / is ${site?.id ?? ''}`,
73
+ });
74
+ // No I/O: the installation and each container's answer in; the host document and routes out.
75
+ // Throws when the installation gives a document the host schema refuses (two rows of one id).
76
+ export const combineHost = ({ kind, installation, answers, states }) => {
77
+ const { byId, refused } = sortAnswers(installation.extensions, answers);
78
+ const rows = installation.extensions.map((row) => {
79
+ const served = byId.get(row.id) ?? [];
80
+ return { entry: entryOf(row, served, states?.[row.id]), served };
81
+ });
82
+ const document = documentOf(installation, kind, rows.map((r) => r.entry));
83
+ const { routes, dropped } = routeTable(rows);
84
+ const site = routes.find((r) => r.part === 'pages');
85
+ return { document, routes, refused: [...refused, ...dropped.map((r) => pagesRefusal(r, site))] };
86
+ };
@@ -2,6 +2,7 @@ import { type ExtensionPackage } from '../manifest/manifest.schema.js';
2
2
  import { type HostPartKind } from '../manifest/parts.js';
3
3
  import { type ImagePartKind } from '../manifest/primitives.schema.js';
4
4
  import { type DiscoveryDocument, type ExtensionRecord } from './discovery.schema.js';
5
+ import { type AppRowDoc, type ServesKind } from './served.schema.js';
5
6
  export interface BuildInfo {
6
7
  commit: string;
7
8
  buildTime: string;
@@ -28,7 +29,20 @@ export type ServedRecord = Omit<ExtensionRecord, 'parts'> & {
28
29
  export declare const hostedRecordOf: (pkg: ExtensionPackage, build: BuildInfo, hosted: readonly HostPartKind[], extras: RecordExtras) => ServedRecord;
29
30
  export declare const validateRecord: (value: unknown) => ExtensionRecord;
30
31
  export declare const loadRecord: (file: string) => Promise<ExtensionRecord | null>;
31
- export declare const discoveryDocument: (record: ServedRecord, host: string) => {
32
+ export interface Serving {
33
+ serves: ServesKind[];
34
+ app?: AppRowDoc;
35
+ }
36
+ export declare const servingOf: (parts: readonly ImagePartKind[], app?: AppRowDoc) => Serving;
37
+ export declare const discoveryDocument: (record: ServedRecord, host: string, serving: Serving) => {
38
+ app?: {
39
+ title: string;
40
+ entry: string;
41
+ css: string;
42
+ icon?: string | undefined;
43
+ order?: number | undefined;
44
+ } | undefined;
45
+ serves: ("pages" | "ui" | "api" | "mcp" | "worker" | "app")[];
32
46
  commands?: string[] | undefined;
33
47
  secrets?: string[] | undefined;
34
48
  image?: string | undefined;
@@ -3,6 +3,7 @@ import {} from '../manifest/manifest.schema.js';
3
3
  import { normalizeParts, scopedSecrets } from '../manifest/parts.js';
4
4
  import {} from '../manifest/primitives.schema.js';
5
5
  import { ExtensionRecordSchema, } from './discovery.schema.js';
6
+ import {} from './served.schema.js';
6
7
  export const DEFAULT_RECORD_FILE = '/run/agentage/agentage-extension.json';
7
8
  const partsOf = (pkg, images, migrations) => {
8
9
  const parts = {};
@@ -51,9 +52,12 @@ export const loadRecord = async (file) => {
51
52
  const record = await readJsonIfExists(file);
52
53
  return record === undefined ? null : validateRecord(record);
53
54
  };
54
- export const discoveryDocument = (record, host) => {
55
+ // A part image serves its own part; a host every part it runs, and app when it has a nav row.
56
+ export const servingOf = (parts, app) => app ? { serves: [...parts, 'app'], app } : { serves: [...parts] };
57
+ export const discoveryDocument = (record, host, serving) => {
55
58
  const { id, version, commit, buildTime, ...rest } = record;
56
59
  delete rest.secrets;
57
60
  delete rest.secretParts;
58
- return { id, version, commit, buildTime, host, ...rest };
61
+ const app = serving.app && { app: serving.app };
62
+ return { id, version, commit, buildTime, host, ...rest, serves: serving.serves, ...app };
59
63
  };
@@ -5,6 +5,10 @@ export declare const WidgetSchema: z.ZodObject<{
5
5
  element: z.ZodString;
6
6
  module: z.ZodString;
7
7
  }, z.core.$strict>;
8
+ export declare const ToolRecordSchema: z.ZodObject<{
9
+ name: z.ZodString;
10
+ scope: z.ZodString;
11
+ }, z.core.$strict>;
8
12
  export declare const ExtensionRecordSchema: z.ZodObject<{
9
13
  secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
10
14
  secretParts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodEnum<{
@@ -57,6 +61,22 @@ export declare const ExtensionRecordSchema: z.ZodObject<{
57
61
  commands: z.ZodOptional<z.ZodArray<z.ZodString>>;
58
62
  }, z.core.$strict>;
59
63
  export declare const DiscoveryDocumentSchema: z.ZodObject<{
64
+ host: z.ZodString;
65
+ serves: z.ZodArray<z.ZodEnum<{
66
+ pages: "pages";
67
+ ui: "ui";
68
+ api: "api";
69
+ mcp: "mcp";
70
+ worker: "worker";
71
+ app: "app";
72
+ }>>;
73
+ app: z.ZodOptional<z.ZodObject<{
74
+ title: z.ZodString;
75
+ icon: z.ZodOptional<z.ZodString>;
76
+ order: z.ZodOptional<z.ZodInt>;
77
+ entry: z.ZodString;
78
+ css: z.ZodString;
79
+ }, z.core.$strict>>;
60
80
  parts: z.ZodObject<{
61
81
  pages: z.ZodOptional<z.ZodObject<{
62
82
  image: z.ZodString;
@@ -83,7 +103,6 @@ export declare const DiscoveryDocumentSchema: z.ZodObject<{
83
103
  migrations: z.ZodOptional<z.ZodInt>;
84
104
  }, z.core.$strict>>;
85
105
  }, z.core.$strict>;
86
- host: z.ZodString;
87
106
  id: z.ZodString;
88
107
  version: z.ZodString;
89
108
  commit: z.ZodString;
@@ -103,6 +122,21 @@ export declare const DiscoveryDocumentSchema: z.ZodObject<{
103
122
  }, z.core.$strict>;
104
123
  export declare const CloudDiscoveryDocumentSchema: z.ZodObject<{
105
124
  host: z.ZodString;
125
+ serves: z.ZodArray<z.ZodEnum<{
126
+ pages: "pages";
127
+ ui: "ui";
128
+ api: "api";
129
+ mcp: "mcp";
130
+ worker: "worker";
131
+ app: "app";
132
+ }>>;
133
+ app: z.ZodOptional<z.ZodObject<{
134
+ title: z.ZodString;
135
+ icon: z.ZodOptional<z.ZodString>;
136
+ order: z.ZodOptional<z.ZodInt>;
137
+ entry: z.ZodString;
138
+ css: z.ZodString;
139
+ }, z.core.$strict>>;
106
140
  id: z.ZodString;
107
141
  version: z.ZodString;
108
142
  commit: z.ZodString;
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { CommandNameSchema, CommitSchema, ExtensionIdSchema, IMAGE_PART_KINDS, PrefixedToolNameSchema, SecretNameSchema, SecretPartSchema, StoreKindSchema, VersionSchema, } from '../manifest/primitives.schema.js';
3
+ import { APP_ROW_RULE, appRowFits, AppRowSchema, ServesSchema } from './served.schema.js';
3
4
  // registry host[:port]/owner/{id}-{part}@sha256: deployed by digest, a version's images never change.
4
5
  const ImageDigestRefSchema = z
5
6
  .string()
@@ -42,7 +43,7 @@ export const WidgetSchema = z.strictObject({
42
43
  element: z.string().regex(/^[a-z][a-z0-9]*-[a-z0-9-]+$/),
43
44
  module: z.string().regex(/^\/ui\/[^/]+\/[^/]+\.m?js$/),
44
45
  });
45
- const ToolRecordSchema = z.strictObject({
46
+ export const ToolRecordSchema = z.strictObject({
46
47
  name: PrefixedToolNameSchema,
47
48
  scope: z.string().regex(/^(public|[a-z][a-z0-9-]*:(read|write|admin))$/),
48
49
  });
@@ -86,9 +87,11 @@ const HOSTED_RULE = {
86
87
  message: 'at least one part with an image, the one image, or only parts with no image',
87
88
  path: ['parts'],
88
89
  };
89
- // The api prefix is /api/{id}, or the old /api/v{N}: never another extension's id.
90
+ // In a build record the api prefix is /api/{id}, or the old /api/v{N}: never another extension's id.
90
91
  const openapiNamesItsExtension = ({ id, openapi }) => !openapi || /^\/api\/v[0-9]+\//.test(openapi) || openapi === `/api/${id}/openapi.json`;
91
92
  const OPENAPI_RULE = { message: 'openapi is /api/{id}/openapi.json', path: ['openapi'] };
93
+ // A served document has no old /api/v{N} form: what serves it now runs this kit.
94
+ const openapiIsOwn = ({ id, openapi }) => !openapi || openapi === `/api/${id}/openapi.json`;
92
95
  // A scoped name lives only in secretParts, so an estate that does not read it mounts nothing.
93
96
  const scoped = (name) => `secret ${name}: one or more parts, none repeated, and never also in secrets`;
94
97
  // The build record: written by `build --push` into the package and the release asset; no host.
@@ -107,15 +110,19 @@ export const ExtensionRecordSchema = z
107
110
  if (!parts.length || new Set(parts).size !== parts.length || doc.secrets?.includes(name))
108
111
  ctx.addIssue({ code: 'custom', path: ['secretParts', name], message: scoped(name) });
109
112
  });
110
- // What a deployment serves at /.well-known/agentage-extension.json: the record plus its host.
113
+ // The record as served: its host, the parts this container answers for and the app nav row.
114
+ const servedShape = { host: OriginSchema, serves: ServesSchema, app: AppRowSchema.optional() };
115
+ // What a deployment serves at /.well-known/agentage-extension.json.
111
116
  export const DiscoveryDocumentSchema = z
112
- .strictObject({ ...recordShape, parts: ServedPartsSchema, host: OriginSchema })
117
+ .strictObject({ ...recordShape, parts: ServedPartsSchema, ...servedShape })
113
118
  .refine(servedForm, HOSTED_RULE)
119
+ .refine(appRowFits, APP_ROW_RULE)
114
120
  .refine(imagesNameTheirExtension, IMAGE_RULE)
115
- .refine(openapiNamesItsExtension, OPENAPI_RULE);
121
+ .refine(openapiIsOwn, OPENAPI_RULE);
116
122
  // The form the cloud serves: every part by its image, or the one image; never a part with no image.
117
123
  export const CloudDiscoveryDocumentSchema = z
118
- .strictObject({ ...recordShape, host: OriginSchema })
124
+ .strictObject({ ...recordShape, ...servedShape })
119
125
  .refine(oneImageForm, FORM_RULE)
126
+ .refine(appRowFits, APP_ROW_RULE)
120
127
  .refine(imagesNameTheirExtension, IMAGE_RULE)
121
- .refine(openapiNamesItsExtension, OPENAPI_RULE);
128
+ .refine(openapiIsOwn, OPENAPI_RULE);
@@ -0,0 +1,74 @@
1
+ import { z } from 'zod';
2
+ export declare const HOST_KINDS: readonly ["local", "cloud"];
3
+ export declare const ENTRY_STATES: readonly ["running", "starting", "failed", "disabled", "down"];
4
+ export declare const ExposeSchema: z.ZodObject<{
5
+ mcp: z.ZodOptional<z.ZodEnum<{
6
+ public: "public";
7
+ internal: "internal";
8
+ }>>;
9
+ api: z.ZodOptional<z.ZodEnum<{
10
+ public: "public";
11
+ internal: "internal";
12
+ }>>;
13
+ app: z.ZodOptional<z.ZodLiteral<"public">>;
14
+ pages: z.ZodOptional<z.ZodLiteral<"public">>;
15
+ }, z.core.$strict>;
16
+ export declare const HostDocumentSchema: z.ZodObject<{
17
+ host: z.ZodString;
18
+ kind: z.ZodEnum<{
19
+ cloud: "cloud";
20
+ local: "local";
21
+ }>;
22
+ shell: z.ZodOptional<z.ZodObject<{
23
+ package: z.ZodString;
24
+ version: z.ZodString;
25
+ }, z.core.$strict>>;
26
+ extensions: z.ZodArray<z.ZodObject<{
27
+ id: z.ZodString;
28
+ version: z.ZodString;
29
+ commit: z.ZodOptional<z.ZodString>;
30
+ parts: z.ZodArray<z.ZodEnum<{
31
+ pages: "pages";
32
+ ui: "ui";
33
+ api: "api";
34
+ mcp: "mcp";
35
+ worker: "worker";
36
+ app: "app";
37
+ }>>;
38
+ tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
39
+ name: z.ZodString;
40
+ scope: z.ZodString;
41
+ }, z.core.$strict>>>;
42
+ openapi: z.ZodOptional<z.ZodString>;
43
+ app: z.ZodOptional<z.ZodObject<{
44
+ title: z.ZodString;
45
+ icon: z.ZodOptional<z.ZodString>;
46
+ order: z.ZodOptional<z.ZodInt>;
47
+ entry: z.ZodString;
48
+ css: z.ZodString;
49
+ }, z.core.$strict>>;
50
+ expose: z.ZodObject<{
51
+ mcp: z.ZodOptional<z.ZodEnum<{
52
+ public: "public";
53
+ internal: "internal";
54
+ }>>;
55
+ api: z.ZodOptional<z.ZodEnum<{
56
+ public: "public";
57
+ internal: "internal";
58
+ }>>;
59
+ app: z.ZodOptional<z.ZodLiteral<"public">>;
60
+ pages: z.ZodOptional<z.ZodLiteral<"public">>;
61
+ }, z.core.$strict>;
62
+ state: z.ZodEnum<{
63
+ failed: "failed";
64
+ running: "running";
65
+ starting: "starting";
66
+ disabled: "disabled";
67
+ down: "down";
68
+ }>;
69
+ }, z.core.$strict>>;
70
+ }, z.core.$strict>;
71
+ export type HostDocument = z.infer<typeof HostDocumentSchema>;
72
+ export type HostEntry = HostDocument['extensions'][number];
73
+ export type HostKind = (typeof HOST_KINDS)[number];
74
+ export type Expose = z.infer<typeof ExposeSchema>;
@@ -0,0 +1,54 @@
1
+ import { z } from 'zod';
2
+ import { CommitSchema, ExtensionIdSchema, PackageNameSchema, VersionSchema, } from '../manifest/primitives.schema.js';
3
+ import { ToolRecordSchema } from './discovery.schema.js';
4
+ import { APP_ROW_RULE, appRowFits, AppRowSchema, SERVES_KINDS } from './served.schema.js';
5
+ export const HOST_KINDS = ['local', 'cloud'];
6
+ // down: the installation lists it and no container answered with a valid document.
7
+ export const ENTRY_STATES = ['running', 'starting', 'failed', 'disabled', 'down'];
8
+ const ServedExposeSchema = z.enum(['public', 'internal']);
9
+ // A part not named is off; app and pages are for the internet or not at all.
10
+ export const ExposeSchema = z.strictObject({
11
+ mcp: ServedExposeSchema.optional(),
12
+ api: ServedExposeSchema.optional(),
13
+ app: z.literal('public').optional(),
14
+ pages: z.literal('public').optional(),
15
+ });
16
+ const ExtensionEntrySchema = z
17
+ .strictObject({
18
+ id: ExtensionIdSchema,
19
+ version: VersionSchema,
20
+ commit: CommitSchema.optional(),
21
+ parts: z.array(z.enum(SERVES_KINDS)),
22
+ tools: z.array(ToolRecordSchema).min(1).optional(),
23
+ openapi: z
24
+ .string()
25
+ .regex(/^\/api\/[a-z][a-z0-9-]*\/openapi\.json$/)
26
+ .optional(),
27
+ app: AppRowSchema.optional(),
28
+ expose: ExposeSchema,
29
+ state: z.enum(ENTRY_STATES),
30
+ })
31
+ .refine(({ id, parts, app }) => appRowFits({ id, serves: parts, app }), APP_ROW_RULE)
32
+ .refine(({ id, openapi }) => !openapi || openapi === `/api/${id}/openapi.json`, {
33
+ message: 'openapi is /api/{id}/openapi.json',
34
+ path: ['openapi'],
35
+ })
36
+ .refine(({ id, tools }) => (tools ?? []).every((t) => t.name.startsWith(`${id}__`)), {
37
+ message: 'every tool is {id}__{name}',
38
+ path: ['tools'],
39
+ });
40
+ // The shell is a library the host serves: named here only, never a row of extensions.
41
+ const ShellSchema = z.strictObject({ package: PackageNameSchema, version: VersionSchema });
42
+ const uniqueIds = ({ extensions }) => new Set(extensions.map((e) => e.id)).size === extensions.length;
43
+ // GET /.well-known/agentage-host.json: one app host, built from the documents of its extensions.
44
+ export const HostDocumentSchema = z
45
+ .strictObject({
46
+ host: z
47
+ .string()
48
+ .max(63)
49
+ .regex(/^[a-z][a-z0-9-]*$/),
50
+ kind: z.enum(HOST_KINDS),
51
+ shell: ShellSchema.optional(),
52
+ extensions: z.array(ExtensionEntrySchema),
53
+ })
54
+ .refine(uniqueIds, { message: 'one entry for each id', path: ['extensions'] });
@@ -0,0 +1,23 @@
1
+ import { type DiscoveryDocument } from './discovery.schema.js';
2
+ import { type HostEntry } from './host-document.schema.js';
3
+ declare const ROUTED: readonly ["api", "mcp", "app", "pages"];
4
+ export type RoutedPart = (typeof ROUTED)[number];
5
+ export interface Route {
6
+ prefix: string;
7
+ id: string;
8
+ part: RoutedPart;
9
+ upstream: string;
10
+ expose: 'public' | 'internal';
11
+ }
12
+ export interface Served {
13
+ upstream: string;
14
+ doc: DiscoveryDocument;
15
+ }
16
+ export declare const routeTable: (entries: {
17
+ entry: HostEntry;
18
+ served: Served[];
19
+ }[]) => {
20
+ routes: Route[];
21
+ dropped: Route[];
22
+ };
23
+ export {};
@@ -0,0 +1,24 @@
1
+ import {} from './discovery.schema.js';
2
+ import {} from './host-document.schema.js';
3
+ // The parts a host routes by path; worker and ui are never routed, pages own the rest of the paths.
4
+ const ROUTED = ['api', 'mcp', 'app', 'pages'];
5
+ const prefixOf = (part, id) => (part === 'pages' ? '/' : `/${part}/${id}`);
6
+ // A running entry's part routes to the first container that serves it, when the installation exposes it.
7
+ const routesOf = (entry, served) => ROUTED.flatMap((part) => {
8
+ if (entry.state !== 'running')
9
+ return [];
10
+ const expose = entry.expose[part];
11
+ const by = served.find(({ doc }) => doc.serves.includes(part));
12
+ if (!expose || !by)
13
+ return [];
14
+ return [
15
+ { prefix: prefixOf(part, entry.id), id: entry.id, part, upstream: by.upstream, expose },
16
+ ];
17
+ });
18
+ // In installation order; one pages route (the first row's) goes last, since / matches every path.
19
+ export const routeTable = (entries) => {
20
+ const all = entries.flatMap(({ entry, served }) => routesOf(entry, served));
21
+ const [site, ...more] = all.filter((r) => r.part === 'pages');
22
+ const routes = [...all.filter((r) => r.part !== 'pages'), ...(site ? [site] : [])];
23
+ return { routes, dropped: more };
24
+ };
@@ -0,0 +1,30 @@
1
+ import { z } from 'zod';
2
+ export declare const SERVES_KINDS: readonly ["pages", "ui", "api", "mcp", "worker", "app"];
3
+ export type ServesKind = (typeof SERVES_KINDS)[number];
4
+ export declare const ServesSchema: z.ZodArray<z.ZodEnum<{
5
+ pages: "pages";
6
+ ui: "ui";
7
+ api: "api";
8
+ mcp: "mcp";
9
+ worker: "worker";
10
+ app: "app";
11
+ }>>;
12
+ export declare const AppRowSchema: z.ZodObject<{
13
+ title: z.ZodString;
14
+ icon: z.ZodOptional<z.ZodString>;
15
+ order: z.ZodOptional<z.ZodInt>;
16
+ entry: z.ZodString;
17
+ css: z.ZodString;
18
+ }, z.core.$strict>;
19
+ export type AppRowDoc = z.infer<typeof AppRowSchema>;
20
+ interface ServedRow {
21
+ id: string;
22
+ serves: readonly ServesKind[];
23
+ app?: AppRowDoc;
24
+ }
25
+ export declare const appRowFits: ({ id, serves, app }: ServedRow) => boolean;
26
+ export declare const APP_ROW_RULE: {
27
+ message: string;
28
+ path: string[];
29
+ };
30
+ export {};
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { AppMetaSchema } from '../manifest/manifest.schema.js';
3
+ import { IMAGE_PART_KINDS } from '../manifest/primitives.schema.js';
4
+ // What one container answers for: its part kinds, and app when it serves the bundle at /app/{id}/.
5
+ export const SERVES_KINDS = [...IMAGE_PART_KINDS, 'app'];
6
+ const noRepeat = (kinds) => new Set(kinds).size === kinds.length;
7
+ export const ServesSchema = z
8
+ .array(z.enum(SERVES_KINDS))
9
+ .min(1)
10
+ .refine(noRepeat, { message: 'each part once' });
11
+ // The nav row of the app part: its meta and the content-hashed bundle files.
12
+ export const AppRowSchema = AppMetaSchema.extend({
13
+ entry: z.string().regex(/^\/app\/[a-z][a-z0-9-]*\/app-[0-9a-f]+\.js$/),
14
+ css: z.string().regex(/^\/app\/[a-z][a-z0-9-]*\/app-[0-9a-f]+\.css$/),
15
+ });
16
+ // The app row comes with app in serves, and its files sit under /app/{id}/ of this id.
17
+ export const appRowFits = ({ id, serves, app }) => {
18
+ if (!app)
19
+ return !serves.includes('app');
20
+ const at = `/app/${id}/`;
21
+ return serves.includes('app') && app.entry.startsWith(at) && app.css.startsWith(at);
22
+ };
23
+ export const APP_ROW_RULE = {
24
+ message: 'app is set exactly when serves lists app, with files under /app/{id}/',
25
+ path: ['app'],
26
+ };
@@ -12,12 +12,13 @@ export declare const readShell: (dir: string, version?: string) => Promise<Shell
12
12
  type User = {
13
13
  id: string;
14
14
  email?: string;
15
- name?: string;
16
15
  };
17
- export declare const sessionOf: ({ sub, text }: CliUser) => {
16
+ type Session = {
18
17
  user: User | null;
19
- host: "local";
18
+ host: 'local';
19
+ signIn?: string;
20
20
  };
21
+ export declare const sessionOf: ({ sub, text }: CliUser) => Session;
21
22
  export declare const shellRoutes: (app: Express, { shell, entries, events, user }: ShellDeps) => void;
22
23
  export interface ShellDeps {
23
24
  shell?: Shell;
@@ -8,6 +8,7 @@ import { hasApp } from './app-files.js';
8
8
  import {} from './cli-user-watch.js';
9
9
  import {} from './entries.js';
10
10
  import {} from './shell-events.js';
11
+ import { LOCAL_SIGN_IN, signInPage } from './sign-in-page.js';
11
12
  // The shell the kit carries (dist/shell, written by the kit build); none when run from src.
12
13
  export const kitShellDir = (base = import.meta.url) => {
13
14
  const dir = fileURLToPath(new URL('../../shell', base));
@@ -21,11 +22,11 @@ export const readShell = async (dir, version) => {
21
22
  return { dir, package: pkg.name, version: version ?? pkg.version };
22
23
  };
23
24
  const textOf = (value) => (typeof value === 'string' ? value : undefined);
24
- // K9: the user the children run as (issuer checked in cli-user.ts); email, name of its auth.json.
25
- // No `signIn` (S4 A4): on the daemon the shell keeps its `agentage setup` hint.
25
+ // K9: the user the children run as (issuer checked in cli-user.ts) and the email of its auth.json.
26
+ // The fields of a cloud app host's session (id, email; no name), so both frames show one label.
26
27
  export const sessionOf = ({ sub, text }) => {
27
28
  if (sub === undefined)
28
- return { user: null, host: 'local' };
29
+ return { user: null, host: 'local', signIn: LOCAL_SIGN_IN };
29
30
  let shown = {};
30
31
  try {
31
32
  shown = JSON.parse(text ?? '').user ?? {};
@@ -34,8 +35,7 @@ export const sessionOf = ({ sub, text }) => {
34
35
  // the sub alone
35
36
  }
36
37
  const email = textOf(shown['email']);
37
- const name = textOf(shown['name']);
38
- return { user: { id: sub, ...(email && { email }), ...(name && { name }) }, host: 'local' };
38
+ return { user: { id: sub, ...(email && { email }) }, host: 'local' };
39
39
  };
40
40
  // First path segments that are daemon routes: an unknown path under them stays a JSON 404.
41
41
  const OWN = new Set(['api', 'mcp', 'host', 'shell', 'app', 'health', '.well-known']);
@@ -52,11 +52,13 @@ const page = (shell, entries) => async (req, res, next) => {
52
52
  const notAFile = (req) => {
53
53
  throw fail('NOT_FOUND', `${req.originalUrl} is not a shell file`);
54
54
  };
55
- // S1.2.1: /, /{id}/* (the shell page, 404 for an id with no app), /shell/*, the session, the events.
55
+ // S1.2.1: /, /{id}/* (the shell page, 404 for an id with no app), /shell/*, the session, the events,
56
+ // and the page of the Sign in link.
56
57
  export const shellRoutes = (app, { shell, entries, events, user }) => {
57
58
  app.get('/shell/session', async (_req, res) => {
58
59
  res.set('Cache-Control', 'no-store').json(sessionOf(user));
59
60
  });
61
+ app.get(LOCAL_SIGN_IN, signInPage);
60
62
  app.get('/shell/events', events.stream);
61
63
  if (!shell)
62
64
  return;
@@ -0,0 +1,3 @@
1
+ import { type RequestHandler } from 'express';
2
+ export declare const LOCAL_SIGN_IN = "/shell/sign-in";
3
+ export declare const signInPage: RequestHandler;
@@ -0,0 +1,30 @@
1
+ import {} from 'express';
2
+ // The shell's Sign in link on the daemon: one fixed same-origin path, never a URL of another origin.
3
+ export const LOCAL_SIGN_IN = '/shell/sign-in';
4
+ const PAGE = `<!doctype html>
5
+ <html lang="en">
6
+ <meta charset="utf-8">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1">
8
+ <title>Sign in - agentage</title>
9
+ <style>
10
+ :root { color-scheme: light dark; }
11
+ body { font: 15px/1.5 system-ui, sans-serif; max-width: 32rem; margin: 15vh auto; padding: 0 16px; }
12
+ code { font-size: 14px; padding: 2px 6px; border-radius: 4px; background: rgba(127, 127, 127, 0.18); }
13
+ </style>
14
+ <h1>Sign in</h1>
15
+ <p>This dashboard runs on your machine. To sign in, run <code>agentage setup</code> in a terminal.</p>
16
+ <p>The dashboard shows your account a few seconds after the sign-in.</p>
17
+ <p><a href="/">Back to the dashboard</a></p>
18
+ </html>
19
+ `;
20
+ // A browser cannot start the cli: the page says how to sign in. The desktop catches the link first.
21
+ export const signInPage = (_req, res) => {
22
+ res
23
+ .status(200)
24
+ .set({
25
+ 'Content-Type': 'text/html; charset=utf-8',
26
+ 'Cache-Control': 'no-store',
27
+ 'Content-Security-Policy': "default-src 'none'; style-src 'unsafe-inline'",
28
+ })
29
+ .send(PAGE);
30
+ };
@@ -80,7 +80,14 @@ export const hostPartsOf = async (h, base) => {
80
80
  mounts.forEach((m) => m.mount(app));
81
81
  };
82
82
  const record = await recordOf(h, parts, mounts);
83
- const app = createPartApp({ ...base, parts, part: 'api', mount, record });
83
+ const app = createPartApp({
84
+ ...base,
85
+ parts,
86
+ part: 'api',
87
+ mount,
88
+ record,
89
+ ...(row && { app: row }),
90
+ });
84
91
  const start = () => mounts.forEach((m) => m.start?.());
85
92
  const stop = async () => void (await Promise.all(mounts.map((m) => m.stop?.())));
86
93
  return { app, parts, start, stop };
@@ -1,3 +1,4 @@
1
+ export { combineHost, type Answer, type Combined, type HostInstallation, type Refusal, type Route, } from '../discovery/combine.js';
1
2
  export { capabilities } from '../tool/capabilities.js';
2
3
  export { localOnly } from './daemon/guard.js';
3
4
  export { createDaemon, DAEMON_PORT, type Daemon, type DaemonOptions } from './daemon/daemon.js';
@@ -1,3 +1,4 @@
1
+ export { combineHost, } from '../discovery/combine.js';
1
2
  export { capabilities } from '../tool/capabilities.js';
2
3
  export { localOnly } from './daemon/guard.js';
3
4
  export { createDaemon, DAEMON_PORT } from './daemon/daemon.js';
@@ -51,6 +51,11 @@ declare const CommandSchema: z.ZodObject<{
51
51
  description: z.ZodOptional<z.ZodString>;
52
52
  }, z.core.$strict>>>;
53
53
  }, z.core.$strict>;
54
+ export declare const AppMetaSchema: z.ZodObject<{
55
+ title: z.ZodString;
56
+ icon: z.ZodOptional<z.ZodString>;
57
+ order: z.ZodOptional<z.ZodInt>;
58
+ }, z.core.$strict>;
54
59
  export declare const PackageSchema: z.ZodObject<{
55
60
  name: z.ZodString;
56
61
  version: z.ZodString;
@@ -54,7 +54,7 @@ const SecretSchema = z.union([
54
54
  z.strictObject({ name: SecretNameSchema, parts: z.array(SecretPartSchema).min(1) }),
55
55
  ]);
56
56
  // The nav row of the app part; icon is a lucide icon name.
57
- const AppMetaSchema = z.strictObject({
57
+ export const AppMetaSchema = z.strictObject({
58
58
  title: z.string().min(1).max(40),
59
59
  icon: z
60
60
  .string()
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { DiscoveryDocumentSchema, ExtensionRecordSchema } from '../discovery/discovery.schema.js';
3
+ import { HostDocumentSchema } from '../discovery/host-document.schema.js';
3
4
  import { ErrorEnvelopeSchema, OkEnvelopeSchema } from '../envelope/envelope.schema.js';
4
5
  import { HealthSchema } from '../health/health.schema.js';
5
6
  import { PackageSchema } from '../manifest/manifest.schema.js';
@@ -17,6 +18,10 @@ const SOURCES = {
17
18
  schema: DiscoveryDocumentSchema,
18
19
  title: 'GET /.well-known/agentage-extension.json',
19
20
  },
21
+ 'host-document.schema.json': {
22
+ schema: HostDocumentSchema,
23
+ title: 'GET /.well-known/agentage-host.json',
24
+ },
20
25
  'health.schema.json': { schema: HealthSchema, title: 'GET /health of every part container' },
21
26
  'error-envelope.schema.json': { schema: ErrorEnvelopeSchema, title: 'REST error envelope' },
22
27
  'ok-envelope.schema.json': { schema: OkEnvelopeSchema, title: 'REST success envelope' },
@@ -5,6 +5,7 @@ import { type WellKnownEntry } from '../api/well-known.js';
5
5
  import { type FilesEntry } from '../api/files-registry.js';
6
6
  import { type TokenCheck } from '../auth/token-check.js';
7
7
  import { type BuildInfo, type ServedRecord } from '../discovery/discovery.js';
8
+ import { type AppRowDoc } from '../discovery/served.schema.js';
8
9
  import { type HealthCheck } from '../health/health.js';
9
10
  import { type Log } from '../log/log.js';
10
11
  import { type ExtensionPackage } from '../manifest/manifest.schema.js';
@@ -26,6 +27,7 @@ export interface PartAppBase {
26
27
  guards?: RequestHandler[];
27
28
  parts?: ImagePartKind[];
28
29
  clockRate?: number;
30
+ app?: AppRowDoc;
29
31
  }
30
32
  interface PartAppOptions extends PartAppBase {
31
33
  part: ImagePartKind;
@@ -7,12 +7,14 @@ import { mountFiles } from '../api/files.js';
7
7
  import {} from '../api/files-registry.js';
8
8
  import { methodsOf, routeAccess, sameShape } from '../auth/route-access.js';
9
9
  import { setCaller, setCleared } from '../auth/token-check.js';
10
- import { discoveryDocument, recordOf, } from '../discovery/discovery.js';
10
+ import {} from '../discovery/discovery.js';
11
+ import {} from '../discovery/served.schema.js';
11
12
  import { apiPrefix } from '../discovery/openapi.js';
12
13
  import { createHealthHandler } from '../health/health.js';
13
14
  import {} from '../log/log.js';
14
15
  import {} from '../manifest/manifest.schema.js';
15
16
  import {} from '../manifest/primitives.schema.js';
17
+ import { discoveryHandler } from './discovery-handler.js';
16
18
  import { errorHandler, notFound } from './errors.js';
17
19
  import { requestLine } from './request-line.js';
18
20
  import {} from './part.types.js';
@@ -36,14 +38,6 @@ const dropCookie = (req, _res, next) => {
36
38
  next();
37
39
  };
38
40
  export const BODY_LIMIT = '1mb';
39
- const requestOrigin = (req) => `${req.protocol}://${req.get('host') ?? ''}`;
40
- const discoveryHandler = (options) => {
41
- const images = options.ownImage ? { [options.part]: options.ownImage } : {};
42
- const record = options.record ?? recordOf(options.pkg, options.build, images);
43
- return (req, res) => {
44
- res.json(discoveryDocument(record, options.origin ?? requestOrigin(req)));
45
- };
46
- };
47
41
  const healthHandler = (options) => createHealthHandler({
48
42
  extension: options.pkg.agentage.id,
49
43
  part: options.part,
@@ -0,0 +1,6 @@
1
+ import { type RequestHandler } from 'express';
2
+ import { type ImagePartKind } from '../manifest/primitives.schema.js';
3
+ import { type PartAppBase } from './app.js';
4
+ export declare const discoveryHandler: (options: PartAppBase & {
5
+ part: ImagePartKind;
6
+ }) => RequestHandler;
@@ -0,0 +1,14 @@
1
+ import {} from 'express';
2
+ import { discoveryDocument, recordOf, servingOf } from '../discovery/discovery.js';
3
+ import {} from '../manifest/primitives.schema.js';
4
+ import {} from './app.js';
5
+ const requestOrigin = (req) => `${req.protocol}://${req.get('host') ?? ''}`;
6
+ // GET /.well-known/agentage-extension.json: the record, the host and what this container serves.
7
+ export const discoveryHandler = (options) => {
8
+ const images = options.ownImage ? { [options.part]: options.ownImage } : {};
9
+ const record = options.record ?? recordOf(options.pkg, options.build, images);
10
+ const serving = servingOf(options.parts ?? [options.part], options.app);
11
+ return (req, res) => {
12
+ res.json(discoveryDocument(record, options.origin ?? requestOrigin(req), serving));
13
+ };
14
+ };
@@ -4,7 +4,7 @@
4
4
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self' 'sha256-rPnVQ9IYe8CdsZZF35pNR4JDk/fH7Uqv6mzmCnCCky8=' 'sha256-lofENefBf5fETbin4TmrCuvlqGNlwIr9jsrkSYCOq+c=' 'sha256-ZowhplWzFwaUWeLf0FFjuCiJ6T38qHnoSSn0bfCSIG4='; style-src 'self'; img-src 'self' data:; font-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'" />
5
5
  <meta charset="utf-8" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <meta name="agentage-shell" content="0.18.8" />
7
+ <meta name="agentage-shell" content="0.19.0" />
8
8
  <title>agentage</title>
9
9
  <script>
10
10
  try {
@@ -1,9 +1,10 @@
1
1
  import { type ExtensionRecord } from '../../discovery/discovery.schema.js';
2
+ import { type ServesKind } from '../../discovery/served.schema.js';
2
3
  import { type ExtensionPackage } from '../../manifest/manifest.schema.js';
3
4
  import { type BuildResult } from '../build.js';
4
5
  import { type Run } from '../exec.js';
5
6
  export declare const LOCAL_DIR = ".agentage";
6
- export declare const assertDiscoverable: (record: ExtensionRecord, origin: string) => void;
7
+ export declare const assertDiscoverable: (record: ExtensionRecord, origin: string, serves: ServesKind[]) => void;
7
8
  export declare const writeLocalRecord: (dir: string, pkg: ExtensionPackage, built: BuildResult, run: Run) => Promise<{
8
9
  file: string;
9
10
  record: {
@@ -2,6 +2,7 @@ import { mkdir, writeFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { discoveryDocument } from '../../discovery/discovery.js';
4
4
  import { DiscoveryDocumentSchema } from '../../discovery/discovery.schema.js';
5
+ import {} from '../../discovery/served.schema.js';
5
6
  import { formatIssues } from '../../manifest/read-manifest.js';
6
7
  import {} from '../../manifest/manifest.schema.js';
7
8
  import { recordFor } from '../build.js';
@@ -13,8 +14,8 @@ const localImage = async (run, built) => {
13
14
  const repository = built.tag.slice(0, built.tag.lastIndexOf(':'));
14
15
  return { ...built, digest: id, image: `${repository}@${id}` };
15
16
  };
16
- export const assertDiscoverable = (record, origin) => {
17
- const result = DiscoveryDocumentSchema.safeParse(discoveryDocument(record, origin));
17
+ export const assertDiscoverable = (record, origin, serves) => {
18
+ const result = DiscoveryDocumentSchema.safeParse(discoveryDocument(record, origin, { serves }));
18
19
  if (!result.success)
19
20
  throw new Error(`discovery would be invalid: ${formatIssues(result.error.issues)}`);
20
21
  };
@@ -35,7 +35,7 @@ const buildStep = async (s, env) => {
35
35
  const images = plural(built.images.length, 'image');
36
36
  s.line('build', `${images} from the release recipes`, 'same recipe and tags as a release');
37
37
  const { file, record } = await writeLocalRecord(s.dir, s.pkg, built, s.deps.run);
38
- assertDiscoverable(record, GATEWAY);
38
+ assertDiscoverable(record, GATEWAY, imageParts(s.pkg));
39
39
  s.line('record', `${LOCAL_DIR}/record.json`, 'discovery valid');
40
40
  await renderFiles(s, file, Object.fromEntries(built.images.map((i) => [i.part, i.tag])));
41
41
  return built.commit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentage/extension",
3
- "version": "0.18.8",
3
+ "version": "0.19.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",
@@ -222,6 +222,55 @@
222
222
  "type": "string",
223
223
  "maxLength": 270,
224
224
  "pattern": "^(https:\\/\\/[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)+|http:\\/\\/(127\\.0\\.0\\.1|localhost))(:[0-9]{1,5})?$"
225
+ },
226
+ "serves": {
227
+ "minItems": 1,
228
+ "type": "array",
229
+ "items": {
230
+ "type": "string",
231
+ "enum": [
232
+ "pages",
233
+ "ui",
234
+ "api",
235
+ "mcp",
236
+ "worker",
237
+ "app"
238
+ ]
239
+ }
240
+ },
241
+ "app": {
242
+ "type": "object",
243
+ "properties": {
244
+ "title": {
245
+ "type": "string",
246
+ "minLength": 1,
247
+ "maxLength": 40
248
+ },
249
+ "icon": {
250
+ "type": "string",
251
+ "maxLength": 64,
252
+ "pattern": "^[a-z][a-z0-9-]*$"
253
+ },
254
+ "order": {
255
+ "type": "integer",
256
+ "minimum": 0,
257
+ "maximum": 1000
258
+ },
259
+ "entry": {
260
+ "type": "string",
261
+ "pattern": "^\\/app\\/[a-z][a-z0-9-]*\\/app-[0-9a-f]+\\.js$"
262
+ },
263
+ "css": {
264
+ "type": "string",
265
+ "pattern": "^\\/app\\/[a-z][a-z0-9-]*\\/app-[0-9a-f]+\\.css$"
266
+ }
267
+ },
268
+ "required": [
269
+ "title",
270
+ "entry",
271
+ "css"
272
+ ],
273
+ "additionalProperties": false
225
274
  }
226
275
  },
227
276
  "required": [
@@ -230,7 +279,8 @@
230
279
  "commit",
231
280
  "buildTime",
232
281
  "parts",
233
- "host"
282
+ "host",
283
+ "serves"
234
284
  ],
235
285
  "additionalProperties": false
236
286
  }
@@ -0,0 +1,187 @@
1
+ {
2
+ "$id": "https://agentage.io/schemas/host-document.schema.json",
3
+ "title": "GET /.well-known/agentage-host.json",
4
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
5
+ "type": "object",
6
+ "properties": {
7
+ "host": {
8
+ "type": "string",
9
+ "maxLength": 63,
10
+ "pattern": "^[a-z][a-z0-9-]*$"
11
+ },
12
+ "kind": {
13
+ "type": "string",
14
+ "enum": [
15
+ "local",
16
+ "cloud"
17
+ ]
18
+ },
19
+ "shell": {
20
+ "type": "object",
21
+ "properties": {
22
+ "package": {
23
+ "type": "string",
24
+ "maxLength": 214,
25
+ "pattern": "^(?:@[a-z0-9][a-z0-9._~-]*\\/)?[a-z0-9][a-z0-9._~-]*$"
26
+ },
27
+ "version": {
28
+ "type": "string",
29
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
30
+ }
31
+ },
32
+ "required": [
33
+ "package",
34
+ "version"
35
+ ],
36
+ "additionalProperties": false
37
+ },
38
+ "extensions": {
39
+ "type": "array",
40
+ "items": {
41
+ "type": "object",
42
+ "properties": {
43
+ "id": {
44
+ "type": "string",
45
+ "maxLength": 32,
46
+ "pattern": "^(?!(?:auth|www|api|sync|mail|mcp|ui|app|shell|host|health|git|setup|status|update|extension|add|remove|help|con|prn|aux|nul|com[0-9]|lpt[0-9])$)[a-z][a-z0-9-]*$"
47
+ },
48
+ "version": {
49
+ "type": "string",
50
+ "pattern": "^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)(-[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?(\\+[0-9A-Za-z-]+(\\.[0-9A-Za-z-]+)*)?$"
51
+ },
52
+ "commit": {
53
+ "type": "string",
54
+ "pattern": "^[0-9a-f]{40}$"
55
+ },
56
+ "parts": {
57
+ "type": "array",
58
+ "items": {
59
+ "type": "string",
60
+ "enum": [
61
+ "pages",
62
+ "ui",
63
+ "api",
64
+ "mcp",
65
+ "worker",
66
+ "app"
67
+ ]
68
+ }
69
+ },
70
+ "tools": {
71
+ "minItems": 1,
72
+ "type": "array",
73
+ "items": {
74
+ "type": "object",
75
+ "properties": {
76
+ "name": {
77
+ "type": "string",
78
+ "maxLength": 64,
79
+ "pattern": "^[a-z][a-z0-9-]*__[a-z][a-z0-9_-]*$"
80
+ },
81
+ "scope": {
82
+ "type": "string",
83
+ "pattern": "^(public|[a-z][a-z0-9-]*:(read|write|admin))$"
84
+ }
85
+ },
86
+ "required": [
87
+ "name",
88
+ "scope"
89
+ ],
90
+ "additionalProperties": false
91
+ }
92
+ },
93
+ "openapi": {
94
+ "type": "string",
95
+ "pattern": "^\\/api\\/[a-z][a-z0-9-]*\\/openapi\\.json$"
96
+ },
97
+ "app": {
98
+ "type": "object",
99
+ "properties": {
100
+ "title": {
101
+ "type": "string",
102
+ "minLength": 1,
103
+ "maxLength": 40
104
+ },
105
+ "icon": {
106
+ "type": "string",
107
+ "maxLength": 64,
108
+ "pattern": "^[a-z][a-z0-9-]*$"
109
+ },
110
+ "order": {
111
+ "type": "integer",
112
+ "minimum": 0,
113
+ "maximum": 1000
114
+ },
115
+ "entry": {
116
+ "type": "string",
117
+ "pattern": "^\\/app\\/[a-z][a-z0-9-]*\\/app-[0-9a-f]+\\.js$"
118
+ },
119
+ "css": {
120
+ "type": "string",
121
+ "pattern": "^\\/app\\/[a-z][a-z0-9-]*\\/app-[0-9a-f]+\\.css$"
122
+ }
123
+ },
124
+ "required": [
125
+ "title",
126
+ "entry",
127
+ "css"
128
+ ],
129
+ "additionalProperties": false
130
+ },
131
+ "expose": {
132
+ "type": "object",
133
+ "properties": {
134
+ "mcp": {
135
+ "type": "string",
136
+ "enum": [
137
+ "public",
138
+ "internal"
139
+ ]
140
+ },
141
+ "api": {
142
+ "type": "string",
143
+ "enum": [
144
+ "public",
145
+ "internal"
146
+ ]
147
+ },
148
+ "app": {
149
+ "type": "string",
150
+ "const": "public"
151
+ },
152
+ "pages": {
153
+ "type": "string",
154
+ "const": "public"
155
+ }
156
+ },
157
+ "additionalProperties": false
158
+ },
159
+ "state": {
160
+ "type": "string",
161
+ "enum": [
162
+ "running",
163
+ "starting",
164
+ "failed",
165
+ "disabled",
166
+ "down"
167
+ ]
168
+ }
169
+ },
170
+ "required": [
171
+ "id",
172
+ "version",
173
+ "parts",
174
+ "expose",
175
+ "state"
176
+ ],
177
+ "additionalProperties": false
178
+ }
179
+ }
180
+ },
181
+ "required": [
182
+ "host",
183
+ "kind",
184
+ "extensions"
185
+ ],
186
+ "additionalProperties": false
187
+ }