@dot-agent/compiler 0.10.0 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +13 -248
- package/dist/core.d.cts +2 -3
- package/dist/core.d.mts +2 -0
- package/dist/core.mjs +2 -0
- package/dist/index.cjs +1008 -1305
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -27
- package/dist/index.d.cts.map +1 -0
- package/dist/{index.d.ts → index.d.mts} +29 -27
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1057 -0
- package/dist/index.mjs.map +1 -0
- package/dist/zip-core-BCiH0sUt.d.cts +123 -0
- package/dist/zip-core-BCiH0sUt.d.cts.map +1 -0
- package/dist/zip-core-BCiH0sUt.d.mts +123 -0
- package/dist/zip-core-BCiH0sUt.d.mts.map +1 -0
- package/dist/zip-core-BjnIQMRA.cjs +292 -0
- package/dist/zip-core-BjnIQMRA.cjs.map +1 -0
- package/dist/zip-core-Dw_OgIjV.mjs +180 -0
- package/dist/zip-core-Dw_OgIjV.mjs.map +1 -0
- package/package.json +27 -19
- package/dist/chunk-AYXHOOUX.js +0 -213
- package/dist/chunk-AYXHOOUX.js.map +0 -1
- package/dist/core-D2X2Eohl.d.cts +0 -120
- package/dist/core-D2X2Eohl.d.ts +0 -120
- package/dist/core.cjs.map +0 -1
- package/dist/core.d.ts +0 -3
- package/dist/core.js +0 -27
- package/dist/core.js.map +0 -1
- package/dist/index.js +0 -1134
- package/dist/index.js.map +0 -1
package/dist/core.cjs
CHANGED
|
@@ -1,248 +1,13 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
|
|
30
|
-
// src/core.ts
|
|
31
|
-
var core_exports = {};
|
|
32
|
-
__export(core_exports, {
|
|
33
|
-
aboutmeToJson: () => aboutmeToJson,
|
|
34
|
-
buildAboutme: () => buildAboutme,
|
|
35
|
-
buildId: () => buildId,
|
|
36
|
-
createZip: () => createZip,
|
|
37
|
-
extractDigest: () => extractDigest,
|
|
38
|
-
extractFiles: () => extractFiles,
|
|
39
|
-
extractName: () => extractName,
|
|
40
|
-
parseAboutme: () => parseAboutme,
|
|
41
|
-
parseId: () => parseId,
|
|
42
|
-
validateMagicBytes: () => validateMagicBytes,
|
|
43
|
-
validateZipBomb: () => validateZipBomb
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(core_exports);
|
|
46
|
-
|
|
47
|
-
// src/generated-version.ts
|
|
48
|
-
var DSL_VERSION = "0.1";
|
|
49
|
-
|
|
50
|
-
// src/manifest.ts
|
|
51
|
-
function parseAboutme(json) {
|
|
52
|
-
if (!json.dslVersion) throw new Error("Missing dslVersion in aboutme.json");
|
|
53
|
-
if (!json.id) throw new Error("Missing id in aboutme.json");
|
|
54
|
-
if (!json.name) throw new Error("Missing name in aboutme.json");
|
|
55
|
-
if (!json.description) throw new Error("Missing description in aboutme.json");
|
|
56
|
-
if (!json.domain) throw new Error("Missing domain in aboutme.json");
|
|
57
|
-
if (!json.compiler) throw new Error("Missing compiler in aboutme.json");
|
|
58
|
-
if (!Array.isArray(json.capabilities)) throw new Error("Missing capabilities array in aboutme.json");
|
|
59
|
-
if (!Array.isArray(json.requires)) throw new Error("Missing requires array in aboutme.json");
|
|
60
|
-
if (!json.integrity) throw new Error("Missing integrity in aboutme.json");
|
|
61
|
-
return {
|
|
62
|
-
dslVersion: json.dslVersion,
|
|
63
|
-
id: json.id,
|
|
64
|
-
name: json.name,
|
|
65
|
-
description: json.description,
|
|
66
|
-
version: json.version ?? "",
|
|
67
|
-
domain: json.domain,
|
|
68
|
-
license: json.license ?? "",
|
|
69
|
-
persona: json.persona,
|
|
70
|
-
purpose: json.purpose ?? "unknown",
|
|
71
|
-
compiler: json.compiler,
|
|
72
|
-
commit: json.commit,
|
|
73
|
-
capabilities: json.capabilities,
|
|
74
|
-
requires: json.requires,
|
|
75
|
-
integrity: json.integrity
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function buildAboutme(opts) {
|
|
79
|
-
return {
|
|
80
|
-
dslVersion: `dot-agent/${DSL_VERSION}`,
|
|
81
|
-
id: opts.id,
|
|
82
|
-
name: opts.name,
|
|
83
|
-
description: opts.description,
|
|
84
|
-
version: opts.version,
|
|
85
|
-
domain: opts.domain,
|
|
86
|
-
license: opts.license ?? "",
|
|
87
|
-
persona: opts.persona,
|
|
88
|
-
purpose: opts.purpose ?? "unknown",
|
|
89
|
-
compiler: opts.compiler,
|
|
90
|
-
commit: opts.commit,
|
|
91
|
-
capabilities: opts.capabilities ?? [],
|
|
92
|
-
requires: opts.requires ?? [],
|
|
93
|
-
integrity: opts.integrity
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
function aboutmeToJson(aboutme) {
|
|
97
|
-
return JSON.stringify(aboutme, null, 2);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// src/id.ts
|
|
101
|
-
var KNOWN_PLATFORMS = ["github.com", "gitlab.com", "codeberg.org", "sr.ht"];
|
|
102
|
-
function parseNamespaceName(identifier) {
|
|
103
|
-
const atIdx = identifier.indexOf("@");
|
|
104
|
-
if (atIdx !== -1 && (identifier.indexOf("/") === -1 || atIdx < identifier.indexOf("/"))) {
|
|
105
|
-
const slashIdx = identifier.indexOf("/");
|
|
106
|
-
if (slashIdx === -1) {
|
|
107
|
-
throw new Error(`Invalid agent ID: email namespace requires a name after '/' (got '${identifier}')`);
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
namespace: identifier.slice(0, slashIdx),
|
|
111
|
-
name: identifier.slice(slashIdx + 1)
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
for (const platform of KNOWN_PLATFORMS) {
|
|
115
|
-
if (identifier.startsWith(platform + "/")) {
|
|
116
|
-
const afterPlatform = identifier.slice(platform.length + 1);
|
|
117
|
-
const slashIdx = afterPlatform.indexOf("/");
|
|
118
|
-
if (slashIdx === -1) {
|
|
119
|
-
throw new Error(
|
|
120
|
-
`Invalid agent ID: '${platform}' namespace requires a user segment and a name (got '${identifier}')`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
namespace: platform + "/" + afterPlatform.slice(0, slashIdx),
|
|
125
|
-
name: afterPlatform.slice(slashIdx + 1)
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
const lastSlash = identifier.lastIndexOf("/");
|
|
130
|
-
if (lastSlash === -1) {
|
|
131
|
-
throw new Error(`Invalid agent ID: missing '/' separator in '${identifier}'`);
|
|
132
|
-
}
|
|
133
|
-
return {
|
|
134
|
-
namespace: identifier.slice(0, lastSlash),
|
|
135
|
-
name: identifier.slice(lastSlash + 1)
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function parseId(id) {
|
|
139
|
-
if (!id) throw new Error("Invalid agent ID: empty string");
|
|
140
|
-
const colonIdx = id.indexOf(":");
|
|
141
|
-
let identifier;
|
|
142
|
-
let version;
|
|
143
|
-
let digest;
|
|
144
|
-
if (colonIdx === -1) {
|
|
145
|
-
identifier = id;
|
|
146
|
-
} else {
|
|
147
|
-
identifier = id.slice(0, colonIdx);
|
|
148
|
-
const rest = id.slice(colonIdx + 1);
|
|
149
|
-
if (!rest) throw new Error(`Invalid agent ID: empty version after ':' in '${id}'`);
|
|
150
|
-
const tildeIdx = rest.indexOf("~");
|
|
151
|
-
if (tildeIdx === -1) {
|
|
152
|
-
version = rest;
|
|
153
|
-
} else {
|
|
154
|
-
version = rest.slice(0, tildeIdx);
|
|
155
|
-
digest = rest.slice(tildeIdx + 1);
|
|
156
|
-
if (!version) throw new Error(`Invalid agent ID: empty version before '~' in '${id}'`);
|
|
157
|
-
if (!digest) throw new Error(`Invalid agent ID: empty digest after '~' in '${id}'`);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
const { namespace, name } = parseNamespaceName(identifier);
|
|
161
|
-
if (!namespace) throw new Error(`Invalid agent ID: empty namespace in '${id}'`);
|
|
162
|
-
if (!name) throw new Error(`Invalid agent ID: empty name in '${id}'`);
|
|
163
|
-
return { namespace, name, version, digest };
|
|
164
|
-
}
|
|
165
|
-
function buildId(parts) {
|
|
166
|
-
const { namespace, name, version, digest } = parts;
|
|
167
|
-
if (!namespace || !name) {
|
|
168
|
-
throw new Error("Missing required ID parts: namespace and name");
|
|
169
|
-
}
|
|
170
|
-
if (digest && !version) {
|
|
171
|
-
throw new Error("Invalid ID parts: digest requires version");
|
|
172
|
-
}
|
|
173
|
-
let result = `${namespace}/${name}`;
|
|
174
|
-
if (version) {
|
|
175
|
-
result += `:${version}`;
|
|
176
|
-
if (digest) result += `~${digest}`;
|
|
177
|
-
}
|
|
178
|
-
return result.toLowerCase();
|
|
179
|
-
}
|
|
180
|
-
function extractDigest(id) {
|
|
181
|
-
try {
|
|
182
|
-
return parseId(id).digest ?? "";
|
|
183
|
-
} catch {
|
|
184
|
-
return "";
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
function extractName(id) {
|
|
188
|
-
try {
|
|
189
|
-
return parseId(id).name;
|
|
190
|
-
} catch {
|
|
191
|
-
return "";
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// src/zip-core.ts
|
|
196
|
-
var import_jszip = __toESM(require("jszip"), 1);
|
|
197
|
-
var MAX_ZIP_SIZE = 500 * 1024 * 1024;
|
|
198
|
-
var MAX_COMPRESSION_RATIO = 100;
|
|
199
|
-
function validateMagicBytes(bytes) {
|
|
200
|
-
if (!(bytes[0] === 80 && bytes[1] === 75 && bytes[2] === 3 && bytes[3] === 4)) {
|
|
201
|
-
throw new Error("Not a valid .agent file (invalid magic bytes)");
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function validateZipBomb(zip, compressedSize) {
|
|
205
|
-
let totalUncompressed = 0;
|
|
206
|
-
zip.forEach((_path, file) => {
|
|
207
|
-
if (!file.dir) totalUncompressed += file._data?.uncompressedSize || 0;
|
|
208
|
-
});
|
|
209
|
-
if (totalUncompressed > MAX_ZIP_SIZE) {
|
|
210
|
-
throw new Error(`Bundle exceeds 500MB uncompressed: ${totalUncompressed}`);
|
|
211
|
-
}
|
|
212
|
-
if (totalUncompressed / compressedSize > MAX_COMPRESSION_RATIO) {
|
|
213
|
-
throw new Error(`Compression ratio exceeds 100x: ${(totalUncompressed / compressedSize).toFixed(1)}x`);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
function createZip() {
|
|
217
|
-
return new import_jszip.default();
|
|
218
|
-
}
|
|
219
|
-
async function extractFiles(zip, filter) {
|
|
220
|
-
const files = /* @__PURE__ */ new Map();
|
|
221
|
-
const promises = [];
|
|
222
|
-
zip.forEach((relativePath, file) => {
|
|
223
|
-
if (file.dir) return;
|
|
224
|
-
if (filter && !filter.some((f) => relativePath.startsWith(f))) return;
|
|
225
|
-
promises.push(
|
|
226
|
-
file.async("text").then((content) => {
|
|
227
|
-
files.set(relativePath, content);
|
|
228
|
-
})
|
|
229
|
-
);
|
|
230
|
-
});
|
|
231
|
-
await Promise.all(promises);
|
|
232
|
-
return files;
|
|
233
|
-
}
|
|
234
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
235
|
-
0 && (module.exports = {
|
|
236
|
-
aboutmeToJson,
|
|
237
|
-
buildAboutme,
|
|
238
|
-
buildId,
|
|
239
|
-
createZip,
|
|
240
|
-
extractDigest,
|
|
241
|
-
extractFiles,
|
|
242
|
-
extractName,
|
|
243
|
-
parseAboutme,
|
|
244
|
-
parseId,
|
|
245
|
-
validateMagicBytes,
|
|
246
|
-
validateZipBomb
|
|
247
|
-
});
|
|
248
|
-
//# sourceMappingURL=core.cjs.map
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_zip_core = require("./zip-core-BjnIQMRA.cjs");
|
|
3
|
+
exports.aboutmeToJson = require_zip_core.aboutmeToJson;
|
|
4
|
+
exports.buildAboutme = require_zip_core.buildAboutme;
|
|
5
|
+
exports.buildId = require_zip_core.buildId;
|
|
6
|
+
exports.createZip = require_zip_core.createZip;
|
|
7
|
+
exports.extractDigest = require_zip_core.extractDigest;
|
|
8
|
+
exports.extractFiles = require_zip_core.extractFiles;
|
|
9
|
+
exports.extractName = require_zip_core.extractName;
|
|
10
|
+
exports.parseAboutme = require_zip_core.parseAboutme;
|
|
11
|
+
exports.parseId = require_zip_core.parseId;
|
|
12
|
+
exports.validateMagicBytes = require_zip_core.validateMagicBytes;
|
|
13
|
+
exports.validateZipBomb = require_zip_core.validateZipBomb;
|
package/dist/core.d.cts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export { AnnotatedRef, DescriptionFile
|
|
3
|
-
import 'jszip';
|
|
1
|
+
import { S as Integrity, a as buildId, b as DescriptionFile, c as parseId, d as parseAboutme, f as AboutMe, g as AnnotatedRef, h as AgentFiles, i as validateZipBomb, l as aboutmeToJson, n as extractFiles, o as extractDigest, p as AgentBundle, r as validateMagicBytes, s as extractName, t as createZip, u as buildAboutme, v as BuildAboutmeOptions, w as LintMessage, x as IdParts, y as Capability } from "./zip-core-BCiH0sUt.cjs";
|
|
2
|
+
export { type AboutMe, type AgentBundle, type AgentFiles, type AnnotatedRef, type BuildAboutmeOptions, type Capability, type DescriptionFile, type IdParts, type Integrity, type LintMessage, aboutmeToJson, buildAboutme, buildId, createZip, extractDigest, extractFiles, extractName, parseAboutme, parseId, validateMagicBytes, validateZipBomb };
|
package/dist/core.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { S as Integrity, a as buildId, b as DescriptionFile, c as parseId, d as parseAboutme, f as AboutMe, g as AnnotatedRef, h as AgentFiles, i as validateZipBomb, l as aboutmeToJson, n as extractFiles, o as extractDigest, p as AgentBundle, r as validateMagicBytes, s as extractName, t as createZip, u as buildAboutme, v as BuildAboutmeOptions, w as LintMessage, x as IdParts, y as Capability } from "./zip-core-BCiH0sUt.mjs";
|
|
2
|
+
export { type AboutMe, type AgentBundle, type AgentFiles, type AnnotatedRef, type BuildAboutmeOptions, type Capability, type DescriptionFile, type IdParts, type Integrity, type LintMessage, aboutmeToJson, buildAboutme, buildId, createZip, extractDigest, extractFiles, extractName, parseAboutme, parseId, validateMagicBytes, validateZipBomb };
|
package/dist/core.mjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { a as buildId, d as aboutmeToJson, f as buildAboutme, i as validateZipBomb, l as parseId, n as extractFiles, o as extractDigest, p as parseAboutme, r as validateMagicBytes, s as extractName, t as createZip } from "./zip-core-Dw_OgIjV.mjs";
|
|
2
|
+
export { aboutmeToJson, buildAboutme, buildId, createZip, extractDigest, extractFiles, extractName, parseAboutme, parseId, validateMagicBytes, validateZipBomb };
|