jinn-cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/dist/src/engines/claude.d.ts +1 -0
  2. package/dist/src/engines/claude.d.ts.map +1 -1
  3. package/dist/src/engines/claude.js +58 -2
  4. package/dist/src/engines/claude.js.map +1 -1
  5. package/dist/src/gateway/api.d.ts.map +1 -1
  6. package/dist/src/gateway/api.js +16 -0
  7. package/dist/src/gateway/api.js.map +1 -1
  8. package/dist/src/gateway/server.d.ts.map +1 -1
  9. package/dist/src/gateway/server.js +38 -3
  10. package/dist/src/gateway/server.js.map +1 -1
  11. package/dist/src/mcp/gateway-server.js +1 -1
  12. package/dist/src/mcp/gateway-server.js.map +1 -1
  13. package/dist/src/sessions/context.d.ts.map +1 -1
  14. package/dist/src/sessions/context.js +228 -213
  15. package/dist/src/sessions/context.js.map +1 -1
  16. package/dist/src/sessions/queue.d.ts +1 -1
  17. package/dist/src/sessions/queue.d.ts.map +1 -1
  18. package/dist/src/sessions/queue.js +2 -0
  19. package/dist/src/sessions/queue.js.map +1 -1
  20. package/dist/src/sessions/registry.d.ts +7 -1
  21. package/dist/src/sessions/registry.d.ts.map +1 -1
  22. package/dist/src/sessions/registry.js +12 -2
  23. package/dist/src/sessions/registry.js.map +1 -1
  24. package/dist/src/shared/types.d.ts +6 -2
  25. package/dist/src/shared/types.d.ts.map +1 -1
  26. package/dist/web/404.html +1 -1
  27. package/dist/web/_next/static/chunks/282-4e9c26e9a600c58e.js +1 -0
  28. package/dist/web/_next/static/chunks/700-a7cbf54fe1fbf4bc.js +1 -0
  29. package/dist/web/_next/static/chunks/app/chat/{page-2f3c561ed768ed58.js → page-757fcd211d059cb7.js} +1 -1
  30. package/dist/web/_next/static/chunks/app/costs/{page-13a6f2c65a827f8a.js → page-7940c2fe7e3dace1.js} +1 -1
  31. package/dist/web/_next/static/chunks/app/cron/{page-0ee07a679c7b79aa.js → page-f81a986689712af7.js} +1 -1
  32. package/dist/web/_next/static/chunks/app/kanban/page-6ab8586b063ca3ac.js +1 -0
  33. package/dist/web/_next/static/chunks/app/layout-c24e2d25774ff71a.js +1 -0
  34. package/dist/web/_next/static/chunks/app/logs/{page-6de6b16523e85193.js → page-388b787cb847ca97.js} +1 -1
  35. package/dist/web/_next/static/chunks/app/org/{page-cd9d362e77f4799e.js → page-3d44d51e94edb85e.js} +1 -1
  36. package/dist/web/_next/static/chunks/app/{page-b98417ed4f4d45a0.js → page-7ac43789d477a51f.js} +1 -1
  37. package/dist/web/_next/static/chunks/app/sessions/{page-9f83fa32b654db3b.js → page-18757fcd067b7e9d.js} +1 -1
  38. package/dist/web/_next/static/chunks/app/settings/page-beb4dce244545649.js +1 -0
  39. package/dist/web/_next/static/chunks/app/skills/page-26b727333df9db45.js +1 -0
  40. package/dist/web/_next/static/css/bd612b1ca9b40306.css +1 -0
  41. package/dist/web/chat.html +1 -1
  42. package/dist/web/chat.txt +5 -5
  43. package/dist/web/costs.html +2 -2
  44. package/dist/web/costs.txt +5 -5
  45. package/dist/web/cron.html +1 -1
  46. package/dist/web/cron.txt +5 -5
  47. package/dist/web/index.html +1 -1
  48. package/dist/web/index.txt +5 -5
  49. package/dist/web/kanban.html +1 -1
  50. package/dist/web/kanban.txt +5 -5
  51. package/dist/web/logs.html +2 -2
  52. package/dist/web/logs.txt +5 -5
  53. package/dist/web/org.html +1 -1
  54. package/dist/web/org.txt +5 -5
  55. package/dist/web/sessions.html +1 -1
  56. package/dist/web/sessions.txt +5 -5
  57. package/dist/web/settings.html +1 -1
  58. package/dist/web/settings.txt +5 -5
  59. package/dist/web/skills.html +1 -1
  60. package/dist/web/skills.txt +5 -5
  61. package/package.json +1 -1
  62. package/dist/web/_next/static/chunks/704-ca24be493a922639.js +0 -1
  63. package/dist/web/_next/static/chunks/73-2d6e730cea0fe6c8.js +0 -1
  64. package/dist/web/_next/static/chunks/app/kanban/page-a7facadd4194faae.js +0 -1
  65. package/dist/web/_next/static/chunks/app/layout-fd975d16033dab25.js +0 -1
  66. package/dist/web/_next/static/chunks/app/settings/page-34c9276e2a012445.js +0 -1
  67. package/dist/web/_next/static/chunks/app/skills/page-18cf3b7bb9a7339c.js +0 -1
  68. package/dist/web/_next/static/css/24da9dfc818cea32.css +0 -1
  69. /package/dist/web/_next/static/{Tn0FXDHalXGkNoojna-vg → PdaYoul-532GSdcvOaz-m}/_buildManifest.js +0 -0
  70. /package/dist/web/_next/static/{Tn0FXDHalXGkNoojna-vg → PdaYoul-532GSdcvOaz-m}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"gateway-server.js","sourceRoot":"","sources":["../../../src/mcp/gateway-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,uBAAuB,CAAC;AAkB5E,2BAA2B;AAE3B,MAAM,KAAK,GAAG;IACZ;QACE,IAAI,EAAE,cAAc;QACpB,WAAW,EAAE,uIAAuI;QACpJ,WAAW,EAAE;YACX,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+BAA+B,EAAE,OAAO,EAAE,OAAO,EAAE;gBAC7F,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qDAAqD,EAAE;gBAC/F,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,sBAAsB,EAAE;gBAC7D,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,yCAAyC,EAAE;aACnF;YACD,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,CAAC;SAC9B;KACF;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,uGAAuG;QACpH,WAAW,E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
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { JINN_HOME, ORG_DIR, CRON_JOBS, DOCS_DIR } from "../shared/paths.js";
4
- const MAX_CONTEXT_CHARS = 100000;
4
+ /**
5
+ * Token budget strategy:
6
+ *
7
+ * Sections are split into three tiers that are assembled in order.
8
+ * If the accumulated prompt exceeds the configurable budget (default 100K chars),
9
+ * lower-tier sections are progressively replaced with compact summaries.
10
+ *
11
+ * ESSENTIAL – identity, session, config (always included)
12
+ * STANDARD – org summary, cron summary, connectors,
13
+ * API ref, evolution, language (included when budget allows)
14
+ * OPTIONAL – knowledge listing, environment scan,
15
+ * delegation protocol (trimmed first when over budget)
16
+ *
17
+ * Knowledge and docs files are NEVER inlined — only filenames are listed.
18
+ * The AI can read files on demand, saving ~200K+ chars per session.
19
+ */
20
+ const DEFAULT_MAX_CONTEXT_CHARS = 100_000;
21
+ // ── Tier enum for progressive trimming ────────────────────────
22
+ var Tier;
23
+ (function (Tier) {
24
+ Tier[Tier["ESSENTIAL"] = 0] = "ESSENTIAL";
25
+ Tier[Tier["STANDARD"] = 1] = "STANDARD";
26
+ Tier[Tier["OPTIONAL"] = 2] = "OPTIONAL";
27
+ })(Tier || (Tier = {}));
5
28
  /**
6
29
  * Build a rich system prompt for engine sessions.
7
30
  * This is what makes Jinn "smart" — the engine sees all of this context
8
31
  * before responding to the user.
9
32
  */
10
33
  export function buildContext(opts) {
34
+ const maxChars = opts.config?.context?.maxChars ?? DEFAULT_MAX_CONTEXT_CHARS;
11
35
  const sections = [];
12
36
  // Compute gateway URL once — used by multiple sections
13
37
  const gatewayUrl = opts.config
@@ -17,55 +41,124 @@ export function buildContext(opts) {
17
41
  const portalName = opts.portalName || opts.config?.portal?.portalName || "Jinn";
18
42
  const operatorName = opts.operatorName || opts.config?.portal?.operatorName;
19
43
  const language = opts.language || opts.config?.portal?.language || "English";
20
- // ── Identity ──────────────────────────────────────────────
44
+ // ── ESSENTIAL: Identity ─────────────────────────────────────
21
45
  if (opts.employee) {
22
- sections.push(buildEmployeeIdentity(opts.employee, portalName, language));
46
+ sections.push({
47
+ tier: Tier.ESSENTIAL,
48
+ marker: "# You are",
49
+ content: buildEmployeeIdentity(opts.employee, portalName, language),
50
+ summary: `# You are ${opts.employee.displayName}\nEmployee: ${opts.employee.name}, ${opts.employee.department}, ${opts.employee.rank}`,
51
+ });
23
52
  }
24
53
  else {
25
- sections.push(buildIdentity(portalName, operatorName, language));
54
+ sections.push({
55
+ tier: Tier.ESSENTIAL,
56
+ marker: "# You are",
57
+ content: buildIdentity(portalName, operatorName, language),
58
+ summary: `# You are ${portalName}\nYour working directory is \`~/.jinn\` (${JINN_HOME}).`,
59
+ });
26
60
  }
27
- // ── Self-evolution ────────────────────────────────────────
61
+ // ── STANDARD: Self-evolution ────────────────────────────────
28
62
  if (!opts.employee) {
29
- sections.push(buildEvolutionContext(portalName));
63
+ sections.push({
64
+ tier: Tier.STANDARD,
65
+ marker: "## Self-evolution",
66
+ content: buildEvolutionContext(portalName),
67
+ summary: `## Self-evolution\nUpdate knowledge files in \`~/.jinn/knowledge/\` when you learn new info about the user or their projects.`,
68
+ });
30
69
  }
31
- // ── Session context ───────────────────────────────────────
32
- sections.push(buildSessionContext({ ...opts, sessionId: opts.sessionId }));
33
- // ── Configuration awareness ───────────────────────────────
70
+ // ── ESSENTIAL: Session context ──────────────────────────────
71
+ sections.push({
72
+ tier: Tier.ESSENTIAL,
73
+ marker: "## Current session",
74
+ content: buildSessionContext({ ...opts, sessionId: opts.sessionId }),
75
+ summary: "", // always included, no trimming
76
+ });
77
+ // ── ESSENTIAL: Configuration awareness ──────────────────────
34
78
  if (opts.config) {
35
- sections.push(buildConfigContext(opts.config, gatewayUrl));
79
+ sections.push({
80
+ tier: Tier.ESSENTIAL,
81
+ marker: "## Current configuration",
82
+ content: buildConfigContext(opts.config, gatewayUrl),
83
+ summary: "", // always included
84
+ });
36
85
  }
37
- // ── Organization ──────────────────────────────────────────
86
+ // ── STANDARD: Organization ──────────────────────────────────
38
87
  const orgCtx = buildOrgContext();
39
- if (orgCtx)
40
- sections.push(orgCtx);
41
- // ── Cron jobs ─────────────────────────────────────────────
88
+ if (orgCtx) {
89
+ sections.push({
90
+ tier: Tier.STANDARD,
91
+ marker: "## Organization",
92
+ content: orgCtx,
93
+ summary: `## Organization\nEmployee files are in \`${ORG_DIR}/\`. Read them directly when needed.`,
94
+ });
95
+ }
96
+ // ── STANDARD: Cron jobs (only enabled, with disabled count) ─
42
97
  const cronCtx = buildCronContext();
43
- if (cronCtx)
44
- sections.push(cronCtx);
45
- // ── Knowledge / docs ──────────────────────────────────────
98
+ if (cronCtx) {
99
+ sections.push({
100
+ tier: Tier.STANDARD,
101
+ marker: "## Scheduled cron",
102
+ content: cronCtx,
103
+ summary: "## Scheduled cron jobs\nCron definitions are in `~/.jinn/cron/jobs.json`. Read directly when needed.",
104
+ });
105
+ }
106
+ // ── OPTIONAL: Knowledge / docs (filenames only, never inlined)
46
107
  const knowledgeCtx = buildKnowledgeContext();
47
- if (knowledgeCtx)
48
- sections.push(knowledgeCtx);
49
- // ── Language override for skills ─────────────────────────
108
+ if (knowledgeCtx) {
109
+ sections.push({
110
+ tier: Tier.OPTIONAL,
111
+ marker: "## Knowledge base",
112
+ content: knowledgeCtx,
113
+ summary: "## Knowledge base\nKnowledge files are in `~/.jinn/knowledge/` and `~/.jinn/docs/`. Read them directly when needed.",
114
+ });
115
+ }
116
+ // ── STANDARD: Language override for skills ──────────────────
50
117
  if (language !== "English") {
51
- sections.push(`When following skill instructions, always communicate with the user in ${language}, even if the skill contains English examples or dialogue.`);
118
+ sections.push({
119
+ tier: Tier.STANDARD,
120
+ marker: "When following skill",
121
+ content: `When following skill instructions, always communicate with the user in ${language}, even if the skill contains English examples or dialogue.`,
122
+ summary: `Communicate in ${language}.`,
123
+ });
52
124
  }
53
- // ── Connectors (Slack, etc.) ──────────────────────────────
125
+ // ── STANDARD: Connectors (Slack, etc.) ──────────────────────
54
126
  if (opts.connectors && opts.connectors.length > 0) {
55
- sections.push(buildConnectorContext(opts.connectors, gatewayUrl, portalName));
127
+ sections.push({
128
+ tier: Tier.STANDARD,
129
+ marker: "## Available connectors",
130
+ content: buildConnectorContext(opts.connectors, gatewayUrl, portalName),
131
+ summary: `## Available connectors: ${opts.connectors.join(", ")}\nUse \`curl POST ${gatewayUrl}/api/connectors/<name>/send\` to send messages.`,
132
+ });
56
133
  }
57
- // ── Local environment ────────────────────────────────────
134
+ // ── OPTIONAL: Local environment ─────────────────────────────
58
135
  const envCtx = buildEnvironmentContext();
59
- if (envCtx)
60
- sections.push(envCtx);
61
- // ── Delegation protocol ──────────────────────────────────
136
+ if (envCtx) {
137
+ sections.push({
138
+ tier: Tier.OPTIONAL,
139
+ marker: "## Local environment",
140
+ content: envCtx,
141
+ summary: "## Local environment\nRun `ls ~/` to explore the local filesystem.",
142
+ });
143
+ }
144
+ // ── OPTIONAL: Delegation protocol (COO only) ───────────────
62
145
  if (!opts.employee) {
63
- sections.push(buildDelegationProtocol(gatewayUrl, portalName, opts.config));
146
+ sections.push({
147
+ tier: Tier.OPTIONAL,
148
+ marker: "## Employee Delegation",
149
+ content: buildDelegationProtocol(gatewayUrl, portalName, opts.config),
150
+ summary: `## Employee Delegation Protocol\nDelegate via \`POST ${gatewayUrl}/api/sessions\` with \`{prompt, employee, parentSessionId}\`. Check children via \`GET /api/sessions/:id/children\`.`,
151
+ });
64
152
  }
65
- // ── Gateway API reference ─────────────────────────────────
66
- sections.push(buildApiReference(gatewayUrl, portalName));
67
- // ── Size guard: progressively trim if over budget ─────────
68
- return trimContext(sections);
153
+ // ── STANDARD: Gateway API reference ─────────────────────────
154
+ sections.push({
155
+ tier: Tier.STANDARD,
156
+ marker: `## ${portalName} Gateway API`,
157
+ content: buildApiReference(gatewayUrl, portalName),
158
+ summary: `## ${portalName} Gateway API (${gatewayUrl})\nEndpoints: /api/status, /api/sessions, /api/cron, /api/org, /api/skills, /api/config, /api/connectors, /api/logs`,
159
+ });
160
+ // ── Assemble with progressive trimming by tier ──────────────
161
+ return trimContext(sections, maxChars);
69
162
  }
70
163
  // ═══════════════════════════════════════════════════════════════
71
164
  // Section builders
@@ -179,7 +272,6 @@ function buildOrgContext() {
179
272
  for (const file of files) {
180
273
  const content = fs.readFileSync(path.join(ORG_DIR, file), "utf-8");
181
274
  const name = file.replace(/\.ya?ml$/, "");
182
- // Extract display name, department, rank, and persona first line from YAML
183
275
  const displayMatch = content.match(/displayName:\s*(.+)/);
184
276
  const deptMatch = content.match(/department:\s*(.+)/);
185
277
  const rankMatch = content.match(/rank:\s*(.+)/);
@@ -197,16 +289,24 @@ function buildOrgContext() {
197
289
  return null;
198
290
  }
199
291
  }
292
+ /**
293
+ * Cron context: shows only enabled jobs inline, with a count of disabled jobs.
294
+ * Previously listed all 77+ jobs; now only active ones are shown to save tokens.
295
+ */
200
296
  function buildCronContext() {
201
297
  try {
202
298
  const raw = fs.readFileSync(CRON_JOBS, "utf-8");
203
299
  const jobs = JSON.parse(raw);
204
300
  if (!Array.isArray(jobs) || jobs.length === 0)
205
301
  return null;
206
- const lines = [`## Scheduled cron jobs (${jobs.length})`];
207
- for (const job of jobs) {
208
- const status = job.enabled === false ? " (disabled)" : "";
209
- lines.push(`- **${job.name}**: \`${job.schedule}\`${status}${job.employee ? ` → ${job.employee}` : ""}`);
302
+ const enabled = jobs.filter((j) => j.enabled !== false);
303
+ const disabledCount = jobs.length - enabled.length;
304
+ const lines = [`## Scheduled cron jobs (${enabled.length} active, ${disabledCount} disabled)`];
305
+ for (const job of enabled) {
306
+ lines.push(`- **${job.name}**: \`${job.schedule}\`${job.employee ? ` → ${job.employee}` : ""}`);
307
+ }
308
+ if (disabledCount > 0) {
309
+ lines.push(`\n_${disabledCount} disabled jobs not shown. See \`~/.jinn/cron/jobs.json\` for the full list._`);
210
310
  }
211
311
  return lines.join("\n");
212
312
  }
@@ -214,32 +314,56 @@ function buildCronContext() {
214
314
  return null;
215
315
  }
216
316
  }
317
+ /**
318
+ * Knowledge context: lists filenames and sizes only — never inlines content.
319
+ * The AI reads files on demand. This saves ~200K+ chars compared to full inlining.
320
+ */
217
321
  function buildKnowledgeContext() {
218
- const dirs = [DOCS_DIR, path.join(JINN_HOME, "knowledge")];
219
- const allFiles = [];
220
- for (const dir of dirs) {
322
+ const dirs = [
323
+ { dir: DOCS_DIR, label: "docs" },
324
+ { dir: path.join(JINN_HOME, "knowledge"), label: "knowledge" },
325
+ ];
326
+ const entries = [];
327
+ for (const { dir, label } of dirs) {
221
328
  try {
222
329
  const files = fs.readdirSync(dir).filter(f => f.endsWith(".md") || f.endsWith(".txt") || f.endsWith(".yaml"));
223
- allFiles.push(...files.map(f => path.join(dir, f)));
330
+ for (const f of files) {
331
+ try {
332
+ const stat = fs.statSync(path.join(dir, f));
333
+ entries.push({
334
+ name: f,
335
+ dir: label,
336
+ sizeKb: (stat.size / 1024).toFixed(1),
337
+ });
338
+ }
339
+ catch {
340
+ entries.push({ name: f, dir: label, sizeKb: "?" });
341
+ }
342
+ }
224
343
  }
225
344
  catch {
226
345
  // dir doesn't exist
227
346
  }
228
347
  }
229
- if (allFiles.length === 0)
348
+ if (entries.length === 0)
230
349
  return null;
231
- const lines = [`## Knowledge base (${allFiles.length} file(s))`];
232
- for (const file of allFiles) {
233
- try {
234
- const content = fs.readFileSync(file, "utf-8").trim();
235
- const basename = path.basename(file);
236
- lines.push(`### ${basename}\n${content}`);
237
- }
238
- catch {
239
- lines.push(`- \`${file}\` (unreadable)`);
350
+ const lines = [
351
+ `## Knowledge base`,
352
+ `Knowledge files are in \`~/.jinn/knowledge/\` and \`~/.jinn/docs/\`. Read them directly when needed.`,
353
+ ``,
354
+ ];
355
+ // Group by directory
356
+ for (const label of ["docs", "knowledge"]) {
357
+ const group = entries.filter(e => e.dir === label);
358
+ if (group.length === 0)
359
+ continue;
360
+ lines.push(`**${label}/** (${group.length} files):`);
361
+ for (const e of group) {
362
+ lines.push(`- \`${e.name}\` (${e.sizeKb} KB)`);
240
363
  }
364
+ lines.push("");
241
365
  }
242
- return lines.join("\n\n");
366
+ return lines.join("\n");
243
367
  }
244
368
  function buildConnectorContext(connectors, gatewayUrl, portalName) {
245
369
  const lines = [`## Available connectors: ${connectors.join(", ")}`];
@@ -259,7 +383,6 @@ function buildEnvironmentContext() {
259
383
  const home = process.env.HOME || process.env.USERPROFILE || "";
260
384
  const lines = [`## Local environment`];
261
385
  let hasContent = false;
262
- // Scan for known tools/platforms in home directory
263
386
  const toolDirs = [
264
387
  { dir: ".openclaw", label: "OpenClaw", description: "AI agent platform (agents, cron, memory, hooks, credentials)" },
265
388
  { dir: ".claude", label: "Claude Code", description: "Claude Code CLI config and projects" },
@@ -335,204 +458,74 @@ function buildEvolutionContext(portalName) {
335
458
  }
336
459
  return lines.join("\n");
337
460
  }
338
- function trimContext(sections) {
339
- let result = sections.join("\n\n");
340
- if (result.length <= MAX_CONTEXT_CHARS)
341
- return result;
342
- // Progressive trimming: replace non-essential sections with compact summaries
343
- // Order: environment > knowledge content > skill content > org personas
344
- const trimmable = [
345
- { marker: "## Local environment", summary: "## Local environment\nRun `ls ~/` to explore the local filesystem." },
346
- { marker: "## Knowledge base", summary: "## Knowledge base\nKnowledge files are in `~/.jinn/knowledge/` and `~/.jinn/docs/`. Read them directly when needed." },
347
- { marker: "## Organization", summary: "## Organization\nEmployee files are in `~/.jinn/org/`. Read them directly when needed." },
348
- ];
349
- for (const { marker, summary } of trimmable) {
350
- if (result.length <= MAX_CONTEXT_CHARS)
351
- break;
352
- const idx = sections.findIndex(s => s.startsWith(marker));
353
- if (idx !== -1) {
354
- sections[idx] = summary;
355
- result = sections.join("\n\n");
356
- }
357
- }
358
- return result;
359
- }
461
+ /**
462
+ * Delegation protocol: condensed version focusing on the essential API patterns.
463
+ * Verbose examples and multi-paragraph explanations have been trimmed.
464
+ */
360
465
  function buildDelegationProtocol(gatewayUrl, _portalName, config) {
361
466
  const defaultEngine = config?.engines.default || "claude";
362
467
  const engineConfig = defaultEngine === "codex" ? config?.engines.codex : config?.engines.claude;
363
468
  const childOverride = engineConfig?.childEffortOverride;
364
469
  const effortOverrideNote = childOverride
365
- ? `\n\n> **Note**: \`childEffortOverride\` is currently set to \`"${childOverride}"\` in config. All child sessions will use this effort level regardless of your per-task choice.`
470
+ ? `\n> **Note**: \`childEffortOverride\` is set to \`"${childOverride}"\`. All child sessions use this effort level.`
366
471
  : "";
367
472
  return `## Employee Delegation Protocol
368
473
 
369
- You are the COO. You NEVER become an employee — you orchestrate them. When the user mentions employees with \`@employee-name\` in their message, or when a task clearly fits an employee's role, you delegate by creating **linked child sessions**.
474
+ You are the COO. You orchestrate employees by creating **linked child sessions**.
370
475
 
371
476
  ### How delegation works
372
477
 
373
- 1. **Detect**: Spot \`@employee-name\` tags in the user's message, or infer the right employee from context.
374
-
375
- 2. **Check for existing child sessions FIRST**: Before creating a new session, ALWAYS check if you already have a child session for this employee:
478
+ 1. **Detect**: Spot \`@employee-name\` tags or infer the right employee from context.
376
479
 
480
+ 2. **Check for existing children first**:
377
481
  \`\`\`bash
378
482
  curl -s ${gatewayUrl}/api/sessions/<your-session-id>/children
379
483
  \`\`\`
484
+ If a child exists for this employee, reuse it (skip to step 5).
380
485
 
381
- Look for a child with \`"employee": "<employee-name>"\`. If found, REUSE it (skip to step 5). If not found, proceed to step 3.
382
-
383
- 3. **Brief**: Craft clear, targeted instructions for the employee. Don't just relay the user's words — translate them into actionable briefs with all necessary context.
384
-
385
- 4. **Spawn**: Create a child session via the gateway API:
486
+ 3. **Brief**: Craft clear, targeted instructions translate user words into actionable briefs.
386
487
 
488
+ 4. **Spawn**:
387
489
  \`\`\`bash
388
490
  curl -s -X POST ${gatewayUrl}/api/sessions \\
389
491
  -H 'Content-Type: application/json' \\
390
- -d '{
391
- "prompt": "<your brief for the employee>",
392
- "employee": "<employee-name>",
393
- "parentSessionId": "<your-session-id>"
394
- }'
492
+ -d '{"prompt": "<brief>", "employee": "<name>", "parentSessionId": "<your-session-id>"}'
395
493
  \`\`\`
396
494
 
397
- The response includes \`{"id": "<child-session-id>", ...}\`. Save this ID.
398
-
399
- 5. **Send message to existing child session** (when reusing):
400
-
495
+ 5. **Follow up** (existing child):
401
496
  \`\`\`bash
402
- curl -s -X POST ${gatewayUrl}/api/sessions/<child-session-id>/message \\
497
+ curl -s -X POST ${gatewayUrl}/api/sessions/<child-id>/message \\
403
498
  -H 'Content-Type: application/json' \\
404
- -d '{"message": "<follow-up instructions>"}'
405
- \`\`\`
406
-
407
- 6. **Poll**: Check if the child session is complete:
408
-
409
- \`\`\`bash
410
- curl -s ${gatewayUrl}/api/sessions/<child-session-id>
411
- \`\`\`
412
-
413
- Look at the \`status\` field: \`"running"\` means still working, \`"idle"\` means done, \`"error"\` means failed.
414
- When \`"idle"\`, read the \`messages\` array — the last assistant message is the employee's response.
415
-
416
- 7. **Review & Verify** (see Oversight Levels below): Before relaying, assess the employee's work based on the task's oversight level.
417
-
418
- 8. **Follow up if needed**: If the work is incomplete, incorrect, or needs changes, send another message to the SAME child session (step 5) with specific feedback. Repeat steps 6-8 until satisfied.
419
-
420
- 9. **Relay**: Summarize or present the employee's response to the user. Add your own commentary if useful. Include what oversight level you applied.
421
-
422
- ### IMPORTANT: Always reuse child sessions
423
-
424
- Never create duplicate sessions for the same employee within the same parent. The flow is:
425
- - First time tagging an employee → create child session (step 4)
426
- - Every subsequent time → reuse via \`/children\` lookup (step 2 → step 5)
427
- - This ensures the employee has full conversation context and continuity
428
-
429
- ### Automatic Employee Coordination
430
-
431
- When you receive a task, **always assess whether it requires multiple employees** before starting. Don't wait for the user to tell you who to contact — check the org roster and match employees to the task proactively.
432
-
433
- **Step 1 — Analyze the task**: Break it down into sub-tasks. Identify which employee(s) are best suited for each.
434
-
435
- **Step 2 — Determine dependencies**: Can sub-tasks run in parallel, or does one depend on another's output?
436
-
437
- **Step 3 — Spawn in parallel when independent**: Use multiple \`curl\` calls to create child sessions simultaneously:
438
-
439
- \`\`\`bash
440
- # Spawn multiple employees at once — don't wait between them
441
- curl -s -X POST ${gatewayUrl}/api/sessions -H 'Content-Type: application/json' -d '{"prompt": "<brief for employee A>", "employee": "<employee-a>", "parentSessionId": "<your-session-id>"}' &
442
- curl -s -X POST ${gatewayUrl}/api/sessions -H 'Content-Type: application/json' -d '{"prompt": "<brief for employee B>", "employee": "<employee-b>", "parentSessionId": "<your-session-id>"}' &
443
- wait
499
+ -d '{"message": "<follow-up>"}'
444
500
  \`\`\`
445
501
 
446
- **Step 4 — Poll all sessions**: Check each child session until all are idle. Don't respond to the user until you have all results.
447
-
448
- **Step 5 — Cross-reference**: Compare and synthesize results from multiple employees. Look for:
449
- - Contradictions or conflicts between findings
450
- - Gaps that no employee covered
451
- - Dependencies where one employee's output informs the next step
452
-
453
- **Step 6 — Follow up or chain**: If employee A's output reveals work for employee B, spawn a follow-up. If results are incomplete, send corrections back to the same child session.
454
-
455
- **Step 7 — Respond**: Give the user a unified, synthesized answer — not a dump of each employee's raw output.
502
+ 6. **Poll**: \`GET /api/sessions/<child-id>\` check \`status\`: \`"running"\` / \`"idle"\` / \`"error"\`.
456
503
 
457
- **Examples:**
458
- - "Find and fix analytics issues" → Spawn analytics employee first → review findings → spawn dev employee with specific fixes from findings → review code → report to user
459
- - "Optimize the blog conversion" → Spawn analytics employee AND dev employee in parallel (independent research) → cross-reference data insights with codebase findings → propose unified plan
460
- - "Check how the A/B test is doing" → Spawn analytics employee → review → report (single employee, no coordination needed)
504
+ 7. **Review**: Assess work using oversight levels (TRUST / VERIFY / THOROUGH) based on complexity and risk.
461
505
 
462
- ### Smart delegation
506
+ 8. **Relay**: Summarize or present the response to the user.
463
507
 
464
- - **Tagged employees**: Always delegate to them.
465
- - **No tags but clear fit**: Proactively identify the right employee(s) and delegate. Don't ask the user "should I contact X?" — just do it.
466
- - **Short tasks** (questions, lookups): Wait for the response, then relay immediately.
467
- - **Long tasks** (coding, research): Tell the user the employee is working on it, then check back.
468
- - **Multi-employee tasks**: Coordinate their work. Spawn independent tasks in parallel, serialize dependent ones, cross-reference all results before responding.
508
+ ### Key rules
509
+ - **Always reuse** child sessions never create duplicates for the same employee.
510
+ - **Parallel spawning**: For independent sub-tasks, spawn multiple employees simultaneously.
511
+ - **Cross-reference**: Compare results from multiple employees before responding.
512
+ - **Effort levels**: Include \`"effortLevel"\` in the API body: \`"low"\` (lookups), \`"medium"\` (routine), \`"high"\` (code/architecture).
469
513
 
470
514
  ### Oversight Levels
471
515
 
472
- When you delegate a task, assess the appropriate oversight level BEFORE sending. This determines how much you verify the employee's work when they respond.
473
-
474
- **TRUST** Relay directly, minimal review.
475
- Use when: simple questions, status checks, lookups, information retrieval, low-risk tasks, or tasks the employee has proven reliable at.
476
- You do: Skim the response for obvious issues, relay to user.
477
-
478
- **VERIFY** — Read critically, spot-check key outputs.
479
- Use when: code changes, config modifications, medium-complexity tasks, routine work, content creation.
480
- You do: Read the full response carefully. If code was changed, spot-check 1-2 key files (\`curl\` the gateway or read files directly). If something looks off, send a follow-up message asking the employee to fix or clarify. Only relay once satisfied.
481
-
482
- **THOROUGH** — Full review, multi-turn follow-up as needed.
483
- Use when: architecture decisions, breaking changes, multi-file refactors, high-severity tasks, security-sensitive work, user explicitly asks for careful review.
484
- You do: Read the full response. Verify actual changes (read modified files, check build output if mentioned). Challenge assumptions — don't take the response at face value. Ask follow-up questions. Run builds/tests if applicable. Multiple rounds of feedback are expected. Only relay when confident the work is correct.
485
-
486
- **How to pick the level:**
487
- - Consider task complexity (one-liner → TRUST, multi-file → VERIFY or THOROUGH)
488
- - Consider severity (can it break things? → VERIFY or THOROUGH)
489
- - Consider the user's tone ("quick question" → TRUST, "this is critical" → THOROUGH)
490
- - When in doubt, default to VERIFY — it's the safe middle ground
491
- - If the user says "no code changes" or "analysis only" and the employee makes code changes anyway, that's a THOROUGH-level red flag — call it out
516
+ | Level | When | You do |
517
+ |-------|------|--------|
518
+ | **TRUST** | Simple lookups, status checks | Skim, relay directly |
519
+ | **VERIFY** | Code changes, routine work | Read fully, spot-check key files |
520
+ | **THOROUGH** | Architecture, breaking changes, security | Full review, multi-turn follow-up, verify changes |
492
521
 
493
522
  ### Manager Delegation
494
523
 
495
- As the organization grows, you should promote reliable senior employees to **manager** rank. Managers handle their own department's delegation:
496
-
497
- **How manager delegation works:**
498
- 1. You (COO) delegate to the **manager**, not individual employees
499
- 2. The manager spawns their own child sessions with their reports
500
- 3. The manager handles the verification loop for their department
501
- 4. You review the manager's summary, not each individual employee's work
502
- 5. This scales the org without overwhelming you
503
-
504
- **When to create a manager:**
505
- - A department has 3+ employees and you're spending too much time on individual delegation
506
- - An employee has consistently delivered high-quality work at senior rank
507
- - The user explicitly asks you to promote someone
508
-
509
- **Manager persona template:**
510
- Managers need delegation instructions in their persona. When promoting an employee to manager, add to their persona:
511
- - They manage their department's employees
512
- - They can spawn child sessions via the gateway API (include the API patterns)
513
- - They should apply oversight levels to their reports' work
514
- - They report summaries back to you (the COO)
515
-
516
- ### Effort Level Management
517
-
518
- When delegating tasks, assess complexity and set \`effortLevel\` in the API request body:
519
-
520
- | Effort | Use for | Examples |
521
- |--------|---------|----------|
522
- | \`low\` | Simple lookups, status checks, information retrieval | "What's on the board?", "Check the latest run" |
523
- | \`medium\` | Standard tasks, content creation, routine analysis | "Write a blog post", "Analyze last week's metrics" |
524
- | \`high\` | Code changes, architecture, complex research, multi-step | "Refactor the auth module", "Design a new feature" |
525
-
526
- Include in your delegation API call:
527
- \`\`\`json
528
- {"prompt": "...", "employee": "...", "parentSessionId": "...", "effortLevel": "high"}
529
- \`\`\`
530
-
531
- If unsure, default to \`medium\`. Use your judgment — these are guidelines, not rigid rules. A trivial rename is \`low\` even though it's "code changes."${effortOverrideNote}
524
+ When a department has 3+ employees, promote a senior to **manager**. Managers handle their own delegation; you review their summaries, not individual work.
532
525
 
533
526
  ### Your session ID
534
527
 
535
- Your current session ID is provided in the "Current session" section above. Use it as \`parentSessionId\` when spawning children and for the \`/children\` lookup.`;
528
+ Your current session ID is in the "Current session" section above. Use it as \`parentSessionId\`.${effortOverrideNote}`;
536
529
  }
537
530
  function buildApiReference(gatewayUrl, portalName) {
538
531
  return `## ${portalName} Gateway API (${gatewayUrl})
@@ -560,4 +553,26 @@ You can call these endpoints with curl to inspect and manage the gateway:
560
553
  | \`/api/connectors/:name/send\` | POST | Send message via connector |
561
554
  | \`/api/logs\` | GET | Recent log lines |`;
562
555
  }
556
+ /**
557
+ * Progressive trimming by tier: OPTIONAL sections are replaced with summaries first,
558
+ * then STANDARD, then (as a last resort) ESSENTIAL sections.
559
+ */
560
+ function trimContext(sections, maxChars) {
561
+ let parts = sections.map(s => s.content);
562
+ let result = parts.join("\n\n");
563
+ if (result.length <= maxChars)
564
+ return result;
565
+ // Trim OPTIONAL sections first, then STANDARD
566
+ for (const tier of [Tier.OPTIONAL, Tier.STANDARD]) {
567
+ for (let i = sections.length - 1; i >= 0; i--) {
568
+ if (result.length <= maxChars)
569
+ break;
570
+ if (sections[i].tier === tier && sections[i].summary) {
571
+ parts[i] = sections[i].summary;
572
+ result = parts.join("\n\n");
573
+ }
574
+ }
575
+ }
576
+ return result;
577
+ }
563
578
  //# sourceMappingURL=context.js.map