@agentxm/extension-content 0.28.14-preview.1789139351.5cd4595aa

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.
Files changed (133) hide show
  1. package/LICENSE +110 -0
  2. package/README.md +17 -0
  3. package/dist/src/content/agent-skills-standard.d.ts +17 -0
  4. package/dist/src/content/agent-skills-standard.js +24 -0
  5. package/dist/src/content/frontmatter.d.ts +52 -0
  6. package/dist/src/content/frontmatter.js +115 -0
  7. package/dist/src/content/index.d.ts +11 -0
  8. package/dist/src/content/index.js +11 -0
  9. package/dist/src/content/skill-content.d.ts +43 -0
  10. package/dist/src/content/skill-content.js +184 -0
  11. package/dist/src/content/skill-types.d.ts +22 -0
  12. package/dist/src/content/skill-types.js +9 -0
  13. package/dist/src/content/subagent-content.d.ts +58 -0
  14. package/dist/src/content/subagent-content.js +101 -0
  15. package/dist/src/index.d.ts +23 -0
  16. package/dist/src/index.js +23 -0
  17. package/dist/src/knowledge/index.d.ts +9 -0
  18. package/dist/src/knowledge/index.js +9 -0
  19. package/dist/src/knowledge/knowledge-search.d.ts +32 -0
  20. package/dist/src/knowledge/knowledge-search.js +147 -0
  21. package/dist/src/knowledge/okf.d.ts +86 -0
  22. package/dist/src/knowledge/okf.js +1090 -0
  23. package/dist/src/knowledge/package-inspection.d.ts +125 -0
  24. package/dist/src/knowledge/package-inspection.js +45 -0
  25. package/dist/src/lint/catalog/hook/decision-portability.d.ts +4 -0
  26. package/dist/src/lint/catalog/hook/decision-portability.js +40 -0
  27. package/dist/src/lint/catalog/hook/entrypoint-exists.d.ts +4 -0
  28. package/dist/src/lint/catalog/hook/entrypoint-exists.js +39 -0
  29. package/dist/src/lint/catalog/hook/envelope.d.ts +6 -0
  30. package/dist/src/lint/catalog/hook/envelope.js +15 -0
  31. package/dist/src/lint/catalog/hook/matcher-raw-portability.d.ts +4 -0
  32. package/dist/src/lint/catalog/hook/matcher-raw-portability.js +51 -0
  33. package/dist/src/lint/catalog/hook.d.ts +4 -0
  34. package/dist/src/lint/catalog/hook.js +15 -0
  35. package/dist/src/lint/catalog/knowledge/diagnostics.d.ts +128 -0
  36. package/dist/src/lint/catalog/knowledge/diagnostics.js +78 -0
  37. package/dist/src/lint/catalog/knowledge/envelope.d.ts +6 -0
  38. package/dist/src/lint/catalog/knowledge/envelope.js +15 -0
  39. package/dist/src/lint/catalog/knowledge.d.ts +11 -0
  40. package/dist/src/lint/catalog/knowledge.js +15 -0
  41. package/dist/src/lint/catalog/mcp-server/envelope.d.ts +6 -0
  42. package/dist/src/lint/catalog/mcp-server/envelope.js +15 -0
  43. package/dist/src/lint/catalog/mcp-server.d.ts +4 -0
  44. package/dist/src/lint/catalog/mcp-server.js +4 -0
  45. package/dist/src/lint/catalog/pack/manifest-keys-recognized.d.ts +28 -0
  46. package/dist/src/lint/catalog/pack/manifest-keys-recognized.js +38 -0
  47. package/dist/src/lint/catalog/pack/manifest-present.d.ts +17 -0
  48. package/dist/src/lint/catalog/pack/manifest-present.js +24 -0
  49. package/dist/src/lint/catalog/pack/manifest-schema-valid.d.ts +25 -0
  50. package/dist/src/lint/catalog/pack/manifest-schema-valid.js +33 -0
  51. package/dist/src/lint/catalog/pack-accessor/contexts.d.ts +51 -0
  52. package/dist/src/lint/catalog/pack-accessor/contexts.js +45 -0
  53. package/dist/src/lint/catalog/pack-accessor/platform.d.ts +56 -0
  54. package/dist/src/lint/catalog/pack-accessor/platform.js +93 -0
  55. package/dist/src/lint/catalog/pack-accessor/vft.d.ts +60 -0
  56. package/dist/src/lint/catalog/pack-accessor/vft.js +85 -0
  57. package/dist/src/lint/catalog/pack.d.ts +31 -0
  58. package/dist/src/lint/catalog/pack.js +36 -0
  59. package/dist/src/lint/catalog/rule/envelope.d.ts +6 -0
  60. package/dist/src/lint/catalog/rule/envelope.js +15 -0
  61. package/dist/src/lint/catalog/rule.d.ts +4 -0
  62. package/dist/src/lint/catalog/rule.js +4 -0
  63. package/dist/src/lint/catalog/shared/envelope-rules.d.ts +88 -0
  64. package/dist/src/lint/catalog/shared/envelope-rules.js +84 -0
  65. package/dist/src/lint/catalog/shared/manifest-json.d.ts +18 -0
  66. package/dist/src/lint/catalog/shared/manifest-json.js +28 -0
  67. package/dist/src/lint/catalog/shared/manifest-present.d.ts +25 -0
  68. package/dist/src/lint/catalog/shared/manifest-present.js +37 -0
  69. package/dist/src/lint/catalog/shared/recommended-packs-rules.d.ts +70 -0
  70. package/dist/src/lint/catalog/shared/recommended-packs-rules.js +139 -0
  71. package/dist/src/lint/catalog/shared/schema-rule.d.ts +57 -0
  72. package/dist/src/lint/catalog/shared/schema-rule.js +102 -0
  73. package/dist/src/lint/catalog/skill/frontmatter-parseable.d.ts +31 -0
  74. package/dist/src/lint/catalog/skill/frontmatter-parseable.js +148 -0
  75. package/dist/src/lint/catalog/skill/frontmatter-standard-valid.d.ts +13 -0
  76. package/dist/src/lint/catalog/skill/frontmatter-standard-valid.js +61 -0
  77. package/dist/src/lint/catalog/skill/manifest-keys-recognized.d.ts +26 -0
  78. package/dist/src/lint/catalog/skill/manifest-keys-recognized.js +41 -0
  79. package/dist/src/lint/catalog/skill/manifest-present.d.ts +23 -0
  80. package/dist/src/lint/catalog/skill/manifest-present.js +32 -0
  81. package/dist/src/lint/catalog/skill/manifest-schema-valid.d.ts +21 -0
  82. package/dist/src/lint/catalog/skill/manifest-schema-valid.js +36 -0
  83. package/dist/src/lint/catalog/skill/recommended-packs-valid.d.ts +8 -0
  84. package/dist/src/lint/catalog/skill/recommended-packs-valid.js +12 -0
  85. package/dist/src/lint/catalog/skill/skill-md-present.d.ts +17 -0
  86. package/dist/src/lint/catalog/skill/skill-md-present.js +37 -0
  87. package/dist/src/lint/catalog/skill/standalone-declaration-valid.d.ts +8 -0
  88. package/dist/src/lint/catalog/skill/standalone-declaration-valid.js +12 -0
  89. package/dist/src/lint/catalog/skill-accessor/contexts.d.ts +61 -0
  90. package/dist/src/lint/catalog/skill-accessor/contexts.js +55 -0
  91. package/dist/src/lint/catalog/skill-accessor/platform.d.ts +53 -0
  92. package/dist/src/lint/catalog/skill-accessor/platform.js +90 -0
  93. package/dist/src/lint/catalog/skill-accessor/vft.d.ts +77 -0
  94. package/dist/src/lint/catalog/skill-accessor/vft.js +135 -0
  95. package/dist/src/lint/catalog/skill.d.ts +38 -0
  96. package/dist/src/lint/catalog/skill.js +53 -0
  97. package/dist/src/lint/catalog/subagent/envelope.d.ts +6 -0
  98. package/dist/src/lint/catalog/subagent/envelope.js +15 -0
  99. package/dist/src/lint/catalog/subagent.d.ts +4 -0
  100. package/dist/src/lint/catalog/subagent.js +4 -0
  101. package/dist/src/lint/catalog-metadata.d.ts +125 -0
  102. package/dist/src/lint/catalog-metadata.js +642 -0
  103. package/dist/src/lint/compose-path.d.ts +28 -0
  104. package/dist/src/lint/compose-path.js +64 -0
  105. package/dist/src/lint/config.d.ts +77 -0
  106. package/dist/src/lint/config.js +99 -0
  107. package/dist/src/lint/context.d.ts +239 -0
  108. package/dist/src/lint/context.js +17 -0
  109. package/dist/src/lint/describe-document.d.ts +31 -0
  110. package/dist/src/lint/describe-document.js +50 -0
  111. package/dist/src/lint/evaluate.d.ts +47 -0
  112. package/dist/src/lint/evaluate.js +73 -0
  113. package/dist/src/lint/index.d.ts +36 -0
  114. package/dist/src/lint/index.js +34 -0
  115. package/dist/src/lint/issues-to-findings.d.ts +35 -0
  116. package/dist/src/lint/issues-to-findings.js +149 -0
  117. package/dist/src/lint/rule.d.ts +97 -0
  118. package/dist/src/lint/rule.js +17 -0
  119. package/dist/src/packaging/archive-guardrails.d.ts +39 -0
  120. package/dist/src/packaging/archive-guardrails.js +250 -0
  121. package/dist/src/packaging/filtered-package-validation.d.ts +24 -0
  122. package/dist/src/packaging/filtered-package-validation.js +117 -0
  123. package/dist/src/packaging/ingest-limits.d.ts +25 -0
  124. package/dist/src/packaging/ingest-limits.js +41 -0
  125. package/dist/src/packaging/input-normalization.d.ts +40 -0
  126. package/dist/src/packaging/input-normalization.js +125 -0
  127. package/dist/src/packaging/manifest-policy.d.ts +611 -0
  128. package/dist/src/packaging/manifest-policy.js +196 -0
  129. package/dist/src/packaging/test-zip-helpers.d.ts +13 -0
  130. package/dist/src/packaging/test-zip-helpers.js +117 -0
  131. package/dist/src/testing.d.ts +9 -0
  132. package/dist/src/testing.js +9 -0
  133. package/package.json +65 -0
@@ -0,0 +1,196 @@
1
+ import * as Data from "effect/Data";
2
+ import * as Effect from "effect/Effect";
3
+ import * as Result from "effect/Result";
4
+ import * as Schema from "effect/Schema";
5
+ import * as SchemaIssue from "effect/SchemaIssue";
6
+ import { ExtensionNameSchema, ExtensionTypeSchema, } from "@agentxm/extension-model/unstable/extensions/common";
7
+ import { HookManifestSchema, HOOK_MANIFEST_FILENAME, } from "@agentxm/extension-model/unstable/hooks/manifest-schema";
8
+ import { HandleSchema } from "@agentxm/extension-model/unstable/extensions/handle";
9
+ import { KnowledgeManifestSchema, KNOWLEDGE_MANIFEST_FILENAME, } from "@agentxm/extension-model/unstable/knowledge/manifest-schema";
10
+ import { McpServerManifestSchema, MCP_SERVER_MANIFEST_FILENAME, } from "@agentxm/extension-model/unstable/mcps/manifest-schema";
11
+ import { PACK_MANIFEST_FILENAME, PackManifestSchema, } from "@agentxm/extension-model/unstable/packs/manifest-schema";
12
+ import { RuleManifestSchema, RULE_MANIFEST_FILENAME, } from "@agentxm/extension-model/unstable/rules/manifest-schema";
13
+ import { SkillManifestSchema, MANIFEST_FILENAME as SKILL_MANIFEST_FILENAME, } from "@agentxm/extension-model/unstable/skills/manifest-schema";
14
+ import { SubagentManifestSchema, MANIFEST_FILENAME as SUBAGENT_MANIFEST_FILENAME, } from "@agentxm/extension-model/unstable/subagents/manifest-schema";
15
+ import { VersionSchema } from "@agentxm/extension-model/unstable/version-constraints";
16
+ export class ManifestError extends Data.TaggedError("ManifestError") {
17
+ }
18
+ export const MANIFEST_FILENAME_BY_TYPE = {
19
+ skill: SKILL_MANIFEST_FILENAME,
20
+ "mcp-server": MCP_SERVER_MANIFEST_FILENAME,
21
+ subagent: SUBAGENT_MANIFEST_FILENAME,
22
+ pack: PACK_MANIFEST_FILENAME,
23
+ rule: RULE_MANIFEST_FILENAME,
24
+ hook: HOOK_MANIFEST_FILENAME,
25
+ knowledge: KNOWLEDGE_MANIFEST_FILENAME,
26
+ };
27
+ export const manifestFilenameForType = (type) => MANIFEST_FILENAME_BY_TYPE[type];
28
+ export const ManifestIdentitySchema = Schema.Struct({
29
+ owner: HandleSchema.pipe(Schema.annotateKey({ messageMissingKey: "owner is required" })),
30
+ type: ExtensionTypeSchema.pipe(Schema.annotateKey({ messageMissingKey: "type is required" })),
31
+ name: ExtensionNameSchema.pipe(Schema.annotateKey({ messageMissingKey: "name is required" })),
32
+ version: VersionSchema.pipe(Schema.annotateKey({ messageMissingKey: "version is required" })),
33
+ }).annotate({
34
+ identifier: "ManifestIdentity",
35
+ title: "Manifest Identity",
36
+ description: "The key identity fields from a manifest: who owns it, what type, its name, and version.",
37
+ });
38
+ const MANIFEST_SCHEMA_BY_TYPE = {
39
+ skill: SkillManifestSchema,
40
+ "mcp-server": McpServerManifestSchema,
41
+ subagent: SubagentManifestSchema,
42
+ pack: PackManifestSchema,
43
+ rule: RuleManifestSchema,
44
+ hook: HookManifestSchema,
45
+ knowledge: KnowledgeManifestSchema,
46
+ };
47
+ export const manifestSchemaForType = (type) => MANIFEST_SCHEMA_BY_TYPE[type];
48
+ const hasOwnField = (value, field) => typeof value === "object" &&
49
+ value !== null &&
50
+ !Array.isArray(value) &&
51
+ Object.hasOwn(value, field);
52
+ const purlHasVersion = (value) => {
53
+ const queryStart = value.search(/[?#]/);
54
+ const comparable = queryStart === -1 ? value : value.slice(0, queryStart);
55
+ const lastSlash = comparable.lastIndexOf("/");
56
+ return lastSlash >= 0 && comparable.indexOf("@", lastSlash + 1) !== -1;
57
+ };
58
+ const purlType = (value) => {
59
+ const match = /^pkg:([^/]+)\//i.exec(value);
60
+ return match?.[1]?.toLowerCase();
61
+ };
62
+ const versScheme = (value) => {
63
+ const match = /^vers:([^/]+)\//i.exec(value);
64
+ return match?.[1]?.toLowerCase();
65
+ };
66
+ const classifyCompanionPackageManifestError = (raw) => {
67
+ if (typeof raw !== "object" || raw === null || !("packages" in raw)) {
68
+ return undefined;
69
+ }
70
+ const packages = Reflect.get(raw, "packages");
71
+ if (!Array.isArray(packages)) {
72
+ return {
73
+ code: "companion_package_invalid",
74
+ detail: "Manifest packages must be an array of companion package objects.",
75
+ };
76
+ }
77
+ for (const entry of packages) {
78
+ if (typeof entry !== "object" || entry === null || Array.isArray(entry)) {
79
+ return {
80
+ code: "companion_package_invalid",
81
+ detail: "Manifest packages entries must be objects with purl and optional versionRange fields.",
82
+ };
83
+ }
84
+ const purl = Reflect.get(entry, "purl");
85
+ if (typeof purl !== "string") {
86
+ return {
87
+ code: "companion_package_invalid",
88
+ detail: "Manifest packages entries must include a purl string.",
89
+ };
90
+ }
91
+ if (purlHasVersion(purl)) {
92
+ return {
93
+ code: "companion_package_purl_has_version",
94
+ detail: "Companion package purls are identities, not pins. Move versions into versionRange.",
95
+ };
96
+ }
97
+ const versionRange = Reflect.get(entry, "versionRange");
98
+ if (versionRange !== undefined && typeof versionRange !== "string") {
99
+ return {
100
+ code: "companion_package_invalid",
101
+ detail: "Manifest packages versionRange must be a VERS string.",
102
+ };
103
+ }
104
+ const packageType = purlType(purl);
105
+ const rangeScheme = typeof versionRange === "string" ? versScheme(versionRange) : undefined;
106
+ if (packageType !== undefined && rangeScheme !== undefined && packageType !== rangeScheme) {
107
+ return {
108
+ code: "companion_package_scheme_mismatch",
109
+ detail: "Companion package purl ecosystem must match the versionRange VERS scheme.",
110
+ };
111
+ }
112
+ }
113
+ // No concrete companion-package problem found: the schema decode failed for an
114
+ // unrelated reason, so let the caller fall back to a generic manifest error
115
+ // rather than misreporting it as companion_package_invalid.
116
+ return undefined;
117
+ };
118
+ export const validateManifestHasNoAgentsField = (fileName, raw) => {
119
+ if (!hasOwnField(raw, "agents"))
120
+ return Result.void;
121
+ return Result.fail(new ManifestError({
122
+ code: "manifest_schema_invalid",
123
+ detail: `Manifest file "${fileName}" must not include "agents"; express targeting in settings.agents.`,
124
+ }));
125
+ };
126
+ export const resolveManifest = (input) => Effect.gen(function* () {
127
+ const expectedFilename = manifestFilenameForType(input.type);
128
+ const [manifestEntry, ...rest] = input.entries.filter((entry) => {
129
+ const normalized = entry.fileName.replace(/\\/g, "/");
130
+ return (normalized === expectedFilename ||
131
+ normalized.toLowerCase() === expectedFilename.toLowerCase());
132
+ });
133
+ if (manifestEntry === undefined) {
134
+ return yield* new ManifestError({
135
+ code: "manifest_missing",
136
+ detail: `Expected manifest file "${expectedFilename}" not found in archive root.`,
137
+ });
138
+ }
139
+ if (rest.length > 0) {
140
+ const allCandidates = [manifestEntry, ...rest];
141
+ return yield* new ManifestError({
142
+ code: "manifest_multiple",
143
+ detail: `Multiple manifest candidates found for type "${input.type}": ${allCandidates.map((candidate) => candidate.fileName).join(", ")}.`,
144
+ });
145
+ }
146
+ const rawBytes = yield* input.readEntry(manifestEntry.fileName);
147
+ const text = new TextDecoder().decode(rawBytes);
148
+ const parsed = yield* Schema.decodeUnknownEffect(Schema.fromJsonString(Schema.Unknown))(text).pipe(Effect.mapError(() => new ManifestError({
149
+ code: "manifest_invalid_json",
150
+ detail: `Manifest file "${manifestEntry.fileName}" contains invalid JSON.`,
151
+ })));
152
+ yield* Effect.fromResult(validateManifestHasNoAgentsField(manifestEntry.fileName, parsed));
153
+ const schema = manifestSchemaForType(input.type);
154
+ yield* Schema.decodeUnknownEffect(schema)(parsed).pipe(Effect.mapError((error) => {
155
+ const companionPackageError = classifyCompanionPackageManifestError(parsed);
156
+ return new ManifestError({
157
+ code: companionPackageError?.code ?? "manifest_schema_invalid",
158
+ detail: companionPackageError?.detail ??
159
+ `Manifest file "${manifestEntry.fileName}" does not conform to the ${input.type} manifest schema.`,
160
+ details: SchemaIssue.makeFormatterDefault()(error.issue),
161
+ });
162
+ }));
163
+ const identity = yield* Schema.decodeUnknownEffect(ManifestIdentitySchema)(parsed).pipe(Effect.mapError(() => new ManifestError({
164
+ code: "manifest_schema_invalid",
165
+ detail: `Manifest file "${manifestEntry.fileName}" is missing required identity fields (owner, type, name, version).`,
166
+ })));
167
+ return {
168
+ identity,
169
+ raw: parsed,
170
+ fileName: manifestEntry.fileName,
171
+ };
172
+ });
173
+ export const validateDeclaredManifestAlignment = (declaredIdentity, manifest) => {
174
+ const mismatches = [];
175
+ if (declaredIdentity.name !== manifest.name) {
176
+ mismatches.push(`name: declared="${declaredIdentity.name}" manifest="${manifest.name}"`);
177
+ }
178
+ if (declaredIdentity.owner !== manifest.owner) {
179
+ mismatches.push(`owner: declared="${declaredIdentity.owner}" manifest="${manifest.owner}"`);
180
+ }
181
+ if (declaredIdentity.type !== manifest.type) {
182
+ mismatches.push(`type: declared="${declaredIdentity.type}" manifest="${manifest.type}"`);
183
+ }
184
+ if (declaredIdentity.version !== manifest.version) {
185
+ mismatches.push(`version: declared="${declaredIdentity.version}" manifest="${manifest.version}"`);
186
+ }
187
+ if (mismatches.length > 0) {
188
+ return Result.fail(new ManifestError({
189
+ code: "declared_manifest_mismatch",
190
+ detail: `Declared publish identity and manifest identity disagree: ${mismatches.join(", ")}.`,
191
+ details: { declaredIdentity, manifest },
192
+ }));
193
+ }
194
+ return Result.void;
195
+ };
196
+ //# sourceMappingURL=manifest-policy.js.map
@@ -0,0 +1,13 @@
1
+ interface ZipFileEntry {
2
+ fileName: string;
3
+ content: Uint8Array;
4
+ compressionMethod?: number;
5
+ externalAttributes?: number;
6
+ }
7
+ export declare const buildZip: (entries: ZipFileEntry[]) => Uint8Array;
8
+ export declare const buildSymlinkZip: (symlinkName: string, targetPath: string) => Uint8Array;
9
+ export declare const buildDecompressionBombZip: (uncompressedSize: number, compressedSize: number, entryName?: string) => Uint8Array;
10
+ export declare const buildMalformedZip: () => Uint8Array;
11
+ export declare const textContent: (text: string) => Uint8Array;
12
+ export {};
13
+ //# sourceMappingURL=test-zip-helpers.d.ts.map
@@ -0,0 +1,117 @@
1
+ import * as zlib from "node:zlib";
2
+ const textEncoder = new TextEncoder();
3
+ const LOCAL_FILE_HEADER_SIG = 0x04034b50;
4
+ const CENTRAL_DIR_SIG = 0x02014b50;
5
+ const EOCD_SIG = 0x06054b50;
6
+ const writeUint32LE = (buf, offset, value) => buf.setUint32(offset, value, true);
7
+ const writeUint16LE = (buf, offset, value) => buf.setUint16(offset, value, true);
8
+ const concatBytes = (arrays) => {
9
+ const totalLength = arrays.reduce((sum, array) => sum + array.length, 0);
10
+ const result = new Uint8Array(totalLength);
11
+ let offset = 0;
12
+ for (const array of arrays) {
13
+ result.set(array, offset);
14
+ offset += array.length;
15
+ }
16
+ return result;
17
+ };
18
+ export const buildZip = (entries) => {
19
+ const centralDirs = [];
20
+ let currentOffset = 0;
21
+ const localParts = [];
22
+ for (const entry of entries) {
23
+ const fileNameBytes = textEncoder.encode(entry.fileName);
24
+ const compressionMethod = entry.compressionMethod ?? 0;
25
+ let compressedData;
26
+ if (compressionMethod === 8) {
27
+ const deflated = zlib.deflateRawSync(entry.content);
28
+ compressedData = new Uint8Array(deflated.buffer, deflated.byteOffset, deflated.byteLength);
29
+ }
30
+ else {
31
+ compressedData = entry.content;
32
+ }
33
+ const localBuf = new ArrayBuffer(30);
34
+ const localView = new DataView(localBuf);
35
+ writeUint32LE(localView, 0, LOCAL_FILE_HEADER_SIG);
36
+ writeUint16LE(localView, 4, 20);
37
+ writeUint16LE(localView, 6, 0);
38
+ writeUint16LE(localView, 8, compressionMethod);
39
+ writeUint16LE(localView, 10, 0);
40
+ writeUint16LE(localView, 12, 0);
41
+ writeUint32LE(localView, 14, 0);
42
+ writeUint32LE(localView, 18, compressedData.length);
43
+ writeUint32LE(localView, 22, entry.content.length);
44
+ writeUint16LE(localView, 26, fileNameBytes.length);
45
+ writeUint16LE(localView, 28, 0);
46
+ const localHeaderBytes = new Uint8Array(localBuf);
47
+ const localRecord = concatBytes([localHeaderBytes, fileNameBytes, compressedData]);
48
+ localParts.push(localRecord);
49
+ const cdirBuf = new ArrayBuffer(46);
50
+ const cdirView = new DataView(cdirBuf);
51
+ writeUint32LE(cdirView, 0, CENTRAL_DIR_SIG);
52
+ writeUint16LE(cdirView, 4, 20);
53
+ writeUint16LE(cdirView, 6, 20);
54
+ writeUint16LE(cdirView, 8, 0);
55
+ writeUint16LE(cdirView, 10, compressionMethod);
56
+ writeUint16LE(cdirView, 12, 0);
57
+ writeUint16LE(cdirView, 14, 0);
58
+ writeUint32LE(cdirView, 16, 0);
59
+ writeUint32LE(cdirView, 20, compressedData.length);
60
+ writeUint32LE(cdirView, 24, entry.content.length);
61
+ writeUint16LE(cdirView, 28, fileNameBytes.length);
62
+ writeUint16LE(cdirView, 30, 0);
63
+ writeUint16LE(cdirView, 32, 0);
64
+ writeUint16LE(cdirView, 34, 0);
65
+ writeUint16LE(cdirView, 36, 0);
66
+ writeUint32LE(cdirView, 38, entry.externalAttributes ?? 0);
67
+ writeUint32LE(cdirView, 42, currentOffset);
68
+ centralDirs.push(concatBytes([new Uint8Array(cdirBuf), fileNameBytes]));
69
+ currentOffset += localRecord.length;
70
+ }
71
+ const cdirStartOffset = currentOffset;
72
+ const allCdir = concatBytes(centralDirs);
73
+ const eocdBuf = new ArrayBuffer(22);
74
+ const eocdView = new DataView(eocdBuf);
75
+ writeUint32LE(eocdView, 0, EOCD_SIG);
76
+ writeUint16LE(eocdView, 4, 0);
77
+ writeUint16LE(eocdView, 6, 0);
78
+ writeUint16LE(eocdView, 8, entries.length);
79
+ writeUint16LE(eocdView, 10, entries.length);
80
+ writeUint32LE(eocdView, 12, allCdir.length);
81
+ writeUint32LE(eocdView, 16, cdirStartOffset);
82
+ writeUint16LE(eocdView, 20, 0);
83
+ return concatBytes([...localParts, allCdir, new Uint8Array(eocdBuf)]);
84
+ };
85
+ export const buildSymlinkZip = (symlinkName, targetPath) => {
86
+ const symlinkAttrs = (0xa000 | 0o777) << 16;
87
+ return buildZip([
88
+ {
89
+ fileName: symlinkName,
90
+ content: textEncoder.encode(targetPath),
91
+ externalAttributes: symlinkAttrs,
92
+ },
93
+ ]);
94
+ };
95
+ export const buildDecompressionBombZip = (uncompressedSize, compressedSize, entryName = "bomb.bin") => {
96
+ const content = new Uint8Array(compressedSize);
97
+ const zip = buildZip([
98
+ {
99
+ fileName: entryName,
100
+ content,
101
+ compressionMethod: 0,
102
+ },
103
+ ]);
104
+ const view = new DataView(zip.buffer, zip.byteOffset, zip.byteLength);
105
+ view.setUint32(22, uncompressedSize, true);
106
+ for (let i = zip.length - 22; i >= 0; i--) {
107
+ if (view.getUint32(i, true) === EOCD_SIG) {
108
+ const cdirOffset = view.getUint32(i + 16, true);
109
+ view.setUint32(cdirOffset + 24, uncompressedSize, true);
110
+ break;
111
+ }
112
+ }
113
+ return zip;
114
+ };
115
+ export const buildMalformedZip = () => new Uint8Array([0x00, 0x01, 0x02, 0x03, 0x04, 0x05]);
116
+ export const textContent = (text) => textEncoder.encode(text);
117
+ //# sourceMappingURL=test-zip-helpers.js.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Deterministic archive builders for tests that exercise archive guardrails
3
+ * and publish input normalization without a zip tool.
4
+ *
5
+ * @experimental This API is unstable and may change without notice.
6
+ * @packageDocumentation
7
+ */
8
+ export { buildDecompressionBombZip, buildMalformedZip, buildSymlinkZip, buildZip, textContent, } from "./packaging/test-zip-helpers.js";
9
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Deterministic archive builders for tests that exercise archive guardrails
3
+ * and publish input normalization without a zip tool.
4
+ *
5
+ * @experimental This API is unstable and may change without notice.
6
+ * @packageDocumentation
7
+ */
8
+ export { buildDecompressionBombZip, buildMalformedZip, buildSymlinkZip, buildZip, textContent, } from "./packaging/test-zip-helpers.js";
9
+ //# sourceMappingURL=testing.js.map
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "author": "AgentXM <hello@agentxm.ai> (https://agentxm.ai)",
3
+ "bugs": {
4
+ "url": "https://github.com/agentxm/axm/issues"
5
+ },
6
+ "dependencies": {
7
+ "@agentxm/extension-model": "^0.28.14-preview.1789139351.5cd4595aa",
8
+ "effect": "4.0.0-rc.112",
9
+ "yaml": "^2.9.0"
10
+ },
11
+ "description": "AXM extension content behavior: skill and subagent content parsing, Knowledge bundle inspection and search, the lint rule catalog, and archive and manifest validation shared by the axm CLI and the AgentXM Registry. Unstable and unsupported — use the axm.sh CLI.",
12
+ "devDependencies": {
13
+ "@effect/platform-node": "4.0.0-rc.112",
14
+ "@effect/vitest": "4.0.0-rc.112",
15
+ "@typescript/native": "npm:typescript@^7.0.2",
16
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
17
+ "vitest": "^4.1.10"
18
+ },
19
+ "engines": {
20
+ "node": ">=22.19.0"
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "axm-source": "./src/index.ts",
25
+ "default": "./dist/src/index.js",
26
+ "types": "./dist/src/index.d.ts"
27
+ },
28
+ "./knowledge": {
29
+ "axm-source": "./src/knowledge/index.ts",
30
+ "default": "./dist/src/knowledge/index.js",
31
+ "types": "./dist/src/knowledge/index.d.ts"
32
+ },
33
+ "./lint": {
34
+ "axm-source": "./src/lint/index.ts",
35
+ "default": "./dist/src/lint/index.js",
36
+ "types": "./dist/src/lint/index.d.ts"
37
+ },
38
+ "./testing": {
39
+ "axm-source": "./src/testing.ts",
40
+ "default": "./dist/src/testing.js",
41
+ "types": "./dist/src/testing.d.ts"
42
+ }
43
+ },
44
+ "files": [
45
+ "dist/src/",
46
+ "!**/*.map"
47
+ ],
48
+ "homepage": "https://axm.sh",
49
+ "license": "FSL-1.1-MIT",
50
+ "name": "@agentxm/extension-content",
51
+ "nx": {
52
+ "includedScripts": []
53
+ },
54
+ "publishConfig": {
55
+ "access": "public"
56
+ },
57
+ "repository": {
58
+ "directory": "packages/core/extension-content",
59
+ "type": "git",
60
+ "url": "https://github.com/agentxm/axm.git"
61
+ },
62
+ "sideEffects": false,
63
+ "type": "module",
64
+ "version": "0.28.14-preview.1789139351.5cd4595aa"
65
+ }