feat(runtime): establish miniapp kernel and sdk design

This commit is contained in:
2026-08-05 00:46:16 +08:00
parent d8aa087bc8
commit 9fb8cd1598
86 changed files with 4615 additions and 1364 deletions
@@ -0,0 +1,27 @@
/**
* Host 所有的易失 Artifact 内容缓存。
*
* 它只保存已经通过 ArtifactState 接纳的宿主字节;内容不写入 Conversation Store
* Agent 只能引用不透明 local_ref,不能直接填充或读取缓存。
*
* Host-owned volatile bytes for Artifact metadata already accepted by
* ArtifactState. This cache has no network, persistence, DOM or protocol
* dependency: an Agent can name an opaque ref but cannot populate or read it.
*/
export class ArtifactContentCache {
private readonly blobs = new Map<string, Blob>();
public put(localRef: string, content: Blob): boolean {
if (!opaqueRef(localRef) || content.size > 512 * 1024 * 1024) return false;
this.blobs.set(localRef, content);
return true;
}
public get(localRef: string): Blob | undefined { return this.blobs.get(localRef); }
public has(localRef: string | undefined): boolean { return Boolean(localRef && this.blobs.has(localRef)); }
public clear(): void { this.blobs.clear(); }
}
function opaqueRef(value: string): boolean {
return /^[A-Za-z0-9_.:-]{1,128}$/.test(value) && !/[\\/]/.test(value);
}