@agentunion/fastaun-browser 0.5.6 → 0.5.9
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/CHANGELOG.md +104 -0
- package/_packed_docs/CHANGELOG.md +104 -0
- package/_packed_docs/INDEX.md +12 -11
- package/_packed_docs/KITE_DOCS_GUIDE.md +4 -3
- package/_packed_docs/agent.md/SCHEMA.md +83 -58
- package/_packed_docs/agent.md/examples/codeagent-claudecode.md +1 -1
- package/_packed_docs/agent.md/examples/openclaw-lobster.md +1 -1
- package/_packed_docs/agent.md/examples/signed-openclaw-lobster.md +1 -1
- package/_packed_docs/agent.md/examples//347/276/244/347/273/204-/345/274/200/345/217/221/345/233/242/351/230/237.md +21 -0
- package/_packed_docs/audit/AUN/346/234/215/345/212/241Go/345/214/226/351/207/215/346/236/204/347/262/276/347/273/206/345/214/226/346/272/220/347/240/201/345/256/241/346/237/245-20260718.md +3 -3
- package/_packed_docs/aun/345/205/254/347/275/221/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +7 -0
- package/_packed_docs/aun/345/210/206/345/270/203/345/274/217/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +422 -331
- package/_packed_docs/aun/346/265/213/350/257/225/350/277/220/350/241/214/346/214/207/345/215/227.md +598 -398
- package/_packed_docs/group-message-rpc-alignment-gaps.md +741 -0
- package/_packed_docs/message-online-push-alignment.md +572 -0
- package/_packed_docs/protocol/06-/346/234/215/345/212/241/345/215/217/350/256/256.md +1 -1
- package/_packed_docs/sdk/02-WebSocket/345/215/217/350/256/256.md +10 -10
- package/_packed_docs/sdk/03-/346/240/270/345/277/203/346/246/202/345/277/265.md +2 -2
- package/_packed_docs/sdk/04-/350/277/236/346/216/245/344/270/216/350/256/244/350/257/201.md +30 -10
- package/_packed_docs/sdk/06-API/346/211/213/345/206/214.md +23 -20
- package/_packed_docs/sdk/07-/351/224/231/350/257/257/345/244/204/347/220/206.md +3 -3
- package/_packed_docs/sdk/08-/346/234/200/344/275/263/345/256/236/350/267/265.md +5 -6
- package/_packed_docs/sdk/09-group-rpc-manual.md +11 -7
- package/_packed_docs/sdk/09-message-rpc-manual.md +5 -3
- package/_packed_docs/sdk/09-storage-rpc-manual.md +14 -3
- package/_packed_docs/sdk/AUN_DOCS_GUIDE.md +19 -17
- package/_packed_docs/sdk/CHANGELOG-0.5.6.md +73 -0
- package/_packed_docs/sdk/INDEX.md +22 -22
- package/_packed_docs/sdk/README.md +6 -5
- package/dist/agent-md-schema.d.ts +14 -0
- package/dist/agent-md-schema.d.ts.map +1 -0
- package/dist/agent-md-schema.js +103 -0
- package/dist/agent-md-schema.js.map +1 -0
- package/dist/agent-md.d.ts +7 -0
- package/dist/agent-md.d.ts.map +1 -1
- package/dist/agent-md.js +230 -10
- package/dist/agent-md.js.map +1 -1
- package/dist/aid-store.d.ts +5 -1
- package/dist/aid-store.d.ts.map +1 -1
- package/dist/aid-store.js +24 -4
- package/dist/aid-store.js.map +1 -1
- package/dist/aid.d.ts +2 -0
- package/dist/aid.d.ts.map +1 -1
- package/dist/aid.js +29 -7
- package/dist/aid.js.map +1 -1
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +1 -0
- package/dist/auth.js.map +1 -1
- package/dist/bundle.js +30253 -21955
- package/dist/cert-utils.d.ts +1 -0
- package/dist/cert-utils.d.ts.map +1 -1
- package/dist/cert-utils.js +36 -16
- package/dist/cert-utils.js.map +1 -1
- package/dist/client/delivery.d.ts +40 -5
- package/dist/client/delivery.d.ts.map +1 -1
- package/dist/client/delivery.js +719 -221
- package/dist/client/delivery.js.map +1 -1
- package/dist/client/group-state.js +2 -2
- package/dist/client/group-state.js.map +1 -1
- package/dist/client/lifecycle.d.ts +15 -1
- package/dist/client/lifecycle.d.ts.map +1 -1
- package/dist/client/lifecycle.js +463 -151
- package/dist/client/lifecycle.js.map +1 -1
- package/dist/client/rpc-pipeline.d.ts +25 -6
- package/dist/client/rpc-pipeline.d.ts.map +1 -1
- package/dist/client/rpc-pipeline.js +407 -123
- package/dist/client/rpc-pipeline.js.map +1 -1
- package/dist/client/runtime.d.ts +1 -3
- package/dist/client/runtime.d.ts.map +1 -1
- package/dist/client/runtime.js +4 -7
- package/dist/client/runtime.js.map +1 -1
- package/dist/client/v2-e2ee.d.ts +20 -2
- package/dist/client/v2-e2ee.d.ts.map +1 -1
- package/dist/client/v2-e2ee.js +434 -112
- package/dist/client/v2-e2ee.js.map +1 -1
- package/dist/client.d.ts +22 -10
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +500 -116
- package/dist/client.js.map +1 -1
- package/dist/facades.d.ts +23 -1
- package/dist/facades.d.ts.map +1 -1
- package/dist/facades.js +55 -7
- package/dist/facades.js.map +1 -1
- package/dist/group-id.d.ts.map +1 -1
- package/dist/group-id.js +2 -17
- package/dist/group-id.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/seq-tracker.d.ts.map +1 -1
- package/dist/seq-tracker.js +8 -2
- package/dist/seq-tracker.js.map +1 -1
- package/dist/tools/cross-sdk-agent.js +23 -1
- package/dist/tools/cross-sdk-agent.js.map +1 -1
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +8 -1
- package/dist/transport.js.map +1 -1
- package/dist/validators.d.ts.map +1 -1
- package/dist/validators.js +8 -14
- package/dist/validators.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -5
|
@@ -10,8 +10,9 @@ AUN(Agent Union Network)定义 Agent 之间安全通信的标准接口,基
|
|
|
10
10
|
- **三主体 SDK 模型**:`AIDStore` 管理 keystore,`AID` 是不可变身份值对象,`AUNClient` 管理连接与会话。
|
|
11
11
|
- **Gateway 连接**:当前各语言 SDK 稳定支持 Gateway 接入;Peer / Relay 仍处于协议定义或未实现状态。
|
|
12
12
|
- **默认 E2EE**:P2P 和 Group V2 消息默认加密;普通明文消息需要显式关闭加密。
|
|
13
|
-
- **统一 RPC / 事件 / Notify**:业务方法通过 `client.call(method, params)` 调用,事件通过 `client.on(event, handler)` 订阅;在线轻量通知通过 `client.notify()` 发送,支持同域和跨域在线 federation,详见 `Notify通知方案.md`。
|
|
14
|
-
-
|
|
13
|
+
- **统一 RPC / 事件 / Notify**:业务方法通过 `client.call(method, params)` 调用,事件通过 `client.on(event, handler)` 订阅;在线轻量通知通过 `client.notify()` 发送,支持同域和跨域在线 federation,详见 `Notify通知方案.md`。
|
|
14
|
+
- **当前 access token**:自行发起要求 AID Bearer 的 HTTP 数据面请求时,每次请求前使用 Python `get_access_token()`、TypeScript / JavaScript `getAccessToken()` 或 Go `GetAccessToken()` 读取后台刷新维护的缓存;不得长期复用 `authenticate()` 首次返回的字符串。
|
|
15
|
+
- **Service Proxy**:Python SDK 提供 `ServiceProxyClient`,provider 会先向 Gateway 注册 `proxy.*` 控制面服务列表,再在每条 proxy-server 隧道认证后注册数据面服务列表。
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
@@ -106,9 +107,9 @@ Layer 1: 安全层 TLS + AUN E2EE
|
|
|
106
107
|
| [01-快速开始](01-快速开始.md) | 安装、三主体模型、最小示例、多语言构造 |
|
|
107
108
|
| [02-WebSocket协议](02-WebSocket协议.md) | 握手流程、消息格式、Capabilities、裸 WebSocket 示例 |
|
|
108
109
|
| [03-核心概念](03-核心概念.md) | AID、AIDStore、AUNClient、九态状态机、E2EE |
|
|
109
|
-
| [04-连接与认证](04-连接与认证.md) |
|
|
110
|
+
| [04-连接与认证](04-连接与认证.md) | 注册、加载、认证、当前 access token getter、连接、Python Push 自动登记、事件、agent.md |
|
|
110
111
|
| [05-E2EE加密通信](05-E2EE加密通信.md) | E2EE 收发、ProtectedHeaders、密钥管理 |
|
|
111
|
-
| [06-API手册](06-API手册.md) | AIDStore / AID / AUNClient / Python PushFacade / ServiceProxyClient / 事件 / RPC 索引 |
|
|
112
|
+
| [06-API手册](06-API手册.md) | AIDStore / AID / AUNClient / 四 SDK access token getter / Python PushFacade / ServiceProxyClient / 事件 / RPC 索引 |
|
|
112
113
|
| [07-错误处理](07-错误处理.md) | Result、异常层级、错误码、重试策略 |
|
|
113
114
|
| [08-最佳实践](08-最佳实践.md) | 幂等连接、多 AID、资源清理、测试数据保护 |
|
|
114
115
|
| [AUN Storage架构设计](<../aun-fs/AUN Storage架构设计.md>) | Storage SDK VFS、控制面/数据面分离、服务端分层、类 Linux 权限、mount/symlink 和关键时序 |
|
|
@@ -121,7 +122,7 @@ RPC 专项手册:
|
|
|
121
122
|
|------|------|
|
|
122
123
|
| [09-message-rpc-manual.md](09-message-rpc-manual.md) | P2P 消息、ack、thought |
|
|
123
124
|
| [09-group-rpc-manual.md](09-group-rpc-manual.md) | 群组生命周期、成员、群消息、群 thought、Group FS |
|
|
124
|
-
| [09-storage-rpc-manual.md](09-storage-rpc-manual.md) | 对象存储 + POSIX VFS(fs/卷/软链/ACL/token
|
|
125
|
+
| [09-storage-rpc-manual.md](09-storage-rpc-manual.md) | 对象存储 + POSIX VFS(fs/卷/软链/ACL/token)+ 数据面 HTTP 下载与 Bearer/ticket 边界 |
|
|
125
126
|
| [09-collab-rpc-manual.md](09-collab-rpc-manual.md) | 协作层:版本化文档、乐观锁、三方合并、目录快照 |
|
|
126
127
|
| [09-meta-rpc-manual.md](09-meta-rpc-manual.md) | ping / status / trust_roots |
|
|
127
128
|
| [09-stream-rpc-manual.md](09-stream-rpc-manual.md) | 流式数据传输 |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const AGENT_MD_MAX_SIGNATURE_BYTES = 2048;
|
|
2
|
+
export declare function validateAgentMdDocument(content: string, opts?: {
|
|
3
|
+
expectedAid?: string;
|
|
4
|
+
maxPayloadBytes?: number;
|
|
5
|
+
requireSignature?: boolean;
|
|
6
|
+
now?: number;
|
|
7
|
+
}): {
|
|
8
|
+
payload: string;
|
|
9
|
+
frontmatter: Record<string, unknown>;
|
|
10
|
+
signature: Record<string, string> | null;
|
|
11
|
+
};
|
|
12
|
+
export declare function verifyAgentMdUpload(content: string, certPem: string, expectedAid: string, now?: number): Promise<void>;
|
|
13
|
+
export declare function validateAgentMdCertificate(certPem: string, expectedAid: string, timestamp: number, now?: number, requireCurrentValidity?: boolean): void;
|
|
14
|
+
//# sourceMappingURL=agent-md-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-md-schema.d.ts","sourceRoot":"","sources":["../src/agent-md-schema.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAqBjD,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO;;;;EA2B/J;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO5H;AAED,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,EACZ,sBAAsB,UAAO,GAC5B,IAAI,CASN"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { ValidationError } from './errors.js';
|
|
2
|
+
import { parseAgentMdTailSignature, parseCertMetadata, verifySignatureWithCert, certFingerprint, publicKeyMatchesFingerprint, isStrictBase64 } from './cert-utils.js';
|
|
3
|
+
import { parseDocument } from 'yaml';
|
|
4
|
+
const AID_RE = /^[A-Za-z0-9_][A-Za-z0-9_-]*(?:\.[A-Za-z0-9_][A-Za-z0-9_-]*)+$/;
|
|
5
|
+
const SEMVER_RE = /^\d+\.\d+\.\d+$/;
|
|
6
|
+
export const AGENT_MD_MAX_SIGNATURE_BYTES = 2048;
|
|
7
|
+
function assertValidUtf8Text(content) {
|
|
8
|
+
const encoded = new TextEncoder().encode(content);
|
|
9
|
+
if (new TextDecoder('utf-8', { fatal: true }).decode(encoded) !== content) {
|
|
10
|
+
throw new ValidationError('agent.md must be valid UTF-8 text');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function frontmatter(payload) {
|
|
14
|
+
const lines = payload.replace(/^\ufeff/, '').split(/\r\n|\n|\r/);
|
|
15
|
+
if (lines[0]?.trim() !== '---')
|
|
16
|
+
throw new ValidationError('agent.md must start with YAML frontmatter');
|
|
17
|
+
const end = lines.slice(1).findIndex((line) => line.trim() === '---');
|
|
18
|
+
if (end < 0)
|
|
19
|
+
throw new ValidationError('agent.md frontmatter is not closed');
|
|
20
|
+
const doc = parseDocument(lines.slice(1, end + 1).join('\n'), { uniqueKeys: true });
|
|
21
|
+
if (doc.errors.length)
|
|
22
|
+
throw new ValidationError(`agent.md frontmatter is invalid: ${doc.errors[0].message}`);
|
|
23
|
+
const result = doc.toJS();
|
|
24
|
+
if (!result || typeof result !== 'object' || Array.isArray(result))
|
|
25
|
+
throw new ValidationError('agent.md frontmatter must be a mapping');
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
export function validateAgentMdDocument(content, opts = {}) {
|
|
29
|
+
if (!String(content ?? '').trim())
|
|
30
|
+
throw new ValidationError('agent.md content cannot be empty');
|
|
31
|
+
assertValidUtf8Text(String(content));
|
|
32
|
+
if ((String(content).match(/<!-- AUN-SIGNATURE/g) ?? []).length > 1)
|
|
33
|
+
throw new ValidationError('agent.md must contain exactly one signature block');
|
|
34
|
+
const parsed = parseAgentMdTailSignature(String(content));
|
|
35
|
+
if (parsed.parseError)
|
|
36
|
+
throw new ValidationError(parsed.parseError);
|
|
37
|
+
if (opts.requireSignature && !parsed.fields)
|
|
38
|
+
throw new ValidationError('agent.md signature is required');
|
|
39
|
+
if (new TextEncoder().encode(parsed.payload).byteLength > (opts.maxPayloadBytes ?? 4096))
|
|
40
|
+
throw new ValidationError('agent.md payload exceeds 4096 bytes');
|
|
41
|
+
if (parsed.fields && new TextEncoder().encode(String(content)).byteLength - new TextEncoder().encode(parsed.payload).byteLength > AGENT_MD_MAX_SIGNATURE_BYTES)
|
|
42
|
+
throw new ValidationError(`agent.md signature block exceeds ${AGENT_MD_MAX_SIGNATURE_BYTES} bytes`);
|
|
43
|
+
const meta = frontmatter(parsed.payload);
|
|
44
|
+
for (const key of ['aid', 'name', 'type', 'version', 'description'])
|
|
45
|
+
if (!(key in meta))
|
|
46
|
+
throw new ValidationError(`agent.md frontmatter missing ${key}`);
|
|
47
|
+
if (typeof meta.aid !== 'string' || !AID_RE.test(meta.aid))
|
|
48
|
+
throw new ValidationError('agent.md frontmatter aid has invalid format');
|
|
49
|
+
if (opts.expectedAid && meta.aid.toLowerCase() !== opts.expectedAid.trim().toLowerCase())
|
|
50
|
+
throw new ValidationError('agent.md frontmatter aid does not match local AID');
|
|
51
|
+
for (const key of ['name', 'type', 'description'])
|
|
52
|
+
if (typeof meta[key] !== 'string' || !String(meta[key]).trim())
|
|
53
|
+
throw new ValidationError(`agent.md frontmatter ${key} must be a non-empty string`);
|
|
54
|
+
if (typeof meta.version !== 'string' || !SEMVER_RE.test(meta.version))
|
|
55
|
+
throw new ValidationError('agent.md version must be SemVer MAJOR.MINOR.PATCH');
|
|
56
|
+
if (Array.from(String(meta.description)).length > 100)
|
|
57
|
+
throw new ValidationError('agent.md description exceeds 100 characters');
|
|
58
|
+
if (meta.tags !== undefined && (!Array.isArray(meta.tags) || meta.tags.some((item) => typeof item !== 'string')))
|
|
59
|
+
throw new ValidationError('agent.md tags must be an array of strings');
|
|
60
|
+
const fields = parsed.fields;
|
|
61
|
+
if (fields) {
|
|
62
|
+
if (Object.keys(fields).some((key) => !['cert_fingerprint', 'public_key_fingerprint', 'timestamp', 'signature'].includes(key)))
|
|
63
|
+
throw new ValidationError('agent.md signature contains unknown fields');
|
|
64
|
+
if (!/^sha256:[0-9a-f]{64}$/i.test(fields.cert_fingerprint))
|
|
65
|
+
throw new ValidationError('agent.md cert_fingerprint is invalid');
|
|
66
|
+
if (fields.public_key_fingerprint && !/^sha256:[0-9a-f]{64}$/i.test(fields.public_key_fingerprint))
|
|
67
|
+
throw new ValidationError('agent.md public_key_fingerprint is invalid');
|
|
68
|
+
if (!/^\d+$/.test(fields.timestamp) || !isStrictBase64(fields.signature))
|
|
69
|
+
throw new ValidationError('agent.md signature fields are invalid');
|
|
70
|
+
const now = Math.trunc(opts.now ?? Date.now() / 1000);
|
|
71
|
+
const ts = Number(fields.timestamp);
|
|
72
|
+
if (ts > now + 300)
|
|
73
|
+
throw new ValidationError('agent.md signature timestamp is too far in the future');
|
|
74
|
+
}
|
|
75
|
+
return { payload: parsed.payload, frontmatter: meta, signature: fields };
|
|
76
|
+
}
|
|
77
|
+
export async function verifyAgentMdUpload(content, certPem, expectedAid, now) {
|
|
78
|
+
const parsed = validateAgentMdDocument(content, { expectedAid, requireSignature: true, now });
|
|
79
|
+
const fields = parsed.signature;
|
|
80
|
+
validateAgentMdCertificate(certPem, expectedAid, Number(fields.timestamp), now);
|
|
81
|
+
const actualCertFingerprint = (await certFingerprint(certPem)).toLowerCase();
|
|
82
|
+
if (actualCertFingerprint !== fields.cert_fingerprint.trim().toLowerCase())
|
|
83
|
+
throw new ValidationError('agent.md certificate fingerprint mismatch');
|
|
84
|
+
if (fields.public_key_fingerprint && !(await publicKeyMatchesFingerprint(certPem, fields.public_key_fingerprint)))
|
|
85
|
+
throw new ValidationError('agent.md public key fingerprint mismatch');
|
|
86
|
+
if (!(await verifySignatureWithCert(certPem, fields.signature, new TextEncoder().encode(parsed.payload))))
|
|
87
|
+
throw new ValidationError('agent.md signature verification failed');
|
|
88
|
+
}
|
|
89
|
+
export function validateAgentMdCertificate(certPem, expectedAid, timestamp, now, requireCurrentValidity = true) {
|
|
90
|
+
const metadata = parseCertMetadata(certPem);
|
|
91
|
+
const notBefore = Math.trunc(metadata.notBefore.getTime() / 1000);
|
|
92
|
+
const notAfter = Math.trunc(metadata.notAfter.getTime() / 1000);
|
|
93
|
+
const current = Math.trunc(now ?? Date.now() / 1000);
|
|
94
|
+
if (![notBefore, notAfter, current, timestamp].every(Number.isFinite))
|
|
95
|
+
throw new ValidationError('agent.md signing certificate is invalid');
|
|
96
|
+
if (requireCurrentValidity && (current < notBefore || current > notAfter))
|
|
97
|
+
throw new ValidationError('agent.md signing certificate is expired or not yet valid');
|
|
98
|
+
if (metadata.subject.trim().toLowerCase() !== expectedAid.trim().toLowerCase())
|
|
99
|
+
throw new ValidationError('agent.md signing certificate subject does not match AID');
|
|
100
|
+
if (timestamp < notBefore || timestamp > notAfter)
|
|
101
|
+
throw new ValidationError('agent.md signature timestamp is outside certificate validity');
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=agent-md-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-md-schema.js","sourceRoot":"","sources":["../src/agent-md-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,eAAe,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtK,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAErC,MAAM,MAAM,GAAG,+DAA+D,CAAC;AAC/E,MAAM,SAAS,GAAG,iBAAiB,CAAC;AACpC,MAAM,CAAC,MAAM,4BAA4B,GAAG,IAAI,CAAC;AAEjD,SAAS,mBAAmB,CAAC,OAAe;IAC1C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,IAAI,IAAI,WAAW,CAAC,OAAO,EAAE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,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAClE,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;IAChE,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IACrD,IAAI,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC;QAAE,MAAM,IAAI,eAAe,CAAC,yCAAyC,CAAC,CAAC;IAC5I,IAAI,sBAAsB,IAAI,CAAC,OAAO,GAAG,SAAS,IAAI,OAAO,GAAG,QAAQ,CAAC;QAAE,MAAM,IAAI,eAAe,CAAC,0DAA0D,CAAC,CAAC;IACjK,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,WAAW,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE;QAAE,MAAM,IAAI,eAAe,CAAC,yDAAyD,CAAC,CAAC;IACrK,IAAI,SAAS,GAAG,SAAS,IAAI,SAAS,GAAG,QAAQ;QAAE,MAAM,IAAI,eAAe,CAAC,8DAA8D,CAAC,CAAC;AAC/I,CAAC"}
|
package/dist/agent-md.d.ts
CHANGED
|
@@ -2,6 +2,11 @@ import { AID } from './aid.js';
|
|
|
2
2
|
import type { TokenStore } from './keystore/index.js';
|
|
3
3
|
import type { ModuleLogger } from './logger.js';
|
|
4
4
|
import { type JsonObject } from './types.js';
|
|
5
|
+
export declare function buildDefaultAgentMd(aid: string, options?: {
|
|
6
|
+
type?: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
}): string;
|
|
5
10
|
export type AgentMdVerification = {
|
|
6
11
|
status: string;
|
|
7
12
|
reason?: string;
|
|
@@ -38,6 +43,7 @@ export interface AgentMdManagerOptions {
|
|
|
38
43
|
aunPath: string;
|
|
39
44
|
tokenStore?: TokenStore;
|
|
40
45
|
logger?: ModuleLogger | null;
|
|
46
|
+
uploadViaGatewayHost?: boolean;
|
|
41
47
|
ownerAidGetter?: () => string | null | undefined;
|
|
42
48
|
currentAidGetter?: () => AID | null | undefined;
|
|
43
49
|
gatewayResolver?: (aid: string) => Promise<string> | string;
|
|
@@ -48,6 +54,7 @@ export interface AgentMdManagerOptions {
|
|
|
48
54
|
export declare class AgentMdManager {
|
|
49
55
|
private _aunPath;
|
|
50
56
|
private _agentMdPath;
|
|
57
|
+
private _uploadViaGatewayHost;
|
|
51
58
|
private _tokenStore?;
|
|
52
59
|
private _log;
|
|
53
60
|
private _ownerAidGetter?;
|
package/dist/agent-md.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-md.d.ts","sourceRoot":"","sources":["../src/agent-md.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"agent-md.d.ts","sourceRoot":"","sources":["../src/agent-md.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAI3D,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAO,GACnE,MAAM,CAkBR;AAgJD,MAAM,MAAM,mBAAmB,GAAG;IAAE,MAAM,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,OAAO,CAAC,CAAC;WAkCnF,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAM1D,OAAO,CAAC,MAAM,CAAC,cAAc;IAO7B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAQhC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,SAAS;IAKjB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,WAAW;IAInB,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;YAIL,eAAe;YAIf,YAAY;YAaZ,YAAY;IAM1B,OAAO,CAAC,IAAI;YAIE,WAAW;YAqDX,aAAa;YA+Cb,KAAK;YAkCL,YAAY;YAeZ,aAAa;YAgBb,SAAS;IAavB,OAAO,CAAC,gBAAgB;YAaV,oBAAoB;YASpB,mBAAmB;YAWnB,gBAAgB;YAShB,uBAAuB;CAkBtC"}
|
package/dist/agent-md.js
CHANGED
|
@@ -1,8 +1,28 @@
|
|
|
1
1
|
import { AID } from './aid.js';
|
|
2
2
|
import { certMatchesFingerprint, parseAgentMdTailSignature } from './cert-utils.js';
|
|
3
|
+
import { validateAgentMdDocument, verifyAgentMdUpload } from './agent-md-schema.js';
|
|
3
4
|
import { AUNError, ClientSignatureError, NotFoundError, StateError, ValidationError } from './errors.js';
|
|
4
5
|
import { isJsonObject } from './types.js';
|
|
5
6
|
const DEFAULT_HTTP_TIMEOUT_MS = 30_000;
|
|
7
|
+
export function buildDefaultAgentMd(aid, options = {}) {
|
|
8
|
+
const target = String(aid ?? '').trim();
|
|
9
|
+
const type = String(options.type ?? 'agent').trim() || 'agent';
|
|
10
|
+
const name = String(options.name ?? '').trim() || target.split('.', 1)[0] || target;
|
|
11
|
+
const normalized = String(options.description ?? '').trim().replace(/\s+/g, ' ') || `AUN ${type} ${name}`;
|
|
12
|
+
const description = Array.from(normalized).slice(0, 100).join('');
|
|
13
|
+
return [
|
|
14
|
+
'---',
|
|
15
|
+
`aid: ${JSON.stringify(target)}`,
|
|
16
|
+
`name: ${JSON.stringify(name)}`,
|
|
17
|
+
`type: ${JSON.stringify(type)}`,
|
|
18
|
+
'version: "1.0.0"',
|
|
19
|
+
`description: ${JSON.stringify(description)}`,
|
|
20
|
+
'---',
|
|
21
|
+
'',
|
|
22
|
+
`# ${name}`,
|
|
23
|
+
'',
|
|
24
|
+
].join('\n');
|
|
25
|
+
}
|
|
6
26
|
const HEAD_HTTP_TIMEOUT_MS = 15_000;
|
|
7
27
|
const noopLogger = {
|
|
8
28
|
error: () => { },
|
|
@@ -10,7 +30,127 @@ const noopLogger = {
|
|
|
10
30
|
info: () => { },
|
|
11
31
|
debug: () => { },
|
|
12
32
|
};
|
|
33
|
+
function nodeBuiltin(name) {
|
|
34
|
+
const processLike = globalThis.process;
|
|
35
|
+
if (typeof processLike?.getBuiltinModule !== 'function')
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
return processLike.getBuiltinModule(name);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function requestHeaders(init) {
|
|
45
|
+
const out = {};
|
|
46
|
+
try {
|
|
47
|
+
new Headers(init.headers).forEach((value, key) => {
|
|
48
|
+
out[key] = value;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
function requestWithNodeHost(input, init, timeoutMs) {
|
|
57
|
+
return new Promise((resolve, reject) => {
|
|
58
|
+
let parsed;
|
|
59
|
+
try {
|
|
60
|
+
parsed = new URL(input);
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
reject(error);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const module = parsed.protocol === 'https:'
|
|
67
|
+
? nodeBuiltin('node:https')
|
|
68
|
+
: nodeBuiltin('node:http');
|
|
69
|
+
if (!module) {
|
|
70
|
+
reject(new Error('Node HTTP module is unavailable'));
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
const headers = requestHeaders(init);
|
|
74
|
+
const options = {
|
|
75
|
+
method: init.method ?? 'GET',
|
|
76
|
+
headers,
|
|
77
|
+
timeout: timeoutMs,
|
|
78
|
+
};
|
|
79
|
+
if (parsed.protocol === 'https:') {
|
|
80
|
+
options.rejectUnauthorized = runtimeEnv('NODE_TLS_REJECT_UNAUTHORIZED') !== '0';
|
|
81
|
+
}
|
|
82
|
+
let settled = false;
|
|
83
|
+
let request = null;
|
|
84
|
+
const onAbort = () => {
|
|
85
|
+
request?.destroy(new Error('agent.md request aborted'));
|
|
86
|
+
finish(() => reject(new AUNError('agent.md request aborted')));
|
|
87
|
+
};
|
|
88
|
+
const finish = (callback) => {
|
|
89
|
+
if (settled)
|
|
90
|
+
return;
|
|
91
|
+
settled = true;
|
|
92
|
+
if (init.signal)
|
|
93
|
+
init.signal.removeEventListener('abort', onAbort);
|
|
94
|
+
callback();
|
|
95
|
+
};
|
|
96
|
+
if (init.signal?.aborted) {
|
|
97
|
+
onAbort();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
request = module.request(input, options, (response) => {
|
|
102
|
+
const chunks = [];
|
|
103
|
+
response.on('data', (chunk) => {
|
|
104
|
+
if (chunk instanceof Uint8Array)
|
|
105
|
+
chunks.push(chunk);
|
|
106
|
+
else
|
|
107
|
+
chunks.push(new TextEncoder().encode(String(chunk ?? '')));
|
|
108
|
+
});
|
|
109
|
+
response.on('error', (error) => {
|
|
110
|
+
finish(() => reject(error instanceof Error ? error : new Error(String(error))));
|
|
111
|
+
});
|
|
112
|
+
response.on('end', () => {
|
|
113
|
+
const total = chunks.reduce((size, chunk) => size + chunk.byteLength, 0);
|
|
114
|
+
const body = new Uint8Array(total);
|
|
115
|
+
let offset = 0;
|
|
116
|
+
for (const chunk of chunks) {
|
|
117
|
+
body.set(chunk, offset);
|
|
118
|
+
offset += chunk.byteLength;
|
|
119
|
+
}
|
|
120
|
+
const responseHeaders = {};
|
|
121
|
+
for (const [key, value] of Object.entries(response.headers)) {
|
|
122
|
+
if (typeof value === 'string')
|
|
123
|
+
responseHeaders[key] = value;
|
|
124
|
+
else if (Array.isArray(value))
|
|
125
|
+
responseHeaders[key] = value[0] ?? '';
|
|
126
|
+
}
|
|
127
|
+
finish(() => resolve(new Response(body, {
|
|
128
|
+
status: response.statusCode ?? 500,
|
|
129
|
+
headers: responseHeaders,
|
|
130
|
+
})));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
request.on('error', (error) => {
|
|
134
|
+
finish(() => reject(error instanceof Error ? error : new Error(String(error))));
|
|
135
|
+
});
|
|
136
|
+
request.setTimeout(timeoutMs, () => {
|
|
137
|
+
request?.destroy();
|
|
138
|
+
finish(() => reject(new AUNError(`agent.md request timed out after ${timeoutMs}ms`)));
|
|
139
|
+
});
|
|
140
|
+
init.signal?.addEventListener('abort', onAbort, { once: true });
|
|
141
|
+
if (typeof init.body === 'string')
|
|
142
|
+
request.write(init.body);
|
|
143
|
+
request.end();
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
finish(() => reject(error));
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
13
150
|
async function fetchWithTimeout(input, init, timeoutMs = DEFAULT_HTTP_TIMEOUT_MS) {
|
|
151
|
+
if (new Headers(init.headers).has('host')) {
|
|
152
|
+
return await requestWithNodeHost(input, init, timeoutMs);
|
|
153
|
+
}
|
|
14
154
|
const controller = new AbortController();
|
|
15
155
|
const timer = globalThis.setTimeout(() => controller.abort(), timeoutMs);
|
|
16
156
|
try {
|
|
@@ -32,12 +172,54 @@ function headerValue(headers, name) {
|
|
|
32
172
|
function agentMdHttpScheme(gatewayUrl) {
|
|
33
173
|
return String(gatewayUrl ?? '').trim().toLowerCase().startsWith('ws://') ? 'http' : 'https';
|
|
34
174
|
}
|
|
175
|
+
function runtimeEnv(name) {
|
|
176
|
+
const processLike = globalThis.process;
|
|
177
|
+
return String(processLike?.env?.[name] ?? '').trim();
|
|
178
|
+
}
|
|
179
|
+
function nameServiceAgentMdUrl(aid, gatewayUrl) {
|
|
180
|
+
const configuredBase = runtimeEnv('AUN_NAMESERVICE_URL') || runtimeEnv('KITE_NAMESERVICE_URL');
|
|
181
|
+
if (configuredBase) {
|
|
182
|
+
try {
|
|
183
|
+
const parsed = new URL(configuredBase);
|
|
184
|
+
if (parsed.protocol && parsed.host) {
|
|
185
|
+
parsed.pathname = `${parsed.pathname.replace(/\/+$/g, '')}/agent.md`;
|
|
186
|
+
parsed.search = '';
|
|
187
|
+
parsed.hash = '';
|
|
188
|
+
return parsed.toString();
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
catch {
|
|
192
|
+
// 无效配置时回退到按 issuer 推导的 NameService 公网地址。
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
const target = String(aid ?? '').trim().toLowerCase();
|
|
196
|
+
const gatewayHost = (() => {
|
|
197
|
+
try {
|
|
198
|
+
return new URL(String(gatewayUrl ?? '').trim()).hostname.toLowerCase();
|
|
199
|
+
}
|
|
200
|
+
catch {
|
|
201
|
+
return '';
|
|
202
|
+
}
|
|
203
|
+
})();
|
|
204
|
+
const configuredIssuer = runtimeEnv('AUN_ISSUER_DOMAIN').toLowerCase();
|
|
205
|
+
const issuer = configuredIssuer
|
|
206
|
+
|| (gatewayHost.startsWith('gateway.') ? gatewayHost.slice('gateway.'.length) : '')
|
|
207
|
+
|| (target.includes('.') ? target.slice(target.indexOf('.') + 1) : '');
|
|
208
|
+
const host = runtimeEnv('AUN_SERVICE_PUBLIC_HOST_NAMESERVICE') || issuer;
|
|
209
|
+
if (!host)
|
|
210
|
+
return '';
|
|
211
|
+
const scheme = runtimeEnv('AUN_SERVICE_SCHEME_NAMESERVICE') || agentMdHttpScheme(gatewayUrl);
|
|
212
|
+
const port = runtimeEnv('AUN_SERVICE_PUBLIC_PORT_NAMESERVICE');
|
|
213
|
+
const hostWithPort = port && !host.includes(':') && !host.endsWith(`:${port}`) ? `${host}:${port}` : host;
|
|
214
|
+
return `${scheme}://${hostWithPort}/agent.md`;
|
|
215
|
+
}
|
|
35
216
|
function isRecord(value) {
|
|
36
217
|
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
37
218
|
}
|
|
38
219
|
export class AgentMdManager {
|
|
39
220
|
_aunPath;
|
|
40
221
|
_agentMdPath;
|
|
222
|
+
_uploadViaGatewayHost;
|
|
41
223
|
_tokenStore;
|
|
42
224
|
_log;
|
|
43
225
|
_ownerAidGetter;
|
|
@@ -55,6 +237,7 @@ export class AgentMdManager {
|
|
|
55
237
|
constructor(opts) {
|
|
56
238
|
this._aunPath = String(opts.aunPath ?? '');
|
|
57
239
|
this._agentMdPath = this._defaultRoot();
|
|
240
|
+
this._uploadViaGatewayHost = opts.uploadViaGatewayHost ?? false;
|
|
58
241
|
this._tokenStore = opts.tokenStore;
|
|
59
242
|
this._log = opts.logger ?? noopLogger;
|
|
60
243
|
this._ownerAidGetter = opts.ownerAidGetter;
|
|
@@ -93,6 +276,7 @@ export class AgentMdManager {
|
|
|
93
276
|
const text = String(content ?? '');
|
|
94
277
|
if (text.length === 0)
|
|
95
278
|
throw new ValidationError('uploadAgentMd requires non-empty content');
|
|
279
|
+
validateAgentMdDocument(text, { expectedAid: target });
|
|
96
280
|
await this.saveRecord(target, {
|
|
97
281
|
content: text,
|
|
98
282
|
local_etag: await AgentMdManager.contentEtag(text),
|
|
@@ -103,11 +287,13 @@ export class AgentMdManager {
|
|
|
103
287
|
if (localContent === null || localContent.length === 0) {
|
|
104
288
|
throw new ValidationError('uploadAgentMd requires local agent.md content');
|
|
105
289
|
}
|
|
290
|
+
validateAgentMdDocument(localContent, { expectedAid: target });
|
|
106
291
|
const signedResult = await current.signAgentMd(localContent);
|
|
107
292
|
if (!signedResult.ok) {
|
|
108
293
|
throw new ClientSignatureError(signedResult.error.message || 'agent.md signing failed');
|
|
109
294
|
}
|
|
110
295
|
const signed = signedResult.data.signed;
|
|
296
|
+
await verifyAgentMdUpload(signed, current.certPem, target);
|
|
111
297
|
const result = await this._uploadHttp(target, signed);
|
|
112
298
|
const localEtag = await AgentMdManager.contentEtag(signed);
|
|
113
299
|
const remoteEtag = String(result.etag ?? '').trim();
|
|
@@ -155,7 +341,7 @@ export class AgentMdManager {
|
|
|
155
341
|
last_error: '',
|
|
156
342
|
});
|
|
157
343
|
let inSync = null;
|
|
158
|
-
if (target === this._ownerAid()) {
|
|
344
|
+
if (target.toLowerCase() === this._ownerAid().toLowerCase()) {
|
|
159
345
|
const remote = contentResult.etag || String(saved.remote_etag ?? '');
|
|
160
346
|
inSync = localEtag && remote ? localEtag === remote : false;
|
|
161
347
|
}
|
|
@@ -480,7 +666,7 @@ export class AgentMdManager {
|
|
|
480
666
|
async _resolvePeer(aid, certFingerprint) {
|
|
481
667
|
const expectedFp = String(certFingerprint ?? '').trim().toLowerCase();
|
|
482
668
|
const current = this._currentAid();
|
|
483
|
-
if (current
|
|
669
|
+
if (current && current.aid.toLowerCase() === aid.toLowerCase()) {
|
|
484
670
|
if (!expectedFp || await certMatchesFingerprint(current.certPem, expectedFp))
|
|
485
671
|
return current;
|
|
486
672
|
}
|
|
@@ -502,14 +688,48 @@ export class AgentMdManager {
|
|
|
502
688
|
async _uploadHttp(aid, content) {
|
|
503
689
|
const gatewayUrl = await this._resolveGateway(aid);
|
|
504
690
|
const token = await this._accessToken(aid, gatewayUrl);
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
},
|
|
511
|
-
|
|
512
|
-
|
|
691
|
+
// 浏览器禁止覆盖 Host;动态 AID URL 由浏览器/Docker 的通配解析路由。
|
|
692
|
+
const viaGatewayHost = this._uploadViaGatewayHost && nodeBuiltin('node:http') !== null;
|
|
693
|
+
const headers = {
|
|
694
|
+
Authorization: `Bearer ${token}`,
|
|
695
|
+
'Content-Type': 'text/markdown; charset=utf-8',
|
|
696
|
+
...(viaGatewayHost ? { Host: this._safeAid(aid) } : {}),
|
|
697
|
+
};
|
|
698
|
+
let url = this._url(aid, gatewayUrl);
|
|
699
|
+
if (viaGatewayHost) {
|
|
700
|
+
try {
|
|
701
|
+
const parsedGateway = new URL(String(gatewayUrl ?? '').trim());
|
|
702
|
+
const gatewayHost = parsedGateway.hostname;
|
|
703
|
+
const gatewayPort = parsedGateway.port;
|
|
704
|
+
if (gatewayHost) {
|
|
705
|
+
const host = gatewayPort && gatewayPort !== '443' && gatewayPort !== '20001'
|
|
706
|
+
? `${gatewayHost}:${gatewayPort}`
|
|
707
|
+
: gatewayHost;
|
|
708
|
+
url = `${agentMdHttpScheme(gatewayUrl)}://${host}/agent.md`;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
catch {
|
|
712
|
+
// 无效 Gateway 地址时保留目标 AID URL。
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
let response;
|
|
716
|
+
try {
|
|
717
|
+
response = await fetchWithTimeout(url, { method: 'PUT', headers, body: content });
|
|
718
|
+
}
|
|
719
|
+
catch (error) {
|
|
720
|
+
if (!viaGatewayHost)
|
|
721
|
+
throw error;
|
|
722
|
+
const fallbackUrl = nameServiceAgentMdUrl(aid, gatewayUrl);
|
|
723
|
+
if (!fallbackUrl || fallbackUrl === url)
|
|
724
|
+
throw error;
|
|
725
|
+
response = await fetchWithTimeout(fallbackUrl, { method: 'PUT', headers, body: content });
|
|
726
|
+
}
|
|
727
|
+
if (response.status === 404 && viaGatewayHost) {
|
|
728
|
+
const fallbackUrl = nameServiceAgentMdUrl(aid, gatewayUrl);
|
|
729
|
+
if (fallbackUrl && fallbackUrl !== url) {
|
|
730
|
+
response = await fetchWithTimeout(fallbackUrl, { method: 'PUT', headers, body: content });
|
|
731
|
+
}
|
|
732
|
+
}
|
|
513
733
|
if (response.status === 404) {
|
|
514
734
|
throw new NotFoundError(`agent.md endpoint not found for aid: ${aid}`);
|
|
515
735
|
}
|