@comma-agents/core 2.0.0-rc.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/LICENSE +21 -0
- package/README.md +18 -0
- package/dist/abortable/abortable.d.ts +5 -0
- package/dist/abortable/abortable.types.d.ts +10 -0
- package/dist/abortable/index.d.ts +2 -0
- package/dist/agents/agent/agent.constants.d.ts +5 -0
- package/dist/agents/agent/agent.d.ts +24 -0
- package/dist/agents/agent/agent.types.d.ts +408 -0
- package/dist/agents/agent/agent.utils.d.ts +107 -0
- package/dist/agents/built-in/user/user-agent.d.ts +32 -0
- package/dist/agents/built-in/user/user-agent.types.d.ts +53 -0
- package/dist/agents/built-in/user/user-agent.utils.d.ts +2 -0
- package/dist/agents/hook-into-agent/hook-into-agent.d.ts +29 -0
- package/dist/agents/hooks/hooks.types.d.ts +64 -0
- package/dist/agents/hooks/hooks.utils.d.ts +9 -0
- package/dist/agents/hooks/index.d.ts +2 -0
- package/dist/agents/loader/index.d.ts +4 -0
- package/dist/agents/loader/loader.d.ts +49 -0
- package/dist/agents/loader/loader.schema.d.ts +270 -0
- package/dist/agents/loader/loader.types.d.ts +15 -0
- package/dist/conversation-context/conversation-context.d.ts +78 -0
- package/dist/conversation-context/conversation-context.types.d.ts +111 -0
- package/dist/conversation-context/conversation-context.utils.d.ts +6 -0
- package/dist/conversation-context/index.d.ts +3 -0
- package/dist/conversation-context/retention/compaction/compaction.constants.d.ts +3 -0
- package/dist/conversation-context/retention/compaction/compaction.d.ts +21 -0
- package/dist/conversation-context/retention/compaction/compaction.types.d.ts +26 -0
- package/dist/conversation-context/retention/compaction/index.d.ts +2 -0
- package/dist/conversation-context/retention/index.d.ts +4 -0
- package/dist/conversation-context/retention/retention.d.ts +9 -0
- package/dist/conversation-context/retention/retention.types.d.ts +90 -0
- package/dist/conversation-context/retention/retention.utils.d.ts +3 -0
- package/dist/conversation-context/retention/rolling-window/index.d.ts +2 -0
- package/dist/conversation-context/retention/rolling-window/rolling-window.d.ts +13 -0
- package/dist/conversation-context/retention/rolling-window/rolling-window.types.d.ts +5 -0
- package/dist/credentials/backends/json-file.d.ts +21 -0
- package/dist/credentials/credentials.constants.d.ts +9 -0
- package/dist/credentials/credentials.d.ts +18 -0
- package/dist/credentials/credentials.schema.d.ts +102 -0
- package/dist/credentials/credentials.types.d.ts +118 -0
- package/dist/credentials/credentials.utils.d.ts +30 -0
- package/dist/credentials/index.d.ts +6 -0
- package/dist/defaults/defaults.d.ts +108 -0
- package/dist/defaults/defaults.types.d.ts +51 -0
- package/dist/defaults/index.d.ts +2 -0
- package/dist/errors/index.d.ts +70 -0
- package/dist/flows/built-in/broadcast/broadcast-flow.constants.d.ts +2 -0
- package/dist/flows/built-in/broadcast/broadcast-flow.d.ts +30 -0
- package/dist/flows/built-in/cycle/cycle-flow.d.ts +53 -0
- package/dist/flows/built-in/sequential/sequential-flow.d.ts +25 -0
- package/dist/flows/flow/flow.d.ts +79 -0
- package/dist/flows/flow/flow.types.d.ts +179 -0
- package/dist/flows/flow/flow.utils.d.ts +18 -0
- package/dist/flows/hook-into-flow/hook-into-flow.d.ts +30 -0
- package/dist/flows/index.d.ts +6 -0
- package/dist/flows/loader/index.d.ts +4 -0
- package/dist/flows/loader/loader.d.ts +55 -0
- package/dist/flows/loader/loader.schema.d.ts +195 -0
- package/dist/flows/loader/loader.types.d.ts +27 -0
- package/dist/guard/guard.d.ts +17 -0
- package/dist/guard/guard.types.d.ts +112 -0
- package/dist/guard/index.d.ts +3 -0
- package/dist/guard/policies.d.ts +28 -0
- package/dist/hooks/built-in/token-tracking/index.d.ts +2 -0
- package/dist/hooks/built-in/token-tracking/token-tracking.constants.d.ts +14 -0
- package/dist/hooks/built-in/token-tracking/token-tracking.d.ts +87 -0
- package/dist/hooks/built-in/token-tracking/token-tracking.types.d.ts +136 -0
- package/dist/hooks/hooks.d.ts +10 -0
- package/dist/hooks/hooks.types.d.ts +11 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.js +8961 -0
- package/dist/language/index.d.ts +1 -0
- package/dist/language/language.types.d.ts +60 -0
- package/dist/model/index.d.ts +5 -0
- package/dist/model/model.d.ts +63 -0
- package/dist/model/model.types.d.ts +85 -0
- package/dist/model/model.utils.d.ts +151 -0
- package/dist/model/providers/catalog/catalog.d.ts +57 -0
- package/dist/model/providers/catalog/catalog.types.d.ts +50 -0
- package/dist/model/providers/catalog/catalog.utils.d.ts +15 -0
- package/dist/model/providers/catalog/index.d.ts +3 -0
- package/dist/model/providers/index.d.ts +7 -0
- package/dist/model/providers/listers/copilot.d.ts +10 -0
- package/dist/model/providers/listers/index.d.ts +2 -0
- package/dist/model/providers/listers/ollama.d.ts +9 -0
- package/dist/model/providers/providers.d.ts +69 -0
- package/dist/model/providers/providers.types.d.ts +157 -0
- package/dist/model/providers/providers.utils.d.ts +16 -0
- package/dist/prompts/index.d.ts +4 -0
- package/dist/prompts/message-builder.d.ts +89 -0
- package/dist/prompts/prompts.types.d.ts +86 -0
- package/dist/prompts/template/prompt-template.d.ts +22 -0
- package/dist/sandbox/in-sandbox.d.ts +31 -0
- package/dist/sandbox/index.d.ts +4 -0
- package/dist/sandbox/sandbox.constants.d.ts +31 -0
- package/dist/sandbox/sandbox.d.ts +11 -0
- package/dist/sandbox/sandbox.types.d.ts +105 -0
- package/dist/skills/index.d.ts +4 -0
- package/dist/skills/skills.constants.d.ts +10 -0
- package/dist/skills/skills.loader.d.ts +46 -0
- package/dist/skills/skills.registry.d.ts +18 -0
- package/dist/skills/skills.types.d.ts +66 -0
- package/dist/skills/skills.utils.d.ts +37 -0
- package/dist/strategy/discover/discover.d.ts +16 -0
- package/dist/strategy/discover/discover.types.d.ts +70 -0
- package/dist/strategy/discover/discover.utils.d.ts +95 -0
- package/dist/strategy/discover/index.d.ts +3 -0
- package/dist/strategy/exporter/exporter.d.ts +27 -0
- package/dist/strategy/exporter/exporter.types.d.ts +6 -0
- package/dist/strategy/index.d.ts +10 -0
- package/dist/strategy/loader/loader.d.ts +39 -0
- package/dist/strategy/loader/loader.types.d.ts +106 -0
- package/dist/strategy/loader/loader.utils.d.ts +20 -0
- package/dist/strategy/loader/project-loader.d.ts +9 -0
- package/dist/strategy/schema.d.ts +1032 -0
- package/dist/timeline/index.d.ts +4 -0
- package/dist/timeline/projections/conversation-context.d.ts +19 -0
- package/dist/timeline/projections/file-state.d.ts +8 -0
- package/dist/timeline/projections/index.d.ts +3 -0
- package/dist/timeline/timeline.d.ts +11 -0
- package/dist/timeline/timeline.types.d.ts +97 -0
- package/dist/tools/build-tool-system-prompt.d.ts +41 -0
- package/dist/tools/built-in/ask-question/ask-question.d.ts +21 -0
- package/dist/tools/built-in/ask-question/index.d.ts +2 -0
- package/dist/tools/built-in/create-file/create-file.d.ts +18 -0
- package/dist/tools/built-in/create-file/create-file.types.d.ts +11 -0
- package/dist/tools/built-in/create-file/index.d.ts +2 -0
- package/dist/tools/built-in/delete-file/delete-file.constants.d.ts +14 -0
- package/dist/tools/built-in/delete-file/delete-file.d.ts +5 -0
- package/dist/tools/built-in/delete-file/delete-file.types.d.ts +26 -0
- package/dist/tools/built-in/delete-file/index.d.ts +2 -0
- package/dist/tools/built-in/describe-tool.d.ts +61 -0
- package/dist/tools/built-in/edit-file/edit-file.d.ts +46 -0
- package/dist/tools/built-in/edit-file/edit-file.replacers.d.ts +81 -0
- package/dist/tools/built-in/edit-file/edit-file.types.d.ts +59 -0
- package/dist/tools/built-in/edit-file/edit-file.utils.d.ts +70 -0
- package/dist/tools/built-in/edit-file/index.d.ts +2 -0
- package/dist/tools/built-in/glob/glob.constants.d.ts +3 -0
- package/dist/tools/built-in/glob/glob.d.ts +25 -0
- package/dist/tools/built-in/glob/glob.types.d.ts +31 -0
- package/dist/tools/built-in/glob/glob.utils.d.ts +4 -0
- package/dist/tools/built-in/glob/index.d.ts +2 -0
- package/dist/tools/built-in/launch-strategy/index.d.ts +2 -0
- package/dist/tools/built-in/launch-strategy/launch-strategy.d.ts +26 -0
- package/dist/tools/built-in/launch-strategy/launch-strategy.types.d.ts +14 -0
- package/dist/tools/built-in/list-directory/index.d.ts +2 -0
- package/dist/tools/built-in/list-directory/list-directory.constants.d.ts +3 -0
- package/dist/tools/built-in/list-directory/list-directory.d.ts +20 -0
- package/dist/tools/built-in/list-directory/list-directory.types.d.ts +41 -0
- package/dist/tools/built-in/list-directory/list-directory.utils.d.ts +4 -0
- package/dist/tools/built-in/list-skills/index.d.ts +2 -0
- package/dist/tools/built-in/list-skills/list-skills.d.ts +5 -0
- package/dist/tools/built-in/list-skills/list-skills.types.d.ts +10 -0
- package/dist/tools/built-in/list-strategy/index.d.ts +2 -0
- package/dist/tools/built-in/list-strategy/list-strategy.d.ts +14 -0
- package/dist/tools/built-in/list-strategy/list-strategy.types.d.ts +33 -0
- package/dist/tools/built-in/load-skill/index.d.ts +2 -0
- package/dist/tools/built-in/load-skill/load-skill.d.ts +24 -0
- package/dist/tools/built-in/load-skill/load-skill.types.d.ts +15 -0
- package/dist/tools/built-in/lsp-request/index.d.ts +2 -0
- package/dist/tools/built-in/lsp-request/lsp-request.d.ts +4 -0
- package/dist/tools/built-in/lsp-request/lsp-request.schema.d.ts +23 -0
- package/dist/tools/built-in/lsp-request/lsp-request.types.d.ts +4 -0
- package/dist/tools/built-in/move-file/index.d.ts +2 -0
- package/dist/tools/built-in/move-file/move-file.d.ts +21 -0
- package/dist/tools/built-in/move-file/move-file.types.d.ts +12 -0
- package/dist/tools/built-in/read-file/index.d.ts +2 -0
- package/dist/tools/built-in/read-file/read-file.constants.d.ts +1 -0
- package/dist/tools/built-in/read-file/read-file.d.ts +32 -0
- package/dist/tools/built-in/read-file/read-file.types.d.ts +34 -0
- package/dist/tools/built-in/read-file/read-file.utils.d.ts +14 -0
- package/dist/tools/built-in/restore-file/index.d.ts +2 -0
- package/dist/tools/built-in/restore-file/restore-file.d.ts +16 -0
- package/dist/tools/built-in/restore-file/restore-file.types.d.ts +11 -0
- package/dist/tools/built-in/run-command/index.d.ts +2 -0
- package/dist/tools/built-in/run-command/run-command.constants.d.ts +23 -0
- package/dist/tools/built-in/run-command/run-command.d.ts +21 -0
- package/dist/tools/built-in/run-command/run-command.types.d.ts +81 -0
- package/dist/tools/built-in/run-command/run-command.utils.d.ts +37 -0
- package/dist/tools/built-in/search-files/index.d.ts +2 -0
- package/dist/tools/built-in/search-files/search-files.constants.d.ts +5 -0
- package/dist/tools/built-in/search-files/search-files.d.ts +30 -0
- package/dist/tools/built-in/search-files/search-files.types.d.ts +19 -0
- package/dist/tools/built-in/search-files/search-files.utils.d.ts +11 -0
- package/dist/tools/built-in/todo/todo.d.ts +62 -0
- package/dist/tools/built-in/todo/todo.types.d.ts +7 -0
- package/dist/tools/built-in/webfetch/webfetch.constants.d.ts +3 -0
- package/dist/tools/built-in/webfetch/webfetch.d.ts +33 -0
- package/dist/tools/built-in/webfetch/webfetch.types.d.ts +8 -0
- package/dist/tools/built-in/webfetch/webfetch.utils.d.ts +19 -0
- package/dist/tools/built-in/write-file/index.d.ts +2 -0
- package/dist/tools/built-in/write-file/write-file.d.ts +18 -0
- package/dist/tools/built-in/write-file/write-file.types.d.ts +11 -0
- package/dist/tools/define/define-tool.d.ts +15 -0
- package/dist/tools/io/atomic-write.d.ts +37 -0
- package/dist/tools/io/audit-sink.d.ts +29 -0
- package/dist/tools/io/audit.types.d.ts +115 -0
- package/dist/tools/io/audit.utils.d.ts +48 -0
- package/dist/tools/io/binary.d.ts +16 -0
- package/dist/tools/io/bom.d.ts +15 -0
- package/dist/tools/io/diff.d.ts +27 -0
- package/dist/tools/io/hash.d.ts +25 -0
- package/dist/tools/io/index.d.ts +19 -0
- package/dist/tools/io/newline.d.ts +34 -0
- package/dist/tools/io/sandbox-error.d.ts +13 -0
- package/dist/tools/io/session-file-state.d.ts +68 -0
- package/dist/tools/io/stale-file.d.ts +9 -0
- package/dist/tools/io/trash.d.ts +57 -0
- package/dist/tools/launch-strategy.types.d.ts +38 -0
- package/dist/tools/result/index.d.ts +1 -0
- package/dist/tools/result/result.d.ts +47 -0
- package/dist/tools/tool.constants.d.ts +7 -0
- package/dist/tools/tool.registry.d.ts +54 -0
- package/dist/tools/tool.types.d.ts +191 -0
- package/package.json +48 -0
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Frontmatter metadata for a single skill.
|
|
3
|
+
*
|
|
4
|
+
* Skills follow the Anthropic / opencode `SKILL.md` convention: a YAML
|
|
5
|
+
* frontmatter block at the top of the file declares the skill's identity
|
|
6
|
+
* and a short description, followed by the full instructional body.
|
|
7
|
+
*/
|
|
8
|
+
export interface SkillMetadata {
|
|
9
|
+
/** Unique skill identifier. Must be kebab-case. */
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/**
|
|
12
|
+
* Short, action-oriented description shown to the LLM in the system
|
|
13
|
+
* prompt header. Used to decide whether to call `load_skill`. Should
|
|
14
|
+
* fit on one line and answer "when should I load this?".
|
|
15
|
+
*/
|
|
16
|
+
readonly description: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A fully loaded skill — metadata plus the body of its `SKILL.md`.
|
|
20
|
+
*/
|
|
21
|
+
export interface Skill extends SkillMetadata {
|
|
22
|
+
/** Markdown body of the skill (frontmatter stripped). */
|
|
23
|
+
readonly content: string;
|
|
24
|
+
/** Absolute path to the source `SKILL.md` file. */
|
|
25
|
+
readonly sourcePath: string;
|
|
26
|
+
/**
|
|
27
|
+
* Origin of the skill. Project skills override global skills with the
|
|
28
|
+
* same `name`.
|
|
29
|
+
*/
|
|
30
|
+
readonly origin: "global" | "project";
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* In-memory skill registry. Holds resolved skills keyed by name and
|
|
34
|
+
* exposes lookup / listing for the loader, the system-prompt header
|
|
35
|
+
* builder, and the `load_skill` tool.
|
|
36
|
+
*/
|
|
37
|
+
export interface SkillRegistry {
|
|
38
|
+
/** Register or replace a skill. Project skills override global ones by name. */
|
|
39
|
+
register(skill: Skill): void;
|
|
40
|
+
/** Look up a skill by name. */
|
|
41
|
+
get(name: string): Skill | undefined;
|
|
42
|
+
/** All registered skills, sorted by `name`. */
|
|
43
|
+
list(): readonly Skill[];
|
|
44
|
+
/** True when no skills are registered. */
|
|
45
|
+
isEmpty(): boolean;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Options for {@link loadSkills}.
|
|
49
|
+
*/
|
|
50
|
+
export interface LoadSkillsOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Absolute path to the global skills directory. Each direct subdirectory
|
|
53
|
+
* containing a `SKILL.md` becomes a skill. Defaults to
|
|
54
|
+
* `<configRoot>/comma-agents/skills/`.
|
|
55
|
+
*
|
|
56
|
+
* Set to `null` to skip global discovery.
|
|
57
|
+
*/
|
|
58
|
+
readonly globalSkillsDir?: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Absolute path to the project-local skills directory. Defaults to
|
|
61
|
+
* `<cwd>/.comma/skills/`. Skills here override global ones by name.
|
|
62
|
+
*
|
|
63
|
+
* Set to `null` to skip project discovery.
|
|
64
|
+
*/
|
|
65
|
+
readonly projectSkillsDir?: string | null;
|
|
66
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { SkillMetadata } from "./skills.types";
|
|
2
|
+
/**
|
|
3
|
+
* Resolve the platform-appropriate user config root. Mirrors the logic
|
|
4
|
+
* used by the TUI's `resolveConfigRoot` so that skills authored alongside
|
|
5
|
+
* the TUI config are discovered without extra configuration.
|
|
6
|
+
*
|
|
7
|
+
* - macOS: `~/Library/Application Support`
|
|
8
|
+
* - Windows: `%APPDATA%` (falls back to `~/AppData/Roaming`)
|
|
9
|
+
* - Linux/other: `$XDG_CONFIG_HOME` or `~/.config`
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveUserConfigRoot(): string;
|
|
12
|
+
/** Absolute path to the default global skills directory for this user. */
|
|
13
|
+
export declare function resolveDefaultGlobalSkillsDir(): string;
|
|
14
|
+
/** Absolute path to the default project-local skills directory for the given workspace. */
|
|
15
|
+
export declare function resolveDefaultProjectSkillsDir(workspaceRoot: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Parse the YAML frontmatter of a `SKILL.md` file and return the metadata
|
|
18
|
+
* plus the remaining markdown body. The grammar is intentionally minimal
|
|
19
|
+
* — just enough to recognise:
|
|
20
|
+
*
|
|
21
|
+
* ```
|
|
22
|
+
* ---
|
|
23
|
+
* name: my-skill
|
|
24
|
+
* description: One-line summary.
|
|
25
|
+
* ---
|
|
26
|
+
*
|
|
27
|
+
* # Body
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* Unknown frontmatter keys are ignored. Throws `SkillParseError`-style
|
|
31
|
+
* `Error` instances with a descriptive message when required fields are
|
|
32
|
+
* missing or malformed; the caller decides how to surface them.
|
|
33
|
+
*/
|
|
34
|
+
export declare function parseSkillFile(rawContent: string): {
|
|
35
|
+
metadata: SkillMetadata;
|
|
36
|
+
body: string;
|
|
37
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DiscoverStrategiesOptions, DiscoverStrategiesResult } from "./discover.types";
|
|
2
|
+
/**
|
|
3
|
+
* Discover all available strategies on disk.
|
|
4
|
+
*
|
|
5
|
+
* Returns schema-validated strategies plus warnings for any candidate
|
|
6
|
+
* that failed to parse or validate. See the module header for the full
|
|
7
|
+
* list of sources scanned.
|
|
8
|
+
*
|
|
9
|
+
* @param options - Optional cwd / dataDir / includeBundled overrides.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const { strategies, warnings } = await discoverStrategies();
|
|
13
|
+
* for (const s of strategies) console.log(s.label, "→", s.path);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function discoverStrategies(options?: DiscoverStrategiesOptions): Promise<DiscoverStrategiesResult>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a discovered strategy was found.
|
|
3
|
+
*
|
|
4
|
+
* - `bundled` — shipped with `@comma-agents/core` under `packages/core/strategies/`.
|
|
5
|
+
* - `cwd` — single strategy file under `<cwd>/.comma/strategies/`.
|
|
6
|
+
* - `cwd-project` — strategy referenced by a `comma-project.json`
|
|
7
|
+
* inside `<cwd>/.comma/strategies/<project>/`.
|
|
8
|
+
* - `cwd-root-project` — strategy referenced by `<cwd>/.comma/comma-project.json`.
|
|
9
|
+
* - `data` — single strategy file under `<dataDir>/strategies/`.
|
|
10
|
+
* - `data-project` — strategy referenced by a `comma-project.json`
|
|
11
|
+
* inside `<dataDir>/strategies/<project>/`.
|
|
12
|
+
*/
|
|
13
|
+
export type DiscoveredStrategyOrigin = "bundled" | "bundled-project" | "cwd" | "cwd-project" | "cwd-root-project" | "data" | "data-project";
|
|
14
|
+
/** A successfully discovered and schema-validated strategy. */
|
|
15
|
+
export interface DiscoveredStrategy {
|
|
16
|
+
/** Strategy `name` field from the file. */
|
|
17
|
+
readonly name: string;
|
|
18
|
+
/** Optional strategy `description` field. */
|
|
19
|
+
readonly description?: string;
|
|
20
|
+
/** Strategy `version` field. */
|
|
21
|
+
readonly version: string;
|
|
22
|
+
/** Absolute path to the strategy file on disk. */
|
|
23
|
+
readonly path: string;
|
|
24
|
+
/**
|
|
25
|
+
* When the strategy is part of a project, the absolute path to the
|
|
26
|
+
* project's `comma-project.json`. Used by the daemon to call
|
|
27
|
+
* `loadProject(manifestPath)` before loading the strategy.
|
|
28
|
+
*/
|
|
29
|
+
readonly manifestPath?: string;
|
|
30
|
+
/** Where this strategy was found. */
|
|
31
|
+
readonly origin: DiscoveredStrategyOrigin;
|
|
32
|
+
/**
|
|
33
|
+
* Human-readable label. For project-scoped strategies this is
|
|
34
|
+
* `"<project> > <name>"`; otherwise just `<name>`.
|
|
35
|
+
*/
|
|
36
|
+
readonly label: string;
|
|
37
|
+
}
|
|
38
|
+
/** A discovery candidate that could not be loaded or validated. */
|
|
39
|
+
export interface DiscoveryWarning {
|
|
40
|
+
/** Absolute path to the candidate that failed. */
|
|
41
|
+
readonly path: string;
|
|
42
|
+
/** Reason the candidate was excluded (parse/validation error message). */
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
}
|
|
45
|
+
/** Options for {@link discoverStrategies}. */
|
|
46
|
+
export interface DiscoverStrategiesOptions {
|
|
47
|
+
/** Working directory to scan for `.comma/strategies/`. Defaults to `process.cwd()`. */
|
|
48
|
+
readonly cwd?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Platform data directory to scan for `strategies/`.
|
|
51
|
+
* Defaults to `resolveDataDir()`.
|
|
52
|
+
*/
|
|
53
|
+
readonly dataDir?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether to include the strategies bundled with `@comma-agents/core`
|
|
56
|
+
* (under `packages/core/strategies/`). Defaults to `true`.
|
|
57
|
+
*/
|
|
58
|
+
readonly includeBundled?: boolean;
|
|
59
|
+
}
|
|
60
|
+
/** Result of {@link discoverStrategies}. */
|
|
61
|
+
export interface DiscoverStrategiesResult {
|
|
62
|
+
/**
|
|
63
|
+
* Schema-validated strategies, in source-priority order:
|
|
64
|
+
* bundled → cwd → cwd-project → cwd-root-project → data → data-project.
|
|
65
|
+
* Duplicates (by absolute path) are removed.
|
|
66
|
+
*/
|
|
67
|
+
readonly strategies: readonly DiscoveredStrategy[];
|
|
68
|
+
/** Files that were skipped because they failed to parse or validate. */
|
|
69
|
+
readonly warnings: readonly DiscoveryWarning[];
|
|
70
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { DiscoveredStrategy, DiscoveredStrategyOrigin } from "./discover.types";
|
|
2
|
+
/**
|
|
3
|
+
* Internal: parse outcome — either a validated strategy header, or a
|
|
4
|
+
* reason it was skipped. Helpers return these so the caller can collect
|
|
5
|
+
* warnings centrally.
|
|
6
|
+
*/
|
|
7
|
+
export type ParsedStrategyHeader = {
|
|
8
|
+
readonly ok: true;
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly version: string;
|
|
11
|
+
readonly description: string | undefined;
|
|
12
|
+
} | {
|
|
13
|
+
readonly ok: false;
|
|
14
|
+
readonly reason: string;
|
|
15
|
+
};
|
|
16
|
+
/** Internal: parse outcome for a project manifest. */
|
|
17
|
+
export type ParsedProjectManifest = {
|
|
18
|
+
readonly ok: true;
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description: string | undefined;
|
|
21
|
+
/** Absolute paths of every strategy file referenced by this manifest. */
|
|
22
|
+
readonly strategyPaths: readonly string[];
|
|
23
|
+
} | {
|
|
24
|
+
readonly ok: false;
|
|
25
|
+
readonly reason: string;
|
|
26
|
+
};
|
|
27
|
+
/** Return `true` when `filePath` ends with one of {@link STRATEGY_EXTENSIONS}. */
|
|
28
|
+
export declare function hasStrategyExtension(filePath: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve a strategy file's parse format from its extension.
|
|
31
|
+
*
|
|
32
|
+
* `.json` / `.jsonc` parse as JSON (comments stripped); `.yaml` / `.yml`
|
|
33
|
+
* parse as YAML. Throws when the extension is unrecognized — callers
|
|
34
|
+
* should gate via {@link hasStrategyExtension} first.
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatForExtension(filePath: string): "json" | "yaml";
|
|
37
|
+
/**
|
|
38
|
+
* Read a strategy file from disk and return its raw text plus the
|
|
39
|
+
* detected parse format (based on extension).
|
|
40
|
+
*
|
|
41
|
+
* Exposed from core so the daemon executor can reuse the same logic
|
|
42
|
+
* without re-implementing JSON/YAML detection or comment stripping.
|
|
43
|
+
*
|
|
44
|
+
* @throws when the file does not exist or has an unsupported extension.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readStrategyFile(filePath: string): Promise<{
|
|
47
|
+
readonly content: string;
|
|
48
|
+
readonly format: "json" | "yaml";
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Parse a strategy file and return its validated header
|
|
52
|
+
* (`name`, `version`, `description`). Failures are returned as a
|
|
53
|
+
* `{ ok: false, reason }` value rather than thrown so the caller can
|
|
54
|
+
* batch-collect warnings.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseStrategyHeader(filePath: string): Promise<ParsedStrategyHeader>;
|
|
57
|
+
/**
|
|
58
|
+
* Parse a `comma-project.json` manifest and return its name plus the
|
|
59
|
+
* absolute paths of every strategy it references. Strategy entries in
|
|
60
|
+
* the manifest are resolved relative to the manifest's directory.
|
|
61
|
+
*/
|
|
62
|
+
export declare function parseProjectManifest(manifestPath: string): Promise<ParsedProjectManifest>;
|
|
63
|
+
/** List strategy files directly inside `dir` (non-recursive). */
|
|
64
|
+
export declare function listStrategyFiles(dir: string): string[];
|
|
65
|
+
/**
|
|
66
|
+
* List `<dir>/<child>/comma-project.json` manifest paths for every
|
|
67
|
+
* subdirectory of `dir` that contains one.
|
|
68
|
+
*/
|
|
69
|
+
export declare function listProjectManifests(dir: string): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Build a {@link DiscoveredStrategy} from a parsed strategy header.
|
|
72
|
+
* Project-scoped entries get a `"<project> > <name>"` label.
|
|
73
|
+
*/
|
|
74
|
+
export declare function buildDiscoveredStrategy(input: {
|
|
75
|
+
readonly header: Extract<ParsedStrategyHeader, {
|
|
76
|
+
ok: true;
|
|
77
|
+
}>;
|
|
78
|
+
readonly path: string;
|
|
79
|
+
readonly origin: DiscoveredStrategyOrigin;
|
|
80
|
+
readonly projectName?: string;
|
|
81
|
+
readonly manifestPath?: string;
|
|
82
|
+
}): DiscoveredStrategy;
|
|
83
|
+
/**
|
|
84
|
+
* Locate the root directory of the `@comma-agents/core` package.
|
|
85
|
+
*
|
|
86
|
+
* Walks up from this source file looking for a `package.json` whose
|
|
87
|
+
* `name === "@comma-agents/core"`. This works in both workspace
|
|
88
|
+
* development (where the source lives under `packages/core/src/`) and
|
|
89
|
+
* when the package is consumed from `node_modules`.
|
|
90
|
+
*
|
|
91
|
+
* Returns `null` if the package root cannot be located (e.g., when the
|
|
92
|
+
* file has been bundled into a single artifact without a package
|
|
93
|
+
* manifest nearby).
|
|
94
|
+
*/
|
|
95
|
+
export declare function findCorePackageRoot(): string | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { LoadedStrategy } from "../loader/loader.types";
|
|
2
|
+
import type { ExportStrategyOptions } from "./exporter.types";
|
|
3
|
+
/**
|
|
4
|
+
* Serialize a loaded strategy back to a JSON or YAML string.
|
|
5
|
+
*
|
|
6
|
+
* Uses the original validated data (`strategy.raw`) for faithful
|
|
7
|
+
* round-trip serialization. This means any fields that were normalized
|
|
8
|
+
* or defaulted during loading are preserved in their original form.
|
|
9
|
+
*
|
|
10
|
+
* @param strategy - A previously loaded strategy.
|
|
11
|
+
* @param options - Format and indentation options.
|
|
12
|
+
* @returns The serialized strategy string.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* import { loadStrategy, exportStrategy } from "@comma-agents/core";
|
|
17
|
+
*
|
|
18
|
+
* const strategy = await loadStrategy("./strategy.json", { providers });
|
|
19
|
+
*
|
|
20
|
+
* // Export as JSON (default)
|
|
21
|
+
* const json = exportStrategy(strategy);
|
|
22
|
+
*
|
|
23
|
+
* // Export as YAML
|
|
24
|
+
* const yaml = exportStrategy(strategy, { format: "yaml" });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function exportStrategy(strategy: LoadedStrategy, options?: ExportStrategyOptions): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type { DiscoveredStrategy, DiscoveredStrategyOrigin, DiscoverStrategiesOptions, DiscoverStrategiesResult, DiscoveryWarning, } from "./discover/index";
|
|
2
|
+
export { discoverStrategies, readStrategyFile } from "./discover/index";
|
|
3
|
+
export { exportStrategy } from "./exporter/exporter";
|
|
4
|
+
export type { ExportStrategyOptions } from "./exporter/exporter.types";
|
|
5
|
+
export { loadStrategy, loadStrategyFromString } from "./loader/loader";
|
|
6
|
+
export type { LoadedStrategy, LoadStrategyOptions, } from "./loader/loader.types";
|
|
7
|
+
export type { LoadedProject } from "./loader/project-loader";
|
|
8
|
+
export { loadProject } from "./loader/project-loader";
|
|
9
|
+
export type { AgentDef, AgentStep, BroadcastFlowDef, BuiltInToolName, CommaProjectManifest, CycleFlowDef, FlowDef, LLMAgentDef, SequentialFlowDef, Strategy, UserAgentDef, } from "./schema";
|
|
10
|
+
export { CommaProjectManifestSchema, isAgentStep, isFlowDef, isLLMAgentDef, isUserAgentDef, StrategySchema, } from "./schema";
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { LoadedStrategy, LoadStrategyOptions } from "./loader.types";
|
|
2
|
+
/**
|
|
3
|
+
* Load a strategy from a JSON or YAML file.
|
|
4
|
+
*
|
|
5
|
+
* Auto-detects format by file extension (`.json`, `.yaml`, `.yml`).
|
|
6
|
+
* Validates the structure, instantiates agents and flows, and returns
|
|
7
|
+
* a runnable `LoadedStrategy`.
|
|
8
|
+
*
|
|
9
|
+
* Model and tool resolution happen via global registries. Call
|
|
10
|
+
* `registerModel()` / `registerProvider()` / `registerTool()` before
|
|
11
|
+
* loading a strategy.
|
|
12
|
+
*
|
|
13
|
+
* @param filePath - Absolute or relative path to the strategy file.
|
|
14
|
+
* @param options - Input collector, flow hooks, model override.
|
|
15
|
+
* @returns The loaded strategy with a runnable entry flow.
|
|
16
|
+
* @throws {StrategyValidationError} If the file is invalid or missing required fields.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { loadStrategy, registerProvider } from "@comma-agents/core";
|
|
21
|
+
*
|
|
22
|
+
* registerProvider("openai", (modelId) => openai(modelId));
|
|
23
|
+
* const strategy = await loadStrategy("./strategy.json");
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function loadStrategy(filePath: string, options?: LoadStrategyOptions): Promise<LoadedStrategy>;
|
|
27
|
+
/**
|
|
28
|
+
* Load a strategy from a raw JSON or YAML string.
|
|
29
|
+
*
|
|
30
|
+
* Useful when the content is already in memory (e.g., received over
|
|
31
|
+
* a WebSocket from the TUI, or from a test fixture).
|
|
32
|
+
*
|
|
33
|
+
* @param content - The raw strategy string.
|
|
34
|
+
* @param format - "json" or "yaml".
|
|
35
|
+
* @param options - Input collector, hooks, abort signal, model override.
|
|
36
|
+
* @returns The loaded strategy with a runnable entry flow.
|
|
37
|
+
* @throws {StrategyValidationError} If parsing or validation fails.
|
|
38
|
+
*/
|
|
39
|
+
export declare function loadStrategyFromString(content: string, format: "json" | "yaml", options?: LoadStrategyOptions): Promise<LoadedStrategy>;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Agent } from "../../agents/agent/agent.types";
|
|
2
|
+
import type { InputCollector } from "../../agents/built-in/user/user-agent.types";
|
|
3
|
+
import type { FlowHooks } from "../../flows/flow/flow.types";
|
|
4
|
+
import type { LanguageService } from "../../language";
|
|
5
|
+
import type { SkillRegistry } from "../../skills/skills.types";
|
|
6
|
+
import type { LaunchStrategyHandle } from "../../tools/launch-strategy.types";
|
|
7
|
+
import type { Strategy } from "../schema";
|
|
8
|
+
/**
|
|
9
|
+
* Options for loading a strategy.
|
|
10
|
+
*
|
|
11
|
+
* Model and tool resolution happen internally via global registries
|
|
12
|
+
* (registerModel / registerProvider / registerTool). The loader does
|
|
13
|
+
* not accept provider factories or credential stores — callers must
|
|
14
|
+
* configure those globally before loading a strategy.
|
|
15
|
+
*/
|
|
16
|
+
export interface LoadStrategyOptions {
|
|
17
|
+
/**
|
|
18
|
+
* Input collector function for user agents.
|
|
19
|
+
* Required if the strategy contains any user agents with `requireInput: true`.
|
|
20
|
+
*/
|
|
21
|
+
readonly inputCollector?: InputCollector;
|
|
22
|
+
/**
|
|
23
|
+
* Flow hooks to inject into all flows via `hookIntoFlow()` after
|
|
24
|
+
* construction. Useful for the daemon to observe step execution,
|
|
25
|
+
* flow lifecycle, etc.
|
|
26
|
+
*/
|
|
27
|
+
readonly flowHooks?: FlowHooks;
|
|
28
|
+
/**
|
|
29
|
+
* Override the model for ALL LLM agents in the strategy.
|
|
30
|
+
*
|
|
31
|
+
* When set, every agent's model string is replaced with this value,
|
|
32
|
+
* regardless of what the strategy file specifies. Format: "providerID/modelID".
|
|
33
|
+
*
|
|
34
|
+
* Useful for the daemon's `--model-override` flag, allowing a single
|
|
35
|
+
* daemon instance to serve any provider/model combination without
|
|
36
|
+
* editing strategy files.
|
|
37
|
+
*
|
|
38
|
+
* @example "github-copilot/gpt-4o"
|
|
39
|
+
*/
|
|
40
|
+
readonly modelOverride?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Skill registry to make available to every LLM agent in this strategy.
|
|
43
|
+
*
|
|
44
|
+
* When provided, every agent that lists `load_skill` in its `tools`
|
|
45
|
+
* array can resolve skill names against this registry. The loader also
|
|
46
|
+
* prepends a compact `## Available Skills` block to each agent's
|
|
47
|
+
* `systemPrompt` so the model knows what to ask for. Build the
|
|
48
|
+
* registry with `loadSkills(workspaceRoot)`.
|
|
49
|
+
*/
|
|
50
|
+
readonly skillRegistry?: SkillRegistry;
|
|
51
|
+
/**
|
|
52
|
+
* Optional base directory of the strategy file, used to resolve relative paths
|
|
53
|
+
* (such as system prompt file paths).
|
|
54
|
+
*/
|
|
55
|
+
readonly strategyDir?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Optional handle for spawning sub-strategies, threaded into every
|
|
58
|
+
* agent's {@link ToolContext} so tools such as `launch_strategy` can
|
|
59
|
+
* delegate to a runtime-supplied implementation (e.g., the daemon
|
|
60
|
+
* executor, which wires the nested run's flow/agent hooks to the
|
|
61
|
+
* parent run's broadcast pipeline).
|
|
62
|
+
*
|
|
63
|
+
* When omitted, `launch_strategy` falls back to an in-process
|
|
64
|
+
* `loadStrategy` + `flow.call()` invocation with no broadcast.
|
|
65
|
+
*/
|
|
66
|
+
readonly launchStrategy?: LaunchStrategyHandle;
|
|
67
|
+
/** Optional runtime language service threaded into every agent tool call. */
|
|
68
|
+
readonly languageService?: LanguageService;
|
|
69
|
+
/**
|
|
70
|
+
* Optional run identifier propagated to every agent's
|
|
71
|
+
* {@link AgentConfig.runId} (and from there into each tool's
|
|
72
|
+
* {@link ToolContext.runId}).
|
|
73
|
+
*
|
|
74
|
+
* Distinct from `sessionId` (which scopes the audit log and trash
|
|
75
|
+
* metadata across an entire user/daemon session): `runId` identifies
|
|
76
|
+
* a single strategy invocation. The daemon executor passes the
|
|
77
|
+
* top-level run id here, and gives each `launch_strategy` sub-load
|
|
78
|
+
* a *fresh* derived id, so recursive strategy invocations have
|
|
79
|
+
* isolated state for tools that key on `runId` (notably `todo_*`,
|
|
80
|
+
* which shares state across agents within one invocation but must not
|
|
81
|
+
* leak into recursive sub-runs).
|
|
82
|
+
*
|
|
83
|
+
* When omitted, runId-aware tools fall back to `agentName`-only
|
|
84
|
+
* keying (their original behaviour) — safe for tests and embedded
|
|
85
|
+
* callers that don't care about cross-launch isolation.
|
|
86
|
+
*/
|
|
87
|
+
readonly runId?: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The result of loading a strategy — contains the runnable flow
|
|
91
|
+
* and metadata for inspection.
|
|
92
|
+
*/
|
|
93
|
+
export interface LoadedStrategy {
|
|
94
|
+
/** Strategy name from the file. */
|
|
95
|
+
readonly name: string;
|
|
96
|
+
/** Strategy version from the file. */
|
|
97
|
+
readonly version: string;
|
|
98
|
+
/** Optional description. */
|
|
99
|
+
readonly description?: string;
|
|
100
|
+
/** The instantiated entry flow as a runnable Agent. */
|
|
101
|
+
readonly flow: Agent;
|
|
102
|
+
/** The instantiated agent registry (for inspection/testing). */
|
|
103
|
+
readonly agents: Readonly<Record<string, Agent>>;
|
|
104
|
+
/** The raw validated strategy data (for exporting). */
|
|
105
|
+
readonly raw: Strategy;
|
|
106
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Agent } from "../../agents/agent/agent.types";
|
|
2
|
+
import type { SkillRegistry } from "../../skills/skills.types";
|
|
3
|
+
import type { FlowDef, Strategy } from "../schema";
|
|
4
|
+
import type { LoadStrategyOptions } from "./loader.types";
|
|
5
|
+
/**
|
|
6
|
+
* Build all agents defined in the strategy into live Agent instances.
|
|
7
|
+
*
|
|
8
|
+
* Model and tool resolution happen inside createAgent via global
|
|
9
|
+
* registries — the loader only passes string identifiers through.
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildAgentRegistry(strategy: Strategy, options: LoadStrategyOptions): Promise<Record<string, Agent>>;
|
|
12
|
+
/** @internal Used by tests to assert the header gets attached. */
|
|
13
|
+
export declare function previewSkillsHeader(registry: SkillRegistry): string;
|
|
14
|
+
/**
|
|
15
|
+
* Recursively build a flow definition into a runnable Agent.
|
|
16
|
+
*
|
|
17
|
+
* If `options.flowHooks` is provided, hooks are injected into the
|
|
18
|
+
* created flow via `hookIntoFlow()` after construction.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildFlow(flowDef: FlowDef, agents: Readonly<Record<string, Agent>>, options: LoadStrategyOptions): Agent;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommaProjectManifest } from "../schema";
|
|
2
|
+
export interface LoadedProject {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly version?: string;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
readonly manifest: CommaProjectManifest;
|
|
7
|
+
readonly manifestDir: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadProject(manifestPath: string): Promise<LoadedProject>;
|