@agent-teams/docs-protocol 0.1.0-rc.9 → 0.1.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.
Files changed (83) hide show
  1. package/CHANGELOG.md +71 -0
  2. package/assets/history/sha256-51d3f02a352ce2c3b0a4068a86b6899a57ab54b0a876c468e3fb3e536519caca/caller.yml +14 -0
  3. package/assets/history/sha256-fd633c3c6337e5cfe51a9f36989bb654381634c5ab4add9e4da71fe40ab4e0dd/caller.yml +14 -0
  4. package/assets/transition-catalog.json +1 -1
  5. package/dist/consumer-integration/adapters/agents-route-adapter-v1.d.ts +4 -9
  6. package/dist/consumer-integration/adapters/agents-route-adapter-v1.d.ts.map +1 -1
  7. package/dist/consumer-integration/adapters/agents-route-adapter-v1.js +3 -0
  8. package/dist/consumer-integration/adapters/agents-route-adapter-v1.js.map +1 -1
  9. package/dist/consumer-integration/adapters/consumer-integration-node-error.d.ts +5 -0
  10. package/dist/consumer-integration/adapters/consumer-integration-node-error.d.ts.map +1 -0
  11. package/dist/consumer-integration/adapters/consumer-integration-node-error.js +9 -0
  12. package/dist/consumer-integration/adapters/consumer-integration-node-error.js.map +1 -0
  13. package/dist/consumer-integration/adapters/foundation-known-file-transaction.d.ts +3 -0
  14. package/dist/consumer-integration/adapters/foundation-known-file-transaction.d.ts.map +1 -0
  15. package/dist/consumer-integration/adapters/foundation-known-file-transaction.js +7 -0
  16. package/dist/consumer-integration/adapters/foundation-known-file-transaction.js.map +1 -0
  17. package/dist/consumer-integration/adapters/node-consumer-integration-repository.d.ts +3 -4
  18. package/dist/consumer-integration/adapters/node-consumer-integration-repository.d.ts.map +1 -1
  19. package/dist/consumer-integration/adapters/node-consumer-integration-repository.js +9 -132
  20. package/dist/consumer-integration/adapters/node-consumer-integration-repository.js.map +1 -1
  21. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.d.ts +2 -0
  22. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.d.ts.map +1 -1
  23. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.js +1 -0
  24. package/dist/consumer-integration/adapters/package-consumer-asset-catalog.js.map +1 -1
  25. package/dist/consumer-integration/adapters/pnpm-lockfile-validator-v1.d.ts +3 -0
  26. package/dist/consumer-integration/adapters/pnpm-lockfile-validator-v1.d.ts.map +1 -0
  27. package/dist/consumer-integration/adapters/pnpm-lockfile-validator-v1.js +120 -0
  28. package/dist/consumer-integration/adapters/pnpm-lockfile-validator-v1.js.map +1 -0
  29. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.d.ts +4 -9
  30. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.d.ts.map +1 -1
  31. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.js +4 -1
  32. package/dist/consumer-integration/adapters/pnpm-manifest-adapter-v1.js.map +1 -1
  33. package/dist/consumer-integration/adapters/strict-json-record.d.ts +3 -0
  34. package/dist/consumer-integration/adapters/strict-json-record.d.ts.map +1 -0
  35. package/dist/consumer-integration/adapters/strict-json-record.js +27 -0
  36. package/dist/consumer-integration/adapters/strict-json-record.js.map +1 -0
  37. package/dist/consumer-integration/application/model/consumer-integration-execution.d.ts +11 -0
  38. package/dist/consumer-integration/application/model/consumer-integration-execution.d.ts.map +1 -0
  39. package/dist/consumer-integration/application/model/consumer-integration-execution.js +2 -0
  40. package/dist/consumer-integration/application/model/consumer-integration-execution.js.map +1 -0
  41. package/dist/consumer-integration/application/policies/consumer-integration-assets.d.ts +1 -1
  42. package/dist/consumer-integration/application/policies/consumer-integration-assets.d.ts.map +1 -1
  43. package/dist/consumer-integration/application/policies/consumer-integration-desired-state.js +1 -1
  44. package/dist/consumer-integration/application/policies/consumer-integration-desired-state.js.map +1 -1
  45. package/dist/consumer-integration/application/policies/consumer-integration-prior-cohort.d.ts +14 -0
  46. package/dist/consumer-integration/application/policies/consumer-integration-prior-cohort.d.ts.map +1 -0
  47. package/dist/consumer-integration/application/policies/consumer-integration-prior-cohort.js +186 -0
  48. package/dist/consumer-integration/application/policies/consumer-integration-prior-cohort.js.map +1 -0
  49. package/dist/consumer-integration/application/ports/consumer-integration-lifecycle.d.ts +31 -0
  50. package/dist/consumer-integration/application/ports/consumer-integration-lifecycle.d.ts.map +1 -0
  51. package/dist/consumer-integration/application/ports/consumer-integration-lifecycle.js +2 -0
  52. package/dist/consumer-integration/application/ports/consumer-integration-lifecycle.js.map +1 -0
  53. package/dist/consumer-integration/application/ports/consumer-integration-planners.d.ts +35 -0
  54. package/dist/consumer-integration/application/ports/consumer-integration-planners.d.ts.map +1 -0
  55. package/dist/consumer-integration/application/ports/consumer-integration-planners.js +2 -0
  56. package/dist/consumer-integration/application/ports/consumer-integration-planners.js.map +1 -0
  57. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.d.ts +2 -5
  58. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.d.ts.map +1 -1
  59. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.js +5 -192
  60. package/dist/consumer-integration/application/use-cases/plan-consumer-integration.js.map +1 -1
  61. package/dist/consumer-integration/application/use-cases/run-consumer-integration.d.ts +29 -0
  62. package/dist/consumer-integration/application/use-cases/run-consumer-integration.d.ts.map +1 -0
  63. package/dist/consumer-integration/application/use-cases/run-consumer-integration.js +139 -0
  64. package/dist/consumer-integration/application/use-cases/run-consumer-integration.js.map +1 -0
  65. package/dist/consumer-integration/composition/consumer-integration-cli.js +1 -1
  66. package/dist/consumer-integration/composition/consumer-integration-cli.js.map +1 -1
  67. package/dist/consumer-integration/composition/consumer-integration-planner.d.ts +19 -0
  68. package/dist/consumer-integration/composition/consumer-integration-planner.d.ts.map +1 -0
  69. package/dist/consumer-integration/composition/consumer-integration-planner.js +14 -0
  70. package/dist/consumer-integration/composition/consumer-integration-planner.js.map +1 -0
  71. package/dist/consumer-integration/composition/node-consumer-integration.d.ts +2 -10
  72. package/dist/consumer-integration/composition/node-consumer-integration.d.ts.map +1 -1
  73. package/dist/consumer-integration/composition/node-consumer-integration.js +19 -133
  74. package/dist/consumer-integration/composition/node-consumer-integration.js.map +1 -1
  75. package/dist/consumer-integration/generated/canonical-assets.d.ts +1 -1
  76. package/dist/consumer-integration/generated/canonical-assets.d.ts.map +1 -1
  77. package/dist/consumer-integration/generated/canonical-assets.js +1 -1
  78. package/dist/consumer-integration/generated/canonical-assets.js.map +1 -1
  79. package/dist/consumer-integration/index.d.ts +1 -1
  80. package/dist/consumer-integration/index.d.ts.map +1 -1
  81. package/dist/consumer-integration/index.js +1 -1
  82. package/dist/consumer-integration/index.js.map +1 -1
  83. package/package.json +2 -2
@@ -0,0 +1,186 @@
1
+ import { CANONICAL_DOCS_SKILL, canonicalCallerWorkflow, canonicalConsumerIntegrationJson, canonicalDocsScripts, canonicalDocsScriptsDigest, canonicalManagedRoute, canonicalManagedState, digestBytes } from "./consumer-integration-assets.js";
2
+ import { assertConsumerIntegrationDesiredStateV1 } from "./consumer-integration-desired-state.js";
3
+ function desiredAtRecordedRepository(desired, record) {
4
+ const repository = record["repository"];
5
+ if (typeof repository !== "object" || repository === null || Array.isArray(repository)) {
6
+ return undefined;
7
+ }
8
+ const candidate = repository;
9
+ if (candidate.provider !== desired.repository.provider || candidate.id !== desired.repository.id) {
10
+ return undefined;
11
+ }
12
+ const recorded = { ...desired, repository: candidate };
13
+ try {
14
+ assertConsumerIntegrationDesiredStateV1(recorded);
15
+ return recorded;
16
+ }
17
+ catch {
18
+ return undefined;
19
+ }
20
+ }
21
+ function inputDigest(observation) {
22
+ return observation.state === "file" ? digestBytes(observation.bytes) : undefined;
23
+ }
24
+ function managedRouteDigest(observation) {
25
+ if (observation.state !== "file") {
26
+ return undefined;
27
+ }
28
+ const source = Buffer.from(observation.bytes).toString("utf8").replaceAll("\r\n", "\n");
29
+ const begin = source.indexOf("<!-- agent-teams-docs:route/v1 begin -->");
30
+ const endMarker = "<!-- agent-teams-docs:route/v1 end -->";
31
+ const end = source.indexOf(endMarker, begin);
32
+ return begin >= 0 && end >= begin
33
+ ? digestBytes(Buffer.from(source.slice(begin, end + endMarker.length), "utf8"))
34
+ : undefined;
35
+ }
36
+ function manifestScriptsDigest(observation, profilePath) {
37
+ if (observation.state !== "file") {
38
+ return undefined;
39
+ }
40
+ try {
41
+ const manifest = JSON.parse(Buffer.from(observation.bytes).toString("utf8"));
42
+ const scripts = typeof manifest["scripts"] === "object" && manifest["scripts"] !== null &&
43
+ !Array.isArray(manifest["scripts"])
44
+ ? manifest["scripts"]
45
+ : {};
46
+ const observed = Object.fromEntries(Object.keys(canonicalDocsScripts(profilePath)).map((name) => [
47
+ name,
48
+ scripts[name] ?? null
49
+ ]));
50
+ return digestBytes(Buffer.from(canonicalConsumerIntegrationJson(observed), "utf8"));
51
+ }
52
+ catch {
53
+ return undefined;
54
+ }
55
+ }
56
+ function matchesRecordedCatalogEvidence(input) {
57
+ const recordedDesired = desiredAtRecordedRepository(input.desired, input.record);
58
+ if (recordedDesired === undefined) {
59
+ return false;
60
+ }
61
+ const expected = canonicalManagedState({ ...recordedDesired, cohort: input.prior.cohort }, {
62
+ skillDigest: digestBytes(input.prior.skill),
63
+ callerWorkflowDigest: digestBytes(input.prior.callerWorkflow),
64
+ assetCatalogDigest: input.prior.cohort.assets.assetCatalogDigest,
65
+ transitionCatalogDigest: input.prior.cohort.assets.transitionCatalogDigest,
66
+ agentsRouteDigest: input.prior.agentsRouteDigest,
67
+ docsScriptsDigest: input.prior.docsScriptsDigest
68
+ });
69
+ return canonicalConsumerIntegrationJson(input.record) ===
70
+ canonicalConsumerIntegrationJson(JSON.parse(expected));
71
+ }
72
+ function matchesObservedCatalogEvidence(input) {
73
+ return input.snapshot.skill.state === "file" &&
74
+ Buffer.from(input.snapshot.skill.bytes).equals(Buffer.from(input.prior.skill)) &&
75
+ input.snapshot.callerWorkflow.state === "file" &&
76
+ Buffer.from(input.snapshot.callerWorkflow.bytes).equals(Buffer.from(input.prior.callerWorkflow)) &&
77
+ managedRouteDigest(input.snapshot.agents) === input.prior.agentsRouteDigest &&
78
+ manifestScriptsDigest(input.snapshot.packageManifest, input.desired.profilePath) ===
79
+ input.prior.docsScriptsDigest;
80
+ }
81
+ // oxlint-disable-next-line complexity
82
+ export function trustedPriorCohort(desired, snapshot, catalog) {
83
+ if (snapshot.managedState.state !== "file") {
84
+ return undefined;
85
+ }
86
+ try {
87
+ const stateSource = Buffer.from(snapshot.managedState.bytes).toString("utf8");
88
+ const record = JSON.parse(stateSource);
89
+ const { stateDigest, ...body } = record;
90
+ if (typeof stateDigest !== "string" || stateDigest !== digestBytes(Buffer.from(canonicalConsumerIntegrationJson({ domain: "agent-teams.docs-protocol.managed-state/v1", body }), "utf8")) || `${canonicalConsumerIntegrationJson(record)}\n` !== stateSource) {
91
+ return undefined;
92
+ }
93
+ const recordedDesired = desiredAtRecordedRepository(desired, record);
94
+ const currentSkill = Buffer.from(CANONICAL_DOCS_SKILL, "utf8");
95
+ const currentCaller = Buffer.from(canonicalCallerWorkflow(desired.cohort), "utf8");
96
+ const currentRouteDigest = digestBytes(Buffer.from(canonicalManagedRoute(desired.skillPath), "utf8"));
97
+ const currentScriptsDigest = canonicalDocsScriptsDigest(desired.profilePath);
98
+ const currentState = recordedDesired === undefined ? undefined : canonicalManagedState(recordedDesired, {
99
+ skillDigest: digestBytes(currentSkill),
100
+ callerWorkflowDigest: digestBytes(currentCaller),
101
+ assetCatalogDigest: catalog.catalogDigest,
102
+ transitionCatalogDigest: catalog.transitionCatalogDigest,
103
+ agentsRouteDigest: currentRouteDigest,
104
+ docsScriptsDigest: currentScriptsDigest
105
+ });
106
+ if (record["cohortId"] === desired.cohort.cohortId &&
107
+ desired.cohort.assets.skillDigest === digestBytes(currentSkill) &&
108
+ desired.cohort.assets.callerWorkflowDigest === digestBytes(currentCaller) &&
109
+ desired.cohort.assets.assetCatalogDigest === catalog.catalogDigest &&
110
+ desired.cohort.assets.transitionCatalogDigest === catalog.transitionCatalogDigest &&
111
+ currentState === stateSource && inputDigest(snapshot.skill) === digestBytes(currentSkill) &&
112
+ inputDigest(snapshot.callerWorkflow) === digestBytes(currentCaller) &&
113
+ managedRouteDigest(snapshot.agents) === currentRouteDigest &&
114
+ manifestScriptsDigest(snapshot.packageManifest, desired.profilePath) === currentScriptsDigest &&
115
+ snapshot.skill.state === "file" && snapshot.callerWorkflow.state === "file") {
116
+ return {
117
+ cohortId: desired.cohort.cohortId,
118
+ allowedTargetCohortIds: [],
119
+ schemas: desired.cohort.schemas,
120
+ skill: snapshot.skill.bytes,
121
+ callerWorkflow: snapshot.callerWorkflow.bytes,
122
+ agentsRouteDigest: currentRouteDigest,
123
+ docsScriptsDigest: currentScriptsDigest,
124
+ managedState: snapshot.managedState.bytes
125
+ };
126
+ }
127
+ const prior = catalog.directTargetBundles.find(({ cohort }) => cohort.cohortId === record["cohortId"]);
128
+ if (prior !== undefined && matchesRecordedCatalogEvidence({ desired, record, prior }) &&
129
+ matchesObservedCatalogEvidence({ desired, snapshot, prior })) {
130
+ return {
131
+ cohortId: prior.cohort.cohortId,
132
+ allowedTargetCohortIds: desired.cohort.upgradeFrom.includes(prior.cohort.cohortId) ||
133
+ prior.cohort.rollbackTo.includes(desired.cohort.cohortId)
134
+ ? [desired.cohort.cohortId]
135
+ : [],
136
+ schemas: prior.cohort.schemas,
137
+ skill: prior.skill,
138
+ callerWorkflow: prior.callerWorkflow,
139
+ agentsRouteDigest: prior.agentsRouteDigest,
140
+ docsScriptsDigest: prior.docsScriptsDigest,
141
+ managedState: snapshot.managedState.bytes
142
+ };
143
+ }
144
+ const technicalRecordedDesired = desiredAtRecordedRepository(desired, record);
145
+ const assets = record["assets"];
146
+ const sources = assets === undefined || technicalRecordedDesired === undefined ||
147
+ typeof record["cohortId"] !== "string" ? [] :
148
+ catalog.currentSourceExecutors.filter((candidate) => canonicalConsumerIntegrationJson(record["packages"]) ===
149
+ canonicalConsumerIntegrationJson(candidate.packages) &&
150
+ canonicalConsumerIntegrationJson(record["schemas"]) ===
151
+ canonicalConsumerIntegrationJson(candidate.schemas) &&
152
+ canonicalConsumerIntegrationJson(record["runtime"]) ===
153
+ canonicalConsumerIntegrationJson(candidate.runtime) &&
154
+ assets["skillDigest"] === candidate.skillDigest &&
155
+ assets["callerWorkflowDigest"] === candidate.callerWorkflowDigest &&
156
+ assets["assetCatalogDigest"] === candidate.assetCatalogDigest &&
157
+ assets["assetCatalogDigest"] === catalog.catalogDigest &&
158
+ assets["transitionCatalogDigest"] === catalog.transitionCatalogDigest &&
159
+ assets["agentsRouteDigest"] === candidate.agentsRouteDigest &&
160
+ assets["docsScriptsDigest"] === candidate.docsScriptsDigest &&
161
+ inputDigest(snapshot.skill) === candidate.skillDigest &&
162
+ inputDigest(snapshot.callerWorkflow) === candidate.callerWorkflowDigest &&
163
+ managedRouteDigest(snapshot.agents) === candidate.agentsRouteDigest &&
164
+ manifestScriptsDigest(snapshot.packageManifest, desired.profilePath) ===
165
+ candidate.docsScriptsDigest);
166
+ const source = sources.length === 1 ? sources[0] : undefined;
167
+ if (source === undefined || snapshot.skill.state !== "file" ||
168
+ snapshot.callerWorkflow.state !== "file") {
169
+ return undefined;
170
+ }
171
+ return {
172
+ cohortId: String(record["cohortId"]),
173
+ allowedTargetCohortIds: source.directTargetCohortIds,
174
+ schemas: source.schemas,
175
+ skill: snapshot.skill.bytes,
176
+ callerWorkflow: snapshot.callerWorkflow.bytes,
177
+ agentsRouteDigest: source.agentsRouteDigest,
178
+ docsScriptsDigest: source.docsScriptsDigest,
179
+ managedState: snapshot.managedState.bytes
180
+ };
181
+ }
182
+ catch {
183
+ return undefined;
184
+ }
185
+ }
186
+ //# sourceMappingURL=consumer-integration-prior-cohort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-integration-prior-cohort.js","sourceRoot":"","sources":["../../../../src/consumer-integration/application/policies/consumer-integration-prior-cohort.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,gCAAgC,EAChC,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAq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QAAQ,CAAC,KAAK,CAAC,KAAK;YAC3B,cAAc,EAAE,QAAQ,CAAC,cAAc,CAAC,KAAK;YAC7C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,YAAY,EAAE,QAAQ,CAAC,YAAY,CAAC,KAAK;SAC1C,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,31 @@
1
+ import type { KnownFileTransactionBarrierInspection, KnownFileTransactionPlanV1, KnownFileTransactionReceiptV1 } from "@agent-teams/engineering-foundation/mutation";
2
+ import type { ConsumerAssetCatalogV1 } from "../policies/consumer-integration-assets.js";
3
+ import type { ConsumerIntegrationDesiredStateV1, ConsumerIntegrationSnapshot } from "../../domain/model.js";
4
+ interface ConsumerIntegrationInput {
5
+ readonly desired: ConsumerIntegrationDesiredStateV1;
6
+ readonly root: string;
7
+ readonly snapshot: ConsumerIntegrationSnapshot;
8
+ }
9
+ export interface ConsumerIntegrationInputReader {
10
+ read(options: {
11
+ readonly consumerRoot: string;
12
+ readonly integrationProfilePath?: string;
13
+ }): Promise<ConsumerIntegrationInput>;
14
+ }
15
+ export interface ConsumerAssetCatalogReader {
16
+ read(): Promise<ConsumerAssetCatalogV1>;
17
+ }
18
+ export interface ConsumerIntegrationTransactionPort {
19
+ inspect(options: {
20
+ readonly consumerRoot: string;
21
+ }): Promise<KnownFileTransactionBarrierInspection>;
22
+ apply(options: {
23
+ readonly consumerRoot: string;
24
+ readonly plan: KnownFileTransactionPlanV1;
25
+ }): Promise<KnownFileTransactionReceiptV1>;
26
+ recover(options: {
27
+ readonly consumerRoot: string;
28
+ }): Promise<KnownFileTransactionReceiptV1>;
29
+ }
30
+ export {};
31
+ //# sourceMappingURL=consumer-integration-lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-integration-lifecycle.d.ts","sourceRoot":"","sources":["../../../../src/consumer-integration/application/ports/consumer-integration-lifecycle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qCAAqC,EACrC,0BAA0B,EAC1B,6BAA6B,EAC9B,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,KAAK,EACV,iCAAiC,EACjC,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAE/B,UAAU,wBAAwB;IAChC,QAAQ,CAAC,OAAO,EAAE,iCAAiC,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;CAChD;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,CAAC,OAAO,EAAE;QACZ,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;KAC1C,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;CACvC;AAED,MAAM,WAAW,0BAA0B;IACzC,IAAI,IAAI,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,kCAAkC;IACjD,OAAO,CAAC,OAAO,EAAE;QACf,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;KAC/B,GAAG,OAAO,CAAC,qCAAqC,CAAC,CAAC;IACnD,KAAK,CAAC,OAAO,EAAE;QACb,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,IAAI,EAAE,0BAA0B,CAAC;KAC3C,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;IAC3C,OAAO,CAAC,OAAO,EAAE;QACf,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;KAC/B,GAAG,OAAO,CAAC,6BAA6B,CAAC,CAAC;CAC5C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=consumer-integration-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-integration-lifecycle.js","sourceRoot":"","sources":["../../../../src/consumer-integration/application/ports/consumer-integration-lifecycle.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import type { ConsumerIntegrationDigest, ConsumerIntegrationFileObservation, ConsumerIntegrationIssue, QualifiedDocsCohortBindingV1 } from "../../domain/model.js";
2
+ export interface AgentsRoutePlanV1 {
3
+ readonly state: "absent" | "conflict" | "exact-current" | "known-prior";
4
+ readonly currentDigest: ConsumerIntegrationDigest;
5
+ readonly expectedDigest: ConsumerIntegrationDigest;
6
+ readonly postimage?: Uint8Array;
7
+ readonly issues: readonly ConsumerIntegrationIssue[];
8
+ }
9
+ export interface PnpmManifestPlanV1 {
10
+ readonly state: "conflict" | "exact-current" | "known-prior";
11
+ readonly currentDigest: ConsumerIntegrationDigest;
12
+ readonly expectedDigest: ConsumerIntegrationDigest;
13
+ readonly postimage?: Uint8Array;
14
+ readonly issues: readonly ConsumerIntegrationIssue[];
15
+ }
16
+ export interface AgentsRoutePlannerV1 {
17
+ plan(input: {
18
+ readonly observation: ConsumerIntegrationFileObservation;
19
+ readonly skillPath: string;
20
+ readonly knownPriorRouteDigest?: ConsumerIntegrationDigest;
21
+ }): AgentsRoutePlanV1;
22
+ }
23
+ export interface PnpmManifestPlannerV1 {
24
+ plan(input: {
25
+ readonly observation: ConsumerIntegrationFileObservation;
26
+ readonly profilePath: string;
27
+ readonly cohort: QualifiedDocsCohortBindingV1;
28
+ readonly knownPriorScriptsDigest?: ConsumerIntegrationDigest;
29
+ }): PnpmManifestPlanV1;
30
+ }
31
+ export interface ConsumerIntegrationPlanningPorts {
32
+ readonly agentsRoute: AgentsRoutePlannerV1;
33
+ readonly packageManifest: PnpmManifestPlannerV1;
34
+ }
35
+ //# sourceMappingURL=consumer-integration-planners.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-integration-planners.d.ts","sourceRoot":"","sources":["../../../../src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AAC;KAC9D,GAAG,kBAAkB,CAAC;CACxB;AAED,MAAM,WAAW,gCAAgC;IAC/C,QAAQ,CAAC,WAAW,EAAE,oBAAoB,CAAC;IAC3C,QAAQ,CAAC,eAAe,EAAE,qBAAqB,CAAC;CACjD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=consumer-integration-planners.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consumer-integration-planners.js","sourceRoot":"","sources":["../../../../src/consumer-integration/application/ports/consumer-integration-planners.ts"],"names":[],"mappings":""}
@@ -1,4 +1,5 @@
1
1
  import { compileKnownFileTransactionPlan } from "@agent-teams/engineering-foundation/mutation";
2
+ import type { ConsumerIntegrationPlanningPorts } from "../ports/consumer-integration-planners.js";
2
3
  import type { ConsumerIntegrationDesiredStateV1, ConsumerIntegrationPlanV1, ConsumerIntegrationSnapshot } from "../../domain/model.js";
3
4
  import { type ConsumerAssetCatalogV1, type KnownPriorCohortCatalogEntryV1 } from "../policies/consumer-integration-assets.js";
4
5
  export declare function compileConsumerIntegration(input: {
@@ -7,12 +8,8 @@ export declare function compileConsumerIntegration(input: {
7
8
  readonly assetCatalog?: ConsumerAssetCatalogV1;
8
9
  /** Unit-level compatibility input; production composition loads package assets. */
9
10
  readonly knownPriorCohorts?: readonly KnownPriorCohortCatalogEntryV1[];
10
- }): {
11
+ }, ports: ConsumerIntegrationPlanningPorts): {
11
12
  readonly plan: ConsumerIntegrationPlanV1;
12
13
  readonly mutationPlan?: ReturnType<typeof compileKnownFileTransactionPlan>;
13
14
  };
14
- export declare function planConsumerIntegration(input: {
15
- readonly desired: ConsumerIntegrationDesiredStateV1;
16
- readonly snapshot: ConsumerIntegrationSnapshot;
17
- }): ConsumerIntegrationPlanV1;
18
15
  //# sourceMappingURL=plan-consumer-integration.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plan-consumer-integration.d.ts","sourceRoot":"","sources":["../../../../src/consumer-integration/application/use-cases/plan-consumer-integration.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAEhC,MAAM,8CAA8C,CAAC;AAItD,OAAO,KAAK,EAEV,iCAAiC,EAIjC,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAWL,KAAK,sBAAsB,EAK3B,KAAK,8BAA8B,EACpC,MAAM,4CAA4C,CAAC;AAygBpD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,OAAO,EAAE,iCAAiC,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;IAC/C,QAAQ,CAAC,YAAY,CAAC,EAAE,sBAAsB,CAAC;IAC/C,mFAAmF;IACnF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,8BAA8B,EAAE,CAAC;CACxE,GAAG;IACF,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC;CAC5E,CAoHA;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE;IAC7C,QAAQ,CAAC,OAAO,EAAE,iCAAiC,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;CAChD,GAAG,yBAAyB,CAE5B"}
1
+ {"version":3,"file":"plan-consumer-integration.d.ts","sourceRoot":"","sources":["../../../../src/consumer-integration/application/use-cases/plan-consumer-integration.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,+BAA+B,EAEhC,MAAM,8CAA8C,CAAC;AAEtD,OAAO,KAAK,EACV,gCAAgC,EACjC,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAEV,iCAAiC,EAIjC,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAUL,KAAK,sBAAsB,EAK3B,KAAK,8BAA8B,EACpC,MAAM,4CAA4C,CAAC;AAmTpD,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,CAAC,OAAO,EAAE,iCAAiC,CAAC;IACpD,QAAQ,CAAC,QAAQ,EAAE,2BAA2B,CAAC;IAC/C,QAAQ,CAAC,YAAY,CAAC,EAAE,sBAAsB,CAAC;IAC/C,mFAAmF;IACnF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,SAAS,8BAA8B,EAAE,CAAC;CACxE,EAAE,KAAK,EAAE,gCAAgC,GAAG;IAC3C,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC;CAC5E,CAoHA"}
@@ -1,28 +1,8 @@
1
- /* oxlint-disable max-lines -- compiler phases remain colocated to keep the private mutation intent non-exported. */
2
1
  import { compileKnownFileTransactionPlan } from "@agent-teams/engineering-foundation/mutation";
3
- import { planAgentsRouteV1 } from "../../adapters/agents-route-adapter-v1.js";
4
- import { planPnpmManifestV1 } from "../../adapters/pnpm-manifest-adapter-v1.js";
5
- import { BUNDLED_KNOWN_PRIOR_COHORTS, BOOTSTRAP_KNOWN_PRIOR_CALLER_WORKFLOWS, BOOTSTRAP_KNOWN_PRIOR_DOCS_SKILLS, CANONICAL_DOCS_SKILL, canonicalCallerWorkflow, canonicalConsumerIntegrationJson, canonicalDocsScripts, canonicalDocsScriptsDigest, canonicalManagedRoute, canonicalManagedState, BUNDLED_CURRENT_SOURCE_EXECUTORS, describeCanonicalConsumerAssets, digestBytes, isBootstrapKnownPriorCallerWorkflow } from "../policies/consumer-integration-assets.js";
2
+ import { BUNDLED_KNOWN_PRIOR_COHORTS, BOOTSTRAP_KNOWN_PRIOR_CALLER_WORKFLOWS, BOOTSTRAP_KNOWN_PRIOR_DOCS_SKILLS, CANONICAL_DOCS_SKILL, canonicalCallerWorkflow, canonicalConsumerIntegrationJson, canonicalDocsScriptsDigest, canonicalManagedRoute, canonicalManagedState, BUNDLED_CURRENT_SOURCE_EXECUTORS, describeCanonicalConsumerAssets, digestBytes, isBootstrapKnownPriorCallerWorkflow } from "../policies/consumer-integration-assets.js";
6
3
  import { consumerIntegrationAuthorityGuards } from "../policies/consumer-integration-authority-guards.js";
7
4
  import { assertConsumerIntegrationDesiredStateV1 } from "../policies/consumer-integration-desired-state.js";
8
- function desiredAtRecordedRepository(desired, record) {
9
- const repository = record["repository"];
10
- if (typeof repository !== "object" || repository === null || Array.isArray(repository)) {
11
- return undefined;
12
- }
13
- const candidate = repository;
14
- if (candidate.provider !== desired.repository.provider || candidate.id !== desired.repository.id) {
15
- return undefined;
16
- }
17
- const recorded = { ...desired, repository: candidate };
18
- try {
19
- assertConsumerIntegrationDesiredStateV1(recorded);
20
- return recorded;
21
- }
22
- catch {
23
- return undefined;
24
- }
25
- }
5
+ import { trustedPriorCohort } from "../policies/consumer-integration-prior-cohort.js";
26
6
  function issue(code, subject, message) {
27
7
  return { code, severity: "error", subject, message };
28
8
  }
@@ -58,170 +38,6 @@ function assertSnapshotRuntime(snapshot) {
58
38
  }
59
39
  }
60
40
  }
61
- function managedRouteDigest(observation) {
62
- if (observation.state !== "file") {
63
- return undefined;
64
- }
65
- const source = Buffer.from(observation.bytes).toString("utf8").replaceAll("\r\n", "\n");
66
- const begin = source.indexOf("<!-- agent-teams-docs:route/v1 begin -->");
67
- const endMarker = "<!-- agent-teams-docs:route/v1 end -->";
68
- const end = source.indexOf(endMarker, begin);
69
- return begin >= 0 && end >= begin
70
- ? digestBytes(Buffer.from(source.slice(begin, end + endMarker.length), "utf8"))
71
- : undefined;
72
- }
73
- function manifestScriptsDigest(observation, profilePath) {
74
- if (observation.state !== "file") {
75
- return undefined;
76
- }
77
- try {
78
- const manifest = JSON.parse(Buffer.from(observation.bytes).toString("utf8"));
79
- const scripts = typeof manifest["scripts"] === "object" && manifest["scripts"] !== null &&
80
- !Array.isArray(manifest["scripts"])
81
- ? manifest["scripts"]
82
- : {};
83
- const observed = Object.fromEntries(Object.keys(canonicalDocsScripts(profilePath)).map((name) => [
84
- name,
85
- scripts[name] ?? null
86
- ]));
87
- return digestBytes(Buffer.from(canonicalConsumerIntegrationJson(observed), "utf8"));
88
- }
89
- catch {
90
- return undefined;
91
- }
92
- }
93
- function matchesRecordedCatalogEvidence(input) {
94
- const recordedDesired = desiredAtRecordedRepository(input.desired, input.record);
95
- if (recordedDesired === undefined) {
96
- return false;
97
- }
98
- const expected = canonicalManagedState({ ...recordedDesired, cohort: input.prior.cohort }, {
99
- skillDigest: digestBytes(input.prior.skill),
100
- callerWorkflowDigest: digestBytes(input.prior.callerWorkflow),
101
- assetCatalogDigest: input.prior.cohort.assets.assetCatalogDigest,
102
- transitionCatalogDigest: input.prior.cohort.assets.transitionCatalogDigest,
103
- agentsRouteDigest: input.prior.agentsRouteDigest,
104
- docsScriptsDigest: input.prior.docsScriptsDigest
105
- });
106
- return canonicalConsumerIntegrationJson(input.record) ===
107
- canonicalConsumerIntegrationJson(JSON.parse(expected));
108
- }
109
- function matchesObservedCatalogEvidence(input) {
110
- return input.snapshot.skill.state === "file" &&
111
- Buffer.from(input.snapshot.skill.bytes).equals(Buffer.from(input.prior.skill)) &&
112
- input.snapshot.callerWorkflow.state === "file" &&
113
- Buffer.from(input.snapshot.callerWorkflow.bytes).equals(Buffer.from(input.prior.callerWorkflow)) &&
114
- managedRouteDigest(input.snapshot.agents) === input.prior.agentsRouteDigest &&
115
- manifestScriptsDigest(input.snapshot.packageManifest, input.desired.profilePath) === input.prior.docsScriptsDigest;
116
- }
117
- // oxlint-disable-next-line complexity -- every evidence predicate must hold before source-executor trust.
118
- function trustedPriorCohort(desired, snapshot, catalog) {
119
- if (snapshot.managedState.state !== "file") {
120
- return undefined;
121
- }
122
- try {
123
- const stateSource = Buffer.from(snapshot.managedState.bytes).toString("utf8");
124
- const record = JSON.parse(stateSource);
125
- const { stateDigest, ...body } = record;
126
- if (typeof stateDigest !== "string" || stateDigest !== digestBytes(Buffer.from(canonicalConsumerIntegrationJson({ domain: "agent-teams.docs-protocol.managed-state/v1", body }), "utf8")) || `${canonicalConsumerIntegrationJson(record)}\n` !== stateSource) {
127
- return undefined;
128
- }
129
- const recordedDesired = desiredAtRecordedRepository(desired, record);
130
- const currentSkill = Buffer.from(CANONICAL_DOCS_SKILL, "utf8");
131
- const currentCaller = Buffer.from(canonicalCallerWorkflow(desired.cohort), "utf8");
132
- const currentRouteDigest = digestBytes(Buffer.from(canonicalManagedRoute(desired.skillPath), "utf8"));
133
- const currentScriptsDigest = canonicalDocsScriptsDigest(desired.profilePath);
134
- const currentState = recordedDesired === undefined ? undefined : canonicalManagedState(recordedDesired, {
135
- skillDigest: digestBytes(currentSkill),
136
- callerWorkflowDigest: digestBytes(currentCaller),
137
- assetCatalogDigest: catalog.catalogDigest,
138
- transitionCatalogDigest: catalog.transitionCatalogDigest,
139
- agentsRouteDigest: currentRouteDigest,
140
- docsScriptsDigest: currentScriptsDigest
141
- });
142
- if (record["cohortId"] === desired.cohort.cohortId &&
143
- desired.cohort.assets.skillDigest === digestBytes(currentSkill) &&
144
- desired.cohort.assets.callerWorkflowDigest === digestBytes(currentCaller) &&
145
- desired.cohort.assets.assetCatalogDigest === catalog.catalogDigest &&
146
- desired.cohort.assets.transitionCatalogDigest === catalog.transitionCatalogDigest &&
147
- currentState === stateSource && inputDigest(snapshot.skill) === digestBytes(currentSkill) &&
148
- inputDigest(snapshot.callerWorkflow) === digestBytes(currentCaller) &&
149
- managedRouteDigest(snapshot.agents) === currentRouteDigest &&
150
- manifestScriptsDigest(snapshot.packageManifest, desired.profilePath) === currentScriptsDigest &&
151
- snapshot.skill.state === "file" && snapshot.callerWorkflow.state === "file") {
152
- return {
153
- cohortId: desired.cohort.cohortId,
154
- allowedTargetCohortIds: [],
155
- schemas: desired.cohort.schemas,
156
- skill: snapshot.skill.bytes,
157
- callerWorkflow: snapshot.callerWorkflow.bytes,
158
- agentsRouteDigest: currentRouteDigest,
159
- docsScriptsDigest: currentScriptsDigest,
160
- managedState: snapshot.managedState.bytes
161
- };
162
- }
163
- const prior = catalog.directTargetBundles.find(({ cohort }) => cohort.cohortId === record["cohortId"]);
164
- if (prior !== undefined && matchesRecordedCatalogEvidence({ desired, record, prior }) &&
165
- matchesObservedCatalogEvidence({ desired, snapshot, prior })) {
166
- return {
167
- cohortId: prior.cohort.cohortId,
168
- allowedTargetCohortIds: desired.cohort.upgradeFrom.includes(prior.cohort.cohortId) ||
169
- prior.cohort.rollbackTo.includes(desired.cohort.cohortId)
170
- ? [desired.cohort.cohortId]
171
- : [],
172
- schemas: prior.cohort.schemas,
173
- skill: prior.skill,
174
- callerWorkflow: prior.callerWorkflow,
175
- agentsRouteDigest: prior.agentsRouteDigest,
176
- docsScriptsDigest: prior.docsScriptsDigest,
177
- managedState: snapshot.managedState.bytes
178
- };
179
- }
180
- const technicalRecordedDesired = desiredAtRecordedRepository(desired, record);
181
- const assets = record["assets"];
182
- const sources = assets === undefined || technicalRecordedDesired === undefined ||
183
- typeof record["cohortId"] !== "string" ? [] :
184
- catalog.currentSourceExecutors.filter((candidate) => canonicalConsumerIntegrationJson(record["packages"]) ===
185
- canonicalConsumerIntegrationJson(candidate.packages) &&
186
- canonicalConsumerIntegrationJson(record["schemas"]) ===
187
- canonicalConsumerIntegrationJson(candidate.schemas) &&
188
- canonicalConsumerIntegrationJson(record["runtime"]) ===
189
- canonicalConsumerIntegrationJson(candidate.runtime) &&
190
- assets["skillDigest"] === candidate.skillDigest &&
191
- assets["callerWorkflowDigest"] === candidate.callerWorkflowDigest &&
192
- assets["assetCatalogDigest"] === candidate.assetCatalogDigest &&
193
- assets["assetCatalogDigest"] === catalog.catalogDigest &&
194
- assets["transitionCatalogDigest"] === catalog.transitionCatalogDigest &&
195
- assets["agentsRouteDigest"] === candidate.agentsRouteDigest &&
196
- assets["docsScriptsDigest"] === candidate.docsScriptsDigest &&
197
- inputDigest(snapshot.skill) === candidate.skillDigest &&
198
- inputDigest(snapshot.callerWorkflow) === candidate.callerWorkflowDigest &&
199
- managedRouteDigest(snapshot.agents) === candidate.agentsRouteDigest &&
200
- manifestScriptsDigest(snapshot.packageManifest, desired.profilePath) ===
201
- candidate.docsScriptsDigest);
202
- const source = sources.length === 1 ? sources[0] : undefined;
203
- if (source === undefined || snapshot.skill.state !== "file" ||
204
- snapshot.callerWorkflow.state !== "file") {
205
- return undefined;
206
- }
207
- return {
208
- cohortId: String(record["cohortId"]),
209
- allowedTargetCohortIds: source.directTargetCohortIds,
210
- schemas: source.schemas,
211
- skill: snapshot.skill.bytes,
212
- callerWorkflow: snapshot.callerWorkflow.bytes,
213
- agentsRouteDigest: source.agentsRouteDigest,
214
- docsScriptsDigest: source.docsScriptsDigest,
215
- managedState: snapshot.managedState.bytes
216
- };
217
- }
218
- catch {
219
- return undefined;
220
- }
221
- }
222
- function inputDigest(observation) {
223
- return observation.state === "file" ? digestBytes(observation.bytes) : undefined;
224
- }
225
41
  function fullAsset(input) {
226
42
  const expectedDigest = digestBytes(input.postimage);
227
43
  if (input.observation.state === "absent") {
@@ -425,7 +241,7 @@ function planFullAssets(input) {
425
241
  })
426
242
  ];
427
243
  }
428
- export function compileConsumerIntegration(input) {
244
+ export function compileConsumerIntegration(input, ports) {
429
245
  assertConsumerIntegrationDesiredStateV1(input.desired);
430
246
  assertSnapshotRuntime(input.snapshot);
431
247
  const desired = input.desired;
@@ -437,14 +253,14 @@ export function compileConsumerIntegration(input) {
437
253
  });
438
254
  const prior = trustedPriorCohort(desired, input.snapshot, assetCatalog);
439
255
  const issues = [...cohortIssues(desired, prior, assetCatalog)];
440
- const manifest = planPnpmManifestV1({
256
+ const manifest = ports.packageManifest.plan({
441
257
  observation: input.snapshot.packageManifest,
442
258
  profilePath: desired.profilePath,
443
259
  cohort: desired.cohort,
444
260
  ...(prior === undefined ? {} : { knownPriorScriptsDigest: prior.docsScriptsDigest })
445
261
  });
446
262
  issues.push(...manifest.issues);
447
- const route = planAgentsRouteV1({
263
+ const route = ports.agentsRoute.plan({
448
264
  observation: input.snapshot.agents,
449
265
  skillPath: desired.skillPath,
450
266
  ...(prior === undefined ? {} : { knownPriorRouteDigest: prior.agentsRouteDigest })
@@ -531,7 +347,4 @@ export function compileConsumerIntegration(input) {
531
347
  ...(mutationPlan === undefined ? {} : { mutationPlan })
532
348
  });
533
349
  }
534
- export function planConsumerIntegration(input) {
535
- return compileConsumerIntegration(input).plan;
536
- }
537
350
  //# sourceMappingURL=plan-consumer-integration.js.map