@agent-teams/docs-protocol 0.0.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +201 -0
  3. package/README.md +92 -0
  4. package/dist/adapters/adoption-input.d.ts +9 -0
  5. package/dist/adapters/adoption-input.d.ts.map +1 -0
  6. package/dist/adapters/adoption-input.js +72 -0
  7. package/dist/adapters/adoption-input.js.map +1 -0
  8. package/dist/adapters/adoption-package-identity.d.ts +7 -0
  9. package/dist/adapters/adoption-package-identity.d.ts.map +1 -0
  10. package/dist/adapters/adoption-package-identity.js +69 -0
  11. package/dist/adapters/adoption-package-identity.js.map +1 -0
  12. package/dist/adapters/docs-command-envelope-schema-validator.d.ts +2 -0
  13. package/dist/adapters/docs-command-envelope-schema-validator.d.ts.map +1 -0
  14. package/dist/adapters/docs-command-envelope-schema-validator.js +24 -0
  15. package/dist/adapters/docs-command-envelope-schema-validator.js.map +1 -0
  16. package/dist/adapters/docs-profile-schema-validator.d.ts +2 -0
  17. package/dist/adapters/docs-profile-schema-validator.d.ts.map +1 -0
  18. package/dist/adapters/docs-profile-schema-validator.js +28 -0
  19. package/dist/adapters/docs-profile-schema-validator.js.map +1 -0
  20. package/dist/adapters/foundation-docs-port.d.ts +12 -0
  21. package/dist/adapters/foundation-docs-port.d.ts.map +1 -0
  22. package/dist/adapters/foundation-docs-port.js +108 -0
  23. package/dist/adapters/foundation-docs-port.js.map +1 -0
  24. package/dist/adapters/node-adoption-inspector.d.ts +5 -0
  25. package/dist/adapters/node-adoption-inspector.d.ts.map +1 -0
  26. package/dist/adapters/node-adoption-inspector.js +102 -0
  27. package/dist/adapters/node-adoption-inspector.js.map +1 -0
  28. package/dist/adapters/node-code-anchor-matcher.d.ts +5 -0
  29. package/dist/adapters/node-code-anchor-matcher.d.ts.map +1 -0
  30. package/dist/adapters/node-code-anchor-matcher.js +65 -0
  31. package/dist/adapters/node-code-anchor-matcher.js.map +1 -0
  32. package/dist/adapters/node-profile-reader.d.ts +9 -0
  33. package/dist/adapters/node-profile-reader.d.ts.map +1 -0
  34. package/dist/adapters/node-profile-reader.js +118 -0
  35. package/dist/adapters/node-profile-reader.js.map +1 -0
  36. package/dist/application/authority-handshake.d.ts +14 -0
  37. package/dist/application/authority-handshake.d.ts.map +1 -0
  38. package/dist/application/authority-handshake.js +15 -0
  39. package/dist/application/authority-handshake.js.map +1 -0
  40. package/dist/application/docs-new-completion.d.ts +33 -0
  41. package/dist/application/docs-new-completion.d.ts.map +1 -0
  42. package/dist/application/docs-new-completion.js +226 -0
  43. package/dist/application/docs-new-completion.js.map +1 -0
  44. package/dist/application/docs-protocol.d.ts +168 -0
  45. package/dist/application/docs-protocol.d.ts.map +1 -0
  46. package/dist/application/docs-protocol.js +450 -0
  47. package/dist/application/docs-protocol.js.map +1 -0
  48. package/dist/cli.d.ts +3 -0
  49. package/dist/cli.d.ts.map +1 -0
  50. package/dist/cli.js +4 -0
  51. package/dist/cli.js.map +1 -0
  52. package/dist/composition/cli.d.ts +4 -0
  53. package/dist/composition/cli.d.ts.map +1 -0
  54. package/dist/composition/cli.js +436 -0
  55. package/dist/composition/cli.js.map +1 -0
  56. package/dist/composition/node-docs-api.d.ts +148 -0
  57. package/dist/composition/node-docs-api.d.ts.map +1 -0
  58. package/dist/composition/node-docs-api.js +38 -0
  59. package/dist/composition/node-docs-api.js.map +1 -0
  60. package/dist/domain/document-semantics.d.ts +7 -0
  61. package/dist/domain/document-semantics.d.ts.map +1 -0
  62. package/dist/domain/document-semantics.js +146 -0
  63. package/dist/domain/document-semantics.js.map +1 -0
  64. package/dist/domain/model.d.ts +285 -0
  65. package/dist/domain/model.d.ts.map +1 -0
  66. package/dist/domain/model.js +3 -0
  67. package/dist/domain/model.js.map +1 -0
  68. package/dist/domain/profile-policy.d.ts +7 -0
  69. package/dist/domain/profile-policy.d.ts.map +1 -0
  70. package/dist/domain/profile-policy.js +109 -0
  71. package/dist/domain/profile-policy.js.map +1 -0
  72. package/dist/index.d.ts +6 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +4 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/qualification/index.d.ts +23 -0
  77. package/dist/qualification/index.d.ts.map +1 -0
  78. package/dist/qualification/index.js +462 -0
  79. package/dist/qualification/index.js.map +1 -0
  80. package/package.json +64 -0
  81. package/schemas/docs-protocol/v1.schema.json +12 -0
  82. package/schemas/docs-protocol-command-envelope/v1.schema.json +239 -0
  83. package/schemas/docs-protocol-profile/v1.schema.json +46 -0
@@ -0,0 +1,108 @@
1
+ import { applyDocumentationPlanV2, buildDocumentationCatalogV2, describeDocumentAuthoringProfileV2, findDocumentationDocumentsV2, inspectDocumentTransactionV2, inspectDocumentAuthoringEnvironmentV1, planDocumentationDocumentV2, recoverDocumentationTransactionV2 } from "@agent-teams/engineering-foundation/document-authoring";
2
+ import { DocsProfileError } from "../domain/profile-policy.js";
3
+ import { normalizeDocumentIds } from "../domain/document-semantics.js";
4
+ function stringArray(value, subject) {
5
+ if (value === undefined) {
6
+ return Object.freeze([]);
7
+ }
8
+ if (!Array.isArray(value) || !value.every((entry) => typeof entry === "string")) {
9
+ throw new DocsProfileError(`${subject} must be an array of canonical document IDs.`);
10
+ }
11
+ return normalizeDocumentIds(value, subject);
12
+ }
13
+ function projected(entry, blockedByKey) {
14
+ const metadata = entry.metadata;
15
+ return Object.freeze({
16
+ ...entry,
17
+ metadata,
18
+ related: stringArray(metadata["related"], `${entry.id}.related`),
19
+ blockedBy: stringArray(metadata[blockedByKey], `${entry.id}.${blockedByKey}`)
20
+ });
21
+ }
22
+ function signalOption(signal) {
23
+ return signal === undefined ? {} : { signal };
24
+ }
25
+ export class NodeFoundationDocsPort {
26
+ inspectEnvironment(input) {
27
+ return inspectDocumentAuthoringEnvironmentV1({
28
+ consumerRoot: input.consumerRoot,
29
+ ...signalOption(input.signal)
30
+ });
31
+ }
32
+ async describe(input) {
33
+ const description = await describeDocumentAuthoringProfileV2({
34
+ consumerRoot: input.consumerRoot,
35
+ profilePath: input.profilePath,
36
+ ...signalOption(input.signal)
37
+ });
38
+ return Object.freeze({
39
+ authority: description.authority,
40
+ authorityPaths: Object.freeze([
41
+ description.authorityPaths.profile,
42
+ description.authorityPaths.metadataSchema,
43
+ description.authorityPaths.ownerCatalog,
44
+ ...(description.authorityPaths.metadataSidecar === undefined ? [] : [description.authorityPaths.metadataSidecar]),
45
+ ...description.types.map(({ template }) => template.path)
46
+ ].toSorted((left, right) => Buffer.compare(Buffer.from(left), Buffer.from(right)))),
47
+ metadataSchemaPath: description.authorityPaths.metadataSchema,
48
+ metadataSidecar: description.authorityPaths.metadataSidecar === undefined
49
+ ? Object.freeze({ kind: "none" })
50
+ : Object.freeze({ kind: "path-metadata-map", path: description.authorityPaths.metadataSidecar }),
51
+ ownerIds: description.ownerIds,
52
+ profileSchemaVersion: description.profileSchemaVersion,
53
+ projectId: description.projectId,
54
+ semanticDigest: description.semanticDigest,
55
+ types: description.types
56
+ });
57
+ }
58
+ async buildCatalog(input) {
59
+ return buildDocumentationCatalogV2({
60
+ consumerRoot: input.consumerRoot,
61
+ profilePath: input.profilePath,
62
+ ...signalOption(input.signal)
63
+ });
64
+ }
65
+ async find(input) {
66
+ const base = await findDocumentationDocumentsV2({
67
+ consumerRoot: input.consumerRoot,
68
+ profilePath: input.profilePath,
69
+ query: {
70
+ ...(input.query.text === undefined ? {} : { text: input.query.text }),
71
+ filters: {
72
+ ...(input.query.id === undefined ? {} : { id: input.query.id }),
73
+ ...(input.query.owner === undefined ? {} : { owner: input.query.owner }),
74
+ ...(input.query.status === undefined ? {} : { status: input.query.status }),
75
+ ...(input.query.type === undefined ? {} : { type: input.query.type })
76
+ }
77
+ },
78
+ ...signalOption(input.signal)
79
+ });
80
+ return Object.freeze(base.documents.map((entry) => projected(entry, "blocked_by")));
81
+ }
82
+ inspect(consumerRoot) {
83
+ return inspectDocumentTransactionV2(consumerRoot);
84
+ }
85
+ plan(input) {
86
+ return planDocumentationDocumentV2({
87
+ consumerRoot: input.consumerRoot,
88
+ profilePath: input.profilePath,
89
+ intent: input.intent,
90
+ parentPolicy: input.parentPolicy,
91
+ ...signalOption(input.signal)
92
+ });
93
+ }
94
+ apply(input) {
95
+ return applyDocumentationPlanV2({
96
+ consumerRoot: input.consumerRoot,
97
+ plan: input.plan,
98
+ ...signalOption(input.signal)
99
+ });
100
+ }
101
+ recover(input) {
102
+ return recoverDocumentationTransactionV2({
103
+ consumerRoot: input.consumerRoot,
104
+ ...signalOption(input.signal)
105
+ });
106
+ }
107
+ }
108
+ //# sourceMappingURL=foundation-docs-port.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foundation-docs-port.js","sourceRoot":"","sources":["../../src/adapters/foundation-docs-port.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,kCAAkC,EAClC,4BAA4B,EAC5B,4BAA4B,EAC5B,qCAAqC,EACrC,2BAA2B,EAC3B,iCAAiC,EAGlC,MAAM,wDAAwD,CAAC;AAOhE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAEvE,SAAS,WAAW,CAAC,KAAwC,EAAE,OAAe;IAC5E,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAAA,CAAC;IACpD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,EAAE,CAAC;QAChF,MAAM,IAAI,gBAAgB,CAAC,GAAG,OAAO,8CAA8C,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,oBAAoB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AA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AO,4BAA4B,CAAC,YAAY,CAAC,CAAC;IACpD,CAAC;IAED,IAAI,CAAC,KAAgD;QACnD,OAAO,2BAA2B,CAAC;YACjC,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAiD;QACrD,OAAO,wBAAwB,CAAC;YAC9B,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,OAAO,CAAC,KAAmD;QACzD,OAAO,iCAAiC,CAAC;YACvC,YAAY,EAAE,KAAK,CAAC,YAAY;YAChC,GAAG,YAAY,CAAC,KAAK,CAAC,MAAM,CAAC;SAC9B,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import type { DocsAdoptionInspector, DocsDiagnostic } from "../domain/model.js";
2
+ export declare class NodeDocsAdoptionInspector implements DocsAdoptionInspector {
3
+ inspect(input: Parameters<DocsAdoptionInspector["inspect"]>[0]): Promise<readonly DocsDiagnostic[]>;
4
+ }
5
+ //# sourceMappingURL=node-adoption-inspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-adoption-inspector.d.ts","sourceRoot":"","sources":["../../src/adapters/node-adoption-inspector.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAiDhF,qBAAa,yBAA0B,YAAW,qBAAqB;IAC/D,OAAO,CAAC,KAAK,EAAE,UAAU,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,cAAc,EAAE,CAAC,CAiCxG;CACF"}
@@ -0,0 +1,102 @@
1
+ import { realpath } from "node:fs/promises";
2
+ import { resolve } from "node:path";
3
+ import { assertContainedAuthority, MAX_MANIFEST_BYTES, MAX_ROUTING_BYTES, MAX_SKILL_BYTES, parseJsonRecord, readContainedText, recordField } from "./adoption-input.js";
4
+ import { DOCS_PACKAGE, FOUNDATION_PACKAGE, inspectAdoptionPackageIdentity } from "./adoption-package-identity.js";
5
+ const COMMANDS = ["check", "doctor", "find", "info", "new", "recover"];
6
+ function diagnostic(subject, message) {
7
+ return { ruleId: "docs.adoption.invalid", severity: "error", phase: "authority", subject, message };
8
+ }
9
+ function inspectSkill(source) {
10
+ if (source.includes("\r") || source !== source.normalize("NFC") || !source.endsWith("\n")) {
11
+ return ["Skill must be NFC UTF-8 text with LF lines and one final newline."];
12
+ }
13
+ const lines = source.slice(0, -1).split("\n");
14
+ const diagnostics = [];
15
+ if (lines.length < 20 || lines.length > 30) {
16
+ diagnostics.push("Skill must contain between 20 and 30 lines.");
17
+ }
18
+ const protocolDeclarations = source.match(/agent-teams\.docs-protocol\/v[0-9]+/gu) ?? [];
19
+ if (protocolDeclarations.length !== 1 || protocolDeclarations[0] !== "agent-teams.docs-protocol/v1") {
20
+ diagnostics.push("Skill must declare exactly agent-teams.docs-protocol/v1.");
21
+ }
22
+ const evidence = [
23
+ /pnpm docs:find/u,
24
+ /pnpm docs:new.*--dry-run/u,
25
+ /pnpm docs:new.*--apply/u,
26
+ /(?=.*manual)(?=.*reported)(?=.*index)(?=.*link)/iu,
27
+ /pnpm docs:check/u
28
+ ];
29
+ let previous = -1;
30
+ for (const marker of evidence) {
31
+ const matches = lines.flatMap((line, index) => marker.test(line) ? [index] : []);
32
+ if (matches.length !== 1 || matches[0] <= previous) {
33
+ diagnostics.push("Skill must contain unique ordered find, dry-run preview, apply, manual reported index/link, and check evidence.");
34
+ break;
35
+ }
36
+ previous = matches[0];
37
+ }
38
+ return diagnostics;
39
+ }
40
+ function inspectAgentsRoute(source, skillPath) {
41
+ const expected = `Use [${skillPath}](${skillPath}) for documentation.`;
42
+ const routes = source.split("\n").filter((line) => line.includes("docs-authoring/SKILL.md"));
43
+ return routes.length === 1 && routes[0] === expected ? [] : [`AGENTS.md must contain exactly one route: ${expected}`];
44
+ }
45
+ export class NodeDocsAdoptionInspector {
46
+ async inspect(input) {
47
+ const diagnostics = [];
48
+ let root = "";
49
+ try {
50
+ root = await realpath(resolve(input.consumerRoot));
51
+ }
52
+ catch {
53
+ return Object.freeze([diagnostic(input.consumerRoot, "Consumer root must be one accessible real directory.")]);
54
+ }
55
+ let manifest = {};
56
+ try {
57
+ manifest = parseJsonRecord(await readContainedText(root, "package.json", MAX_MANIFEST_BYTES));
58
+ }
59
+ catch (error) {
60
+ diagnostics.push(diagnostic("package.json", `A bounded real strict JSON package manifest is required: ${error instanceof Error ? error.message : "invalid input"}`));
61
+ }
62
+ const scripts = recordField(manifest, "scripts");
63
+ for (const command of COMMANDS) {
64
+ const expected = `agent-teams-docs ${command} --consumer . --profile ${input.profilePath}`;
65
+ if (scripts[`docs:${command}`] !== expected) {
66
+ diagnostics.push(diagnostic(`package.json#scripts.docs:${command}`, `Expected exact script: ${expected}`));
67
+ }
68
+ }
69
+ const dependencies = recordField(manifest, "dependencies");
70
+ const devDependencies = recordField(manifest, "devDependencies");
71
+ for (const packageName of [DOCS_PACKAGE, FOUNDATION_PACKAGE]) {
72
+ if (dependencies[packageName] !== undefined) {
73
+ diagnostics.push(diagnostic("package.json#dependencies", `${packageName} is tooling-only and must not be a production dependency.`));
74
+ }
75
+ }
76
+ diagnostics.push(...(await inspectAdoptionPackageIdentity(root, devDependencies)).map(({ message, subject }) => diagnostic(subject, message)));
77
+ try {
78
+ const agents = await readContainedText(root, "AGENTS.md", MAX_ROUTING_BYTES);
79
+ diagnostics.push(...inspectAgentsRoute(agents, input.skillPath).map((message) => diagnostic("AGENTS.md", message)));
80
+ }
81
+ catch (error) {
82
+ diagnostics.push(diagnostic("AGENTS.md", `AGENTS.md must be a bounded real file: ${error instanceof Error ? error.message : "invalid input"}`));
83
+ }
84
+ try {
85
+ const skill = await readContainedText(root, input.skillPath, MAX_SKILL_BYTES);
86
+ diagnostics.push(...inspectSkill(skill).map((message) => diagnostic(input.skillPath, message)));
87
+ }
88
+ catch (error) {
89
+ diagnostics.push(diagnostic(input.skillPath, `Skill must be a bounded real file: ${error instanceof Error ? error.message : "invalid input"}`));
90
+ }
91
+ for (const path of [input.profilePath, input.skillPath, ...input.authorityPaths]) {
92
+ try {
93
+ await assertContainedAuthority(root, path);
94
+ }
95
+ catch {
96
+ diagnostics.push(diagnostic(path, "Declared documentation authority must be a bounded real contained regular file."));
97
+ }
98
+ }
99
+ return Object.freeze(diagnostics);
100
+ }
101
+ }
102
+ //# sourceMappingURL=node-adoption-inspector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-adoption-inspector.js","sourceRoot":"","sources":["../../src/adapters/node-adoption-inspector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,eAAe,EACf,iBAAiB,EACjB,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,8BAA8B,EAAE,MAAM,gCAAgC,CAAC;AAElH,MAAM,QAAQ,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,CAAU,CAAC;AAEhF,SAAS,UAAU,CAAC,OAAe,EAAE,OAAe;IAClD,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,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AAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC;gBAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,iFAAiF,CAAC,CAAC,CAAC;YAAC,CAAC;QACtL,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,5 @@
1
+ import type { CodeAnchorMatcher } from "../domain/model.js";
2
+ export declare class NodeCodeAnchorMatcher implements CodeAnchorMatcher {
3
+ matchedPatterns(input: Parameters<CodeAnchorMatcher["matchedPatterns"]>[0]): Promise<readonly string[]>;
4
+ }
5
+ //# sourceMappingURL=node-code-anchor-matcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-code-anchor-matcher.d.ts","sourceRoot":"","sources":["../../src/adapters/node-code-anchor-matcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAuB5D,qBAAa,qBAAsB,YAAW,iBAAiB;IACvD,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAkC5G;CACF"}
@@ -0,0 +1,65 @@
1
+ import { lstat, readdir, realpath } from "node:fs/promises";
2
+ import { isAbsolute, matchesGlob, relative, resolve, sep } from "node:path";
3
+ const MAX_PATTERNS = 1_024;
4
+ const MAX_CORPUS_FILES = 50_000;
5
+ const MAX_CORPUS_PATH_BYTES = 8 * 1024 * 1024;
6
+ const EXCLUDED_DIRECTORY_NAMES = new Set([".git", "node_modules"]);
7
+ function contained(root, candidate) {
8
+ const path = relative(root, candidate);
9
+ return path === "" || (!path.startsWith(`..${sep}`) && path !== ".." && !isAbsolute(path));
10
+ }
11
+ async function realFileAncestry(root, repositoryPath) {
12
+ let current = root;
13
+ for (const segment of repositoryPath.split("/")) {
14
+ current = resolve(current, segment);
15
+ const state = await lstat(current);
16
+ if (state.isSymbolicLink()) {
17
+ return false;
18
+ }
19
+ }
20
+ const state = await lstat(current);
21
+ return state.isFile() && contained(root, await realpath(current));
22
+ }
23
+ export class NodeCodeAnchorMatcher {
24
+ async matchedPatterns(input) {
25
+ if (input.patterns.length > MAX_PATTERNS) {
26
+ throw new RangeError(`Code anchor matcher exceeds the ${MAX_PATTERNS}-pattern budget.`);
27
+ }
28
+ const root = await realpath(resolve(input.consumerRoot));
29
+ const files = [];
30
+ let pathBytes = 0;
31
+ const pending = [""];
32
+ while (pending.length > 0) {
33
+ input.signal?.throwIfAborted();
34
+ const directory = pending.pop();
35
+ const entries = (await readdir(resolve(root, directory), { withFileTypes: true }))
36
+ .toSorted((left, right) => Buffer.compare(Buffer.from(left.name), Buffer.from(right.name)));
37
+ const childDirectories = [];
38
+ for (const entry of entries) {
39
+ input.signal?.throwIfAborted();
40
+ const repositoryPath = directory === "" ? entry.name : `${directory}/${entry.name}`;
41
+ const state = await lstat(resolve(root, repositoryPath));
42
+ if (state.isSymbolicLink()) {
43
+ continue;
44
+ }
45
+ if (state.isDirectory() && !EXCLUDED_DIRECTORY_NAMES.has(entry.name)) {
46
+ childDirectories.push(repositoryPath);
47
+ }
48
+ else if (state.isFile() && await realFileAncestry(root, repositoryPath)) {
49
+ pathBytes += Buffer.byteLength(repositoryPath);
50
+ if (files.length >= MAX_CORPUS_FILES || pathBytes > MAX_CORPUS_PATH_BYTES) {
51
+ throw new RangeError(`Code anchor corpus exceeds the ${MAX_CORPUS_FILES}-file or ${MAX_CORPUS_PATH_BYTES}-byte path budget.`);
52
+ }
53
+ files.push(repositoryPath);
54
+ }
55
+ }
56
+ // Reverse push preserves bytewise ascending traversal with a LIFO stack.
57
+ for (const child of childDirectories.toReversed()) {
58
+ pending.push(child);
59
+ }
60
+ }
61
+ const matched = input.patterns.filter((pattern) => files.some((repositoryPath) => matchesGlob(repositoryPath, pattern)));
62
+ return Object.freeze(matched);
63
+ }
64
+ }
65
+ //# sourceMappingURL=node-code-anchor-matcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-code-anchor-matcher.js","sourceRoot":"","sources":["../../src/adapters/node-code-anchor-matcher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAI5E,MAAM,YAAY,GAAG,KAAK,CAAC;AAC3B,MAAM,gBAAgB,GAAG,MAAM,CAAC;AAChC,MAAM,qBAAqB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC9C,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;AAEnE,SAAS,SAAS,CAAC,IAAY,EAAE,SAAiB;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACvC,OAAO,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,IAAY,EAAE,cAAsB;IAClE,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,KAAK,MAAM,OAAO,IAAI,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QAChD,OAAO,GAAG,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACpC,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,KAAK,CAAC,cAAc,EAAE,EAAE,CAAC;YAAA,OAAO,KAAK,CAAC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EAAE,CAAC,WAAW,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QACzH,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAChC,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ import type { DocsProfileReader } from "../domain/model.js";
2
+ export declare class NodeDocsProfileReader implements DocsProfileReader {
3
+ read(input: {
4
+ readonly consumerRoot: string;
5
+ readonly profilePath: string;
6
+ readonly signal?: AbortSignal;
7
+ }): Promise<import("../domain/model.js").DocsProtocolProfile>;
8
+ }
9
+ //# sourceMappingURL=node-profile-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-profile-reader.d.ts","sourceRoot":"","sources":["../../src/adapters/node-profile-reader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAsF5D,qBAAa,qBAAsB,YAAW,iBAAiB;IACvD,IAAI,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,6DAI/G;CACF"}
@@ -0,0 +1,118 @@
1
+ import { constants } from "node:fs";
2
+ import { lstat, open, realpath } from "node:fs/promises";
3
+ import { isAbsolute, relative, resolve, sep } from "node:path";
4
+ import { isAlias, isMap, isNode, isPair, parseDocument, visit } from "yaml";
5
+ import { DocsProfileError, parseDocsProtocolProfile } from "../domain/profile-policy.js";
6
+ import { assertDocsProtocolProfileSchema } from "./docs-profile-schema-validator.js";
7
+ const MAX_PROFILE_BYTES = 1_048_576;
8
+ function contained(root, candidate) {
9
+ const path = relative(root, candidate);
10
+ return path === "" || (!path.startsWith(`..${sep}`) && path !== ".." && !isAbsolute(path));
11
+ }
12
+ function assertInitialFile(state) {
13
+ if (!state.isFile() || state.isSymbolicLink()) {
14
+ throw new DocsProfileError("Profile must be a regular file.");
15
+ }
16
+ if (state.size > BigInt(MAX_PROFILE_BYTES)) {
17
+ throw new DocsProfileError("Profile exceeds 1 MiB.");
18
+ }
19
+ }
20
+ function sameIdentity(left, right) {
21
+ return left.dev === right.dev && left.ino === right.ino;
22
+ }
23
+ async function readBounded(handle, signal) {
24
+ const chunks = [];
25
+ let total = 0;
26
+ while (total <= MAX_PROFILE_BYTES) {
27
+ signal?.throwIfAborted();
28
+ const remaining = MAX_PROFILE_BYTES + 1 - total;
29
+ const chunk = Buffer.allocUnsafe(Math.min(64 * 1024, remaining));
30
+ const { bytesRead } = await handle.read(chunk, 0, chunk.byteLength, null);
31
+ if (bytesRead === 0) {
32
+ return Buffer.concat(chunks, total);
33
+ }
34
+ chunks.push(chunk.subarray(0, bytesRead));
35
+ total += bytesRead;
36
+ }
37
+ throw new DocsProfileError("Profile exceeds 1 MiB.");
38
+ }
39
+ async function readProfileBytes(input) {
40
+ if (isAbsolute(input.profilePath)) {
41
+ throw new DocsProfileError("Profile path must be repository-relative.");
42
+ }
43
+ const root = await realpath(resolve(input.consumerRoot));
44
+ input.signal?.throwIfAborted();
45
+ const requested = resolve(root, input.profilePath);
46
+ if (!contained(root, requested)) {
47
+ throw new DocsProfileError("Profile path escapes the consumer root.");
48
+ }
49
+ const noFollow = process.platform === "win32" ? 0 : constants.O_NOFOLLOW;
50
+ const nonBlocking = process.platform === "win32" ? 0 : constants.O_NONBLOCK;
51
+ const handle = await open(requested, constants.O_RDONLY | noFollow | nonBlocking).catch((error) => {
52
+ if (error.code === "ELOOP") {
53
+ throw new DocsProfileError("Profile path must be a real contained file without symlinks.");
54
+ }
55
+ throw error;
56
+ });
57
+ try {
58
+ const opened = await handle.stat({ bigint: true });
59
+ assertInitialFile(opened);
60
+ const physical = await realpath(requested);
61
+ input.signal?.throwIfAborted();
62
+ if (!contained(root, physical) || physical !== requested) {
63
+ throw new DocsProfileError("Profile path must be a real contained file without symlinks.");
64
+ }
65
+ const pathState = await lstat(physical, { bigint: true });
66
+ if (!pathState.isFile() || pathState.isSymbolicLink() || !sameIdentity(pathState, opened)) {
67
+ throw new DocsProfileError("Profile identity changed before its bounded read.");
68
+ }
69
+ const bytes = await readBounded(handle, input.signal);
70
+ const after = await handle.stat({ bigint: true });
71
+ if (!sameIdentity(after, opened) || after.size !== opened.size || after.mtimeNs !== opened.mtimeNs || after.size !== BigInt(bytes.byteLength)) {
72
+ throw new DocsProfileError("Profile changed during its bounded read or exceeds 1 MiB.");
73
+ }
74
+ return bytes;
75
+ }
76
+ finally {
77
+ await handle.close();
78
+ }
79
+ }
80
+ function parseProfileSource(bytes) {
81
+ const source = new TextDecoder("utf-8", { fatal: true }).decode(bytes);
82
+ if (source.includes("\0") || source.startsWith("\uFEFF")) {
83
+ throw new DocsProfileError("Profile encoding is invalid.");
84
+ }
85
+ const document = parseDocument(source, { customTags: [], merge: false, schema: "core", uniqueKeys: true });
86
+ if (document.errors.length > 0 || document.warnings.length > 0) {
87
+ const problem = [...document.errors, ...document.warnings].slice(0, 8).map(({ message }) => message).join("; ").slice(0, 1000);
88
+ throw new DocsProfileError(`Profile YAML is invalid: ${problem}`);
89
+ }
90
+ let forbidden;
91
+ visit(document, (_key, node) => {
92
+ if (isAlias(node)) {
93
+ forbidden = "YAML aliases are prohibited.";
94
+ }
95
+ else if (isNode(node) && (node.anchor !== undefined || node.tag !== undefined)) {
96
+ forbidden = "YAML anchors and explicit tags are prohibited.";
97
+ }
98
+ else if (isPair(node) && isNode(node.key) && "value" in node.key && node.key.value === "<<") {
99
+ forbidden = "YAML merge keys are prohibited.";
100
+ }
101
+ else if (isMap(node) && node.items.length > 10_000) {
102
+ forbidden = "YAML mapping exceeds the limit.";
103
+ }
104
+ return forbidden === undefined ? undefined : visit.BREAK;
105
+ });
106
+ if (forbidden !== undefined) {
107
+ throw new DocsProfileError(forbidden);
108
+ }
109
+ return document.toJS({ maxAliasCount: 0 });
110
+ }
111
+ export class NodeDocsProfileReader {
112
+ async read(input) {
113
+ const value = parseProfileSource(await readProfileBytes(input));
114
+ await assertDocsProtocolProfileSchema(value);
115
+ return parseDocsProtocolProfile(value);
116
+ }
117
+ }
118
+ //# sourceMappingURL=node-profile-reader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-profile-reader.js","sourceRoot":"","sources":["../../src/adapters/node-profile-reader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAmB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACzF,OAAO,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AAErF,MAAM,iBAAiB,GAAG,SAAS,CAAC;AAEpC,SAAS,SAAS,CAAC,IAAY,EAAE,SAAiB;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACvC,OAAO,IAAI,KAAK,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AAC7F,CAAC;AAED,SAAS,iBAAiB,CAAC,KAA8C;IACvE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,IAAI,KAAK,CAAC,cAAc,EAAE,EAAE,CAAC;QAAA,MAAM,IAAI,gBAAgB,CAAC,iCAAiC,CAAC,CAAC;IAAA,CAAC;IAC/G,IAAI,KAAK,CAAC,IAAI,GAAG,MAAM,CAA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IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;YAAA,SAAS,GAAG,iCAAiC,CAAC;QAAA,CAAC;aACxI,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;YAAA,SAAS,GAAG,iCAAiC,CAAC;QAAA,CAAC;QACpG,OAAO,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC;IAC3D,CAAC,CAAC,CAAC;IACH,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAAA,MAAM,IAAI,gBAAgB,CAAC,SAAS,CAAC,CAAC;IAAA,CAAC;IACrE,OAAO,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAY,CAAC;AACxD,CAAC;AAED,MAAM,OAAO,qBAAqB;IAChC,KAAK,CAAC,IAAI,CAAC,KAAqG;QAC9G,MAAM,KAAK,GAAG,kBAAkB,CAAC,MAAM,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;QAChE,MAAM,+BAA+B,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,wBAAwB,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import type { FoundationDocsPort } from "../domain/model.js";
2
+ type Catalog = Awaited<ReturnType<FoundationDocsPort["buildCatalog"]>>;
3
+ type Description = Awaited<ReturnType<FoundationDocsPort["describe"]>>;
4
+ type Plan = Awaited<ReturnType<FoundationDocsPort["plan"]>>;
5
+ export declare function planAuthorityStable(plan: Plan, before: {
6
+ readonly catalog: Catalog;
7
+ readonly description: Description;
8
+ }, after: {
9
+ readonly catalog: Catalog;
10
+ readonly description: Description;
11
+ }): boolean;
12
+ export declare function catalogMatchesExpectedPostimage(plan: Plan, catalog: Catalog): boolean;
13
+ export {};
14
+ //# sourceMappingURL=authority-handshake.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-handshake.d.ts","sourceRoot":"","sources":["../../src/application/authority-handshake.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,KAAK,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AACvE,KAAK,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACvE,KAAK,IAAI,GAAG,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AAM5D,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,EACV,MAAM,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;CAAE,EACxE,KAAK,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAA;CAAE,GACtE,OAAO,CAMT;AAED,wBAAgB,+BAA+B,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAGrF"}
@@ -0,0 +1,15 @@
1
+ function isPlanV2(plan) {
2
+ return plan.schemaVersion === 2;
3
+ }
4
+ export function planAuthorityStable(plan, before, after) {
5
+ return isPlanV2(plan) &&
6
+ before.description.semanticDigest === plan.authority.profileSemanticDigest &&
7
+ plan.authority.profileSemanticDigest === after.description.semanticDigest &&
8
+ before.catalog.semanticDigest === plan.authority.catalogPreimageSemanticDigest &&
9
+ plan.authority.catalogPreimageSemanticDigest === after.catalog.semanticDigest;
10
+ }
11
+ export function catalogMatchesExpectedPostimage(plan, catalog) {
12
+ return isPlanV2(plan) &&
13
+ catalog.semanticDigest === plan.authority.expectedCatalogPostimageSemanticDigest;
14
+ }
15
+ //# sourceMappingURL=authority-handshake.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authority-handshake.js","sourceRoot":"","sources":["../../src/application/authority-handshake.ts"],"names":[],"mappings":"AAQA,SAAS,QAAQ,CAAC,IAAU;IAC1B,OAAO,IAAI,CAAC,aAAa,KAAK,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,mBAAmB,CACjC,IAAU,EACV,MAAwE,EACxE,KAAuE;IAEvE,OAAO,QAAQ,CAAC,IAAI,CAAC;QACnB,MAAM,CAAC,WAAW,CAAC,cAAc,KAAK,IAAI,CAAC,SAAS,CAAC,qBAAqB;QAC1E,IAAI,CAAC,SAAS,CAAC,qBAAqB,KAAK,KAAK,CAAC,WAAW,CAAC,cAAc;QACzE,MAAM,CAAC,OAAO,CAAC,cAAc,KAAK,IAAI,CAAC,SAAS,CAAC,6BAA6B;QAC9E,IAAI,CAAC,SAAS,CAAC,6BAA6B,KAAK,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC;AAClF,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,IAAU,EAAE,OAAgB;IAC1E,OAAO,QAAQ,CAAC,IAAI,CAAC;QACnB,OAAO,CAAC,cAAc,KAAK,IAAI,CAAC,SAAS,CAAC,sCAAsC,CAAC;AACrF,CAAC"}
@@ -0,0 +1,33 @@
1
+ import type { DocumentReceiptContract } from "@agent-teams/engineering-foundation/document-authoring";
2
+ import type { CodeAnchorMatcher, DocsCodeAnchor, DocsCommandOutcome, DocsDiagnostic, FoundationDocsPort, ReachabilityAction } from "../domain/model.js";
3
+ export declare function boundedDiagnostics(diagnostics: readonly DocsDiagnostic[]): readonly DocsDiagnostic[];
4
+ export declare function inspectRecapturedAnchors(anchors: readonly DocsCodeAnchor[], matchedPatterns: readonly string[]): {
5
+ readonly diagnostics: readonly DocsDiagnostic[];
6
+ readonly requiredMissing: boolean;
7
+ };
8
+ export declare function mergeDiagnostics(...groups: readonly (readonly DocsDiagnostic[])[]): readonly DocsDiagnostic[];
9
+ export declare function inspectCorpusSemantics(input: {
10
+ readonly anchors: CodeAnchorMatcher;
11
+ readonly catalog: Awaited<ReturnType<FoundationDocsPort["buildCatalog"]>>;
12
+ readonly consumerRoot: string;
13
+ readonly signal?: AbortSignal;
14
+ }): Promise<readonly DocsDiagnostic[]>;
15
+ export declare function completeDocsNewApply(input: {
16
+ readonly anchors: CodeAnchorMatcher;
17
+ readonly codeAnchors: readonly DocsCodeAnchor[];
18
+ readonly consumerRoot: string;
19
+ readonly diagnostics: readonly DocsDiagnostic[];
20
+ readonly foundation: FoundationDocsPort;
21
+ readonly outcome: DocsCommandOutcome;
22
+ readonly plan: Awaited<ReturnType<FoundationDocsPort["plan"]>>;
23
+ readonly profilePath: string;
24
+ readonly reachability: ReachabilityAction;
25
+ readonly receipt: DocumentReceiptContract;
26
+ readonly signal?: AbortSignal;
27
+ }): Promise<{
28
+ readonly diagnostics: readonly DocsDiagnostic[];
29
+ readonly outcome: DocsCommandOutcome;
30
+ readonly reachability?: ReachabilityAction;
31
+ readonly writeState?: "published-recovery-required";
32
+ }>;
33
+ //# sourceMappingURL=docs-new-completion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs-new-completion.d.ts","sourceRoot":"","sources":["../../src/application/docs-new-completion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,uBAAuB,EAAE,MAAM,wDAAwD,CAAC;AAEzH,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAW5B,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,GAAG,SAAS,cAAc,EAAE,CAYpG;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,SAAS,cAAc,EAAE,EAClC,eAAe,EAAE,SAAS,MAAM,EAAE,GACjC;IAAE,QAAQ,CA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