@agentproto/catalog-sync 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,21 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Jeremy André and agentproto contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,8 @@ import { CatalogGenerator } from './types.js';
2
2
  export { CatalogSource, GeneratedFiles, GeneratorContext, defineGenerator } from './types.js';
3
3
  export { RunGeneratorsOptions, RunGeneratorsResult, runGenerators } from './runner.js';
4
4
  export { llmOpenRouterGenerator } from './generators/llm-openrouter.js';
5
+ export { CatalogFileDiff, RefreshableSource, ReviewedRefreshOptions, ReviewedRefreshResult, SourceRefreshResult, refreshSources, reviewedRefresh } from './refresh-workflow.js';
6
+ export { OPENAI_LLM_SOURCE, OPENAI_SOURCES } from './sources/openai.js';
5
7
 
6
8
  /**
7
9
  * voice-elevenlabs generator — reads the ElevenLabs /v1/voices snapshot and
package/dist/index.mjs CHANGED
@@ -603,7 +603,165 @@ var imageReplicate = defineGenerator({
603
603
  return { [outputPath]: lines.join("\n") };
604
604
  }
605
605
  });
606
+ var __dirname2 = dirname(fileURLToPath(import.meta.url));
607
+ function catalogSyncDir2() {
608
+ return resolve(__dirname2, "..");
609
+ }
610
+ function snapshotPath2(id) {
611
+ return join(catalogSyncDir2(), "snapshots", `${id}.json`);
612
+ }
613
+ function repoRoot2() {
614
+ let dir = catalogSyncDir2();
615
+ for (let i = 0; i < 12; i++) {
616
+ if (existsSync(join(dir, "pnpm-workspace.yaml"))) return dir;
617
+ const parent = dirname(dir);
618
+ if (parent === dir) break;
619
+ dir = parent;
620
+ }
621
+ return dirname(dirname(catalogSyncDir2()));
622
+ }
623
+ function readIfExists2(absPath) {
624
+ if (!existsSync(absPath)) return void 0;
625
+ return readFileSync(absPath, "utf8");
626
+ }
627
+ function resolveHeaders2(headers) {
628
+ const out = {};
629
+ const missing = [];
630
+ if (!headers) return { headers: out, missing };
631
+ for (const [key, value] of Object.entries(headers)) {
632
+ out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name) => {
633
+ const v = process.env[name];
634
+ if (v === void 0 || v === "") {
635
+ missing.push(name);
636
+ return "";
637
+ }
638
+ return v;
639
+ });
640
+ }
641
+ return { headers: out, missing };
642
+ }
643
+ async function refreshSources(sources2, opts) {
644
+ const results = [];
645
+ const fetchImpl = opts.fetchImpl ?? fetch;
646
+ for (const { source, refreshable, notes } of sources2) {
647
+ if (!opts.refresh) {
648
+ results.push({
649
+ id: source.id,
650
+ url: source.url,
651
+ refreshed: false,
652
+ notes: "Offline mode: using committed snapshot."
653
+ });
654
+ continue;
655
+ }
656
+ if (!refreshable) {
657
+ results.push({
658
+ id: source.id,
659
+ url: source.url,
660
+ refreshed: false,
661
+ skipped: true,
662
+ notes: notes ?? "Source is not refreshable."
663
+ });
664
+ continue;
665
+ }
666
+ const { headers, missing } = resolveHeaders2(source.headers);
667
+ if (missing.length > 0) {
668
+ results.push({
669
+ id: source.id,
670
+ url: source.url,
671
+ refreshed: false,
672
+ error: `Missing env vars: ${missing.join(", ")}`
673
+ });
674
+ continue;
675
+ }
676
+ try {
677
+ const res = await fetchImpl(source.url, {
678
+ method: source.method ?? "GET",
679
+ headers,
680
+ ...source.body !== void 0 ? { body: JSON.stringify(source.body) } : {}
681
+ });
682
+ if (!res.ok) {
683
+ results.push({
684
+ id: source.id,
685
+ url: source.url,
686
+ refreshed: false,
687
+ error: `${res.status} ${res.statusText}`
688
+ });
689
+ continue;
690
+ }
691
+ const text = await res.text();
692
+ const parsed = JSON.parse(text);
693
+ mkdirSync(dirname(snapshotPath2(source.id)), { recursive: true });
694
+ writeFileSync(
695
+ snapshotPath2(source.id),
696
+ `${JSON.stringify(parsed, null, 2)}
697
+ `,
698
+ "utf8"
699
+ );
700
+ results.push({
701
+ id: source.id,
702
+ url: source.url,
703
+ refreshed: true,
704
+ notes: "Snapshot updated from live source."
705
+ });
706
+ } catch (err) {
707
+ results.push({
708
+ id: source.id,
709
+ url: source.url,
710
+ refreshed: false,
711
+ error: err instanceof Error ? err.message : String(err)
712
+ });
713
+ }
714
+ }
715
+ return results;
716
+ }
717
+ async function reviewedRefresh(gens, refreshableSources, opts) {
718
+ const sourceResults = await refreshSources(refreshableSources, opts);
719
+ const files = {};
720
+ for (const gen of gens) {
721
+ const ctx = {
722
+ refresh: opts.refresh,
723
+ async fetchSource(src) {
724
+ const path = snapshotPath2(src.id);
725
+ const existing = readIfExists2(path);
726
+ if (existing !== void 0) return JSON.parse(existing);
727
+ throw new Error(
728
+ `catalog-sync: no committed snapshot for source "${src.id}" (${path}).`
729
+ );
730
+ }
731
+ };
732
+ const out = await gen.generate(ctx);
733
+ Object.assign(files, out);
734
+ }
735
+ const root = repoRoot2();
736
+ const diffs = [];
737
+ const changed = [];
738
+ for (const [relPath, after] of Object.entries(files)) {
739
+ const abs = join(root, relPath);
740
+ const before = readIfExists2(abs);
741
+ const isChanged = before !== after;
742
+ diffs.push({ path: relPath, before, after, changed: isChanged });
743
+ if (isChanged) {
744
+ changed.push(relPath);
745
+ if (opts.write) {
746
+ mkdirSync(dirname(abs), { recursive: true });
747
+ writeFileSync(abs, after, "utf8");
748
+ }
749
+ }
750
+ }
751
+ return { files, changed, diffs, sources: sourceResults };
752
+ }
753
+
754
+ // src/sources/openai.ts
755
+ var OPENAI_LLM_SOURCE = {
756
+ source: {
757
+ id: "llm-openai",
758
+ url: "https://openai.com/api/pricing"
759
+ },
760
+ refreshable: false,
761
+ notes: "OpenAI has no stable machine-readable pricing endpoint. Pricing in @agentproto/model-catalog is committed manually from openai.com/api/pricing and verified against independent aggregators where possible. Automated refresh is disabled to avoid scraping or fabricating prices."
762
+ };
763
+ var OPENAI_SOURCES = [OPENAI_LLM_SOURCE];
606
764
 
607
- export { defineGenerator, imageReplicate, llmOpenRouterGenerator, runGenerators, voiceElevenlabs, voiceMinimax };
765
+ export { OPENAI_LLM_SOURCE, OPENAI_SOURCES, defineGenerator, imageReplicate, llmOpenRouterGenerator, refreshSources, reviewedRefresh, runGenerators, voiceElevenlabs, voiceMinimax };
608
766
  //# sourceMappingURL=index.mjs.map
609
767
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts","../src/runner.ts","../src/generators/llm-openrouter.ts","../src/generators/serialize-voices.ts","../src/generators/voice-elevenlabs.ts","../src/generators/voice-minimax.ts","../src/generators/image-replicate.ts"],"names":["__dirname","OUTPUT_PATH"],"mappings":";;;;;;;;;;;;;AAsDO,SAAS,gBAAgB,CAAA,EAAuC;AACrE,EAAA,OAAO,CAAA;AACT;AC7CA,IAAMA,WAAA,GAAY,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAQxD,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CAAM,IAAA,CAAK,IAAI,CAAA,EAAE;AAAA,EAC1C;AACF,CAAC","file":"index.mjs","sourcesContent":["/**\n * catalog-sync generator contract.\n *\n * FROZEN — a sibling agent builds provider generators against this surface.\n * Do not change field names, shapes, or the `defineGenerator` signature\n * without coordinating. Adding new generators is the expected extension\n * path; editing this file is not.\n */\n\nexport interface CatalogSource {\n id: string\n url: string\n /** HTTP method for the live (`--refresh`) fetch. Default `\"GET\"`. */\n method?: \"GET\" | \"POST\"\n /**\n * Request headers for the live fetch. A value may embed `env:VAR_NAME`\n * tokens, resolved from `process.env` at fetch time (e.g.\n * `{ \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" }` or\n * `{ Authorization: \"Bearer env:MINIMAX_API_KEY\" }`). If any referenced env\n * var is unset, the source is treated as un-refreshable — the committed\n * snapshot is reused rather than fetched without auth. Offline reads\n * (default, no `--refresh`) ignore headers entirely.\n */\n headers?: Record<string, string>\n /** JSON request body for POST sources (e.g. MiniMax `get_voice`). */\n body?: unknown\n}\n\nexport interface GeneratorContext {\n /**\n * Reads the pinned snapshot at `snapshots/<src.id>.json`; if missing and\n * `refresh=true`, fetches `src.url` and writes the snapshot. Returns\n * parsed JSON.\n *\n * Offline by default: when no snapshot exists and `refresh` is false this\n * throws — generators MUST be runnable without network access so CI and\n * tests are deterministic. The only network path is behind `--refresh`.\n */\n fetchSource(src: CatalogSource): Promise<unknown>\n refresh: boolean\n}\n\n/** Repo-relative path → TS source text. */\nexport type GeneratedFiles = Record<string, string>\n\nexport interface CatalogGenerator {\n /** e.g. \"llm:openrouter\" */\n name: string\n modality: \"llm\" | \"image\" | \"video\" | \"audio\" | \"voice\"\n sources: CatalogSource[]\n generate(ctx: GeneratorContext): Promise<GeneratedFiles>\n}\n\n/** Identity helper — lets a generator module declare itself with type inference. */\nexport function defineGenerator(g: CatalogGenerator): CatalogGenerator {\n return g\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\n/**\n * The catalog-sync package directory. Resolves the same way whether the\n * module is loaded from `src/` (vitest, type-checking) or `dist/` (built) —\n * both sit one level below the package root, so walking up one directory\n * from this file lands on `packages/catalog-sync/`.\n */\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\n/** Absolute path to a committed/pinned source snapshot. */\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\n/**\n * The monorepo root. Resolved by walking up from the catalog-sync package\n * until `pnpm-workspace.yaml` is found. Generated-file paths in\n * {@link GeneratedFiles} are repo-relative and are resolved against this.\n */\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n // Fallback: catalog-sync lives at <root>/packages/catalog-sync.\n return dirname(dirname(catalogSyncDir()))\n}\n\n/** Reads an existing file as UTF-8, or returns undefined when absent. */\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\n/**\n * Resolve `env:VAR_NAME` tokens inside header values from `process.env`.\n * Returns the materialized headers plus the names of any referenced env vars\n * that are unset — the caller uses `missing` to decide whether the source can\n * be refreshed (we never fetch an authed endpoint without its key).\n */\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\nexport interface RunGeneratorsOptions {\n /** When true, missing snapshots are fetched from their pinned `url`. */\n refresh: boolean\n /** When true, generated files are written to disk at their repo-relative path. */\n write: boolean\n}\n\nexport interface RunGeneratorsResult {\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from what is on disk. */\n changed: string[]\n}\n\n/**\n * Runs each generator, gathering its emitted files, then (optionally) writes\n * them. `changed` is ALWAYS computed — it is the diff of generated content\n * vs disk — so `--check` (write=false) can surface drift without mutating\n * anything. Writes only happen when `write=true` AND a path differs.\n */\nexport async function runGenerators(\n gens: CatalogGenerator[],\n opts: RunGeneratorsOptions\n): Promise<RunGeneratorsResult> {\n const files: GeneratedFiles = {}\n\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n\n // Offline path (default): reuse the committed snapshot; error if none.\n if (!opts.refresh) {\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" ` +\n `(${path}), and --refresh is not set. Run ` +\n `\\`catalog-sync generate --refresh\\` to fetch ${src.url}.`\n )\n }\n\n // --refresh: force a live re-fetch (do NOT short-circuit on an existing\n // snapshot — refreshing is the whole point). Auth headers may embed\n // `env:VAR` tokens; if a referenced var is unset we can't authenticate,\n // so reuse the committed snapshot rather than fetch unauthenticated.\n const { headers, missing } = resolveHeaders(src.headers)\n if (missing.length > 0) {\n if (existing !== undefined) {\n process.stderr.write(\n `catalog-sync: skipping refresh of \"${src.id}\" — missing env ` +\n `${missing.join(\", \")}; reusing committed snapshot.\\n`\n )\n return JSON.parse(existing)\n }\n throw new Error(\n `catalog-sync: cannot refresh \"${src.id}\" — missing env ` +\n `${missing.join(\", \")} and no committed snapshot.`\n )\n }\n const res = await fetch(src.url, {\n method: src.method ?? \"GET\",\n headers,\n ...(src.body !== undefined\n ? { body: JSON.stringify(src.body) }\n : {}),\n })\n if (!res.ok) {\n throw new Error(\n `catalog-sync: fetch ${src.url} failed: ${res.status} ${res.statusText}`\n )\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, `${JSON.stringify(parsed, null, 2)}\\n`, \"utf8\")\n return parsed\n },\n }\n\n const out = await gen.generate(ctx)\n for (const [path, content] of Object.entries(out)) {\n files[path] = content\n }\n }\n\n const root = repoRoot()\n const changed: string[] = []\n for (const [relPath, content] of Object.entries(files)) {\n const abs = join(root, relPath)\n const existing = readIfExists(abs)\n if (existing !== content) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, content, \"utf8\")\n }\n }\n }\n\n return { files, changed }\n}\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\n\n/**\n * PINNED source. The OpenRouter `/api/v1/models` payload lists every route\n * the router exposes with per-token USD pricing. We never fetch it at build\n * or test time — only behind `--refresh`, which writes\n * `snapshots/llm-openrouter.json` so the next offline run is deterministic.\n */\nconst OPENROUTER_MODELS_URL = \"https://openrouter.ai/api/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/openrouter-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// OpenRouter prices are STRINGS of USD-per-token (e.g. \"0.000003\" = $3/1M).\n// `input_cache_read` / `input_cache_write` are optional and only present for\n// models that support prompt caching (Anthropic, etc.). These are the REAL\n// OpenRouter field names (verified against the live /v1/models payload) — an\n// earlier draft used `cache_read`/`cache_write`, which never matched, so cache\n// multipliers were silently always absent. passthrough() keeps the other live\n// keys (web_search, image, audio, internal_reasoning, input_cache_write_1h)\n// forward-compatible without a regenerate — we only read what we model.\n\nconst PricingSchema = z\n .object({\n prompt: z.string().optional(),\n completion: z.string().optional(),\n input_cache_read: z.string().optional(),\n input_cache_write: z.string().optional(),\n })\n .passthrough()\n\nconst ModelSchema = z\n .object({\n id: z.string(),\n pricing: PricingSchema.optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(ModelSchema),\n})\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n// Drop-in for `packages/model-catalog/src/llm/openrouter-routes.generated.ts`.\n// Structurally identical to LLMPricing — inputPer1M / outputPer1M in USD per\n// 1M tokens, plus cacheReadMultiplier / cacheWriteMultiplier WHEN the source\n// carries cache_read / cache_write. The existing committed file omits cache\n// fields; this generator emits them when present (per the P3 spec: \"plus\n// cache fields if the source has them\"). Fields are optional on LLMPricing,\n// so the output remains drop-in compatible.\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n cacheWriteMultiplier?: number\n vendor: string\n provider: \"openrouter\"\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the per-token × 1e6 product. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/** Convert a per-token USD string to USD-per-1M-tokens, or undefined if unpriced. */\nfunction per1m(tokenPrice: string | undefined): number | undefined {\n if (tokenPrice === undefined) return undefined\n const n = Number(tokenPrice)\n if (!Number.isFinite(n)) return undefined\n return round6(n * 1_000_000)\n}\n\n/** Shortest faithful decimal string (matches existing file: 1, 0.5, 0.7448, 1.25). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/** Vendor slug = first segment of the OpenRouter route id (`vendor/model`). */\nfunction vendorOf(id: string): string {\n if (!id.includes(\"/\")) return id\n return id.split(\"/\")[0] ?? id\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.cacheWriteMultiplier !== undefined) {\n fields.push(`cacheWriteMultiplier: ${fmt(e.cacheWriteMultiplier)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeFile(entries: Record<string, LLMPricingEntry>): string {\n const ids = Object.keys(entries).sort()\n const providers = Array.from(new Set(ids.map(vendorOf))).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:openrouter).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${OPENROUTER_MODELS_URL}`,\n \"// Pricing carries provider USD (inputPer1M / outputPer1M) plus cache\",\n \"// multipliers (cacheReadMultiplier / cacheWriteMultiplier) derived from the\",\n \"// source's input_cache_read / input_cache_write per-token fields when present.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n \"export const OPENROUTER_ROUTES: Record<string, LLMPricing> = {\",\n ]\n for (const id of ids) {\n lines.push(` ${JSON.stringify(id)}: ${serializeEntry(entries[id]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/** Provider slugs treated as OpenRouter routes by the picker. */\")\n lines.push(\"export const OPENROUTER_PROVIDERS: readonly string[] = [\")\n for (const p of providers) {\n lines.push(` ${JSON.stringify(p)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:openrouter: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, LLMPricingEntry> = {}\n for (const model of parsed.data) {\n const pricing = model.pricing\n if (!pricing) continue\n const inputPer1M = per1m(pricing.prompt)\n const outputPer1M = per1m(pricing.completion)\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n // Skip unpriced routes (e.g. openrouter/auto, which carries \"0\" pricing).\n if (inputPer1M === 0 && outputPer1M === 0) continue\n\n const entry: LLMPricingEntry = {\n inputPer1M,\n outputPer1M,\n vendor: vendorOf(model.id),\n provider: \"openrouter\",\n }\n\n const cacheReadPer1M = per1m(pricing.input_cache_read)\n const cacheWritePer1M = per1m(pricing.input_cache_write)\n if (cacheReadPer1M !== undefined && cacheReadPer1M > 0 && inputPer1M > 0) {\n entry.cacheReadMultiplier = round6(cacheReadPer1M / inputPer1M)\n }\n if (cacheWritePer1M !== undefined && cacheWritePer1M > 0 && inputPer1M > 0) {\n entry.cacheWriteMultiplier = round6(cacheWritePer1M / inputPer1M)\n }\n\n entries[model.id] = entry\n }\n\n return { [OUTPUT_PATH]: serializeFile(entries) }\n}\n\nconst sources = [{ id: \"llm-openrouter\", url: OPENROUTER_MODELS_URL }]\n\nexport const llmOpenRouterGenerator = defineGenerator({\n name: \"llm:openrouter\",\n modality: \"llm\",\n sources,\n generate,\n})\n","/**\n * Shared CatalogVoice[] → TS-source serializer for the voice generators.\n *\n * The mapping (raw provider JSON → CatalogVoice) lives in\n * `@agentproto/model-catalog/providers` so build time and runtime share it;\n * this module only turns the mapped voices into a committed `*.generated.ts`.\n * Field emit order is fixed (matches the historical generator output) so the\n * generated file stays diff-stable across runs.\n */\n\nimport type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"\n\nfunction serializeVoice(v: CatalogVoice): string {\n const lines: string[] = [\" {\"]\n lines.push(` catalogId: ${JSON.stringify(v.catalogId)},`)\n lines.push(` providerVoiceId: ${JSON.stringify(v.providerVoiceId)},`)\n lines.push(` provider: ${JSON.stringify(v.provider)},`)\n lines.push(` label: ${JSON.stringify(v.label)},`)\n lines.push(` description: ${JSON.stringify(v.description)},`)\n lines.push(` gender: ${JSON.stringify(v.gender)},`)\n lines.push(` primaryLanguage: ${JSON.stringify(v.primaryLanguage)},`)\n lines.push(\n ` supportedLanguages: [${v.supportedLanguages.map(l => JSON.stringify(l)).join(\", \")}],`,\n )\n if (v.quality !== undefined) lines.push(` quality: ${JSON.stringify(v.quality)},`)\n if (v.featured !== undefined) lines.push(` featured: ${v.featured},`)\n if (v.samplePath !== undefined) lines.push(` samplePath: ${JSON.stringify(v.samplePath)},`)\n if (v.age !== undefined) lines.push(` age: ${JSON.stringify(v.age)},`)\n lines.push(\" },\")\n return lines.join(\"\\n\")\n}\n\n/**\n * Render a full generated voice module.\n *\n * @param generatorName e.g. `voice:elevenlabs` (goes in the header comment)\n * @param exportName e.g. `ELEVENLABS_VOICES`\n * @param voices mapped voices, in emit order\n */\nexport function serializeVoiceModule(\n generatorName: string,\n exportName: string,\n voices: readonly CatalogVoice[],\n): string {\n const lines: string[] = [\n `// Generated by @agentproto/catalog-sync generator ${generatorName}`,\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n 'import type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"',\n \"\",\n `export const ${exportName}: readonly CatalogVoice[] = [`,\n ]\n for (const v of voices) lines.push(serializeVoice(v))\n lines.push(\"] as const\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n","/**\n * voice-elevenlabs generator — reads the ElevenLabs /v1/voices snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n ElevenLabsVoicesSnapshotSchema,\n mapElevenLabsVoices,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (and is the single,\n// dist-safe reader; generators never touch the filesystem themselves).\nexport const ELEVENLABS_SOURCE: CatalogSource = {\n id: \"voice-elevenlabs\",\n url: \"https://api.elevenlabs.io/v1/voices\",\n // Live refresh needs the account key; offline reads ignore this.\n headers: { \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-elevenlabs.generated.ts\"\n\nexport const voiceElevenlabs: CatalogGenerator = defineGenerator({\n name: \"voice:elevenlabs\",\n modality: \"voice\",\n sources: [ELEVENLABS_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = ElevenLabsVoicesSnapshotSchema.parse(\n await ctx.fetchSource(ELEVENLABS_SOURCE),\n )\n const voices = mapElevenLabsVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:elevenlabs\",\n \"ELEVENLABS_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * voice-minimax generator — reads the MiniMax /v1/get_voice snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n mapMinimaxVoices,\n MinimaxVoicesSnapshotSchema,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\nexport const MINIMAX_SOURCE: CatalogSource = {\n id: \"voice-minimax\",\n url: \"https://api.minimax.io/v1/get_voice\",\n // get_voice is a POST; live refresh needs the account key (Bearer). Without\n // MINIMAX_API_KEY set, the framework reuses the committed snapshot.\n method: \"POST\",\n headers: {\n Authorization: \"Bearer env:MINIMAX_API_KEY\",\n \"Content-Type\": \"application/json\",\n },\n body: { voice_type: \"system\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-minimax.generated.ts\"\n\nexport const voiceMinimax: CatalogGenerator = defineGenerator({\n name: \"voice:minimax\",\n modality: \"voice\",\n sources: [MINIMAX_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = MinimaxVoicesSnapshotSchema.parse(\n await ctx.fetchSource(MINIMAX_SOURCE),\n )\n const voices = mapMinimaxVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:minimax\",\n \"MINIMAX_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * image-replicate generator — reads a curated Replicate image-models\n * snapshot and emits ImageModelDefinition[]-shaped generated TS entries.\n *\n * Mirrors the shape from packages/model-catalog/src/image/catalog.ts exactly.\n * Provider-native ids only; no product-specific aliases.\n */\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\n\n// ── Replicate snapshot shapes ───────────────────────────────────────────\n\ninterface ReplicateOpenApiSchema {\n input: { type: string; properties: Record<string, { type: string; items?: { type: string }; format?: string }> }\n output: { type: string; items?: { type: string; format?: string }; format?: string }\n}\n\ninterface ReplicateLatestVersion {\n id: string\n created_at: string\n openapi_schema: ReplicateOpenApiSchema\n}\n\ninterface ReplicateModel {\n owner: string\n name: string\n description: string\n visibility: string\n run_count: number\n cover_image_url: string | null\n latest_version: ReplicateLatestVersion\n}\n\ninterface ReplicateSnapshot {\n _meta: Record<string, unknown>\n models: ReplicateModel[]\n}\n\n// ── ImageModelDefinition mirror (from packages/model-catalog/src/image/catalog.ts) ──\n\ninterface ImageModelPricing {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n billingUnit: \"per_image\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\ninterface ImageModelCapabilities {\n generate: boolean\n edit: boolean\n upscale?: boolean\n}\n\ninterface ImageModelReferenceImages {\n supported: boolean\n fieldName: \"image_input\" | \"input_images\" | \"input_image\" | \"none\"\n maxCount: number\n singular: boolean\n}\n\ninterface ImageModelAspectRatio {\n supported: string[]\n default: string\n}\n\ninterface ImageModelEntry {\n id: string\n name: string\n providerId: string\n provider: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n pricing: ImageModelPricing\n description: string\n agentVisible: boolean\n triggerWord?: string\n}\n\n// ── Pricing (hand-authored, mirrors model-catalog) ──────────────────────\n\ninterface PricingRecord {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\nconst PRICING: Record<string, PricingRecord> = {\n \"nano-banana-pro\": { costPerImage: 0.15, costTier: \"high\", baseCost: 0.15, creditCost: 10 },\n \"nano-banana-2\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 5 },\n \"nano-banana\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-2-dev\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"flux-kontext-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-kontext-max\": { costPerImage: 0.08, costTier: \"medium\", baseCost: 0.08, creditCost: 8 },\n \"flux-1.1-pro-ultra\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 8 },\n \"seedream-4\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"recraft-v3\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"image-01\": { costPerImage: 0.02, costTier: \"low\", baseCost: 0.02, creditCost: 2 },\n \"gpt-image-1\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"ideogram-v3-turbo\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 4 },\n \"flux-1.1-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n}\n\n// Models visible to agents (the active generation ones)\nconst AGENT_VISIBLE = new Set([\n \"nano-banana-pro\",\n \"nano-banana-2\",\n \"nano-banana\",\n \"flux-2-dev\",\n \"flux-kontext-pro\",\n \"flux-kontext-max\",\n \"flux-1.1-pro-ultra\",\n \"seedream-4\",\n \"recraft-v3\",\n \"image-01\",\n \"gpt-image-1\",\n \"ideogram-v3-turbo\",\n])\n\nconst ASPECT_RATIOS_DEFAULT: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_WIDE: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\", \"4:5\", \"5:4\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_ULTRA: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"21:9\", \"9:21\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_NBPRO: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\", \"21:9\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_NB2: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_SQUARE: ImageModelAspectRatio = {\n supported: [\"1:1\"],\n default: \"1:1\",\n}\n\ninterface ModelSpec {\n id: string\n name: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n triggerWord?: string\n}\n\nconst MODEL_SPECS: Record<string, ModelSpec> = {\n \"nano-banana-pro\": {\n id: \"nano-banana-pro\",\n name: \"Nano Banana Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 14, singular: false },\n aspectRatio: ASPECT_RATIOS_NBPRO,\n output: \"string\",\n },\n \"nano-banana-2\": {\n id: \"nano-banana-2\",\n name: \"Nano Banana 2\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_NB2,\n output: \"string\",\n },\n \"nano-banana\": {\n id: \"nano-banana\",\n name: \"Nano Banana\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-2-dev\": {\n id: \"flux-2-dev\",\n name: \"Flux 2 Dev\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_images\", maxCount: 5, singular: false },\n aspectRatio: ASPECT_RATIOS_WIDE,\n output: \"string\",\n },\n \"flux-kontext-pro\": {\n id: \"flux-kontext-pro\",\n name: \"Flux Kontext Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-kontext-max\": {\n id: \"flux-kontext-max\",\n name: \"Flux Kontext Max\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-1.1-pro-ultra\": {\n id: \"flux-1.1-pro-ultra\",\n name: \"Flux 1.1 Pro Ultra\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_ULTRA,\n output: \"string\",\n },\n \"seedream-4\": {\n id: \"seedream-4\",\n name: \"SeedReam 4\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 10, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"recraft-v3\": {\n id: \"recraft\",\n name: \"Recraft V3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_SQUARE,\n output: \"string\",\n },\n \"image-01\": {\n id: \"minimax\",\n name: \"MiniMax Image\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"3:4\", \"4:3\"], default: \"1:1\" },\n output: \"array\",\n },\n \"gpt-image-1\": {\n id: \"gpt-image-1\",\n name: \"OpenAI GPT Image 1\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: { supported: [\"1:1\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"ideogram-v3-turbo\": {\n id: \"ideogram-v3\",\n name: \"Ideogram v3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"flux-1.1-pro\": {\n id: \"flux\",\n name: \"Flux 1.1 Pro\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\"], default: \"1:1\" },\n output: \"string\",\n },\n}\n\nfunction mapModel(raw: ReplicateModel): ImageModelEntry {\n const providerId = `${raw.owner}/${raw.name}`\n const spec = MODEL_SPECS[raw.name] ?? {\n id: raw.name,\n name: raw.name,\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\" as const, maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\" as const,\n }\n\n const pricing = PRICING[raw.name] ?? {\n costPerImage: 0.03,\n costTier: \"low\" as const,\n baseCost: 0.03,\n creditCost: 3,\n }\n\n return {\n id: spec.id,\n name: spec.name,\n providerId,\n provider: raw.owner === \"openai\" ? \"openai\" : raw.owner === \"minimax\" ? \"minimax\" : \"replicate\",\n capabilities: spec.capabilities,\n referenceImages: spec.referenceImages,\n aspectRatio: spec.aspectRatio,\n output: spec.output,\n pricing: {\n costPerImage: pricing.costPerImage,\n costTier: pricing.costTier,\n billingUnit: \"per_image\" as const,\n baseCost: pricing.baseCost,\n ...(pricing.creditCost !== undefined ? { creditCost: pricing.creditCost } : {}),\n ...(pricing.overrideCreditCost !== undefined ? { overrideCreditCost: pricing.overrideCreditCost } : {}),\n },\n description: raw.description,\n agentVisible: AGENT_VISIBLE.has(raw.name),\n ...(spec.triggerWord ? { triggerWord: spec.triggerWord } : {}),\n }\n}\n\n// ── Generator ────────────────────────────────────────────────────────────\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\nexport const REPLICATE_SOURCE: CatalogSource = {\n id: \"image-replicate\",\n url: \"https://api.replicate.com/v1/models?query=image+generation\",\n}\n\nexport const imageReplicate: CatalogGenerator = defineGenerator({\n name: \"image:replicate\",\n modality: \"image\",\n sources: [REPLICATE_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const data = (await ctx.fetchSource(REPLICATE_SOURCE)) as ReplicateSnapshot\n\n const entries = data.models.map(mapModel)\n\n const lines: string[] = [\n \"// Generated by @agentproto/catalog-sync generator image:replicate\",\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n \"import type { ImageModelDefinition } from \\\"@agentproto/model-catalog/image\\\"\",\n \"\",\n \"export const REPLICATE_IMAGE_MODELS: Record<string, ImageModelDefinition> = {\",\n ]\n\n for (const e of entries) {\n const trigger = e.triggerWord ? `,\\n triggerWord: ${JSON.stringify(e.triggerWord)}` : \"\"\n const creditCost = e.pricing.creditCost !== undefined\n ? `,\\n creditCost: ${e.pricing.creditCost}`\n : \"\"\n const override = e.pricing.overrideCreditCost !== undefined\n ? `,\\n overrideCreditCost: ${e.pricing.overrideCreditCost}`\n : \"\"\n\n lines.push(` ${JSON.stringify(e.id)}: {`)\n lines.push(` id: ${JSON.stringify(e.id)},`)\n lines.push(` name: ${JSON.stringify(e.name)},`)\n lines.push(` providerId: ${JSON.stringify(e.providerId)},`)\n lines.push(` provider: ${JSON.stringify(e.provider)},`)\n lines.push(` capabilities: { generate: ${e.capabilities.generate}, edit: ${e.capabilities.edit}${e.capabilities.upscale ? `, upscale: ${e.capabilities.upscale}` : \"\"} },`)\n lines.push(` referenceImages: {`)\n lines.push(` supported: ${e.referenceImages.supported},`)\n lines.push(` fieldName: ${JSON.stringify(e.referenceImages.fieldName)},`)\n lines.push(` maxCount: ${e.referenceImages.maxCount},`)\n lines.push(` singular: ${e.referenceImages.singular},`)\n lines.push(` },`)\n lines.push(` aspectRatio: {`)\n lines.push(` supported: [${e.aspectRatio.supported.map(a => JSON.stringify(a)).join(\", \")}],`)\n lines.push(` default: ${JSON.stringify(e.aspectRatio.default)},`)\n lines.push(` },`)\n lines.push(` output: ${JSON.stringify(e.output)},`)\n lines.push(` pricing: {`)\n lines.push(` costPerImage: ${e.pricing.costPerImage},`)\n lines.push(` costTier: ${JSON.stringify(e.pricing.costTier)},`)\n lines.push(` billingUnit: ${JSON.stringify(e.pricing.billingUnit)},`)\n lines.push(` baseCost: ${e.pricing.baseCost},${creditCost}${override}`)\n lines.push(` },`)\n lines.push(` description: ${JSON.stringify(e.description)},`)\n lines.push(` agentVisible: ${e.agentVisible},${trigger}`)\n lines.push(` },`)\n }\n\n lines.push(\"}\")\n lines.push(\"\")\n\n const outputPath = \"packages/catalog-sync/generated/image-replicate.generated.ts\"\n return { [outputPath]: lines.join(\"\\n\") }\n },\n})\n"]}
1
+ {"version":3,"sources":["../src/types.ts","../src/runner.ts","../src/generators/llm-openrouter.ts","../src/generators/serialize-voices.ts","../src/generators/voice-elevenlabs.ts","../src/generators/voice-minimax.ts","../src/generators/image-replicate.ts","../src/refresh-workflow.ts","../src/sources/openai.ts"],"names":["__dirname","OUTPUT_PATH","dirname","fileURLToPath","catalogSyncDir","resolve","snapshotPath","join","repoRoot","existsSync","readIfExists","readFileSync","resolveHeaders","sources","mkdirSync","writeFileSync"],"mappings":";;;;;;;;;;;;;AAsDO,SAAS,gBAAgB,CAAA,EAAuC;AACrE,EAAA,OAAO,CAAA;AACT;AC7CA,IAAMA,WAAA,GAAY,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAQxD,SAAS,cAAA,GAAyB;AAChC,EAAA,OAAO,OAAA,CAAQA,aAAW,IAAI,CAAA;AAChC;AAGA,SAAS,aAAa,EAAA,EAAoB;AACxC,EAAA,OAAO,KAAK,cAAA,EAAe,EAAG,WAAA,EAAa,CAAA,EAAG,EAAE,CAAA,KAAA,CAAO,CAAA;AACzD;AAOA,SAAS,QAAA,GAAmB;AAC1B,EAAA,IAAI,MAAM,cAAA,EAAe;AACzB,EAAA,KAAA,IAA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B,EAAC;AAClC,EAAA,MAAM,UAAoB,EAAC;AAE3B,EAAA,KAAA,MAAW,CAAC,OAAA,EAAS,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AACpD,IAAA,MAAM,GAAA,GAAMD,IAAAA,CAAK,IAAA,EAAM,OAAO,CAAA;AAC9B,IAAA,MAAM,MAAA,GAASG,cAAa,GAAG,CAAA;AAC/B,IAAA,MAAM,YAAY,MAAA,KAAW,KAAA;AAC7B,IAAA,KAAA,CAAM,IAAA,CAAK,EAAE,IAAA,EAAM,OAAA,EAAS,QAAQ,KAAA,EAAO,OAAA,EAAS,WAAW,CAAA;AAC/D,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,OAAA,CAAQ,KAAK,OAAO,CAAA;AACpB,MAAA,IAAI,KAAK,KAAA,EAAO;AACd,QAAAI,UAAUZ,OAAAA,CAAQ,GAAG,GAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AAC3C,QAAAa,aAAAA,CAAc,GAAA,EAAK,KAAA,EAAO,MAAM,CAAA;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,SAAS,aAAA,EAAc;AACzD;;;AC9PO,IAAM,iBAAA,GAAuC;AAAA,EAClD,MAAA,EAAQ;AAAA,IACN,EAAA,EAAI,YAAA;AAAA,IACJ,GAAA,EAAK;AAAA,GACP;AAAA,EACA,WAAA,EAAa,KAAA;AAAA,EACb,KAAA,EACE;AAKJ;AAGO,IAAM,cAAA,GAAsC,CAAC,iBAAiB","file":"index.mjs","sourcesContent":["/**\n * catalog-sync generator contract.\n *\n * FROZEN — a sibling agent builds provider generators against this surface.\n * Do not change field names, shapes, or the `defineGenerator` signature\n * without coordinating. Adding new generators is the expected extension\n * path; editing this file is not.\n */\n\nexport interface CatalogSource {\n id: string\n url: string\n /** HTTP method for the live (`--refresh`) fetch. Default `\"GET\"`. */\n method?: \"GET\" | \"POST\"\n /**\n * Request headers for the live fetch. A value may embed `env:VAR_NAME`\n * tokens, resolved from `process.env` at fetch time (e.g.\n * `{ \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" }` or\n * `{ Authorization: \"Bearer env:MINIMAX_API_KEY\" }`). If any referenced env\n * var is unset, the source is treated as un-refreshable — the committed\n * snapshot is reused rather than fetched without auth. Offline reads\n * (default, no `--refresh`) ignore headers entirely.\n */\n headers?: Record<string, string>\n /** JSON request body for POST sources (e.g. MiniMax `get_voice`). */\n body?: unknown\n}\n\nexport interface GeneratorContext {\n /**\n * Reads the pinned snapshot at `snapshots/<src.id>.json`; if missing and\n * `refresh=true`, fetches `src.url` and writes the snapshot. Returns\n * parsed JSON.\n *\n * Offline by default: when no snapshot exists and `refresh` is false this\n * throws — generators MUST be runnable without network access so CI and\n * tests are deterministic. The only network path is behind `--refresh`.\n */\n fetchSource(src: CatalogSource): Promise<unknown>\n refresh: boolean\n}\n\n/** Repo-relative path → TS source text. */\nexport type GeneratedFiles = Record<string, string>\n\nexport interface CatalogGenerator {\n /** e.g. \"llm:openrouter\" */\n name: string\n modality: \"llm\" | \"image\" | \"video\" | \"audio\" | \"voice\"\n sources: CatalogSource[]\n generate(ctx: GeneratorContext): Promise<GeneratedFiles>\n}\n\n/** Identity helper — lets a generator module declare itself with type inference. */\nexport function defineGenerator(g: CatalogGenerator): CatalogGenerator {\n return g\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\n/**\n * The catalog-sync package directory. Resolves the same way whether the\n * module is loaded from `src/` (vitest, type-checking) or `dist/` (built) —\n * both sit one level below the package root, so walking up one directory\n * from this file lands on `packages/catalog-sync/`.\n */\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\n/** Absolute path to a committed/pinned source snapshot. */\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\n/**\n * The monorepo root. Resolved by walking up from the catalog-sync package\n * until `pnpm-workspace.yaml` is found. Generated-file paths in\n * {@link GeneratedFiles} are repo-relative and are resolved against this.\n */\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n // Fallback: catalog-sync lives at <root>/packages/catalog-sync.\n return dirname(dirname(catalogSyncDir()))\n}\n\n/** Reads an existing file as UTF-8, or returns undefined when absent. */\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\n/**\n * Resolve `env:VAR_NAME` tokens inside header values from `process.env`.\n * Returns the materialized headers plus the names of any referenced env vars\n * that are unset — the caller uses `missing` to decide whether the source can\n * be refreshed (we never fetch an authed endpoint without its key).\n */\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\nexport interface RunGeneratorsOptions {\n /** When true, missing snapshots are fetched from their pinned `url`. */\n refresh: boolean\n /** When true, generated files are written to disk at their repo-relative path. */\n write: boolean\n}\n\nexport interface RunGeneratorsResult {\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from what is on disk. */\n changed: string[]\n}\n\n/**\n * Runs each generator, gathering its emitted files, then (optionally) writes\n * them. `changed` is ALWAYS computed — it is the diff of generated content\n * vs disk — so `--check` (write=false) can surface drift without mutating\n * anything. Writes only happen when `write=true` AND a path differs.\n */\nexport async function runGenerators(\n gens: CatalogGenerator[],\n opts: RunGeneratorsOptions\n): Promise<RunGeneratorsResult> {\n const files: GeneratedFiles = {}\n\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n\n // Offline path (default): reuse the committed snapshot; error if none.\n if (!opts.refresh) {\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" ` +\n `(${path}), and --refresh is not set. Run ` +\n `\\`catalog-sync generate --refresh\\` to fetch ${src.url}.`\n )\n }\n\n // --refresh: force a live re-fetch (do NOT short-circuit on an existing\n // snapshot — refreshing is the whole point). Auth headers may embed\n // `env:VAR` tokens; if a referenced var is unset we can't authenticate,\n // so reuse the committed snapshot rather than fetch unauthenticated.\n const { headers, missing } = resolveHeaders(src.headers)\n if (missing.length > 0) {\n if (existing !== undefined) {\n process.stderr.write(\n `catalog-sync: skipping refresh of \"${src.id}\" — missing env ` +\n `${missing.join(\", \")}; reusing committed snapshot.\\n`\n )\n return JSON.parse(existing)\n }\n throw new Error(\n `catalog-sync: cannot refresh \"${src.id}\" — missing env ` +\n `${missing.join(\", \")} and no committed snapshot.`\n )\n }\n const res = await fetch(src.url, {\n method: src.method ?? \"GET\",\n headers,\n ...(src.body !== undefined\n ? { body: JSON.stringify(src.body) }\n : {}),\n })\n if (!res.ok) {\n throw new Error(\n `catalog-sync: fetch ${src.url} failed: ${res.status} ${res.statusText}`\n )\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(path), { recursive: true })\n writeFileSync(path, `${JSON.stringify(parsed, null, 2)}\\n`, \"utf8\")\n return parsed\n },\n }\n\n const out = await gen.generate(ctx)\n for (const [path, content] of Object.entries(out)) {\n files[path] = content\n }\n }\n\n const root = repoRoot()\n const changed: string[] = []\n for (const [relPath, content] of Object.entries(files)) {\n const abs = join(root, relPath)\n const existing = readIfExists(abs)\n if (existing !== content) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, content, \"utf8\")\n }\n }\n }\n\n return { files, changed }\n}\n","import { z } from \"zod\"\n\nimport { defineGenerator, type GeneratedFiles, type GeneratorContext } from \"../types.js\"\n\n/**\n * PINNED source. The OpenRouter `/api/v1/models` payload lists every route\n * the router exposes with per-token USD pricing. We never fetch it at build\n * or test time — only behind `--refresh`, which writes\n * `snapshots/llm-openrouter.json` so the next offline run is deterministic.\n */\nconst OPENROUTER_MODELS_URL = \"https://openrouter.ai/api/v1/models\"\n\n/** Repo-relative drop-in target for {@link @agentproto/model-catalog}. */\nconst OUTPUT_PATH = \"packages/model-catalog/src/llm/openrouter-routes.generated.ts\"\n\n// ── Source schema ────────────────────────────────────────────────────────\n// OpenRouter prices are STRINGS of USD-per-token (e.g. \"0.000003\" = $3/1M).\n// `input_cache_read` / `input_cache_write` are optional and only present for\n// models that support prompt caching (Anthropic, etc.). These are the REAL\n// OpenRouter field names (verified against the live /v1/models payload) — an\n// earlier draft used `cache_read`/`cache_write`, which never matched, so cache\n// multipliers were silently always absent. passthrough() keeps the other live\n// keys (web_search, image, audio, internal_reasoning, input_cache_write_1h)\n// forward-compatible without a regenerate — we only read what we model.\n\nconst PricingSchema = z\n .object({\n prompt: z.string().optional(),\n completion: z.string().optional(),\n input_cache_read: z.string().optional(),\n input_cache_write: z.string().optional(),\n })\n .passthrough()\n\nconst ModelSchema = z\n .object({\n id: z.string(),\n pricing: PricingSchema.optional(),\n })\n .passthrough()\n\nconst SnapshotSchema = z.object({\n data: z.array(ModelSchema),\n})\n\n// ── Output shape (mirrors model-catalog's LLMPricing) ────────────────────\n// Drop-in for `packages/model-catalog/src/llm/openrouter-routes.generated.ts`.\n// Structurally identical to LLMPricing — inputPer1M / outputPer1M in USD per\n// 1M tokens, plus cacheReadMultiplier / cacheWriteMultiplier WHEN the source\n// carries cache_read / cache_write. The existing committed file omits cache\n// fields; this generator emits them when present (per the P3 spec: \"plus\n// cache fields if the source has them\"). Fields are optional on LLMPricing,\n// so the output remains drop-in compatible.\n\ninterface LLMPricingEntry {\n inputPer1M: number\n outputPer1M: number\n cacheReadMultiplier?: number\n cacheWriteMultiplier?: number\n vendor: string\n provider: \"openrouter\"\n}\n\n// ── Number helpers ──────────────────────────────────────────────────────\n\n/** Round to 6 decimal places, killing binary-float noise from the per-token × 1e6 product. */\nfunction round6(n: number): number {\n return Math.round(n * 1_000_000) / 1_000_000\n}\n\n/** Convert a per-token USD string to USD-per-1M-tokens, or undefined if unpriced. */\nfunction per1m(tokenPrice: string | undefined): number | undefined {\n if (tokenPrice === undefined) return undefined\n const n = Number(tokenPrice)\n if (!Number.isFinite(n)) return undefined\n return round6(n * 1_000_000)\n}\n\n/** Shortest faithful decimal string (matches existing file: 1, 0.5, 0.7448, 1.25). */\nfunction fmt(n: number): string {\n if (!Number.isFinite(n)) return \"0\"\n return `${round6(n)}`\n}\n\n/** Vendor slug = first segment of the OpenRouter route id (`vendor/model`). */\nfunction vendorOf(id: string): string {\n if (!id.includes(\"/\")) return id\n return id.split(\"/\")[0] ?? id\n}\n\n// ── Serialization ────────────────────────────────────────────────────────\n\nfunction serializeEntry(e: LLMPricingEntry): string {\n const fields: string[] = [\n `inputPer1M: ${fmt(e.inputPer1M)}`,\n `outputPer1M: ${fmt(e.outputPer1M)}`,\n ]\n if (e.cacheReadMultiplier !== undefined) {\n fields.push(`cacheReadMultiplier: ${fmt(e.cacheReadMultiplier)}`)\n }\n if (e.cacheWriteMultiplier !== undefined) {\n fields.push(`cacheWriteMultiplier: ${fmt(e.cacheWriteMultiplier)}`)\n }\n fields.push(`vendor: ${JSON.stringify(e.vendor)}`)\n fields.push(`provider: ${JSON.stringify(e.provider)}`)\n return `{\\n ${fields.join(\",\\n \")},\\n }`\n}\n\nfunction serializeFile(entries: Record<string, LLMPricingEntry>): string {\n const ids = Object.keys(entries).sort()\n const providers = Array.from(new Set(ids.map(vendorOf))).sort()\n\n const lines: string[] = [\n \"// AUTO-GENERATED by @agentproto/catalog-sync (llm:openrouter).\",\n \"// Do not edit by hand — re-run `pnpm --filter @agentproto/catalog-sync generate`.\",\n `// Source: ${OPENROUTER_MODELS_URL}`,\n \"// Pricing carries provider USD (inputPer1M / outputPer1M) plus cache\",\n \"// multipliers (cacheReadMultiplier / cacheWriteMultiplier) derived from the\",\n \"// source's input_cache_read / input_cache_write per-token fields when present.\",\n \"\",\n 'import type { LLMPricing } from \"./catalog.js\"',\n \"\",\n \"export const OPENROUTER_ROUTES: Record<string, LLMPricing> = {\",\n ]\n for (const id of ids) {\n lines.push(` ${JSON.stringify(id)}: ${serializeEntry(entries[id]!)},`)\n }\n lines.push(\"}\")\n lines.push(\"\")\n lines.push(\"/** Provider slugs treated as OpenRouter routes by the picker. */\")\n lines.push(\"export const OPENROUTER_PROVIDERS: readonly string[] = [\")\n for (const p of providers) {\n lines.push(` ${JSON.stringify(p)},`)\n }\n lines.push(\"]\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n\n// ── Generator ───────────────────────────────────────────────────────────\n\nasync function generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n const src = sources[0]\n if (!src) throw new Error(\"llm:openrouter: no source configured\")\n const parsed = SnapshotSchema.parse(await ctx.fetchSource(src))\n\n const entries: Record<string, LLMPricingEntry> = {}\n for (const model of parsed.data) {\n const pricing = model.pricing\n if (!pricing) continue\n const inputPer1M = per1m(pricing.prompt)\n const outputPer1M = per1m(pricing.completion)\n if (inputPer1M === undefined || outputPer1M === undefined) continue\n // Skip unpriced routes (e.g. openrouter/auto, which carries \"0\" pricing).\n if (inputPer1M === 0 && outputPer1M === 0) continue\n\n const entry: LLMPricingEntry = {\n inputPer1M,\n outputPer1M,\n vendor: vendorOf(model.id),\n provider: \"openrouter\",\n }\n\n const cacheReadPer1M = per1m(pricing.input_cache_read)\n const cacheWritePer1M = per1m(pricing.input_cache_write)\n if (cacheReadPer1M !== undefined && cacheReadPer1M > 0 && inputPer1M > 0) {\n entry.cacheReadMultiplier = round6(cacheReadPer1M / inputPer1M)\n }\n if (cacheWritePer1M !== undefined && cacheWritePer1M > 0 && inputPer1M > 0) {\n entry.cacheWriteMultiplier = round6(cacheWritePer1M / inputPer1M)\n }\n\n entries[model.id] = entry\n }\n\n return { [OUTPUT_PATH]: serializeFile(entries) }\n}\n\nconst sources = [{ id: \"llm-openrouter\", url: OPENROUTER_MODELS_URL }]\n\nexport const llmOpenRouterGenerator = defineGenerator({\n name: \"llm:openrouter\",\n modality: \"llm\",\n sources,\n generate,\n})\n","/**\n * Shared CatalogVoice[] → TS-source serializer for the voice generators.\n *\n * The mapping (raw provider JSON → CatalogVoice) lives in\n * `@agentproto/model-catalog/providers` so build time and runtime share it;\n * this module only turns the mapped voices into a committed `*.generated.ts`.\n * Field emit order is fixed (matches the historical generator output) so the\n * generated file stays diff-stable across runs.\n */\n\nimport type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"\n\nfunction serializeVoice(v: CatalogVoice): string {\n const lines: string[] = [\" {\"]\n lines.push(` catalogId: ${JSON.stringify(v.catalogId)},`)\n lines.push(` providerVoiceId: ${JSON.stringify(v.providerVoiceId)},`)\n lines.push(` provider: ${JSON.stringify(v.provider)},`)\n lines.push(` label: ${JSON.stringify(v.label)},`)\n lines.push(` description: ${JSON.stringify(v.description)},`)\n lines.push(` gender: ${JSON.stringify(v.gender)},`)\n lines.push(` primaryLanguage: ${JSON.stringify(v.primaryLanguage)},`)\n lines.push(\n ` supportedLanguages: [${v.supportedLanguages.map(l => JSON.stringify(l)).join(\", \")}],`,\n )\n if (v.quality !== undefined) lines.push(` quality: ${JSON.stringify(v.quality)},`)\n if (v.featured !== undefined) lines.push(` featured: ${v.featured},`)\n if (v.samplePath !== undefined) lines.push(` samplePath: ${JSON.stringify(v.samplePath)},`)\n if (v.age !== undefined) lines.push(` age: ${JSON.stringify(v.age)},`)\n lines.push(\" },\")\n return lines.join(\"\\n\")\n}\n\n/**\n * Render a full generated voice module.\n *\n * @param generatorName e.g. `voice:elevenlabs` (goes in the header comment)\n * @param exportName e.g. `ELEVENLABS_VOICES`\n * @param voices mapped voices, in emit order\n */\nexport function serializeVoiceModule(\n generatorName: string,\n exportName: string,\n voices: readonly CatalogVoice[],\n): string {\n const lines: string[] = [\n `// Generated by @agentproto/catalog-sync generator ${generatorName}`,\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n 'import type { CatalogVoice } from \"@agentproto/model-catalog/schema/voice\"',\n \"\",\n `export const ${exportName}: readonly CatalogVoice[] = [`,\n ]\n for (const v of voices) lines.push(serializeVoice(v))\n lines.push(\"] as const\")\n lines.push(\"\")\n return lines.join(\"\\n\")\n}\n","/**\n * voice-elevenlabs generator — reads the ElevenLabs /v1/voices snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n ElevenLabsVoicesSnapshotSchema,\n mapElevenLabsVoices,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (and is the single,\n// dist-safe reader; generators never touch the filesystem themselves).\nexport const ELEVENLABS_SOURCE: CatalogSource = {\n id: \"voice-elevenlabs\",\n url: \"https://api.elevenlabs.io/v1/voices\",\n // Live refresh needs the account key; offline reads ignore this.\n headers: { \"xi-api-key\": \"env:ELEVENLABS_API_KEY\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-elevenlabs.generated.ts\"\n\nexport const voiceElevenlabs: CatalogGenerator = defineGenerator({\n name: \"voice:elevenlabs\",\n modality: \"voice\",\n sources: [ELEVENLABS_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = ElevenLabsVoicesSnapshotSchema.parse(\n await ctx.fetchSource(ELEVENLABS_SOURCE),\n )\n const voices = mapElevenLabsVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:elevenlabs\",\n \"ELEVENLABS_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * voice-minimax generator — reads the MiniMax /v1/get_voice snapshot and\n * emits a CatalogVoice[]-shaped generated TS file.\n *\n * The raw → CatalogVoice mapping lives in\n * `@agentproto/model-catalog/providers` (shared with the runtime\n * live-on-setup path); this generator only fetches, validates, and\n * serializes. Provider-native ids only; no product-specific aliases.\n */\n\nimport {\n mapMinimaxVoices,\n MinimaxVoicesSnapshotSchema,\n} from \"@agentproto/model-catalog/providers\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\nimport { serializeVoiceModule } from \"./serialize-voices.js\"\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\nexport const MINIMAX_SOURCE: CatalogSource = {\n id: \"voice-minimax\",\n url: \"https://api.minimax.io/v1/get_voice\",\n // get_voice is a POST; live refresh needs the account key (Bearer). Without\n // MINIMAX_API_KEY set, the framework reuses the committed snapshot.\n method: \"POST\",\n headers: {\n Authorization: \"Bearer env:MINIMAX_API_KEY\",\n \"Content-Type\": \"application/json\",\n },\n body: { voice_type: \"system\" },\n}\n\nconst OUTPUT_PATH = \"packages/catalog-sync/generated/voice-minimax.generated.ts\"\n\nexport const voiceMinimax: CatalogGenerator = defineGenerator({\n name: \"voice:minimax\",\n modality: \"voice\",\n sources: [MINIMAX_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const snapshot = MinimaxVoicesSnapshotSchema.parse(\n await ctx.fetchSource(MINIMAX_SOURCE),\n )\n const voices = mapMinimaxVoices(snapshot)\n return {\n [OUTPUT_PATH]: serializeVoiceModule(\n \"voice:minimax\",\n \"MINIMAX_VOICES\",\n voices,\n ),\n }\n },\n})\n","/**\n * image-replicate generator — reads a curated Replicate image-models\n * snapshot and emits ImageModelDefinition[]-shaped generated TS entries.\n *\n * Mirrors the shape from packages/model-catalog/src/image/catalog.ts exactly.\n * Provider-native ids only; no product-specific aliases.\n */\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"../types.js\"\nimport { defineGenerator } from \"../types.js\"\n\n// ── Replicate snapshot shapes ───────────────────────────────────────────\n\ninterface ReplicateOpenApiSchema {\n input: { type: string; properties: Record<string, { type: string; items?: { type: string }; format?: string }> }\n output: { type: string; items?: { type: string; format?: string }; format?: string }\n}\n\ninterface ReplicateLatestVersion {\n id: string\n created_at: string\n openapi_schema: ReplicateOpenApiSchema\n}\n\ninterface ReplicateModel {\n owner: string\n name: string\n description: string\n visibility: string\n run_count: number\n cover_image_url: string | null\n latest_version: ReplicateLatestVersion\n}\n\ninterface ReplicateSnapshot {\n _meta: Record<string, unknown>\n models: ReplicateModel[]\n}\n\n// ── ImageModelDefinition mirror (from packages/model-catalog/src/image/catalog.ts) ──\n\ninterface ImageModelPricing {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n billingUnit: \"per_image\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\ninterface ImageModelCapabilities {\n generate: boolean\n edit: boolean\n upscale?: boolean\n}\n\ninterface ImageModelReferenceImages {\n supported: boolean\n fieldName: \"image_input\" | \"input_images\" | \"input_image\" | \"none\"\n maxCount: number\n singular: boolean\n}\n\ninterface ImageModelAspectRatio {\n supported: string[]\n default: string\n}\n\ninterface ImageModelEntry {\n id: string\n name: string\n providerId: string\n provider: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n pricing: ImageModelPricing\n description: string\n agentVisible: boolean\n triggerWord?: string\n}\n\n// ── Pricing (hand-authored, mirrors model-catalog) ──────────────────────\n\ninterface PricingRecord {\n costPerImage: number\n costTier: \"low\" | \"medium\" | \"high\"\n baseCost: number\n creditCost?: number\n overrideCreditCost?: number\n}\n\nconst PRICING: Record<string, PricingRecord> = {\n \"nano-banana-pro\": { costPerImage: 0.15, costTier: \"high\", baseCost: 0.15, creditCost: 10 },\n \"nano-banana-2\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 5 },\n \"nano-banana\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-2-dev\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"flux-kontext-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"flux-kontext-max\": { costPerImage: 0.08, costTier: \"medium\", baseCost: 0.08, creditCost: 8 },\n \"flux-1.1-pro-ultra\": { costPerImage: 0.06, costTier: \"medium\", baseCost: 0.06, creditCost: 8 },\n \"seedream-4\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 3 },\n \"recraft-v3\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"image-01\": { costPerImage: 0.02, costTier: \"low\", baseCost: 0.02, creditCost: 2 },\n \"gpt-image-1\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n \"ideogram-v3-turbo\": { costPerImage: 0.03, costTier: \"low\", baseCost: 0.03, creditCost: 4 },\n \"flux-1.1-pro\": { costPerImage: 0.04, costTier: \"low\", baseCost: 0.04, creditCost: 5 },\n}\n\n// Models visible to agents (the active generation ones)\nconst AGENT_VISIBLE = new Set([\n \"nano-banana-pro\",\n \"nano-banana-2\",\n \"nano-banana\",\n \"flux-2-dev\",\n \"flux-kontext-pro\",\n \"flux-kontext-max\",\n \"flux-1.1-pro-ultra\",\n \"seedream-4\",\n \"recraft-v3\",\n \"image-01\",\n \"gpt-image-1\",\n \"ideogram-v3-turbo\",\n])\n\nconst ASPECT_RATIOS_DEFAULT: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_WIDE: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\", \"4:5\", \"5:4\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_ULTRA: ImageModelAspectRatio = {\n supported: [\"1:1\", \"9:16\", \"16:9\", \"21:9\", \"9:21\", \"3:4\", \"4:3\"],\n default: \"1:1\",\n}\n\nconst ASPECT_RATIOS_NBPRO: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\", \"21:9\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_NB2: ImageModelAspectRatio = {\n supported: [\n \"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\", \"3:4\", \"4:3\",\n \"4:5\", \"5:4\",\n ],\n default: \"match_input_image\",\n}\n\nconst ASPECT_RATIOS_SQUARE: ImageModelAspectRatio = {\n supported: [\"1:1\"],\n default: \"1:1\",\n}\n\ninterface ModelSpec {\n id: string\n name: string\n capabilities: ImageModelCapabilities\n referenceImages: ImageModelReferenceImages\n aspectRatio: ImageModelAspectRatio\n output: \"string\" | \"array\"\n triggerWord?: string\n}\n\nconst MODEL_SPECS: Record<string, ModelSpec> = {\n \"nano-banana-pro\": {\n id: \"nano-banana-pro\",\n name: \"Nano Banana Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 14, singular: false },\n aspectRatio: ASPECT_RATIOS_NBPRO,\n output: \"string\",\n },\n \"nano-banana-2\": {\n id: \"nano-banana-2\",\n name: \"Nano Banana 2\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_NB2,\n output: \"string\",\n },\n \"nano-banana\": {\n id: \"nano-banana\",\n name: \"Nano Banana\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 4, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-2-dev\": {\n id: \"flux-2-dev\",\n name: \"Flux 2 Dev\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_images\", maxCount: 5, singular: false },\n aspectRatio: ASPECT_RATIOS_WIDE,\n output: \"string\",\n },\n \"flux-kontext-pro\": {\n id: \"flux-kontext-pro\",\n name: \"Flux Kontext Pro\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-kontext-max\": {\n id: \"flux-kontext-max\",\n name: \"Flux Kontext Max\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"flux-1.1-pro-ultra\": {\n id: \"flux-1.1-pro-ultra\",\n name: \"Flux 1.1 Pro Ultra\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_ULTRA,\n output: \"string\",\n },\n \"seedream-4\": {\n id: \"seedream-4\",\n name: \"SeedReam 4\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"image_input\", maxCount: 10, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\",\n },\n \"recraft-v3\": {\n id: \"recraft\",\n name: \"Recraft V3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_SQUARE,\n output: \"string\",\n },\n \"image-01\": {\n id: \"minimax\",\n name: \"MiniMax Image\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"3:4\", \"4:3\"], default: \"1:1\" },\n output: \"array\",\n },\n \"gpt-image-1\": {\n id: \"gpt-image-1\",\n name: \"OpenAI GPT Image 1\",\n capabilities: { generate: true, edit: true },\n referenceImages: { supported: true, fieldName: \"input_image\", maxCount: 1, singular: true },\n aspectRatio: { supported: [\"1:1\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"ideogram-v3-turbo\": {\n id: \"ideogram-v3\",\n name: \"Ideogram v3\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\", \"2:3\", \"3:2\"], default: \"1:1\" },\n output: \"string\",\n },\n \"flux-1.1-pro\": {\n id: \"flux\",\n name: \"Flux 1.1 Pro\",\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\", maxCount: 0, singular: false },\n aspectRatio: { supported: [\"1:1\", \"9:16\", \"16:9\"], default: \"1:1\" },\n output: \"string\",\n },\n}\n\nfunction mapModel(raw: ReplicateModel): ImageModelEntry {\n const providerId = `${raw.owner}/${raw.name}`\n const spec = MODEL_SPECS[raw.name] ?? {\n id: raw.name,\n name: raw.name,\n capabilities: { generate: true, edit: false },\n referenceImages: { supported: false, fieldName: \"none\" as const, maxCount: 0, singular: false },\n aspectRatio: ASPECT_RATIOS_DEFAULT,\n output: \"string\" as const,\n }\n\n const pricing = PRICING[raw.name] ?? {\n costPerImage: 0.03,\n costTier: \"low\" as const,\n baseCost: 0.03,\n creditCost: 3,\n }\n\n return {\n id: spec.id,\n name: spec.name,\n providerId,\n provider: raw.owner === \"openai\" ? \"openai\" : raw.owner === \"minimax\" ? \"minimax\" : \"replicate\",\n capabilities: spec.capabilities,\n referenceImages: spec.referenceImages,\n aspectRatio: spec.aspectRatio,\n output: spec.output,\n pricing: {\n costPerImage: pricing.costPerImage,\n costTier: pricing.costTier,\n billingUnit: \"per_image\" as const,\n baseCost: pricing.baseCost,\n ...(pricing.creditCost !== undefined ? { creditCost: pricing.creditCost } : {}),\n ...(pricing.overrideCreditCost !== undefined ? { overrideCreditCost: pricing.overrideCreditCost } : {}),\n },\n description: raw.description,\n agentVisible: AGENT_VISIBLE.has(raw.name),\n ...(spec.triggerWord ? { triggerWord: spec.triggerWord } : {}),\n }\n}\n\n// ── Generator ────────────────────────────────────────────────────────────\n\n// `id` MUST match the snapshot filename stem — the framework's\n// `ctx.fetchSource` resolves `snapshots/<id>.json` (single dist-safe reader;\n// generators never touch the filesystem themselves).\nexport const REPLICATE_SOURCE: CatalogSource = {\n id: \"image-replicate\",\n url: \"https://api.replicate.com/v1/models?query=image+generation\",\n}\n\nexport const imageReplicate: CatalogGenerator = defineGenerator({\n name: \"image:replicate\",\n modality: \"image\",\n sources: [REPLICATE_SOURCE],\n\n async generate(ctx: GeneratorContext): Promise<GeneratedFiles> {\n // Snapshot-first (refresh re-fetches) — both handled by the framework.\n const data = (await ctx.fetchSource(REPLICATE_SOURCE)) as ReplicateSnapshot\n\n const entries = data.models.map(mapModel)\n\n const lines: string[] = [\n \"// Generated by @agentproto/catalog-sync generator image:replicate\",\n \"// DO NOT EDIT MANUALLY — regenerate with catalog-sync\",\n \"\",\n \"import type { ImageModelDefinition } from \\\"@agentproto/model-catalog/image\\\"\",\n \"\",\n \"export const REPLICATE_IMAGE_MODELS: Record<string, ImageModelDefinition> = {\",\n ]\n\n for (const e of entries) {\n const trigger = e.triggerWord ? `,\\n triggerWord: ${JSON.stringify(e.triggerWord)}` : \"\"\n const creditCost = e.pricing.creditCost !== undefined\n ? `,\\n creditCost: ${e.pricing.creditCost}`\n : \"\"\n const override = e.pricing.overrideCreditCost !== undefined\n ? `,\\n overrideCreditCost: ${e.pricing.overrideCreditCost}`\n : \"\"\n\n lines.push(` ${JSON.stringify(e.id)}: {`)\n lines.push(` id: ${JSON.stringify(e.id)},`)\n lines.push(` name: ${JSON.stringify(e.name)},`)\n lines.push(` providerId: ${JSON.stringify(e.providerId)},`)\n lines.push(` provider: ${JSON.stringify(e.provider)},`)\n lines.push(` capabilities: { generate: ${e.capabilities.generate}, edit: ${e.capabilities.edit}${e.capabilities.upscale ? `, upscale: ${e.capabilities.upscale}` : \"\"} },`)\n lines.push(` referenceImages: {`)\n lines.push(` supported: ${e.referenceImages.supported},`)\n lines.push(` fieldName: ${JSON.stringify(e.referenceImages.fieldName)},`)\n lines.push(` maxCount: ${e.referenceImages.maxCount},`)\n lines.push(` singular: ${e.referenceImages.singular},`)\n lines.push(` },`)\n lines.push(` aspectRatio: {`)\n lines.push(` supported: [${e.aspectRatio.supported.map(a => JSON.stringify(a)).join(\", \")}],`)\n lines.push(` default: ${JSON.stringify(e.aspectRatio.default)},`)\n lines.push(` },`)\n lines.push(` output: ${JSON.stringify(e.output)},`)\n lines.push(` pricing: {`)\n lines.push(` costPerImage: ${e.pricing.costPerImage},`)\n lines.push(` costTier: ${JSON.stringify(e.pricing.costTier)},`)\n lines.push(` billingUnit: ${JSON.stringify(e.pricing.billingUnit)},`)\n lines.push(` baseCost: ${e.pricing.baseCost},${creditCost}${override}`)\n lines.push(` },`)\n lines.push(` description: ${JSON.stringify(e.description)},`)\n lines.push(` agentVisible: ${e.agentVisible},${trigger}`)\n lines.push(` },`)\n }\n\n lines.push(\"}\")\n lines.push(\"\")\n\n const outputPath = \"packages/catalog-sync/generated/image-replicate.generated.ts\"\n return { [outputPath]: lines.join(\"\\n\") }\n },\n})\n","/**\n * Reviewed refresh workflow for catalog-sync.\n *\n * Extends the existing generator framework with explicit, reviewable diffs and\n * source-level metadata so operators can see exactly what changed and why.\n *\n * Design constraints (per project convention):\n * - Pricing is never fabricated.\n * - Refresh only hits pinned source URLs; unrefreshable sources are skipped\n * with an explanation.\n * - The committed snapshot is the single source of truth for offline runs.\n * - Availability-only local cache stays separate from the reviewed refresh.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return dirname(dirname(catalogSyncDir()))\n}\n\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\n// ── Source metadata ────────────────────────────────────────────────────────\n\n/**\n * Source-level refresh metadata. Wraps a frozen {@link CatalogSource} without\n * mutating it, so existing generators keep compiling unchanged.\n */\nexport interface RefreshableSource {\n source: CatalogSource\n /** When false, the source is skipped by --refresh and documented in results. */\n refreshable: boolean\n /** Human-readable explanation of the source contract or gap. */\n notes?: string\n}\n\nexport interface SourceRefreshResult {\n id: string\n url: string\n /** True when a live fetch was attempted and succeeded. */\n refreshed: boolean\n /** True when the source is known to be unrefreshable. */\n skipped?: boolean\n /** Human-readable status / gap explanation. */\n notes?: string\n /** Present when refresh was attempted but failed. */\n error?: string\n}\n\n// ── File diff ──────────────────────────────────────────────────────────────\n\nexport interface CatalogFileDiff {\n /** Repo-relative path. */\n path: string\n /** Content currently on disk, or undefined when the file does not exist. */\n before: string | undefined\n /** Generated content. */\n after: string\n /** True when before !== after. */\n changed: boolean\n}\n\n// ── Options / result ───────────────────────────────────────────────────────\n\nexport interface ReviewedRefreshOptions {\n /** When true, attempt live fetches for refreshable sources. */\n refresh: boolean\n /** When true, write generated files to disk. */\n write: boolean\n /**\n * Optional fetch implementation for tests. Defaults to the global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\nexport interface ReviewedRefreshResult {\n /** Generated repo-relative path → content. */\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from disk. */\n changed: string[]\n /** Per-file before/after reviewable diffs. */\n diffs: CatalogFileDiff[]\n /** Per-source refresh status. */\n sources: SourceRefreshResult[]\n}\n\n// ── Implementation ─────────────────────────────────────────────────────────\n\n/**\n * Fetch every refreshable source and record the outcome.\n *\n * Unrefreshable sources (e.g. OpenAI, which has no stable pricing endpoint)\n * are reported as skipped rather than silently ignored or scraped.\n */\nexport async function refreshSources(\n sources: RefreshableSource[],\n opts: Pick<ReviewedRefreshOptions, \"refresh\" | \"fetchImpl\">\n): Promise<SourceRefreshResult[]> {\n const results: SourceRefreshResult[] = []\n const fetchImpl = opts.fetchImpl ?? fetch\n\n for (const { source, refreshable, notes } of sources) {\n if (!opts.refresh) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n notes: \"Offline mode: using committed snapshot.\",\n })\n continue\n }\n\n if (!refreshable) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n skipped: true,\n notes: notes ?? \"Source is not refreshable.\",\n })\n continue\n }\n\n const { headers, missing } = resolveHeaders(source.headers)\n if (missing.length > 0) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `Missing env vars: ${missing.join(\", \")}`,\n })\n continue\n }\n\n try {\n const res = await fetchImpl(source.url, {\n method: source.method ?? \"GET\",\n headers,\n ...(source.body !== undefined\n ? { body: JSON.stringify(source.body) }\n : {}),\n })\n if (!res.ok) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `${res.status} ${res.statusText}`,\n })\n continue\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(snapshotPath(source.id)), { recursive: true })\n writeFileSync(\n snapshotPath(source.id),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf8\"\n )\n results.push({\n id: source.id,\n url: source.url,\n refreshed: true,\n notes: \"Snapshot updated from live source.\",\n })\n } catch (err) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: err instanceof Error ? err.message : String(err),\n })\n }\n }\n\n return results\n}\n\n/**\n * Run generators using the current snapshots (whether refreshed or committed)\n * and produce reviewable file diffs.\n */\nexport async function reviewedRefresh(\n gens: CatalogGenerator[],\n refreshableSources: RefreshableSource[],\n opts: ReviewedRefreshOptions\n): Promise<ReviewedRefreshResult> {\n const sourceResults = await refreshSources(refreshableSources, opts)\n\n const files: GeneratedFiles = {}\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" (${path}).`\n )\n },\n }\n const out = await gen.generate(ctx)\n Object.assign(files, out)\n }\n\n const root = repoRoot()\n const diffs: CatalogFileDiff[] = []\n const changed: string[] = []\n\n for (const [relPath, after] of Object.entries(files)) {\n const abs = join(root, relPath)\n const before = readIfExists(abs)\n const isChanged = before !== after\n diffs.push({ path: relPath, before, after, changed: isChanged })\n if (isChanged) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, after, \"utf8\")\n }\n }\n }\n\n return { files, changed, diffs, sources: sourceResults }\n}\n","/**\n * OpenAI LLM source contract.\n *\n * OpenAI does **not** publish a stable, machine-readable pricing/model catalog\n * endpoint. The authoritative pricing page is `openai.com/api/pricing`, but it\n * is HTML-only, not a documented API, and has historically changed layout\n * without notice.\n *\n * Therefore this source is intentionally **not refreshable** in the automated\n * `catalog-sync` workflow. Pricing is committed by hand from the official page\n * and cross-checked with third-party aggregators where noted. We do not scrape\n * or guess.\n *\n * If OpenAI releases a stable `/v1/models` endpoint that includes pricing, or\n * a documented pricing JSON feed, this source can be upgraded to refreshable.\n * Until then, the gap is recorded honestly in refresh results.\n */\n\nimport type { RefreshableSource } from \"../refresh-workflow.js\"\n\nexport const OPENAI_LLM_SOURCE: RefreshableSource = {\n source: {\n id: \"llm-openai\",\n url: \"https://openai.com/api/pricing\",\n },\n refreshable: false,\n notes:\n \"OpenAI has no stable machine-readable pricing endpoint. \" +\n \"Pricing in @agentproto/model-catalog is committed manually from \" +\n \"openai.com/api/pricing and verified against independent aggregators \" +\n \"where possible. Automated refresh is disabled to avoid scraping or \" +\n \"fabricating prices.\",\n}\n\n/** Convenience array for workflows that want to include the OpenAI contract. */\nexport const OPENAI_SOURCES: RefreshableSource[] = [OPENAI_LLM_SOURCE]\n"]}
@@ -0,0 +1,83 @@
1
+ import { CatalogSource, GeneratedFiles, CatalogGenerator } from './types.js';
2
+
3
+ /**
4
+ * Reviewed refresh workflow for catalog-sync.
5
+ *
6
+ * Extends the existing generator framework with explicit, reviewable diffs and
7
+ * source-level metadata so operators can see exactly what changed and why.
8
+ *
9
+ * Design constraints (per project convention):
10
+ * - Pricing is never fabricated.
11
+ * - Refresh only hits pinned source URLs; unrefreshable sources are skipped
12
+ * with an explanation.
13
+ * - The committed snapshot is the single source of truth for offline runs.
14
+ * - Availability-only local cache stays separate from the reviewed refresh.
15
+ */
16
+
17
+ /**
18
+ * Source-level refresh metadata. Wraps a frozen {@link CatalogSource} without
19
+ * mutating it, so existing generators keep compiling unchanged.
20
+ */
21
+ interface RefreshableSource {
22
+ source: CatalogSource;
23
+ /** When false, the source is skipped by --refresh and documented in results. */
24
+ refreshable: boolean;
25
+ /** Human-readable explanation of the source contract or gap. */
26
+ notes?: string;
27
+ }
28
+ interface SourceRefreshResult {
29
+ id: string;
30
+ url: string;
31
+ /** True when a live fetch was attempted and succeeded. */
32
+ refreshed: boolean;
33
+ /** True when the source is known to be unrefreshable. */
34
+ skipped?: boolean;
35
+ /** Human-readable status / gap explanation. */
36
+ notes?: string;
37
+ /** Present when refresh was attempted but failed. */
38
+ error?: string;
39
+ }
40
+ interface CatalogFileDiff {
41
+ /** Repo-relative path. */
42
+ path: string;
43
+ /** Content currently on disk, or undefined when the file does not exist. */
44
+ before: string | undefined;
45
+ /** Generated content. */
46
+ after: string;
47
+ /** True when before !== after. */
48
+ changed: boolean;
49
+ }
50
+ interface ReviewedRefreshOptions {
51
+ /** When true, attempt live fetches for refreshable sources. */
52
+ refresh: boolean;
53
+ /** When true, write generated files to disk. */
54
+ write: boolean;
55
+ /**
56
+ * Optional fetch implementation for tests. Defaults to the global `fetch`.
57
+ */
58
+ fetchImpl?: typeof fetch;
59
+ }
60
+ interface ReviewedRefreshResult {
61
+ /** Generated repo-relative path → content. */
62
+ files: GeneratedFiles;
63
+ /** Repo-relative paths whose generated content differs from disk. */
64
+ changed: string[];
65
+ /** Per-file before/after reviewable diffs. */
66
+ diffs: CatalogFileDiff[];
67
+ /** Per-source refresh status. */
68
+ sources: SourceRefreshResult[];
69
+ }
70
+ /**
71
+ * Fetch every refreshable source and record the outcome.
72
+ *
73
+ * Unrefreshable sources (e.g. OpenAI, which has no stable pricing endpoint)
74
+ * are reported as skipped rather than silently ignored or scraped.
75
+ */
76
+ declare function refreshSources(sources: RefreshableSource[], opts: Pick<ReviewedRefreshOptions, "refresh" | "fetchImpl">): Promise<SourceRefreshResult[]>;
77
+ /**
78
+ * Run generators using the current snapshots (whether refreshed or committed)
79
+ * and produce reviewable file diffs.
80
+ */
81
+ declare function reviewedRefresh(gens: CatalogGenerator[], refreshableSources: RefreshableSource[], opts: ReviewedRefreshOptions): Promise<ReviewedRefreshResult>;
82
+
83
+ export { type CatalogFileDiff, type RefreshableSource, type ReviewedRefreshOptions, type ReviewedRefreshResult, type SourceRefreshResult, refreshSources, reviewedRefresh };
@@ -0,0 +1,161 @@
1
+ import { mkdirSync, writeFileSync, existsSync, readFileSync } from 'fs';
2
+ import { dirname, join, resolve } from 'path';
3
+ import { fileURLToPath } from 'url';
4
+
5
+ /**
6
+ * @agentproto/catalog-sync v0.1.0
7
+ * Build-time generator framework for @agentproto/model-catalog.
8
+ * Generates *.generated.ts from pinned provider sources.
9
+ */
10
+
11
+ var __dirname$1 = dirname(fileURLToPath(import.meta.url));
12
+ function catalogSyncDir() {
13
+ return resolve(__dirname$1, "..");
14
+ }
15
+ function snapshotPath(id) {
16
+ return join(catalogSyncDir(), "snapshots", `${id}.json`);
17
+ }
18
+ function repoRoot() {
19
+ let dir = catalogSyncDir();
20
+ for (let i = 0; i < 12; i++) {
21
+ if (existsSync(join(dir, "pnpm-workspace.yaml"))) return dir;
22
+ const parent = dirname(dir);
23
+ if (parent === dir) break;
24
+ dir = parent;
25
+ }
26
+ return dirname(dirname(catalogSyncDir()));
27
+ }
28
+ function readIfExists(absPath) {
29
+ if (!existsSync(absPath)) return void 0;
30
+ return readFileSync(absPath, "utf8");
31
+ }
32
+ function resolveHeaders(headers) {
33
+ const out = {};
34
+ const missing = [];
35
+ if (!headers) return { headers: out, missing };
36
+ for (const [key, value] of Object.entries(headers)) {
37
+ out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name) => {
38
+ const v = process.env[name];
39
+ if (v === void 0 || v === "") {
40
+ missing.push(name);
41
+ return "";
42
+ }
43
+ return v;
44
+ });
45
+ }
46
+ return { headers: out, missing };
47
+ }
48
+ async function refreshSources(sources, opts) {
49
+ const results = [];
50
+ const fetchImpl = opts.fetchImpl ?? fetch;
51
+ for (const { source, refreshable, notes } of sources) {
52
+ if (!opts.refresh) {
53
+ results.push({
54
+ id: source.id,
55
+ url: source.url,
56
+ refreshed: false,
57
+ notes: "Offline mode: using committed snapshot."
58
+ });
59
+ continue;
60
+ }
61
+ if (!refreshable) {
62
+ results.push({
63
+ id: source.id,
64
+ url: source.url,
65
+ refreshed: false,
66
+ skipped: true,
67
+ notes: notes ?? "Source is not refreshable."
68
+ });
69
+ continue;
70
+ }
71
+ const { headers, missing } = resolveHeaders(source.headers);
72
+ if (missing.length > 0) {
73
+ results.push({
74
+ id: source.id,
75
+ url: source.url,
76
+ refreshed: false,
77
+ error: `Missing env vars: ${missing.join(", ")}`
78
+ });
79
+ continue;
80
+ }
81
+ try {
82
+ const res = await fetchImpl(source.url, {
83
+ method: source.method ?? "GET",
84
+ headers,
85
+ ...source.body !== void 0 ? { body: JSON.stringify(source.body) } : {}
86
+ });
87
+ if (!res.ok) {
88
+ results.push({
89
+ id: source.id,
90
+ url: source.url,
91
+ refreshed: false,
92
+ error: `${res.status} ${res.statusText}`
93
+ });
94
+ continue;
95
+ }
96
+ const text = await res.text();
97
+ const parsed = JSON.parse(text);
98
+ mkdirSync(dirname(snapshotPath(source.id)), { recursive: true });
99
+ writeFileSync(
100
+ snapshotPath(source.id),
101
+ `${JSON.stringify(parsed, null, 2)}
102
+ `,
103
+ "utf8"
104
+ );
105
+ results.push({
106
+ id: source.id,
107
+ url: source.url,
108
+ refreshed: true,
109
+ notes: "Snapshot updated from live source."
110
+ });
111
+ } catch (err) {
112
+ results.push({
113
+ id: source.id,
114
+ url: source.url,
115
+ refreshed: false,
116
+ error: err instanceof Error ? err.message : String(err)
117
+ });
118
+ }
119
+ }
120
+ return results;
121
+ }
122
+ async function reviewedRefresh(gens, refreshableSources, opts) {
123
+ const sourceResults = await refreshSources(refreshableSources, opts);
124
+ const files = {};
125
+ for (const gen of gens) {
126
+ const ctx = {
127
+ refresh: opts.refresh,
128
+ async fetchSource(src) {
129
+ const path = snapshotPath(src.id);
130
+ const existing = readIfExists(path);
131
+ if (existing !== void 0) return JSON.parse(existing);
132
+ throw new Error(
133
+ `catalog-sync: no committed snapshot for source "${src.id}" (${path}).`
134
+ );
135
+ }
136
+ };
137
+ const out = await gen.generate(ctx);
138
+ Object.assign(files, out);
139
+ }
140
+ const root = repoRoot();
141
+ const diffs = [];
142
+ const changed = [];
143
+ for (const [relPath, after] of Object.entries(files)) {
144
+ const abs = join(root, relPath);
145
+ const before = readIfExists(abs);
146
+ const isChanged = before !== after;
147
+ diffs.push({ path: relPath, before, after, changed: isChanged });
148
+ if (isChanged) {
149
+ changed.push(relPath);
150
+ if (opts.write) {
151
+ mkdirSync(dirname(abs), { recursive: true });
152
+ writeFileSync(abs, after, "utf8");
153
+ }
154
+ }
155
+ }
156
+ return { files, changed, diffs, sources: sourceResults };
157
+ }
158
+
159
+ export { refreshSources, reviewedRefresh };
160
+ //# sourceMappingURL=refresh-workflow.mjs.map
161
+ //# sourceMappingURL=refresh-workflow.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/refresh-workflow.ts"],"names":["__dirname"],"mappings":";;;;;;;;;;AAyBA,IAAMA,WAAA,GAAY,OAAA,CAAQ,aAAA,CAAc,MAAA,CAAA,IAAA,CAAY,GAAG,CAAC,CAAA;AAExD,SAAS,cAAA,GAAyB;AAChC,EAAA,OAAO,OAAA,CAAQA,aAAW,IAAI,CAAA;AAChC;AAEA,SAAS,aAAa,EAA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AAM,UAAoB,EAAC;AAE3B,EAAA,KAAA,MAAW,CAAC,OAAA,EAAS,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AACpD,IAAA,MAAM,GAAA,GAAM,IAAA,CAAK,IAAA,EAAM,OAAO,CAAA;AAC9B,IAAA,MAAM,MAAA,GAAS,aAAa,GAAG,CAAA;AAC/B,IAAA,MAAM,YAAY,MAAA,KAAW,KAAA;AAC7B,IAAA,KAAA,CAAM,IAAA,CAAK,EAAE,IAAA,EAAM,OAAA,EAAS,QAAQ,KAAA,EAAO,OAAA,EAAS,WAAW,CAAA;AAC/D,IAAA,IAAI,SAAA,EAAW;AACb,MAAA,OAAA,CAAQ,KAAK,OAAO,CAAA;AACpB,MAAA,IAAI,KAAK,KAAA,EAAO;AACd,QAAA,SAAA,CAAU,QAAQ,GAAG,CAAA,EAAG,EAAE,SAAA,EAAW,MAAM,CAAA;AAC3C,QAAA,aAAA,CAAc,GAAA,EAAK,OAAO,MAAM,CAAA;AAAA,MAClC;AAAA,IACF;AAAA,EACF;AAEA,EAAA,OAAO,EAAE,KAAA,EAAO,OAAA,EAAS,KAAA,EAAO,SAAS,aAAA,EAAc;AACzD","file":"refresh-workflow.mjs","sourcesContent":["/**\n * Reviewed refresh workflow for catalog-sync.\n *\n * Extends the existing generator framework with explicit, reviewable diffs and\n * source-level metadata so operators can see exactly what changed and why.\n *\n * Design constraints (per project convention):\n * - Pricing is never fabricated.\n * - Refresh only hits pinned source URLs; unrefreshable sources are skipped\n * with an explanation.\n * - The committed snapshot is the single source of truth for offline runs.\n * - Availability-only local cache stays separate from the reviewed refresh.\n */\n\nimport { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\"\nimport { dirname, join, resolve } from \"node:path\"\nimport { fileURLToPath } from \"node:url\"\n\nimport type {\n CatalogGenerator,\n CatalogSource,\n GeneratedFiles,\n GeneratorContext,\n} from \"./types.js\"\n\nconst __dirname = dirname(fileURLToPath(import.meta.url))\n\nfunction catalogSyncDir(): string {\n return resolve(__dirname, \"..\")\n}\n\nfunction snapshotPath(id: string): string {\n return join(catalogSyncDir(), \"snapshots\", `${id}.json`)\n}\n\nfunction repoRoot(): string {\n let dir = catalogSyncDir()\n for (let i = 0; i < 12; i++) {\n if (existsSync(join(dir, \"pnpm-workspace.yaml\"))) return dir\n const parent = dirname(dir)\n if (parent === dir) break\n dir = parent\n }\n return dirname(dirname(catalogSyncDir()))\n}\n\nfunction readIfExists(absPath: string): string | undefined {\n if (!existsSync(absPath)) return undefined\n return readFileSync(absPath, \"utf8\")\n}\n\nfunction resolveHeaders(headers?: Record<string, string>): {\n headers: Record<string, string>\n missing: string[]\n} {\n const out: Record<string, string> = {}\n const missing: string[] = []\n if (!headers) return { headers: out, missing }\n for (const [key, value] of Object.entries(headers)) {\n out[key] = value.replace(/env:([A-Z0-9_]+)/g, (_match, name: string) => {\n const v = process.env[name]\n if (v === undefined || v === \"\") {\n missing.push(name)\n return \"\"\n }\n return v\n })\n }\n return { headers: out, missing }\n}\n\n// ── Source metadata ────────────────────────────────────────────────────────\n\n/**\n * Source-level refresh metadata. Wraps a frozen {@link CatalogSource} without\n * mutating it, so existing generators keep compiling unchanged.\n */\nexport interface RefreshableSource {\n source: CatalogSource\n /** When false, the source is skipped by --refresh and documented in results. */\n refreshable: boolean\n /** Human-readable explanation of the source contract or gap. */\n notes?: string\n}\n\nexport interface SourceRefreshResult {\n id: string\n url: string\n /** True when a live fetch was attempted and succeeded. */\n refreshed: boolean\n /** True when the source is known to be unrefreshable. */\n skipped?: boolean\n /** Human-readable status / gap explanation. */\n notes?: string\n /** Present when refresh was attempted but failed. */\n error?: string\n}\n\n// ── File diff ──────────────────────────────────────────────────────────────\n\nexport interface CatalogFileDiff {\n /** Repo-relative path. */\n path: string\n /** Content currently on disk, or undefined when the file does not exist. */\n before: string | undefined\n /** Generated content. */\n after: string\n /** True when before !== after. */\n changed: boolean\n}\n\n// ── Options / result ───────────────────────────────────────────────────────\n\nexport interface ReviewedRefreshOptions {\n /** When true, attempt live fetches for refreshable sources. */\n refresh: boolean\n /** When true, write generated files to disk. */\n write: boolean\n /**\n * Optional fetch implementation for tests. Defaults to the global `fetch`.\n */\n fetchImpl?: typeof fetch\n}\n\nexport interface ReviewedRefreshResult {\n /** Generated repo-relative path → content. */\n files: GeneratedFiles\n /** Repo-relative paths whose generated content differs from disk. */\n changed: string[]\n /** Per-file before/after reviewable diffs. */\n diffs: CatalogFileDiff[]\n /** Per-source refresh status. */\n sources: SourceRefreshResult[]\n}\n\n// ── Implementation ─────────────────────────────────────────────────────────\n\n/**\n * Fetch every refreshable source and record the outcome.\n *\n * Unrefreshable sources (e.g. OpenAI, which has no stable pricing endpoint)\n * are reported as skipped rather than silently ignored or scraped.\n */\nexport async function refreshSources(\n sources: RefreshableSource[],\n opts: Pick<ReviewedRefreshOptions, \"refresh\" | \"fetchImpl\">\n): Promise<SourceRefreshResult[]> {\n const results: SourceRefreshResult[] = []\n const fetchImpl = opts.fetchImpl ?? fetch\n\n for (const { source, refreshable, notes } of sources) {\n if (!opts.refresh) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n notes: \"Offline mode: using committed snapshot.\",\n })\n continue\n }\n\n if (!refreshable) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n skipped: true,\n notes: notes ?? \"Source is not refreshable.\",\n })\n continue\n }\n\n const { headers, missing } = resolveHeaders(source.headers)\n if (missing.length > 0) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `Missing env vars: ${missing.join(\", \")}`,\n })\n continue\n }\n\n try {\n const res = await fetchImpl(source.url, {\n method: source.method ?? \"GET\",\n headers,\n ...(source.body !== undefined\n ? { body: JSON.stringify(source.body) }\n : {}),\n })\n if (!res.ok) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: `${res.status} ${res.statusText}`,\n })\n continue\n }\n const text = await res.text()\n const parsed: unknown = JSON.parse(text)\n mkdirSync(dirname(snapshotPath(source.id)), { recursive: true })\n writeFileSync(\n snapshotPath(source.id),\n `${JSON.stringify(parsed, null, 2)}\\n`,\n \"utf8\"\n )\n results.push({\n id: source.id,\n url: source.url,\n refreshed: true,\n notes: \"Snapshot updated from live source.\",\n })\n } catch (err) {\n results.push({\n id: source.id,\n url: source.url,\n refreshed: false,\n error: err instanceof Error ? err.message : String(err),\n })\n }\n }\n\n return results\n}\n\n/**\n * Run generators using the current snapshots (whether refreshed or committed)\n * and produce reviewable file diffs.\n */\nexport async function reviewedRefresh(\n gens: CatalogGenerator[],\n refreshableSources: RefreshableSource[],\n opts: ReviewedRefreshOptions\n): Promise<ReviewedRefreshResult> {\n const sourceResults = await refreshSources(refreshableSources, opts)\n\n const files: GeneratedFiles = {}\n for (const gen of gens) {\n const ctx: GeneratorContext = {\n refresh: opts.refresh,\n async fetchSource(src: CatalogSource): Promise<unknown> {\n const path = snapshotPath(src.id)\n const existing = readIfExists(path)\n if (existing !== undefined) return JSON.parse(existing)\n throw new Error(\n `catalog-sync: no committed snapshot for source \"${src.id}\" (${path}).`\n )\n },\n }\n const out = await gen.generate(ctx)\n Object.assign(files, out)\n }\n\n const root = repoRoot()\n const diffs: CatalogFileDiff[] = []\n const changed: string[] = []\n\n for (const [relPath, after] of Object.entries(files)) {\n const abs = join(root, relPath)\n const before = readIfExists(abs)\n const isChanged = before !== after\n diffs.push({ path: relPath, before, after, changed: isChanged })\n if (isChanged) {\n changed.push(relPath)\n if (opts.write) {\n mkdirSync(dirname(abs), { recursive: true })\n writeFileSync(abs, after, \"utf8\")\n }\n }\n }\n\n return { files, changed, diffs, sources: sourceResults }\n}\n"]}
@@ -0,0 +1,26 @@
1
+ import { RefreshableSource } from '../refresh-workflow.js';
2
+ import '../types.js';
3
+
4
+ /**
5
+ * OpenAI LLM source contract.
6
+ *
7
+ * OpenAI does **not** publish a stable, machine-readable pricing/model catalog
8
+ * endpoint. The authoritative pricing page is `openai.com/api/pricing`, but it
9
+ * is HTML-only, not a documented API, and has historically changed layout
10
+ * without notice.
11
+ *
12
+ * Therefore this source is intentionally **not refreshable** in the automated
13
+ * `catalog-sync` workflow. Pricing is committed by hand from the official page
14
+ * and cross-checked with third-party aggregators where noted. We do not scrape
15
+ * or guess.
16
+ *
17
+ * If OpenAI releases a stable `/v1/models` endpoint that includes pricing, or
18
+ * a documented pricing JSON feed, this source can be upgraded to refreshable.
19
+ * Until then, the gap is recorded honestly in refresh results.
20
+ */
21
+
22
+ declare const OPENAI_LLM_SOURCE: RefreshableSource;
23
+ /** Convenience array for workflows that want to include the OpenAI contract. */
24
+ declare const OPENAI_SOURCES: RefreshableSource[];
25
+
26
+ export { OPENAI_LLM_SOURCE, OPENAI_SOURCES };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @agentproto/catalog-sync v0.1.0
3
+ * Build-time generator framework for @agentproto/model-catalog.
4
+ * Generates *.generated.ts from pinned provider sources.
5
+ */
6
+
7
+ // src/sources/openai.ts
8
+ var OPENAI_LLM_SOURCE = {
9
+ source: {
10
+ id: "llm-openai",
11
+ url: "https://openai.com/api/pricing"
12
+ },
13
+ refreshable: false,
14
+ notes: "OpenAI has no stable machine-readable pricing endpoint. Pricing in @agentproto/model-catalog is committed manually from openai.com/api/pricing and verified against independent aggregators where possible. Automated refresh is disabled to avoid scraping or fabricating prices."
15
+ };
16
+ var OPENAI_SOURCES = [OPENAI_LLM_SOURCE];
17
+
18
+ export { OPENAI_LLM_SOURCE, OPENAI_SOURCES };
19
+ //# sourceMappingURL=openai.mjs.map
20
+ //# sourceMappingURL=openai.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/sources/openai.ts"],"names":[],"mappings":";;;;;;;AAoBO,IAAM,iBAAA,GAAuC;AAAA,EAClD,MAAA,EAAQ;AAAA,IACN,EAAA,EAAI,YAAA;AAAA,IACJ,GAAA,EAAK;AAAA,GACP;AAAA,EACA,WAAA,EAAa,KAAA;AAAA,EACb,KAAA,EACE;AAKJ;AAGO,IAAM,cAAA,GAAsC,CAAC,iBAAiB","file":"openai.mjs","sourcesContent":["/**\n * OpenAI LLM source contract.\n *\n * OpenAI does **not** publish a stable, machine-readable pricing/model catalog\n * endpoint. The authoritative pricing page is `openai.com/api/pricing`, but it\n * is HTML-only, not a documented API, and has historically changed layout\n * without notice.\n *\n * Therefore this source is intentionally **not refreshable** in the automated\n * `catalog-sync` workflow. Pricing is committed by hand from the official page\n * and cross-checked with third-party aggregators where noted. We do not scrape\n * or guess.\n *\n * If OpenAI releases a stable `/v1/models` endpoint that includes pricing, or\n * a documented pricing JSON feed, this source can be upgraded to refreshable.\n * Until then, the gap is recorded honestly in refresh results.\n */\n\nimport type { RefreshableSource } from \"../refresh-workflow.js\"\n\nexport const OPENAI_LLM_SOURCE: RefreshableSource = {\n source: {\n id: \"llm-openai\",\n url: \"https://openai.com/api/pricing\",\n },\n refreshable: false,\n notes:\n \"OpenAI has no stable machine-readable pricing endpoint. \" +\n \"Pricing in @agentproto/model-catalog is committed manually from \" +\n \"openai.com/api/pricing and verified against independent aggregators \" +\n \"where possible. Automated refresh is disabled to avoid scraping or \" +\n \"fabricating prices.\",\n}\n\n/** Convenience array for workflows that want to include the OpenAI contract. */\nexport const OPENAI_SOURCES: RefreshableSource[] = [OPENAI_LLM_SOURCE]\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentproto/catalog-sync",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Build-time generator framework for @agentproto/model-catalog. Generates *.generated.ts from pinned provider sources (LLM, image, video, audio, voice).",
5
5
  "keywords": [
6
6
  "agentproto",
@@ -18,7 +18,7 @@
18
18
  "bugs": {
19
19
  "url": "https://github.com/agentproto/ts/issues"
20
20
  },
21
- "license": "MIT",
21
+ "license": "Apache-2.0",
22
22
  "publishConfig": {
23
23
  "access": "public"
24
24
  },
@@ -55,11 +55,21 @@
55
55
  "types": "./dist/generators/llm-openrouter.d.ts",
56
56
  "import": "./dist/generators/llm-openrouter.mjs",
57
57
  "default": "./dist/generators/llm-openrouter.mjs"
58
+ },
59
+ "./refresh-workflow": {
60
+ "types": "./dist/refresh-workflow.d.ts",
61
+ "import": "./dist/refresh-workflow.mjs",
62
+ "default": "./dist/refresh-workflow.mjs"
63
+ },
64
+ "./sources/openai": {
65
+ "types": "./dist/sources/openai.d.ts",
66
+ "import": "./dist/sources/openai.mjs",
67
+ "default": "./dist/sources/openai.mjs"
58
68
  }
59
69
  },
60
70
  "dependencies": {
61
71
  "zod": "^4.4.3",
62
- "@agentproto/model-catalog": "0.2.0"
72
+ "@agentproto/model-catalog": "0.3.0"
63
73
  },
64
74
  "devDependencies": {
65
75
  "@types/node": "^25.6.2",