@bastani/atomic 0.9.29 → 0.9.30-alpha.2
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/CHANGELOG.md +27 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/core/anthropic-thinking-guard.js.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
- package/dist/core/extensions/loader-virtual-modules.js +6 -0
- package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
- package/dist/core/http-dispatcher.d.ts +1 -1
- package/dist/core/http-dispatcher.d.ts.map +1 -1
- package/dist/core/http-dispatcher.js +2 -1
- package/dist/core/http-dispatcher.js.map +1 -1
- package/dist/core/key-id-schema.d.ts +6 -0
- package/dist/core/key-id-schema.d.ts.map +1 -0
- package/dist/core/key-id-schema.js +16 -0
- package/dist/core/key-id-schema.js.map +1 -0
- package/dist/core/keybindings-schema.d.ts +4 -0
- package/dist/core/keybindings-schema.d.ts.map +1 -0
- package/dist/core/keybindings-schema.js +20 -0
- package/dist/core/keybindings-schema.js.map +1 -0
- package/dist/core/keybindings.d.ts +226 -79
- package/dist/core/keybindings.d.ts.map +1 -1
- package/dist/core/keybindings.js +25 -20
- package/dist/core/keybindings.js.map +1 -1
- package/dist/core/model-config.d.ts +685 -164
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +22 -176
- package/dist/core/model-config.js.map +1 -1
- package/dist/core/project-trust.d.ts.map +1 -1
- package/dist/core/project-trust.js +2 -1
- package/dist/core/project-trust.js.map +1 -1
- package/dist/core/resource-loader-context-files.d.ts.map +1 -1
- package/dist/core/resource-loader-context-files.js +10 -6
- package/dist/core/resource-loader-context-files.js.map +1 -1
- package/dist/core/settings-defaults.d.ts +80 -0
- package/dist/core/settings-defaults.d.ts.map +1 -0
- package/dist/core/settings-defaults.js +81 -0
- package/dist/core/settings-defaults.js.map +1 -0
- package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-basic-accessors.js +34 -29
- package/dist/core/settings-manager-basic-accessors.js.map +1 -1
- package/dist/core/settings-manager-resource-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-resource-accessors.js +10 -9
- package/dist/core/settings-manager-resource-accessors.js.map +1 -1
- package/dist/core/settings-manager-ui-accessors.d.ts.map +1 -1
- package/dist/core/settings-manager-ui-accessors.js +26 -18
- package/dist/core/settings-manager-ui-accessors.js.map +1 -1
- package/dist/core/settings-schema.d.ts +292 -0
- package/dist/core/settings-schema.d.ts.map +1 -0
- package/dist/core/settings-schema.js +403 -0
- package/dist/core/settings-schema.js.map +1 -0
- package/dist/core/settings-types.d.ts +2 -181
- package/dist/core/settings-types.d.ts.map +1 -1
- package/dist/core/settings-types.js.map +1 -1
- package/dist/extensions/codemode/index.d.ts.map +1 -1
- package/dist/extensions/codemode/index.js +2 -1
- package/dist/extensions/codemode/index.js.map +1 -1
- package/dist/extensions/codemode/tool.d.ts +1 -1
- package/dist/extensions/codemode/tool.d.ts.map +1 -1
- package/dist/extensions/codemode/tool.js +2 -1
- package/dist/extensions/codemode/tool.js.map +1 -1
- package/dist/extensions/herdr/index.d.ts.map +1 -1
- package/dist/extensions/herdr/index.js +4 -1
- package/dist/extensions/herdr/index.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-items.js +2 -4
- package/dist/modes/interactive/components/settings-selector-items.js.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.d.ts.map +1 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js +2 -1
- package/dist/modes/interactive/components/settings-selector-submenus.js.map +1 -1
- package/dist/modes/interactive/theme/catppuccin-frappe.json +1 -1
- package/dist/modes/interactive/theme/catppuccin-latte.json +1 -1
- package/dist/modes/interactive/theme/catppuccin-macchiato.json +1 -1
- package/dist/modes/interactive/theme/catppuccin-mocha.json +1 -1
- package/dist/modes/interactive/theme/dark.json +1 -1
- package/dist/modes/interactive/theme/light.json +1 -1
- package/dist/modes/interactive/theme/theme-class.d.ts +3 -12
- package/dist/modes/interactive/theme/theme-class.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-class.js +2 -9
- package/dist/modes/interactive/theme/theme-class.js.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-loading.js +3 -21
- package/dist/modes/interactive/theme/theme-loading.js.map +1 -1
- package/dist/modes/interactive/theme/theme-parse.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-parse.js +3 -0
- package/dist/modes/interactive/theme/theme-parse.js.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.d.ts +5 -224
- package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -1
- package/dist/modes/interactive/theme/theme-schema.js +47 -72
- package/dist/modes/interactive/theme/theme-schema.js.map +1 -1
- package/dist/modes/interactive/theme/theme-tokens.d.ts +262 -0
- package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
- package/dist/modes/interactive/theme/theme-tokens.js +126 -0
- package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
- package/docs/compaction/reference.md +1 -1
- package/docs/compaction.md +2 -2
- package/docs/keybindings.md +2 -0
- package/docs/models.md +2 -0
- package/docs/providers.md +1 -1
- package/docs/settings.md +2 -0
- package/docs/themes/reference.md +2 -2
- package/docs/themes.md +3 -1
- package/examples/extensions/dynamic-resources/dynamic.json +1 -1
- package/npm-shrinkwrap.json +36 -36
- package/package.json +5 -3
- package/schemas/keybindings.schema.json +413 -0
- package/schemas/models.schema.json +1178 -0
- package/schemas/settings.schema.json +940 -0
- package/schemas/theme.schema.json +369 -0
- package/dist/modes/interactive/theme/theme-schema.json +0 -361
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;
|
|
1
|
+
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAWxD,OAAO,EAAE,KAAK,MAAM,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAqB5C,uGAAuG;AACvG,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUlC,CAAC;AAEF,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiBzB,CAAC;AAEH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAcvB,CAAC;AAEH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AW,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE9D;IAED,cAAc,IAAI,SAAS,MAAM,EAAE,CAElC;IAED,QAAQ,IAAI,MAAM,GAAG,SAAS,CAE7B;CACD"}
|
|
@@ -1,58 +1,13 @@
|
|
|
1
1
|
/** Immutable, credential-blind models.json snapshot. */
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { ProviderCompatSchema } from "@bastani/pi-ai/providers/compat-schema";
|
|
4
|
+
import { ModelCostSchema, ModelInputLimitsSchema, ModelInputModalitySchema, ModelPromptCacheSchema, ThinkingLevelMapSchema, } from "@bastani/pi-ai/providers/model-schema";
|
|
3
5
|
import { Type } from "typebox";
|
|
4
6
|
import { Compile } from "typebox/compile";
|
|
5
7
|
import { stripJsonComments } from "../utils/json.js";
|
|
6
8
|
import { normalizePath } from "../utils/paths.js";
|
|
7
9
|
import { stripBom } from "../utils/text.js";
|
|
8
10
|
import { normalizeProviderKeys } from "./azure-provider-compat.js";
|
|
9
|
-
const PercentileCutoffsSchema = Type.Object({
|
|
10
|
-
p50: Type.Optional(Type.Number()),
|
|
11
|
-
p75: Type.Optional(Type.Number()),
|
|
12
|
-
p90: Type.Optional(Type.Number()),
|
|
13
|
-
p99: Type.Optional(Type.Number()),
|
|
14
|
-
});
|
|
15
|
-
const OpenRouterRoutingSchema = Type.Object({
|
|
16
|
-
allow_fallbacks: Type.Optional(Type.Boolean()),
|
|
17
|
-
require_parameters: Type.Optional(Type.Boolean()),
|
|
18
|
-
data_collection: Type.Optional(Type.Union([Type.Literal("deny"), Type.Literal("allow")])),
|
|
19
|
-
zdr: Type.Optional(Type.Boolean()),
|
|
20
|
-
enforce_distillable_text: Type.Optional(Type.Boolean()),
|
|
21
|
-
order: Type.Optional(Type.Array(Type.String())),
|
|
22
|
-
only: Type.Optional(Type.Array(Type.String())),
|
|
23
|
-
ignore: Type.Optional(Type.Array(Type.String())),
|
|
24
|
-
quantizations: Type.Optional(Type.Array(Type.String())),
|
|
25
|
-
sort: Type.Optional(Type.Union([
|
|
26
|
-
Type.String(),
|
|
27
|
-
Type.Object({
|
|
28
|
-
by: Type.Optional(Type.String()),
|
|
29
|
-
partition: Type.Optional(Type.Union([Type.String(), Type.Null()])),
|
|
30
|
-
}),
|
|
31
|
-
])),
|
|
32
|
-
max_price: Type.Optional(Type.Object({
|
|
33
|
-
prompt: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
34
|
-
completion: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
35
|
-
image: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
36
|
-
audio: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
37
|
-
request: Type.Optional(Type.Union([Type.Number(), Type.String()])),
|
|
38
|
-
})),
|
|
39
|
-
preferred_min_throughput: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),
|
|
40
|
-
preferred_max_latency: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),
|
|
41
|
-
});
|
|
42
|
-
const VercelGatewayRoutingSchema = Type.Object({
|
|
43
|
-
only: Type.Optional(Type.Array(Type.String())),
|
|
44
|
-
order: Type.Optional(Type.Array(Type.String())),
|
|
45
|
-
});
|
|
46
|
-
const ThinkingLevelMapValueSchema = Type.Union([Type.String(), Type.Null()]);
|
|
47
|
-
const ThinkingLevelMapSchema = Type.Object({
|
|
48
|
-
off: Type.Optional(ThinkingLevelMapValueSchema),
|
|
49
|
-
minimal: Type.Optional(ThinkingLevelMapValueSchema),
|
|
50
|
-
low: Type.Optional(ThinkingLevelMapValueSchema),
|
|
51
|
-
medium: Type.Optional(ThinkingLevelMapValueSchema),
|
|
52
|
-
high: Type.Optional(ThinkingLevelMapValueSchema),
|
|
53
|
-
xhigh: Type.Optional(ThinkingLevelMapValueSchema),
|
|
54
|
-
max: Type.Optional(ThinkingLevelMapValueSchema),
|
|
55
|
-
});
|
|
56
11
|
const SamplingParamsSchema = Type.Record(Type.String(), Type.Unknown());
|
|
57
12
|
const SamplingParamsByThinkingLevelSchema = Type.Object({
|
|
58
13
|
off: Type.Optional(SamplingParamsSchema),
|
|
@@ -63,117 +18,14 @@ const SamplingParamsByThinkingLevelSchema = Type.Object({
|
|
|
63
18
|
xhigh: Type.Optional(SamplingParamsSchema),
|
|
64
19
|
max: Type.Optional(SamplingParamsSchema),
|
|
65
20
|
});
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const OpenAICompletionsCompatSchema = Type.Object({
|
|
73
|
-
supportsStore: Type.Optional(Type.Boolean()),
|
|
74
|
-
supportsDeveloperRole: Type.Optional(Type.Boolean()),
|
|
75
|
-
supportsReasoningEffort: Type.Optional(Type.Boolean()),
|
|
76
|
-
supportsUsageInStreaming: Type.Optional(Type.Boolean()),
|
|
77
|
-
supportsFinishReason: Type.Optional(Type.Boolean()),
|
|
78
|
-
maxTokensField: Type.Optional(Type.Union([Type.Literal("max_completion_tokens"), Type.Literal("max_tokens")])),
|
|
79
|
-
requiresToolResultName: Type.Optional(Type.Boolean()),
|
|
80
|
-
requiresAssistantAfterToolResult: Type.Optional(Type.Boolean()),
|
|
81
|
-
requiresThinkingAsText: Type.Optional(Type.Boolean()),
|
|
82
|
-
requiresReasoningContentOnAssistantMessages: Type.Optional(Type.Boolean()),
|
|
83
|
-
thinkingFormat: Type.Optional(Type.Union([
|
|
84
|
-
Type.Literal("openai"),
|
|
85
|
-
Type.Literal("openrouter"),
|
|
86
|
-
Type.Literal("together"),
|
|
87
|
-
Type.Literal("baseten"),
|
|
88
|
-
Type.Literal("deepseek"),
|
|
89
|
-
Type.Literal("zai"),
|
|
90
|
-
Type.Literal("qwen"),
|
|
91
|
-
Type.Literal("chat-template"),
|
|
92
|
-
Type.Literal("qwen-chat-template"),
|
|
93
|
-
Type.Literal("string-thinking"),
|
|
94
|
-
Type.Literal("ant-ling"),
|
|
95
|
-
])),
|
|
96
|
-
chatTemplateKwargs: Type.Optional(Type.Record(Type.String(), ChatTemplateKwargSchema)),
|
|
97
|
-
chatTemplateArgs: Type.Optional(Type.Record(Type.String(), ChatTemplateKwargSchema)),
|
|
98
|
-
cacheControlFormat: Type.Optional(Type.Literal("anthropic")),
|
|
99
|
-
openRouterRouting: Type.Optional(OpenRouterRoutingSchema),
|
|
100
|
-
vercelGatewayRouting: Type.Optional(VercelGatewayRoutingSchema),
|
|
101
|
-
supportsOpenAIGrammarTools: Type.Optional(Type.Boolean()),
|
|
102
|
-
supportsStrictMode: Type.Optional(Type.Boolean()),
|
|
103
|
-
supportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),
|
|
104
|
-
supportsMidConvoToolAdditions: Type.Optional(Type.Boolean()),
|
|
105
|
-
sendSessionAffinityHeaders: Type.Optional(Type.Boolean()),
|
|
106
|
-
sessionAffinityFormat: Type.Optional(Type.Union([Type.Literal("openai"), Type.Literal("openai-nosession"), Type.Literal("openrouter")])),
|
|
107
|
-
supportsLongCacheRetention: Type.Optional(Type.Boolean()),
|
|
108
|
-
vllmPriority: Type.Optional(Type.Number()),
|
|
109
|
-
supportsThinkingTokenBudget: Type.Optional(Type.Boolean()),
|
|
110
|
-
});
|
|
111
|
-
const OpenAIResponsesCompatSchema = Type.Object({
|
|
112
|
-
supportsDeveloperRole: Type.Optional(Type.Boolean()),
|
|
113
|
-
supportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),
|
|
114
|
-
sessionAffinityFormat: Type.Optional(Type.Union([Type.Literal("openai"), Type.Literal("openai-nosession"), Type.Literal("openrouter")])),
|
|
115
|
-
supportsLongCacheRetention: Type.Optional(Type.Boolean()),
|
|
116
|
-
supportsStrictMode: Type.Optional(Type.Boolean()),
|
|
117
|
-
supportsOpenAIGrammarTools: Type.Optional(Type.Boolean()),
|
|
118
|
-
supportsAdditionalTools: Type.Optional(Type.Boolean()),
|
|
119
|
-
supportsToolSearch: Type.Optional(Type.Boolean()),
|
|
120
|
-
supportsMaxOutputTokens: Type.Optional(Type.Boolean()),
|
|
121
|
-
});
|
|
122
|
-
const ModelCostRatesSchema = {
|
|
123
|
-
input: Type.Number(),
|
|
124
|
-
output: Type.Number(),
|
|
125
|
-
cacheRead: Type.Number(),
|
|
126
|
-
cacheWrite: Type.Number(),
|
|
127
|
-
};
|
|
128
|
-
const ModelCostTierSchema = Type.Object({
|
|
129
|
-
inputTokensAbove: Type.Number(),
|
|
130
|
-
...ModelCostRatesSchema,
|
|
131
|
-
});
|
|
132
|
-
const ModelCostSchema = Type.Object({
|
|
133
|
-
...ModelCostRatesSchema,
|
|
134
|
-
tiers: Type.Optional(Type.Array(ModelCostTierSchema)),
|
|
135
|
-
});
|
|
136
|
-
const ModelPromptCacheSchema = Type.Object({
|
|
137
|
-
short: Type.Optional(Type.Number({ exclusiveMinimum: 0 })),
|
|
138
|
-
long: Type.Optional(Type.Number({ exclusiveMinimum: 0 })),
|
|
139
|
-
});
|
|
140
|
-
const ImageResizeSchema = Type.Object({
|
|
141
|
-
maxWidth: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
142
|
-
maxHeight: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
143
|
-
maxBytes: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
144
|
-
jpegQuality: Type.Optional(Type.Integer({ minimum: 1, maximum: 100 })),
|
|
145
|
-
});
|
|
146
|
-
const ModelInputLimitsSchema = Type.Object({
|
|
147
|
-
maxRequestBytes: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
148
|
-
images: Type.Optional(Type.Object({
|
|
149
|
-
resize: Type.Optional(ImageResizeSchema),
|
|
150
|
-
maxPerMessage: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
151
|
-
maxPerRequest: Type.Optional(Type.Integer({ minimum: 1 })),
|
|
21
|
+
const PositiveTokenCountSchema = Type.Number({ exclusiveMinimum: 0 });
|
|
22
|
+
/** Everything pi-ai defines for compatibility, plus Atomic's alias for the grammar-tool capability. */
|
|
23
|
+
export const ModelsJsonCompatSchema = Type.Object({
|
|
24
|
+
...ProviderCompatSchema.properties,
|
|
25
|
+
supportsGrammarTools: Type.Optional(Type.Boolean({
|
|
26
|
+
description: "Atomic alias for supportsOpenAIGrammarTools. The canonical field wins if both are set.",
|
|
152
27
|
})),
|
|
153
|
-
});
|
|
154
|
-
const AnthropicMessagesCompatSchema = Type.Object({
|
|
155
|
-
supportsEagerToolInputStreaming: Type.Optional(Type.Boolean()),
|
|
156
|
-
supportsLongCacheRetention: Type.Optional(Type.Boolean()),
|
|
157
|
-
sendSessionAffinityHeaders: Type.Optional(Type.Boolean()),
|
|
158
|
-
supportsCacheControlOnTools: Type.Optional(Type.Boolean()),
|
|
159
|
-
supportsTemperature: Type.Optional(Type.Boolean()),
|
|
160
|
-
forceAdaptiveThinking: Type.Optional(Type.Boolean()),
|
|
161
|
-
allowEmptySignature: Type.Optional(Type.Boolean()),
|
|
162
|
-
supportsStrictTools: Type.Optional(Type.Boolean()),
|
|
163
|
-
supportsMidConvoEffort: Type.Optional(Type.Boolean()),
|
|
164
|
-
supportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),
|
|
165
|
-
supportsMidConvoToolChanges: Type.Optional(Type.Boolean()),
|
|
166
|
-
enforcesPreservedThinkingBinding: Type.Optional(Type.Boolean()),
|
|
167
|
-
allowedFallbackModels: Type.Optional(Type.Array(Type.Object({
|
|
168
|
-
provider: Type.String({ minLength: 1 }),
|
|
169
|
-
model: Type.String({ minLength: 1 }),
|
|
170
|
-
cost: ModelCostSchema,
|
|
171
|
-
}), { maxItems: 3 })),
|
|
172
|
-
});
|
|
173
|
-
const ProviderCompatSchema = Type.Union([OpenAICompletionsCompatSchema, OpenAIResponsesCompatSchema, AnthropicMessagesCompatSchema], {
|
|
174
|
-
// OpenAI branches permit unknown fields; enforce fallback metadata across every branch.
|
|
175
|
-
allOf: [Type.Object({ allowedFallbackModels: AnthropicMessagesCompatSchema.properties.allowedFallbackModels })],
|
|
176
|
-
});
|
|
28
|
+
}, { description: "Provider and model compatibility overrides.", additionalProperties: true });
|
|
177
29
|
const ModelDefinitionSchema = Type.Object({
|
|
178
30
|
id: Type.String({ minLength: 1 }),
|
|
179
31
|
name: Type.Optional(Type.String({ minLength: 1 })),
|
|
@@ -181,37 +33,31 @@ const ModelDefinitionSchema = Type.Object({
|
|
|
181
33
|
baseUrl: Type.Optional(Type.String({ minLength: 1 })),
|
|
182
34
|
reasoning: Type.Optional(Type.Boolean()),
|
|
183
35
|
thinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),
|
|
184
|
-
input: Type.Optional(Type.Array(
|
|
36
|
+
input: Type.Optional(Type.Array(ModelInputModalitySchema)),
|
|
185
37
|
inputLimits: Type.Optional(ModelInputLimitsSchema),
|
|
186
38
|
cost: Type.Optional(ModelCostSchema),
|
|
187
39
|
promptCache: Type.Optional(ModelPromptCacheSchema),
|
|
188
|
-
contextWindow: Type.Optional(
|
|
189
|
-
maxTokens: Type.Optional(
|
|
40
|
+
contextWindow: Type.Optional(PositiveTokenCountSchema),
|
|
41
|
+
maxTokens: Type.Optional(PositiveTokenCountSchema),
|
|
190
42
|
samplingParams: Type.Optional(SamplingParamsSchema),
|
|
191
43
|
samplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),
|
|
192
44
|
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
193
|
-
compat: Type.Optional(
|
|
45
|
+
compat: Type.Optional(ModelsJsonCompatSchema),
|
|
194
46
|
});
|
|
195
47
|
const ModelOverrideSchema = Type.Object({
|
|
196
48
|
name: Type.Optional(Type.String({ minLength: 1 })),
|
|
197
49
|
reasoning: Type.Optional(Type.Boolean()),
|
|
198
50
|
thinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),
|
|
199
|
-
input: Type.Optional(Type.Array(
|
|
51
|
+
input: Type.Optional(Type.Array(ModelInputModalitySchema)),
|
|
200
52
|
inputLimits: Type.Optional(ModelInputLimitsSchema),
|
|
201
|
-
cost: Type.Optional(Type.
|
|
202
|
-
input: Type.Optional(Type.Number()),
|
|
203
|
-
output: Type.Optional(Type.Number()),
|
|
204
|
-
cacheRead: Type.Optional(Type.Number()),
|
|
205
|
-
cacheWrite: Type.Optional(Type.Number()),
|
|
206
|
-
tiers: Type.Optional(Type.Array(ModelCostTierSchema)),
|
|
207
|
-
})),
|
|
53
|
+
cost: Type.Optional(Type.Partial(ModelCostSchema)),
|
|
208
54
|
promptCache: Type.Optional(ModelPromptCacheSchema),
|
|
209
|
-
contextWindow: Type.Optional(
|
|
210
|
-
maxTokens: Type.Optional(
|
|
55
|
+
contextWindow: Type.Optional(PositiveTokenCountSchema),
|
|
56
|
+
maxTokens: Type.Optional(PositiveTokenCountSchema),
|
|
211
57
|
samplingParams: Type.Optional(SamplingParamsSchema),
|
|
212
58
|
samplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),
|
|
213
59
|
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
214
|
-
compat: Type.Optional(
|
|
60
|
+
compat: Type.Optional(ModelsJsonCompatSchema),
|
|
215
61
|
});
|
|
216
62
|
const ProviderConfigSchema = Type.Object({
|
|
217
63
|
name: Type.Optional(Type.String({ minLength: 1 })),
|
|
@@ -220,12 +66,13 @@ const ProviderConfigSchema = Type.Object({
|
|
|
220
66
|
api: Type.Optional(Type.String({ minLength: 1 })),
|
|
221
67
|
oauth: Type.Optional(Type.Literal("radius")),
|
|
222
68
|
headers: Type.Optional(Type.Record(Type.String(), Type.String())),
|
|
223
|
-
compat: Type.Optional(
|
|
69
|
+
compat: Type.Optional(ModelsJsonCompatSchema),
|
|
224
70
|
authHeader: Type.Optional(Type.Boolean()),
|
|
225
71
|
models: Type.Optional(Type.Array(ModelDefinitionSchema)),
|
|
226
72
|
modelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),
|
|
227
73
|
});
|
|
228
|
-
const ModelsConfigSchema = Type.Object({
|
|
74
|
+
export const ModelsConfigSchema = Type.Object({
|
|
75
|
+
$schema: Type.Optional(Type.String()),
|
|
229
76
|
providers: Type.Record(Type.String(), ProviderConfigSchema),
|
|
230
77
|
});
|
|
231
78
|
const validateModelsConfig = Compile(ModelsConfigSchema);
|
|
@@ -283,9 +130,8 @@ export class ModelConfig {
|
|
|
283
130
|
.join("\n") || "Unknown schema error";
|
|
284
131
|
return new ModelConfig(new Map(), `Invalid models.json schema:\n${errors}\n\nFile: ${path}`);
|
|
285
132
|
}
|
|
286
|
-
const config = parsed;
|
|
287
133
|
const providers = new Map();
|
|
288
|
-
for (const [providerId, provider] of Object.entries(normalizeProviderKeys(
|
|
134
|
+
for (const [providerId, provider] of Object.entries(normalizeProviderKeys(parsed.providers))) {
|
|
289
135
|
providers.set(providerId, deepFreeze(structuredClone(provider)));
|
|
290
136
|
}
|
|
291
137
|
return new ModelConfig(providers);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-config.js","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAe,IAAI,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,MAAM,uBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC;IAC3C,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACjC,GAAG,EAAE,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;IACjC,GAAG,EAAE,IAAI,CAAC,QAAQ,C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AK,CAAC,OAAO,EAAE,CAAC;iBACtE,IAAI,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC;YACxC,OAAO,IAAI,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE,gCAAgC,MAAM,aAAa,IAAI,EAAE,CAAC,CAAC;QAC9F,CAAC;QAED,MAAM,MAAM,GAAG,MAAoB,CAAC;QACpC,MAAM,SAAS,GAAG,IAAI,GAAG,EAA8B,CAAC;QACxD,KAAK,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YAC9F,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,cAAc;QACb,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD","sourcesContent":["/** Immutable, credential-blind models.json snapshot. */\n\nimport { readFile } from \"node:fs/promises\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { stripJsonComments } from \"../utils/json.ts\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { normalizeProviderKeys } from \"./azure-provider-compat.js\";\n\nconst PercentileCutoffsSchema = Type.Object({\n\tp50: Type.Optional(Type.Number()),\n\tp75: Type.Optional(Type.Number()),\n\tp90: Type.Optional(Type.Number()),\n\tp99: Type.Optional(Type.Number()),\n});\n\nconst OpenRouterRoutingSchema = Type.Object({\n\tallow_fallbacks: Type.Optional(Type.Boolean()),\n\trequire_parameters: Type.Optional(Type.Boolean()),\n\tdata_collection: Type.Optional(Type.Union([Type.Literal(\"deny\"), Type.Literal(\"allow\")])),\n\tzdr: Type.Optional(Type.Boolean()),\n\tenforce_distillable_text: Type.Optional(Type.Boolean()),\n\torder: Type.Optional(Type.Array(Type.String())),\n\tonly: Type.Optional(Type.Array(Type.String())),\n\tignore: Type.Optional(Type.Array(Type.String())),\n\tquantizations: Type.Optional(Type.Array(Type.String())),\n\tsort: Type.Optional(\n\t\tType.Union([\n\t\t\tType.String(),\n\t\t\tType.Object({\n\t\t\t\tby: Type.Optional(Type.String()),\n\t\t\t\tpartition: Type.Optional(Type.Union([Type.String(), Type.Null()])),\n\t\t\t}),\n\t\t]),\n\t),\n\tmax_price: Type.Optional(\n\t\tType.Object({\n\t\t\tprompt: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\tcompletion: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\timage: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\taudio: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t\trequest: Type.Optional(Type.Union([Type.Number(), Type.String()])),\n\t\t}),\n\t),\n\tpreferred_min_throughput: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),\n\tpreferred_max_latency: Type.Optional(Type.Union([Type.Number(), PercentileCutoffsSchema])),\n});\n\nconst VercelGatewayRoutingSchema = Type.Object({\n\tonly: Type.Optional(Type.Array(Type.String())),\n\torder: Type.Optional(Type.Array(Type.String())),\n});\n\nconst ThinkingLevelMapValueSchema = Type.Union([Type.String(), Type.Null()]);\nconst ThinkingLevelMapSchema = Type.Object({\n\toff: Type.Optional(ThinkingLevelMapValueSchema),\n\tminimal: Type.Optional(ThinkingLevelMapValueSchema),\n\tlow: Type.Optional(ThinkingLevelMapValueSchema),\n\tmedium: Type.Optional(ThinkingLevelMapValueSchema),\n\thigh: Type.Optional(ThinkingLevelMapValueSchema),\n\txhigh: Type.Optional(ThinkingLevelMapValueSchema),\n\tmax: Type.Optional(ThinkingLevelMapValueSchema),\n});\n\nconst SamplingParamsSchema = Type.Record(Type.String(), Type.Unknown());\nconst SamplingParamsByThinkingLevelSchema = Type.Object({\n\toff: Type.Optional(SamplingParamsSchema),\n\tminimal: Type.Optional(SamplingParamsSchema),\n\tlow: Type.Optional(SamplingParamsSchema),\n\tmedium: Type.Optional(SamplingParamsSchema),\n\thigh: Type.Optional(SamplingParamsSchema),\n\txhigh: Type.Optional(SamplingParamsSchema),\n\tmax: Type.Optional(SamplingParamsSchema),\n});\n\nconst ChatTemplateKwargScalarSchema = Type.Union([Type.String(), Type.Number(), Type.Boolean(), Type.Null()]);\nconst ChatTemplateKwargVariableSchema = Type.Object({\n\t$var: Type.Union([Type.Literal(\"thinking.enabled\"), Type.Literal(\"thinking.effort\")]),\n\tomitWhenOff: Type.Optional(Type.Boolean()),\n});\nconst ChatTemplateKwargSchema = Type.Union([ChatTemplateKwargScalarSchema, ChatTemplateKwargVariableSchema]);\n\nconst OpenAICompletionsCompatSchema = Type.Object({\n\tsupportsStore: Type.Optional(Type.Boolean()),\n\tsupportsDeveloperRole: Type.Optional(Type.Boolean()),\n\tsupportsReasoningEffort: Type.Optional(Type.Boolean()),\n\tsupportsUsageInStreaming: Type.Optional(Type.Boolean()),\n\tsupportsFinishReason: Type.Optional(Type.Boolean()),\n\tmaxTokensField: Type.Optional(Type.Union([Type.Literal(\"max_completion_tokens\"), Type.Literal(\"max_tokens\")])),\n\trequiresToolResultName: Type.Optional(Type.Boolean()),\n\trequiresAssistantAfterToolResult: Type.Optional(Type.Boolean()),\n\trequiresThinkingAsText: Type.Optional(Type.Boolean()),\n\trequiresReasoningContentOnAssistantMessages: Type.Optional(Type.Boolean()),\n\tthinkingFormat: Type.Optional(\n\t\tType.Union([\n\t\t\tType.Literal(\"openai\"),\n\t\t\tType.Literal(\"openrouter\"),\n\t\t\tType.Literal(\"together\"),\n\t\t\tType.Literal(\"baseten\"),\n\t\t\tType.Literal(\"deepseek\"),\n\t\t\tType.Literal(\"zai\"),\n\t\t\tType.Literal(\"qwen\"),\n\t\t\tType.Literal(\"chat-template\"),\n\t\t\tType.Literal(\"qwen-chat-template\"),\n\t\t\tType.Literal(\"string-thinking\"),\n\t\t\tType.Literal(\"ant-ling\"),\n\t\t]),\n\t),\n\tchatTemplateKwargs: Type.Optional(Type.Record(Type.String(), ChatTemplateKwargSchema)),\n\tchatTemplateArgs: Type.Optional(Type.Record(Type.String(), ChatTemplateKwargSchema)),\n\tcacheControlFormat: Type.Optional(Type.Literal(\"anthropic\")),\n\topenRouterRouting: Type.Optional(OpenRouterRoutingSchema),\n\tvercelGatewayRouting: Type.Optional(VercelGatewayRoutingSchema),\n\tsupportsOpenAIGrammarTools: Type.Optional(Type.Boolean()),\n\tsupportsStrictMode: Type.Optional(Type.Boolean()),\n\tsupportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),\n\tsupportsMidConvoToolAdditions: Type.Optional(Type.Boolean()),\n\tsendSessionAffinityHeaders: Type.Optional(Type.Boolean()),\n\tsessionAffinityFormat: Type.Optional(\n\t\tType.Union([Type.Literal(\"openai\"), Type.Literal(\"openai-nosession\"), Type.Literal(\"openrouter\")]),\n\t),\n\tsupportsLongCacheRetention: Type.Optional(Type.Boolean()),\n\tvllmPriority: Type.Optional(Type.Number()),\n\tsupportsThinkingTokenBudget: Type.Optional(Type.Boolean()),\n});\n\nconst OpenAIResponsesCompatSchema = Type.Object({\n\tsupportsDeveloperRole: Type.Optional(Type.Boolean()),\n\tsupportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),\n\tsessionAffinityFormat: Type.Optional(\n\t\tType.Union([Type.Literal(\"openai\"), Type.Literal(\"openai-nosession\"), Type.Literal(\"openrouter\")]),\n\t),\n\tsupportsLongCacheRetention: Type.Optional(Type.Boolean()),\n\tsupportsStrictMode: Type.Optional(Type.Boolean()),\n\tsupportsOpenAIGrammarTools: Type.Optional(Type.Boolean()),\n\tsupportsAdditionalTools: Type.Optional(Type.Boolean()),\n\tsupportsToolSearch: Type.Optional(Type.Boolean()),\n\tsupportsMaxOutputTokens: Type.Optional(Type.Boolean()),\n});\n\nconst ModelCostRatesSchema = {\n\tinput: Type.Number(),\n\toutput: Type.Number(),\n\tcacheRead: Type.Number(),\n\tcacheWrite: Type.Number(),\n};\nconst ModelCostTierSchema = Type.Object({\n\tinputTokensAbove: Type.Number(),\n\t...ModelCostRatesSchema,\n});\nconst ModelCostSchema = Type.Object({\n\t...ModelCostRatesSchema,\n\ttiers: Type.Optional(Type.Array(ModelCostTierSchema)),\n});\nconst ModelPromptCacheSchema = Type.Object({\n\tshort: Type.Optional(Type.Number({ exclusiveMinimum: 0 })),\n\tlong: Type.Optional(Type.Number({ exclusiveMinimum: 0 })),\n});\nconst ImageResizeSchema = Type.Object({\n\tmaxWidth: Type.Optional(Type.Integer({ minimum: 1 })),\n\tmaxHeight: Type.Optional(Type.Integer({ minimum: 1 })),\n\tmaxBytes: Type.Optional(Type.Integer({ minimum: 1 })),\n\tjpegQuality: Type.Optional(Type.Integer({ minimum: 1, maximum: 100 })),\n});\nconst ModelInputLimitsSchema = Type.Object({\n\tmaxRequestBytes: Type.Optional(Type.Integer({ minimum: 1 })),\n\timages: Type.Optional(\n\t\tType.Object({\n\t\t\tresize: Type.Optional(ImageResizeSchema),\n\t\t\tmaxPerMessage: Type.Optional(Type.Integer({ minimum: 1 })),\n\t\t\tmaxPerRequest: Type.Optional(Type.Integer({ minimum: 1 })),\n\t\t}),\n\t),\n});\n\nconst AnthropicMessagesCompatSchema = Type.Object({\n\tsupportsEagerToolInputStreaming: Type.Optional(Type.Boolean()),\n\tsupportsLongCacheRetention: Type.Optional(Type.Boolean()),\n\tsendSessionAffinityHeaders: Type.Optional(Type.Boolean()),\n\tsupportsCacheControlOnTools: Type.Optional(Type.Boolean()),\n\tsupportsTemperature: Type.Optional(Type.Boolean()),\n\tforceAdaptiveThinking: Type.Optional(Type.Boolean()),\n\tallowEmptySignature: Type.Optional(Type.Boolean()),\n\tsupportsStrictTools: Type.Optional(Type.Boolean()),\n\tsupportsMidConvoEffort: Type.Optional(Type.Boolean()),\n\tsupportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),\n\tsupportsMidConvoToolChanges: Type.Optional(Type.Boolean()),\n\tenforcesPreservedThinkingBinding: Type.Optional(Type.Boolean()),\n\tallowedFallbackModels: Type.Optional(\n\t\tType.Array(\n\t\t\tType.Object({\n\t\t\t\tprovider: Type.String({ minLength: 1 }),\n\t\t\t\tmodel: Type.String({ minLength: 1 }),\n\t\t\t\tcost: ModelCostSchema,\n\t\t\t}),\n\t\t\t{ maxItems: 3 },\n\t\t),\n\t),\n});\n\nconst ProviderCompatSchema = Type.Union(\n\t[OpenAICompletionsCompatSchema, OpenAIResponsesCompatSchema, AnthropicMessagesCompatSchema],\n\t{\n\t\t// OpenAI branches permit unknown fields; enforce fallback metadata across every branch.\n\t\tallOf: [Type.Object({ allowedFallbackModels: AnthropicMessagesCompatSchema.properties.allowedFallbackModels })],\n\t},\n);\n\nconst ModelDefinitionSchema = Type.Object({\n\tid: Type.String({ minLength: 1 }),\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(Type.Union([Type.Literal(\"text\"), Type.Literal(\"image\"), Type.Literal(\"pdf\")]))),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(ModelCostSchema),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(Type.Number()),\n\tmaxTokens: Type.Optional(Type.Number()),\n\tsamplingParams: Type.Optional(SamplingParamsSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ModelOverrideSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(Type.Union([Type.Literal(\"text\"), Type.Literal(\"image\"), Type.Literal(\"pdf\")]))),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(\n\t\tType.Object({\n\t\t\tinput: Type.Optional(Type.Number()),\n\t\t\toutput: Type.Optional(Type.Number()),\n\t\t\tcacheRead: Type.Optional(Type.Number()),\n\t\t\tcacheWrite: Type.Optional(Type.Number()),\n\t\t\ttiers: Type.Optional(Type.Array(ModelCostTierSchema)),\n\t\t}),\n\t),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(Type.Number()),\n\tmaxTokens: Type.Optional(Type.Number()),\n\tsamplingParams: Type.Optional(SamplingParamsSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ProviderCompatSchema),\n});\n\nconst ProviderConfigSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\tapiKey: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\toauth: Type.Optional(Type.Literal(\"radius\")),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ProviderCompatSchema),\n\tauthHeader: Type.Optional(Type.Boolean()),\n\tmodels: Type.Optional(Type.Array(ModelDefinitionSchema)),\n\tmodelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),\n});\n\nconst ModelsConfigSchema = Type.Object({\n\tproviders: Type.Record(Type.String(), ProviderConfigSchema),\n});\nconst validateModelsConfig = Compile(ModelsConfigSchema);\n\nexport type ModelsJsonModel = Static<typeof ModelDefinitionSchema>;\nexport type ModelsJsonModelOverride = Static<typeof ModelOverrideSchema>;\nexport type ModelsJsonProvider = Static<typeof ProviderConfigSchema>;\ntype ModelsJson = Static<typeof ModelsConfigSchema>;\n\nfunction formatValidationPath(error: TLocalizedValidationError): string {\n\tif (error.keyword === \"required\") {\n\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\tconst requiredProperty = requiredProperties?.[0];\n\t\tif (requiredProperty) {\n\t\t\tconst basePath = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\t\t\treturn basePath ? `${basePath}.${requiredProperty}` : requiredProperty;\n\t\t}\n\t}\n\tconst path = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\treturn path || \"root\";\n}\n\nfunction deepFreeze<T>(value: T): T {\n\tif (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n\tfor (const child of Object.values(value)) deepFreeze(child);\n\treturn Object.freeze(value);\n}\n\n/** One immutable load of models.json. */\nexport class ModelConfig {\n\tprivate readonly providers: ReadonlyMap<string, ModelsJsonProvider>;\n\tprivate readonly error: string | undefined;\n\n\tprivate constructor(providers: ReadonlyMap<string, ModelsJsonProvider>, error?: string) {\n\t\tthis.providers = providers;\n\t\tthis.error = error;\n\t}\n\n\tstatic async load(modelsJsonPath: string | undefined): Promise<ModelConfig> {\n\t\tif (!modelsJsonPath) return new ModelConfig(new Map());\n\t\tconst path = normalizePath(modelsJsonPath);\n\t\tlet content: string;\n\t\ttry {\n\t\t\tcontent = await readFile(path, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return new ModelConfig(new Map());\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to load models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(stripJsonComments(stripBom(content)));\n\t\t} catch (error) {\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to parse models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!validateModelsConfig.Check(parsed)) {\n\t\t\tconst errors =\n\t\t\t\tvalidateModelsConfig\n\t\t\t\t\t.Errors(parsed)\n\t\t\t\t\t.map((error) => ` - ${formatValidationPath(error)}: ${error.message}`)\n\t\t\t\t\t.join(\"\\n\") || \"Unknown schema error\";\n\t\t\treturn new ModelConfig(new Map(), `Invalid models.json schema:\\n${errors}\\n\\nFile: ${path}`);\n\t\t}\n\n\t\tconst config = parsed as ModelsJson;\n\t\tconst providers = new Map<string, ModelsJsonProvider>();\n\t\tfor (const [providerId, provider] of Object.entries(normalizeProviderKeys(config.providers))) {\n\t\t\tproviders.set(providerId, deepFreeze(structuredClone(provider)));\n\t\t}\n\t\treturn new ModelConfig(providers);\n\t}\n\n\tgetProvider(providerId: string): ModelsJsonProvider | undefined {\n\t\treturn this.providers.get(providerId);\n\t}\n\n\tgetProviderIds(): readonly string[] {\n\t\treturn [...this.providers.keys()];\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.error;\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"model-config.js","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,EACN,eAAe,EACf,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB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,CAAC,KAAK,EAAE,EAAE,CAAC,OAAO,oBAAoB,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;iBACtE,IAAI,CAAC,IAAI,CAAC,IAAI,sBAAsB,CAAC;YACxC,OAAO,IAAI,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE,gCAAgC,MAAM,aAAa,IAAI,EAAE,CAAC,CAAC;QAC9F,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,GAAG,EAA8B,CAAC;QACxD,KAAK,MAAM,CAAC,UAAU,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,qBAAqB,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;YAC9F,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,IAAI,WAAW,CAAC,SAAS,CAAC,CAAC;IACnC,CAAC;IAED,WAAW,CAAC,UAAkB;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACvC,CAAC;IAED,cAAc;QACb,OAAO,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD","sourcesContent":["/** Immutable, credential-blind models.json snapshot. */\n\nimport { readFile } from \"node:fs/promises\";\nimport { ProviderCompatSchema } from \"@bastani/pi-ai/providers/compat-schema\";\nimport {\n\tModelCostSchema,\n\tModelInputLimitsSchema,\n\tModelInputModalitySchema,\n\tModelPromptCacheSchema,\n\tThinkingLevelMapSchema,\n} from \"@bastani/pi-ai/providers/model-schema\";\nimport { type Static, Type } from \"typebox\";\nimport { Compile } from \"typebox/compile\";\nimport type { TLocalizedValidationError } from \"typebox/error\";\nimport { stripJsonComments } from \"../utils/json.ts\";\nimport { normalizePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { normalizeProviderKeys } from \"./azure-provider-compat.js\";\n\nconst SamplingParamsSchema = Type.Record(Type.String(), Type.Unknown());\nconst SamplingParamsByThinkingLevelSchema = Type.Object({\n\toff: Type.Optional(SamplingParamsSchema),\n\tminimal: Type.Optional(SamplingParamsSchema),\n\tlow: Type.Optional(SamplingParamsSchema),\n\tmedium: Type.Optional(SamplingParamsSchema),\n\thigh: Type.Optional(SamplingParamsSchema),\n\txhigh: Type.Optional(SamplingParamsSchema),\n\tmax: Type.Optional(SamplingParamsSchema),\n});\n\nconst PositiveTokenCountSchema = Type.Number({ exclusiveMinimum: 0 });\n\n/** Everything pi-ai defines for compatibility, plus Atomic's alias for the grammar-tool capability. */\nexport const ModelsJsonCompatSchema = Type.Object(\n\t{\n\t\t...ProviderCompatSchema.properties,\n\t\tsupportsGrammarTools: Type.Optional(\n\t\t\tType.Boolean({\n\t\t\t\tdescription: \"Atomic alias for supportsOpenAIGrammarTools. The canonical field wins if both are set.\",\n\t\t\t}),\n\t\t),\n\t},\n\t{ description: \"Provider and model compatibility overrides.\", additionalProperties: true },\n);\n\nconst ModelDefinitionSchema = Type.Object({\n\tid: Type.String({ minLength: 1 }),\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(ModelInputModalitySchema)),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(ModelCostSchema),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(PositiveTokenCountSchema),\n\tmaxTokens: Type.Optional(PositiveTokenCountSchema),\n\tsamplingParams: Type.Optional(SamplingParamsSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ModelsJsonCompatSchema),\n});\n\nconst ModelOverrideSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\treasoning: Type.Optional(Type.Boolean()),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\tinput: Type.Optional(Type.Array(ModelInputModalitySchema)),\n\tinputLimits: Type.Optional(ModelInputLimitsSchema),\n\tcost: Type.Optional(Type.Partial(ModelCostSchema)),\n\tpromptCache: Type.Optional(ModelPromptCacheSchema),\n\tcontextWindow: Type.Optional(PositiveTokenCountSchema),\n\tmaxTokens: Type.Optional(PositiveTokenCountSchema),\n\tsamplingParams: Type.Optional(SamplingParamsSchema),\n\tsamplingParamsByThinkingLevel: Type.Optional(SamplingParamsByThinkingLevelSchema),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ModelsJsonCompatSchema),\n});\n\nconst ProviderConfigSchema = Type.Object({\n\tname: Type.Optional(Type.String({ minLength: 1 })),\n\tbaseUrl: Type.Optional(Type.String({ minLength: 1 })),\n\tapiKey: Type.Optional(Type.String({ minLength: 1 })),\n\tapi: Type.Optional(Type.String({ minLength: 1 })),\n\toauth: Type.Optional(Type.Literal(\"radius\")),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tcompat: Type.Optional(ModelsJsonCompatSchema),\n\tauthHeader: Type.Optional(Type.Boolean()),\n\tmodels: Type.Optional(Type.Array(ModelDefinitionSchema)),\n\tmodelOverrides: Type.Optional(Type.Record(Type.String(), ModelOverrideSchema)),\n});\n\nexport const ModelsConfigSchema = Type.Object({\n\t$schema: Type.Optional(Type.String()),\n\tproviders: Type.Record(Type.String(), ProviderConfigSchema),\n});\nconst validateModelsConfig = Compile(ModelsConfigSchema);\n\nexport type ModelsJsonModel = Static<typeof ModelDefinitionSchema>;\nexport type ModelsJsonModelOverride = Static<typeof ModelOverrideSchema>;\nexport type ModelsJsonProvider = Static<typeof ProviderConfigSchema>;\n\nfunction formatValidationPath(error: TLocalizedValidationError): string {\n\tif (error.keyword === \"required\") {\n\t\tconst requiredProperties = (error.params as { requiredProperties?: string[] }).requiredProperties;\n\t\tconst requiredProperty = requiredProperties?.[0];\n\t\tif (requiredProperty) {\n\t\t\tconst basePath = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\t\t\treturn basePath ? `${basePath}.${requiredProperty}` : requiredProperty;\n\t\t}\n\t}\n\tconst path = error.instancePath.replace(/^\\//, \"\").replace(/\\//g, \".\");\n\treturn path || \"root\";\n}\n\nfunction deepFreeze<T>(value: T): T {\n\tif (typeof value !== \"object\" || value === null || Object.isFrozen(value)) return value;\n\tfor (const child of Object.values(value)) deepFreeze(child);\n\treturn Object.freeze(value);\n}\n\n/** One immutable load of models.json. */\nexport class ModelConfig {\n\tprivate readonly providers: ReadonlyMap<string, ModelsJsonProvider>;\n\tprivate readonly error: string | undefined;\n\n\tprivate constructor(providers: ReadonlyMap<string, ModelsJsonProvider>, error?: string) {\n\t\tthis.providers = providers;\n\t\tthis.error = error;\n\t}\n\n\tstatic async load(modelsJsonPath: string | undefined): Promise<ModelConfig> {\n\t\tif (!modelsJsonPath) return new ModelConfig(new Map());\n\t\tconst path = normalizePath(modelsJsonPath);\n\t\tlet content: string;\n\t\ttry {\n\t\t\tcontent = await readFile(path, \"utf-8\");\n\t\t} catch (error) {\n\t\t\tif ((error as NodeJS.ErrnoException).code === \"ENOENT\") return new ModelConfig(new Map());\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to load models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tlet parsed: unknown;\n\t\ttry {\n\t\t\tparsed = JSON.parse(stripJsonComments(stripBom(content)));\n\t\t} catch (error) {\n\t\t\treturn new ModelConfig(\n\t\t\t\tnew Map(),\n\t\t\t\t`Failed to parse models.json: ${error instanceof Error ? error.message : error}\\n\\nFile: ${path}`,\n\t\t\t);\n\t\t}\n\n\t\tif (!validateModelsConfig.Check(parsed)) {\n\t\t\tconst errors =\n\t\t\t\tvalidateModelsConfig\n\t\t\t\t\t.Errors(parsed)\n\t\t\t\t\t.map((error) => ` - ${formatValidationPath(error)}: ${error.message}`)\n\t\t\t\t\t.join(\"\\n\") || \"Unknown schema error\";\n\t\t\treturn new ModelConfig(new Map(), `Invalid models.json schema:\\n${errors}\\n\\nFile: ${path}`);\n\t\t}\n\n\t\tconst providers = new Map<string, ModelsJsonProvider>();\n\t\tfor (const [providerId, provider] of Object.entries(normalizeProviderKeys(parsed.providers))) {\n\t\t\tproviders.set(providerId, deepFreeze(structuredClone(provider)));\n\t\t}\n\t\treturn new ModelConfig(providers);\n\t}\n\n\tgetProvider(providerId: string): ModelsJsonProvider | undefined {\n\t\treturn this.providers.get(providerId);\n\t}\n\n\tgetProviderIds(): readonly string[] {\n\t\treturn [...this.providers.keys()];\n\t}\n\n\tgetError(): string | undefined {\n\t\treturn this.error;\n\t}\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-trust.d.ts","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"project-trust.d.ts","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEvF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAIN,KAAK,iBAAiB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,OAAO,GAAG,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;AAE/D,MAAM,WAAW,4BAA4B;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;IAC1C,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AAMD;;;;;;;;GAQG;AACH,wBAAgB,wCAAwC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/E;AAqBD,wBAAsB,qBAAqB,CAAC,OAAO,EAAE,4BAA4B,GAAG,OAAO,CAAC,OAAO,CAAC,CAkDnG"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { APP_TITLE, CONFIG_DIR_NAME } from "../config.js";
|
|
2
2
|
import { emitProjectTrustEvent } from "./extensions/runner.js";
|
|
3
|
+
import { SETTINGS_DEFAULTS } from "./settings-defaults.js";
|
|
3
4
|
import { getProjectTrustOptions, hasProjectTrustInputs, } from "./trust-manager.js";
|
|
4
5
|
function formatProjectTrustPrompt(cwd) {
|
|
5
6
|
return `Trust project folder?\n${cwd}\n\nThis allows ${APP_TITLE} to load ${CONFIG_DIR_NAME} settings and resources, install missing project packages, and execute project extensions.`;
|
|
@@ -50,7 +51,7 @@ export async function resolveProjectTrusted(options) {
|
|
|
50
51
|
if (decision !== null) {
|
|
51
52
|
return decision;
|
|
52
53
|
}
|
|
53
|
-
switch (options.defaultProjectTrust ??
|
|
54
|
+
switch (options.defaultProjectTrust ?? SETTINGS_DEFAULTS.defaultProjectTrust) {
|
|
54
55
|
case "always":
|
|
55
56
|
return true;
|
|
56
57
|
case "never":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"project-trust.js","sourceRoot":"","sources":["../../src/core/project-trust.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EACN,sBAAsB,EACtB,qBAAqB,GAGrB,MAAM,oBAAoB,CAAC;AAe5B,SAAS,wBAAwB,CAAC,GAAW;IAC5C,OAAO,0BAA0B,GAAG,mBAAmB,SAAS,YAAY,eAAe,4FAA4F,CAAC;AACzL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,wCAAwC,CAAC,MAAc;IACtE,OAAO,4BAA4B,MAAM,mBAAmB,SAAS,gJAAgJ,CAAC;AACvN,CAAC;AAED,KAAK,UAAU,wBAAwB,CACtC,GAAW,EACX,GAAwB,EACxB,aAAsB;IAEtB,MAAM,OAAO,GAAG,sBAAsB,CAAC,GAAG,EAAE,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;IAC1E,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,MAAM,CACnC,aAAa,IAAI,wBAAwB,CAAC,GAAG,CAAC,EAC9C,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CACrC,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC;AAC5D,CAAC;AAED,SAAS,4BAA4B,CAAC,UAA6B,EAAE,MAA0B;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,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAC;IACjB,CAAC;IAED,QAAQ,OAAO,CAAC,mBAAmB,IAAI,iBAAiB,CAAC,mBAAmB,EAAE,CAAC;QAC9E,KAAK,QAAQ;YACZ,OAAO,IAAI,CAAC;QACb,KAAK,OAAO;YACX,OAAO,KAAK,CAAC;QACd,KAAK,KAAK;YACT,MAAM;IACR,CAAC;IAED,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,KAAK,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACd,CAAC;IAED,MAAM,QAAQ,GAAG,MAAM,wBAAwB,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IACjH,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;QAC5B,4BAA4B,CAAC,OAAO,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC;QAC3D,OAAO,QAAQ,CAAC,OAAO,CAAC;IACzB,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { APP_TITLE, CONFIG_DIR_NAME } from \"../config.js\";\nimport { emitProjectTrustEvent } from \"./extensions/runner.ts\";\nimport type { LoadExtensionsResult, ProjectTrustContext } from \"./extensions/types.ts\";\nimport { SETTINGS_DEFAULTS } from \"./settings-defaults.ts\";\nimport type { DefaultProjectTrust } from \"./settings-manager.ts\";\nimport {\n\tgetProjectTrustOptions,\n\thasProjectTrustInputs,\n\ttype ProjectTrustOption,\n\ttype ProjectTrustStore,\n} from \"./trust-manager.ts\";\n\nexport type AppMode = \"interactive\" | \"print\" | \"json\" | \"rpc\";\n\nexport interface ResolveProjectTrustedOptions {\n\tcwd: string;\n\ttrustStore: ProjectTrustStore;\n\ttrustOverride?: boolean;\n\tdefaultProjectTrust?: DefaultProjectTrust;\n\textensionsResult?: LoadExtensionsResult;\n\tprojectTrustContext: ProjectTrustContext;\n\tpromptMessage?: string;\n\tonExtensionError?: (message: string) => void;\n}\n\nfunction formatProjectTrustPrompt(cwd: string): string {\n\treturn `Trust project folder?\\n${cwd}\\n\\nThis allows ${APP_TITLE} to load ${CONFIG_DIR_NAME} settings and resources, install missing project packages, and execute project extensions.`;\n}\n\n/**\n * The prompt shown for a `-e` extension source outside the project.\n *\n * Named through `APP_TITLE` for the same reason as the project-folder prompt\n * above: branding is configurable, so a hardcoded product name lies in a\n * rebranded distribution. The `.atomic/.pi` directory names stay literal —\n * they are the two compatibility paths the resource loader reads from that\n * source, not a product name.\n */\nexport function formatBorrowedExtensionSourceTrustPrompt(source: string): string {\n\treturn `Trust extension source?\\n${source}\\n\\nThis allows ${APP_TITLE} to load project-local .atomic/.pi resources and .agents/skills from this -e source, including extensions and workflows that can execute code.`;\n}\n\nasync function selectProjectTrustOption(\n\tcwd: string,\n\tctx: ProjectTrustContext,\n\tpromptMessage?: string,\n): Promise<ProjectTrustOption | undefined> {\n\tconst options = getProjectTrustOptions(cwd, { includeSessionOnly: true });\n\tconst selected = await ctx.ui.select(\n\t\tpromptMessage ?? formatProjectTrustPrompt(cwd),\n\t\toptions.map((option) => option.label),\n\t);\n\treturn options.find((option) => option.label === selected);\n}\n\nfunction saveProjectTrustPromptResult(trustStore: ProjectTrustStore, result: ProjectTrustOption): void {\n\tif (result.updates.length > 0) {\n\t\ttrustStore.setMany(result.updates);\n\t}\n}\n\nexport async function resolveProjectTrusted(options: ResolveProjectTrustedOptions): Promise<boolean> {\n\tif (options.trustOverride !== undefined) {\n\t\treturn options.trustOverride;\n\t}\n\tif (!hasProjectTrustInputs(options.cwd)) {\n\t\treturn true;\n\t}\n\n\tif (options.extensionsResult) {\n\t\tconst { result, errors } = await emitProjectTrustEvent(\n\t\t\toptions.extensionsResult,\n\t\t\t{ type: \"project_trust\", cwd: options.cwd },\n\t\t\toptions.projectTrustContext,\n\t\t);\n\t\tfor (const error of errors) {\n\t\t\toptions.onExtensionError?.(`Extension \"${error.extensionPath}\" project_trust error: ${error.error}`);\n\t\t}\n\t\tif (result) {\n\t\t\tconst trusted = result.trusted === \"yes\";\n\t\t\tif (result.remember === true) {\n\t\t\t\toptions.trustStore.set(options.cwd, trusted);\n\t\t\t}\n\t\t\treturn trusted;\n\t\t}\n\t}\n\n\tconst decision = options.trustStore.get(options.cwd);\n\tif (decision !== null) {\n\t\treturn decision;\n\t}\n\n\tswitch (options.defaultProjectTrust ?? SETTINGS_DEFAULTS.defaultProjectTrust) {\n\t\tcase \"always\":\n\t\t\treturn true;\n\t\tcase \"never\":\n\t\t\treturn false;\n\t\tcase \"ask\":\n\t\t\tbreak;\n\t}\n\n\tif (!options.projectTrustContext.hasUI) {\n\t\treturn false;\n\t}\n\n\tconst selected = await selectProjectTrustOption(options.cwd, options.projectTrustContext, options.promptMessage);\n\tif (selected !== undefined) {\n\t\tsaveProjectTrustPromptResult(options.trustStore, selected);\n\t\treturn selected.trusted;\n\t}\n\treturn false;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-loader-context-files.d.ts","sourceRoot":"","sources":["../../src/core/resource-loader-context-files.ts"],"names":[],"mappings":"AAQA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAerG;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE7F;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAIpF;AAqBD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAgB,GAAG,MAAM,EAAE,CAS/G;
|
|
1
|
+
{"version":3,"file":"resource-loader-context-files.d.ts","sourceRoot":"","sources":["../../src/core/resource-loader-context-files.ts"],"names":[],"mappings":"AAQA,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAerG;AAED;;;GAGG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAE7F;AAED,wBAAgB,gCAAgC,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAIpF;AAqBD,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAgB,GAAG,MAAM,EAAE,CAS/G;AAsED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;CACzB,GAAG,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CA2C3C"}
|
|
@@ -99,9 +99,11 @@ function isDescendantOf(directory, child) {
|
|
|
99
99
|
* occupy the same logical repository scope, so loading both applies that context twice. Returns
|
|
100
100
|
* undefined when nothing is shadowed, leaving normal ancestor inheritance alone.
|
|
101
101
|
*
|
|
102
|
-
* Returned
|
|
103
|
-
* file's
|
|
104
|
-
* (macOS `/tmp` -> `/private/tmp`) or
|
|
102
|
+
* Returned as the main repo root's real path joined with the selected file name, not
|
|
103
|
+
* the file's own real path: `git worktree add` writes the `.git` file's `gitdir:` target
|
|
104
|
+
* in realpath form while cwd may still be symlinked (macOS `/tmp` -> `/private/tmp`) or
|
|
105
|
+
* short-named (Windows `RUNNER~1`), and a worktree context file that symlinks to the main
|
|
106
|
+
* repo's copy would otherwise resolve to the shadowed path itself.
|
|
105
107
|
*/
|
|
106
108
|
function findShadowedContextFile(cwd) {
|
|
107
109
|
const gitPaths = findGitPaths(cwd);
|
|
@@ -127,9 +129,9 @@ function findShadowedContextFile(cwd) {
|
|
|
127
129
|
// the main checkout's selected candidate even when the filenames differ.
|
|
128
130
|
if (basename(worktreeContextFile.path) === "AGENTS.override.md") {
|
|
129
131
|
const mainRepoContextFile = loadContextFileFromDir(mainRepoRoot);
|
|
130
|
-
return mainRepoContextFile ?
|
|
132
|
+
return mainRepoContextFile ? join(mainRepoRoot, basename(mainRepoContextFile.path)) : undefined;
|
|
131
133
|
}
|
|
132
|
-
return
|
|
134
|
+
return join(mainRepoRoot, basename(worktreeContextFile.path));
|
|
133
135
|
}
|
|
134
136
|
export function loadProjectContextFiles(options) {
|
|
135
137
|
const resolvedCwd = resolvePath(options.cwd);
|
|
@@ -153,9 +155,11 @@ export function loadProjectContextFiles(options) {
|
|
|
153
155
|
const contextFile = loadContextFileFromDir(currentDir);
|
|
154
156
|
// A nested linked worktree's context file and the main repo's selected copy
|
|
155
157
|
// occupy one logical repository scope; skip the main repo's copy so it is not loaded twice.
|
|
158
|
+
// Compare the directory's real path, not the file's, so a symlinked context file is not
|
|
159
|
+
// mistaken for the main repo's copy it points to.
|
|
156
160
|
const isShadowed = shadowedContextFile !== undefined &&
|
|
157
161
|
contextFile !== null &&
|
|
158
|
-
samePath(realPath(contextFile.path), shadowedContextFile);
|
|
162
|
+
samePath(join(realPath(currentDir), basename(contextFile.path)), shadowedContextFile);
|
|
159
163
|
if (contextFile && !isShadowed && !seenPaths.has(contextFile.path)) {
|
|
160
164
|
ancestorContextFiles.unshift(contextFile);
|
|
161
165
|
seenPaths.add(contextFile.path);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-loader-context-files.js","sourceRoot":"","sources":["../../src/core/resource-loader-context-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,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,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAC3B,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7B,CAAC;IACF,CAAC;IAED,MAAM,oBAAoB,GAA6C,EAAE,CAAC;IAC1E,IAAI,OAAO,CAAC,cAAc,KAAK,KAAK,EAAE,CAAC;QACtC,OAAO,YAAY,CAAC;IACrB,CAAC;IAED,MAAM,mBAAmB,GAAG,uBAAuB,CAAC,WAAW,CAAC,CAAC;IACjE,KAAK,MAAM,UAAU,IAAI,sBAAsB,CAAC,WAAW,CAAC,EAAE,CAAC;QAC9D,MAAM,WAAW,GAAG,sBAAsB,CAAC,UAAU,CAAC,CAAC;QACvD,4EAA4E;QAC5E,4FAA4F;QAC5F,MAAM,UAAU,GACf,mBAAmB,KAAK,SAAS;YACjC,WAAW,KAAK,IAAI;YACpB,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAC3D,IAAI,WAAW,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,oBAAoB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACF,CAAC;IAED,YAAY,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAC;IAE3C,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["import { existsSync, readFileSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, dirname, join, sep } from \"node:path\";\nimport chalk from \"chalk\";\nimport { getAgentDir, getAgentDirs } from \"../config.js\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { findGitPaths } from \"./footer-data-provider.ts\";\n\nexport function resolvePromptInput(input: string | undefined, description: string): string | undefined {\n\tif (!input) {\n\t\treturn undefined;\n\t}\n\n\tif (existsSync(input)) {\n\t\ttry {\n\t\t\treturn stripBom(readFileSync(input, \"utf-8\"));\n\t\t} catch (error) {\n\t\t\tconsole.error(chalk.yellow(`Warning: Could not read ${description} file ${input}: ${error}`));\n\t\t\treturn input;\n\t\t}\n\t}\n\n\treturn input;\n}\n\n/**\n * Path of a system-prompt input that is a real file, for startup disclosure.\n * `resolvePromptInput` also accepts literal prompt text, which has no path.\n */\nexport function resolveExistingPromptSourcePath(input: string | undefined): string | undefined {\n\treturn input && existsSync(input) ? resolvePath(input) : undefined;\n}\n\nexport function resolveExistingPromptSourcePaths(inputs: readonly string[]): string[] {\n\treturn inputs\n\t\t.map((input) => resolveExistingPromptSourcePath(input))\n\t\t.filter((path): path is string => path !== undefined);\n}\n\nfunction loadContextFileFromDir(dir: string): { path: string; content: string } | null {\n\tconst candidates = [\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"];\n\tfor (const filename of candidates) {\n\t\tconst filePath = join(dir, filename);\n\t\tif (existsSync(filePath)) {\n\t\t\ttry {\n\t\t\t\tif (!statSync(filePath).isFile()) continue;\n\t\t\t\treturn {\n\t\t\t\t\tpath: filePath,\n\t\t\t\t\tcontent: stripBom(readFileSync(filePath, \"utf-8\")),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(chalk.yellow(`Warning: Could not read ${filePath}: ${error}`));\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n}\n\nexport function getAncestorDirectories(startDir: string, parentOf: (path: string) => string = dirname): string[] {\n\tconst directories: string[] = [];\n\tlet currentDir = startDir;\n\twhile (true) {\n\t\tdirectories.push(currentDir);\n\t\tconst parentDir = parentOf(currentDir);\n\t\tif (parentDir === currentDir) return directories;\n\t\tcurrentDir = parentDir;\n\t}\n}\n/**\n * Canonical spelling of a path, for comparing one Node derived from `cwd`\n * against one git wrote into a `.git` file.\n *\n * `canonicalizePath` uses `realpathSync`, which resolves symlinks but leaves a\n * Windows 8.3 short component alone — and `os.tmpdir()` on a GitHub Windows\n * runner is exactly that (`C:\\Users\\RUNNER~1\\AppData\\Local\\Temp`). Git records\n * the expanded long form in the `gitdir:` target, so the two spellings of one\n * directory never compared equal and the shadowing guard below silently did\n * nothing on Windows. `realpathSync.native` expands the short component; it is\n * the same pairing `subagents/runs/shared/worktree-root.ts` already relies on.\n */\nfunction realPath(path: string): string {\n\ttry {\n\t\treturn realpathSync.native(path);\n\t} catch {\n\t\treturn canonicalizePath(path);\n\t}\n}\n\n/** Windows compares paths case-insensitively; POSIX does not. */\nfunction samePath(left: string, right: string): boolean {\n\treturn process.platform === \"win32\" ? left.toLowerCase() === right.toLowerCase() : left === right;\n}\n\n/** True when `child` is a strict descendant of `directory`, under the same casing rule. */\nfunction isDescendantOf(directory: string, child: string): boolean {\n\tconst prefix = `${directory}${sep}`;\n\treturn process.platform === \"win32\"\n\t\t? child.toLowerCase().startsWith(prefix.toLowerCase())\n\t\t: child.startsWith(prefix);\n}\n\n/**\n * The main repo's context file that a nested linked worktree's own copy shadows: both\n * occupy the same logical repository scope, so loading both applies that context twice. Returns\n * undefined when nothing is shadowed, leaving normal ancestor inheritance alone.\n *\n * Returned canonicalized (realpath), because `git worktree add` writes the `.git`\n * file's `gitdir:` target in realpath form while cwd may still be symlinked\n * (macOS `/tmp` -> `/private/tmp`) or short-named (Windows `RUNNER~1`).\n */\nfunction findShadowedContextFile(cwd: string): string | undefined {\n\tconst gitPaths = findGitPaths(cwd);\n\tif (!gitPaths) return undefined;\n\tconst commonGitDir = realPath(gitPaths.commonGitDir);\n\tconst worktreeRoot = realPath(gitPaths.repoDir);\n\tconst mainRepoRoot = dirname(commonGitDir);\n\t// False for an ordinary repo, where the two are the same dir, and for a sibling\n\t// worktree (`git worktree add ../feat`), whose main repo is not an ancestor.\n\tif (!isDescendantOf(mainRepoRoot, worktreeRoot)) return undefined;\n\t// dirname of the common git dir is the main worktree root only when that dir is\n\t// itself checked out from the same repo. In a bare layout (`proj/.bare` +\n\t// `proj/main`) it is just the directory holding `.bare`, which tracks nothing; a\n\t// submodule's gitdir has no `commondir`, so it lands under `.git/modules`.\n\tif (!samePath(realPath(join(mainRepoRoot, \".git\")), commonGitDir)) return undefined;\n\tconst worktreeContextFile = loadContextFileFromDir(worktreeRoot);\n\tif (!worktreeContextFile) return undefined;\n\t// An override replaces every context candidate in its directory, so it shadows\n\t// the main checkout's selected candidate even when the filenames differ.\n\tif (basename(worktreeContextFile.path) === \"AGENTS.override.md\") {\n\t\tconst mainRepoContextFile = loadContextFileFromDir(mainRepoRoot);\n\t\treturn mainRepoContextFile ? realPath(mainRepoContextFile.path) : undefined;\n\t}\n\treturn realPath(join(mainRepoRoot, basename(worktreeContextFile.path)));\n}\n\nexport function loadProjectContextFiles(options: {\n\tcwd: string;\n\tagentDir: string;\n\tprojectTrusted?: boolean;\n}): Array<{ path: string; content: string }> {\n\tconst resolvedCwd = resolvePath(options.cwd);\n\tconst resolvedAgentDir = resolvePath(options.agentDir);\n\n\tconst contextFiles: Array<{ path: string; content: string }> = [];\n\tconst seenPaths = new Set<string>();\n\n\tconst contextAgentDirs = Array.from(\n\t\tnew Set(resolvedAgentDir === getAgentDir() ? getAgentDirs() : [resolvedAgentDir]),\n\t).reverse();\n\tfor (const agentDir of contextAgentDirs) {\n\t\tconst context = loadContextFileFromDir(agentDir);\n\t\tif (context && !seenPaths.has(context.path)) {\n\t\t\tcontextFiles.push(context);\n\t\t\tseenPaths.add(context.path);\n\t\t}\n\t}\n\n\tconst ancestorContextFiles: Array<{ path: string; content: string }> = [];\n\tif (options.projectTrusted === false) {\n\t\treturn contextFiles;\n\t}\n\n\tconst shadowedContextFile = findShadowedContextFile(resolvedCwd);\n\tfor (const currentDir of getAncestorDirectories(resolvedCwd)) {\n\t\tconst contextFile = loadContextFileFromDir(currentDir);\n\t\t// A nested linked worktree's context file and the main repo's selected copy\n\t\t// occupy one logical repository scope; skip the main repo's copy so it is not loaded twice.\n\t\tconst isShadowed =\n\t\t\tshadowedContextFile !== undefined &&\n\t\t\tcontextFile !== null &&\n\t\t\tsamePath(realPath(contextFile.path), shadowedContextFile);\n\t\tif (contextFile && !isShadowed && !seenPaths.has(contextFile.path)) {\n\t\t\tancestorContextFiles.unshift(contextFile);\n\t\t\tseenPaths.add(contextFile.path);\n\t\t}\n\t}\n\n\tcontextFiles.push(...ancestorContextFiles);\n\n\treturn contextFiles;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"resource-loader-context-files.js","sourceRoot":"","sources":["../../src/core/resource-loader-context-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,UAAU,kBAAkB,CAAC,KAAyB,EAAE,WAAmB;IAChF,IAAI,CAAC,KAAK,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,IAAI,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,IAAI,CAAC;YACJ,OAAO,QAAQ,CAAC,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,2BAA2B,WAAW,SAAS,KAAK,KAAK,KAAK,EA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C,EAAE,mBAAmB,CAAC,CAAC;QACvF,IAAI,WAAW,IAAI,CAAC,UAAU,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,oBAAoB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YAC1C,SAAS,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;QACjC,CAAC;IACF,CAAC;IAED,YAAY,CAAC,IAAI,CAAC,GAAG,oBAAoB,CAAC,CAAC;IAE3C,OAAO,YAAY,CAAC;AACrB,CAAC","sourcesContent":["import { existsSync, readFileSync, realpathSync, statSync } from \"node:fs\";\nimport { basename, dirname, join, sep } from \"node:path\";\nimport chalk from \"chalk\";\nimport { getAgentDir, getAgentDirs } from \"../config.js\";\nimport { canonicalizePath, resolvePath } from \"../utils/paths.ts\";\nimport { stripBom } from \"../utils/text.ts\";\nimport { findGitPaths } from \"./footer-data-provider.ts\";\n\nexport function resolvePromptInput(input: string | undefined, description: string): string | undefined {\n\tif (!input) {\n\t\treturn undefined;\n\t}\n\n\tif (existsSync(input)) {\n\t\ttry {\n\t\t\treturn stripBom(readFileSync(input, \"utf-8\"));\n\t\t} catch (error) {\n\t\t\tconsole.error(chalk.yellow(`Warning: Could not read ${description} file ${input}: ${error}`));\n\t\t\treturn input;\n\t\t}\n\t}\n\n\treturn input;\n}\n\n/**\n * Path of a system-prompt input that is a real file, for startup disclosure.\n * `resolvePromptInput` also accepts literal prompt text, which has no path.\n */\nexport function resolveExistingPromptSourcePath(input: string | undefined): string | undefined {\n\treturn input && existsSync(input) ? resolvePath(input) : undefined;\n}\n\nexport function resolveExistingPromptSourcePaths(inputs: readonly string[]): string[] {\n\treturn inputs\n\t\t.map((input) => resolveExistingPromptSourcePath(input))\n\t\t.filter((path): path is string => path !== undefined);\n}\n\nfunction loadContextFileFromDir(dir: string): { path: string; content: string } | null {\n\tconst candidates = [\"AGENTS.override.md\", \"AGENTS.md\", \"AGENTS.MD\", \"CLAUDE.md\", \"CLAUDE.MD\"];\n\tfor (const filename of candidates) {\n\t\tconst filePath = join(dir, filename);\n\t\tif (existsSync(filePath)) {\n\t\t\ttry {\n\t\t\t\tif (!statSync(filePath).isFile()) continue;\n\t\t\t\treturn {\n\t\t\t\t\tpath: filePath,\n\t\t\t\t\tcontent: stripBom(readFileSync(filePath, \"utf-8\")),\n\t\t\t\t};\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(chalk.yellow(`Warning: Could not read ${filePath}: ${error}`));\n\t\t\t}\n\t\t}\n\t}\n\treturn null;\n}\n\nexport function getAncestorDirectories(startDir: string, parentOf: (path: string) => string = dirname): string[] {\n\tconst directories: string[] = [];\n\tlet currentDir = startDir;\n\twhile (true) {\n\t\tdirectories.push(currentDir);\n\t\tconst parentDir = parentOf(currentDir);\n\t\tif (parentDir === currentDir) return directories;\n\t\tcurrentDir = parentDir;\n\t}\n}\n/**\n * Canonical spelling of a path, for comparing one Node derived from `cwd`\n * against one git wrote into a `.git` file.\n *\n * `canonicalizePath` uses `realpathSync`, which resolves symlinks but leaves a\n * Windows 8.3 short component alone — and `os.tmpdir()` on a GitHub Windows\n * runner is exactly that (`C:\\Users\\RUNNER~1\\AppData\\Local\\Temp`). Git records\n * the expanded long form in the `gitdir:` target, so the two spellings of one\n * directory never compared equal and the shadowing guard below silently did\n * nothing on Windows. `realpathSync.native` expands the short component; it is\n * the same pairing `subagents/runs/shared/worktree-root.ts` already relies on.\n */\nfunction realPath(path: string): string {\n\ttry {\n\t\treturn realpathSync.native(path);\n\t} catch {\n\t\treturn canonicalizePath(path);\n\t}\n}\n\n/** Windows compares paths case-insensitively; POSIX does not. */\nfunction samePath(left: string, right: string): boolean {\n\treturn process.platform === \"win32\" ? left.toLowerCase() === right.toLowerCase() : left === right;\n}\n\n/** True when `child` is a strict descendant of `directory`, under the same casing rule. */\nfunction isDescendantOf(directory: string, child: string): boolean {\n\tconst prefix = `${directory}${sep}`;\n\treturn process.platform === \"win32\"\n\t\t? child.toLowerCase().startsWith(prefix.toLowerCase())\n\t\t: child.startsWith(prefix);\n}\n\n/**\n * The main repo's context file that a nested linked worktree's own copy shadows: both\n * occupy the same logical repository scope, so loading both applies that context twice. Returns\n * undefined when nothing is shadowed, leaving normal ancestor inheritance alone.\n *\n * Returned as the main repo root's real path joined with the selected file name, not\n * the file's own real path: `git worktree add` writes the `.git` file's `gitdir:` target\n * in realpath form while cwd may still be symlinked (macOS `/tmp` -> `/private/tmp`) or\n * short-named (Windows `RUNNER~1`), and a worktree context file that symlinks to the main\n * repo's copy would otherwise resolve to the shadowed path itself.\n */\nfunction findShadowedContextFile(cwd: string): string | undefined {\n\tconst gitPaths = findGitPaths(cwd);\n\tif (!gitPaths) return undefined;\n\tconst commonGitDir = realPath(gitPaths.commonGitDir);\n\tconst worktreeRoot = realPath(gitPaths.repoDir);\n\tconst mainRepoRoot = dirname(commonGitDir);\n\t// False for an ordinary repo, where the two are the same dir, and for a sibling\n\t// worktree (`git worktree add ../feat`), whose main repo is not an ancestor.\n\tif (!isDescendantOf(mainRepoRoot, worktreeRoot)) return undefined;\n\t// dirname of the common git dir is the main worktree root only when that dir is\n\t// itself checked out from the same repo. In a bare layout (`proj/.bare` +\n\t// `proj/main`) it is just the directory holding `.bare`, which tracks nothing; a\n\t// submodule's gitdir has no `commondir`, so it lands under `.git/modules`.\n\tif (!samePath(realPath(join(mainRepoRoot, \".git\")), commonGitDir)) return undefined;\n\tconst worktreeContextFile = loadContextFileFromDir(worktreeRoot);\n\tif (!worktreeContextFile) return undefined;\n\t// An override replaces every context candidate in its directory, so it shadows\n\t// the main checkout's selected candidate even when the filenames differ.\n\tif (basename(worktreeContextFile.path) === \"AGENTS.override.md\") {\n\t\tconst mainRepoContextFile = loadContextFileFromDir(mainRepoRoot);\n\t\treturn mainRepoContextFile ? join(mainRepoRoot, basename(mainRepoContextFile.path)) : undefined;\n\t}\n\treturn join(mainRepoRoot, basename(worktreeContextFile.path));\n}\n\nexport function loadProjectContextFiles(options: {\n\tcwd: string;\n\tagentDir: string;\n\tprojectTrusted?: boolean;\n}): Array<{ path: string; content: string }> {\n\tconst resolvedCwd = resolvePath(options.cwd);\n\tconst resolvedAgentDir = resolvePath(options.agentDir);\n\n\tconst contextFiles: Array<{ path: string; content: string }> = [];\n\tconst seenPaths = new Set<string>();\n\n\tconst contextAgentDirs = Array.from(\n\t\tnew Set(resolvedAgentDir === getAgentDir() ? getAgentDirs() : [resolvedAgentDir]),\n\t).reverse();\n\tfor (const agentDir of contextAgentDirs) {\n\t\tconst context = loadContextFileFromDir(agentDir);\n\t\tif (context && !seenPaths.has(context.path)) {\n\t\t\tcontextFiles.push(context);\n\t\t\tseenPaths.add(context.path);\n\t\t}\n\t}\n\n\tconst ancestorContextFiles: Array<{ path: string; content: string }> = [];\n\tif (options.projectTrusted === false) {\n\t\treturn contextFiles;\n\t}\n\n\tconst shadowedContextFile = findShadowedContextFile(resolvedCwd);\n\tfor (const currentDir of getAncestorDirectories(resolvedCwd)) {\n\t\tconst contextFile = loadContextFileFromDir(currentDir);\n\t\t// A nested linked worktree's context file and the main repo's selected copy\n\t\t// occupy one logical repository scope; skip the main repo's copy so it is not loaded twice.\n\t\t// Compare the directory's real path, not the file's, so a symlinked context file is not\n\t\t// mistaken for the main repo's copy it points to.\n\t\tconst isShadowed =\n\t\t\tshadowedContextFile !== undefined &&\n\t\t\tcontextFile !== null &&\n\t\t\tsamePath(join(realPath(currentDir), basename(contextFile.path)), shadowedContextFile);\n\t\tif (contextFile && !isShadowed && !seenPaths.has(contextFile.path)) {\n\t\t\tancestorContextFiles.unshift(contextFile);\n\t\t\tseenPaths.add(contextFile.path);\n\t\t}\n\t}\n\n\tcontextFiles.push(...ancestorContextFiles);\n\n\treturn contextFiles;\n}\n"]}
|