@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,157 @@
|
|
|
1
|
+
import type { Credential } from "../../credentials/credentials.types";
|
|
2
|
+
import type { ProviderFactory } from "../model.types";
|
|
3
|
+
/**
|
|
4
|
+
* Provenance of a resolved model list.
|
|
5
|
+
*
|
|
6
|
+
* - `"catalog"` — models.dev baseline (bundled snapshot or refreshed copy).
|
|
7
|
+
* - `"live"` — returned only from a provider's listModels callback (no catalog overlap).
|
|
8
|
+
* - `"merged"` — catalog baseline overlaid with live results.
|
|
9
|
+
* - `"error"` — live discovery failed; falling back to catalog or empty.
|
|
10
|
+
*/
|
|
11
|
+
export type ModelsSource = "catalog" | "live" | "merged" | "error";
|
|
12
|
+
/** Supported input/output modality identifiers used by the catalog. */
|
|
13
|
+
export type Modality = "text" | "image" | "audio" | "video" | "pdf";
|
|
14
|
+
/** Release/availability status of a model, when known. */
|
|
15
|
+
export type ModelStatus = "alpha" | "beta" | "deprecated";
|
|
16
|
+
/** Coarse-grained capability flags derived from the catalog or live responses. */
|
|
17
|
+
export interface ModelCapabilities {
|
|
18
|
+
/** Supports tool/function calling. */
|
|
19
|
+
readonly tools?: boolean;
|
|
20
|
+
/** Supports reasoning / chain-of-thought. */
|
|
21
|
+
readonly reasoning?: boolean;
|
|
22
|
+
/** Accepts image inputs. */
|
|
23
|
+
readonly vision?: boolean;
|
|
24
|
+
/** Accepts file attachments (images, PDFs, audio). */
|
|
25
|
+
readonly attachment?: boolean;
|
|
26
|
+
/** Supports a dedicated structured-output feature. */
|
|
27
|
+
readonly structuredOutput?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Expected credential type for a provider.
|
|
31
|
+
*
|
|
32
|
+
* - `"api"` — simple API key (OpenAI, Anthropic, etc.)
|
|
33
|
+
* - `"oauth"` — OAuth 2.0 flow (GitHub Copilot)
|
|
34
|
+
* - `"custom"` — provider-specific opaque data
|
|
35
|
+
* - `"none"` — local runtime with no credential needed (Ollama)
|
|
36
|
+
*/
|
|
37
|
+
export type CredentialType = "api" | "oauth" | "custom" | "none";
|
|
38
|
+
/** Per-million-token prices in USD. */
|
|
39
|
+
export interface ModelCost {
|
|
40
|
+
/** Cost per 1M input tokens. */
|
|
41
|
+
readonly input?: number;
|
|
42
|
+
/** Cost per 1M output tokens. */
|
|
43
|
+
readonly output?: number;
|
|
44
|
+
/** Cost per 1M reasoning tokens. */
|
|
45
|
+
readonly reasoning?: number;
|
|
46
|
+
/** Cost per 1M cache-read tokens. */
|
|
47
|
+
readonly cacheRead?: number;
|
|
48
|
+
/** Cost per 1M cache-write tokens. */
|
|
49
|
+
readonly cacheWrite?: number;
|
|
50
|
+
}
|
|
51
|
+
/** Supported modalities. */
|
|
52
|
+
export interface ModelModalities {
|
|
53
|
+
readonly input?: readonly Modality[];
|
|
54
|
+
readonly output?: readonly Modality[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Normalized metadata for a single model. Populated from the catalog,
|
|
58
|
+
* a provider's live response, or a merge of the two.
|
|
59
|
+
*/
|
|
60
|
+
export interface ModelInfo {
|
|
61
|
+
/** Model identifier as used in model strings (e.g., `"gpt-4o"`). */
|
|
62
|
+
readonly id: string;
|
|
63
|
+
/** Human-friendly display name. */
|
|
64
|
+
readonly name?: string;
|
|
65
|
+
/** Grouping label (e.g., `"claude-sonnet"`, `"gpt"`). */
|
|
66
|
+
readonly family?: string;
|
|
67
|
+
/** Maximum total context window in tokens. */
|
|
68
|
+
readonly contextWindow?: number;
|
|
69
|
+
/** Maximum input tokens allowed in a single request. */
|
|
70
|
+
readonly maxInputTokens?: number;
|
|
71
|
+
/** Maximum output tokens per response. */
|
|
72
|
+
readonly maxOutputTokens?: number;
|
|
73
|
+
/** Training knowledge cutoff, `YYYY-MM` or `YYYY-MM-DD`. */
|
|
74
|
+
readonly knowledgeCutoff?: string;
|
|
75
|
+
/** First public release date. */
|
|
76
|
+
readonly releaseDate?: string;
|
|
77
|
+
/** Last metadata update date. */
|
|
78
|
+
readonly lastUpdated?: string;
|
|
79
|
+
/** Release status (alpha/beta/deprecated). */
|
|
80
|
+
readonly status?: ModelStatus;
|
|
81
|
+
/** Supported input/output modalities. */
|
|
82
|
+
readonly modalities?: ModelModalities;
|
|
83
|
+
/** Capability flags. */
|
|
84
|
+
readonly capabilities?: ModelCapabilities;
|
|
85
|
+
/** Pricing information. */
|
|
86
|
+
readonly cost?: ModelCost;
|
|
87
|
+
}
|
|
88
|
+
/** Arguments provided to a provider's live `listModels` callback. */
|
|
89
|
+
export interface ListModelsContext {
|
|
90
|
+
/** Resolved credential for the provider, if any. */
|
|
91
|
+
readonly credential?: Credential;
|
|
92
|
+
/** Provider-specific base URL override (e.g., Ollama host, Copilot enterprise domain). */
|
|
93
|
+
readonly baseURL?: string;
|
|
94
|
+
/** Optional abort signal; callers typically attach a timeout. */
|
|
95
|
+
readonly signal?: AbortSignal;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Live model-listing callback supplied by a provider definition.
|
|
99
|
+
*
|
|
100
|
+
* Implementations should return the raw list from the provider's API.
|
|
101
|
+
* Merge with the catalog baseline is handled by the registry, not here.
|
|
102
|
+
*/
|
|
103
|
+
export type ListModelsFn = (context: ListModelsContext) => Promise<readonly ModelInfo[]>;
|
|
104
|
+
/**
|
|
105
|
+
* Full result of resolving the model list for a single provider.
|
|
106
|
+
*
|
|
107
|
+
* Returned by `listProviderModels()` to consumers (the daemon, tests).
|
|
108
|
+
* `source` describes where the models came from; `error` is populated
|
|
109
|
+
* when live discovery failed and we fell back to catalog or empty.
|
|
110
|
+
*/
|
|
111
|
+
export interface ListModelsResult {
|
|
112
|
+
readonly models: readonly ModelInfo[];
|
|
113
|
+
readonly source: ModelsSource;
|
|
114
|
+
/** ISO timestamp when live data was fetched, if any. */
|
|
115
|
+
readonly fetchedAt?: string;
|
|
116
|
+
/** Error message when `source === "error"` or live fetch partially failed. */
|
|
117
|
+
readonly error?: string;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Everything the runtime knows about a provider: metadata from the
|
|
121
|
+
* catalog plus optional runtime resolution/listing callbacks.
|
|
122
|
+
*/
|
|
123
|
+
export interface ProviderDefinition {
|
|
124
|
+
/** Canonical provider id (matches models.dev keys, e.g., `"github-copilot"`). */
|
|
125
|
+
readonly id: string;
|
|
126
|
+
/** Human-friendly display name. */
|
|
127
|
+
readonly name: string;
|
|
128
|
+
/**
|
|
129
|
+
* Expected credential type for this provider.
|
|
130
|
+
* Defaults to `"api"` for catalog-derived providers when not explicitly set.
|
|
131
|
+
*/
|
|
132
|
+
readonly credentialType?: CredentialType;
|
|
133
|
+
/**
|
|
134
|
+
* Live model-listing callback. When present, `listProviderModels()` will
|
|
135
|
+
* call it and merge the response with the catalog.
|
|
136
|
+
*/
|
|
137
|
+
readonly listModels?: ListModelsFn;
|
|
138
|
+
/**
|
|
139
|
+
* Direct factory for the provider's `LanguageModel` instances. When set,
|
|
140
|
+
* takes precedence over `packageName`/`factoryName`.
|
|
141
|
+
*/
|
|
142
|
+
readonly factory?: ProviderFactory;
|
|
143
|
+
/**
|
|
144
|
+
* npm package name used by the resolver to dynamically import the AI SDK
|
|
145
|
+
* integration. Defaults to `@ai-sdk/<id>` when omitted.
|
|
146
|
+
*/
|
|
147
|
+
readonly packageName?: string;
|
|
148
|
+
/**
|
|
149
|
+
* Export name on the imported module. Defaults to `create<ProviderId>`.
|
|
150
|
+
*/
|
|
151
|
+
readonly factoryName?: string;
|
|
152
|
+
/**
|
|
153
|
+
* `true` when the definition was added via `registerProvider()` rather
|
|
154
|
+
* than derived from the bundled catalog. Set automatically by the registry.
|
|
155
|
+
*/
|
|
156
|
+
readonly isCustom?: boolean;
|
|
157
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ModelInfo } from "./providers.types";
|
|
2
|
+
/**
|
|
3
|
+
* Merge a catalog baseline with a provider's live model list.
|
|
4
|
+
*
|
|
5
|
+
* Strategy (follows opencode's layering approach):
|
|
6
|
+
* - Only models present in the live list survive (live is authoritative for membership).
|
|
7
|
+
* - Each surviving model starts from the catalog entry (rich metadata) and is
|
|
8
|
+
* overlaid with the live entry's fields — live wins for runtime-relevant
|
|
9
|
+
* capabilities and limits, catalog fills in missing cost / release dates / names.
|
|
10
|
+
* - Models present live but not in the catalog are included as-is.
|
|
11
|
+
*/
|
|
12
|
+
export declare function mergeCatalogWithLive(catalogModels: readonly ModelInfo[], liveModels: readonly ModelInfo[]): readonly ModelInfo[];
|
|
13
|
+
/** Merge two `ModelInfo` entries, preferring `overlay` fields when present. */
|
|
14
|
+
export declare function mergeModelInfo(base: ModelInfo, overlay: ModelInfo): ModelInfo;
|
|
15
|
+
/** Sort models by id for stable output. */
|
|
16
|
+
export declare function sortModels(models: readonly ModelInfo[]): readonly ModelInfo[];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { BuildMessagesOptions, SystemPromptOptions, } from "./message-builder";
|
|
2
|
+
export { buildMessages, resolveSystemPrompt } from "./message-builder";
|
|
3
|
+
export type { PromptTemplate, PromptTemplateConfig, TemplateValue, TemplateVariables, } from "./prompts.types";
|
|
4
|
+
export { createPromptTemplate } from "./template/prompt-template";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ModelMessage } from "ai";
|
|
2
|
+
import type { ConversationContext } from "../conversation-context";
|
|
3
|
+
import type { PromptTemplate } from "./prompts.types";
|
|
4
|
+
/**
|
|
5
|
+
* Options for building a message array.
|
|
6
|
+
*/
|
|
7
|
+
export interface BuildMessagesOptions {
|
|
8
|
+
/** The current user message to append. */
|
|
9
|
+
readonly message: string;
|
|
10
|
+
/**
|
|
11
|
+
* Conversation context to prepend.
|
|
12
|
+
* If not provided, only the current message is included.
|
|
13
|
+
*/
|
|
14
|
+
readonly context?: ConversationContext;
|
|
15
|
+
/**
|
|
16
|
+
* Additional context messages to prepend before conversation context.
|
|
17
|
+
* Useful for injecting few-shot examples or other context.
|
|
18
|
+
*/
|
|
19
|
+
readonly prefix?: readonly ModelMessage[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Options for resolving a system prompt, supporting both static strings
|
|
23
|
+
* and dynamic prompt templates.
|
|
24
|
+
*/
|
|
25
|
+
export interface SystemPromptOptions {
|
|
26
|
+
/**
|
|
27
|
+
* System prompt — a static string or a `PromptTemplate` for dynamic interpolation.
|
|
28
|
+
* When a `PromptTemplate` is provided, it is rendered with its baked-in variables.
|
|
29
|
+
*/
|
|
30
|
+
readonly systemPrompt?: string | PromptTemplate;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build a message array for the Vercel AI SDK.
|
|
34
|
+
*
|
|
35
|
+
* Composes messages in this order:
|
|
36
|
+
* 1. `prefix` messages (e.g., few-shot examples)
|
|
37
|
+
* 2. Conversation context (from `ConversationContext`)
|
|
38
|
+
* 3. Current user message
|
|
39
|
+
*
|
|
40
|
+
* Returns native AI SDK `ModelMessage[]` that can be passed directly to
|
|
41
|
+
* `generateText()` / `streamText()`. Preserves tool calls, tool results,
|
|
42
|
+
* reasoning, and multi-modal content from the conversation context.
|
|
43
|
+
*
|
|
44
|
+
* Note: The system prompt is NOT included in the message array — it should
|
|
45
|
+
* be passed via the `system` parameter of `generateText`/`streamText`.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const messages = buildMessages({
|
|
50
|
+
* message: "How do I use generics?",
|
|
51
|
+
* context,
|
|
52
|
+
* prefix: [
|
|
53
|
+
* { role: "user", content: "What is TypeScript?" },
|
|
54
|
+
* { role: "assistant", content: "TypeScript is a typed superset of JavaScript." },
|
|
55
|
+
* ],
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* const result = await generateText({
|
|
59
|
+
* model: openai("gpt-4o"),
|
|
60
|
+
* system: "You are a helpful assistant.",
|
|
61
|
+
* messages,
|
|
62
|
+
* });
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
export declare function buildMessages(options: BuildMessagesOptions): readonly ModelMessage[];
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a system prompt from either a static string or a dynamic template.
|
|
68
|
+
*
|
|
69
|
+
* If `systemPrompt` is a `PromptTemplate`, it is rendered with its baked-in
|
|
70
|
+
* variables. If it is a plain string, it is returned as-is.
|
|
71
|
+
*
|
|
72
|
+
* @returns The resolved system prompt string, or `undefined` if none configured.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* // Static
|
|
77
|
+
* const prompt = await resolveSystemPrompt({ systemPrompt: "You are helpful." });
|
|
78
|
+
* // => "You are helpful."
|
|
79
|
+
*
|
|
80
|
+
* // Dynamic template
|
|
81
|
+
* const template = createPromptTemplate({
|
|
82
|
+
* template: "You are {{ role }}, an expert in {{ language }}.",
|
|
83
|
+
* variables: { role: "a reviewer", language: "TypeScript" },
|
|
84
|
+
* });
|
|
85
|
+
* const prompt = await resolveSystemPrompt({ systemPrompt: template });
|
|
86
|
+
* // => "You are a reviewer, an expert in TypeScript."
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolveSystemPrompt(options: SystemPromptOptions): Promise<string | undefined>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A value that can be used to fill a prompt template variable.
|
|
3
|
+
*
|
|
4
|
+
* - Primitives (`string`, `number`, `boolean`, `null`) are passed directly to Liquid.
|
|
5
|
+
* - Arrays and objects enable `{% for %}` loops and dot-access in templates.
|
|
6
|
+
* - Functions (`() => string | Promise<string>`) are resolved to strings before
|
|
7
|
+
* the Liquid render pass — this preserves the async-first design.
|
|
8
|
+
*/
|
|
9
|
+
export type TemplateValue = string | number | boolean | null | undefined | readonly TemplateValue[] | {
|
|
10
|
+
readonly [key: string]: TemplateValue;
|
|
11
|
+
} | (() => string | Promise<string>);
|
|
12
|
+
/**
|
|
13
|
+
* A map of variable names to their values for prompt template interpolation.
|
|
14
|
+
*
|
|
15
|
+
* Values can be primitives, arrays, objects, or async functions.
|
|
16
|
+
* Functions are resolved to strings before the Liquid render pass.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* const vars: TemplateVariables = {
|
|
21
|
+
* role: "code reviewer",
|
|
22
|
+
* language: "TypeScript",
|
|
23
|
+
* tools: ["bash", "read", "write"],
|
|
24
|
+
* style: () => loadStyleGuide(), // async function → resolved to string
|
|
25
|
+
* };
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export type TemplateVariables = Readonly<Record<string, TemplateValue>>;
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for creating a prompt template.
|
|
31
|
+
*/
|
|
32
|
+
export interface PromptTemplateConfig {
|
|
33
|
+
/**
|
|
34
|
+
* The template string using Liquid syntax.
|
|
35
|
+
*
|
|
36
|
+
* Supports the full LiquidJS template language:
|
|
37
|
+
* - `{{ name }}` — variable interpolation
|
|
38
|
+
* - `{{ "VAR" | env }}` — environment variable via custom filter
|
|
39
|
+
* - `{{ "/path" | file }}` — file contents (first line) via custom filter
|
|
40
|
+
* - `{{ "command" | exec }}` — shell command output via custom filter
|
|
41
|
+
* - `{% if condition %}...{% endif %}` — conditionals
|
|
42
|
+
* - `{% for item in items %}...{% endfor %}` — loops
|
|
43
|
+
* - `{{ text | upcase }}` — built-in Liquid filters
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* "You are {{ role }}, an expert in {{ language }}."
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
readonly template: string;
|
|
51
|
+
/**
|
|
52
|
+
* Default variable values. Can be overridden at render time.
|
|
53
|
+
*/
|
|
54
|
+
readonly variables?: TemplateVariables;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* A compiled prompt template backed by LiquidJS.
|
|
58
|
+
*/
|
|
59
|
+
export interface PromptTemplate {
|
|
60
|
+
/** The original template string. */
|
|
61
|
+
readonly template: string;
|
|
62
|
+
/** The default variables provided at creation time. */
|
|
63
|
+
readonly defaults: TemplateVariables;
|
|
64
|
+
/**
|
|
65
|
+
* Render the prompt by resolving all variables through LiquidJS.
|
|
66
|
+
* Override variables take precedence over defaults.
|
|
67
|
+
*
|
|
68
|
+
* @throws {Error} if a required variable is missing or a filter fails
|
|
69
|
+
*/
|
|
70
|
+
render(overrides?: TemplateVariables): Promise<string>;
|
|
71
|
+
/**
|
|
72
|
+
* Update the default variables used during rendering.
|
|
73
|
+
* New values overwrite matching keys; keys not in the input are left as-is.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const tpl = createPromptTemplate({
|
|
78
|
+
* template: "You are {{ role }}, reviewing {{ language }} code.",
|
|
79
|
+
* variables: { role: "a reviewer" },
|
|
80
|
+
* });
|
|
81
|
+
* tpl.updatePromptVariables({ language: "TypeScript" });
|
|
82
|
+
* await tpl.render(); // "You are a reviewer, reviewing TypeScript code."
|
|
83
|
+
* ```
|
|
84
|
+
*/
|
|
85
|
+
updatePromptVariables(variables: TemplateVariables): void;
|
|
86
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { PromptTemplate, PromptTemplateConfig } from "../prompts.types";
|
|
2
|
+
/**
|
|
3
|
+
* Create a prompt template backed by LiquidJS.
|
|
4
|
+
*
|
|
5
|
+
* Templates use the full Liquid syntax — `{{ variable }}` interpolation,
|
|
6
|
+
* `{% if %}` / `{% for %}` control flow, filters, and the custom
|
|
7
|
+
* `env`, `file`, `exec` filters.
|
|
8
|
+
*
|
|
9
|
+
* Function-typed variable values are resolved to strings before the
|
|
10
|
+
* Liquid render pass, so `() => string | Promise<string>` still works.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const tpl = createPromptTemplate({
|
|
15
|
+
* template: "You are {{ role }}, an expert in {{ language }}.",
|
|
16
|
+
* variables: { role: "a code reviewer", language: "TypeScript" },
|
|
17
|
+
* });
|
|
18
|
+
* await tpl.render(); // "You are a code reviewer, an expert in TypeScript."
|
|
19
|
+
* await tpl.render({ language: "Rust" }); // "You are a code reviewer, an expert in Rust."
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function createPromptTemplate(config: PromptTemplateConfig): PromptTemplate;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Agent } from "../agents/agent/agent.types";
|
|
2
|
+
import type { GuardCallbacks } from "../guard/guard.types";
|
|
3
|
+
import type { Sandbox, SandboxConfig } from "./sandbox.types";
|
|
4
|
+
/**
|
|
5
|
+
* Apply sandbox enforcement to a strategy or agent.
|
|
6
|
+
*
|
|
7
|
+
* Creates a `Sandbox` from the config, which lazily creates per-tool `Guard`
|
|
8
|
+
* instances. Tools access their guard directly via `ToolContext.guard` and
|
|
9
|
+
* call `guard.authorize()` for path resolution, jail enforcement, policy
|
|
10
|
+
* evaluation, and interactive "ask" dispatch.
|
|
11
|
+
*
|
|
12
|
+
* @param boxed - The strategy or agent to sandbox.
|
|
13
|
+
* @param config - Partial sandbox configuration. Defaults are taken from
|
|
14
|
+
* `DEFAULT_SANDBOX_CONFIG` (jailed to process.cwd(), default forbidden globs).
|
|
15
|
+
* @param callbacks - onAsk / onPolicyChange handlers shared across all guards.
|
|
16
|
+
* @returns The same entity (mutated in-place).
|
|
17
|
+
*/
|
|
18
|
+
export declare function inSandbox(boxed: Agent, config?: Partial<SandboxConfig>, callbacks?: GuardCallbacks): Agent;
|
|
19
|
+
export declare function inSandbox(boxed: {
|
|
20
|
+
agents: Readonly<Record<string, Agent>>;
|
|
21
|
+
flow: Agent;
|
|
22
|
+
}, config?: Partial<SandboxConfig>, callbacks?: GuardCallbacks): typeof boxed;
|
|
23
|
+
/**
|
|
24
|
+
* Retrieve the `Sandbox` instance from a previously sandboxed entity.
|
|
25
|
+
*
|
|
26
|
+
* Returns `undefined` if `inSandbox` was never called on this entity.
|
|
27
|
+
* Useful for the daemon to access `sandbox.guardFor(tool)` for policy management.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getSandbox(boxed: Agent | {
|
|
30
|
+
agents: Readonly<Record<string, Agent>>;
|
|
31
|
+
}): Sandbox | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { getSandbox, inSandbox } from "./in-sandbox";
|
|
2
|
+
export { createSandbox } from "./sandbox";
|
|
3
|
+
export { DEFAULT_DAEMON_SANDBOX_CONFIG, DEFAULT_FORBIDDEN_GLOBS, DEFAULT_SANDBOX_CONFIG, PERMISSIVE_SANDBOX_CONFIG, } from "./sandbox.constants";
|
|
4
|
+
export type { AccessMode, AuthorizationContext, PathPolicy, PermissionDecision, PermissionOperation, PermissionRequest, PermissionRequester, PolicyPatch, Sandbox, SandboxConfig, } from "./sandbox.types";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SandboxConfig } from "./sandbox.types";
|
|
2
|
+
/**
|
|
3
|
+
* Cwd-relative glob patterns that are always denied for read and write
|
|
4
|
+
* unless the caller explicitly overrides `forbiddenGlobs` on `SandboxConfig`.
|
|
5
|
+
*
|
|
6
|
+
* Covers VCS metadata, dotenv files, common private keys/certs, and
|
|
7
|
+
* package-manager auth files. Patterns are evaluated by Bun.Glob.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DEFAULT_FORBIDDEN_GLOBS: readonly string[];
|
|
10
|
+
/**
|
|
11
|
+
* Permissive config — unjailed, absolute paths allowed, no forbidden globs,
|
|
12
|
+
* all reads and writes allowed.
|
|
13
|
+
*
|
|
14
|
+
* Applied as fallback in `buildAgentToolSet` when no sandbox is configured.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PERMISSIVE_SANDBOX_CONFIG: SandboxConfig;
|
|
17
|
+
/**
|
|
18
|
+
* Recommended default config — jailed to cwd, absolute paths rejected,
|
|
19
|
+
* default forbidden globs enforced, all operations allowed within the boundary.
|
|
20
|
+
* `.comma/**` and `.` are explicitly allowlisted for reading so skills and
|
|
21
|
+
* configuration are always accessible without triggering permission prompts.
|
|
22
|
+
*/
|
|
23
|
+
export declare const DEFAULT_SANDBOX_CONFIG: SandboxConfig;
|
|
24
|
+
/**
|
|
25
|
+
* Daemon default config — jailed to cwd, absolute paths allowed (daemon
|
|
26
|
+
* passes absolute paths), in-cwd paths auto-allowed, anything outside
|
|
27
|
+
* cwd triggers "ask" via the permission bridge. `.comma/**` and `.`
|
|
28
|
+
* are explicitly allowlisted for reading so skills and configuration are
|
|
29
|
+
* always accessible without prompting.
|
|
30
|
+
*/
|
|
31
|
+
export declare const DEFAULT_DAEMON_SANDBOX_CONFIG: Omit<SandboxConfig, "cwd">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GuardCallbacks } from "../guard/guard.types";
|
|
2
|
+
import type { Sandbox, SandboxConfig } from "./sandbox.types";
|
|
3
|
+
/**
|
|
4
|
+
* Create a Sandbox — a thin registry that lazily creates per-tool Guard
|
|
5
|
+
* instances. Each guard handles path resolution, jail enforcement, policy
|
|
6
|
+
* chain evaluation, and "ask" dispatch.
|
|
7
|
+
*
|
|
8
|
+
* @param config - Sandbox configuration. Missing fields use sensible defaults.
|
|
9
|
+
* @param callbacks - onAsk / onPolicyChange handlers shared across all guards.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createSandbox(config?: Partial<SandboxConfig>, callbacks?: GuardCallbacks): Sandbox;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decision mode for a path or operation.
|
|
3
|
+
* - `"allow"` — permit immediately.
|
|
4
|
+
* - `"deny"` — reject immediately with a SandboxViolationError.
|
|
5
|
+
* - `"ask"` — delegate to the PermissionRequester; throws if none is configured.
|
|
6
|
+
*/
|
|
7
|
+
export type AccessMode = "allow" | "deny" | "ask";
|
|
8
|
+
/**
|
|
9
|
+
* Policy applied to a class of file-system operations (read or write).
|
|
10
|
+
*
|
|
11
|
+
* Evaluation order: deny patterns → allow patterns → default.
|
|
12
|
+
* Patterns are Bun.Glob expressions relative to the sandbox `cwd`.
|
|
13
|
+
*/
|
|
14
|
+
export interface PathPolicy {
|
|
15
|
+
/** Decision when no pattern matches. */
|
|
16
|
+
readonly default: AccessMode;
|
|
17
|
+
/** Glob patterns (relative to cwd) that are explicitly allowed. */
|
|
18
|
+
readonly allow?: readonly string[];
|
|
19
|
+
/** Glob patterns (relative to cwd) that are explicitly denied. Deny wins over allow when both match. */
|
|
20
|
+
readonly deny?: readonly string[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Static configuration for a Sandbox instance.
|
|
24
|
+
*/
|
|
25
|
+
export interface SandboxConfig {
|
|
26
|
+
/** Absolute path used as the root for relative-path resolution and jail boundary. */
|
|
27
|
+
readonly cwd: string;
|
|
28
|
+
/**
|
|
29
|
+
* When `true`, any path that resolves outside `cwd` throws a
|
|
30
|
+
* SandboxViolationError with `reason: "jail"`.
|
|
31
|
+
*/
|
|
32
|
+
readonly jail: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* When `false`, tools that pass an absolute path receive a
|
|
35
|
+
* SandboxViolationError with `reason: "absolute-path"`.
|
|
36
|
+
*/
|
|
37
|
+
readonly allowAbsolutePaths: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Cwd-relative glob patterns that are unconditionally denied for both
|
|
40
|
+
* read and write operations. Evaluated before `read` / `write` policies;
|
|
41
|
+
* cannot be overridden by `allow` patterns or session decisions.
|
|
42
|
+
*/
|
|
43
|
+
readonly forbiddenGlobs: readonly string[];
|
|
44
|
+
/** Read-access policy applied to every FS read operation. */
|
|
45
|
+
readonly read: PathPolicy;
|
|
46
|
+
/** Write-access policy applied to every FS write operation. */
|
|
47
|
+
readonly write: PathPolicy;
|
|
48
|
+
/** Metadata for trash archive identification (runId, sessionId). Injected by the daemon executor. */
|
|
49
|
+
readonly trashMetadata?: SandboxTrashMetadata;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* File-system operation categories used in permission requests.
|
|
53
|
+
* `"fs.exec"` is reserved for future bash sandboxing.
|
|
54
|
+
*/
|
|
55
|
+
export type PermissionOperation = "fs.read" | "fs.write" | "fs.exec";
|
|
56
|
+
/**
|
|
57
|
+
* The decision returned by a PermissionRequester.
|
|
58
|
+
* - `"allow"` / `"deny"` — one-shot for this invocation only.
|
|
59
|
+
* - `"allow-session"` / `"deny-session"` — remembered for the lifetime
|
|
60
|
+
* of this guard's session memory (stored in-memory, not persisted to disk).
|
|
61
|
+
*/
|
|
62
|
+
export type PermissionDecision = "allow" | "deny" | "allow-session" | "deny-session";
|
|
63
|
+
/**
|
|
64
|
+
* Data passed to a PermissionRequester when policy resolves to `"ask"`.
|
|
65
|
+
*/
|
|
66
|
+
export interface PermissionRequest {
|
|
67
|
+
readonly agentName: string;
|
|
68
|
+
readonly toolName?: string;
|
|
69
|
+
readonly operation: PermissionOperation;
|
|
70
|
+
readonly resource: string;
|
|
71
|
+
readonly reason: "policy-ask" | "policy-deny-override";
|
|
72
|
+
readonly details?: Readonly<Record<string, unknown>>;
|
|
73
|
+
readonly signal?: AbortSignal;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Async function that presents a permission request to a human (or policy
|
|
77
|
+
* engine) and returns the decision.
|
|
78
|
+
*
|
|
79
|
+
* If the function throws or rejects, the guard treats it as `"deny"`.
|
|
80
|
+
*/
|
|
81
|
+
export type PermissionRequester = (request: PermissionRequest) => Promise<PermissionDecision>;
|
|
82
|
+
/**
|
|
83
|
+
* A partial update to a guard's in-memory policy.
|
|
84
|
+
* Applied by the daemon's `update_policy` message.
|
|
85
|
+
*/
|
|
86
|
+
export interface PolicyPatch {
|
|
87
|
+
readonly mode: "read" | "write";
|
|
88
|
+
readonly allow?: readonly string[];
|
|
89
|
+
readonly deny?: readonly string[];
|
|
90
|
+
readonly default?: AccessMode;
|
|
91
|
+
}
|
|
92
|
+
import type { Guard, Policy } from "../guard/guard.types";
|
|
93
|
+
import type { SandboxTrashMetadata } from "../tools/io/trash";
|
|
94
|
+
/**
|
|
95
|
+
* Thin guard registry. Creates per-tool Guard instances lazily.
|
|
96
|
+
* Tools access their guard directly via `ToolContext.guard`.
|
|
97
|
+
*/
|
|
98
|
+
export interface Sandbox {
|
|
99
|
+
/** The resolved absolute working directory. */
|
|
100
|
+
readonly cwd: string;
|
|
101
|
+
/** Map of tool name → Guard (lazily populated). */
|
|
102
|
+
readonly guards: ReadonlyMap<string, Guard>;
|
|
103
|
+
/** Get or lazily create a guard for the given tool. Accepts optional tool-level policies. */
|
|
104
|
+
guardFor(toolName: string, toolPolicies?: readonly Policy[]): Guard;
|
|
105
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { SkillLoadResult, SkillLoadWarning } from "./skills.loader";
|
|
2
|
+
export { buildSkillsPromptHeader, loadSkills } from "./skills.loader";
|
|
3
|
+
export { createSkillRegistry } from "./skills.registry";
|
|
4
|
+
export type { LoadSkillsOptions, Skill, SkillMetadata, SkillRegistry, } from "./skills.types";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Subdirectory under the OS config root holding global skills. */
|
|
2
|
+
export declare const GLOBAL_SKILLS_SUBDIR = "comma-agents/skills";
|
|
3
|
+
/** Subdirectory under the project workspace holding project-local skills. */
|
|
4
|
+
export declare const PROJECT_SKILLS_SUBDIR = ".comma/skills";
|
|
5
|
+
/** Filename inside each skill directory. */
|
|
6
|
+
export declare const SKILL_FILENAME = "SKILL.md";
|
|
7
|
+
/** Maximum size of a `SKILL.md` file in bytes (256 KiB). Prevents runaway loads. */
|
|
8
|
+
export declare const SKILL_MAX_BYTES: number;
|
|
9
|
+
/** Regular expression that valid skill names must match (kebab-case, 1–64 chars). */
|
|
10
|
+
export declare const SKILL_NAME_PATTERN: RegExp;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { LoadSkillsOptions, SkillRegistry } from "./skills.types";
|
|
2
|
+
/**
|
|
3
|
+
* A non-fatal warning produced while scanning a skills directory. Surfaced
|
|
4
|
+
* so callers can log malformed or oversized skills without aborting the
|
|
5
|
+
* whole scan.
|
|
6
|
+
*/
|
|
7
|
+
export interface SkillLoadWarning {
|
|
8
|
+
readonly sourcePath: string;
|
|
9
|
+
readonly message: string;
|
|
10
|
+
}
|
|
11
|
+
/** Result returned by {@link loadSkills}. */
|
|
12
|
+
export interface SkillLoadResult {
|
|
13
|
+
readonly registry: SkillRegistry;
|
|
14
|
+
readonly warnings: readonly SkillLoadWarning[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Scan the global and project skill directories and return a populated
|
|
18
|
+
* registry. Missing directories are silently ignored (not an error —
|
|
19
|
+
* users may have neither). Project skills override global skills with
|
|
20
|
+
* the same `name`.
|
|
21
|
+
*
|
|
22
|
+
* Each direct subdirectory containing a `SKILL.md` becomes a skill;
|
|
23
|
+
* deeper nesting is ignored to keep discovery predictable. Files larger
|
|
24
|
+
* than {@link SKILL_MAX_BYTES} or with malformed frontmatter are
|
|
25
|
+
* skipped and reported as `warnings`.
|
|
26
|
+
*
|
|
27
|
+
* @param workspaceRoot - Used to resolve the default project skills directory.
|
|
28
|
+
* @param options - Override or disable either discovery root.
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadSkills(workspaceRoot: string, options?: LoadSkillsOptions): Promise<SkillLoadResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Build the system-prompt header block advertising available skills.
|
|
33
|
+
* Returns an empty string when the registry is empty so callers can
|
|
34
|
+
* concatenate unconditionally.
|
|
35
|
+
*
|
|
36
|
+
* The block format is deliberately compact — `name: description` per
|
|
37
|
+
* line — so that even dozens of skills cost little context:
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
* ## Available Skills
|
|
41
|
+
* Call the `load_skill` tool with one of these names to load its full instructions:
|
|
42
|
+
* - ts-patterns: TypeScript conventions for new modules.
|
|
43
|
+
* - react-practices: React component and hook patterns.
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
export declare function buildSkillsPromptHeader(registry: SkillRegistry): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { SkillRegistry } from "./skills.types";
|
|
2
|
+
/**
|
|
3
|
+
* Create an in-memory skill registry.
|
|
4
|
+
*
|
|
5
|
+
* Project skills always override global skills with the same name; the
|
|
6
|
+
* registry enforces this regardless of registration order. Calling
|
|
7
|
+
* `register` with a global skill whose name is already taken by a
|
|
8
|
+
* project skill is a no-op.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const registry = createSkillRegistry();
|
|
13
|
+
* registry.register(projectSkill);
|
|
14
|
+
* registry.register(globalSkill); // ignored if names collide
|
|
15
|
+
* registry.get("ts-patterns");
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function createSkillRegistry(): SkillRegistry;
|