@agentage/extension 0.20.0 → 0.20.2
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/auth/part-auth.js +4 -5
- package/dist/context/context.d.ts +0 -1
- 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/child-env.d.ts +11 -0
- package/dist/host/child-env.js +12 -0
- package/dist/host/{daemon/guard.js → guard.js} +1 -1
- package/dist/host/host-extension.js +1 -1
- package/dist/host/host-main.d.ts +1 -0
- package/dist/host/host-main.js +3 -0
- package/dist/host/index.d.ts +2 -6
- package/dist/host/index.js +1 -5
- package/dist/host/kit-shell.d.ts +1 -0
- package/dist/host/kit-shell.js +8 -0
- package/dist/host/serve-host.js +1 -1
- package/dist/internal/index.d.ts +29 -0
- package/dist/internal/index.js +30 -0
- package/dist/runtime/part-mounts.d.ts +0 -1
- package/dist/runtime/part-mounts.js +1 -1
- package/dist/runtime/run-part.js +0 -2
- package/dist/server/app.d.ts +0 -1
- package/dist/server/app.js +4 -5
- package/dist/server/discovery-handler.js +11 -3
- package/dist/shell/dist/index.html +1 -1
- package/dist/shell/dist/shell.css +1 -1
- package/dist/tool/check.js +3 -0
- package/dist/tool/recipe.js +2 -2
- package/dist/tool/up/gateway.js +0 -3
- package/package.json +5 -1
- package/schemas/extension-discovery.schema.json +40 -22
- package/dist/host/daemon/add.d.ts +0 -11
- package/dist/host/daemon/add.js +0 -93
- package/dist/host/daemon/app-files.d.ts +0 -8
- package/dist/host/daemon/app-files.js +0 -34
- package/dist/host/daemon/app-header.d.ts +0 -2
- package/dist/host/daemon/app-header.js +0 -12
- package/dist/host/daemon/app-reload.d.ts +0 -10
- package/dist/host/daemon/app-reload.js +0 -18
- package/dist/host/daemon/child-files.d.ts +0 -20
- package/dist/host/daemon/child-files.js +0 -53
- package/dist/host/daemon/child.d.ts +0 -30
- package/dist/host/daemon/child.js +0 -126
- package/dist/host/daemon/cli-user-watch.d.ts +0 -9
- package/dist/host/daemon/cli-user-watch.js +0 -47
- package/dist/host/daemon/cli-user.d.ts +0 -2
- package/dist/host/daemon/cli-user.js +0 -42
- package/dist/host/daemon/daemon-files.d.ts +0 -20
- package/dist/host/daemon/daemon-files.js +0 -46
- package/dist/host/daemon/daemon-owner.d.ts +0 -1
- package/dist/host/daemon/daemon-owner.js +0 -32
- package/dist/host/daemon/daemon.d.ts +0 -19
- package/dist/host/daemon/daemon.js +0 -137
- package/dist/host/daemon/entries.d.ts +0 -21
- package/dist/host/daemon/entries.js +0 -24
- package/dist/host/daemon/gate.d.ts +0 -3
- package/dist/host/daemon/gate.js +0 -19
- package/dist/host/daemon/health-routes.d.ts +0 -18
- package/dist/host/daemon/health-routes.js +0 -75
- package/dist/host/daemon/host-token.d.ts +0 -6
- package/dist/host/daemon/host-token.js +0 -28
- package/dist/host/daemon/installation.d.ts +0 -35
- package/dist/host/daemon/installation.js +0 -90
- package/dist/host/daemon/installer-call.d.ts +0 -21
- package/dist/host/daemon/installer-call.js +0 -48
- package/dist/host/daemon/json-file.d.ts +0 -6
- package/dist/host/daemon/json-file.js +0 -90
- package/dist/host/daemon/lane.d.ts +0 -9
- package/dist/host/daemon/lane.js +0 -24
- package/dist/host/daemon/last-words.d.ts +0 -2
- package/dist/host/daemon/last-words.js +0 -28
- package/dist/host/daemon/limits.d.ts +0 -16
- package/dist/host/daemon/limits.js +0 -31
- package/dist/host/daemon/ops.d.ts +0 -12
- package/dist/host/daemon/ops.js +0 -94
- package/dist/host/daemon/patch-values.d.ts +0 -6
- package/dist/host/daemon/patch-values.js +0 -39
- package/dist/host/daemon/pending.d.ts +0 -15
- package/dist/host/daemon/pending.js +0 -18
- package/dist/host/daemon/proxy.d.ts +0 -11
- package/dist/host/daemon/proxy.js +0 -106
- package/dist/host/daemon/queue.d.ts +0 -3
- package/dist/host/daemon/queue.js +0 -27
- package/dist/host/daemon/redact-stream.d.ts +0 -4
- package/dist/host/daemon/redact-stream.js +0 -24
- package/dist/host/daemon/reload-marker.d.ts +0 -8
- package/dist/host/daemon/reload-marker.js +0 -57
- package/dist/host/daemon/reload.d.ts +0 -10
- package/dist/host/daemon/reload.js +0 -72
- package/dist/host/daemon/restart.d.ts +0 -14
- package/dist/host/daemon/restart.js +0 -59
- package/dist/host/daemon/routes.d.ts +0 -6
- package/dist/host/daemon/routes.js +0 -101
- package/dist/host/daemon/run-lock.d.ts +0 -1
- package/dist/host/daemon/run-lock.js +0 -15
- package/dist/host/daemon/seal-reach.d.ts +0 -2
- package/dist/host/daemon/seal-reach.js +0 -38
- package/dist/host/daemon/seal.d.ts +0 -20
- package/dist/host/daemon/seal.js +0 -93
- package/dist/host/daemon/shell-events.d.ts +0 -9
- package/dist/host/daemon/shell-events.js +0 -36
- package/dist/host/daemon/shell-routes.d.ts +0 -29
- package/dist/host/daemon/shell-routes.js +0 -68
- package/dist/host/daemon/sign-in-page.d.ts +0 -3
- package/dist/host/daemon/sign-in-page.js +0 -30
- package/dist/host/daemon/start-checks.d.ts +0 -6
- package/dist/host/daemon/start-checks.js +0 -29
- package/dist/host/daemon/stopping.d.ts +0 -10
- package/dist/host/daemon/stopping.js +0 -28
- package/dist/host/daemon/supervisor.d.ts +0 -59
- package/dist/host/daemon/supervisor.js +0 -107
- package/dist/host/daemon/write-all.d.ts +0 -8
- package/dist/host/daemon/write-all.js +0 -45
- /package/dist/host/{daemon/guard.d.ts → guard.d.ts} +0 -0
package/dist/auth/part-auth.js
CHANGED
|
@@ -24,11 +24,10 @@ const valid = (env, key) => {
|
|
|
24
24
|
return parsed.success ? parsed.data : '';
|
|
25
25
|
};
|
|
26
26
|
// ctx.platform from the token check's env; pages and worker start without it and get ''.
|
|
27
|
-
export const platformOf = (env) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
27
|
+
export const platformOf = (env) => ({
|
|
28
|
+
issuer: valid(env, 'AGENTAGE_ISSUER'),
|
|
29
|
+
audience: valid(env, 'AGENTAGE_AUDIENCE'),
|
|
30
|
+
});
|
|
32
31
|
// *.agentage.io covers the domain and every host under it at any depth; else one exact host.
|
|
33
32
|
export const covers = (audience, host) => audience.startsWith('*.')
|
|
34
33
|
? host === audience.slice(2) || host.endsWith(audience.slice(1))
|
|
@@ -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;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface LaunchSpec {
|
|
2
|
+
id: string;
|
|
3
|
+
dir: string;
|
|
4
|
+
dataDir: string;
|
|
5
|
+
settings: Record<string, unknown>;
|
|
6
|
+
secrets: Record<string, string>;
|
|
7
|
+
origin: string;
|
|
8
|
+
storeOpenMs?: number;
|
|
9
|
+
userSub?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const childEnv: (spec: LaunchSpec, secretsDir: string, runDir?: string) => Record<string, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// What dist/host/main.js reads (docs/part-image.md), on a port the OS picks.
|
|
2
|
+
export const childEnv = (spec, secretsDir, runDir) => ({
|
|
3
|
+
PORT: '0',
|
|
4
|
+
AGENTAGE_EXTENSION_DIR: spec.dir,
|
|
5
|
+
AGENTAGE_DATA_DIR: spec.dataDir,
|
|
6
|
+
AGENTAGE_SETTINGS: JSON.stringify(spec.settings),
|
|
7
|
+
AGENTAGE_SECRETS_DIR: secretsDir,
|
|
8
|
+
AGENTAGE_ORIGIN: spec.origin,
|
|
9
|
+
...(runDir && { AGENTAGE_RUN_DIR: runDir }),
|
|
10
|
+
...(spec.storeOpenMs && { AGENTAGE_STORE_OPEN_MS: String(spec.storeOpenMs) }),
|
|
11
|
+
...(spec.userSub && { AGENTAGE_USER_SUB: spec.userSub }),
|
|
12
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {} from 'express';
|
|
2
|
-
import { fail } from '
|
|
2
|
+
import { fail } from '../envelope/envelope.js';
|
|
3
3
|
// What a browser says of a request another site started (an <img>, a link, a form).
|
|
4
4
|
const FOREIGN = ['cross-site', 'same-site'];
|
|
5
5
|
const hostsAt = (port) => [`127.0.0.1:${port}`, `localhost:${port}`];
|
|
@@ -14,7 +14,7 @@ import { readManifest } from '../manifest/read-manifest.js';
|
|
|
14
14
|
import { buildInfoFromEnv } from '../runtime/build-info.js';
|
|
15
15
|
import {} from '../server/app.js';
|
|
16
16
|
import { hostClockRate } from '../worker/clock.js';
|
|
17
|
-
import { localOnly } from './
|
|
17
|
+
import { localOnly } from './guard.js';
|
|
18
18
|
import { hostPartsOf } from './host-parts.js';
|
|
19
19
|
import { openHostStore, STORE_OPEN_MS } from './host-store.js';
|
|
20
20
|
import { hostStoreChecks } from './host-url-store.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HOST_MAIN: string;
|
package/dist/host/index.d.ts
CHANGED
|
@@ -1,8 +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
|
-
export { localOnly } from './
|
|
4
|
-
export { createDaemon, DAEMON_PORT, type Daemon, type DaemonOptions } from './daemon/daemon.js';
|
|
5
|
-
export { type Installer, type State } from './daemon/supervisor.js';
|
|
6
|
-
export { withFileLock } from './daemon/json-file.js';
|
|
7
|
-
export { updateInstallation, type InstallEntry, type Installation } from './daemon/installation.js';
|
|
3
|
+
export { localOnly } from './guard.js';
|
|
8
4
|
export { hostExtension, type HostedExtension, type HostOptions } from './host-extension.js';
|
package/dist/host/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
export { combineHost, } from '../discovery/combine.js';
|
|
2
2
|
export { capabilities } from '../tool/capabilities.js';
|
|
3
|
-
export { localOnly } from './
|
|
4
|
-
export { createDaemon, DAEMON_PORT } from './daemon/daemon.js';
|
|
5
|
-
export {} from './daemon/supervisor.js';
|
|
6
|
-
export { withFileLock } from './daemon/json-file.js';
|
|
7
|
-
export { updateInstallation } from './daemon/installation.js';
|
|
3
|
+
export { localOnly } from './guard.js';
|
|
8
4
|
export { hostExtension } from './host-extension.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const kitShellDir: (base?: string) => string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
// The shell the kit carries (dist/shell, written by the kit build); none when run from src.
|
|
5
|
+
export const kitShellDir = (base = import.meta.url) => {
|
|
6
|
+
const dir = fileURLToPath(new URL('../shell', base));
|
|
7
|
+
return existsSync(join(dir, 'package.json')) ? dir : undefined;
|
|
8
|
+
};
|
package/dist/host/serve-host.js
CHANGED
|
@@ -4,7 +4,7 @@ import { setTimeout as sleep } from 'node:timers/promises';
|
|
|
4
4
|
import { createLog } from '../log/log.js';
|
|
5
5
|
import {} from '../runtime/build-info.js';
|
|
6
6
|
import { listen, shutdownOn } from '../server/serve.js';
|
|
7
|
-
import { loopbackPorts } from './
|
|
7
|
+
import { loopbackPorts } from './guard.js';
|
|
8
8
|
import { guardOf, hostEnvOf } from './host-env.js';
|
|
9
9
|
import { hostBuildInfo, hostWith } from './host-extension.js';
|
|
10
10
|
export const ORPHAN_MS = 10_000;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { agcidMiddleware } from '../agcid/scope.js';
|
|
2
|
+
export { download } from '../api/download.js';
|
|
3
|
+
export { type ApiContext } from '../api/routes.js';
|
|
4
|
+
export { fits, type Setting } from '../context/settings.js';
|
|
5
|
+
export { type Answer, type CallerState, combineHost, type CombineInput, } from '../discovery/combine.js';
|
|
6
|
+
export { DiscoveryDocumentSchema } from '../discovery/discovery.schema.js';
|
|
7
|
+
export { HostDocumentSchema, type HostEntry } from '../discovery/host-document.schema.js';
|
|
8
|
+
export { SERVES_KINDS } from '../discovery/served.schema.js';
|
|
9
|
+
export { fail, ok } from '../envelope/envelope.js';
|
|
10
|
+
export { parse } from '../envelope/parse.js';
|
|
11
|
+
export { type AppRow, appRowIn, appStatic } from '../host/app-bundle.js';
|
|
12
|
+
export { childEnv, type LaunchSpec } from '../host/child-env.js';
|
|
13
|
+
export { clearOldLock, DATA_DIR_LOCKED, lockDataDir } from '../host/data-lock.js';
|
|
14
|
+
export { localOnly } from '../host/guard.js';
|
|
15
|
+
export { guardOf } from '../host/host-env.js';
|
|
16
|
+
export { HOST_MAIN } from '../host/host-main.js';
|
|
17
|
+
export { kitShellDir } from '../host/kit-shell.js';
|
|
18
|
+
export { serveHost } from '../host/serve-host.js';
|
|
19
|
+
export { createLog, type Log } from '../log/log.js';
|
|
20
|
+
export { type ExtensionPackage } from '../manifest/manifest.schema.js';
|
|
21
|
+
export { hasStore, hostParts, mountedIn, secretNames } from '../manifest/parts.js';
|
|
22
|
+
export { ExtensionIdSchema, SecretNameSchema, VersionSchema, } from '../manifest/primitives.schema.js';
|
|
23
|
+
export { readManifest } from '../manifest/read-manifest.js';
|
|
24
|
+
export { BODY_LIMIT } from '../server/app.js';
|
|
25
|
+
export { errorHandler, notFound } from '../server/errors.js';
|
|
26
|
+
export { closeNow, listen } from '../server/serve.js';
|
|
27
|
+
export { startOn, startTestServer, type TestServer } from '../testing/test-server.js';
|
|
28
|
+
export { KIT_VERSION } from '../tool/kit-version.js';
|
|
29
|
+
export { CLOCK_RATE_ENV, parseClockRate } from '../worker/clock.js';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// The kit modules the app host program (@agentage/apphost) builds on; not a public api.
|
|
2
|
+
export { agcidMiddleware } from '../agcid/scope.js';
|
|
3
|
+
export { download } from '../api/download.js';
|
|
4
|
+
export {} from '../api/routes.js';
|
|
5
|
+
export { fits } from '../context/settings.js';
|
|
6
|
+
export { combineHost, } from '../discovery/combine.js';
|
|
7
|
+
export { DiscoveryDocumentSchema } from '../discovery/discovery.schema.js';
|
|
8
|
+
export { HostDocumentSchema } from '../discovery/host-document.schema.js';
|
|
9
|
+
export { SERVES_KINDS } from '../discovery/served.schema.js';
|
|
10
|
+
export { fail, ok } from '../envelope/envelope.js';
|
|
11
|
+
export { parse } from '../envelope/parse.js';
|
|
12
|
+
export { appRowIn, appStatic } from '../host/app-bundle.js';
|
|
13
|
+
export { childEnv } from '../host/child-env.js';
|
|
14
|
+
export { clearOldLock, DATA_DIR_LOCKED, lockDataDir } from '../host/data-lock.js';
|
|
15
|
+
export { localOnly } from '../host/guard.js';
|
|
16
|
+
export { guardOf } from '../host/host-env.js';
|
|
17
|
+
export { HOST_MAIN } from '../host/host-main.js';
|
|
18
|
+
export { kitShellDir } from '../host/kit-shell.js';
|
|
19
|
+
export { serveHost } from '../host/serve-host.js';
|
|
20
|
+
export { createLog } from '../log/log.js';
|
|
21
|
+
export {} from '../manifest/manifest.schema.js';
|
|
22
|
+
export { hasStore, hostParts, mountedIn, secretNames } from '../manifest/parts.js';
|
|
23
|
+
export { ExtensionIdSchema, SecretNameSchema, VersionSchema, } from '../manifest/primitives.schema.js';
|
|
24
|
+
export { readManifest } from '../manifest/read-manifest.js';
|
|
25
|
+
export { BODY_LIMIT } from '../server/app.js';
|
|
26
|
+
export { errorHandler, notFound } from '../server/errors.js';
|
|
27
|
+
export { closeNow, listen } from '../server/serve.js';
|
|
28
|
+
export { startOn, startTestServer } from '../testing/test-server.js';
|
|
29
|
+
export { KIT_VERSION } from '../tool/kit-version.js';
|
|
30
|
+
export { CLOCK_RATE_ENV, parseClockRate } from '../worker/clock.js';
|
|
@@ -29,7 +29,7 @@ const api = async (input) => {
|
|
|
29
29
|
const openapi = routes.length > 0 ? generatedOpenapi(input.pkg, routes) : input.openapi;
|
|
30
30
|
const options = { ...input.base, router, routes, openapi, wellKnown: documents, files };
|
|
31
31
|
const record = openapi ? { openapi: openapiPath(input.pkg.agentage.id) } : {};
|
|
32
|
-
return { mount: (app) => mountApiRoutes(app,
|
|
32
|
+
return { mount: (app) => mountApiRoutes(app, options), record };
|
|
33
33
|
};
|
|
34
34
|
const mcp = async (input) => {
|
|
35
35
|
const registry = createToolRegistry();
|
package/dist/runtime/run-part.js
CHANGED
|
@@ -103,8 +103,6 @@ const inputFor = async (options, start) => {
|
|
|
103
103
|
base,
|
|
104
104
|
openapi,
|
|
105
105
|
importModule: options.importModule,
|
|
106
|
-
// The old prefix as a second mount, so next stays green; it goes in phase 4.
|
|
107
|
-
apiAliases: ['/api/v1'],
|
|
108
106
|
// /mcp/{id} (and /connector/{id}) as the app host routes it; bare /mcp for the estate gateway.
|
|
109
107
|
mcpPaths: [MCP_PATH, mcpPathOf(start.pkg.agentage.id)],
|
|
110
108
|
};
|