somora 2026.930.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.
- package/LICENSE +21 -0
- package/README.md +364 -0
- package/bin/node-version.d.mts +3 -0
- package/bin/node-version.mjs +45 -0
- package/bin/somora.mjs +77 -0
- package/config.example.yaml +896 -0
- package/docs/agents.md +677 -0
- package/docs/api.md +3194 -0
- package/docs/browser.md +317 -0
- package/docs/builder.md +331 -0
- package/docs/cache-strategy.md +373 -0
- package/docs/compaction.md +253 -0
- package/docs/display.md +154 -0
- package/docs/dream-phases.md +891 -0
- package/docs/files.md +387 -0
- package/docs/imagegen.md +366 -0
- package/docs/images/somora-hero.png +0 -0
- package/docs/images/somora-mobile-2026-05-23.png +0 -0
- package/docs/images/somora-tui-2026-05-23.png +0 -0
- package/docs/images/somora-web-2026-05-23.png +0 -0
- package/docs/index.md +178 -0
- package/docs/lsp.md +93 -0
- package/docs/mcp.md +332 -0
- package/docs/memory.md +407 -0
- package/docs/mobile.md +310 -0
- package/docs/models.md +379 -0
- package/docs/projects.md +425 -0
- package/docs/realtime-voice.md +293 -0
- package/docs/resources.md +230 -0
- package/docs/sampling.md +128 -0
- package/docs/security.md +189 -0
- package/docs/sentinel.md +295 -0
- package/docs/setup.md +1217 -0
- package/docs/skills.md +501 -0
- package/docs/team.md +189 -0
- package/docs/thinking.md +463 -0
- package/docs/tmux.md +399 -0
- package/docs/tools.md +117 -0
- package/docs/videogen.md +191 -0
- package/docs/voice.md +288 -0
- package/docs/web.md +893 -0
- package/docs/wiki.md +583 -0
- package/npm-shrinkwrap.json +5670 -0
- package/package.json +116 -0
- package/src/attachments/store.ts +196 -0
- package/src/browser/change-stream.ts +31 -0
- package/src/browser/display.ts +108 -0
- package/src/browser/policy.ts +121 -0
- package/src/browser/screencast.ts +374 -0
- package/src/browser/service.ts +1337 -0
- package/src/browser/session.ts +15 -0
- package/src/browser/snapshot.ts +40 -0
- package/src/cli/auth.ts +117 -0
- package/src/cli/codex.ts +41 -0
- package/src/cli/lsp.ts +71 -0
- package/src/cli/resolvers/clawhub.ts +400 -0
- package/src/cli/setup.ts +835 -0
- package/src/cli/skill.ts +619 -0
- package/src/cli/somora.ts +548 -0
- package/src/cli/systemd-unit.ts +72 -0
- package/src/cli/team.ts +148 -0
- package/src/cli/tui/activity-stream.ts +121 -0
- package/src/cli/tui/api.ts +479 -0
- package/src/cli/tui/app.tsx +1169 -0
- package/src/cli/tui/autocomplete.tsx +55 -0
- package/src/cli/tui/commands.ts +913 -0
- package/src/cli/tui/dream-glyphs.ts +22 -0
- package/src/cli/tui/footer.tsx +15 -0
- package/src/cli/tui/format.ts +28 -0
- package/src/cli/tui/header.tsx +279 -0
- package/src/cli/tui/index.tsx +120 -0
- package/src/cli/tui/markdown.tsx +63 -0
- package/src/cli/tui/sampling.ts +162 -0
- package/src/cli/tui/separator.tsx +13 -0
- package/src/cli/tui/state.ts +42 -0
- package/src/cli/tui/stream.ts +330 -0
- package/src/cli/tui/thinking-text.ts +54 -0
- package/src/cli/tui/turn-views.tsx +499 -0
- package/src/cli/tui/types.ts +410 -0
- package/src/cli/tui/work-queue.ts +161 -0
- package/src/cli/update-args.ts +55 -0
- package/src/cli/wiki.ts +406 -0
- package/src/compaction/index.ts +28 -0
- package/src/compaction/midturn.ts +210 -0
- package/src/compaction/policy.ts +154 -0
- package/src/compaction/summarize.ts +691 -0
- package/src/compaction/template.ts +90 -0
- package/src/compaction/types.ts +148 -0
- package/src/config/loader.ts +276 -0
- package/src/config/reload.ts +43 -0
- package/src/config/types.ts +2292 -0
- package/src/dream/deep-actions.ts +324 -0
- package/src/dream/deep-dispatcher.ts +237 -0
- package/src/dream/deep-llm.ts +388 -0
- package/src/dream/deep-prompts.ts +106 -0
- package/src/dream/deep-runner.ts +757 -0
- package/src/dream/deep-skip-cache.ts +199 -0
- package/src/dream/deep-worker.ts +229 -0
- package/src/dream/json-salvage.ts +34 -0
- package/src/dream/judge.ts +188 -0
- package/src/dream/loop-state.ts +286 -0
- package/src/dream/lucid-actions.ts +303 -0
- package/src/dream/lucid-batches.ts +94 -0
- package/src/dream/lucid-prompt.ts +82 -0
- package/src/dream/lucid-runner.ts +744 -0
- package/src/dream/lucid-storage.ts +277 -0
- package/src/dream/lucid-structure.ts +102 -0
- package/src/dream/lucid-types.ts +137 -0
- package/src/dream/lucid-worker.ts +224 -0
- package/src/dream/rem-dedup.ts +502 -0
- package/src/dream/rem-extract.ts +782 -0
- package/src/dream/rem-reset-run.ts +67 -0
- package/src/dream/rem-runner.ts +696 -0
- package/src/dream/rem-worker.ts +527 -0
- package/src/dream/review-window.ts +71 -0
- package/src/dream/scheduler-state.ts +129 -0
- package/src/dream/storage.ts +497 -0
- package/src/dream/types.ts +133 -0
- package/src/dream/wiki-context.ts +133 -0
- package/src/engine/a2a.ts +33 -0
- package/src/engine/availability.ts +63 -0
- package/src/engine/claude-cli.ts +969 -0
- package/src/engine/codex-app-server-client.ts +294 -0
- package/src/engine/codex-bin.ts +49 -0
- package/src/engine/codex-cli.ts +1014 -0
- package/src/engine/codex-dynamic-tools.ts +239 -0
- package/src/engine/codex-home.ts +63 -0
- package/src/engine/codex-thread-config.ts +74 -0
- package/src/engine/context-budget.ts +257 -0
- package/src/engine/engine-meta-labels.ts +211 -0
- package/src/engine/grok-cli.ts +941 -0
- package/src/engine/inline-think.ts +59 -0
- package/src/engine/model-availability.ts +105 -0
- package/src/engine/openai-compatible.ts +2464 -0
- package/src/engine/reasoning-retry.ts +83 -0
- package/src/engine/registry.ts +13 -0
- package/src/engine/replay.ts +195 -0
- package/src/engine/sampling.ts +90 -0
- package/src/engine/thinking-params.ts +264 -0
- package/src/engine/types.ts +269 -0
- package/src/engine/user-tag.ts +24 -0
- package/src/imagegen/aspect.ts +128 -0
- package/src/imagegen/generate.ts +642 -0
- package/src/imagegen/references.ts +75 -0
- package/src/imagegen/types.ts +154 -0
- package/src/lsp/client.ts +183 -0
- package/src/lsp/fake-server.helper.mjs +42 -0
- package/src/lsp/format.ts +29 -0
- package/src/lsp/index.ts +21 -0
- package/src/lsp/manager.ts +238 -0
- package/src/lsp/registry.ts +151 -0
- package/src/mcp/config.ts +117 -0
- package/src/mcp/hub/audit.ts +55 -0
- package/src/mcp/hub/bridge.ts +115 -0
- package/src/mcp/hub/catalog.ts +69 -0
- package/src/mcp/hub/credentials.ts +406 -0
- package/src/mcp/hub/env-expand.ts +14 -0
- package/src/mcp/hub/manager.ts +770 -0
- package/src/mcp/hub/normalize.ts +213 -0
- package/src/mcp/server.ts +368 -0
- package/src/mcp/tool-schema.ts +20 -0
- package/src/media/capabilities.ts +392 -0
- package/src/media/records.ts +175 -0
- package/src/media/store.ts +217 -0
- package/src/media/types.ts +69 -0
- package/src/memory/chunking.ts +168 -0
- package/src/memory/embeddings.ts +262 -0
- package/src/memory/index.ts +15 -0
- package/src/memory/inject.ts +197 -0
- package/src/memory/manager.ts +996 -0
- package/src/memory/registry.ts +176 -0
- package/src/memory/rescan.ts +101 -0
- package/src/memory/retrieval.ts +586 -0
- package/src/memory/shared-index.ts +372 -0
- package/src/memory/slug.ts +39 -0
- package/src/memory/storage.ts +385 -0
- package/src/memory/watcher.ts +134 -0
- package/src/multimodal/blocks.ts +101 -0
- package/src/multimodal/dimensions.ts +214 -0
- package/src/multimodal/load.ts +86 -0
- package/src/multimodal/mime.ts +135 -0
- package/src/multimodal/pdf-render.ts +80 -0
- package/src/multimodal/user-content.ts +266 -0
- package/src/persona/files.ts +144 -0
- package/src/persona/loader.ts +598 -0
- package/src/persona/skill-gating-store.ts +59 -0
- package/src/persona/tool-gating-store.ts +113 -0
- package/src/projects/focus.ts +186 -0
- package/src/projects/prompt-block.ts +106 -0
- package/src/projects/scheme.ts +107 -0
- package/src/projects/store.ts +144 -0
- package/src/projects/types.ts +73 -0
- package/src/sentinel/dispatcher.ts +97 -0
- package/src/sentinel/schedule.ts +271 -0
- package/src/sentinel/scheduler.ts +840 -0
- package/src/sentinel/store.ts +259 -0
- package/src/sentinel/types.ts +221 -0
- package/src/server/activity-stream.ts +160 -0
- package/src/server/ask-calls.ts +137 -0
- package/src/server/ask-wait-graph.ts +171 -0
- package/src/server/async-tasks.ts +199 -0
- package/src/server/builder-busy.ts +86 -0
- package/src/server/builder-prompt.ts +204 -0
- package/src/server/builder-questions.ts +117 -0
- package/src/server/builder-session.ts +249 -0
- package/src/server/chat-aborts.ts +83 -0
- package/src/server/claude-config-dir.ts +71 -0
- package/src/server/claude-credential-sync.ts +454 -0
- package/src/server/env-file.ts +100 -0
- package/src/server/env.ts +115 -0
- package/src/server/heal-session.ts +151 -0
- package/src/server/history-page.ts +46 -0
- package/src/server/index.ts +7244 -0
- package/src/server/lockfile.ts +89 -0
- package/src/server/logger.ts +67 -0
- package/src/server/logs.ts +187 -0
- package/src/server/loopback-fetch.ts +130 -0
- package/src/server/openai-client.ts +89 -0
- package/src/server/prompt-assembly.ts +334 -0
- package/src/server/restart-reconcile.ts +139 -0
- package/src/server/run-turn-fallback.ts +275 -0
- package/src/server/run-turn-types.ts +91 -0
- package/src/server/run-turn.ts +1474 -0
- package/src/server/sanitize-assistant-text.ts +112 -0
- package/src/server/session-export.ts +220 -0
- package/src/server/session-queue.ts +376 -0
- package/src/server/session-workdir.ts +49 -0
- package/src/server/sse-h2-safe.ts +61 -0
- package/src/server/sse-liveness.ts +162 -0
- package/src/server/sse-serializer.ts +161 -0
- package/src/server/start-turn.ts +249 -0
- package/src/server/steer-inbox.ts +107 -0
- package/src/server/tls-keeper.ts +153 -0
- package/src/server/tool-format.ts +167 -0
- package/src/server/turn-framing.ts +52 -0
- package/src/server/turn-origin-kind.ts +74 -0
- package/src/server/turn-origin.ts +40 -0
- package/src/server/work-ledger.ts +975 -0
- package/src/server/workspace.ts +114 -0
- package/src/setup/config-edit.ts +201 -0
- package/src/setup/presets.ts +71 -0
- package/src/setup/prompt.ts +163 -0
- package/src/setup/tailscale.ts +44 -0
- package/src/skills/bin-checks.ts +227 -0
- package/src/skills/bootstrap.ts +347 -0
- package/src/skills/env-scope.ts +175 -0
- package/src/skills/gating.ts +71 -0
- package/src/skills/lint.ts +202 -0
- package/src/skills/load.ts +368 -0
- package/src/skills/path-helpers.ts +102 -0
- package/src/skills/registry.ts +178 -0
- package/src/ssh/exec.ts +142 -0
- package/src/ssh/index.ts +12 -0
- package/src/ssh/known-hosts.ts +109 -0
- package/src/ssh/pool.ts +307 -0
- package/src/storage/sessions.ts +602 -0
- package/src/team/render.ts +149 -0
- package/src/team/resolve.ts +122 -0
- package/src/team/store.ts +124 -0
- package/src/team/types.ts +111 -0
- package/src/team/write.ts +95 -0
- package/src/testing/isolated-home.mts +46 -0
- package/src/tmux/attention-watcher.ts +272 -0
- package/src/tmux/attention.ts +336 -0
- package/src/tmux/list.ts +91 -0
- package/src/tmux/origin-store.ts +102 -0
- package/src/tmux/tui-markers.ts +267 -0
- package/src/tools/agents/ask-cancel.ts +94 -0
- package/src/tools/agents/ask-result.ts +235 -0
- package/src/tools/agents/ask.ts +704 -0
- package/src/tools/agents/builder-dispatch.ts +217 -0
- package/src/tools/agents/images.ts +104 -0
- package/src/tools/agents/index.ts +42 -0
- package/src/tools/agents/long-task-timeouts.ts +39 -0
- package/src/tools/agents/session-list.ts +136 -0
- package/src/tools/agents/session-model.ts +106 -0
- package/src/tools/agents/spawn.ts +845 -0
- package/src/tools/agents/status.ts +589 -0
- package/src/tools/browser/index.ts +6 -0
- package/src/tools/browser/ops.ts +145 -0
- package/src/tools/browser/tools.ts +184 -0
- package/src/tools/builder/short-descriptions.ts +80 -0
- package/src/tools/builder/tools.ts +222 -0
- package/src/tools/docs/index.ts +1 -0
- package/src/tools/docs/tools.ts +228 -0
- package/src/tools/dream/index.ts +11 -0
- package/src/tools/dream/tools.ts +1002 -0
- package/src/tools/exec/allowlist.ts +233 -0
- package/src/tools/exec/background-detach.helper.mts +27 -0
- package/src/tools/exec/blacklist.ts +336 -0
- package/src/tools/exec/concurrency.ts +150 -0
- package/src/tools/exec/fit-output.ts +82 -0
- package/src/tools/exec/index.ts +7 -0
- package/src/tools/exec/internal-env.ts +89 -0
- package/src/tools/exec/job-store.ts +403 -0
- package/src/tools/exec/local.ts +649 -0
- package/src/tools/exec/remote.ts +399 -0
- package/src/tools/exec/tools.ts +934 -0
- package/src/tools/file/analyze.ts +378 -0
- package/src/tools/file/index.ts +2 -0
- package/src/tools/file/local.ts +707 -0
- package/src/tools/file/lsp-hook.ts +72 -0
- package/src/tools/file/persona-guard.ts +61 -0
- package/src/tools/file/policy.ts +292 -0
- package/src/tools/file/read-format.ts +129 -0
- package/src/tools/file/remote.ts +680 -0
- package/src/tools/file/replace.ts +507 -0
- package/src/tools/file/search-window.ts +224 -0
- package/src/tools/file/tools.ts +658 -0
- package/src/tools/file/write-scope.ts +182 -0
- package/src/tools/gating.ts +106 -0
- package/src/tools/image/budget.ts +82 -0
- package/src/tools/image/index.ts +7 -0
- package/src/tools/image/tools.ts +601 -0
- package/src/tools/index.ts +99 -0
- package/src/tools/memory/index.ts +12 -0
- package/src/tools/memory/tools.ts +399 -0
- package/src/tools/projects/index.ts +1 -0
- package/src/tools/projects/tools.ts +643 -0
- package/src/tools/registry.ts +427 -0
- package/src/tools/resources/index.ts +8 -0
- package/src/tools/resources/tools.ts +176 -0
- package/src/tools/resources/visibility.ts +60 -0
- package/src/tools/sentinel/index.ts +1 -0
- package/src/tools/sentinel/tools.ts +592 -0
- package/src/tools/skill/index.ts +4 -0
- package/src/tools/skill/tools.ts +285 -0
- package/src/tools/time/index.ts +5 -0
- package/src/tools/time/tools.ts +123 -0
- package/src/tools/tmux/index.ts +1 -0
- package/src/tools/tmux/local.ts +277 -0
- package/src/tools/tmux/remote.ts +168 -0
- package/src/tools/tmux/tools.ts +1064 -0
- package/src/tools/tool-output.ts +97 -0
- package/src/tools/types.ts +227 -0
- package/src/tools/video/index.ts +1 -0
- package/src/tools/video/tools.ts +425 -0
- package/src/tools/web/fetch.ts +337 -0
- package/src/tools/web/index.ts +4 -0
- package/src/tools/web/tools.ts +186 -0
- package/src/tools/wiki/index.ts +1 -0
- package/src/tools/wiki/tools.ts +445 -0
- package/src/tts/cache-gc.ts +128 -0
- package/src/tts/prepare-for-tts.ts +114 -0
- package/src/tts/service.ts +332 -0
- package/src/types/events.ts +695 -0
- package/src/types/turn-origin.ts +53 -0
- package/src/version.ts +21 -0
- package/src/videogen/dialects.ts +222 -0
- package/src/videogen/generate.ts +484 -0
- package/src/videogen/jobs.ts +178 -0
- package/src/videogen/runner.ts +125 -0
- package/src/videogen/wake.ts +119 -0
- package/src/voice/realtime/call.ts +948 -0
- package/src/voice/realtime/consult.ts +293 -0
- package/src/voice/realtime/fake-provider.ts +134 -0
- package/src/voice/realtime/manager.ts +384 -0
- package/src/voice/realtime/openai-provider.ts +471 -0
- package/src/voice/realtime/persona.ts +227 -0
- package/src/voice/realtime/session-match.ts +116 -0
- package/src/voice/realtime/types.ts +182 -0
- package/src/wiki/conflict.ts +113 -0
- package/src/wiki/explorer.ts +578 -0
- package/src/wiki/index-builder.ts +172 -0
- package/src/wiki/language.ts +134 -0
- package/src/wiki/log-builder.ts +150 -0
- package/src/wiki/map.ts +258 -0
- package/src/wiki/migration/analyze.ts +304 -0
- package/src/wiki/migration/execute.ts +689 -0
- package/src/wiki/migration/refine.ts +402 -0
- package/src/wiki/migration/store.ts +100 -0
- package/src/wiki/move-page.ts +57 -0
- package/src/wiki/structure-file.ts +192 -0
- package/src/wiki/taxonomy.ts +140 -0
- package/src/wiki/templates.ts +163 -0
- package/src/wiki/types.ts +133 -0
- package/templates/skills/README.md +24 -0
- package/templates/skills/_templates/api-wrapper/SKILL.md +26 -0
- package/templates/skills/_templates/cli-wrapper/BOOTSTRAP.md +32 -0
- package/templates/skills/_templates/cli-wrapper/SKILL.md +24 -0
- package/templates/skills/_templates/default/SKILL.md +25 -0
- package/templates/skills/builder-handover/SKILL.md +96 -0
- package/templates/skills/builder-handover/assets/ORDER.md +12 -0
- package/templates/skills/skill-author/SKILL.md +110 -0
- package/tsconfig.json +22 -0
- package/web/dist/assets/index-BaVv6pB2.js +631 -0
- package/web/dist/assets/index-BaVv6pB2.js.map +1 -0
- package/web/dist/assets/index-V3FV3Z25.css +32 -0
- package/web/dist/favicon.svg +8 -0
- package/web/dist/index.html +20 -0
- package/web/package.json +36 -0
- package/web/tsconfig.json +25 -0
- package/web-mobile/dist/apple-touch-icon.png +0 -0
- package/web-mobile/dist/assets/index-BqKt7IMx.css +1 -0
- package/web-mobile/dist/assets/index-X_vRr6cd.js +88 -0
- package/web-mobile/dist/assets/index-X_vRr6cd.js.map +1 -0
- package/web-mobile/dist/favicon.svg +8 -0
- package/web-mobile/dist/icon-192.png +0 -0
- package/web-mobile/dist/icon-512.png +0 -0
- package/web-mobile/dist/index.html +27 -0
- package/web-mobile/dist/manifest.webmanifest +32 -0
- package/web-mobile/dist/service-worker.js +90 -0
- package/web-mobile/package.json +28 -0
- package/web-mobile/tsconfig.json +25 -0
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
// `skill` tool — activate a skill by name. Loads the skill's full
|
|
2
|
+
// SKILL.md body into the agent's context. The skill registry that the
|
|
3
|
+
// agent sees in its system prompt only carries name + description (+
|
|
4
|
+
// optional when_to_use); to actually FOLLOW a skill the agent calls
|
|
5
|
+
// this tool, then performs the work itself with the regular tools.
|
|
6
|
+
//
|
|
7
|
+
// Why a dedicated tool instead of the standard `file_read`: semantic
|
|
8
|
+
// clarity ("I am activating skill X" is a deliberate act, not a random
|
|
9
|
+
// file read), per-agent allow-list enforcement, and a future hook
|
|
10
|
+
// surface (telemetry, requires-recheck before activation, etc.). See
|
|
11
|
+
// `private/skills-design.md` for the full rationale.
|
|
12
|
+
|
|
13
|
+
import { readFile, stat } from 'node:fs/promises';
|
|
14
|
+
import { homedir } from 'node:os';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { logger } from '../../server/logger.ts';
|
|
18
|
+
import { loadPersona } from '../../persona/loader.ts';
|
|
19
|
+
import { loadAvailableSkills } from '../../skills/load.ts';
|
|
20
|
+
import { filterSkillsForAgent } from '../../skills/registry.ts';
|
|
21
|
+
import type { ToolDefinition } from '../types.ts';
|
|
22
|
+
|
|
23
|
+
const SOMORA_HOME = process.env.SOMORA_HOME ?? join(homedir(), '.somora');
|
|
24
|
+
const SKILLS_DIR = join(SOMORA_HOME, 'skills');
|
|
25
|
+
|
|
26
|
+
// Same regex as load.ts — must match the on-disk slug format. Cheap
|
|
27
|
+
// up-front rejection of obviously bad inputs (path traversal, casing).
|
|
28
|
+
const SKILL_NAME_RE = /^[a-z0-9]+(-[a-z0-9]+)*$/;
|
|
29
|
+
|
|
30
|
+
const SkillInput = z
|
|
31
|
+
.object({
|
|
32
|
+
name: z
|
|
33
|
+
.string()
|
|
34
|
+
.min(1)
|
|
35
|
+
.max(64)
|
|
36
|
+
.regex(SKILL_NAME_RE, 'skill names are lowercase [a-z0-9-], no leading/trailing/consecutive hyphens')
|
|
37
|
+
.describe(
|
|
38
|
+
'Slug of the skill to activate (matches the directory name under ~/.somora/skills/, ' +
|
|
39
|
+
'and the `name` listed in the system-prompt <available_skills> registry). Use exactly ' +
|
|
40
|
+
'the name as shown in the registry — no path, no extension.',
|
|
41
|
+
),
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
44
|
+
|
|
45
|
+
interface SkillOutput {
|
|
46
|
+
name: string;
|
|
47
|
+
description: string;
|
|
48
|
+
when_to_use?: string;
|
|
49
|
+
/** Full SKILL.md body (frontmatter stripped). The agent should treat
|
|
50
|
+
* this as instructions to follow — typically a multi-step procedure
|
|
51
|
+
* using the regular tools. */
|
|
52
|
+
body: string;
|
|
53
|
+
/** True if the skill's `requires.bins` and `requires.config` are all
|
|
54
|
+
* satisfied on this host. When false, body is still returned but
|
|
55
|
+
* the agent should consider whether the procedure can actually run. */
|
|
56
|
+
available: boolean;
|
|
57
|
+
/** Reason when `available` is false. */
|
|
58
|
+
unavailable_reason?: string;
|
|
59
|
+
/** Tags from `metadata.somora.tags`, when present. */
|
|
60
|
+
tags?: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const skill: ToolDefinition<z.infer<typeof SkillInput>, SkillOutput> = {
|
|
64
|
+
name: 'skill',
|
|
65
|
+
toolset: 'skills',
|
|
66
|
+
description:
|
|
67
|
+
'Activate a skill — load its full step-by-step instructions into your context. ' +
|
|
68
|
+
'The system prompt lists every available skill in <available_skills> with name, ' +
|
|
69
|
+
'description, and (sometimes) when_to_use. When a task matches a skill, call this ' +
|
|
70
|
+
'tool with the skill\'s `name` to pull the full SKILL.md body, then follow the ' +
|
|
71
|
+
'instructions step by step using your normal tools (file_*, exec, tmux, web, …). ' +
|
|
72
|
+
'\n\n' +
|
|
73
|
+
'A skill is pure instruction text — it does NOT execute anything by itself. The ' +
|
|
74
|
+
'work is yours to do based on what the body tells you. Skills may reference scripts ' +
|
|
75
|
+
'or assets shipped alongside (paths relative to the skill folder); read them with ' +
|
|
76
|
+
'file_read or run them with exec as the body directs. ' +
|
|
77
|
+
'\n\n' +
|
|
78
|
+
'Per-agent filtering: each agent sees only the skills allowed by its agent.yaml ' +
|
|
79
|
+
'configuration (empty/unset = all skills). Calling this tool with a name that is ' +
|
|
80
|
+
'not in your <available_skills> registry returns an error. ' +
|
|
81
|
+
'\n\n' +
|
|
82
|
+
'Creating new skills: skills live on disk at `~/.somora/skills/<slug>/SKILL.md` ' +
|
|
83
|
+
'(slug is lowercase, [a-z0-9-], must equal the parent dir name and the `name` field). ' +
|
|
84
|
+
'Use file_write to create one — `slug` and the dir are auto-derived from the path. ' +
|
|
85
|
+
'Frontmatter follows the agentskills.io spec: required `name` + `description` (≤1024 ' +
|
|
86
|
+
'chars, what + when in one sentence), plus optional somora extras under `metadata. ' +
|
|
87
|
+
'somora.{when_to_use, requires.{bins,config}, tags}`. After writing the file, the ' +
|
|
88
|
+
'skill appears in <available_skills> on the very next turn — no server restart.',
|
|
89
|
+
inputSchema: SkillInput,
|
|
90
|
+
jsonSchema: {
|
|
91
|
+
type: 'object',
|
|
92
|
+
properties: {
|
|
93
|
+
name: {
|
|
94
|
+
type: 'string',
|
|
95
|
+
description:
|
|
96
|
+
'Slug of the skill to activate, exactly as listed in <available_skills>. ' +
|
|
97
|
+
'Lowercase letters, digits, dashes; no path, no extension.',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
required: ['name'],
|
|
101
|
+
additionalProperties: false,
|
|
102
|
+
},
|
|
103
|
+
async handler(input, ctx): Promise<SkillOutput> {
|
|
104
|
+
// Re-load skills + persona on every call. Same convention as
|
|
105
|
+
// persona/loader.ts: filesystem reads are cheap, edits take effect
|
|
106
|
+
// on the next turn without a server restart.
|
|
107
|
+
const persona = await loadPersona(ctx.agent);
|
|
108
|
+
if (!persona) {
|
|
109
|
+
throw new Error(`skill: agent '${ctx.agent}' not found`);
|
|
110
|
+
}
|
|
111
|
+
const all = await loadAvailableSkills(ctx.config);
|
|
112
|
+
const allowed = filterSkillsForAgent(all, persona.skillGating);
|
|
113
|
+
const skill = allowed.find((s) => s.name === input.name);
|
|
114
|
+
if (!skill) {
|
|
115
|
+
const knownNames = allowed.map((s) => s.name);
|
|
116
|
+
// Help the agent self-correct: if the requested name exists but
|
|
117
|
+
// is filtered out, say so clearly.
|
|
118
|
+
const inAllButFiltered = all.some((s) => s.name === input.name);
|
|
119
|
+
if (inAllButFiltered) {
|
|
120
|
+
throw new Error(
|
|
121
|
+
`skill '${input.name}' exists but is not allowed for agent '${ctx.agent}'. ` +
|
|
122
|
+
`Allowed skills: ${knownNames.join(', ') || '(none)'}.`,
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
throw new Error(
|
|
126
|
+
`skill '${input.name}' not found. Available: ${knownNames.join(', ') || '(none)'}.`,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Re-stat the file so we honor the configured per-file size cap
|
|
131
|
+
// (`config.skills.maxSkillFileBytes`). The body in `skill.body` was
|
|
132
|
+
// already read by loadAvailableSkills, but we want a fresh enforcement
|
|
133
|
+
// point in case the file grew between scan and activation.
|
|
134
|
+
const skillMdPath = join(SKILLS_DIR, skill.name, 'SKILL.md');
|
|
135
|
+
try {
|
|
136
|
+
const s = await stat(skillMdPath);
|
|
137
|
+
if (s.size > ctx.config.skills.maxSkillFileBytes) {
|
|
138
|
+
throw new Error(
|
|
139
|
+
`skill '${skill.name}' SKILL.md is ${s.size} bytes, exceeds limit of ` +
|
|
140
|
+
`${ctx.config.skills.maxSkillFileBytes} (config.skills.maxSkillFileBytes).`,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
} catch (err) {
|
|
144
|
+
// Re-stat failure is unusual (we just listed it). Fall through to
|
|
145
|
+
// returning the previously-read body — the cap-check is best-
|
|
146
|
+
// effort, not a security gate.
|
|
147
|
+
logger.warn({
|
|
148
|
+
msg: 'skill.restat_failed',
|
|
149
|
+
name: skill.name,
|
|
150
|
+
err: (err as Error).message,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Re-read the body fresh so a SKILL.md edited mid-session takes
|
|
155
|
+
// effect immediately. Reuse the parser path? Cheaper to just read
|
|
156
|
+
// the file — frontmatter at the top is small, the body is what we
|
|
157
|
+
// want. We strip frontmatter manually to avoid re-instantiating
|
|
158
|
+
// gray-matter for a single read.
|
|
159
|
+
let raw: string;
|
|
160
|
+
try {
|
|
161
|
+
raw = await readFile(skillMdPath, 'utf8');
|
|
162
|
+
} catch (err) {
|
|
163
|
+
logger.warn({
|
|
164
|
+
msg: 'skill.body_read_failed',
|
|
165
|
+
name: skill.name,
|
|
166
|
+
err: (err as Error).message,
|
|
167
|
+
});
|
|
168
|
+
// Fall back to the body captured at scan time.
|
|
169
|
+
raw = '';
|
|
170
|
+
}
|
|
171
|
+
let body = skill.body;
|
|
172
|
+
if (raw) {
|
|
173
|
+
// Strip a leading `---\n...\n---\n` frontmatter block if present.
|
|
174
|
+
// We don't care about the YAML content here — that was already
|
|
175
|
+
// validated at scan time.
|
|
176
|
+
const fmMatch = raw.match(/^---\n[\s\S]*?\n---\n?/);
|
|
177
|
+
body = (fmMatch ? raw.slice(fmMatch[0].length) : raw).trim();
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
logger.info({
|
|
181
|
+
msg: 'skill.activated',
|
|
182
|
+
agent: ctx.agent,
|
|
183
|
+
session: ctx.session,
|
|
184
|
+
name: skill.name,
|
|
185
|
+
available: skill.available,
|
|
186
|
+
body_len: body.length,
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
// When the skill is unavailable on this host (missing bin /
|
|
190
|
+
// missing config), prepend a clearly-marked warning to the body so
|
|
191
|
+
// the model doesn't blindly run commands the environment can't
|
|
192
|
+
// execute. Hans 2026-05-09: body alone was ambiguous when
|
|
193
|
+
// available:false.
|
|
194
|
+
const finalBody = skill.available
|
|
195
|
+
? body
|
|
196
|
+
: `> ⚠️ **This skill is currently unavailable on this host: ${skill.unavailableReason ?? 'unknown reason'}.**\n` +
|
|
197
|
+
`> Either install the missing dependency, set the missing config, or run the skill's commands ` +
|
|
198
|
+
`via \`exec({target: <other-resource>})\` against a host that has them.\n\n` +
|
|
199
|
+
body;
|
|
200
|
+
|
|
201
|
+
return {
|
|
202
|
+
name: skill.name,
|
|
203
|
+
description: skill.description,
|
|
204
|
+
...(skill.whenToUse ? { when_to_use: skill.whenToUse } : {}),
|
|
205
|
+
body: finalBody,
|
|
206
|
+
available: skill.available,
|
|
207
|
+
...(skill.unavailableReason ? { unavailable_reason: skill.unavailableReason } : {}),
|
|
208
|
+
...(skill.requiresEnvVars.length > 0 ? { requires_env_vars: skill.requiresEnvVars } : {}),
|
|
209
|
+
...(skill.tags.length > 0 ? { tags: skill.tags } : {}),
|
|
210
|
+
};
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
// `skill_list` — enumerate the skills available to the calling agent.
|
|
215
|
+
//
|
|
216
|
+
// The system-prompt <available_skills> registry is the primary surface,
|
|
217
|
+
// but it is not always reachable: codex-cli freezes the system prompt at
|
|
218
|
+
// session start, so long-running codex sessions lose the registry to
|
|
219
|
+
// codex-side context compaction and never learn about skills added later
|
|
220
|
+
// (hans 2026-07-20 report — the somora-feedback skill existed for two
|
|
221
|
+
// months but was invisible to his May session). This tool is the
|
|
222
|
+
// on-demand answer: same data as the registry, fetched fresh from disk,
|
|
223
|
+
// filtered by the agent's allow-list.
|
|
224
|
+
const SkillListInput = z.object({}).strict();
|
|
225
|
+
|
|
226
|
+
interface SkillListEntry {
|
|
227
|
+
name: string;
|
|
228
|
+
description: string;
|
|
229
|
+
when_to_use?: string;
|
|
230
|
+
available: boolean;
|
|
231
|
+
unavailable_reason?: string;
|
|
232
|
+
tags?: string[];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
interface SkillListOutput {
|
|
236
|
+
skills: SkillListEntry[];
|
|
237
|
+
count: number;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export const skillList: ToolDefinition<z.infer<typeof SkillListInput>, SkillListOutput> = {
|
|
241
|
+
name: 'skill_list',
|
|
242
|
+
toolset: 'skills',
|
|
243
|
+
description:
|
|
244
|
+
'List every skill available to you, with name, description, when_to_use and availability. ' +
|
|
245
|
+
'Same catalogue as the <available_skills> block in your system prompt, but fetched fresh ' +
|
|
246
|
+
'from disk — use this when you suspect your prompt copy is stale or missing (long-running ' +
|
|
247
|
+
'sessions, engine-side context compaction) or before concluding that no suitable skill ' +
|
|
248
|
+
'exists. To activate a skill from the list, call the `skill` tool with its `name`. ' +
|
|
249
|
+
'Read-only; takes no arguments.',
|
|
250
|
+
inputSchema: SkillListInput,
|
|
251
|
+
jsonSchema: {
|
|
252
|
+
type: 'object',
|
|
253
|
+
properties: {},
|
|
254
|
+
additionalProperties: false,
|
|
255
|
+
},
|
|
256
|
+
async handler(_input, ctx): Promise<SkillListOutput> {
|
|
257
|
+
// Fresh read on every call, same convention as `skill`: cheap
|
|
258
|
+
// filesystem scan, edits take effect without a server restart.
|
|
259
|
+
const persona = await loadPersona(ctx.agent);
|
|
260
|
+
if (!persona) {
|
|
261
|
+
throw new Error(`skill_list: agent '${ctx.agent}' not found`);
|
|
262
|
+
}
|
|
263
|
+
const all = await loadAvailableSkills(ctx.config);
|
|
264
|
+
const allowed = filterSkillsForAgent(all, persona.skillGating);
|
|
265
|
+
const skills = allowed.map((s) => ({
|
|
266
|
+
name: s.name,
|
|
267
|
+
description: s.description,
|
|
268
|
+
...(s.whenToUse ? { when_to_use: s.whenToUse } : {}),
|
|
269
|
+
available: s.available,
|
|
270
|
+
...(s.unavailableReason ? { unavailable_reason: s.unavailableReason } : {}),
|
|
271
|
+
...(s.tags.length > 0 ? { tags: s.tags } : {}),
|
|
272
|
+
}));
|
|
273
|
+
logger.info({
|
|
274
|
+
msg: 'skill.list',
|
|
275
|
+
agent: ctx.agent,
|
|
276
|
+
session: ctx.session,
|
|
277
|
+
count: skills.length,
|
|
278
|
+
});
|
|
279
|
+
return { skills, count: skills.length };
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export function skillTools(): ToolDefinition[] {
|
|
284
|
+
return [skill, skillList] as ToolDefinition[];
|
|
285
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// Time tool — current date, time, and timezone-aware formatting. Cheap
|
|
2
|
+
// and always available; serves the "what's today's date" use case that
|
|
3
|
+
// the model would otherwise hallucinate from its training cutoff.
|
|
4
|
+
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import type { ToolDefinition } from '../types.ts';
|
|
7
|
+
|
|
8
|
+
const NowInput = z
|
|
9
|
+
.object({
|
|
10
|
+
timezone: z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1)
|
|
13
|
+
.optional()
|
|
14
|
+
.describe(
|
|
15
|
+
'IANA timezone name (e.g., "Europe/Vienna", "UTC", "America/Los_Angeles"). ' +
|
|
16
|
+
'Defaults to the server\'s local timezone if omitted.',
|
|
17
|
+
),
|
|
18
|
+
})
|
|
19
|
+
.strict();
|
|
20
|
+
|
|
21
|
+
interface NowOutput {
|
|
22
|
+
iso: string;
|
|
23
|
+
date: string;
|
|
24
|
+
time: string;
|
|
25
|
+
timezone: string;
|
|
26
|
+
day_of_week: string;
|
|
27
|
+
week_number: number;
|
|
28
|
+
unix_ms: number;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function isoWeekNumber(d: Date): number {
|
|
32
|
+
// Standard ISO-8601 week number: week starts Monday, week 1 contains
|
|
33
|
+
// the year's first Thursday. We copy the date so we don't mutate the
|
|
34
|
+
// caller's value.
|
|
35
|
+
const target = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
|
|
36
|
+
const dayNum = (target.getUTCDay() + 6) % 7;
|
|
37
|
+
target.setUTCDate(target.getUTCDate() - dayNum + 3);
|
|
38
|
+
const firstThursday = new Date(Date.UTC(target.getUTCFullYear(), 0, 4));
|
|
39
|
+
const firstDayNum = (firstThursday.getUTCDay() + 6) % 7;
|
|
40
|
+
firstThursday.setUTCDate(firstThursday.getUTCDate() - firstDayNum + 3);
|
|
41
|
+
return 1 + Math.round((target.getTime() - firstThursday.getTime()) / (7 * 24 * 60 * 60 * 1000));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const timeNow: ToolDefinition<z.infer<typeof NowInput>, NowOutput> = {
|
|
45
|
+
name: 'time_now',
|
|
46
|
+
toolset: 'time',
|
|
47
|
+
description:
|
|
48
|
+
'Returns the current date AND time, with day-of-week and ISO week number. ' +
|
|
49
|
+
'NEVER answer date/time questions from your own memory — your training cutoff ' +
|
|
50
|
+
'means you do not know what "today" is. Use this whenever you need today\'s date, ' +
|
|
51
|
+
'the current time, or to compute relative dates (yesterday, last week, in 3 days). ' +
|
|
52
|
+
'Pass an optional IANA `timezone` like "Europe/Vienna" or "America/Los_Angeles"; ' +
|
|
53
|
+
'omit it to use the server\'s local timezone. Returns ISO-8601 plus broken-out ' +
|
|
54
|
+
'date/time strings, day_of_week, week_number, and unix_ms for arithmetic.',
|
|
55
|
+
inputSchema: NowInput,
|
|
56
|
+
jsonSchema: {
|
|
57
|
+
type: 'object',
|
|
58
|
+
properties: {
|
|
59
|
+
timezone: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description:
|
|
62
|
+
'IANA timezone name (e.g., "Europe/Vienna", "UTC", "America/Los_Angeles"). ' +
|
|
63
|
+
'Defaults to the server\'s local timezone if omitted.',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
additionalProperties: false,
|
|
67
|
+
},
|
|
68
|
+
async handler(input): Promise<NowOutput> {
|
|
69
|
+
const now = new Date();
|
|
70
|
+
const tz = input.timezone ?? Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
71
|
+
|
|
72
|
+
// Validate the timezone by trying to use it. Intl throws RangeError
|
|
73
|
+
// on unknown TZ names — translate to a clear tool error.
|
|
74
|
+
let dateParts: Intl.DateTimeFormatPart[];
|
|
75
|
+
try {
|
|
76
|
+
dateParts = new Intl.DateTimeFormat('en-CA', {
|
|
77
|
+
timeZone: tz,
|
|
78
|
+
year: 'numeric',
|
|
79
|
+
month: '2-digit',
|
|
80
|
+
day: '2-digit',
|
|
81
|
+
hour: '2-digit',
|
|
82
|
+
minute: '2-digit',
|
|
83
|
+
second: '2-digit',
|
|
84
|
+
hour12: false,
|
|
85
|
+
weekday: 'long',
|
|
86
|
+
}).formatToParts(now);
|
|
87
|
+
} catch (err) {
|
|
88
|
+
if (err instanceof RangeError) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
`unknown timezone: '${tz}'. Use an IANA name like 'Europe/Vienna' or 'UTC'.`,
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const part = (type: Intl.DateTimeFormatPartTypes): string =>
|
|
97
|
+
dateParts.find((p) => p.type === type)?.value ?? '';
|
|
98
|
+
|
|
99
|
+
const year = part('year');
|
|
100
|
+
const month = part('month');
|
|
101
|
+
const day = part('day');
|
|
102
|
+
let hour = part('hour');
|
|
103
|
+
// Some locales render midnight as "24" with hour12:false — normalize.
|
|
104
|
+
if (hour === '24') hour = '00';
|
|
105
|
+
const minute = part('minute');
|
|
106
|
+
const second = part('second');
|
|
107
|
+
const dayOfWeek = part('weekday');
|
|
108
|
+
|
|
109
|
+
return {
|
|
110
|
+
iso: now.toISOString(),
|
|
111
|
+
date: `${year}-${month}-${day}`,
|
|
112
|
+
time: `${hour}:${minute}:${second}`,
|
|
113
|
+
timezone: tz,
|
|
114
|
+
day_of_week: dayOfWeek,
|
|
115
|
+
week_number: isoWeekNumber(now),
|
|
116
|
+
unix_ms: now.getTime(),
|
|
117
|
+
};
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export function timeTools(): ToolDefinition[] {
|
|
122
|
+
return [timeNow] as ToolDefinition[];
|
|
123
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { tmux, tmuxTools } from './tools.ts';
|