@agentage/extension 0.20.0 → 0.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contracts/index.d.ts +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/discovery/combine-answers.d.ts +42 -0
- package/dist/discovery/combine-answers.js +70 -0
- package/dist/discovery/combine.d.ts +2 -28
- package/dist/discovery/combine.js +3 -44
- package/dist/discovery/discovery.d.ts +1 -1
- package/dist/discovery/discovery.schema.d.ts +14 -4
- package/dist/discovery/discovery.schema.js +10 -5
- package/dist/discovery/host-document.schema.d.ts +44 -0
- package/dist/discovery/host-document.schema.js +3 -6
- package/dist/host/index.d.ts +1 -1
- package/dist/server/discovery-handler.js +11 -3
- package/dist/shell/dist/index.html +1 -1
- package/package.json +1 -1
- package/schemas/extension-discovery.schema.json +40 -22
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
3
|
+
export { combineHost, entryOfDocument, type Answer, type CallerState, type Combined, type CombineInput, type HostInstallation, type Refusal, type Route, } from '../discovery/combine.js';
|
|
4
4
|
export { HostDocumentSchema, type HostDocument, type HostEntry, } from '../discovery/host-document.schema.js';
|
|
5
5
|
export { ERROR_CODES, type ErrorCode } from '../envelope/codes.js';
|
|
6
6
|
export { ErrorEnvelopeSchema, OkEnvelopeSchema } from '../envelope/envelope.schema.js';
|
package/dist/contracts/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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';
|
|
3
|
+
export { combineHost, entryOfDocument, } from '../discovery/combine.js';
|
|
4
4
|
export { HostDocumentSchema, } from '../discovery/host-document.schema.js';
|
|
5
5
|
export { ERROR_CODES } from '../envelope/codes.js';
|
|
6
6
|
export { ErrorEnvelopeSchema, OkEnvelopeSchema } from '../envelope/envelope.schema.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type DiscoveryDocument } from './discovery.schema.js';
|
|
2
|
+
import { type Served } from './route-table.js';
|
|
3
|
+
export interface Answer {
|
|
4
|
+
upstream: string;
|
|
5
|
+
document: unknown;
|
|
6
|
+
expectedId?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Refusal {
|
|
9
|
+
upstream: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
reason: string;
|
|
12
|
+
}
|
|
13
|
+
export interface AnswerRow {
|
|
14
|
+
id: string;
|
|
15
|
+
version: string;
|
|
16
|
+
enabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const entryOfDocument: (doc: DiscoveryDocument) => {
|
|
19
|
+
app?: {
|
|
20
|
+
title: string;
|
|
21
|
+
entry: string;
|
|
22
|
+
css: string;
|
|
23
|
+
icon?: string | undefined;
|
|
24
|
+
order?: number | undefined;
|
|
25
|
+
} | undefined;
|
|
26
|
+
openapi?: string | undefined;
|
|
27
|
+
tools?: {
|
|
28
|
+
name: string;
|
|
29
|
+
scope: string;
|
|
30
|
+
}[] | undefined;
|
|
31
|
+
id: string;
|
|
32
|
+
version: string;
|
|
33
|
+
commit: string;
|
|
34
|
+
parts: ("pages" | "ui" | "api" | "mcp" | "worker" | "app")[];
|
|
35
|
+
};
|
|
36
|
+
export declare const entryRefusal: (doc: DiscoveryDocument) => string | null;
|
|
37
|
+
type Sorted = {
|
|
38
|
+
byId: Map<string, Served[]>;
|
|
39
|
+
refused: Refusal[];
|
|
40
|
+
};
|
|
41
|
+
export declare const sortAnswers: (rows: AnswerRow[], answers: Answer[]) => Sorted;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { DiscoveryDocumentSchema } from './discovery.schema.js';
|
|
2
|
+
import { ExtensionEntrySchema } from './host-document.schema.js';
|
|
3
|
+
import {} from './route-table.js';
|
|
4
|
+
import { SERVES_KINDS } from './served.schema.js';
|
|
5
|
+
// The fields of one extension document that the host document repeats as they are.
|
|
6
|
+
export const entryOfDocument = (doc) => ({
|
|
7
|
+
id: doc.id,
|
|
8
|
+
version: doc.version,
|
|
9
|
+
commit: doc.commit,
|
|
10
|
+
parts: SERVES_KINDS.filter((kind) => doc.serves.includes(kind)),
|
|
11
|
+
...(doc.tools && { tools: doc.tools }),
|
|
12
|
+
...(doc.openapi && { openapi: doc.openapi }),
|
|
13
|
+
...(doc.app && { app: doc.app }),
|
|
14
|
+
});
|
|
15
|
+
const issuesOf = (error) => error.issues.map((i) => `${i.path.map(String).join('.')}: ${i.message}`).join('; ');
|
|
16
|
+
// Why a valid document still gives an entry the host schema refuses, or null when it does not.
|
|
17
|
+
export const entryRefusal = (doc) => {
|
|
18
|
+
const entry = { ...entryOfDocument(doc), expose: {}, state: 'running' };
|
|
19
|
+
const parsed = ExtensionEntrySchema.safeParse(entry);
|
|
20
|
+
return parsed.success ? null : `invalid entry: ${issuesOf(parsed.error)}`;
|
|
21
|
+
};
|
|
22
|
+
// Why an answer is not used for its row, or null when it is.
|
|
23
|
+
const refusalOf = (doc, row, first) => {
|
|
24
|
+
if (!row)
|
|
25
|
+
return 'unknown id';
|
|
26
|
+
if (row.enabled === false)
|
|
27
|
+
return 'disabled';
|
|
28
|
+
if (doc.version !== row.version)
|
|
29
|
+
return `version ${doc.version}, not ${row.version}`;
|
|
30
|
+
const bad = entryRefusal(doc);
|
|
31
|
+
if (bad)
|
|
32
|
+
return bad;
|
|
33
|
+
return first && first.doc.commit !== doc.commit ? `another build than ${first.doc.commit}` : null;
|
|
34
|
+
};
|
|
35
|
+
const idRefusal = (doc, expectedId, listed) => {
|
|
36
|
+
if (expectedId === undefined)
|
|
37
|
+
return listed.has(doc.id) ? 'not listed for this id' : null;
|
|
38
|
+
return doc.id === expectedId ? null : `claims another id: ${doc.id}`;
|
|
39
|
+
};
|
|
40
|
+
// The answer's refusal, or the container it adds to its id.
|
|
41
|
+
const judge = ({ rows, listed, byId }, answer) => {
|
|
42
|
+
const { upstream, document, expectedId } = answer;
|
|
43
|
+
const parsed = DiscoveryDocumentSchema.safeParse(document);
|
|
44
|
+
if (!parsed.success)
|
|
45
|
+
return { upstream, reason: `invalid: ${issuesOf(parsed.error)}` };
|
|
46
|
+
const doc = parsed.data;
|
|
47
|
+
const claim = idRefusal(doc, expectedId, listed);
|
|
48
|
+
if (claim)
|
|
49
|
+
return { upstream, id: expectedId ?? doc.id, reason: claim };
|
|
50
|
+
const reason = refusalOf(doc, rows.find((r) => r.id === doc.id), byId.get(doc.id)?.[0]);
|
|
51
|
+
return reason ? { upstream, id: doc.id, reason } : { upstream, doc };
|
|
52
|
+
};
|
|
53
|
+
const sortOne = (context, refused, answer) => {
|
|
54
|
+
const out = judge(context, answer);
|
|
55
|
+
const { byId } = context;
|
|
56
|
+
if ('reason' in out)
|
|
57
|
+
refused.push(out);
|
|
58
|
+
else
|
|
59
|
+
byId.set(out.doc.id, [...(byId.get(out.doc.id) ?? []), out]);
|
|
60
|
+
};
|
|
61
|
+
// Each valid answer under its id, in answer order; every other answer is refused with its reason.
|
|
62
|
+
export const sortAnswers = (rows, answers) => {
|
|
63
|
+
const listed = new Set(answers.flatMap((a) => (a.expectedId ? [a.expectedId] : [])));
|
|
64
|
+
const context = { rows, listed, byId: new Map() };
|
|
65
|
+
const refused = [];
|
|
66
|
+
for (const answer of answers)
|
|
67
|
+
if (answer.document !== null && answer.document !== undefined)
|
|
68
|
+
sortOne(context, refused, answer);
|
|
69
|
+
return { byId: context.byId, refused };
|
|
70
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type Answer, type Refusal } from './combine-answers.js';
|
|
2
2
|
import { type Expose, type HostDocument, type HostKind } from './host-document.schema.js';
|
|
3
3
|
import { type Route } from './route-table.js';
|
|
4
|
+
export { entryOfDocument, type Answer, type Refusal } from './combine-answers.js';
|
|
4
5
|
export { type Route } from './route-table.js';
|
|
5
6
|
export interface HostInstallation {
|
|
6
7
|
host: string;
|
|
@@ -15,38 +16,11 @@ export interface HostInstallation {
|
|
|
15
16
|
expose?: Expose;
|
|
16
17
|
}[];
|
|
17
18
|
}
|
|
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
19
|
export interface Combined {
|
|
28
20
|
document: HostDocument;
|
|
29
21
|
routes: Route[];
|
|
30
22
|
refused: Refusal[];
|
|
31
23
|
}
|
|
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
24
|
export type CallerState = 'starting' | 'failed';
|
|
51
25
|
export interface CombineInput {
|
|
52
26
|
kind: HostKind;
|
|
@@ -1,50 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { entryOfDocument, sortAnswers } from './combine-answers.js';
|
|
2
2
|
import { HostDocumentSchema, } from './host-document.schema.js';
|
|
3
3
|
import { routeTable } from './route-table.js';
|
|
4
4
|
import { SERVES_KINDS } from './served.schema.js';
|
|
5
|
+
export { entryOfDocument } from './combine-answers.js';
|
|
5
6
|
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
7
|
const stateOf = (row, served, told) => {
|
|
49
8
|
if (row.enabled === false)
|
|
50
9
|
return 'disabled';
|
|
@@ -72,7 +31,7 @@ const pagesRefusal = (route, site) => ({
|
|
|
72
31
|
reason: `a second pages route: / is ${site?.id ?? ''}`,
|
|
73
32
|
});
|
|
74
33
|
// No I/O: the installation and each container's answer in; the host document and routes out.
|
|
75
|
-
// Throws
|
|
34
|
+
// Throws only on an installation the host schema refuses (two rows of one id); a bad answer is refused.
|
|
76
35
|
export const combineHost = ({ kind, installation, answers, states }) => {
|
|
77
36
|
const { byId, refused } = sortAnswers(installation.extensions, answers);
|
|
78
37
|
const rows = installation.extensions.map((row) => {
|
|
@@ -47,11 +47,11 @@ export declare const discoveryDocument: (record: ServedRecord, host: string, ser
|
|
|
47
47
|
secrets?: string[] | undefined;
|
|
48
48
|
image?: string | undefined;
|
|
49
49
|
openapi?: string | undefined;
|
|
50
|
-
secretParts?: Record<string, ("pages" | "api" | "mcp" | "worker")[]> | undefined;
|
|
51
50
|
tools?: {
|
|
52
51
|
name: string;
|
|
53
52
|
scope: string;
|
|
54
53
|
}[] | undefined;
|
|
54
|
+
secretParts?: Record<string, ("pages" | "api" | "mcp" | "worker")[]> | undefined;
|
|
55
55
|
widgets?: {
|
|
56
56
|
name: string;
|
|
57
57
|
element: string;
|
|
@@ -9,6 +9,16 @@ export declare const ToolRecordSchema: z.ZodObject<{
|
|
|
9
9
|
name: z.ZodString;
|
|
10
10
|
scope: z.ZodString;
|
|
11
11
|
}, z.core.$strict>;
|
|
12
|
+
export declare const toolsAreOwn: ({ id, tools }: {
|
|
13
|
+
id: string;
|
|
14
|
+
tools?: {
|
|
15
|
+
name: string;
|
|
16
|
+
}[];
|
|
17
|
+
}) => boolean;
|
|
18
|
+
export declare const TOOLS_RULE: {
|
|
19
|
+
message: string;
|
|
20
|
+
path: string[];
|
|
21
|
+
};
|
|
12
22
|
export declare const ExtensionRecordSchema: z.ZodObject<{
|
|
13
23
|
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
14
24
|
secretParts: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodEnum<{
|
|
@@ -78,12 +88,12 @@ export declare const DiscoveryDocumentSchema: z.ZodObject<{
|
|
|
78
88
|
css: z.ZodString;
|
|
79
89
|
}, z.core.$strict>>;
|
|
80
90
|
parts: z.ZodObject<{
|
|
81
|
-
pages: z.ZodOptional<z.ZodObject<{
|
|
91
|
+
pages: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
82
92
|
image: z.ZodString;
|
|
83
|
-
}, z.core.$strict>>;
|
|
84
|
-
ui: z.ZodOptional<z.ZodObject<{
|
|
93
|
+
}, z.core.$strict>, z.ZodObject<{}, z.core.$strict>]>>;
|
|
94
|
+
ui: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
85
95
|
image: z.ZodString;
|
|
86
|
-
}, z.core.$strict>>;
|
|
96
|
+
}, z.core.$strict>, z.ZodObject<{}, z.core.$strict>]>>;
|
|
87
97
|
api: z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<{
|
|
88
98
|
image: z.ZodString;
|
|
89
99
|
}, z.core.$strict>, z.ZodObject<{}, z.core.$strict>]>>;
|
|
@@ -24,11 +24,11 @@ const PartsRecordSchema = z.strictObject({
|
|
|
24
24
|
worker: PartImageSchema.optional(),
|
|
25
25
|
store: StoreRecordSchema.optional(),
|
|
26
26
|
});
|
|
27
|
-
// A part the kit host
|
|
27
|
+
// A part with no image: the kit host, or a part image with no record, never knows its digest.
|
|
28
28
|
const HostedPartSchema = z.strictObject({});
|
|
29
29
|
const ServedPartsSchema = z.strictObject({
|
|
30
|
-
pages: PartImageSchema.optional(),
|
|
31
|
-
ui: PartImageSchema.optional(),
|
|
30
|
+
pages: z.union([PartImageSchema, HostedPartSchema]).optional(),
|
|
31
|
+
ui: z.union([PartImageSchema, HostedPartSchema]).optional(),
|
|
32
32
|
api: z.union([PartImageSchema, HostedPartSchema]).optional(),
|
|
33
33
|
mcp: z.union([PartImageSchema, HostedPartSchema]).optional(),
|
|
34
34
|
worker: z.union([PartImageSchema, HostedPartSchema]).optional(),
|
|
@@ -92,6 +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
98
|
// A scoped name lives only in secretParts, so an estate that does not read it mounts nothing.
|
|
96
99
|
const scoped = (name) => `secret ${name}: one or more parts, none repeated, and never also in secrets`;
|
|
97
100
|
// The build record: written by `build --push` into the package and the release asset; no host.
|
|
@@ -118,11 +121,13 @@ export const DiscoveryDocumentSchema = z
|
|
|
118
121
|
.refine(servedForm, HOSTED_RULE)
|
|
119
122
|
.refine(appRowFits, APP_ROW_RULE)
|
|
120
123
|
.refine(imagesNameTheirExtension, IMAGE_RULE)
|
|
121
|
-
.refine(openapiIsOwn, OPENAPI_RULE)
|
|
124
|
+
.refine(openapiIsOwn, OPENAPI_RULE)
|
|
125
|
+
.refine(toolsAreOwn, TOOLS_RULE);
|
|
122
126
|
// The form the cloud serves: every part by its image, or the one image; never a part with no image.
|
|
123
127
|
export const CloudDiscoveryDocumentSchema = z
|
|
124
128
|
.strictObject({ ...recordShape, ...servedShape })
|
|
125
129
|
.refine(oneImageForm, FORM_RULE)
|
|
126
130
|
.refine(appRowFits, APP_ROW_RULE)
|
|
127
131
|
.refine(imagesNameTheirExtension, IMAGE_RULE)
|
|
128
|
-
.refine(openapiIsOwn, OPENAPI_RULE)
|
|
132
|
+
.refine(openapiIsOwn, OPENAPI_RULE)
|
|
133
|
+
.refine(toolsAreOwn, TOOLS_RULE);
|
|
@@ -13,6 +13,50 @@ export declare const ExposeSchema: z.ZodObject<{
|
|
|
13
13
|
app: z.ZodOptional<z.ZodLiteral<"public">>;
|
|
14
14
|
pages: z.ZodOptional<z.ZodLiteral<"public">>;
|
|
15
15
|
}, z.core.$strict>;
|
|
16
|
+
export declare const ExtensionEntrySchema: z.ZodObject<{
|
|
17
|
+
id: z.ZodString;
|
|
18
|
+
version: z.ZodString;
|
|
19
|
+
commit: z.ZodOptional<z.ZodString>;
|
|
20
|
+
parts: z.ZodArray<z.ZodEnum<{
|
|
21
|
+
pages: "pages";
|
|
22
|
+
ui: "ui";
|
|
23
|
+
api: "api";
|
|
24
|
+
mcp: "mcp";
|
|
25
|
+
worker: "worker";
|
|
26
|
+
app: "app";
|
|
27
|
+
}>>;
|
|
28
|
+
tools: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
scope: z.ZodString;
|
|
31
|
+
}, z.core.$strict>>>;
|
|
32
|
+
openapi: z.ZodOptional<z.ZodString>;
|
|
33
|
+
app: z.ZodOptional<z.ZodObject<{
|
|
34
|
+
title: z.ZodString;
|
|
35
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
36
|
+
order: z.ZodOptional<z.ZodInt>;
|
|
37
|
+
entry: z.ZodString;
|
|
38
|
+
css: z.ZodString;
|
|
39
|
+
}, z.core.$strict>>;
|
|
40
|
+
expose: z.ZodObject<{
|
|
41
|
+
mcp: z.ZodOptional<z.ZodEnum<{
|
|
42
|
+
public: "public";
|
|
43
|
+
internal: "internal";
|
|
44
|
+
}>>;
|
|
45
|
+
api: z.ZodOptional<z.ZodEnum<{
|
|
46
|
+
public: "public";
|
|
47
|
+
internal: "internal";
|
|
48
|
+
}>>;
|
|
49
|
+
app: z.ZodOptional<z.ZodLiteral<"public">>;
|
|
50
|
+
pages: z.ZodOptional<z.ZodLiteral<"public">>;
|
|
51
|
+
}, z.core.$strict>;
|
|
52
|
+
state: z.ZodEnum<{
|
|
53
|
+
failed: "failed";
|
|
54
|
+
running: "running";
|
|
55
|
+
starting: "starting";
|
|
56
|
+
disabled: "disabled";
|
|
57
|
+
down: "down";
|
|
58
|
+
}>;
|
|
59
|
+
}, z.core.$strict>;
|
|
16
60
|
export declare const HostDocumentSchema: z.ZodObject<{
|
|
17
61
|
host: z.ZodString;
|
|
18
62
|
kind: z.ZodEnum<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { CommitSchema, ExtensionIdSchema, PackageNameSchema, VersionSchema, } from '../manifest/primitives.schema.js';
|
|
3
|
-
import { ToolRecordSchema } from './discovery.schema.js';
|
|
3
|
+
import { ToolRecordSchema, TOOLS_RULE, toolsAreOwn } from './discovery.schema.js';
|
|
4
4
|
import { APP_ROW_RULE, appRowFits, AppRowSchema, SERVES_KINDS } from './served.schema.js';
|
|
5
5
|
export const HOST_KINDS = ['local', 'cloud'];
|
|
6
6
|
// down: the installation lists it and no container answered with a valid document.
|
|
@@ -13,7 +13,7 @@ export const ExposeSchema = z.strictObject({
|
|
|
13
13
|
app: z.literal('public').optional(),
|
|
14
14
|
pages: z.literal('public').optional(),
|
|
15
15
|
});
|
|
16
|
-
const ExtensionEntrySchema = z
|
|
16
|
+
export const ExtensionEntrySchema = z
|
|
17
17
|
.strictObject({
|
|
18
18
|
id: ExtensionIdSchema,
|
|
19
19
|
version: VersionSchema,
|
|
@@ -33,10 +33,7 @@ const ExtensionEntrySchema = z
|
|
|
33
33
|
message: 'openapi is /api/{id}/openapi.json',
|
|
34
34
|
path: ['openapi'],
|
|
35
35
|
})
|
|
36
|
-
.refine(
|
|
37
|
-
message: 'every tool is {id}__{name}',
|
|
38
|
-
path: ['tools'],
|
|
39
|
-
});
|
|
36
|
+
.refine(toolsAreOwn, TOOLS_RULE);
|
|
40
37
|
// The shell is a library the host serves: named here only, never a row of extensions.
|
|
41
38
|
const ShellSchema = z.strictObject({ package: PackageNameSchema, version: VersionSchema });
|
|
42
39
|
const uniqueIds = ({ extensions }) => new Set(extensions.map((e) => e.id)).size === extensions.length;
|
package/dist/host/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { combineHost, type Answer, type Combined, type HostInstallation, type Refusal, type Route, } from '../discovery/combine.js';
|
|
1
|
+
export { combineHost, type Answer, type CallerState, type Combined, type CombineInput, type HostInstallation, type Refusal, type Route, } from '../discovery/combine.js';
|
|
2
2
|
export { capabilities } from '../tool/capabilities.js';
|
|
3
3
|
export { localOnly } from './daemon/guard.js';
|
|
4
4
|
export { createDaemon, DAEMON_PORT, type Daemon, type DaemonOptions } from './daemon/daemon.js';
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import {} from 'express';
|
|
2
|
-
import { discoveryDocument, recordOf, servingOf } from '../discovery/discovery.js';
|
|
2
|
+
import { discoveryDocument, recordOf, servingOf, } from '../discovery/discovery.js';
|
|
3
3
|
import {} from '../manifest/primitives.schema.js';
|
|
4
4
|
import {} from './app.js';
|
|
5
|
+
const DIGEST_REF = /@sha256:[0-9a-f]{64}$/;
|
|
6
|
+
// With no record a part lists its image only by digest; a tag is not a release, so it lists {}.
|
|
7
|
+
const ownRecord = (options) => {
|
|
8
|
+
const { ownImage, part } = options;
|
|
9
|
+
if (ownImage && DIGEST_REF.test(ownImage))
|
|
10
|
+
return recordOf(options.pkg, options.build, { [part]: ownImage });
|
|
11
|
+
const record = recordOf(options.pkg, options.build, {});
|
|
12
|
+
return { ...record, parts: { [part]: {}, ...record.parts } };
|
|
13
|
+
};
|
|
5
14
|
const requestOrigin = (req) => `${req.protocol}://${req.get('host') ?? ''}`;
|
|
6
15
|
// GET /.well-known/agentage-extension.json: the record, the host and what this container serves.
|
|
7
16
|
export const discoveryHandler = (options) => {
|
|
8
|
-
const
|
|
9
|
-
const record = options.record ?? recordOf(options.pkg, options.build, images);
|
|
17
|
+
const record = options.record ?? ownRecord(options);
|
|
10
18
|
const serving = servingOf(options.parts ?? [options.part], options.app);
|
|
11
19
|
return (req, res) => {
|
|
12
20
|
res.json(discoveryDocument(record, options.origin ?? requestOrigin(req), serving));
|
|
@@ -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.20.
|
|
7
|
+
<meta name="agentage-shell" content="0.20.1" />
|
|
8
8
|
<title>agentage</title>
|
|
9
9
|
<script>
|
|
10
10
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentage/extension",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.1",
|
|
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",
|
|
@@ -26,32 +26,50 @@
|
|
|
26
26
|
"type": "object",
|
|
27
27
|
"properties": {
|
|
28
28
|
"pages": {
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
"anyOf": [
|
|
30
|
+
{
|
|
31
|
+
"type": "object",
|
|
32
|
+
"properties": {
|
|
33
|
+
"image": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"maxLength": 256,
|
|
36
|
+
"pattern": "^[a-z0-9][a-z0-9.-]*(:[0-9]{1,5})?\\/[a-z0-9][a-z0-9-]*\\/[a-z][a-z0-9-]*-(pages|ui|api|mcp|worker)@sha256:[0-9a-f]{64}$"
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"required": [
|
|
40
|
+
"image"
|
|
41
|
+
],
|
|
42
|
+
"additionalProperties": false
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"type": "object",
|
|
46
|
+
"properties": {},
|
|
47
|
+
"additionalProperties": false
|
|
35
48
|
}
|
|
36
|
-
|
|
37
|
-
"required": [
|
|
38
|
-
"image"
|
|
39
|
-
],
|
|
40
|
-
"additionalProperties": false
|
|
49
|
+
]
|
|
41
50
|
},
|
|
42
51
|
"ui": {
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
52
|
+
"anyOf": [
|
|
53
|
+
{
|
|
54
|
+
"type": "object",
|
|
55
|
+
"properties": {
|
|
56
|
+
"image": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"maxLength": 256,
|
|
59
|
+
"pattern": "^[a-z0-9][a-z0-9.-]*(:[0-9]{1,5})?\\/[a-z0-9][a-z0-9-]*\\/[a-z][a-z0-9-]*-(pages|ui|api|mcp|worker)@sha256:[0-9a-f]{64}$"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"required": [
|
|
63
|
+
"image"
|
|
64
|
+
],
|
|
65
|
+
"additionalProperties": false
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "object",
|
|
69
|
+
"properties": {},
|
|
70
|
+
"additionalProperties": false
|
|
49
71
|
}
|
|
50
|
-
|
|
51
|
-
"required": [
|
|
52
|
-
"image"
|
|
53
|
-
],
|
|
54
|
-
"additionalProperties": false
|
|
72
|
+
]
|
|
55
73
|
},
|
|
56
74
|
"api": {
|
|
57
75
|
"anyOf": [
|