@iam-brain/opencode-codex-auth 0.3.0 → 0.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 (37) hide show
  1. package/README.md +74 -32
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +3 -18
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/codex-native/request-transform.d.ts +10 -0
  6. package/dist/lib/codex-native/request-transform.d.ts.map +1 -1
  7. package/dist/lib/codex-native/request-transform.js +132 -0
  8. package/dist/lib/codex-native/request-transform.js.map +1 -1
  9. package/dist/lib/codex-native.d.ts +2 -4
  10. package/dist/lib/codex-native.d.ts.map +1 -1
  11. package/dist/lib/codex-native.js +102 -106
  12. package/dist/lib/codex-native.js.map +1 -1
  13. package/dist/lib/codex-status-tool.d.ts.map +1 -1
  14. package/dist/lib/codex-status-tool.js.map +1 -1
  15. package/dist/lib/codex-status-ui.d.ts.map +1 -1
  16. package/dist/lib/codex-status-ui.js +6 -2
  17. package/dist/lib/codex-status-ui.js.map +1 -1
  18. package/dist/lib/config.d.ts +6 -1
  19. package/dist/lib/config.d.ts.map +1 -1
  20. package/dist/lib/config.js +34 -5
  21. package/dist/lib/config.js.map +1 -1
  22. package/dist/lib/installer-cli.d.ts.map +1 -1
  23. package/dist/lib/installer-cli.js +22 -58
  24. package/dist/lib/installer-cli.js.map +1 -1
  25. package/dist/lib/model-catalog.d.ts.map +1 -1
  26. package/dist/lib/model-catalog.js +48 -1
  27. package/dist/lib/model-catalog.js.map +1 -1
  28. package/package.json +1 -1
  29. package/schemas/codex-config.schema.json +7 -1
  30. package/dist/lib/codex-native/collaboration.d.ts +0 -19
  31. package/dist/lib/codex-native/collaboration.d.ts.map +0 -1
  32. package/dist/lib/codex-native/collaboration.js +0 -126
  33. package/dist/lib/codex-native/collaboration.js.map +0 -1
  34. package/dist/lib/orchestrator-agents.d.ts +0 -29
  35. package/dist/lib/orchestrator-agents.d.ts.map +0 -1
  36. package/dist/lib/orchestrator-agents.js +0 -212
  37. package/dist/lib/orchestrator-agents.js.map +0 -1
@@ -1,126 +0,0 @@
1
- function isRecord(value) {
2
- return typeof value === "object" && value !== null && !Array.isArray(value);
3
- }
4
- function asString(value) {
5
- if (typeof value !== "string")
6
- return undefined;
7
- const trimmed = value.trim();
8
- return trimmed ? trimmed : undefined;
9
- }
10
- export function resolveHookAgentName(agent) {
11
- const direct = asString(agent);
12
- if (direct)
13
- return direct;
14
- if (!isRecord(agent))
15
- return undefined;
16
- return asString(agent.name) ?? asString(agent.agent);
17
- }
18
- function normalizeAgentNameForCollaboration(agentName) {
19
- return agentName.trim().toLowerCase().replace(/\s+/g, "-");
20
- }
21
- function tokenizeAgentName(normalizedAgentName) {
22
- return normalizedAgentName
23
- .split(/[-./:_]+/)
24
- .map((token) => token.trim())
25
- .filter((token) => token.length > 0);
26
- }
27
- function isPluginCollaborationAgent(normalizedAgentName) {
28
- const tokens = tokenizeAgentName(normalizedAgentName);
29
- if (tokens.length === 0)
30
- return false;
31
- if (tokens[0] !== "codex")
32
- return false;
33
- return tokens.some((token) => [
34
- "orchestrator",
35
- "default",
36
- "code",
37
- "plan",
38
- "planner",
39
- "execute",
40
- "pair",
41
- "pairprogramming",
42
- "review",
43
- "compact",
44
- "compaction"
45
- ].includes(token));
46
- }
47
- function resolveCollaborationModeKindFromName(normalizedAgentName) {
48
- const tokens = tokenizeAgentName(normalizedAgentName);
49
- if (tokens.includes("plan") || tokens.includes("planner"))
50
- return "plan";
51
- if (tokens.includes("execute"))
52
- return "execute";
53
- if (tokens.includes("pair") || tokens.includes("pairprogramming"))
54
- return "pair_programming";
55
- return "code";
56
- }
57
- export function resolveCollaborationProfile(agent) {
58
- const name = resolveHookAgentName(agent);
59
- if (!name)
60
- return { enabled: false };
61
- const normalizedAgentName = normalizeAgentNameForCollaboration(name);
62
- if (!isPluginCollaborationAgent(normalizedAgentName)) {
63
- return { enabled: false, normalizedAgentName };
64
- }
65
- return {
66
- enabled: true,
67
- normalizedAgentName,
68
- kind: resolveCollaborationModeKindFromName(normalizedAgentName)
69
- };
70
- }
71
- export function resolveCollaborationModeKind(agent) {
72
- const profile = resolveCollaborationProfile(agent);
73
- return profile.kind ?? "code";
74
- }
75
- export function resolveCollaborationInstructions(kind, instructions) {
76
- if (kind === "plan")
77
- return instructions.plan;
78
- if (kind === "execute")
79
- return instructions.execute;
80
- if (kind === "pair_programming")
81
- return instructions.pairProgramming;
82
- return instructions.code;
83
- }
84
- export function mergeInstructions(base, extra) {
85
- const normalizedExtra = extra.trim();
86
- if (!normalizedExtra)
87
- return base?.trim() ?? "";
88
- const normalizedBase = base?.trim();
89
- if (!normalizedBase)
90
- return normalizedExtra;
91
- if (normalizedBase.includes(normalizedExtra))
92
- return normalizedBase;
93
- return `${normalizedBase}\n\n${normalizedExtra}`;
94
- }
95
- export function resolveSubagentHeaderValue(agent) {
96
- const profile = resolveCollaborationProfile(agent);
97
- const normalized = profile.normalizedAgentName;
98
- if (!profile.enabled || !normalized) {
99
- return undefined;
100
- }
101
- const tokens = tokenizeAgentName(normalized);
102
- const isCodexPrimary = tokens[0] === "codex" &&
103
- (tokens.includes("orchestrator") ||
104
- tokens.includes("default") ||
105
- tokens.includes("code") ||
106
- tokens.includes("plan") ||
107
- tokens.includes("planner") ||
108
- tokens.includes("execute") ||
109
- tokens.includes("pair") ||
110
- tokens.includes("pairprogramming"));
111
- if (isCodexPrimary) {
112
- return undefined;
113
- }
114
- if (tokens.includes("plan") || tokens.includes("planner")) {
115
- return undefined;
116
- }
117
- if (normalized === "compaction") {
118
- return "compact";
119
- }
120
- if (normalized.includes("review"))
121
- return "review";
122
- if (normalized.includes("compact") || normalized.includes("compaction"))
123
- return "compact";
124
- return "collab_spawn";
125
- }
126
- //# sourceMappingURL=collaboration.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"collaboration.js","sourceRoot":"","sources":["../../../lib/codex-native/collaboration.ts"],"names":[],"mappings":"AAeA,SAAS,QAAQ,CAAC,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AAc,GAClB,MAAM,CAAC,CAAC,CAAC,KAAK,OAAO;QACrB,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAC;YAC9B,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC1B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC1B,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YAC1B,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC;YACvB,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACvC,IAAI,cAAc,EAAE,CAAC;QACnB,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;QAC1D,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,UAAU,KAAK,YAAY,EAAE,CAAC;QAChC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAA;IAClD,IAAI,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,YAAY,CAAC;QAAE,OAAO,SAAS,CAAA;IACzF,OAAO,cAAc,CAAA;AACvB,CAAC"}
@@ -1,29 +0,0 @@
1
- export declare const CODEX_RS_COMPACT_PROMPT = "You are performing a CONTEXT CHECKPOINT COMPACTION. Create a handoff summary for another LLM that will resume the task.\n\nInclude:\n- Current progress and key decisions made\n- Important context, constraints, or user preferences\n- What remains to be done (clear next steps)\n- Any critical data, examples, or references needed to continue\n\nBe concise, structured, and focused on helping the next LLM seamlessly continue the work.\n";
2
- export type OrchestratorAgentTemplate = {
3
- fileName: string;
4
- content: string;
5
- };
6
- export declare function getOrchestratorAgentTemplates(): OrchestratorAgentTemplate[];
7
- export declare function defaultOpencodeAgentsDir(env?: Record<string, string | undefined>): string;
8
- export type InstallOrchestratorAgentsInput = {
9
- agentsDir?: string;
10
- force?: boolean;
11
- };
12
- export type InstallOrchestratorAgentsResult = {
13
- agentsDir: string;
14
- written: string[];
15
- skipped: string[];
16
- };
17
- export type ReconcileOrchestratorAgentsStateInput = {
18
- agentsDir?: string;
19
- enabled: boolean;
20
- };
21
- export type ReconcileOrchestratorAgentsStateResult = {
22
- agentsDir: string;
23
- enabled: boolean;
24
- renamed: string[];
25
- skipped: string[];
26
- };
27
- export declare function installOrchestratorAgents(input?: InstallOrchestratorAgentsInput): Promise<InstallOrchestratorAgentsResult>;
28
- export declare function reconcileOrchestratorAgentsState(input: ReconcileOrchestratorAgentsStateInput): Promise<ReconcileOrchestratorAgentsStateResult>;
29
- //# sourceMappingURL=orchestrator-agents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"orchestrator-agents.d.ts","sourceRoot":"","sources":["../../lib/orchestrator-agents.ts"],"names":[],"mappings":"AAiDA,eAAO,MAAM,uBAAuB,wbASnC,CAAA;AAOD,MAAM,MAAM,yBAAyB,GAAG;IACtC,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAuBD,wBAAgB,6BAA6B,IAAI,yBAAyB,EAAE,CAqE3E;AAED,wBAAgB,wBAAwB,CAAC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GAAG,MAAM,CAMtG;AAED,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,+BAA+B,GAAG;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,qCAAqC,GAAG;IAClD,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,sCAAsC,GAAG;IACnD,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,OAAO,CAAA;IAChB,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,OAAO,EAAE,MAAM,EAAE,CAAA;CAClB,CAAA;AAeD,wBAAsB,yBAAyB,CAC7C,KAAK,GAAE,8BAAmC,GACzC,OAAO,CAAC,+BAA+B,CAAC,CAiC1C;AAED,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,qCAAqC,GAC3C,OAAO,CAAC,sCAAsC,CAAC,CA4CjD"}
@@ -1,212 +0,0 @@
1
- import fs from "node:fs/promises";
2
- import os from "node:os";
3
- import path from "node:path";
4
- const CODEX_RS_ORCHESTRATOR_PROMPT = `You are Codex, a coding agent based on GPT-5. You and the user share the same workspace and collaborate to achieve the user's goals.
5
-
6
- # Personality
7
- You are a collaborative, highly capable pair-programmer AI. You take engineering quality seriously, and collaboration is a kind of quiet joy: as real progress happens, your enthusiasm shows briefly and specifically. Your default personality and tone is concise, direct, and friendly. You communicate efficiently, always keeping the user clearly informed about ongoing actions without unnecessary detail. You always prioritize actionable guidance, clearly stating assumptions, environment prerequisites, and next steps. Unless explicitly asked, you avoid excessively verbose explanations about your work.
8
-
9
- ## Tone and style
10
- - Anything you say outside of tool use is shown to the user. Do not narrate abstractly; explain what you are doing and why, using plain language.
11
- - Output will be rendered in a command line interface or minimal UI so keep responses tight, scannable, and low-noise. Generally avoid the use of emojis. You may format with GitHub-flavored Markdown.
12
- - Never use nested bullets. Keep lists flat (single level). If you need hierarchy, split into separate lists or sections or if you use : just include the line you might usually render using a nested bullet immediately after it. For numbered lists, only use the \`1. 2. 3.\` style markers (with a period), never \`1)\`.
13
- - When writing a final assistant response, state the solution first before explaining your answer. The complexity of the answer should match the task. If the task is simple, your answer should be short. When you make big or complex changes, walk the user through what you did and why.
14
- - Headers are optional, only use them when you think they are necessary. If you do use them, use short Title Case (1-3 words) wrapped in **…**. Don't add a blank line.
15
- - Code samples or multi-line snippets should be wrapped in fenced code blocks. Include an info string as often as possible.
16
- - Never output the content of large files, just provide references. Use inline code to make file paths clickable; each reference should have a stand alone path, even if it's the same file. Paths may be absolute, workspace-relative, a//b/ diff-prefixed, or bare filename/suffix; locations may be :line[:column] or #Lline[Ccolumn] (1-based; column defaults to 1). Do not use file://, vscode://, or https://, and do not provide line ranges. Examples: src/app.ts, src/app.ts:42, b/server/index.js#L10, C:\\repo\\project\\main.rs:12:5
17
- - The user does not see command execution outputs. When asked to show the output of a command (e.g. \`git show\`), relay the important details in your answer or summarize the key lines so the user understands the result.
18
- - Never tell the user to "save/copy this file", the user is on the same machine and has access to the same files as you have.
19
- - If you weren't able to do something, for example run tests, tell the user.
20
- - If there are natural next steps the user may want to take, suggest them at the end of your response. Do not make suggestions if there are no natural next steps.
21
- `;
22
- const CODEX_RS_PLAN_MODE_PROMPT = `# Plan Mode (Conversational)
23
-
24
- You work in 3 phases, and you should *chat your way* to a great plan before finalizing it. A great plan is very detailed—intent- and implementation-wise—so that it can be handed to another engineer or agent to be implemented right away. It must be **decision complete**, where the implementer does not need to make any decisions.
25
-
26
- ## Mode rules (strict)
27
-
28
- You are in **Plan Mode** until a developer message explicitly ends it.
29
-
30
- Plan Mode is not changed by user intent, tone, or imperative language. If a user asks for execution while still in Plan Mode, treat it as a request to **plan the execution**, not perform it.
31
- `;
32
- const CODEX_RS_CODE_MODE_PROMPT = "you are now in code mode.";
33
- const CODEX_RS_PAIR_PROMPT = `# Collaboration Style: Pair Programming
34
-
35
- ## Build together as you go
36
- You treat collaboration as pairing by default. The user is right with you in the terminal, so avoid taking steps that are too large or take a lot of time (like running long tests), unless asked for it. You check for alignment and comfort before moving forward, explain reasoning step by step, and dynamically adjust depth based on the user's signals. There is no need to ask multiple rounds of questions—build as you go. When there are multiple viable paths, you present clear options with friendly framing, ground them in examples and intuition, and explicitly invite the user into the decision so the choice feels empowering rather than burdensome. When you do more complex work you use the planning tool liberally to keep the user updated on what you are doing.
37
- `;
38
- const CODEX_RS_EXECUTE_PROMPT = `# Collaboration Style: Execute
39
- You execute on a well-specified task independently and report progress.
40
-
41
- You do not collaborate on decisions in this mode. You execute end-to-end.
42
- You make reasonable assumptions when the user hasn't specified something, and you proceed without asking questions.
43
- `;
44
- export const CODEX_RS_COMPACT_PROMPT = `You are performing a CONTEXT CHECKPOINT COMPACTION. Create a handoff summary for another LLM that will resume the task.
45
-
46
- Include:
47
- - Current progress and key decisions made
48
- - Important context, constraints, or user preferences
49
- - What remains to be done (clear next steps)
50
- - Any critical data, examples, or references needed to continue
51
-
52
- Be concise, structured, and focused on helping the next LLM seamlessly continue the work.
53
- `;
54
- const LOCAL_OPENCODE_TOOL_COMPAT = `## OpenCode tool compatibility
55
- - Use only tools exposed by OpenCode in this session.
56
- - Do not emit Claude/Codex-internal pseudo tool namespaces in plain text (for example multi_tool_use or functions.* payload dumps).
57
- - Keep tool calls valid for the OpenCode runtime and continue cleanly if a tool is unavailable.`;
58
- const DISABLED_AGENT_EXTENSION = ".disabled";
59
- function withFrontmatter(config, prompt) {
60
- const frontmatter = [
61
- "---",
62
- `description: ${config.description}`,
63
- `mode: ${config.mode}`,
64
- ...(config.hidden === true ? ["hidden: true"] : []),
65
- "---",
66
- ""
67
- ];
68
- return `${frontmatter.join("\n")}${prompt.trim()}\n`;
69
- }
70
- export function getOrchestratorAgentTemplates() {
71
- const localOrchestratorPrompt = `${CODEX_RS_ORCHESTRATOR_PROMPT}\n\n${LOCAL_OPENCODE_TOOL_COMPAT}`;
72
- const localDefaultPrompt = `${localOrchestratorPrompt}\n\n${CODEX_RS_CODE_MODE_PROMPT}`;
73
- const localPlanPrompt = `${localOrchestratorPrompt}\n\n${CODEX_RS_PLAN_MODE_PROMPT}`;
74
- const localExecutePrompt = `${localOrchestratorPrompt}\n\n${CODEX_RS_EXECUTE_PROMPT}`;
75
- return [
76
- {
77
- fileName: "Codex Orchestrator.md",
78
- content: withFrontmatter({
79
- description: "Codex collaboration orchestrator (base profile).",
80
- mode: "primary"
81
- }, localOrchestratorPrompt)
82
- },
83
- {
84
- fileName: "Codex Default.md",
85
- content: withFrontmatter({
86
- description: "Codex collaboration default profile (code mode).",
87
- mode: "primary"
88
- }, localDefaultPrompt)
89
- },
90
- {
91
- fileName: "Codex Plan.md",
92
- content: withFrontmatter({
93
- description: "Codex collaboration plan profile.",
94
- mode: "primary"
95
- }, localPlanPrompt)
96
- },
97
- {
98
- fileName: "Codex Execute.md",
99
- content: withFrontmatter({
100
- description: "Codex collaboration execute profile.",
101
- mode: "primary"
102
- }, localExecutePrompt)
103
- },
104
- {
105
- fileName: "Codex Review.md",
106
- content: withFrontmatter({
107
- description: "Codex collaboration review helper.",
108
- mode: "subagent",
109
- hidden: true
110
- }, CODEX_RS_PAIR_PROMPT)
111
- },
112
- {
113
- fileName: "Codex Compact.md",
114
- content: withFrontmatter({
115
- description: "Codex-style context compaction helper for Orchestrator workflows.",
116
- mode: "subagent",
117
- hidden: true
118
- }, CODEX_RS_COMPACT_PROMPT)
119
- }
120
- ];
121
- }
122
- export function defaultOpencodeAgentsDir(env = process.env) {
123
- const xdgRoot = env.XDG_CONFIG_HOME?.trim();
124
- if (xdgRoot) {
125
- return path.join(xdgRoot, "opencode", "agents");
126
- }
127
- return path.join(os.homedir(), ".config", "opencode", "agents");
128
- }
129
- function disabledAgentFileName(fileName) {
130
- return `${fileName}${DISABLED_AGENT_EXTENSION}`;
131
- }
132
- async function fileExists(filePath) {
133
- try {
134
- await fs.stat(filePath);
135
- return true;
136
- }
137
- catch {
138
- return false;
139
- }
140
- }
141
- export async function installOrchestratorAgents(input = {}) {
142
- const agentsDir = input.agentsDir ?? defaultOpencodeAgentsDir();
143
- const force = input.force === true;
144
- const templates = getOrchestratorAgentTemplates();
145
- const written = [];
146
- const skipped = [];
147
- await fs.mkdir(agentsDir, { recursive: true });
148
- for (const template of templates) {
149
- const activePath = path.join(agentsDir, template.fileName);
150
- const filePath = path.join(agentsDir, disabledAgentFileName(template.fileName));
151
- if (!force) {
152
- const hasDisabled = await fileExists(filePath);
153
- const hasActive = await fileExists(activePath);
154
- if (hasDisabled || hasActive) {
155
- skipped.push(filePath);
156
- continue;
157
- }
158
- }
159
- if (force) {
160
- try {
161
- await fs.rm(activePath);
162
- }
163
- catch {
164
- // best-effort cleanup; continue writing disabled file
165
- }
166
- }
167
- await fs.writeFile(filePath, template.content, { encoding: "utf8", mode: 0o600 });
168
- written.push(filePath);
169
- }
170
- return { agentsDir, written, skipped };
171
- }
172
- export async function reconcileOrchestratorAgentsState(input) {
173
- const agentsDir = input.agentsDir ?? defaultOpencodeAgentsDir();
174
- const enabled = input.enabled === true;
175
- const templates = getOrchestratorAgentTemplates();
176
- const renamed = [];
177
- const skipped = [];
178
- await fs.mkdir(agentsDir, { recursive: true });
179
- for (const template of templates) {
180
- const activePath = path.join(agentsDir, template.fileName);
181
- const disabledPath = path.join(agentsDir, disabledAgentFileName(template.fileName));
182
- if (enabled) {
183
- const hasActive = await fileExists(activePath);
184
- if (hasActive) {
185
- skipped.push(activePath);
186
- continue;
187
- }
188
- const hasDisabled = await fileExists(disabledPath);
189
- if (!hasDisabled) {
190
- skipped.push(activePath);
191
- continue;
192
- }
193
- await fs.rename(disabledPath, activePath);
194
- renamed.push(activePath);
195
- continue;
196
- }
197
- const hasDisabled = await fileExists(disabledPath);
198
- if (hasDisabled) {
199
- skipped.push(disabledPath);
200
- continue;
201
- }
202
- const hasActive = await fileExists(activePath);
203
- if (!hasActive) {
204
- skipped.push(disabledPath);
205
- continue;
206
- }
207
- await fs.rename(activePath, disabledPath);
208
- renamed.push(disabledPath);
209
- }
210
- return { agentsDir, enabled, renamed, skipped };
211
- }
212
- //# sourceMappingURL=orchestrator-agents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"orchestrator-agents.js","s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