@zenera/meta 0.0.0-stage → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +156 -2
  3. package/dist/command.d.ts +5 -0
  4. package/dist/command.js +1086 -0
  5. package/dist/dataset/anchors.d.ts +41 -0
  6. package/dist/dataset/anchors.js +239 -0
  7. package/dist/dataset/changes.d.ts +36 -0
  8. package/dist/dataset/changes.js +319 -0
  9. package/dist/dataset/command.d.ts +17 -0
  10. package/dist/dataset/command.js +1011 -0
  11. package/dist/dataset/drift.d.ts +33 -0
  12. package/dist/dataset/drift.js +71 -0
  13. package/dist/dataset/export.d.ts +26 -0
  14. package/dist/dataset/export.js +51 -0
  15. package/dist/dataset/index.d.ts +2 -0
  16. package/dist/dataset/index.js +2 -0
  17. package/dist/dataset/sample.d.ts +50 -0
  18. package/dist/dataset/sample.js +197 -0
  19. package/dist/dataset/schema.d.ts +33 -0
  20. package/dist/dataset/schema.js +216 -0
  21. package/dist/dataset/store.d.ts +35 -0
  22. package/dist/dataset/store.js +177 -0
  23. package/dist/dataset/types.d.ts +127 -0
  24. package/dist/dataset/types.js +39 -0
  25. package/dist/finetune/analyze-brief.d.ts +26 -0
  26. package/dist/finetune/analyze-brief.js +131 -0
  27. package/dist/finetune/apply-brief.d.ts +23 -0
  28. package/dist/finetune/apply-brief.js +247 -0
  29. package/dist/finetune/brief.d.ts +45 -0
  30. package/dist/finetune/brief.js +158 -0
  31. package/dist/finetune/children.d.ts +8 -0
  32. package/dist/finetune/children.js +76 -0
  33. package/dist/finetune/command.d.ts +30 -0
  34. package/dist/finetune/command.js +520 -0
  35. package/dist/finetune/cost.d.ts +46 -0
  36. package/dist/finetune/cost.js +105 -0
  37. package/dist/finetune/failure.d.ts +15 -0
  38. package/dist/finetune/failure.js +26 -0
  39. package/dist/finetune/feedback.d.ts +57 -0
  40. package/dist/finetune/feedback.js +104 -0
  41. package/dist/finetune/improvements.d.ts +98 -0
  42. package/dist/finetune/improvements.js +501 -0
  43. package/dist/finetune/index.d.ts +2 -0
  44. package/dist/finetune/index.js +2 -0
  45. package/dist/finetune/journal.d.ts +35 -0
  46. package/dist/finetune/journal.js +135 -0
  47. package/dist/finetune/live.d.ts +84 -0
  48. package/dist/finetune/live.js +272 -0
  49. package/dist/finetune/loop.d.ts +3 -0
  50. package/dist/finetune/loop.js +163 -0
  51. package/dist/finetune/memories.d.ts +47 -0
  52. package/dist/finetune/memories.js +171 -0
  53. package/dist/finetune/next-case.d.ts +18 -0
  54. package/dist/finetune/next-case.js +47 -0
  55. package/dist/finetune/recheck.d.ts +58 -0
  56. package/dist/finetune/recheck.js +311 -0
  57. package/dist/finetune/report.d.ts +40 -0
  58. package/dist/finetune/report.js +1397 -0
  59. package/dist/finetune/retry.d.ts +24 -0
  60. package/dist/finetune/retry.js +96 -0
  61. package/dist/finetune/system.d.ts +27 -0
  62. package/dist/finetune/system.js +132 -0
  63. package/dist/finetune/train.d.ts +43 -0
  64. package/dist/finetune/train.js +425 -0
  65. package/dist/finetune/tui.d.ts +16 -0
  66. package/dist/finetune/tui.js +316 -0
  67. package/dist/finetune/tuning.d.ts +193 -0
  68. package/dist/finetune/tuning.js +308 -0
  69. package/dist/finetune/usage.d.ts +66 -0
  70. package/dist/finetune/usage.js +260 -0
  71. package/dist/finetune/view.d.ts +9 -0
  72. package/dist/finetune/view.js +27 -0
  73. package/dist/host.d.ts +2 -0
  74. package/dist/host.js +14 -0
  75. package/dist/index.d.ts +10 -0
  76. package/dist/index.js +15 -0
  77. package/dist/launch.d.ts +90 -0
  78. package/dist/launch.js +310 -0
  79. package/dist/model.d.ts +61 -0
  80. package/dist/model.js +146 -0
  81. package/dist/prompts.d.ts +23 -0
  82. package/dist/prompts.js +84 -0
  83. package/dist/relay.d.ts +20 -0
  84. package/dist/relay.js +123 -0
  85. package/dist/sink.d.ts +61 -0
  86. package/dist/sink.js +198 -0
  87. package/dist/tokens.d.ts +52 -0
  88. package/dist/tokens.js +226 -0
  89. package/dist/wire.d.ts +51 -0
  90. package/dist/wire.js +159 -0
  91. package/package.json +54 -5
package/dist/tokens.js ADDED
@@ -0,0 +1,226 @@
1
+ import { closeSync, existsSync, openSync, readFileSync, readSync, statSync } from 'node:fs';
2
+ import { homedir } from 'node:os';
3
+ import { join } from 'node:path';
4
+ /** An OTel time: `[seconds, nanoseconds]` in this exporter; epoch ms either way. */
5
+ function epochMs(t) {
6
+ if (Array.isArray(t) && typeof t[0] === 'number') {
7
+ return t[0] * 1000 + Number(t[1] ?? 0) / 1e6;
8
+ }
9
+ if (typeof t === 'number') {
10
+ return t;
11
+ }
12
+ return typeof t === 'string' ? Date.parse(t) : undefined;
13
+ }
14
+ /**
15
+ * One line of the span file, as a model call - anything else is undefined.
16
+ * Only counts are read off it: whatever else a span may carry, none of it
17
+ * reaches the ledger.
18
+ */
19
+ export function readSpan(line) {
20
+ let span;
21
+ try {
22
+ span = JSON.parse(line);
23
+ }
24
+ catch {
25
+ return undefined;
26
+ }
27
+ const attrs = (span.attributes ?? {});
28
+ if (span.type !== 'span' || attrs['gen_ai.operation.name'] !== 'chat') {
29
+ return undefined;
30
+ }
31
+ const num = (key) => Number(attrs[key] ?? 0) || 0;
32
+ const start = epochMs(span.startTime) ?? 0;
33
+ const end = epochMs(span.endTime) ?? start;
34
+ // Copilot counts reasoning beside the output; zen counts it inside.
35
+ const reasoning = num('gen_ai.usage.reasoning.output_tokens');
36
+ const cacheWrite = num('gen_ai.usage.cache_creation.input_tokens') ||
37
+ num('gen_ai.usage.cache_creation_input_tokens');
38
+ return {
39
+ model: String(attrs['gen_ai.response.model'] ?? attrs['gen_ai.request.model'] ?? '?'),
40
+ usage: {
41
+ inputTokens: num('gen_ai.usage.input_tokens'),
42
+ cachedInputTokens: num('gen_ai.usage.cache_read.input_tokens') ||
43
+ num('gen_ai.usage.cache_read_input_tokens'),
44
+ outputTokens: num('gen_ai.usage.output_tokens') + reasoning,
45
+ reasoningTokens: reasoning,
46
+ },
47
+ ...(cacheWrite ? { cacheWriteTokens: cacheWrite } : {}),
48
+ startedAt: new Date(start).toISOString(),
49
+ durationMs: Math.max(0, Math.round(end - start)),
50
+ session: typeof attrs['gen_ai.conversation.id'] === 'string'
51
+ ? attrs['gen_ai.conversation.id']
52
+ : undefined,
53
+ traceId: typeof span.traceId === 'string' ? span.traceId : undefined,
54
+ spanId: typeof span.spanId === 'string' ? span.spanId : undefined,
55
+ };
56
+ }
57
+ /** Whole lines out of a stream read in chunks; the unfinished tail is carried. */
58
+ export function splitLines(carry, chunk) {
59
+ const parts = `${carry}${chunk}`.split('\n');
60
+ const rest = parts.pop() ?? '';
61
+ return { lines: parts.filter((l) => l.trim()), carry: rest };
62
+ }
63
+ /** Reads a span file as it grows. `stop()` reads what is left, once. */
64
+ export function tailSpans(path, onCall, everyMs = 1000) {
65
+ let offset = 0;
66
+ let carry = '';
67
+ const poll = () => {
68
+ let fd;
69
+ try {
70
+ const size = statSync(path).size;
71
+ if (size <= offset) {
72
+ return;
73
+ }
74
+ fd = openSync(path, 'r');
75
+ const buf = Buffer.alloc(size - offset);
76
+ readSync(fd, buf, 0, buf.length, offset);
77
+ offset = size;
78
+ const split = splitLines(carry, buf.toString('utf8'));
79
+ carry = split.carry;
80
+ for (const line of split.lines) {
81
+ const call = readSpan(line);
82
+ if (call) {
83
+ onCall(call);
84
+ }
85
+ }
86
+ }
87
+ catch {
88
+ // Not there yet: copilot creates it at the first span.
89
+ }
90
+ finally {
91
+ if (fd !== undefined) {
92
+ closeSync(fd);
93
+ }
94
+ }
95
+ };
96
+ const timer = setInterval(poll, everyMs);
97
+ timer.unref();
98
+ return {
99
+ stop: () => {
100
+ clearInterval(timer);
101
+ poll();
102
+ },
103
+ };
104
+ }
105
+ /** Calls and tokens so far, in the one line the status row and the summary share. */
106
+ export class Tally {
107
+ calls = 0;
108
+ usage = {
109
+ inputTokens: 0,
110
+ cachedInputTokens: 0,
111
+ outputTokens: 0,
112
+ reasoningTokens: 0,
113
+ };
114
+ add(call) {
115
+ this.calls += 1;
116
+ this.usage = {
117
+ inputTokens: this.usage.inputTokens + call.usage.inputTokens,
118
+ cachedInputTokens: this.usage.cachedInputTokens + call.usage.cachedInputTokens,
119
+ outputTokens: this.usage.outputTokens + call.usage.outputTokens,
120
+ reasoningTokens: this.usage.reasoningTokens + call.usage.reasoningTokens,
121
+ };
122
+ }
123
+ toString() {
124
+ const u = this.usage;
125
+ const cached = u.cachedInputTokens ? ` (${compact(u.cachedInputTokens)} cached)` : '';
126
+ return (`${this.calls} call${this.calls === 1 ? '' : 's'} · ${compact(u.inputTokens)} in${cached}` +
127
+ ` · ${compact(u.outputTokens)} out`);
128
+ }
129
+ }
130
+ /** 950, 12.3k, 1.8M. */
131
+ export function compact(n) {
132
+ if (n < 1000) {
133
+ return String(n);
134
+ }
135
+ if (n < 1e6) {
136
+ return `${(n / 1e3).toFixed(n < 1e4 ? 1 : 0)}k`;
137
+ }
138
+ return `${(n / 1e6).toFixed(n < 1e7 ? 2 : 1)}M`;
139
+ }
140
+ /**
141
+ * Copilot's own per-model totals from the last `session.shutdown` in a session's
142
+ * events - cumulative over every resume of it. Reasoning folded into output,
143
+ * as everywhere in zen.
144
+ */
145
+ export function shutdownModels(events) {
146
+ const line = events
147
+ .split('\n')
148
+ .reverse()
149
+ .find((l) => l.includes('"session.shutdown"'));
150
+ if (!line) {
151
+ return undefined;
152
+ }
153
+ let metrics;
154
+ try {
155
+ metrics = JSON.parse(line).data?.modelMetrics ?? {};
156
+ }
157
+ catch {
158
+ return undefined;
159
+ }
160
+ return Object.entries(metrics).map(([model, m]) => {
161
+ const u = m.usage ?? {};
162
+ const reasoning = Number(u.reasoningTokens ?? 0);
163
+ return {
164
+ model,
165
+ calls: Number(m.requests?.count ?? 0),
166
+ usage: {
167
+ inputTokens: Number(u.inputTokens ?? 0),
168
+ cachedInputTokens: Number(u.cacheReadTokens ?? 0),
169
+ outputTokens: Number(u.outputTokens ?? 0) + reasoning,
170
+ reasoningTokens: reasoning,
171
+ },
172
+ };
173
+ });
174
+ }
175
+ export function sessionTotals(sessionId) {
176
+ const home = process.env.COPILOT_HOME ?? join(homedir(), '.copilot');
177
+ try {
178
+ return shutdownModels(readFileSync(join(home, 'session-state', sessionId, 'events.jsonl'), 'utf8'));
179
+ }
180
+ catch {
181
+ return undefined;
182
+ }
183
+ }
184
+ /** Whether this machine holds the session, which is what `--resume` needs. */
185
+ export function sessionKept(sessionId) {
186
+ const home = process.env.COPILOT_HOME ?? join(homedir(), '.copilot');
187
+ return existsSync(join(home, 'session-state', sessionId));
188
+ }
189
+ /**
190
+ * The model a session's history was written by: its last answer's, else the one it started on.
191
+ * A failed resume on another model writes no answer, so it never becomes the session's model.
192
+ */
193
+ export function sessionModel(sessionId) {
194
+ const home = process.env.COPILOT_HOME ?? join(homedir(), '.copilot');
195
+ let text;
196
+ try {
197
+ text = readFileSync(join(home, 'session-state', sessionId, 'events.jsonl'), 'utf8');
198
+ }
199
+ catch {
200
+ return undefined;
201
+ }
202
+ let started;
203
+ const lines = text.split('\n');
204
+ for (let i = lines.length - 1; i >= 0; i--) {
205
+ const line = lines[i];
206
+ if (!line.includes('"assistant.message"') && !line.includes('"session.start"')) {
207
+ continue;
208
+ }
209
+ try {
210
+ const event = JSON.parse(line);
211
+ if (event.type === 'assistant.message' && typeof event.data?.model === 'string') {
212
+ return event.data.model;
213
+ }
214
+ if (event.type === 'session.start' && typeof event.data?.selectedModel === 'string') {
215
+ started = event.data.selectedModel;
216
+ }
217
+ }
218
+ catch {
219
+ // A line cut by a crash says nothing.
220
+ }
221
+ }
222
+ return started;
223
+ }
224
+ /** `google/gemini-3.8-flash` and `gemini-3.8-flash` are one model to copilot. */
225
+ export const sameModel = (a, b) => a.replace(/^.*\//, '').toLowerCase() === b.replace(/^.*\//, '').toLowerCase();
226
+ //# sourceMappingURL=tokens.js.map
package/dist/wire.d.ts ADDED
@@ -0,0 +1,51 @@
1
+ import { type Gateway } from '@zenera/neo';
2
+ import { type KeyEntry, type KeyStore, type Provider } from './host.ts';
3
+ /**
4
+ * Copilot offers its tools as OpenAI *custom* tools, which the completions API
5
+ * rejects outright — `400 Invalid value: 'custom'`. Only the responses API
6
+ * takes them, and only the reasoning models serve it, so the wire API follows
7
+ * the model rather than being a flag nobody would know to set. Older models are
8
+ * listed rather than newer ones, so each new generation works without a release.
9
+ */
10
+ export declare function wireApi(provider: Provider, id: string): string | undefined;
11
+ /** Whether copilot's tools survive the model: OpenAI's completions-only models refuse them. */
12
+ export declare function metaCompatible(provider: Provider, id: string): boolean;
13
+ export interface Wiring {
14
+ provider: Provider;
15
+ /** what the model is called on the wire */
16
+ model: string;
17
+ /** every `COPILOT_*` name and value, ready to hand to the child */
18
+ env: Record<string, string>;
19
+ /** names whose values are secret, for `--secret-env-vars` and for masking */
20
+ secret: string[];
21
+ /** anything true but unwelcome: a location that will be slow, a stale default */
22
+ warnings: string[];
23
+ /** Claude on Vertex: a loopback relay to start, whose url becomes the base url */
24
+ relay?: {
25
+ key: string;
26
+ project: string;
27
+ location: string;
28
+ keyFile: string;
29
+ };
30
+ }
31
+ /** Where the relay's url goes once it is listening. */
32
+ export declare const RELAY_URL = "http://127.0.0.1:<relay>";
33
+ /**
34
+ * Turns a zen key entry and a model id into copilot's environment.
35
+ *
36
+ * `COPILOT_PROVIDER_BASE_URL` is what activates BYOK at all, so every provider
37
+ * gets one — including OpenAI, whose url copilot would otherwise have reached
38
+ * through a GitHub account we are deliberately not using.
39
+ */
40
+ export declare function wire(store: KeyStore, entry: KeyEntry, id: string): Wiring;
41
+ /**
42
+ * Through a gateway: one virtual key, and Bifrost's OpenAI or Anthropic drop-in,
43
+ * which routes on an `<upstream>/<id>` wire model. Claude speaks Anthropic
44
+ * wherever it is hosted; everything else goes through the OpenAI one.
45
+ */
46
+ export declare function wireGateway(at: Gateway, provider: Provider, id: string): Wiring;
47
+ /** Values a `--dry-run` may print. A key is four characters and an apology. */
48
+ export declare function masked(env: Record<string, string>, secret: readonly string[]): string[];
49
+ /** Non-fatal, said once, because a competing file is a silent override. */
50
+ export declare function providersWarning(): string | undefined;
51
+ //# sourceMappingURL=wire.d.ts.map
package/dist/wire.js ADDED
@@ -0,0 +1,159 @@
1
+ import { GATEWAY_UPSTREAMS } from '@zenera/neo';
2
+ import { randomBytes } from 'node:crypto';
3
+ import { existsSync } from 'node:fs';
4
+ import { credentialError, envOf, invokedAs, yellow, } from "./host.js";
5
+ const TYPES = {
6
+ openai: 'openai',
7
+ anthropic: 'anthropic',
8
+ google: 'openai',
9
+ vertex: 'openai',
10
+ openrouter: 'openai',
11
+ };
12
+ const BASE_URLS = {
13
+ openai: 'https://api.openai.com/v1',
14
+ anthropic: 'https://api.anthropic.com',
15
+ google: 'https://generativelanguage.googleapis.com/v1beta/openai/',
16
+ openrouter: 'https://openrouter.ai/api/v1',
17
+ };
18
+ /**
19
+ * Copilot offers its tools as OpenAI *custom* tools, which the completions API
20
+ * rejects outright — `400 Invalid value: 'custom'`. Only the responses API
21
+ * takes them, and only the reasoning models serve it, so the wire API follows
22
+ * the model rather than being a flag nobody would know to set. Older models are
23
+ * listed rather than newer ones, so each new generation works without a release.
24
+ */
25
+ export function wireApi(provider, id) {
26
+ return provider === 'openai' && !/^(gpt-4|gpt-3\.5|chatgpt-)/.test(id)
27
+ ? 'responses'
28
+ : undefined;
29
+ }
30
+ /** Whether copilot's tools survive the model: OpenAI's completions-only models refuse them. */
31
+ export function metaCompatible(provider, id) {
32
+ return provider !== 'openai' || wireApi(provider, id) !== undefined;
33
+ }
34
+ /** Where the relay's url goes once it is listening. */
35
+ export const RELAY_URL = 'http://127.0.0.1:<relay>';
36
+ const vertexClaude = (id) => /^(anthropic\/)?claude-/.test(id);
37
+ /**
38
+ * Turns a zen key entry and a model id into copilot's environment.
39
+ *
40
+ * `COPILOT_PROVIDER_BASE_URL` is what activates BYOK at all, so every provider
41
+ * gets one — including OpenAI, whose url copilot would otherwise have reached
42
+ * through a GitHub account we are deliberately not using.
43
+ */
44
+ export function wire(store, entry, id) {
45
+ const provider = entry.provider;
46
+ const env = {};
47
+ const secret = [];
48
+ const warnings = [];
49
+ env.COPILOT_PROVIDER_TYPE = TYPES[provider];
50
+ env.COPILOT_MODEL = id;
51
+ if (provider === 'vertex' && vertexClaude(id)) {
52
+ const project = store.projectOf(entry)?.id;
53
+ if (entry.holds !== 'file' || !project) {
54
+ throw credentialError(`Claude on vertex needs a service account and a GCP project, not ${entry.provider}/${entry.name}`, 'add one: zen key add vertex --project <id>');
55
+ }
56
+ const model = id.replace(/^anthropic\//, '');
57
+ const key = randomBytes(24).toString('hex');
58
+ env.COPILOT_PROVIDER_TYPE = 'anthropic';
59
+ env.COPILOT_MODEL = model;
60
+ env.COPILOT_PROVIDER_BASE_URL = RELAY_URL;
61
+ env.COPILOT_PROVIDER_API_KEY = key;
62
+ return {
63
+ provider,
64
+ model,
65
+ env,
66
+ secret: ['COPILOT_PROVIDER_API_KEY'],
67
+ warnings,
68
+ relay: {
69
+ key,
70
+ project,
71
+ location: entry.location?.trim() || 'global',
72
+ keyFile: store.fileOf(entry),
73
+ },
74
+ };
75
+ }
76
+ if (provider === 'vertex') {
77
+ const project = store.projectOf(entry)?.id;
78
+ if (!project) {
79
+ throw credentialError(`no GCP project on ${entry.provider}/${entry.name}`, 'set one: zen key add vertex --project <id>');
80
+ }
81
+ const named = entry.location?.trim() || 'global';
82
+ const partner = id.includes('/') && !id.startsWith('google/');
83
+ // Gemini serves the `us`/`eu` multi-regions; partner models answer them with a 404 or 429.
84
+ const location = partner && (named === 'us' || named === 'eu') ? 'global' : named;
85
+ if (location === 'global' && !partner) {
86
+ warnings.push('location `global` adds about ten seconds of cold start');
87
+ }
88
+ env.COPILOT_PROVIDER_BASE_URL = `https://aiplatform.googleapis.com/v1/projects/${project}/locations/${location}/endpoints/openapi`;
89
+ // Vertex speaks publisher names on the wire and knows nothing of zen's
90
+ // provider prefix; the bare id stays as the model *id* so copilot can
91
+ // still match its catalogue for token limits and tool support.
92
+ env.COPILOT_PROVIDER_WIRE_MODEL = id.includes('/') ? id : `google/${id}`;
93
+ // Only Google's own ids are bare: `gpt-oss-…` would get GPT's custom `apply_patch`, which this endpoint rejects.
94
+ env.COPILOT_PROVIDER_MODEL_ID = id.startsWith('google/') ? id.slice('google/'.length) : id;
95
+ }
96
+ else {
97
+ const url = BASE_URLS[provider];
98
+ if (!url) {
99
+ throw credentialError(`no BYOK endpoint known for ${provider}`);
100
+ }
101
+ env.COPILOT_PROVIDER_BASE_URL = url;
102
+ }
103
+ const api = wireApi(provider, id);
104
+ if (api) {
105
+ env.COPILOT_PROVIDER_WIRE_API = api;
106
+ }
107
+ if (entry.holds === 'file') {
108
+ // A Google access token is good for an hour and a session is not, so
109
+ // copilot is told how to mint one rather than handed one that will be
110
+ // stale by the time it matters.
111
+ env.COPILOT_PROVIDER_API_KEY_COMMAND = `${invokedAs('zen')} key token ${entry.provider}`;
112
+ env[envOf(entry)] = store.fileOf(entry);
113
+ }
114
+ else {
115
+ env.COPILOT_PROVIDER_API_KEY = store.reveal(entry);
116
+ secret.push('COPILOT_PROVIDER_API_KEY');
117
+ }
118
+ return { provider, model: env.COPILOT_PROVIDER_WIRE_MODEL ?? id, env, secret, warnings };
119
+ }
120
+ /**
121
+ * Through a gateway: one virtual key, and Bifrost's OpenAI or Anthropic drop-in,
122
+ * which routes on an `<upstream>/<id>` wire model. Claude speaks Anthropic
123
+ * wherever it is hosted; everything else goes through the OpenAI one.
124
+ */
125
+ export function wireGateway(at, provider, id) {
126
+ const claude = provider === 'anthropic' || (provider === 'vertex' && vertexClaude(id));
127
+ const model = provider === 'vertex' ? id.replace(/^anthropic\//, '') : id;
128
+ const env = {
129
+ COPILOT_PROVIDER_TYPE: claude ? 'anthropic' : 'openai',
130
+ COPILOT_PROVIDER_BASE_URL: `${at.baseURL}${claude ? '/anthropic' : '/openai/v1'}`,
131
+ COPILOT_PROVIDER_MODEL_ID: model.replace(/^google\//, ''),
132
+ COPILOT_PROVIDER_WIRE_MODEL: `${GATEWAY_UPSTREAMS[provider]}/${model}`,
133
+ };
134
+ const api = wireApi(provider, model);
135
+ if (api) {
136
+ env.COPILOT_PROVIDER_WIRE_API = api;
137
+ }
138
+ const secret = [];
139
+ if (at.apiKey) {
140
+ env.COPILOT_PROVIDER_API_KEY = at.apiKey;
141
+ secret.push('COPILOT_PROVIDER_API_KEY');
142
+ }
143
+ return { provider, model: env.COPILOT_PROVIDER_WIRE_MODEL, env, secret, warnings: [] };
144
+ }
145
+ /** Values a `--dry-run` may print. A key is four characters and an apology. */
146
+ export function masked(env, secret) {
147
+ return Object.entries(env)
148
+ .sort(([a], [b]) => a.localeCompare(b))
149
+ .map(([name, value]) => `${name}=${secret.includes(name) ? '••••' : value}`);
150
+ }
151
+ /** Non-fatal, said once, because a competing file is a silent override. */
152
+ export function providersWarning() {
153
+ const configured = process.env.COPILOT_PROVIDERS_CONFIG;
154
+ const path = configured ?? `${process.env.HOME ?? ''}/.copilot/providers.json`;
155
+ return existsSync(path)
156
+ ? yellow(`${path} may override the provider zen just wired`)
157
+ : undefined;
158
+ }
159
+ //# sourceMappingURL=wire.js.map
package/package.json CHANGED
@@ -1,6 +1,55 @@
1
1
  {
2
- "name": "@zenera/meta",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "@zenera/meta",
3
+ "version": "1.3.1",
4
+ "description": "The meta agent for zen: GitHub Copilot over a zen project on your own keys, plus the dataset and fine-tuning loop.",
5
+ "keywords": [
6
+ "agents",
7
+ "ai-agents",
8
+ "copilot",
9
+ "llm",
10
+ "finetuning",
11
+ "cli"
12
+ ],
13
+ "license": "MIT",
14
+ "publishConfig": {
15
+ "access": "public"
16
+ },
17
+ "author": "Andrey Ryabov",
18
+ "homepage": "https://github.com/zenera-ai/ZeneraNeo#readme",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/zenera-ai/ZeneraNeo.git",
22
+ "directory": "packages/meta"
23
+ },
24
+ "bugs": "https://github.com/zenera-ai/ZeneraNeo/issues",
25
+ "type": "module",
26
+ "exports": {
27
+ "./command": {
28
+ "types": "./dist/command.d.ts",
29
+ "default": "./dist/command.js"
30
+ },
31
+ "./package.json": "./package.json"
32
+ },
33
+ "files": [
34
+ "dist",
35
+ "!dist/**/*.map"
36
+ ],
37
+ "engines": {
38
+ "node": ">=24"
39
+ },
40
+ "scripts": {
41
+ "build": "tsc -b",
42
+ "clean": "tsc -b --clean && rm -rf dist",
43
+ "prepack": "tsc -b"
44
+ },
45
+ "dependencies": {
46
+ "@zenera/cli": "^1.3.1",
47
+ "@zenera/engine": "^1.3.1",
48
+ "@zenera/neo": "^1.3.1",
49
+ "@zenera/view": "^1.3.1",
50
+ "google-auth-library": "^10.0.0",
51
+ "ink": "^7.1.1",
52
+ "react": "^19.2.8",
53
+ "yaml": "^2.9.1"
54
+ }
55
+ }