jinn-cli 0.1.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/dist/bin/jimmy.d.ts +3 -0
- package/dist/bin/jimmy.d.ts.map +1 -0
- package/dist/bin/jimmy.js +148 -0
- package/dist/bin/jimmy.js.map +1 -0
- package/dist/src/cli/chrome-allow.d.ts +5 -0
- package/dist/src/cli/chrome-allow.d.ts.map +1 -0
- package/dist/src/cli/chrome-allow.js +241 -0
- package/dist/src/cli/chrome-allow.js.map +1 -0
- package/dist/src/cli/create.d.ts +2 -0
- package/dist/src/cli/create.d.ts.map +1 -0
- package/dist/src/cli/create.js +72 -0
- package/dist/src/cli/create.js.map +1 -0
- package/dist/src/cli/instances.d.ts +14 -0
- package/dist/src/cli/instances.d.ts.map +1 -0
- package/dist/src/cli/instances.js +43 -0
- package/dist/src/cli/instances.js.map +1 -0
- package/dist/src/cli/list.d.ts +2 -0
- package/dist/src/cli/list.d.ts.map +1 -0
- package/dist/src/cli/list.js +38 -0
- package/dist/src/cli/list.js.map +1 -0
- package/dist/src/cli/migrate.d.ts +5 -0
- package/dist/src/cli/migrate.d.ts.map +1 -0
- package/dist/src/cli/migrate.js +203 -0
- package/dist/src/cli/migrate.js.map +1 -0
- package/dist/src/cli/nuke.d.ts +2 -0
- package/dist/src/cli/nuke.d.ts.map +1 -0
- package/dist/src/cli/nuke.js +91 -0
- package/dist/src/cli/nuke.js.map +1 -0
- package/dist/src/cli/remove.d.ts +4 -0
- package/dist/src/cli/remove.d.ts.map +1 -0
- package/dist/src/cli/remove.js +47 -0
- package/dist/src/cli/remove.js.map +1 -0
- package/dist/src/cli/setup.d.ts +4 -0
- package/dist/src/cli/setup.d.ts.map +1 -0
- package/dist/src/cli/setup.js +483 -0
- package/dist/src/cli/setup.js.map +1 -0
- package/dist/src/cli/skills.d.ts +28 -0
- package/dist/src/cli/skills.d.ts.map +1 -0
- package/dist/src/cli/skills.js +284 -0
- package/dist/src/cli/skills.js.map +1 -0
- package/dist/src/cli/start.d.ts +5 -0
- package/dist/src/cli/start.d.ts.map +1 -0
- package/dist/src/cli/start.js +34 -0
- package/dist/src/cli/start.js.map +1 -0
- package/dist/src/cli/status.d.ts +2 -0
- package/dist/src/cli/status.d.ts.map +1 -0
- package/dist/src/cli/status.js +60 -0
- package/dist/src/cli/status.js.map +1 -0
- package/dist/src/cli/stop.d.ts +2 -0
- package/dist/src/cli/stop.d.ts.map +1 -0
- package/dist/src/cli/stop.js +11 -0
- package/dist/src/cli/stop.js.map +1 -0
- package/dist/src/connectors/slack/format.d.ts +10 -0
- package/dist/src/connectors/slack/format.d.ts.map +1 -0
- package/dist/src/connectors/slack/format.js +55 -0
- package/dist/src/connectors/slack/format.js.map +1 -0
- package/dist/src/connectors/slack/index.d.ts +18 -0
- package/dist/src/connectors/slack/index.d.ts.map +1 -0
- package/dist/src/connectors/slack/index.js +122 -0
- package/dist/src/connectors/slack/index.js.map +1 -0
- package/dist/src/connectors/slack/threads.d.ts +2 -0
- package/dist/src/connectors/slack/threads.d.ts.map +1 -0
- package/dist/src/connectors/slack/threads.js +10 -0
- package/dist/src/connectors/slack/threads.js.map +1 -0
- package/dist/src/cron/jobs.d.ts +5 -0
- package/dist/src/cron/jobs.d.ts.map +1 -0
- package/dist/src/cron/jobs.js +23 -0
- package/dist/src/cron/jobs.js.map +1 -0
- package/dist/src/cron/runner.d.ts +3 -0
- package/dist/src/cron/runner.d.ts.map +1 -0
- package/dist/src/cron/runner.js +118 -0
- package/dist/src/cron/runner.js.map +1 -0
- package/dist/src/cron/scheduler.d.ts +5 -0
- package/dist/src/cron/scheduler.d.ts.map +1 -0
- package/dist/src/cron/scheduler.js +39 -0
- package/dist/src/cron/scheduler.js.map +1 -0
- package/dist/src/engines/claude.d.ts +14 -0
- package/dist/src/engines/claude.d.ts.map +1 -0
- package/dist/src/engines/claude.js +264 -0
- package/dist/src/engines/claude.js.map +1 -0
- package/dist/src/engines/codex.d.ts +15 -0
- package/dist/src/engines/codex.d.ts.map +1 -0
- package/dist/src/engines/codex.js +346 -0
- package/dist/src/engines/codex.js.map +1 -0
- package/dist/src/gateway/api.d.ts +13 -0
- package/dist/src/gateway/api.d.ts.map +1 -0
- package/dist/src/gateway/api.js +819 -0
- package/dist/src/gateway/api.js.map +1 -0
- package/dist/src/gateway/daemon-entry.d.ts +2 -0
- package/dist/src/gateway/daemon-entry.d.ts.map +1 -0
- package/dist/src/gateway/daemon-entry.js +12 -0
- package/dist/src/gateway/daemon-entry.js.map +1 -0
- package/dist/src/gateway/lifecycle.d.ts +10 -0
- package/dist/src/gateway/lifecycle.d.ts.map +1 -0
- package/dist/src/gateway/lifecycle.js +124 -0
- package/dist/src/gateway/lifecycle.js.map +1 -0
- package/dist/src/gateway/org.d.ts +10 -0
- package/dist/src/gateway/org.d.ts.map +1 -0
- package/dist/src/gateway/org.js +71 -0
- package/dist/src/gateway/org.js.map +1 -0
- package/dist/src/gateway/server.d.ts +4 -0
- package/dist/src/gateway/server.d.ts.map +1 -0
- package/dist/src/gateway/server.js +301 -0
- package/dist/src/gateway/server.js.map +1 -0
- package/dist/src/gateway/watcher.d.ts +14 -0
- package/dist/src/gateway/watcher.d.ts.map +1 -0
- package/dist/src/gateway/watcher.js +104 -0
- package/dist/src/gateway/watcher.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +4 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/sessions/context.d.ts +20 -0
- package/dist/src/sessions/context.d.ts.map +1 -0
- package/dist/src/sessions/context.js +532 -0
- package/dist/src/sessions/context.js.map +1 -0
- package/dist/src/sessions/manager.d.ts +38 -0
- package/dist/src/sessions/manager.d.ts.map +1 -0
- package/dist/src/sessions/manager.js +208 -0
- package/dist/src/sessions/manager.js.map +1 -0
- package/dist/src/sessions/queue.d.ts +14 -0
- package/dist/src/sessions/queue.d.ts.map +1 -0
- package/dist/src/sessions/queue.js +42 -0
- package/dist/src/sessions/queue.js.map +1 -0
- package/dist/src/sessions/registry.d.ts +46 -0
- package/dist/src/sessions/registry.d.ts.map +1 -0
- package/dist/src/sessions/registry.js +193 -0
- package/dist/src/sessions/registry.js.map +1 -0
- package/dist/src/shared/config.d.ts +3 -0
- package/dist/src/shared/config.d.ts.map +1 -0
- package/dist/src/shared/config.js +11 -0
- package/dist/src/shared/config.js.map +1 -0
- package/dist/src/shared/logger.d.ts +12 -0
- package/dist/src/shared/logger.d.ts.map +1 -0
- package/dist/src/shared/logger.js +35 -0
- package/dist/src/shared/logger.js.map +1 -0
- package/dist/src/shared/paths.d.ts +19 -0
- package/dist/src/shared/paths.d.ts.map +1 -0
- package/dist/src/shared/paths.js +31 -0
- package/dist/src/shared/paths.js.map +1 -0
- package/dist/src/shared/types.d.ts +166 -0
- package/dist/src/shared/types.d.ts.map +1 -0
- package/dist/src/shared/types.js +4 -0
- package/dist/src/shared/types.js.map +1 -0
- package/dist/src/shared/version.d.ts +15 -0
- package/dist/src/shared/version.d.ts.map +1 -0
- package/dist/src/shared/version.js +56 -0
- package/dist/src/shared/version.js.map +1 -0
- package/dist/web/404.html +1 -0
- package/dist/web/_next/static/chunks/198-fd91406a158c5c25.js +1 -0
- package/dist/web/_next/static/chunks/517.62389e8d3c929c43.js +1 -0
- package/dist/web/_next/static/chunks/534-17c49c944e0d0fe1.js +1 -0
- package/dist/web/_next/static/chunks/573-070537ec2452d03e.js +1 -0
- package/dist/web/_next/static/chunks/590-2c34156c7417317e.js +1 -0
- package/dist/web/_next/static/chunks/704-af2893821e1d18dc.js +1 -0
- package/dist/web/_next/static/chunks/7273c211.06e3b6021d90b73f.js +1 -0
- package/dist/web/_next/static/chunks/73-c226535579393e21.js +1 -0
- package/dist/web/_next/static/chunks/743-5bb03adbb0e4ddec.js +1 -0
- package/dist/web/_next/static/chunks/874.97d5a27895061057.js +1 -0
- package/dist/web/_next/static/chunks/8e6518bb-c26e82767f1faf66.js +1 -0
- package/dist/web/_next/static/chunks/app/_not-found/page-bb075b0779827928.js +1 -0
- package/dist/web/_next/static/chunks/app/chat/page-6d5bc707a45c92c6.js +1 -0
- package/dist/web/_next/static/chunks/app/costs/page-d6c03718defdb599.js +1 -0
- package/dist/web/_next/static/chunks/app/cron/page-4c563eef2b6231fe.js +1 -0
- package/dist/web/_next/static/chunks/app/kanban/page-55a73165a36f4077.js +1 -0
- package/dist/web/_next/static/chunks/app/layout-5129b67d5f126cf0.js +1 -0
- package/dist/web/_next/static/chunks/app/logs/page-e18889d67e48c9c9.js +1 -0
- package/dist/web/_next/static/chunks/app/org/page-d5cd8d9b7864737b.js +1 -0
- package/dist/web/_next/static/chunks/app/page-b81992940fd1dbc6.js +1 -0
- package/dist/web/_next/static/chunks/app/sessions/page-2eef6ac7882a28ba.js +1 -0
- package/dist/web/_next/static/chunks/app/settings/page-4fb01b9b09500170.js +1 -0
- package/dist/web/_next/static/chunks/app/skills/page-df9465e314561bb5.js +1 -0
- package/dist/web/_next/static/chunks/framework-077b27ad7787463c.js +1 -0
- package/dist/web/_next/static/chunks/main-app-437f51faf74fbb3b.js +1 -0
- package/dist/web/_next/static/chunks/main-f1c74cefd4965abf.js +1 -0
- package/dist/web/_next/static/chunks/pages/_app-77a85fe7d6bca671.js +1 -0
- package/dist/web/_next/static/chunks/pages/_error-68febf4b34900064.js +1 -0
- package/dist/web/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/dist/web/_next/static/chunks/webpack-0f39b7e91dce9791.js +1 -0
- package/dist/web/_next/static/css/4a6a5bca9238c104.css +1 -0
- package/dist/web/_next/static/vLvOwhC8JocJzSHTHKKOv/_buildManifest.js +1 -0
- package/dist/web/_next/static/vLvOwhC8JocJzSHTHKKOv/_ssgManifest.js +1 -0
- package/dist/web/chat.html +1 -0
- package/dist/web/chat.txt +20 -0
- package/dist/web/costs.html +16 -0
- package/dist/web/costs.txt +20 -0
- package/dist/web/cron.html +1 -0
- package/dist/web/cron.txt +20 -0
- package/dist/web/index.html +1 -0
- package/dist/web/index.txt +20 -0
- package/dist/web/kanban.html +1 -0
- package/dist/web/kanban.txt +20 -0
- package/dist/web/logs.html +7 -0
- package/dist/web/logs.txt +20 -0
- package/dist/web/org.html +1 -0
- package/dist/web/org.txt +20 -0
- package/dist/web/sessions.html +1 -0
- package/dist/web/sessions.txt +20 -0
- package/dist/web/settings.html +1 -0
- package/dist/web/settings.txt +20 -0
- package/dist/web/skills.html +1 -0
- package/dist/web/skills.txt +20 -0
- package/package.json +43 -0
- package/template/AGENTS.md +167 -0
- package/template/CLAUDE.md +106 -0
- package/template/config.default.yaml +27 -0
- package/template/docs/architecture.md +74 -0
- package/template/docs/connectors.md +72 -0
- package/template/docs/cron.md +137 -0
- package/template/docs/org.md +105 -0
- package/template/docs/overview.md +39 -0
- package/template/docs/self-modification.md +65 -0
- package/template/docs/skills.md +58 -0
- package/template/knowledge/.gitkeep +0 -0
- package/template/migrations/.gitkeep +0 -0
- package/template/migrations/0.1.0/MIGRATION.md +25 -0
- package/template/skills/cron-manager/SKILL.md +127 -0
- package/template/skills/find-and-install/SKILL.md +92 -0
- package/template/skills/management/SKILL.md +203 -0
- package/template/skills/migrate/SKILL.md +154 -0
- package/template/skills/new/SKILL.md +19 -0
- package/template/skills/onboarding/SKILL.md +106 -0
- package/template/skills/self-heal/SKILL.md +114 -0
- package/template/skills/skill-creator/SKILL.md +112 -0
- package/template/skills/status/SKILL.md +19 -0
- package/template/skills/sync/SKILL.md +67 -0
- package/template/skills.json +3 -0
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { JINN_HOME, ORG_DIR, CRON_JOBS, DOCS_DIR } from "../shared/paths.js";
|
|
4
|
+
const MAX_CONTEXT_CHARS = 100000;
|
|
5
|
+
/**
|
|
6
|
+
* Build a rich system prompt for engine sessions.
|
|
7
|
+
* This is what makes Jinn "smart" — the engine sees all of this context
|
|
8
|
+
* before responding to the user.
|
|
9
|
+
*/
|
|
10
|
+
export function buildContext(opts) {
|
|
11
|
+
const sections = [];
|
|
12
|
+
// Compute gateway URL once — used by multiple sections
|
|
13
|
+
const gatewayUrl = opts.config
|
|
14
|
+
? `http://${opts.config.gateway.host || "127.0.0.1"}:${opts.config.gateway.port || 7777}`
|
|
15
|
+
: "http://127.0.0.1:7777";
|
|
16
|
+
// Resolve personalized names from config
|
|
17
|
+
const portalName = opts.portalName || opts.config?.portal?.portalName || "Jinn";
|
|
18
|
+
const operatorName = opts.operatorName || opts.config?.portal?.operatorName;
|
|
19
|
+
const language = opts.language || opts.config?.portal?.language || "English";
|
|
20
|
+
// ── Identity ──────────────────────────────────────────────
|
|
21
|
+
if (opts.employee) {
|
|
22
|
+
sections.push(buildEmployeeIdentity(opts.employee, portalName, language));
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
sections.push(buildIdentity(portalName, operatorName, language));
|
|
26
|
+
}
|
|
27
|
+
// ── Self-evolution ────────────────────────────────────────
|
|
28
|
+
if (!opts.employee) {
|
|
29
|
+
sections.push(buildEvolutionContext(portalName));
|
|
30
|
+
}
|
|
31
|
+
// ── Session context ───────────────────────────────────────
|
|
32
|
+
sections.push(buildSessionContext({ ...opts, sessionId: opts.sessionId }));
|
|
33
|
+
// ── Configuration awareness ───────────────────────────────
|
|
34
|
+
if (opts.config) {
|
|
35
|
+
sections.push(buildConfigContext(opts.config, gatewayUrl));
|
|
36
|
+
}
|
|
37
|
+
// ── Organization ──────────────────────────────────────────
|
|
38
|
+
const orgCtx = buildOrgContext();
|
|
39
|
+
if (orgCtx)
|
|
40
|
+
sections.push(orgCtx);
|
|
41
|
+
// ── Cron jobs ─────────────────────────────────────────────
|
|
42
|
+
const cronCtx = buildCronContext();
|
|
43
|
+
if (cronCtx)
|
|
44
|
+
sections.push(cronCtx);
|
|
45
|
+
// ── Knowledge / docs ──────────────────────────────────────
|
|
46
|
+
const knowledgeCtx = buildKnowledgeContext();
|
|
47
|
+
if (knowledgeCtx)
|
|
48
|
+
sections.push(knowledgeCtx);
|
|
49
|
+
// ── Language override for skills ─────────────────────────
|
|
50
|
+
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.`);
|
|
52
|
+
}
|
|
53
|
+
// ── Connectors (Slack, etc.) ──────────────────────────────
|
|
54
|
+
if (opts.connectors && opts.connectors.length > 0) {
|
|
55
|
+
sections.push(buildConnectorContext(opts.connectors, gatewayUrl, portalName));
|
|
56
|
+
}
|
|
57
|
+
// ── Local environment ────────────────────────────────────
|
|
58
|
+
const envCtx = buildEnvironmentContext();
|
|
59
|
+
if (envCtx)
|
|
60
|
+
sections.push(envCtx);
|
|
61
|
+
// ── Delegation protocol ──────────────────────────────────
|
|
62
|
+
if (!opts.employee) {
|
|
63
|
+
sections.push(buildDelegationProtocol(gatewayUrl, portalName));
|
|
64
|
+
}
|
|
65
|
+
// ── Gateway API reference ─────────────────────────────────
|
|
66
|
+
sections.push(buildApiReference(gatewayUrl, portalName));
|
|
67
|
+
// ── Size guard: progressively trim if over budget ─────────
|
|
68
|
+
return trimContext(sections);
|
|
69
|
+
}
|
|
70
|
+
// ═══════════════════════════════════════════════════════════════
|
|
71
|
+
// Section builders
|
|
72
|
+
// ═══════════════════════════════════════════════════════════════
|
|
73
|
+
function buildEmployeeIdentity(employee, portalName, language) {
|
|
74
|
+
const languageInstruction = language !== "English"
|
|
75
|
+
? `\n**Language**: Always respond in ${language}. All your communication with the user must be in ${language}.\n`
|
|
76
|
+
: "";
|
|
77
|
+
return `# You are ${employee.displayName}
|
|
78
|
+
|
|
79
|
+
You are an AI employee in the ${portalName} gateway system.
|
|
80
|
+
|
|
81
|
+
## Your persona
|
|
82
|
+
${employee.persona}
|
|
83
|
+
${languageInstruction}
|
|
84
|
+
## Your role
|
|
85
|
+
- **Name**: ${employee.name}
|
|
86
|
+
- **Display name**: ${employee.displayName}
|
|
87
|
+
- **Department**: ${employee.department}
|
|
88
|
+
- **Rank**: ${employee.rank}
|
|
89
|
+
- **Engine**: ${employee.engine}
|
|
90
|
+
- **Model**: ${employee.model}
|
|
91
|
+
|
|
92
|
+
## System context
|
|
93
|
+
You are part of the ${portalName} AI gateway — a system that orchestrates AI workers. You have access to the filesystem, can run commands, call APIs, and send messages via connectors. Your working directory is \`~/.jinn\` (${JINN_HOME}).
|
|
94
|
+
|
|
95
|
+
You can:
|
|
96
|
+
- Read and write files in the home directory
|
|
97
|
+
- Run shell commands
|
|
98
|
+
- Call the gateway API to interact with other parts of the system
|
|
99
|
+
- Send messages via connectors (Slack, etc.)
|
|
100
|
+
- Access skills, knowledge base, and documentation
|
|
101
|
+
- Collaborate with other employees by mentioning them or creating sessions
|
|
102
|
+
|
|
103
|
+
Be proactive, take initiative, and deliver results. You're not a chatbot — you're a worker.`;
|
|
104
|
+
}
|
|
105
|
+
function buildIdentity(portalName, operatorName, language) {
|
|
106
|
+
const operatorLine = operatorName
|
|
107
|
+
? `\nThe user's name is **${operatorName}**. Address them by name when appropriate.`
|
|
108
|
+
: "";
|
|
109
|
+
const languageInstruction = language && language !== "English"
|
|
110
|
+
? `\n**Language**: Always respond in ${language}. All your communication with the user must be in ${language}.`
|
|
111
|
+
: "";
|
|
112
|
+
return `# You are ${portalName}
|
|
113
|
+
|
|
114
|
+
${portalName} is a personal AI assistant and gateway daemon. You are proactive, helpful, and opinionated — not a passive tool. You anticipate needs, suggest improvements, and take initiative when appropriate.${operatorLine}
|
|
115
|
+
|
|
116
|
+
## Core principles
|
|
117
|
+
- **Be proactive**: Don't just answer questions — suggest next steps, flag issues, offer to do related tasks.
|
|
118
|
+
- **Be concise**: Respect the user's time. Lead with the answer, not the reasoning.
|
|
119
|
+
- **Be capable**: You have access to the filesystem, can run commands, call APIs, send messages via connectors, and manage the system.
|
|
120
|
+
- **Be honest**: If you don't know something or can't do something, say so clearly.
|
|
121
|
+
- **Remember context**: You're part of a persistent system. Sessions can be resumed. Build on previous work.
|
|
122
|
+
${languageInstruction}
|
|
123
|
+
## Your home directory
|
|
124
|
+
Your working directory is \`~/.jinn\` (${JINN_HOME}). This contains:
|
|
125
|
+
- \`config.yaml\` — your configuration (engines, connectors, logging)
|
|
126
|
+
- \`org/\` — employee definitions (YAML files defining AI workers)
|
|
127
|
+
- \`skills/\` — reusable skill prompts
|
|
128
|
+
- \`docs/\` — documentation and knowledge base
|
|
129
|
+
- \`knowledge/\` — persistent knowledge files
|
|
130
|
+
- \`cron/\` — scheduled job definitions and run history
|
|
131
|
+
- \`sessions/\` — session database
|
|
132
|
+
- \`logs/\` — gateway logs
|
|
133
|
+
- \`CLAUDE.md\` — user-defined instructions (always follow these)
|
|
134
|
+
- \`AGENTS.md\` — agent/employee documentation
|
|
135
|
+
|
|
136
|
+
You can read, write, and modify any of these files to configure yourself, create new employees, add skills, etc.`;
|
|
137
|
+
}
|
|
138
|
+
function buildSessionContext(opts) {
|
|
139
|
+
let ctx = `## Current session\n`;
|
|
140
|
+
if (opts.sessionId)
|
|
141
|
+
ctx += `- Session ID: ${opts.sessionId}\n`;
|
|
142
|
+
ctx += `- Source: ${opts.source}\n`;
|
|
143
|
+
ctx += `- Channel: ${opts.channel}\n`;
|
|
144
|
+
if (opts.thread)
|
|
145
|
+
ctx += `- Thread: ${opts.thread}\n`;
|
|
146
|
+
ctx += `- User: ${opts.user}\n`;
|
|
147
|
+
ctx += `- Working directory: ${JINN_HOME}`;
|
|
148
|
+
return ctx;
|
|
149
|
+
}
|
|
150
|
+
function buildConfigContext(config, gatewayUrl) {
|
|
151
|
+
const lines = [`## Current configuration`];
|
|
152
|
+
lines.push(`- Gateway: ${gatewayUrl}`);
|
|
153
|
+
lines.push(`- Default engine: ${config.engines.default}`);
|
|
154
|
+
if (config.engines.claude?.model) {
|
|
155
|
+
lines.push(`- Claude model: ${config.engines.claude.model}`);
|
|
156
|
+
}
|
|
157
|
+
if (config.engines.codex?.model) {
|
|
158
|
+
lines.push(`- Codex model: ${config.engines.codex.model}`);
|
|
159
|
+
}
|
|
160
|
+
if (config.logging) {
|
|
161
|
+
lines.push(`- Log level: ${config.logging.level || "info"}`);
|
|
162
|
+
}
|
|
163
|
+
return lines.join("\n");
|
|
164
|
+
}
|
|
165
|
+
function buildOrgContext() {
|
|
166
|
+
try {
|
|
167
|
+
const files = fs.readdirSync(ORG_DIR).filter(f => f.endsWith(".yaml") || f.endsWith(".yml"));
|
|
168
|
+
if (files.length === 0)
|
|
169
|
+
return null;
|
|
170
|
+
const lines = [`## Organization (${files.length} employee(s))`];
|
|
171
|
+
for (const file of files) {
|
|
172
|
+
const content = fs.readFileSync(path.join(ORG_DIR, file), "utf-8");
|
|
173
|
+
const name = file.replace(/\.ya?ml$/, "");
|
|
174
|
+
// Extract display name, department, rank, and persona first line from YAML
|
|
175
|
+
const displayMatch = content.match(/displayName:\s*(.+)/);
|
|
176
|
+
const deptMatch = content.match(/department:\s*(.+)/);
|
|
177
|
+
const rankMatch = content.match(/rank:\s*(.+)/);
|
|
178
|
+
const personaMatch = content.match(/persona:\s*[|>]?\s*\n?\s*(.+)/);
|
|
179
|
+
let entry = `- **${displayMatch?.[1] || name}** (${name}) — ${deptMatch?.[1] || "unassigned"}, ${rankMatch?.[1] || "employee"}`;
|
|
180
|
+
if (personaMatch?.[1]) {
|
|
181
|
+
entry += `\n _${personaMatch[1].trim().slice(0, 120)}_`;
|
|
182
|
+
}
|
|
183
|
+
lines.push(entry);
|
|
184
|
+
}
|
|
185
|
+
lines.push(`\nYou can create new employees by writing YAML files to \`${ORG_DIR}/\``);
|
|
186
|
+
return lines.join("\n");
|
|
187
|
+
}
|
|
188
|
+
catch {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
function buildCronContext() {
|
|
193
|
+
try {
|
|
194
|
+
const raw = fs.readFileSync(CRON_JOBS, "utf-8");
|
|
195
|
+
const jobs = JSON.parse(raw);
|
|
196
|
+
if (!Array.isArray(jobs) || jobs.length === 0)
|
|
197
|
+
return null;
|
|
198
|
+
const lines = [`## Scheduled cron jobs (${jobs.length})`];
|
|
199
|
+
for (const job of jobs) {
|
|
200
|
+
const status = job.enabled === false ? " (disabled)" : "";
|
|
201
|
+
lines.push(`- **${job.name}**: \`${job.schedule}\`${status}${job.employee ? ` → ${job.employee}` : ""}`);
|
|
202
|
+
}
|
|
203
|
+
return lines.join("\n");
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return null;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
function buildKnowledgeContext() {
|
|
210
|
+
const dirs = [DOCS_DIR, path.join(JINN_HOME, "knowledge")];
|
|
211
|
+
const allFiles = [];
|
|
212
|
+
for (const dir of dirs) {
|
|
213
|
+
try {
|
|
214
|
+
const files = fs.readdirSync(dir).filter(f => f.endsWith(".md") || f.endsWith(".txt") || f.endsWith(".yaml"));
|
|
215
|
+
allFiles.push(...files.map(f => path.join(dir, f)));
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
// dir doesn't exist
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (allFiles.length === 0)
|
|
222
|
+
return null;
|
|
223
|
+
const lines = [`## Knowledge base (${allFiles.length} file(s))`];
|
|
224
|
+
for (const file of allFiles) {
|
|
225
|
+
try {
|
|
226
|
+
const content = fs.readFileSync(file, "utf-8").trim();
|
|
227
|
+
const basename = path.basename(file);
|
|
228
|
+
lines.push(`### ${basename}\n${content}`);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
lines.push(`- \`${file}\` (unreadable)`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return lines.join("\n\n");
|
|
235
|
+
}
|
|
236
|
+
function buildConnectorContext(connectors, gatewayUrl, portalName) {
|
|
237
|
+
const lines = [`## Available connectors: ${connectors.join(", ")}`];
|
|
238
|
+
lines.push(`You can send messages and interact with external services via the ${portalName} gateway API.`);
|
|
239
|
+
lines.push(`Use bash with curl to call these endpoints:\n`);
|
|
240
|
+
for (const name of connectors) {
|
|
241
|
+
lines.push(`### ${name}`);
|
|
242
|
+
lines.push(`- **Send message**: \`curl -X POST ${gatewayUrl}/api/connectors/${name}/send -H 'Content-Type: application/json' -d '{"channel":"CHANNEL_ID","text":"message"}'\``);
|
|
243
|
+
lines.push(`- **Send threaded reply**: add \`"thread":"THREAD_TS"\` to the JSON body`);
|
|
244
|
+
lines.push(`- You can proactively send messages without being asked — e.g., to notify about completed tasks, errors, or status updates`);
|
|
245
|
+
}
|
|
246
|
+
lines.push(`\n- **List all connectors**: \`curl ${gatewayUrl}/api/connectors\``);
|
|
247
|
+
lines.push(`- Channel IDs and connector config can be found in \`~/.jinn/config.yaml\``);
|
|
248
|
+
return lines.join("\n");
|
|
249
|
+
}
|
|
250
|
+
function buildEnvironmentContext() {
|
|
251
|
+
const home = process.env.HOME || process.env.USERPROFILE || "";
|
|
252
|
+
const lines = [`## Local environment`];
|
|
253
|
+
let hasContent = false;
|
|
254
|
+
// Scan for known tools/platforms in home directory
|
|
255
|
+
const toolDirs = [
|
|
256
|
+
{ dir: ".openclaw", label: "OpenClaw", description: "AI agent platform (agents, cron, memory, hooks, credentials)" },
|
|
257
|
+
{ dir: ".claude", label: "Claude Code", description: "Claude Code CLI config and projects" },
|
|
258
|
+
{ dir: ".codex", label: "Codex", description: "OpenAI Codex CLI config" },
|
|
259
|
+
];
|
|
260
|
+
for (const tool of toolDirs) {
|
|
261
|
+
const toolPath = path.join(home, tool.dir);
|
|
262
|
+
try {
|
|
263
|
+
const stat = fs.statSync(toolPath);
|
|
264
|
+
if (stat.isDirectory()) {
|
|
265
|
+
const contents = fs.readdirSync(toolPath).filter(f => !f.startsWith("."));
|
|
266
|
+
lines.push(`- **${tool.label}** (\`~/${tool.dir}/\`): ${tool.description}`);
|
|
267
|
+
if (contents.length > 0) {
|
|
268
|
+
lines.push(` Contents: ${contents.slice(0, 15).join(", ")}${contents.length > 15 ? `, ... (${contents.length} total)` : ""}`);
|
|
269
|
+
}
|
|
270
|
+
hasContent = true;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
catch {
|
|
274
|
+
// doesn't exist
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
// Scan ~/Projects for user's codebases
|
|
278
|
+
const projectsDir = path.join(home, "Projects");
|
|
279
|
+
try {
|
|
280
|
+
const projects = fs.readdirSync(projectsDir).filter(f => {
|
|
281
|
+
try {
|
|
282
|
+
return fs.statSync(path.join(projectsDir, f)).isDirectory();
|
|
283
|
+
}
|
|
284
|
+
catch {
|
|
285
|
+
return false;
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
if (projects.length > 0) {
|
|
289
|
+
lines.push(`- **Projects** (\`~/Projects/\`): ${projects.join(", ")}`);
|
|
290
|
+
hasContent = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
// no Projects dir
|
|
295
|
+
}
|
|
296
|
+
if (!hasContent)
|
|
297
|
+
return null;
|
|
298
|
+
lines.push(`\nWhen the user asks about tools or systems on their machine, check these directories first before saying you don't know. Be resourceful — explore the filesystem.`);
|
|
299
|
+
return lines.join("\n");
|
|
300
|
+
}
|
|
301
|
+
function buildEvolutionContext(portalName) {
|
|
302
|
+
const profilePath = path.join(JINN_HOME, "knowledge", "user-profile.md");
|
|
303
|
+
let profileContent = "";
|
|
304
|
+
try {
|
|
305
|
+
profileContent = fs.readFileSync(profilePath, "utf-8").trim();
|
|
306
|
+
}
|
|
307
|
+
catch { }
|
|
308
|
+
const isNew = profileContent.length < 50;
|
|
309
|
+
const lines = [`## Self-evolution`];
|
|
310
|
+
if (isNew) {
|
|
311
|
+
lines.push(`**ONBOARDING MODE**: This is a new or unconfigured ${portalName} installation.`);
|
|
312
|
+
lines.push(`Before answering the user's request, introduce yourself briefly and ask them:`);
|
|
313
|
+
lines.push(`1. What's your name and what do you do? (business, role, projects)`);
|
|
314
|
+
lines.push(`2. What should ${portalName} help you automate? (code reviews, deployments, monitoring, etc.)`);
|
|
315
|
+
lines.push(`3. Communication preferences — emoji style, verbosity (concise vs detailed), language`);
|
|
316
|
+
lines.push(`4. Any active projects ${portalName} should know about?`);
|
|
317
|
+
lines.push(`\nAfter the user responds, write their answers to \`~/.jinn/knowledge/user-profile.md\` and \`~/.jinn/knowledge/preferences.md\`.`);
|
|
318
|
+
lines.push(`Then proceed to help with their original request.`);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
lines.push(`You learn and evolve over time. When you discover new information about the user, their projects, or their preferences:`);
|
|
322
|
+
lines.push(`- Update \`~/.jinn/knowledge/user-profile.md\` with business/identity info`);
|
|
323
|
+
lines.push(`- Update \`~/.jinn/knowledge/preferences.md\` with style/communication preferences`);
|
|
324
|
+
lines.push(`- Update \`~/.jinn/knowledge/projects.md\` with project details`);
|
|
325
|
+
lines.push(`- If the user gives you persistent feedback (e.g. "always do X", "never do Y"), update \`~/.jinn/CLAUDE.md\``);
|
|
326
|
+
lines.push(`\nDo this silently — don't announce every file update. Just evolve.`);
|
|
327
|
+
}
|
|
328
|
+
return lines.join("\n");
|
|
329
|
+
}
|
|
330
|
+
function trimContext(sections) {
|
|
331
|
+
let result = sections.join("\n\n");
|
|
332
|
+
if (result.length <= MAX_CONTEXT_CHARS)
|
|
333
|
+
return result;
|
|
334
|
+
// Progressive trimming: replace non-essential sections with compact summaries
|
|
335
|
+
// Order: environment > knowledge content > skill content > org personas
|
|
336
|
+
const trimmable = [
|
|
337
|
+
{ marker: "## Local environment", summary: "## Local environment\nRun `ls ~/` to explore the local filesystem." },
|
|
338
|
+
{ marker: "## Knowledge base", summary: "## Knowledge base\nKnowledge files are in `~/.jinn/knowledge/` and `~/.jinn/docs/`. Read them directly when needed." },
|
|
339
|
+
{ marker: "## Organization", summary: "## Organization\nEmployee files are in `~/.jinn/org/`. Read them directly when needed." },
|
|
340
|
+
];
|
|
341
|
+
for (const { marker, summary } of trimmable) {
|
|
342
|
+
if (result.length <= MAX_CONTEXT_CHARS)
|
|
343
|
+
break;
|
|
344
|
+
const idx = sections.findIndex(s => s.startsWith(marker));
|
|
345
|
+
if (idx !== -1) {
|
|
346
|
+
sections[idx] = summary;
|
|
347
|
+
result = sections.join("\n\n");
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return result;
|
|
351
|
+
}
|
|
352
|
+
function buildDelegationProtocol(gatewayUrl, _portalName) {
|
|
353
|
+
return `## Employee Delegation Protocol
|
|
354
|
+
|
|
355
|
+
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**.
|
|
356
|
+
|
|
357
|
+
### How delegation works
|
|
358
|
+
|
|
359
|
+
1. **Detect**: Spot \`@employee-name\` tags in the user's message, or infer the right employee from context.
|
|
360
|
+
|
|
361
|
+
2. **Check for existing child sessions FIRST**: Before creating a new session, ALWAYS check if you already have a child session for this employee:
|
|
362
|
+
|
|
363
|
+
\`\`\`bash
|
|
364
|
+
curl -s ${gatewayUrl}/api/sessions/<your-session-id>/children
|
|
365
|
+
\`\`\`
|
|
366
|
+
|
|
367
|
+
Look for a child with \`"employee": "<employee-name>"\`. If found, REUSE it (skip to step 5). If not found, proceed to step 3.
|
|
368
|
+
|
|
369
|
+
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.
|
|
370
|
+
|
|
371
|
+
4. **Spawn**: Create a child session via the gateway API:
|
|
372
|
+
|
|
373
|
+
\`\`\`bash
|
|
374
|
+
curl -s -X POST ${gatewayUrl}/api/sessions \\
|
|
375
|
+
-H 'Content-Type: application/json' \\
|
|
376
|
+
-d '{
|
|
377
|
+
"prompt": "<your brief for the employee>",
|
|
378
|
+
"employee": "<employee-name>",
|
|
379
|
+
"parentSessionId": "<your-session-id>"
|
|
380
|
+
}'
|
|
381
|
+
\`\`\`
|
|
382
|
+
|
|
383
|
+
The response includes \`{"id": "<child-session-id>", ...}\`. Save this ID.
|
|
384
|
+
|
|
385
|
+
5. **Send message to existing child session** (when reusing):
|
|
386
|
+
|
|
387
|
+
\`\`\`bash
|
|
388
|
+
curl -s -X POST ${gatewayUrl}/api/sessions/<child-session-id>/message \\
|
|
389
|
+
-H 'Content-Type: application/json' \\
|
|
390
|
+
-d '{"message": "<follow-up instructions>"}'
|
|
391
|
+
\`\`\`
|
|
392
|
+
|
|
393
|
+
6. **Poll**: Check if the child session is complete:
|
|
394
|
+
|
|
395
|
+
\`\`\`bash
|
|
396
|
+
curl -s ${gatewayUrl}/api/sessions/<child-session-id>
|
|
397
|
+
\`\`\`
|
|
398
|
+
|
|
399
|
+
Look at the \`status\` field: \`"running"\` means still working, \`"idle"\` means done, \`"error"\` means failed.
|
|
400
|
+
When \`"idle"\`, read the \`messages\` array — the last assistant message is the employee's response.
|
|
401
|
+
|
|
402
|
+
7. **Review & Verify** (see Oversight Levels below): Before relaying, assess the employee's work based on the task's oversight level.
|
|
403
|
+
|
|
404
|
+
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.
|
|
405
|
+
|
|
406
|
+
9. **Relay**: Summarize or present the employee's response to the user. Add your own commentary if useful. Include what oversight level you applied.
|
|
407
|
+
|
|
408
|
+
### IMPORTANT: Always reuse child sessions
|
|
409
|
+
|
|
410
|
+
Never create duplicate sessions for the same employee within the same parent. The flow is:
|
|
411
|
+
- First time tagging an employee → create child session (step 4)
|
|
412
|
+
- Every subsequent time → reuse via \`/children\` lookup (step 2 → step 5)
|
|
413
|
+
- This ensures the employee has full conversation context and continuity
|
|
414
|
+
|
|
415
|
+
### Automatic Employee Coordination
|
|
416
|
+
|
|
417
|
+
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.
|
|
418
|
+
|
|
419
|
+
**Step 1 — Analyze the task**: Break it down into sub-tasks. Identify which employee(s) are best suited for each.
|
|
420
|
+
|
|
421
|
+
**Step 2 — Determine dependencies**: Can sub-tasks run in parallel, or does one depend on another's output?
|
|
422
|
+
|
|
423
|
+
**Step 3 — Spawn in parallel when independent**: Use multiple \`curl\` calls to create child sessions simultaneously:
|
|
424
|
+
|
|
425
|
+
\`\`\`bash
|
|
426
|
+
# Spawn multiple employees at once — don't wait between them
|
|
427
|
+
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>"}' &
|
|
428
|
+
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>"}' &
|
|
429
|
+
wait
|
|
430
|
+
\`\`\`
|
|
431
|
+
|
|
432
|
+
**Step 4 — Poll all sessions**: Check each child session until all are idle. Don't respond to the user until you have all results.
|
|
433
|
+
|
|
434
|
+
**Step 5 — Cross-reference**: Compare and synthesize results from multiple employees. Look for:
|
|
435
|
+
- Contradictions or conflicts between findings
|
|
436
|
+
- Gaps that no employee covered
|
|
437
|
+
- Dependencies where one employee's output informs the next step
|
|
438
|
+
|
|
439
|
+
**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.
|
|
440
|
+
|
|
441
|
+
**Step 7 — Respond**: Give the user a unified, synthesized answer — not a dump of each employee's raw output.
|
|
442
|
+
|
|
443
|
+
**Examples:**
|
|
444
|
+
- "Find and fix analytics issues" → Spawn analytics employee first → review findings → spawn dev employee with specific fixes from findings → review code → report to user
|
|
445
|
+
- "Optimize the blog conversion" → Spawn analytics employee AND dev employee in parallel (independent research) → cross-reference data insights with codebase findings → propose unified plan
|
|
446
|
+
- "Check how the A/B test is doing" → Spawn analytics employee → review → report (single employee, no coordination needed)
|
|
447
|
+
|
|
448
|
+
### Smart delegation
|
|
449
|
+
|
|
450
|
+
- **Tagged employees**: Always delegate to them.
|
|
451
|
+
- **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.
|
|
452
|
+
- **Short tasks** (questions, lookups): Wait for the response, then relay immediately.
|
|
453
|
+
- **Long tasks** (coding, research): Tell the user the employee is working on it, then check back.
|
|
454
|
+
- **Multi-employee tasks**: Coordinate their work. Spawn independent tasks in parallel, serialize dependent ones, cross-reference all results before responding.
|
|
455
|
+
|
|
456
|
+
### Oversight Levels
|
|
457
|
+
|
|
458
|
+
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.
|
|
459
|
+
|
|
460
|
+
**TRUST** — Relay directly, minimal review.
|
|
461
|
+
Use when: simple questions, status checks, lookups, information retrieval, low-risk tasks, or tasks the employee has proven reliable at.
|
|
462
|
+
You do: Skim the response for obvious issues, relay to user.
|
|
463
|
+
|
|
464
|
+
**VERIFY** — Read critically, spot-check key outputs.
|
|
465
|
+
Use when: code changes, config modifications, medium-complexity tasks, routine work, content creation.
|
|
466
|
+
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.
|
|
467
|
+
|
|
468
|
+
**THOROUGH** — Full review, multi-turn follow-up as needed.
|
|
469
|
+
Use when: architecture decisions, breaking changes, multi-file refactors, high-severity tasks, security-sensitive work, user explicitly asks for careful review.
|
|
470
|
+
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.
|
|
471
|
+
|
|
472
|
+
**How to pick the level:**
|
|
473
|
+
- Consider task complexity (one-liner → TRUST, multi-file → VERIFY or THOROUGH)
|
|
474
|
+
- Consider severity (can it break things? → VERIFY or THOROUGH)
|
|
475
|
+
- Consider the user's tone ("quick question" → TRUST, "this is critical" → THOROUGH)
|
|
476
|
+
- When in doubt, default to VERIFY — it's the safe middle ground
|
|
477
|
+
- 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
|
|
478
|
+
|
|
479
|
+
### Manager Delegation
|
|
480
|
+
|
|
481
|
+
As the organization grows, you should promote reliable senior employees to **manager** rank. Managers handle their own department's delegation:
|
|
482
|
+
|
|
483
|
+
**How manager delegation works:**
|
|
484
|
+
1. You (COO) delegate to the **manager**, not individual employees
|
|
485
|
+
2. The manager spawns their own child sessions with their reports
|
|
486
|
+
3. The manager handles the verification loop for their department
|
|
487
|
+
4. You review the manager's summary, not each individual employee's work
|
|
488
|
+
5. This scales the org without overwhelming you
|
|
489
|
+
|
|
490
|
+
**When to create a manager:**
|
|
491
|
+
- A department has 3+ employees and you're spending too much time on individual delegation
|
|
492
|
+
- An employee has consistently delivered high-quality work at senior rank
|
|
493
|
+
- The user explicitly asks you to promote someone
|
|
494
|
+
|
|
495
|
+
**Manager persona template:**
|
|
496
|
+
Managers need delegation instructions in their persona. When promoting an employee to manager, add to their persona:
|
|
497
|
+
- They manage their department's employees
|
|
498
|
+
- They can spawn child sessions via the gateway API (include the API patterns)
|
|
499
|
+
- They should apply oversight levels to their reports' work
|
|
500
|
+
- They report summaries back to you (the COO)
|
|
501
|
+
|
|
502
|
+
### Your session ID
|
|
503
|
+
|
|
504
|
+
Your current session ID is provided in the "Current session" section above. Use it as \`parentSessionId\` when spawning children and for the \`/children\` lookup.`;
|
|
505
|
+
}
|
|
506
|
+
function buildApiReference(gatewayUrl, portalName) {
|
|
507
|
+
return `## ${portalName} Gateway API (${gatewayUrl})
|
|
508
|
+
|
|
509
|
+
You can call these endpoints with curl to inspect and manage the gateway:
|
|
510
|
+
|
|
511
|
+
| Endpoint | Method | Description |
|
|
512
|
+
|----------|--------|-------------|
|
|
513
|
+
| \`/api/status\` | GET | Gateway status, uptime, engine info |
|
|
514
|
+
| \`/api/sessions\` | GET | List all sessions |
|
|
515
|
+
| \`/api/sessions/:id\` | GET | Session detail (includes messages) |
|
|
516
|
+
| \`/api/sessions\` | POST | Create new session (\`{prompt, engine?, employee?, parentSessionId?}\`) |
|
|
517
|
+
| \`/api/sessions/:id/message\` | POST | Send follow-up message to existing session (\`{message}\`) |
|
|
518
|
+
| \`/api/sessions/:id/children\` | GET | List child sessions of a parent |
|
|
519
|
+
| \`/api/cron\` | GET | List cron jobs |
|
|
520
|
+
| \`/api/cron/:id\` | PUT | Update cron job (toggle enabled, etc.) |
|
|
521
|
+
| \`/api/cron/:id/runs\` | GET | Cron run history |
|
|
522
|
+
| \`/api/org\` | GET | Organization structure |
|
|
523
|
+
| \`/api/org/employees/:name\` | GET | Employee details |
|
|
524
|
+
| \`/api/skills\` | GET | List skills |
|
|
525
|
+
| \`/api/skills/:name\` | GET | Skill content |
|
|
526
|
+
| \`/api/config\` | GET | Current config |
|
|
527
|
+
| \`/api/config\` | PUT | Update config |
|
|
528
|
+
| \`/api/connectors\` | GET | List connectors |
|
|
529
|
+
| \`/api/connectors/:name/send\` | POST | Send message via connector |
|
|
530
|
+
| \`/api/logs\` | GET | Recent log lines |`;
|
|
531
|
+
}
|
|
532
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../../src/sessions/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE7E,MAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,IAY5B;IACC,MAAM,QAAQ,GAAa,EAAE,CAAC;IAE9B,uDAAuD;IACvD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM;QAC5B,CAAC,CAAC,UAAU,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI,WAAW,IAAI,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAA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GAAG,OAAO,CAAC;YACxB,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;IACH,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,uBAAuB,CAAC,UAAkB,EAAE,WAAmB;IACtE,OAAO;;;;;;;;;;;UAWC,UAAU;;;;;;;;;;kBAUF,UAAU;;;;;;;;;;;;;;kBAcV,UAAU;;;;;;;;UAQlB,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA+BF,UAAU;kBACV,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mKA4EuI,CAAC;AACpK,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAkB,EAAE,UAAkB;IAC/D,OAAO,MAAM,UAAU,iBAAiB,UAAU;;;;;;;;;;;;;;;;;;;;;;;2CAuBT,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Engine, Connector, IncomingMessage, JinnConfig, Employee } from "../shared/types.js";
|
|
2
|
+
import { SessionQueue } from "./queue.js";
|
|
3
|
+
export declare class SessionManager {
|
|
4
|
+
private config;
|
|
5
|
+
private engines;
|
|
6
|
+
private connectorNames;
|
|
7
|
+
private queue;
|
|
8
|
+
constructor(config: JinnConfig, engines: Map<string, Engine>, connectorNames?: string[]);
|
|
9
|
+
/**
|
|
10
|
+
* Get an engine by name.
|
|
11
|
+
*/
|
|
12
|
+
getEngine(name: string): Engine | undefined;
|
|
13
|
+
/**
|
|
14
|
+
* Get the session queue (used by api.ts for mid-turn handling).
|
|
15
|
+
*/
|
|
16
|
+
getQueue(): SessionQueue;
|
|
17
|
+
/**
|
|
18
|
+
* Main entry point: route an incoming message to the right session.
|
|
19
|
+
*/
|
|
20
|
+
route(msg: IncomingMessage, connector: Connector, employee?: Employee): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Run engine for a session, handling reactions and status updates.
|
|
23
|
+
*/
|
|
24
|
+
private runSession;
|
|
25
|
+
/**
|
|
26
|
+
* Handle slash commands. Returns true if a command was handled.
|
|
27
|
+
*/
|
|
28
|
+
handleCommand(msg: IncomingMessage, connector: Connector): Promise<boolean>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete existing session for a source ref.
|
|
31
|
+
*/
|
|
32
|
+
resetSession(sourceRef: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* Build a source ref string from a message.
|
|
35
|
+
*/
|
|
36
|
+
private buildSourceRef;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../../src/sessions/manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,SAAS,EACT,eAAe,EAEf,UAAU,EACV,QAAQ,EAET,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAI1C,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,cAAc,CAAW;IACjC,OAAO,CAAC,KAAK,CAAsB;gBAGjC,MAAM,EAAE,UAAU,EAClB,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,cAAc,GAAE,MAAM,EAAO;IAO/B;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3C;;OAEG;IACH,QAAQ,IAAI,YAAY;IAIxB;;OAEG;IACG,KAAK,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAuC3F;;OAEG;YACW,UAAU;IA6HxB;;OAEG;IACG,aAAa,CAAC,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC;IAoCjF;;OAEG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAQrC;;OAEG;IACH,OAAO,CAAC,cAAc;CAKvB"}
|