@stigmer/runner 3.12.3 → 3.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-fingerprint +1 -1
- package/dist/activities/call-http.js +12 -0
- package/dist/activities/call-http.js.map +1 -1
- package/dist/activities/call-llm.d.ts +18 -0
- package/dist/activities/call-llm.js +56 -2
- package/dist/activities/call-llm.js.map +1 -1
- package/dist/activities/execute-cursor/agent-session-cache.d.ts +72 -0
- package/dist/activities/execute-cursor/agent-session-cache.js +186 -0
- package/dist/activities/execute-cursor/agent-session-cache.js.map +1 -0
- package/dist/activities/execute-cursor/index.js +61 -28
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/service-tier.d.ts +5 -15
- package/dist/activities/execute-cursor/service-tier.js +5 -21
- package/dist/activities/execute-cursor/service-tier.js.map +1 -1
- package/dist/activities/execute-cursor/skill-resolver.js +1 -1
- package/dist/activities/execute-cursor/skill-resolver.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.js +14 -0
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/activities/execute-deep-agent/shell-env.d.ts +8 -5
- package/dist/activities/execute-deep-agent/shell-env.js +10 -7
- package/dist/activities/execute-deep-agent/shell-env.js.map +1 -1
- package/dist/config.js +10 -5
- package/dist/config.js.map +1 -1
- package/dist/encryption/config.js +7 -2
- package/dist/encryption/config.js.map +1 -1
- package/dist/main.js +12 -6
- package/dist/main.js.map +1 -1
- package/dist/payload-codecs.js +2 -1
- package/dist/payload-codecs.js.map +1 -1
- package/dist/runner-manager.js +20 -7
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.js +19 -6
- package/dist/runner.js.map +1 -1
- package/dist/shared/fingerprint-secret.d.ts +3 -2
- package/dist/shared/fingerprint-secret.js +5 -3
- package/dist/shared/fingerprint-secret.js.map +1 -1
- package/dist/shared/llm-backend.js +8 -1
- package/dist/shared/llm-backend.js.map +1 -1
- package/dist/shared/model-client.d.ts +15 -0
- package/dist/shared/model-client.js +57 -13
- package/dist/shared/model-client.js.map +1 -1
- package/dist/shared/registry-endpoint.d.ts +5 -0
- package/dist/shared/registry-endpoint.js +7 -1
- package/dist/shared/registry-endpoint.js.map +1 -1
- package/dist/shared/runner-credential-keys.d.ts +26 -1
- package/dist/shared/runner-credential-keys.js +34 -1
- package/dist/shared/runner-credential-keys.js.map +1 -1
- package/dist/shared/runner-credential-store.d.ts +77 -0
- package/dist/shared/runner-credential-store.js +111 -0
- package/dist/shared/runner-credential-store.js.map +1 -0
- package/dist/shared/service-tier.d.ts +55 -0
- package/dist/shared/service-tier.js +67 -0
- package/dist/shared/service-tier.js.map +1 -0
- package/dist/shared/skill-writer.js +2 -2
- package/dist/shared/skill-writer.js.map +1 -1
- package/dist/shared/zip-extract.d.ts +10 -3
- package/dist/shared/zip-extract.js +10 -3
- package/dist/shared/zip-extract.js.map +1 -1
- package/dist/workflow-engine/tasks/call-function.d.ts +14 -0
- package/dist/workflow-engine/tasks/call-function.js +49 -5
- package/dist/workflow-engine/tasks/call-function.js.map +1 -1
- package/dist/workflow-engine/types.d.ts +6 -0
- package/dist/workflow-engine/types.js.map +1 -1
- package/dist/workflows/engine-core.js +36 -8
- package/dist/workflows/engine-core.js.map +1 -1
- package/package.json +2 -2
- package/src/activities/__tests__/call-http.test.ts +36 -0
- package/src/activities/__tests__/call-llm.test.ts +77 -0
- package/src/activities/call-http.ts +17 -0
- package/src/activities/call-llm.ts +78 -2
- package/src/activities/execute-cursor/__tests__/agent-session-cache.test.ts +220 -0
- package/src/activities/execute-cursor/__tests__/service-tier.test.ts +1 -1
- package/src/activities/execute-cursor/agent-session-cache.ts +229 -0
- package/src/activities/execute-cursor/index.ts +66 -20
- package/src/activities/execute-cursor/service-tier.ts +5 -29
- package/src/activities/execute-cursor/skill-resolver.ts +1 -1
- package/src/activities/execute-deep-agent/setup.ts +15 -0
- package/src/activities/execute-deep-agent/shell-env.ts +10 -7
- package/src/config.ts +10 -5
- package/src/encryption/config.ts +8 -2
- package/src/main.ts +16 -6
- package/src/payload-codecs.ts +2 -1
- package/src/runner-manager.ts +29 -6
- package/src/runner.ts +25 -6
- package/src/shared/__tests__/model-client.test.ts +99 -0
- package/src/shared/__tests__/runner-credential-store.test.ts +155 -0
- package/src/shared/__tests__/zip-extract.test.ts +46 -11
- package/src/shared/fingerprint-secret.ts +5 -3
- package/src/shared/llm-backend.ts +7 -1
- package/src/shared/model-client.ts +76 -13
- package/src/shared/registry-endpoint.ts +9 -1
- package/src/shared/runner-credential-keys.ts +36 -1
- package/src/shared/runner-credential-store.ts +115 -0
- package/src/shared/service-tier.ts +78 -0
- package/src/shared/skill-writer.ts +2 -2
- package/src/shared/zip-extract.ts +14 -7
- package/src/workflow-engine/__tests__/golden-execution.test.ts +20 -1
- package/src/workflow-engine/__tests__/tasks/call-function.test.ts +105 -0
- package/src/workflow-engine/tasks/call-function.ts +74 -13
- package/src/workflow-engine/types.ts +6 -0
- package/src/workflows/engine-core.ts +39 -8
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* `_projects/2026-08/20260809.01.multi-cloud-llm-provider-endpoints/`
|
|
14
14
|
* `design-decisions/001-provider-backends.md`.
|
|
15
15
|
*/
|
|
16
|
+
import { runnerSecretsEnvView } from "./runner-credential-store.js";
|
|
16
17
|
// ─── Backend selection ───────────────────────────────────────────────────────
|
|
17
18
|
/** Env var selecting where Anthropic models are served. */
|
|
18
19
|
export const ANTHROPIC_BACKEND_ENV = "STIGMER_ANTHROPIC_BACKEND";
|
|
@@ -244,7 +245,13 @@ export function checkFoundryPrerequisites(env = process.env) {
|
|
|
244
245
|
* no proxy is configured — a proxied deployment authenticates with
|
|
245
246
|
* STIGMER_TOKEN and holds no provider credentials at all.
|
|
246
247
|
*/
|
|
247
|
-
export function checkDirectCredentials(provider,
|
|
248
|
+
export function checkDirectCredentials(provider,
|
|
249
|
+
// Credential keys live in the runner credential store after the boot
|
|
250
|
+
// capture (#508), so the default is the store view, not bare process.env.
|
|
251
|
+
// The other checks in this module keep the process.env default: they read
|
|
252
|
+
// deployment CONFIG (backend selection, regions), which is deliberately
|
|
253
|
+
// not captured.
|
|
254
|
+
env = runnerSecretsEnvView()) {
|
|
248
255
|
if (provider === "openai") {
|
|
249
256
|
if (env.OPENAI_API_KEY?.trim())
|
|
250
257
|
return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"llm-backend.js","sourceRoot":"","sources":["../../src/shared/llm-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"llm-backend.js","sourceRoot":"","sources":["../../src/shared/llm-backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,gFAAgF;AAEhF,2DAA2D;AAC3D,MAAM,CAAC,MAAM,qBAAqB,GAAG,2BAA2B,CAAC;AACjE,wDAAwD;AACxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,wBAAwB,CAAC;AAE3D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,eAAe,GAAG,uDAAuD,CAAC;AA0BvF,sEAAsE;AACtE,MAAM,iBAAiB,GAAa,EAAE,CAAC;AACvC,MAAM,cAAc,GAAG,CAAC,OAAO,CAAC,CAAC;AAEjC,SAAS,YAAY,CACnB,MAAc,EACd,GAAuB,EACvB,SAAuB,EACvB,OAA0B;IAE1B,MAAM,KAAK,GAAG,GAAG,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC;IAC9C,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjB,mEAAmE;QACnE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,QAAa,EAAE,CAAC;IAC9C,CAAC;IACD,IAAK,SAA+B,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,EAAE,EAAE,EAA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
|
15
15
|
import type { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
16
16
|
import { type LlmProvider } from "./llm-proxy.js";
|
|
17
|
+
import { type EffectiveServiceTier } from "./service-tier.js";
|
|
17
18
|
export interface BuildChatModelOptions {
|
|
18
19
|
/** Registry id ("claude-haiku-4.5"), "provider:model", or a provider API id. */
|
|
19
20
|
readonly modelName: string;
|
|
@@ -42,6 +43,20 @@ export interface BuildChatModelOptions {
|
|
|
42
43
|
*/
|
|
43
44
|
readonly timeoutMs?: number;
|
|
44
45
|
readonly maxRetries?: number;
|
|
46
|
+
/**
|
|
47
|
+
* The execution's EFFECTIVE service tier (stigmer/stigmer#361) — already
|
|
48
|
+
* resolved by the caller (resolveEffectiveServiceTier), never
|
|
49
|
+
* UNSPECIFIED. When set, every provider request pins its tier explicitly
|
|
50
|
+
* (OpenAI `service_tier`; Anthropic `service_tier` via invocationKwargs)
|
|
51
|
+
* so the provider ACCOUNT's default can never pick the price — the #357
|
|
52
|
+
* contract, held on the native harness. Deliberately optional:
|
|
53
|
+
* platform-internal utility calls (tool-approval classification, session
|
|
54
|
+
* subjects, structured extraction, workflow llm_call) are not the
|
|
55
|
+
* execution's own turns and send no tier — the provider treats an absent
|
|
56
|
+
* parameter as its standard behavior, and those calls' models are
|
|
57
|
+
* platform-chosen economy models.
|
|
58
|
+
*/
|
|
59
|
+
readonly serviceTier?: EffectiveServiceTier;
|
|
45
60
|
}
|
|
46
61
|
export interface BuiltChatModel {
|
|
47
62
|
readonly model: BaseChatModel;
|
|
@@ -17,6 +17,8 @@ import { ChatOpenAI } from "@langchain/openai";
|
|
|
17
17
|
import { inferProvider, stripProviderPrefix, resolveProxyBaseUrl, buildProxyHeaders, } from "./llm-proxy.js";
|
|
18
18
|
import { resolveAnthropicBackend, checkVertexPrerequisites, checkBedrockPrerequisites, checkFoundryPrerequisites, toVertexModelId, toBedrockModelId, toFoundryDeploymentName, } from "./llm-backend.js";
|
|
19
19
|
import { resolveToApiModelId } from "./model-registry.js";
|
|
20
|
+
import { toAnthropicServiceTier, toOpenAiServiceTier, } from "./service-tier.js";
|
|
21
|
+
import { getRunnerSecret } from "./runner-credential-store.js";
|
|
20
22
|
/**
|
|
21
23
|
* The operator's request-timeout bound. Only a positive integer means
|
|
22
24
|
* "bound the request" — unset, non-numeric, zero, and negative all
|
|
@@ -63,11 +65,11 @@ export async function buildChatModel(opts) {
|
|
|
63
65
|
// tests. Prerequisites are re-checked here (not only in
|
|
64
66
|
// the factories' preflight) so paths that construct models without a
|
|
65
67
|
// runner factory still fail at dispatch with the catalog message instead
|
|
66
|
-
// of mid-request.
|
|
67
|
-
// standard conventions (GCP: CLOUD_ML_REGION + ADC; AWS: AWS_REGION +
|
|
68
|
-
// the credential chain
|
|
69
|
-
// ANTHROPIC_FOUNDRY_API_KEY
|
|
70
|
-
//
|
|
68
|
+
// of mid-request. Ambient credentials are read natively by each SDK from
|
|
69
|
+
// its standard conventions (GCP: CLOUD_ML_REGION + ADC; AWS: AWS_REGION +
|
|
70
|
+
// the credential chain); runner-held keys (AWS_BEARER_TOKEN_BEDROCK,
|
|
71
|
+
// ANTHROPIC_FOUNDRY_API_KEY) are passed explicitly from the credential
|
|
72
|
+
// store because the boot capture empties their env slots (#508).
|
|
71
73
|
let backendCreateClient;
|
|
72
74
|
let wireModelId = apiModelId;
|
|
73
75
|
let maxTokens = opts.maxTokens;
|
|
@@ -84,7 +86,16 @@ export async function buildChatModel(opts) {
|
|
|
84
86
|
if (prereq !== null)
|
|
85
87
|
throw new Error(prereq);
|
|
86
88
|
const { AnthropicBedrock } = await import("@anthropic-ai/bedrock-sdk");
|
|
87
|
-
|
|
89
|
+
// The SDK's own default for `apiKey` is process.env.AWS_BEARER_TOKEN_BEDROCK,
|
|
90
|
+
// which the boot capture has emptied (#508) — hand it the stored value
|
|
91
|
+
// explicitly. `undefined` when absent preserves the SDK's fallthrough to
|
|
92
|
+
// the ambient AWS credential chain (env keys, IRSA, config files).
|
|
93
|
+
const bedrockBearerToken = getRunnerSecret("AWS_BEARER_TOKEN_BEDROCK");
|
|
94
|
+
backendCreateClient = (options) => new AnthropicBedrock({
|
|
95
|
+
apiKey: bedrockBearerToken,
|
|
96
|
+
maxRetries: options.maxRetries,
|
|
97
|
+
timeout: options.timeout,
|
|
98
|
+
});
|
|
88
99
|
wireModelId = toBedrockModelId(apiModelId);
|
|
89
100
|
if (maxTokens === undefined) {
|
|
90
101
|
// LangChain's per-model maxTokens table prefix-matches the model
|
|
@@ -115,15 +126,20 @@ export async function buildChatModel(opts) {
|
|
|
115
126
|
// so refreshed tokens flow without reconstruction (pinned by
|
|
116
127
|
// foundry-seam.test.ts). Endpoint (resource or base URL) and the key
|
|
117
128
|
// are read natively by the SDK from its own env vars.
|
|
129
|
+
// The SDK's own default for `apiKey` is process.env.ANTHROPIC_FOUNDRY_API_KEY,
|
|
130
|
+
// which the boot capture has emptied (#508) — resolve it from the store
|
|
131
|
+
// and hand it over explicitly. The either/or stays intact: exactly one of
|
|
132
|
+
// apiKey / azureADTokenProvider reaches the constructor.
|
|
133
|
+
const foundryApiKey = getRunnerSecret("ANTHROPIC_FOUNDRY_API_KEY")?.trim() || undefined;
|
|
118
134
|
let azureADTokenProvider;
|
|
119
|
-
if (!
|
|
135
|
+
if (!foundryApiKey) {
|
|
120
136
|
const { DefaultAzureCredential, getBearerTokenProvider } = await import("@azure/identity");
|
|
121
137
|
azureADTokenProvider = getBearerTokenProvider(new DefaultAzureCredential(), "https://ai.azure.com/.default");
|
|
122
138
|
}
|
|
123
139
|
backendCreateClient = (options) => new AnthropicFoundry({
|
|
124
140
|
maxRetries: options.maxRetries,
|
|
125
141
|
timeout: options.timeout,
|
|
126
|
-
...(
|
|
142
|
+
...(foundryApiKey ? { apiKey: foundryApiKey } : { azureADTokenProvider }),
|
|
127
143
|
});
|
|
128
144
|
// Unlike the vertex/bedrock ids, the deployment name needs no maxTokens
|
|
129
145
|
// handling: stripping the snapshot date preserves LangChain's per-model
|
|
@@ -137,18 +153,26 @@ export async function buildChatModel(opts) {
|
|
|
137
153
|
const headers = opts.proxyEndpoint && opts.stigmerToken
|
|
138
154
|
? buildProxyHeaders(opts.stigmerToken, opts.headerScope ?? {})
|
|
139
155
|
: undefined;
|
|
140
|
-
// Proxy mode authenticates with the Stigmer token; direct mode falls back
|
|
141
|
-
// the provider's own
|
|
156
|
+
// Proxy mode authenticates with the Stigmer token; direct mode falls back
|
|
157
|
+
// to the provider's own key, resolved from the credential store (the boot
|
|
158
|
+
// capture moved it out of process.env, #508).
|
|
142
159
|
const apiKey = opts.proxyEndpoint
|
|
143
160
|
? (opts.stigmerToken ?? "proxy-managed")
|
|
144
161
|
: provider === "openai"
|
|
145
|
-
? (
|
|
146
|
-
: (
|
|
162
|
+
? (getRunnerSecret("OPENAI_API_KEY") ?? "")
|
|
163
|
+
: (getRunnerSecret("ANTHROPIC_API_KEY") ?? "");
|
|
164
|
+
// maxRetries applies when a timeout is bound (a retry loop under a bound
|
|
165
|
+
// multiplies the wall-clock budget) or when the caller pinned it
|
|
166
|
+
// explicitly (call-llm hands retry ownership to Temporal, #686). Callers
|
|
167
|
+
// that set neither keep LangChain's default retry behavior unchanged.
|
|
168
|
+
const maxRetries = timeoutMs !== undefined || opts.maxRetries !== undefined
|
|
169
|
+
? { maxRetries: opts.maxRetries ?? 0 }
|
|
170
|
+
: {};
|
|
147
171
|
const common = {
|
|
148
172
|
temperature: opts.temperature ?? 0,
|
|
149
173
|
apiKey,
|
|
150
174
|
...(maxTokens ? { maxTokens } : {}),
|
|
151
|
-
...
|
|
175
|
+
...maxRetries,
|
|
152
176
|
};
|
|
153
177
|
// The request timeout lives in a different slot per wrapper: ChatOpenAI
|
|
154
178
|
// reads `timeout` as a constructor field, but ChatAnthropic ignores it
|
|
@@ -168,6 +192,17 @@ export async function buildChatModel(opts) {
|
|
|
168
192
|
const anthropicClientOptionsField = Object.keys(anthropicClientOptions).length > 0
|
|
169
193
|
? { clientOptions: anthropicClientOptions }
|
|
170
194
|
: {};
|
|
195
|
+
// The tier rides the request body per provider dialect (#361): OpenAI
|
|
196
|
+
// takes `service_tier` as a first-class constructor field; ChatAnthropic
|
|
197
|
+
// has no such field, so it rides `invocationKwargs`, which the wrapper
|
|
198
|
+
// spreads into every request body. Both spellings resolve through the
|
|
199
|
+
// shared mapping so no construction site can invent a third one.
|
|
200
|
+
const openAiServiceTierField = opts.serviceTier !== undefined
|
|
201
|
+
? { service_tier: toOpenAiServiceTier(opts.serviceTier) }
|
|
202
|
+
: {};
|
|
203
|
+
const anthropicServiceTierField = opts.serviceTier !== undefined
|
|
204
|
+
? { invocationKwargs: { service_tier: toAnthropicServiceTier(opts.serviceTier) } }
|
|
205
|
+
: {};
|
|
171
206
|
// The two SDKs name the transport-override block differently (OpenAI:
|
|
172
207
|
// `configuration`, Anthropic: `clientOptions`) — encapsulating that here is
|
|
173
208
|
// the whole point, since the shape mismatch is where bugs used to hide.
|
|
@@ -175,6 +210,7 @@ export async function buildChatModel(opts) {
|
|
|
175
210
|
? new ChatOpenAI({
|
|
176
211
|
model: apiModelId,
|
|
177
212
|
...common,
|
|
213
|
+
...openAiServiceTierField,
|
|
178
214
|
...(timeoutMs ? { timeout: timeoutMs } : {}),
|
|
179
215
|
...(baseUrl || headers
|
|
180
216
|
? {
|
|
@@ -192,6 +228,13 @@ export async function buildChatModel(opts) {
|
|
|
192
228
|
// provided) is what lets this construct with no ANTHROPIC_API_KEY.
|
|
193
229
|
// (Backend mode never has a proxy — see the precedence rule above —
|
|
194
230
|
// so the clientOptions here carry at most the timeout.)
|
|
231
|
+
//
|
|
232
|
+
// service_tier deliberately does NOT ride backend requests:
|
|
233
|
+
// standard/priority tiers are an Anthropic-FIRST-PARTY billing
|
|
234
|
+
// concept, and Vertex/Bedrock/Foundry bill through the cloud
|
|
235
|
+
// provider with no tier dimension — an unknown body param there is
|
|
236
|
+
// a request refusal waiting to happen. The account-default price
|
|
237
|
+
// hole this parameter closes does not exist on those backends.
|
|
195
238
|
new ChatAnthropic({
|
|
196
239
|
model: wireModelId,
|
|
197
240
|
...common,
|
|
@@ -201,6 +244,7 @@ export async function buildChatModel(opts) {
|
|
|
201
244
|
: new ChatAnthropic({
|
|
202
245
|
model: apiModelId,
|
|
203
246
|
...common,
|
|
247
|
+
...anthropicServiceTierField,
|
|
204
248
|
...anthropicClientOptionsField,
|
|
205
249
|
});
|
|
206
250
|
return { model, provider, apiModelId };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-client.js","sourceRoot":"","sources":["../../src/shared/model-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"model-client.js","sourceRoot":"","sources":["../../src/shared/model-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,yBAAyB,EACzB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAA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 export declare function resolveRegistryBaseUrl(env?: NodeJS.ProcessEnv): string;
|
|
|
46
46
|
/**
|
|
47
47
|
* Build request headers for registry fetches: bearer auth when a token is
|
|
48
48
|
* present (cloud requires it; the local server ignores it).
|
|
49
|
+
*
|
|
50
|
+
* The default env is the credential-store view, not bare `process.env`:
|
|
51
|
+
* both token names are captured out of the environment at boot (#508), and
|
|
52
|
+
* the store also carries rotated tokens (manager updateToken / static
|
|
53
|
+
* renewal) that never touch env at all.
|
|
49
54
|
*/
|
|
50
55
|
export declare function buildRegistryHeaders(env?: NodeJS.ProcessEnv): Record<string, string>;
|
|
51
56
|
/** Full URL of the model registry endpoint for the resolved control plane. */
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* API would only mask misconfiguration (and breaks offline/local use).
|
|
20
20
|
*/
|
|
21
21
|
import { normalizeEndpoint } from "../config.js";
|
|
22
|
+
import { runnerSecretsEnvView } from "./runner-credential-store.js";
|
|
22
23
|
/** Default local stigmer-server origin — mirrors config.ts's local-mode default. */
|
|
23
24
|
const DEFAULT_LOCAL_BACKEND = "http://localhost:7234";
|
|
24
25
|
/**
|
|
@@ -62,8 +63,13 @@ export function resolveRegistryBaseUrl(env = process.env) {
|
|
|
62
63
|
/**
|
|
63
64
|
* Build request headers for registry fetches: bearer auth when a token is
|
|
64
65
|
* present (cloud requires it; the local server ignores it).
|
|
66
|
+
*
|
|
67
|
+
* The default env is the credential-store view, not bare `process.env`:
|
|
68
|
+
* both token names are captured out of the environment at boot (#508), and
|
|
69
|
+
* the store also carries rotated tokens (manager updateToken / static
|
|
70
|
+
* renewal) that never touch env at all.
|
|
65
71
|
*/
|
|
66
|
-
export function buildRegistryHeaders(env =
|
|
72
|
+
export function buildRegistryHeaders(env = runnerSecretsEnvView()) {
|
|
67
73
|
const token = env.STIGMER_TOKEN ?? env.STIGMER_AUTH_TOKEN;
|
|
68
74
|
return token ? { Authorization: `Bearer ${token}` } : {};
|
|
69
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry-endpoint.js","sourceRoot":"","sources":["../../src/shared/registry-endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"registry-endpoint.js","sourceRoot":"","sources":["../../src/shared/registry-endpoint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,oFAAoF;AACpF,MAAM,qBAAqB,GAAG,uBAAuB,CAAC;AAEtD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAqB;IACrD,KAAK,EAAE,mBAAmB;IAC1B,WAAW,EAAE,GAAG;IAChB,aAAa,EAAE,CAAC;IAChB,UAAU,EAAE,CAAC;IACb,gBAAgB,EAAE,MAAM;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACzE,MAAM,QAAQ,GAAG,GAAG,CAAC,qBAAqB,CAAC;IAC3C,IAAI,QAAQ;QAAE,OAAO,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAEjD,MAAM,aAAa,GAAG,GAAG,CAAC,sBAAsB,CAAC;IACjD,IAAI,aAAa;QAAE,OAAO,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAE3D,OAAO,iBAAiB,CAAC,GAAG,CAAC,wBAAwB,IAAI,qBAAqB,CAAC,CAAC;AAClF,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAClC,MAAyB,oBAAoB,EAAE;IAE/C,MAAM,KAAK,GAAG,GAAG,CAAC,aAAa,IAAI,GAAG,CAAC,kBAAkB,CAAC;IAC1D,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,UAAU,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3D,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,uBAAuB,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC1E,OAAO,GAAG,sBAAsB,CAAC,GAAG,CAAC,0BAA0B,CAAC;AAClE,CAAC"}
|
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
* their sanctioned delivery channel, and denying them here would break it.
|
|
11
11
|
*
|
|
12
12
|
* Consumers:
|
|
13
|
-
* -
|
|
13
|
+
* - runner-credential-store.ts: captures every name listed in this module
|
|
14
|
+
* out of `process.env` at boot (issue #508 — the Cursor SDK's local agent
|
|
15
|
+
* runtime runs in-process and its shell tool spawns from the runner's own
|
|
16
|
+
* env, so credentials must not LIVE there; see that module for custody
|
|
17
|
+
* rules).
|
|
18
|
+
* - shell-env.ts: SHELL_ENV_DENYLIST for the native harness `execute` tool
|
|
19
|
+
* (defense-in-depth behind the boot scrub).
|
|
14
20
|
* - mcp-manager.test.ts: leak-tripwire canaries for MCP stdio subprocesses
|
|
15
21
|
* (that path passes NO runner env by construction; the test plants these
|
|
16
22
|
* names to prove none leak through).
|
|
@@ -22,3 +28,22 @@
|
|
|
22
28
|
* credential files off disk regardless (owner ruling on #385).
|
|
23
29
|
*/
|
|
24
30
|
export declare const RUNNER_CREDENTIAL_ENV_KEYS: readonly string[];
|
|
31
|
+
/**
|
|
32
|
+
* Env var names of the runner's non-credential secrets — material that is
|
|
33
|
+
* not an outbound-call credential (so it does not belong in
|
|
34
|
+
* {@link RUNNER_CREDENTIAL_ENV_KEYS}, whose inclusion rule is pinned above)
|
|
35
|
+
* but is every bit as sensitive in an agent-readable environment
|
|
36
|
+
* (owner ruling on #508: same boot scrub, separate constant so the #385
|
|
37
|
+
* rule keeps its meaning).
|
|
38
|
+
*
|
|
39
|
+
* The `*_KEY_ID` companions are deliberately absent: key identifiers are
|
|
40
|
+
* rotation bookkeeping, not secrets.
|
|
41
|
+
*/
|
|
42
|
+
export declare const RUNNER_ENCRYPTION_ENV_KEYS: readonly string[];
|
|
43
|
+
/**
|
|
44
|
+
* Every env name whose VALUE the credential store takes custody of at boot:
|
|
45
|
+
* the #385 credential set plus the #508 encryption-key set. This is the
|
|
46
|
+
* scrub list — after `captureRunnerSecrets()`, none of these names remain
|
|
47
|
+
* in `process.env`.
|
|
48
|
+
*/
|
|
49
|
+
export declare const RUNNER_SECRET_ENV_KEYS: readonly string[];
|
|
@@ -10,7 +10,13 @@
|
|
|
10
10
|
* their sanctioned delivery channel, and denying them here would break it.
|
|
11
11
|
*
|
|
12
12
|
* Consumers:
|
|
13
|
-
* -
|
|
13
|
+
* - runner-credential-store.ts: captures every name listed in this module
|
|
14
|
+
* out of `process.env` at boot (issue #508 — the Cursor SDK's local agent
|
|
15
|
+
* runtime runs in-process and its shell tool spawns from the runner's own
|
|
16
|
+
* env, so credentials must not LIVE there; see that module for custody
|
|
17
|
+
* rules).
|
|
18
|
+
* - shell-env.ts: SHELL_ENV_DENYLIST for the native harness `execute` tool
|
|
19
|
+
* (defense-in-depth behind the boot scrub).
|
|
14
20
|
* - mcp-manager.test.ts: leak-tripwire canaries for MCP stdio subprocesses
|
|
15
21
|
* (that path passes NO runner env by construction; the test plants these
|
|
16
22
|
* names to prove none leak through).
|
|
@@ -44,4 +50,31 @@ export const RUNNER_CREDENTIAL_ENV_KEYS = [
|
|
|
44
50
|
// (llm-backend.ts documents it as a supported auth path).
|
|
45
51
|
"AWS_BEARER_TOKEN_BEDROCK",
|
|
46
52
|
];
|
|
53
|
+
/**
|
|
54
|
+
* Env var names of the runner's non-credential secrets — material that is
|
|
55
|
+
* not an outbound-call credential (so it does not belong in
|
|
56
|
+
* {@link RUNNER_CREDENTIAL_ENV_KEYS}, whose inclusion rule is pinned above)
|
|
57
|
+
* but is every bit as sensitive in an agent-readable environment
|
|
58
|
+
* (owner ruling on #508: same boot scrub, separate constant so the #385
|
|
59
|
+
* rule keeps its meaning).
|
|
60
|
+
*
|
|
61
|
+
* The `*_KEY_ID` companions are deliberately absent: key identifiers are
|
|
62
|
+
* rotation bookkeeping, not secrets.
|
|
63
|
+
*/
|
|
64
|
+
export const RUNNER_ENCRYPTION_ENV_KEYS = [
|
|
65
|
+
// Temporal payload-encryption keys (encryption/config.ts). An agent that
|
|
66
|
+
// reads these could decrypt the runner's Temporal history payloads.
|
|
67
|
+
"STIGMER_PAYLOAD_ENCRYPTION_KEY",
|
|
68
|
+
"STIGMER_PAYLOAD_ENCRYPTION_SECONDARY_KEY",
|
|
69
|
+
];
|
|
70
|
+
/**
|
|
71
|
+
* Every env name whose VALUE the credential store takes custody of at boot:
|
|
72
|
+
* the #385 credential set plus the #508 encryption-key set. This is the
|
|
73
|
+
* scrub list — after `captureRunnerSecrets()`, none of these names remain
|
|
74
|
+
* in `process.env`.
|
|
75
|
+
*/
|
|
76
|
+
export const RUNNER_SECRET_ENV_KEYS = [
|
|
77
|
+
...RUNNER_CREDENTIAL_ENV_KEYS,
|
|
78
|
+
...RUNNER_ENCRYPTION_ENV_KEYS,
|
|
79
|
+
];
|
|
47
80
|
//# sourceMappingURL=runner-credential-keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner-credential-keys.js","sourceRoot":"","sources":["../../src/shared/runner-credential-keys.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runner-credential-keys.js","sourceRoot":"","sources":["../../src/shared/runner-credential-keys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,wEAAwE;IACxE,iDAAiD;IACjD,4BAA4B;IAC5B,+DAA+D;IAC/D,sEAAsE;IACtE,eAAe;IACf,gEAAgE;IAChE,iDAAiD;IACjD,oBAAoB;IACpB,wEAAwE;IACxE,iCAAiC;IACjC,gBAAgB;IAChB,sEAAsE;IACtE,mBAAmB;IACnB,mEAAmE;IACnE,gBAAgB;IAChB,kDAAkD;IAClD,2BAA2B;IAC3B,iEAAiE;IACjE,0DAA0D;IAC1D,0BAA0B;CAC3B,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAsB;IAC3D,yEAAyE;IACzE,oEAAoE;IACpE,gCAAgC;IAChC,0CAA0C;CAC3C,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAsB;IACvD,GAAG,0BAA0B;IAC7B,GAAG,0BAA0B;CAC9B,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custody point for the runner's own secrets — the VALUES companion to
|
|
3
|
+
* runner-credential-keys.ts's names (issue #508).
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: the Cursor SDK's local agent runtime ships inside
|
|
6
|
+
* `@cursor/sdk` and runs IN-PROCESS in the runner. Its shell tool spawns
|
|
7
|
+
* bash with `{...process.env, ...}` and its git layer does the same, so
|
|
8
|
+
* anything living in the runner's `process.env` is readable by every shell
|
|
9
|
+
* command the agent runs — and the SDK exposes no env option for local
|
|
10
|
+
* agents to scrub at the spawn boundary. Denylists on runner-owned spawn
|
|
11
|
+
* sites (shell-env.ts) cannot reach those vendor spawns. The only fix that
|
|
12
|
+
* covers every spawn surface, present and future, is for secrets not to
|
|
13
|
+
* LIVE in `process.env` at all: this module captures them at boot and is
|
|
14
|
+
* the sole holder afterwards.
|
|
15
|
+
*
|
|
16
|
+
* Custody rules:
|
|
17
|
+
*
|
|
18
|
+
* 1. `captureRunnerSecrets()` runs at every boot door (both public runner
|
|
19
|
+
* factories, plus main() for symmetry) — it MOVES every
|
|
20
|
+
* {@link RUNNER_SECRET_ENV_KEYS} value out of `process.env` into a
|
|
21
|
+
* module-private map. Idempotent; first call wins.
|
|
22
|
+
* 2. Reads go through {@link getRunnerSecret}: captured value first, live
|
|
23
|
+
* `process.env` as fallback. The fallback keeps the store honest rather
|
|
24
|
+
* than frozen — production sets these vars only at process start (the
|
|
25
|
+
* capture window), so the fallback is a dead path there, but tests and
|
|
26
|
+
* unusual embedders that plant a value later see it behave exactly like
|
|
27
|
+
* the env read it replaced.
|
|
28
|
+
* 3. Rotation writes go through {@link setRunnerSecret} (the
|
|
29
|
+
* runner-manager/static-renewal token channel that previously wrote
|
|
30
|
+
* `process.env.STIGMER_TOKEN` in lockstep with its tokenRef).
|
|
31
|
+
* 4. {@link runnerSecretsEnvView} adapts the store to the codebase's
|
|
32
|
+
* `env: NodeJS.ProcessEnv` injection seams (llm-backend,
|
|
33
|
+
* registry-endpoint). The view re-merges secrets over `process.env` —
|
|
34
|
+
* it exists for in-process CONFIG READS ONLY and must never be handed
|
|
35
|
+
* to a child process env or any spawn options.
|
|
36
|
+
*
|
|
37
|
+
* Embedder note: `@stigmer/runner` is a public library, and capture runs
|
|
38
|
+
* inside the factories, so embedding the runner scrubs the HOST process's
|
|
39
|
+
* env of runner secrets at boot. That is the point — agent shells run in
|
|
40
|
+
* the embedder's process — and host code that still needs a value reads it
|
|
41
|
+
* through this module.
|
|
42
|
+
*/
|
|
43
|
+
/**
|
|
44
|
+
* Move every {@link RUNNER_SECRET_ENV_KEYS} value out of `process.env` into
|
|
45
|
+
* the store. Idempotent — only the first call captures, so a late caller
|
|
46
|
+
* cannot re-freeze values that rotation has since replaced.
|
|
47
|
+
*/
|
|
48
|
+
export declare function captureRunnerSecrets(): void;
|
|
49
|
+
/**
|
|
50
|
+
* Read a runner secret: captured value first, live `process.env` fallback
|
|
51
|
+
* (see custody rule 2). Returns `undefined` when the secret is absent —
|
|
52
|
+
* callers own their missing-secret reaction, exactly as with the env reads
|
|
53
|
+
* this replaces.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getRunnerSecret(name: string): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Write (or with `null`, clear) a runner secret — the rotation channel.
|
|
58
|
+
* Ensures capture has run first so a rotated value can never sit in
|
|
59
|
+
* `process.env` because a writer beat the boot capture.
|
|
60
|
+
*/
|
|
61
|
+
export declare function setRunnerSecret(name: string, value: string | null): void;
|
|
62
|
+
/**
|
|
63
|
+
* `process.env` with the captured secrets merged back over it — an adapter
|
|
64
|
+
* for the `env: NodeJS.ProcessEnv` injection seams so their defaults stay
|
|
65
|
+
* secret-aware after the boot scrub.
|
|
66
|
+
*
|
|
67
|
+
* IN-PROCESS CONFIG READS ONLY: never pass this to a spawn/exec env, a
|
|
68
|
+
* worker thread, or anything else that leaves the process — doing so would
|
|
69
|
+
* reopen exactly the leak the store closes.
|
|
70
|
+
*/
|
|
71
|
+
export declare function runnerSecretsEnvView(): NodeJS.ProcessEnv;
|
|
72
|
+
/**
|
|
73
|
+
* Test-only: forget everything captured and re-arm capture. Unit tests that
|
|
74
|
+
* plant secret env vars and boot pieces of the runner need each test to see
|
|
75
|
+
* its own values.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resetRunnerSecretsForTests(): void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custody point for the runner's own secrets — the VALUES companion to
|
|
3
|
+
* runner-credential-keys.ts's names (issue #508).
|
|
4
|
+
*
|
|
5
|
+
* Why this exists: the Cursor SDK's local agent runtime ships inside
|
|
6
|
+
* `@cursor/sdk` and runs IN-PROCESS in the runner. Its shell tool spawns
|
|
7
|
+
* bash with `{...process.env, ...}` and its git layer does the same, so
|
|
8
|
+
* anything living in the runner's `process.env` is readable by every shell
|
|
9
|
+
* command the agent runs — and the SDK exposes no env option for local
|
|
10
|
+
* agents to scrub at the spawn boundary. Denylists on runner-owned spawn
|
|
11
|
+
* sites (shell-env.ts) cannot reach those vendor spawns. The only fix that
|
|
12
|
+
* covers every spawn surface, present and future, is for secrets not to
|
|
13
|
+
* LIVE in `process.env` at all: this module captures them at boot and is
|
|
14
|
+
* the sole holder afterwards.
|
|
15
|
+
*
|
|
16
|
+
* Custody rules:
|
|
17
|
+
*
|
|
18
|
+
* 1. `captureRunnerSecrets()` runs at every boot door (both public runner
|
|
19
|
+
* factories, plus main() for symmetry) — it MOVES every
|
|
20
|
+
* {@link RUNNER_SECRET_ENV_KEYS} value out of `process.env` into a
|
|
21
|
+
* module-private map. Idempotent; first call wins.
|
|
22
|
+
* 2. Reads go through {@link getRunnerSecret}: captured value first, live
|
|
23
|
+
* `process.env` as fallback. The fallback keeps the store honest rather
|
|
24
|
+
* than frozen — production sets these vars only at process start (the
|
|
25
|
+
* capture window), so the fallback is a dead path there, but tests and
|
|
26
|
+
* unusual embedders that plant a value later see it behave exactly like
|
|
27
|
+
* the env read it replaced.
|
|
28
|
+
* 3. Rotation writes go through {@link setRunnerSecret} (the
|
|
29
|
+
* runner-manager/static-renewal token channel that previously wrote
|
|
30
|
+
* `process.env.STIGMER_TOKEN` in lockstep with its tokenRef).
|
|
31
|
+
* 4. {@link runnerSecretsEnvView} adapts the store to the codebase's
|
|
32
|
+
* `env: NodeJS.ProcessEnv` injection seams (llm-backend,
|
|
33
|
+
* registry-endpoint). The view re-merges secrets over `process.env` —
|
|
34
|
+
* it exists for in-process CONFIG READS ONLY and must never be handed
|
|
35
|
+
* to a child process env or any spawn options.
|
|
36
|
+
*
|
|
37
|
+
* Embedder note: `@stigmer/runner` is a public library, and capture runs
|
|
38
|
+
* inside the factories, so embedding the runner scrubs the HOST process's
|
|
39
|
+
* env of runner secrets at boot. That is the point — agent shells run in
|
|
40
|
+
* the embedder's process — and host code that still needs a value reads it
|
|
41
|
+
* through this module.
|
|
42
|
+
*/
|
|
43
|
+
import { RUNNER_SECRET_ENV_KEYS } from "./runner-credential-keys.js";
|
|
44
|
+
const captured = new Map();
|
|
45
|
+
let captureRan = false;
|
|
46
|
+
/**
|
|
47
|
+
* Move every {@link RUNNER_SECRET_ENV_KEYS} value out of `process.env` into
|
|
48
|
+
* the store. Idempotent — only the first call captures, so a late caller
|
|
49
|
+
* cannot re-freeze values that rotation has since replaced.
|
|
50
|
+
*/
|
|
51
|
+
export function captureRunnerSecrets() {
|
|
52
|
+
if (captureRan)
|
|
53
|
+
return;
|
|
54
|
+
captureRan = true;
|
|
55
|
+
for (const name of RUNNER_SECRET_ENV_KEYS) {
|
|
56
|
+
const value = process.env[name];
|
|
57
|
+
if (value !== undefined) {
|
|
58
|
+
captured.set(name, value);
|
|
59
|
+
delete process.env[name];
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Read a runner secret: captured value first, live `process.env` fallback
|
|
65
|
+
* (see custody rule 2). Returns `undefined` when the secret is absent —
|
|
66
|
+
* callers own their missing-secret reaction, exactly as with the env reads
|
|
67
|
+
* this replaces.
|
|
68
|
+
*/
|
|
69
|
+
export function getRunnerSecret(name) {
|
|
70
|
+
return captured.get(name) ?? process.env[name];
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Write (or with `null`, clear) a runner secret — the rotation channel.
|
|
74
|
+
* Ensures capture has run first so a rotated value can never sit in
|
|
75
|
+
* `process.env` because a writer beat the boot capture.
|
|
76
|
+
*/
|
|
77
|
+
export function setRunnerSecret(name, value) {
|
|
78
|
+
captureRunnerSecrets();
|
|
79
|
+
if (value === null) {
|
|
80
|
+
captured.delete(name);
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
captured.set(name, value);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* `process.env` with the captured secrets merged back over it — an adapter
|
|
88
|
+
* for the `env: NodeJS.ProcessEnv` injection seams so their defaults stay
|
|
89
|
+
* secret-aware after the boot scrub.
|
|
90
|
+
*
|
|
91
|
+
* IN-PROCESS CONFIG READS ONLY: never pass this to a spawn/exec env, a
|
|
92
|
+
* worker thread, or anything else that leaves the process — doing so would
|
|
93
|
+
* reopen exactly the leak the store closes.
|
|
94
|
+
*/
|
|
95
|
+
export function runnerSecretsEnvView() {
|
|
96
|
+
const view = { ...process.env };
|
|
97
|
+
for (const [name, value] of captured) {
|
|
98
|
+
view[name] = value;
|
|
99
|
+
}
|
|
100
|
+
return view;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Test-only: forget everything captured and re-arm capture. Unit tests that
|
|
104
|
+
* plant secret env vars and boot pieces of the runner need each test to see
|
|
105
|
+
* its own values.
|
|
106
|
+
*/
|
|
107
|
+
export function resetRunnerSecretsForTests() {
|
|
108
|
+
captured.clear();
|
|
109
|
+
captureRan = false;
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=runner-credential-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-credential-store.js","sourceRoot":"","sources":["../../src/shared/runner-credential-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;AAC3C,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB;;;;GAIG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,UAAU;QAAE,OAAO;IACvB,UAAU,GAAG,IAAI,CAAC;IAClB,KAAK,MAAM,IAAI,IAAI,sBAAsB,EAAE,CAAC;QAC1C,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AACjD,CAAC;AAED;;;;GAIG;A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