@potential-guide/task-protocol 0.0.0-stage → 0.1.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +84 -2
- package/dist/bundle-files.d.ts +9 -0
- package/dist/bundle-files.d.ts.map +1 -0
- package/dist/bundle-files.js +93 -0
- package/dist/bundle-files.js.map +1 -0
- package/dist/bundle-paths.d.ts +15 -0
- package/dist/bundle-paths.d.ts.map +1 -0
- package/dist/bundle-paths.js +24 -0
- package/dist/bundle-paths.js.map +1 -0
- package/dist/bundle-reference.d.ts +9 -0
- package/dist/bundle-reference.d.ts.map +1 -0
- package/dist/bundle-reference.js +82 -0
- package/dist/bundle-reference.js.map +1 -0
- package/dist/bundle.d.ts +80 -0
- package/dist/bundle.d.ts.map +1 -0
- package/dist/bundle.js +342 -0
- package/dist/bundle.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/json.d.ts +22 -0
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +118 -0
- package/dist/json.js.map +1 -0
- package/dist/logs.d.ts +84 -0
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +81 -0
- package/dist/logs.js.map +1 -0
- package/dist/presentation.d.ts +11 -0
- package/dist/presentation.d.ts.map +1 -0
- package/dist/presentation.js +32 -0
- package/dist/presentation.js.map +1 -0
- package/dist/projection.d.ts +21 -0
- package/dist/projection.d.ts.map +1 -0
- package/dist/projection.js +619 -0
- package/dist/projection.js.map +1 -0
- package/dist/run.d.ts +82 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +24 -0
- package/dist/run.js.map +1 -0
- package/dist/schema-runtime.d.ts +29 -0
- package/dist/schema-runtime.d.ts.map +1 -0
- package/dist/schema-runtime.js +340 -0
- package/dist/schema-runtime.js.map +1 -0
- package/dist/schema.d.ts +8 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +69 -0
- package/dist/schema.js.map +1 -0
- package/dist/task-schema-uri.d.ts +2 -0
- package/dist/task-schema-uri.d.ts.map +1 -0
- package/dist/task-schema-uri.js +2 -0
- package/dist/task-schema-uri.js.map +1 -0
- package/dist/types.d.ts +563 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/worker.d.ts +6 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +6 -0
- package/dist/worker.js.map +1 -0
- package/package.json +52 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 shazhou-ww
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,85 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @potential-guide/task-protocol
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Task Bundle bytes and structure
|
|
4
|
+
|
|
5
|
+
The Bundle protocol owns `taskBundleLimits`, `TaskBundleFileLimits`,
|
|
6
|
+
`isTaskBundlePath`, `parseTaskBundleYaml`, and `readTaskBundle`.
|
|
7
|
+
Limits preserve the 64 MiB total/per-file, 256-file, 512-path and 72 MiB CAR
|
|
8
|
+
budgets. Paths are portable, relative, NFC-normalized names without traversal,
|
|
9
|
+
reserved device names or ambiguous casing.
|
|
10
|
+
`parseTaskBundleYaml` reads bounded UTF-8 JSON-subset YAML, without aliases,
|
|
11
|
+
tags, duplicate keys or non-finite numbers; it also reads author build
|
|
12
|
+
declarations before their own schema validation.
|
|
13
|
+
`readTaskBundle` takes an already supplied `ReadonlyMap<string, Uint8Array>`
|
|
14
|
+
and checks exact file inclusion, capacities, nonempty UTF-8 Worker bytes and
|
|
15
|
+
offline Schema resources. It returns declaration, resolved schemas, bytes and
|
|
16
|
+
file count without evaluating the Worker, reading a directory or fetching data.
|
|
17
|
+
Both author tooling and Engine use this implementation independently of
|
|
18
|
+
`artifact-files`. Filesystem safety and Node runtime eligibility remain caller
|
|
19
|
+
responsibilities; Engine cache/hint/retention budgets are not protocol limits.
|
|
20
|
+
Browser reference and presentation subpaths remain independent of this reader
|
|
21
|
+
and its YAML/Schema implementation.
|
|
22
|
+
|
|
23
|
+
Task Bundle 的引用为根 CID 字符串或 `{cid, hint}`:
|
|
24
|
+
`parseBundleReference(reference)` 接受 CID 文本或对象 JSON,
|
|
25
|
+
`formatBundleReference(bundle)` 保留其填写形状及有序 hint。
|
|
26
|
+
两者复用 `validateBundleReference` 的 CID/HTTP(S) gateway 基址约束;
|
|
27
|
+
hint 可为非空字符串或非空数组,不允许凭据、query、fragment、空项或非法 URI。
|
|
28
|
+
Engine 另施加宿主 hint 数量预算,非法输入与容量超限明确区分。
|
|
29
|
+
Request 原始表示参与幂等;内容判等与缓存使用 `bundleCid(reference)` 规范化根 CID。
|
|
30
|
+
旧 URL/Digest 或 URL#Digest 引用明确拒绝,不做双轨转换。
|
|
31
|
+
辅助函数同时从包根与浏览器安全的 `@potential-guide/task-protocol/bundle-reference`
|
|
32
|
+
子入口导出;浏览器使用子入口,不引入 Node Schema 编译与摘要依赖。
|
|
33
|
+
|
|
34
|
+
可信宿主资源声明采用 `resourceLifetime: "request"`,或提供独立
|
|
35
|
+
`confirmResourceRelease(RunResourceContext)` 证明跨请求 owner/句柄已释放。
|
|
36
|
+
上下文包含可信 workerGeneration;这些宿主函数不进入类型 Worker。
|
|
37
|
+
失败 Result 与成功 Result 一样经纯 terminal 业务复验,不能改写或在恢复前放宽。
|
|
38
|
+
|
|
39
|
+
通用 Task/完整 Run 的 JSON、schema、请求、事件、Store 与服务边界。
|
|
40
|
+
|
|
41
|
+
Task Bundle/Worker 使用唯一 `taskSchemaUri` v1,包含独立诊断日志协议。
|
|
42
|
+
项目尚未正式发布,v1 可原地演进;已移除的 Task v2 和未来未知 URL 明确拒绝,不做别名。
|
|
43
|
+
TaskType 仅声明 type/version/inputSchema/resultSchema/messageSchema 和完整 run 入口;
|
|
44
|
+
Host 用 RegisteredType 本地模块描述注册,不传动态函数对象给 Engine。
|
|
45
|
+
|
|
46
|
+
matchPolicy / MatchPolicy 使用 starts-after-eligible、terminates-after-eligible 两值,after 包含等号。
|
|
47
|
+
时间对应完整 Run 开始/实际退出,不对应业务 Execution;已开始但未终结的 Run
|
|
48
|
+
可在可信源资格边界满足 terminates 条件。Stage 为 initial/running/stopping/stopped/completed/failed;
|
|
49
|
+
stage、canceled、按当前 now 推导的时间标签互相独立,取消或终态不冻结后两者。
|
|
50
|
+
Progress 另用 preparation/allocation/execution、可选有限 0–100 percent 与展示字符串。
|
|
51
|
+
|
|
52
|
+
`aggregateTaskStatus(task, now)` 是纯展示聚合函数,`now` 必须显式传入 epoch 毫秒。
|
|
53
|
+
输入仅需 `stage`、`canceled`、`eligibleAt`、`deadlineAt`,兼容 TaskSnapshot / TaskSummary。
|
|
54
|
+
返回 `{ status, qualifiers }`,不含文案、颜色或 i18n;各 UI 自行映射。
|
|
55
|
+
`status` 为 completed / failed / stopped / canceled / timedOut / stopping / running /
|
|
56
|
+
pending(待生效)/ waiting(已生效、等待匹配)。
|
|
57
|
+
优先保留运行结局,再判断取消、超时,之后保留 running / stopping,
|
|
58
|
+
仅 initial 按生效边界区分 pending / waiting;已匹配运行不因时钟回拨显示待生效。
|
|
59
|
+
终结后取消附加 `demandWithdrawn`;取消或超时但运行未终结附加 `runNotEnded`;
|
|
60
|
+
其余 `qualifiers` 为空数组。这些标识不证明资源回收或结果是否按时产生。
|
|
61
|
+
时间输入遵循协议 canonical UTC,截止不得早于生效时间;无效输入抛出 `TaskError`。
|
|
62
|
+
聚合结果不存储,也不用于匹配、取消或回收决策。
|
|
63
|
+
|
|
64
|
+
浏览器使用独立入口,避免加载服务端 schema / crypto:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { aggregateTaskStatus } from "@potential-guide/task-protocol/presentation";
|
|
68
|
+
|
|
69
|
+
const { status, qualifiers } = aggregateTaskStatus(task, now);
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
messageSchema 支持 boolean,false 是 Never,{} / true 不是 Never。
|
|
73
|
+
messages 必选、Task 归属及确认与生命周期控制分离;checkpoint 是独立、按 resultSchema 验证的机器证据。
|
|
74
|
+
公共服务消息操作使用 taskId/messageId、可信 Caller、持久化状态,不改 Input/deadline。
|
|
75
|
+
|
|
76
|
+
Facts projection v5;Task 仅存受理/取消事实,匹配与状态按源前缀推导。
|
|
77
|
+
新 submission 的 `bundleProtocol:"ipfs"` 区分当前受理记录与不支持的旧协议;
|
|
78
|
+
即使新请求因非法引用而被拒绝,仍可跨重启读取其原始意图及持久拒绝结果。
|
|
79
|
+
Task/Run Binding 保留原 inputSchema;实时共享与纯事实重放都使用该 Schema 编译的结构 Equals。
|
|
80
|
+
历史分组的 equivalenceKey 与 Equals 共用投影和序列化,由绑定 Schema 与原 Input 重建,不落盘为匹配权威。
|
|
81
|
+
允许但未声明的额外字段也参与比较,不能忽略其存在或取值差异。
|
|
82
|
+
Request 幂等冲突检查仍比较完整原始 Request,不使用结构 Equals。
|
|
83
|
+
全域源 revision、完整集合封装和 fromRevision 补读不使用每 Task 权威快照或绑定事务。
|
|
84
|
+
旧版本明确拒绝,无隐式数据迁移或删除。
|
|
85
|
+
完整协议与历史/取消/资源边界见 [Task Engine](../../docs/task-engine.md)。
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type TaskBundleFileLimits } from "./bundle-paths.js";
|
|
2
|
+
/** Inspect supplied bytes only; filesystem, transport and runtime eligibility belong to callers. */
|
|
3
|
+
export declare function readTaskBundle(files: ReadonlyMap<string, Uint8Array>, configuration?: Partial<TaskBundleFileLimits>): {
|
|
4
|
+
declaration: import("./bundle.js").TaskBundleDeclaration;
|
|
5
|
+
resolved: import("./bundle.js").ResolvedTaskBundle;
|
|
6
|
+
bytes: number;
|
|
7
|
+
files: number;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=bundle-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-files.d.ts","sourceRoot":"","sources":["../src/bundle-files.ts"],"names":[],"mappings":"AAMA,OAAO,EAAoB,KAAK,oBAAoB,EAAoB,MAAM,mBAAmB,CAAC;AAGlG,oGAAoG;AACpG,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,CAAC,EACtC,aAAa,GAAE,OAAO,CAAC,oBAAoB,CAAM;;;;;EA6FlD"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { resolveBundleSchemas, validateTaskBundleFiles, parseTaskBundleYaml, validateTaskBundle, } from "./bundle.js";
|
|
2
|
+
import { isTaskBundlePath, taskBundleLimits } from "./bundle-paths.js";
|
|
3
|
+
import { fail, TaskError } from "./json.js";
|
|
4
|
+
/** Inspect supplied bytes only; filesystem, transport and runtime eligibility belong to callers. */
|
|
5
|
+
export function readTaskBundle(files, configuration = {}) {
|
|
6
|
+
const limits = {
|
|
7
|
+
bytes: taskBundleLimits.bytes,
|
|
8
|
+
fileBytes: taskBundleLimits.fileBytes,
|
|
9
|
+
files: taskBundleLimits.files,
|
|
10
|
+
paths: taskBundleLimits.paths,
|
|
11
|
+
...configuration,
|
|
12
|
+
};
|
|
13
|
+
if (Object.values(limits).some((value) => !Number.isSafeInteger(value) || value <= 0))
|
|
14
|
+
fail("invalid_config", "Invalid Bundle file capacity.");
|
|
15
|
+
if (files.size > limits.files)
|
|
16
|
+
fail("capacity_exceeded", "Bundle file capacity exceeded.");
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
const spellings = new Map();
|
|
19
|
+
const unsupportedPaths = [];
|
|
20
|
+
let bytes = 0;
|
|
21
|
+
for (const [path, content] of files) {
|
|
22
|
+
if (!isTaskBundlePath(path) || seen.has(path.toLowerCase()))
|
|
23
|
+
fail("invalid_bundle", "Unsafe or duplicate Bundle path.");
|
|
24
|
+
if (!["task.yaml", "worker.cjs"].includes(path) &&
|
|
25
|
+
!path.startsWith("schemas/") &&
|
|
26
|
+
!path.startsWith("resources/"))
|
|
27
|
+
unsupportedPaths.push(path);
|
|
28
|
+
seen.add(path.toLowerCase());
|
|
29
|
+
let prefix = "";
|
|
30
|
+
for (const part of path.split("/")) {
|
|
31
|
+
prefix = prefix ? `${prefix}/${part}` : part;
|
|
32
|
+
const folded = prefix.toLowerCase();
|
|
33
|
+
if (spellings.has(folded) && spellings.get(folded) !== prefix)
|
|
34
|
+
fail("invalid_bundle", "Ambiguous Bundle path casing.");
|
|
35
|
+
spellings.set(folded, prefix);
|
|
36
|
+
}
|
|
37
|
+
bytes += content.byteLength;
|
|
38
|
+
if (content.byteLength > limits.fileBytes ||
|
|
39
|
+
bytes > limits.bytes ||
|
|
40
|
+
spellings.size > limits.paths)
|
|
41
|
+
fail("capacity_exceeded", "Bundle tree capacity exceeded.");
|
|
42
|
+
}
|
|
43
|
+
for (const path of files.keys()) {
|
|
44
|
+
const parts = path.split("/");
|
|
45
|
+
parts.pop();
|
|
46
|
+
while (parts.length) {
|
|
47
|
+
if (files.has(parts.join("/")))
|
|
48
|
+
fail("invalid_bundle", "Bundle file is also a parent.");
|
|
49
|
+
parts.pop();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const yaml = files.get("task.yaml");
|
|
53
|
+
const worker = files.get("worker.cjs");
|
|
54
|
+
if (!yaml || !worker?.byteLength)
|
|
55
|
+
fail("invalid_bundle", "Bundle requires task.yaml and nonempty worker.cjs.");
|
|
56
|
+
const parsed = parseTaskBundleYaml(yaml);
|
|
57
|
+
if (unsupportedPaths.length &&
|
|
58
|
+
parsed !== null &&
|
|
59
|
+
typeof parsed === "object" &&
|
|
60
|
+
!Array.isArray(parsed) &&
|
|
61
|
+
Array.isArray(parsed.include)) {
|
|
62
|
+
const include = parsed.include;
|
|
63
|
+
const undeclared = unsupportedPaths.find((path) => !include.includes(path));
|
|
64
|
+
if (undeclared !== undefined)
|
|
65
|
+
fail("invalid_bundle", `Undeclared Bundle file: ${undeclared}.`);
|
|
66
|
+
fail("invalid_bundle", `Unsupported Bundle path: ${unsupportedPaths[0]}.`);
|
|
67
|
+
}
|
|
68
|
+
const declaration = validateTaskBundle(parsed);
|
|
69
|
+
validateTaskBundleFiles(declaration, files.keys());
|
|
70
|
+
const schemaFiles = [...files].filter(([path]) => path.startsWith("schemas/"));
|
|
71
|
+
let schemas;
|
|
72
|
+
try {
|
|
73
|
+
schemas = schemaFiles.map(([, content]) => {
|
|
74
|
+
const value = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(content));
|
|
75
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
76
|
+
fail("invalid_schema", "Shared Schema requires an absolute $id.");
|
|
77
|
+
return value;
|
|
78
|
+
});
|
|
79
|
+
new TextDecoder("utf-8", { fatal: true }).decode(worker);
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (error instanceof TaskError)
|
|
83
|
+
throw error;
|
|
84
|
+
fail("invalid_bundle", "Invalid Bundle Worker or Schema JSON.");
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
declaration,
|
|
88
|
+
resolved: resolveBundleSchemas(declaration, schemas, schemaFiles.map(([path]) => path)),
|
|
89
|
+
bytes,
|
|
90
|
+
files: files.size,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=bundle-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-files.js","sourceRoot":"","sources":["../src/bundle-files.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,gBAAgB,EAA6B,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAClG,OAAO,EAAE,IAAI,EAA8B,SAAS,EAAE,MAAM,WAAW,CAAC;AAExE,oGAAoG;AACpG,MAAM,UAAU,cAAc,CAC5B,KAAsC,EACtC,gBAA+C,EAAE;IAEjD,MAAM,MAAM,GAAyB;QACnC,KAAK,EAAE,gBAAgB,CAAC,KAAK;QAC7B,SAAS,EAAE,gBAAgB,CAAC,SAAS;QACrC,KAAK,EAAE,gBAAgB,CAAC,KAAK;QAC7B,KAAK,EAAE,gBAAgB,CAAC,KAAK;QAC7B,GAAG,aAAa;KACjB,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACnF,IAAI,CAAC,gBAAgB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AE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,SAAS;YAAE,MAAM,KAAK,CAAC;QAC5C,IAAI,CAAC,gBAAgB,EAAE,uCAAuC,CAAC,CAAC;IAClE,CAAC;IACD,OAAO;QACL,WAAW;QACX,QAAQ,EAAE,oBAAoB,CAC5B,WAAW,EACX,OAAO,EACP,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAClC;QACD,KAAK;QACL,KAAK,EAAE,KAAK,CAAC,IAAI;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface TaskBundleFileLimits {
|
|
2
|
+
bytes: number;
|
|
3
|
+
fileBytes: number;
|
|
4
|
+
files: number;
|
|
5
|
+
paths: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const taskBundleLimits: Readonly<{
|
|
8
|
+
bytes: number;
|
|
9
|
+
fileBytes: number;
|
|
10
|
+
files: 256;
|
|
11
|
+
paths: 512;
|
|
12
|
+
archiveBytes: number;
|
|
13
|
+
}>;
|
|
14
|
+
export declare function isTaskBundlePath(path: string): boolean;
|
|
15
|
+
//# sourceMappingURL=bundle-paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-paths.d.ts","sourceRoot":"","sources":["../src/bundle-paths.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,gBAAgB;;;;;;EAM3B,CAAC;AAEH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAsBtD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const taskBundleLimits = Object.freeze({
|
|
2
|
+
bytes: 64 * 1024 * 1024,
|
|
3
|
+
fileBytes: 64 * 1024 * 1024,
|
|
4
|
+
files: 256,
|
|
5
|
+
paths: 512,
|
|
6
|
+
archiveBytes: 72 * 1024 * 1024,
|
|
7
|
+
});
|
|
8
|
+
export function isTaskBundlePath(path) {
|
|
9
|
+
const encoder = new TextEncoder();
|
|
10
|
+
return (encoder.encode(path).byteLength <= 1024 &&
|
|
11
|
+
path
|
|
12
|
+
.split("/")
|
|
13
|
+
.every((part) => !!part &&
|
|
14
|
+
part !== "." &&
|
|
15
|
+
part !== ".." &&
|
|
16
|
+
part === part.normalize("NFC") &&
|
|
17
|
+
encoder.encode(part).byteLength <= 255 &&
|
|
18
|
+
part.toLowerCase() !== "node_modules" &&
|
|
19
|
+
!/[\\:<>"|?*]/.test(part) &&
|
|
20
|
+
![...part].some((character) => character.charCodeAt(0) < 32 || character.charCodeAt(0) === 127) &&
|
|
21
|
+
!/[. ]$/.test(part) &&
|
|
22
|
+
!/^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])(?:\.|$)/i.test(part)));
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=bundle-paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-paths.js","sourceRoot":"","sources":["../src/bundle-paths.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,KAAK,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IACvB,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;IAC3B,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,GAAG;IACV,YAAY,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;CAC/B,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;IAClC,OAAO,CACL,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,IAAI,IAAI;QACvC,IAAI;aACD,KAAK,CAAC,GAAG,CAAC;aACV,KAAK,CACJ,CAAC,IAAI,EAAE,EAAE,CACP,CAAC,CAAC,IAAI;YACN,IAAI,KAAK,GAAG;YACZ,IAAI,KAAK,IAAI;YACb,IAAI,KAAK,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;YAC9B,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,IAAI,GAAG;YACtC,IAAI,CAAC,WAAW,EAAE,KAAK,cAAc;YACrC,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;YACzB,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CACb,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,GAAG,CAC/E;YACD,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;YACnB,CAAC,iDAAiD,CAAC,IAAI,CAAC,IAAI,CAAC,CAChE,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type BundleReference = string | {
|
|
2
|
+
cid: string;
|
|
3
|
+
hint: string | string[];
|
|
4
|
+
};
|
|
5
|
+
export declare function bundleCid(value: BundleReference): string;
|
|
6
|
+
export declare function validateBundleReference(value: unknown, maxHints?: number): BundleReference;
|
|
7
|
+
export declare function parseBundleReference(value: string): BundleReference;
|
|
8
|
+
export declare function formatBundleReference(value: BundleReference): string;
|
|
9
|
+
//# sourceMappingURL=bundle-reference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-reference.d.ts","sourceRoot":"","sources":["../src/bundle-reference.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAA;CAAE,CAAC;AAEhF,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAIxD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,OAAO,EACd,QAAQ,SAA0B,GACjC,eAAe,CAgEjB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAWnE;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,eAAe,GAAG,MAAM,CAGpE"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { CID } from "multiformats/cid";
|
|
2
|
+
import { fail } from "./json.js";
|
|
3
|
+
export function bundleCid(value) {
|
|
4
|
+
return CID.parse(typeof value === "string" ? value : value.cid)
|
|
5
|
+
.toV1()
|
|
6
|
+
.toString();
|
|
7
|
+
}
|
|
8
|
+
export function validateBundleReference(value, maxHints = Number.MAX_SAFE_INTEGER) {
|
|
9
|
+
const cid = typeof value === "string"
|
|
10
|
+
? value
|
|
11
|
+
: value && typeof value === "object"
|
|
12
|
+
? Object.getOwnPropertyDescriptor(value, "cid")?.value
|
|
13
|
+
: undefined;
|
|
14
|
+
if (typeof cid !== "string" || cid.length > 256)
|
|
15
|
+
fail("invalid_request", "A Bundle root CID is required.");
|
|
16
|
+
try {
|
|
17
|
+
const parsed = CID.parse(cid);
|
|
18
|
+
if (![0x70, 0x55].includes(parsed.code) || parsed.multihash.code !== 0x12)
|
|
19
|
+
fail("invalid_request", "Unsupported Bundle CID codec or hash.");
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return fail("invalid_request", "Invalid Bundle root CID.");
|
|
23
|
+
}
|
|
24
|
+
if (typeof value === "string")
|
|
25
|
+
return value;
|
|
26
|
+
if (!value ||
|
|
27
|
+
typeof value !== "object" ||
|
|
28
|
+
Array.isArray(value) ||
|
|
29
|
+
Object.keys(value).sort().join(",") !== "cid,hint")
|
|
30
|
+
fail("invalid_request", "Bundle references are a CID or {cid,hint}.");
|
|
31
|
+
const ref = { cid, hint: Object.getOwnPropertyDescriptor(value, "hint")?.value };
|
|
32
|
+
const hints = typeof ref.hint === "string" ? [ref.hint] : ref.hint;
|
|
33
|
+
if (!Array.isArray(hints) || !hints.length)
|
|
34
|
+
fail("invalid_request", "Gateway hints must not be empty.");
|
|
35
|
+
if (hints.length > maxHints)
|
|
36
|
+
fail("capacity_exceeded", "Gateway hint capacity exceeded.");
|
|
37
|
+
for (const hint of hints) {
|
|
38
|
+
if (typeof hint !== "string" ||
|
|
39
|
+
!hint ||
|
|
40
|
+
hint.length > 4096 ||
|
|
41
|
+
[...hint].some((character) => character.charCodeAt(0) <= 32 || character.charCodeAt(0) === 127 || character === "\\"))
|
|
42
|
+
fail("invalid_request", "Invalid gateway hint.");
|
|
43
|
+
let uri;
|
|
44
|
+
try {
|
|
45
|
+
uri = new URL(hint);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return fail("invalid_request", "Invalid gateway base URI.");
|
|
49
|
+
}
|
|
50
|
+
if (!["https:", "http:"].includes(uri.protocol) ||
|
|
51
|
+
!/^https?:\/\/[^/]+/i.test(hint) ||
|
|
52
|
+
hint
|
|
53
|
+
.slice(hint.indexOf("://") + 3)
|
|
54
|
+
.split("/", 1)[0]
|
|
55
|
+
?.includes("@") ||
|
|
56
|
+
uri.username ||
|
|
57
|
+
uri.password ||
|
|
58
|
+
hint.includes("?") ||
|
|
59
|
+
hint.includes("#"))
|
|
60
|
+
fail("invalid_request", "Gateway requires an HTTP(S) base URI without credentials/query/fragment.");
|
|
61
|
+
}
|
|
62
|
+
return { cid: ref.cid, hint: typeof ref.hint === "string" ? ref.hint : [...hints] };
|
|
63
|
+
}
|
|
64
|
+
export function parseBundleReference(value) {
|
|
65
|
+
if (typeof value !== "string")
|
|
66
|
+
fail("invalid_request", "A Bundle CID reference is required.");
|
|
67
|
+
let parsed = value;
|
|
68
|
+
if (value.trim().startsWith("{")) {
|
|
69
|
+
try {
|
|
70
|
+
parsed = JSON.parse(value);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return fail("invalid_request", "Invalid Bundle reference JSON.");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return validateBundleReference(parsed);
|
|
77
|
+
}
|
|
78
|
+
export function formatBundleReference(value) {
|
|
79
|
+
const ref = validateBundleReference(value);
|
|
80
|
+
return typeof ref === "string" ? ref : JSON.stringify(ref);
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=bundle-reference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle-reference.js","sourceRoot":"","sources":["../src/bundle-reference.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,MAAM,UAAU,SAAS,CAAC,KAAsB;IAC9C,OAAO,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC;SAC5D,IAAI,EAAE;SACN,QAAQ,EAAE,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,KAAc,EACd,QAAQ,GAAG,MAAM,CAAC,gBAAgB;IAElC,MAAM,GAAG,GACP,OAAO,KAAK,KAAK,QAAQ;QACvB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAClC,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,KAAK,CAAC,EAAE,KAAK;YACtD,CAAC,CAAC,SAAS,CAAC;IAClB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG;QAC7C,IAAI,CAAC,iBAAiB,EAAE,gCAAgC,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C,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC;AACtF,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,IAAI,CAAC,iBAAiB,EAAE,qCAAqC,CAAC,CAAC;IAC9F,IAAI,MAAM,GAAY,KAAK,CAAC;IAC5B,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC7B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,iBAAiB,EAAE,gCAAgC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IACD,OAAO,uBAAuB,CAAC,MAAM,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAsB;IAC1D,MAAM,GAAG,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAC7D,CAAC"}
|
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type Json, type JsonObject } from "./json.js";
|
|
2
|
+
import { type InputSchema, type JsonSchema } from "./schema.js";
|
|
3
|
+
import { taskSchemaUri } from "./task-schema-uri.js";
|
|
4
|
+
export { taskSchemaUri } from "./task-schema-uri.js";
|
|
5
|
+
export declare const taskBundleSchema: {
|
|
6
|
+
$id: string;
|
|
7
|
+
$comment: string;
|
|
8
|
+
type: string;
|
|
9
|
+
additionalProperties: boolean;
|
|
10
|
+
required: string[];
|
|
11
|
+
properties: {
|
|
12
|
+
$schema: {
|
|
13
|
+
const: string;
|
|
14
|
+
};
|
|
15
|
+
name: {
|
|
16
|
+
type: string;
|
|
17
|
+
minLength: number;
|
|
18
|
+
pattern: string;
|
|
19
|
+
};
|
|
20
|
+
runtime: {
|
|
21
|
+
type: string;
|
|
22
|
+
additionalProperties: boolean;
|
|
23
|
+
required: string[];
|
|
24
|
+
properties: {
|
|
25
|
+
type: {
|
|
26
|
+
const: string;
|
|
27
|
+
};
|
|
28
|
+
minVersion: {
|
|
29
|
+
type: string;
|
|
30
|
+
pattern: string;
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
entry: {
|
|
35
|
+
const: string;
|
|
36
|
+
};
|
|
37
|
+
include: {
|
|
38
|
+
type: string;
|
|
39
|
+
minItems: number;
|
|
40
|
+
maxItems: 256;
|
|
41
|
+
uniqueItems: boolean;
|
|
42
|
+
items: {
|
|
43
|
+
type: string;
|
|
44
|
+
pattern: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: string;
|
|
49
|
+
};
|
|
50
|
+
resultSchema: {
|
|
51
|
+
type: string[];
|
|
52
|
+
};
|
|
53
|
+
messageSchema: {
|
|
54
|
+
type: string[];
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
export * from "./bundle-reference.js";
|
|
59
|
+
export interface TaskBundleDeclaration {
|
|
60
|
+
$schema: typeof taskSchemaUri;
|
|
61
|
+
name: string;
|
|
62
|
+
runtime: {
|
|
63
|
+
type: "node";
|
|
64
|
+
minVersion: string;
|
|
65
|
+
};
|
|
66
|
+
entry: "worker.cjs";
|
|
67
|
+
include: string[];
|
|
68
|
+
inputSchema: JsonObject;
|
|
69
|
+
resultSchema: JsonSchema;
|
|
70
|
+
messageSchema: JsonSchema;
|
|
71
|
+
}
|
|
72
|
+
export interface ResolvedTaskBundle extends Omit<TaskBundleDeclaration, "inputSchema"> {
|
|
73
|
+
inputSchema: InputSchema;
|
|
74
|
+
}
|
|
75
|
+
export declare function parseTaskBundleYaml(bytes: Uint8Array): Json;
|
|
76
|
+
export declare function validateTaskBundle(value: unknown): TaskBundleDeclaration;
|
|
77
|
+
export declare function validateTaskBundleFiles(declaration: TaskBundleDeclaration, paths: Iterable<string>): void;
|
|
78
|
+
/** Resolve only supplied resources. No network loader or ambient Schema registry exists. */
|
|
79
|
+
export declare function resolveBundleSchemas(declaration: TaskBundleDeclaration, resources: readonly JsonObject[], resourcePaths?: readonly string[]): ResolvedTaskBundle;
|
|
80
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bundle.d.ts","sourceRoot":"","sources":["../src/bundle.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,IAAI,EAAE,KAAK,UAAU,EAAmB,MAAM,WAAW,CAAC;AACzF,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoD5B,CAAC;AACF,cAAc,uBAAuB,CAAC;AACtC,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,aAAa,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,KAAK,EAAE,YAAY,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,UAAU,CAAC;IACxB,YAAY,EAAE,UAAU,CAAC;IACzB,aAAa,EAAE,UAAU,CAAC;CAC3B;AACD,MAAM,WAAW,kBAAmB,SAAQ,IAAI,CAAC,qBAAqB,EAAE,aAAa,CAAC;IACpF,W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